From 32697257a986b914d2f820b2af1910d661aac48a Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 15 Oct 2021 17:10:42 +0900 Subject: [PATCH] bdev/nvme: ctrlr_channel has a list of io_path pointers This patch enables each nvme_ctrlr_channel to access the underlying nvme_bdev_channels. This change is used to maintain io_path cache of nvme_bdev_channel. Signed-off-by: Shuhei Matsumoto Change-Id: I22cd3763da1642d4e68dee3a9273e9cc698a4ca8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9893 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: GangCao Reviewed-by: Ben Walker Reviewed-by: Konrad Sztyber Reviewed-by: Aleksey Marchuk --- module/bdev/nvme/bdev_nvme.c | 6 ++++++ module/bdev/nvme/bdev_nvme.h | 9 +++++++++ 2 files changed, 15 insertions(+) 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 {