Commit 361bef31 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev/nvme: Consolidate io_path availability check of io_path_is_current()



io_path availability check was missing and error occurred. To avoid
similar error in future, consolidate io_path availability check to the
head of nvme_io_path_is_current().

About active/active case, checking if ana_state is optimal is more
intuitive than checking if ana_state is not non-optimal.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I2dcd10e04341962a8eddd84f5194bebd8bd6679b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23404


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 2e4f95fa
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -8538,6 +8538,10 @@ nvme_io_path_is_current(struct nvme_io_path *io_path)
	const struct nvme_bdev_channel *nbdev_ch;
	bool current;

	if (!nvme_io_path_is_available(io_path)) {
		return false;
	}

	nbdev_ch = io_path->nbdev_ch;
	if (nbdev_ch == NULL) {
		current = false;
@@ -8550,15 +8554,12 @@ nvme_io_path_is_current(struct nvme_io_path *io_path)
			}
		}

		current = nvme_io_path_is_available(io_path);
		if (io_path->nvme_ns->ana_state == SPDK_NVME_ANA_NON_OPTIMIZED_STATE) {
		/* A non-optimized path is only current if there are no optimized paths. */
			current = current && (optimized_io_path == NULL);
		}
		current = (io_path->nvme_ns->ana_state == SPDK_NVME_ANA_OPTIMIZED_STATE) ||
			  (optimized_io_path == NULL);
	} else {
		if (nbdev_ch->current_io_path) {
			current = nvme_io_path_is_available(io_path) &&
				  (io_path == nbdev_ch->current_io_path);
			current = (io_path == nbdev_ch->current_io_path);
		} else {
			struct nvme_io_path *first_path;