Commit 7baa78c8 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

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: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I7bc4107ce6ae6f116dee03c9bb67d9e4061ce775
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16188


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarRichael <richael.zhuang@arm.com>
parent ae620784
Loading
Loading
Loading
Loading
+19 −21
Original line number Diff line number Diff line
@@ -872,18 +872,14 @@ 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;

	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;
		}
	struct nvme_io_path *io_path, *start, *non_optimized = NULL;

		if (spdk_unlikely(io_path->nvme_ns->ana_state_updating)) {
			continue;
		}
	start = STAILQ_FIRST(&nbdev_ch->io_path_list);

	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;
@@ -897,6 +893,8 @@ _bdev_nvme_find_io_path(struct nvme_bdev_channel *nbdev_ch)
				break;
			}
		}
		io_path = nvme_io_path_get_next(nbdev_ch, io_path);
	} while (io_path != start);

	return non_optimized;
}