bdev/nvme: Refactor _bdev_nvme_find_io_path() to cache non-optimized path for active/active
nbdev_ch->current_io_path is NULL at initialization. bdev_nvme_find_io_path() calls _bdev_nvme_find_io_path() if nbdev_ch->current_io_path is NULL. If there is no optimized path, nbdev_ch->current_io_path is not filled. Hence, as long as there is no optimized path, bdev_nvme_find_next_io_path() is never called. However, bdev_nvme_find_next_io_path() fills nbdev_ch->current_io_path even if the found path is non optimized. This is a contradiction and a bug. To fix this bug, as a preparation, refactor _bdev_nvme_find_io_path() to cnosolidate bdev_nvme_find_next_io_path() and _bdev_nvme_find_io_path() into a single function because bdev_nvme_find_next_io_path() and _bdev_nvme_find_io_path() were almost identical. Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: I7bc4107ce6ae6f116dee03c9bb67d9e4061ce775 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16188 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Richael <richael.zhuang@arm.com>
This commit is contained in:
parent
ae620784bd
commit
7baa78c86c
@ -872,31 +872,29 @@ bdev_nvme_find_next_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;
|
||||
struct nvme_io_path *io_path, *start, *non_optimized = NULL;
|
||||
|
||||
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. */
|
||||
continue;
|
||||
}
|
||||
start = STAILQ_FIRST(&nbdev_ch->io_path_list);
|
||||
|
||||
if (spdk_unlikely(io_path->nvme_ns->ana_state_updating)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (io_path->nvme_ns->ana_state) {
|
||||
case SPDK_NVME_ANA_OPTIMIZED_STATE:
|
||||
nbdev_ch->current_io_path = io_path;
|
||||
return io_path;
|
||||
case SPDK_NVME_ANA_NON_OPTIMIZED_STATE:
|
||||
if (non_optimized == NULL) {
|
||||
non_optimized = io_path;
|
||||
io_path = start;
|
||||
do {
|
||||
if (spdk_likely(nvme_io_path_is_connected(io_path) &&
|
||||
!io_path->nvme_ns->ana_state_updating)) {
|
||||
switch (io_path->nvme_ns->ana_state) {
|
||||
case SPDK_NVME_ANA_OPTIMIZED_STATE:
|
||||
nbdev_ch->current_io_path = io_path;
|
||||
return io_path;
|
||||
case SPDK_NVME_ANA_NON_OPTIMIZED_STATE:
|
||||
if (non_optimized == NULL) {
|
||||
non_optimized = io_path;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
io_path = nvme_io_path_get_next(nbdev_ch, io_path);
|
||||
} while (io_path != start);
|
||||
|
||||
return non_optimized;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user