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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448170
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>
This commit is contained in:
Darek Stojaczyk 2019-03-15 14:50:07 +01:00
parent c781fdee2f
commit 5118004b1d

View File

@ -80,7 +80,7 @@ bdev_null_destruct(void *ctx)
TAILQ_REMOVE(&g_null_bdev_head, bdev, tailq); TAILQ_REMOVE(&g_null_bdev_head, bdev, tailq);
free(bdev->bdev.name); free(bdev->bdev.name);
spdk_dma_free(bdev); free(bdev);
return 0; return 0;
} }
@ -188,7 +188,7 @@ create_null_bdev(const char *name, const struct spdk_uuid *uuid,
return NULL; return NULL;
} }
bdev = spdk_dma_zmalloc(sizeof(*bdev), 0, NULL); bdev = calloc(1, sizeof(*bdev));
if (!bdev) { if (!bdev) {
SPDK_ERRLOG("could not allocate null_bdev\n"); SPDK_ERRLOG("could not allocate null_bdev\n");
return NULL; return NULL;
@ -196,7 +196,7 @@ create_null_bdev(const char *name, const struct spdk_uuid *uuid,
bdev->bdev.name = strdup(name); bdev->bdev.name = strdup(name);
if (!bdev->bdev.name) { if (!bdev->bdev.name) {
spdk_dma_free(bdev); free(bdev);
return NULL; return NULL;
} }
bdev->bdev.product_name = "Null disk"; 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); rc = spdk_bdev_register(&bdev->bdev);
if (rc) { if (rc) {
free(bdev->bdev.name); free(bdev->bdev.name);
spdk_dma_free(bdev); free(bdev);
return NULL; return NULL;
} }
@ -295,7 +295,8 @@ bdev_null_initialize(void)
* Instead of using a real rbuf from the bdev pool, just always point to * Instead of using a real rbuf from the bdev pool, just always point to
* this same zeroed buffer. * 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 * We need to pick some unique address as our "io device" - so just use the
@ -365,7 +366,7 @@ end:
static void static void
_bdev_null_finish_cb(void *arg) _bdev_null_finish_cb(void *arg)
{ {
spdk_dma_free(g_null_read_buf); spdk_free(g_null_read_buf);
spdk_bdev_module_finish_done(); spdk_bdev_module_finish_done();
} }