module/bdev/compress: print a reasonable message on create error
Specifically when a compress bdev already exists on the supplied base. Before this you'd get a bunch of nasty messages providing really no clue as to what was wrong. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: I8cce8902909659fba0e9613891c7ef8ebe4b06d0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11806 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
84257185a4
commit
89ee5a13bf
@ -1525,11 +1525,19 @@ comp_bdev_ch_destroy_cb(void *io_device, void *ctx_buf)
|
|||||||
int
|
int
|
||||||
create_compress_bdev(const char *bdev_name, const char *pm_path, uint32_t lb_size)
|
create_compress_bdev(const char *bdev_name, const char *pm_path, uint32_t lb_size)
|
||||||
{
|
{
|
||||||
|
struct vbdev_compress *comp_bdev = NULL;
|
||||||
|
|
||||||
if ((lb_size != 0) && (lb_size != LB_SIZE_4K) && (lb_size != LB_SIZE_512B)) {
|
if ((lb_size != 0) && (lb_size != LB_SIZE_4K) && (lb_size != LB_SIZE_512B)) {
|
||||||
SPDK_ERRLOG("Logical block size must be 512 or 4096\n");
|
SPDK_ERRLOG("Logical block size must be 512 or 4096\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAILQ_FOREACH(comp_bdev, &g_vbdev_comp, link) {
|
||||||
|
if (strcmp(bdev_name, comp_bdev->base_bdev->name) == 0) {
|
||||||
|
SPDK_ERRLOG("Bass bdev %s already being used for a compress bdev\n", bdev_name);
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
return vbdev_init_reduce(bdev_name, pm_path, lb_size);
|
return vbdev_init_reduce(bdev_name, pm_path, lb_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,11 @@ rpc_bdev_compress_create(struct spdk_jsonrpc_request *request,
|
|||||||
|
|
||||||
rc = create_compress_bdev(req.base_bdev_name, req.pm_path, req.lb_size);
|
rc = create_compress_bdev(req.base_bdev_name, req.pm_path, req.lb_size);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
if (rc == -EBUSY) {
|
||||||
|
spdk_jsonrpc_send_error_response(request, rc, "Base bdev already in use for compression.");
|
||||||
|
} else {
|
||||||
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
|
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
|
||||||
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user