Commit 73b4b9ad authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev/nvme: Put all nvme_bdev_ctrlr accesses into a place in bdev_nvme_create_cb()



When multipath is supported, a subsystem has multiple controllers and
bdev_nvme_create_cb() will create a channel per nvme_bdev_ctrlr by
iterating the list of nvme_bdev_ctrlrs, and will hold lock while
doing it.

If the code to access nvme_bdev_ctrlr is put in a place, the
following patches will be easier and smaller.

Hence reorder the code of bdev_nvme_create_cb() as a preparation.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I2f2e66758c3374c678cc44bbb0116f4611c6753a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7754


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 81b4379c
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -980,20 +980,12 @@ bdev_nvme_create_cb(void *io_device, void *ctx_buf)
{
	struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = io_device;
	struct nvme_io_channel *nvme_ch = ctx_buf;
	struct spdk_io_channel *pg_ch = NULL;
	struct spdk_io_channel *pg_ch;
	int rc;

	if (spdk_nvme_ctrlr_is_ocssd_supported(nvme_bdev_ctrlr->ctrlr)) {
		rc = bdev_ocssd_create_io_channel(nvme_ch);
		if (rc != 0) {
			return rc;
		}
	}

	pg_ch = spdk_get_io_channel(&g_nvme_bdev_ctrlrs);
	if (!pg_ch) {
		rc = -1;
		goto err_pg_ch;
		return -1;
	}

	nvme_ch->group = spdk_io_channel_get_ctx(pg_ch);
@@ -1006,6 +998,13 @@ bdev_nvme_create_cb(void *io_device, void *ctx_buf)

	TAILQ_INIT(&nvme_ch->pending_resets);

	if (spdk_nvme_ctrlr_is_ocssd_supported(nvme_bdev_ctrlr->ctrlr)) {
		rc = bdev_ocssd_create_io_channel(nvme_ch);
		if (rc != 0) {
			goto err_ocssd_ch;
		}
	}

	nvme_ch->ctrlr = nvme_bdev_ctrlr;

	rc = bdev_nvme_create_qpair(nvme_ch);
@@ -1016,11 +1015,11 @@ bdev_nvme_create_cb(void *io_device, void *ctx_buf)
	return 0;

err_qpair:
	spdk_put_io_channel(pg_ch);
err_pg_ch:
	if (nvme_ch->ocssd_ch) {
		bdev_ocssd_destroy_io_channel(nvme_ch);
	}
err_ocssd_ch:
	spdk_put_io_channel(pg_ch);

	return rc;
}