Commit 5118004b authored by Darek Stojaczyk's avatar Darek Stojaczyk
Browse files

bdev/null: allocate bdev struct using regular calloc



spdk_dma_malloc() is not required here, as the bdev
struct is neither DMA-able nor shared between processes.

While here, also allocate g_null_read_buf using
spdk_zmalloc() instead of spdk_dma_zmalloc(),
as spdk_dma_*malloc() is about to be deprecated.

Change-Id: I0dc344bc84932607c2e22a124e2093e87714ec5e
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448170


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>
parent c781fdee
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ bdev_null_destruct(void *ctx)

	TAILQ_REMOVE(&g_null_bdev_head, bdev, tailq);
	free(bdev->bdev.name);
	spdk_dma_free(bdev);
	free(bdev);

	return 0;
}
@@ -188,7 +188,7 @@ create_null_bdev(const char *name, const struct spdk_uuid *uuid,
		return NULL;
	}

	bdev = spdk_dma_zmalloc(sizeof(*bdev), 0, NULL);
	bdev = calloc(1, sizeof(*bdev));
	if (!bdev) {
		SPDK_ERRLOG("could not allocate null_bdev\n");
		return NULL;
@@ -196,7 +196,7 @@ create_null_bdev(const char *name, const struct spdk_uuid *uuid,

	bdev->bdev.name = strdup(name);
	if (!bdev->bdev.name) {
		spdk_dma_free(bdev);
		free(bdev);
		return NULL;
	}
	bdev->bdev.product_name = "Null disk";
@@ -217,7 +217,7 @@ create_null_bdev(const char *name, const struct spdk_uuid *uuid,
	rc = spdk_bdev_register(&bdev->bdev);
	if (rc) {
		free(bdev->bdev.name);
		spdk_dma_free(bdev);
		free(bdev);
		return NULL;
	}

@@ -295,7 +295,8 @@ bdev_null_initialize(void)
	 *  Instead of using a real rbuf from the bdev pool, just always point to
	 *  this same zeroed buffer.
	 */
	g_null_read_buf = spdk_dma_zmalloc(SPDK_BDEV_LARGE_BUF_MAX_SIZE, 0, NULL);
	g_null_read_buf = spdk_zmalloc(SPDK_BDEV_LARGE_BUF_MAX_SIZE, 0, NULL,
				       SPDK_ENV_SOCKET_ID_ANY, SPDK_MALLOC_DMA);

	/*
	 * We need to pick some unique address as our "io device" - so just use the
@@ -365,7 +366,7 @@ end:
static void
_bdev_null_finish_cb(void *arg)
{
	spdk_dma_free(g_null_read_buf);
	spdk_free(g_null_read_buf);
	spdk_bdev_module_finish_done();
}