From e237ce317ee010c0934fe57fe36bbad9027547ba Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Thu, 24 Aug 2017 13:42:06 +0200 Subject: [PATCH] bdev: don't continue on module init error spdk_bdev_init_complete could have been called twice. While here, also simplify bdev_initialize error path. On allocation failure, bdev subsystem will now finish with bdev_mgr->module_init_complete set to false. Fixes: 7fefd60fabb8 ("bdev: make module init synchronous again") Change-Id: Ia4b5d571d26beb34f0e6c0f4c7b3176215eec69f Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/375572 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- lib/bdev/bdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index f2e305295..b628d1d61 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -369,6 +369,7 @@ spdk_bdev_module_init_complete(int rc) if (rc != 0) { spdk_bdev_init_complete(rc); + return; } /* @@ -445,7 +446,7 @@ spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg, if (g_bdev_mgr.bdev_io_pool == NULL) { SPDK_ERRLOG("could not allocate spdk_bdev_io pool\n"); - spdk_bdev_module_init_complete(-1); + spdk_bdev_init_complete(-1); return; } @@ -464,7 +465,7 @@ spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg, SPDK_ENV_SOCKET_ID_ANY); if (!g_bdev_mgr.buf_small_pool) { SPDK_ERRLOG("create rbuf small pool failed\n"); - spdk_bdev_module_init_complete(-1); + spdk_bdev_init_complete(-1); return; } @@ -478,7 +479,7 @@ spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg, SPDK_ENV_SOCKET_ID_ANY); if (!g_bdev_mgr.buf_large_pool) { SPDK_ERRLOG("create rbuf large pool failed\n"); - spdk_bdev_module_init_complete(-1); + spdk_bdev_init_complete(-1); return; }