Commit 804ce732 authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

bdev/compress: factor out setting the comp bdev name



Will be re-used in an upcoming patch.

Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: I676beb7f61c100043189c56484a41c209cd2942d
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465829


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBroadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
parent a480b18e
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -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