Commit 5ac7440a authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Changpeng Liu
Browse files

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: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450255


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent d6afc7f3
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -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;
	}