From 282463f53cad9b2aec79245008078a4990018863 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Tue, 21 Aug 2018 04:19:02 -0400 Subject: [PATCH] blobfs: exit the app after the failure of memory allocation When testing blobfs, the allocation of cache buffer may fail without any error information, users may get segment fault error after that. Change-Id: I6dc8ee4b93c6a9109aba193f599197caa4c4c383 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/422943 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Xiaodong Liu Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/blobfs/blobfs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index fb1df68b4..4fc0e628f 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -218,6 +218,11 @@ __initialize_cache(void) CACHE_BUFFER_SIZE, SPDK_MEMPOOL_DEFAULT_CACHE_SIZE, SPDK_ENV_SOCKET_ID_ANY); + if (!g_cache_pool) { + SPDK_ERRLOG("Create mempool failed, you may " + "increase the memory and try again\n"); + assert(false); + } TAILQ_INIT(&g_caches); pthread_spin_init(&g_caches_lock, 0); }