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: Shuhei 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: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Shuhei Matsumoto 2021-03-29 07:49:49 +09:00 committed by Tomasz Zawadzki
parent 42ae4267b6
commit e5cb3d3fba
2 changed files with 17 additions and 2 deletions

View File

@ -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);
}

View File

@ -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)
{