From 5ac7440af1024e302bdbd613e08ae9e56caa2d2c Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Fri, 5 Apr 2019 10:43:15 +0200 Subject: [PATCH] bdev/malloc: 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 mdisk->malloc_buf using spdk_zmalloc() instead of spdk_dma_zmalloc(), as spdk_dma_*malloc() is about to be deprecated. Change-Id: If835216764a565ade09180159fbbc92411b5c78f Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450255 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/bdev/malloc/bdev_malloc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/bdev/malloc/bdev_malloc.c b/lib/bdev/malloc/bdev_malloc.c index 9edf997d5..796d3235d 100644 --- a/lib/bdev/malloc/bdev_malloc.c +++ b/lib/bdev/malloc/bdev_malloc.c @@ -119,8 +119,8 @@ malloc_disk_free(struct malloc_disk *malloc_disk) } free(malloc_disk->disk.name); - spdk_dma_free(malloc_disk->malloc_buf); - spdk_dma_free(malloc_disk); + spdk_free(malloc_disk->malloc_buf); + free(malloc_disk); } static int @@ -386,9 +386,9 @@ struct spdk_bdev *create_malloc_disk(const char *name, const struct spdk_uuid *u return NULL; } - mdisk = spdk_dma_zmalloc(sizeof(*mdisk), 0, NULL); + mdisk = calloc(1, sizeof(*mdisk)); if (!mdisk) { - SPDK_ERRLOG("mdisk spdk_dma_zmalloc() failed\n"); + SPDK_ERRLOG("mdisk calloc() failed\n"); return NULL; } @@ -398,9 +398,10 @@ struct spdk_bdev *create_malloc_disk(const char *name, const struct spdk_uuid *u * TODO: need to pass a hint so we know which socket to allocate * from on multi-socket systems. */ - mdisk->malloc_buf = spdk_dma_zmalloc(num_blocks * block_size, 2 * 1024 * 1024, NULL); + mdisk->malloc_buf = spdk_zmalloc(num_blocks * block_size, 2 * 1024 * 1024, NULL, + SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA); if (!mdisk->malloc_buf) { - SPDK_ERRLOG("malloc_buf spdk_dma_zmalloc() failed\n"); + SPDK_ERRLOG("malloc_buf spdk_zmalloc() failed\n"); malloc_disk_free(mdisk); return NULL; }