bdev/nvme: check bdev's module when setting multipath policy

We cannot try to set multipath policy on a non-nvme bdev.

While here, make the error messages match what we use for
setting preferred path.

Fixes issue #2543.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I823077f92634ee3c16e77e7e0d67eb343ec3584e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12916
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: <qun.wan@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
Jim Harris 2022-06-06 23:44:54 +00:00 committed by Konrad Sztyber
parent 9bb64b6b6e
commit 68108360f9

View File

@ -3813,12 +3813,17 @@ bdev_nvme_set_multipath_policy(const char *name, enum bdev_nvme_multipath_policy
rc = spdk_bdev_open_ext(name, false, dummy_bdev_event_cb, NULL, &ctx->desc);
if (rc != 0) {
SPDK_ERRLOG("bdev %s is not registered in this module.\n", name);
SPDK_ERRLOG("Failed to open bdev %s.\n", name);
rc = -ENODEV;
goto err_open;
}
bdev = spdk_bdev_desc_get_bdev(ctx->desc);
if (bdev->module != &nvme_if) {
SPDK_ERRLOG("bdev %s is not registered in this module.\n", name);
rc = -ENODEV;
goto err_module;
}
nbdev = SPDK_CONTAINEROF(bdev, struct nvme_bdev, disk);
pthread_mutex_lock(&nbdev->mutex);
@ -3831,6 +3836,8 @@ bdev_nvme_set_multipath_policy(const char *name, enum bdev_nvme_multipath_policy
bdev_nvme_set_multipath_policy_done);
return;
err_module:
spdk_bdev_close(ctx->desc);
err_open:
free(ctx);
err_alloc: