diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 4f9eac413..85afd6b5f 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -574,9 +574,13 @@ _bdev_nvme_add_io_path(struct nvme_bdev_channel *nbdev_ch, struct nvme_ns *nvme_ } io_path->ctrlr_ch = spdk_io_channel_get_ctx(ch); + TAILQ_INSERT_TAIL(&io_path->ctrlr_ch->io_path_list, io_path, tailq); + io_path->nvme_ns = nvme_ns; + io_path->nbdev_ch = nbdev_ch; STAILQ_INSERT_TAIL(&nbdev_ch->io_path_list, io_path, stailq); + return 0; } @@ -587,6 +591,7 @@ _bdev_nvme_delete_io_path(struct nvme_bdev_channel *nbdev_ch, struct nvme_io_pat STAILQ_REMOVE(&nbdev_ch->io_path_list, io_path, nvme_io_path, stailq); + TAILQ_REMOVE(&io_path->ctrlr_ch->io_path_list, io_path, tailq); ch = spdk_io_channel_from_ctx(io_path->ctrlr_ch); spdk_put_io_channel(ch); @@ -1750,6 +1755,7 @@ bdev_nvme_create_ctrlr_channel_cb(void *io_device, void *ctx_buf) #endif TAILQ_INIT(&ctrlr_ch->pending_resets); + TAILQ_INIT(&ctrlr_ch->io_path_list); rc = bdev_nvme_create_qpair(ctrlr_ch); if (rc != 0) { diff --git a/module/bdev/nvme/bdev_nvme.h b/module/bdev/nvme/bdev_nvme.h index f1c1a73cf..a1c362caa 100644 --- a/module/bdev/nvme/bdev_nvme.h +++ b/module/bdev/nvme/bdev_nvme.h @@ -82,6 +82,7 @@ struct nvme_ns { struct nvme_bdev_io; struct nvme_bdev_ctrlr; struct nvme_bdev; +struct nvme_io_path; struct nvme_path_id { struct spdk_nvme_transport_id trid; @@ -164,6 +165,10 @@ struct nvme_ctrlr_channel { struct nvme_poll_group *group; TAILQ_HEAD(, spdk_bdev_io) pending_resets; TAILQ_ENTRY(nvme_ctrlr_channel) tailq; + + /* The following is used to update io_path cache of nvme_bdev_channels. */ + TAILQ_HEAD(, nvme_io_path) io_path_list; + }; #define nvme_ctrlr_channel_get_ctrlr(ctrlr_ch) \ @@ -173,6 +178,10 @@ struct nvme_io_path { struct nvme_ns *nvme_ns; struct nvme_ctrlr_channel *ctrlr_ch; STAILQ_ENTRY(nvme_io_path) stailq; + + /* The following are used to update io_path cache of the nvme_bdev_channel. */ + struct nvme_bdev_channel *nbdev_ch; + TAILQ_ENTRY(nvme_io_path) tailq; }; struct nvme_bdev_channel {