bdev/compress: factor out setting the comp bdev name

Will be re-used in an upcoming patch.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: I676beb7f61c100043189c56484a41c209cd2942d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465829
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
paul luse 2019-08-20 18:41:58 -04:00 committed by Jim Harris
parent a480b18eda
commit 804ce73296

View File

@ -1361,10 +1361,8 @@ static struct spdk_bdev_module compress_if = {
SPDK_BDEV_MODULE_REGISTER(compress, &compress_if)
static void
vbdev_compress_claim(struct vbdev_compress *comp_bdev)
static int _set_compbdev_name(struct vbdev_compress *comp_bdev)
{
int rc;
struct spdk_bdev_alias *aliases;
if (!TAILQ_EMPTY(spdk_bdev_get_aliases(comp_bdev->base_bdev))) {
@ -1372,15 +1370,26 @@ vbdev_compress_claim(struct vbdev_compress *comp_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;
return -ENOMEM;
}
} else {
comp_bdev->comp_bdev.name = spdk_sprintf_alloc("COMP_%s", comp_bdev->base_bdev->name);
if (!comp_bdev->comp_bdev.name) {
SPDK_ERRLOG("could not allocate comp_bdev name for unique name\n");
goto error_bdev_name;
return -ENOMEM;
}
}
return 0;
}
static void
vbdev_compress_claim(struct vbdev_compress *comp_bdev)
{
int rc;
if (_set_compbdev_name(comp_bdev)) {
goto error_bdev_name;
}
/* Note: some of the fields below will change in the future - for example,
* blockcnt specifically will not match (the compressed volume size will