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

bdev/nvme: Factor out getting admin path into a helper function



Factor out the operation to get ctrlr pointer to submit an admin
command into a helper function bdev_nvme_find_admin_path().

This will make the following changes transparent.

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


Community-CI: Broadcom CI
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 42ae4267
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -3206,7 +3206,14 @@ static int
bdev_nvme_admin_passthru(struct nvme_io_channel *nvme_ch, struct nvme_bdev_io *bio,
			 struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes)
{
	uint32_t max_xfer_size = spdk_nvme_ctrlr_get_max_xfer_size(nvme_ch->ctrlr->ctrlr);
	struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
	uint32_t max_xfer_size;

	if (!bdev_nvme_find_admin_path(nvme_ch, &nvme_bdev_ctrlr)) {
		return -EINVAL;
	}

	max_xfer_size = spdk_nvme_ctrlr_get_max_xfer_size(nvme_bdev_ctrlr->ctrlr);

	if (nbytes > max_xfer_size) {
		SPDK_ERRLOG("nbytes is greater than MDTS %" PRIu32 ".\n", max_xfer_size);
@@ -3215,7 +3222,7 @@ bdev_nvme_admin_passthru(struct nvme_io_channel *nvme_ch, struct nvme_bdev_io *b

	bio->orig_thread = spdk_get_thread();

	return spdk_nvme_ctrlr_cmd_admin_raw(nvme_ch->ctrlr->ctrlr, cmd, buf,
	return spdk_nvme_ctrlr_cmd_admin_raw(nvme_bdev_ctrlr->ctrlr, cmd, buf,
					     (uint32_t)nbytes, bdev_nvme_admin_passthru_done, bio);
}

+8 −0
Original line number Diff line number Diff line
@@ -191,6 +191,14 @@ bdev_nvme_find_io_path(struct nvme_bdev *nbdev, struct nvme_io_channel *nvme_ch,
	return true;
}

static inline bool
bdev_nvme_find_admin_path(struct nvme_io_channel *nvme_ch,
			  struct nvme_bdev_ctrlr **_nvme_bdev_ctrlr)
{
	*_nvme_bdev_ctrlr = nvme_ch->ctrlr;
	return true;
}

static inline struct nvme_bdev_ns *
nvme_bdev_to_bdev_ns(struct nvme_bdev *nbdev)
{