bdev/compress: use base bdev alias as base for comp_bdev name

If available, if not use the bdev unique name. This results in
a much friendlier comp_bdev naem for the user.  For example,
now it would look something like this: COMP_lvs0/lvs as opposed
to like this COMP_0b149b31-b66b-4cf7-ab39-a55b50788cd1

Change-Id: I319a141221ed8880edcec930ca5be9f256b105e0
Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463246
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
paul luse 2019-07-25 18:47:07 -04:00 committed by Jim Harris
parent e9211cbf45
commit ca1a3bf18e
2 changed files with 16 additions and 4 deletions

View File

@ -1359,12 +1359,22 @@ static void
vbdev_compress_claim(struct vbdev_compress *comp_bdev) vbdev_compress_claim(struct vbdev_compress *comp_bdev)
{ {
int rc; int rc;
struct spdk_bdev_alias *aliases;
if (!TAILQ_EMPTY(spdk_bdev_get_aliases(comp_bdev->base_bdev))) {
aliases = TAILQ_FIRST(spdk_bdev_get_aliases(comp_bdev->base_bdev));
comp_bdev->comp_bdev.name = spdk_sprintf_alloc("COMP_%s", aliases->alias);
if (!comp_bdev->comp_bdev.name) {
SPDK_ERRLOG("could not allocate comp_bdev name for alias\n");
goto error_bdev_name;
}
} else {
comp_bdev->comp_bdev.name = spdk_sprintf_alloc("COMP_%s", comp_bdev->base_bdev->name); comp_bdev->comp_bdev.name = spdk_sprintf_alloc("COMP_%s", comp_bdev->base_bdev->name);
if (!comp_bdev->comp_bdev.name) { if (!comp_bdev->comp_bdev.name) {
SPDK_ERRLOG("could not allocate comp_bdev name\n"); SPDK_ERRLOG("could not allocate comp_bdev name for unique name\n");
goto error_bdev_name; goto error_bdev_name;
} }
}
/* Note: some of the fields below will change in the future - for example, /* Note: some of the fields below will change in the future - for example,
* blockcnt specifically will not match (the compressed volume size will * blockcnt specifically will not match (the compressed volume size will

View File

@ -233,6 +233,8 @@ spdk_reduce_vol_readv(struct spdk_reduce_vol *vol, struct iovec *iov, int iovcnt
#include "bdev/compress/vbdev_compress.c" #include "bdev/compress/vbdev_compress.c"
/* SPDK stubs */ /* SPDK stubs */
DEFINE_STUB(spdk_bdev_get_aliases, const struct spdk_bdev_aliases_list *,
(const struct spdk_bdev *bdev), NULL);
DEFINE_STUB_V(spdk_bdev_module_list_add, (struct spdk_bdev_module *bdev_module)); DEFINE_STUB_V(spdk_bdev_module_list_add, (struct spdk_bdev_module *bdev_module));
DEFINE_STUB_V(spdk_bdev_free_io, (struct spdk_bdev_io *g_bdev_io)); DEFINE_STUB_V(spdk_bdev_free_io, (struct spdk_bdev_io *g_bdev_io));
DEFINE_STUB(spdk_bdev_io_type_supported, bool, (struct spdk_bdev *bdev, DEFINE_STUB(spdk_bdev_io_type_supported, bool, (struct spdk_bdev *bdev,