From 0869265d66a3a6cfd0b9a7498057903d72eb2d8a Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 16 Mar 2022 16:36:49 +0900 Subject: [PATCH] bdev/nvme: Factor out searching io_path operation from find_io_path() Signed-off-by: Shuhei Matsumoto Change-Id: I26939b39cfd4b92bdbc1d4ef10961ba35145043c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12000 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Dong Yi Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- module/bdev/nvme/bdev_nvme.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index e95103b61..339e14263 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -825,15 +825,11 @@ nvme_ctrlr_is_available(struct nvme_ctrlr *nvme_ctrlr) return true; } -static inline struct nvme_io_path * -bdev_nvme_find_io_path(struct nvme_bdev_channel *nbdev_ch) +static struct nvme_io_path * +_bdev_nvme_find_io_path(struct nvme_bdev_channel *nbdev_ch) { struct nvme_io_path *io_path, *non_optimized = NULL; - if (spdk_likely(nbdev_ch->current_io_path != NULL)) { - return nbdev_ch->current_io_path; - } - STAILQ_FOREACH(io_path, &nbdev_ch->io_path_list, stailq) { if (spdk_unlikely(!nvme_io_path_is_connected(io_path))) { /* The device is currently resetting. */ @@ -861,6 +857,16 @@ bdev_nvme_find_io_path(struct nvme_bdev_channel *nbdev_ch) return non_optimized; } +static inline struct nvme_io_path * +bdev_nvme_find_io_path(struct nvme_bdev_channel *nbdev_ch) +{ + if (spdk_unlikely(nbdev_ch->current_io_path == NULL)) { + return _bdev_nvme_find_io_path(nbdev_ch); + } + + return nbdev_ch->current_io_path; +} + /* Return true if there is any io_path whose qpair is active or ctrlr is not failed, * or false otherwise. *