bdev: check whether memory allocated already
In the case of bdev initialization, the memory could not be allocated. When cleaning up, it needs to check whether the memory pointer is valid or not before touching the address of the pointer. This is to fix below issue: https://github.com/spdk/spdk/issues/1126 Change-Id: Iec0e2c5a40ad153a96fb939414a15ac3b9112a01 Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478849 Community-CI: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: <box.b.chen@intel.com> Reviewed-by: yidong0635 <dongx.yi@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
cbc9d34362
commit
66af6221a0
@ -1125,29 +1125,38 @@ bdev_mgr_unregister_cb(void *io_device)
|
|||||||
{
|
{
|
||||||
spdk_bdev_fini_cb cb_fn = g_fini_cb_fn;
|
spdk_bdev_fini_cb cb_fn = g_fini_cb_fn;
|
||||||
|
|
||||||
if (spdk_mempool_count(g_bdev_mgr.bdev_io_pool) != g_bdev_opts.bdev_io_pool_size) {
|
if (g_bdev_mgr.bdev_io_pool) {
|
||||||
SPDK_ERRLOG("bdev IO pool count is %zu but should be %u\n",
|
if (spdk_mempool_count(g_bdev_mgr.bdev_io_pool) != g_bdev_opts.bdev_io_pool_size) {
|
||||||
spdk_mempool_count(g_bdev_mgr.bdev_io_pool),
|
SPDK_ERRLOG("bdev IO pool count is %zu but should be %u\n",
|
||||||
g_bdev_opts.bdev_io_pool_size);
|
spdk_mempool_count(g_bdev_mgr.bdev_io_pool),
|
||||||
|
g_bdev_opts.bdev_io_pool_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_mempool_free(g_bdev_mgr.bdev_io_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdk_mempool_count(g_bdev_mgr.buf_small_pool) != BUF_SMALL_POOL_SIZE) {
|
if (g_bdev_mgr.buf_small_pool) {
|
||||||
SPDK_ERRLOG("Small buffer pool count is %zu but should be %u\n",
|
if (spdk_mempool_count(g_bdev_mgr.buf_small_pool) != BUF_SMALL_POOL_SIZE) {
|
||||||
spdk_mempool_count(g_bdev_mgr.buf_small_pool),
|
SPDK_ERRLOG("Small buffer pool count is %zu but should be %u\n",
|
||||||
BUF_SMALL_POOL_SIZE);
|
spdk_mempool_count(g_bdev_mgr.buf_small_pool),
|
||||||
assert(false);
|
BUF_SMALL_POOL_SIZE);
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_mempool_free(g_bdev_mgr.buf_small_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdk_mempool_count(g_bdev_mgr.buf_large_pool) != BUF_LARGE_POOL_SIZE) {
|
if (g_bdev_mgr.buf_large_pool) {
|
||||||
SPDK_ERRLOG("Large buffer pool count is %zu but should be %u\n",
|
if (spdk_mempool_count(g_bdev_mgr.buf_large_pool) != BUF_LARGE_POOL_SIZE) {
|
||||||
spdk_mempool_count(g_bdev_mgr.buf_large_pool),
|
SPDK_ERRLOG("Large buffer pool count is %zu but should be %u\n",
|
||||||
BUF_LARGE_POOL_SIZE);
|
spdk_mempool_count(g_bdev_mgr.buf_large_pool),
|
||||||
assert(false);
|
BUF_LARGE_POOL_SIZE);
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_mempool_free(g_bdev_mgr.buf_large_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_mempool_free(g_bdev_mgr.bdev_io_pool);
|
|
||||||
spdk_mempool_free(g_bdev_mgr.buf_small_pool);
|
|
||||||
spdk_mempool_free(g_bdev_mgr.buf_large_pool);
|
|
||||||
spdk_free(g_bdev_mgr.zero_buffer);
|
spdk_free(g_bdev_mgr.zero_buffer);
|
||||||
|
|
||||||
cb_fn(g_fini_cb_arg);
|
cb_fn(g_fini_cb_arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user