Skip to content

Commit

Permalink
bdev/nvme: check bdev's module when setting multipath policy
Browse files Browse the repository at this point in the history
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 spdk#2543.

Signed-off-by: Jim Harris <[email protected]>
Change-Id: I823077f92634ee3c16e77e7e0d67eb343ec3584e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12916
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <[email protected]>
Tested-by: SPDK CI Jenkins <[email protected]>
Reviewed-by: Shuhei Matsumoto <[email protected]>
Reviewed-by: Changpeng Liu <[email protected]>
Reviewed-by: Aleksey Marchuk <[email protected]>
Reviewed-by: <[email protected]>
Reviewed-by: Konrad Sztyber <[email protected]>
  • Loading branch information
jimharris authored and ksztyber committed Jun 8, 2022
1 parent 9bb64b6 commit 6810836
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion module/bdev/nvme/bdev_nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand Down

0 comments on commit 6810836

Please sign in to comment.