Commit 812ffaf1 authored by Ben Walker's avatar Ben Walker
Browse files

bdev: Simplify spdk_bdev_finish



This was implemented as 3 separate functions but
it is simpler as 1.

Also, this wasn't previously freeing the buffer pools.

Change-Id: Ic1b2b3a0596e745a223099cb2a79bea6ef5c69cc
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent f2132bfd
Loading
Loading
Loading
Loading
+35 −34
Original line number Diff line number Diff line
@@ -188,24 +188,6 @@ spdk_bdev_module_get_max_ctx_size(void)
	return max_bdev_module_size;
}

static void
spdk_bdev_module_finish(void)
{
	struct spdk_bdev_module_if *bdev_module;

	TAILQ_FOREACH(bdev_module, &g_bdev_mgr.vbdev_modules, tailq) {
		if (bdev_module->module_fini) {
			bdev_module->module_fini();
		}
	}

	TAILQ_FOREACH(bdev_module, &g_bdev_mgr.bdev_modules, tailq) {
		if (bdev_module->module_fini) {
			bdev_module->module_fini();
		}
	}
}

static void
spdk_bdev_config_text(FILE *fp)
{
@@ -291,28 +273,47 @@ spdk_bdev_initialize(void)
}

static int
spdk_bdev_check_pool(struct spdk_mempool *pool, uint32_t count)
spdk_bdev_finish(void)
{
	if (spdk_mempool_count(pool) != count) {
		SPDK_ERRLOG("spdk_mempool_count(%p) == %zu, should be %u\n",
			    pool, spdk_mempool_count(pool), count);
		return -1;
	} else {
		return 0;
	struct spdk_bdev_module_if *bdev_module;

	TAILQ_FOREACH(bdev_module, &g_bdev_mgr.vbdev_modules, tailq) {
		if (bdev_module->module_fini) {
			bdev_module->module_fini();
		}
	}

static int
spdk_bdev_finish(void)
{
	int rc = 0;
	TAILQ_FOREACH(bdev_module, &g_bdev_mgr.bdev_modules, tailq) {
		if (bdev_module->module_fini) {
			bdev_module->module_fini();
		}
	}

	if (spdk_mempool_count(g_bdev_mgr.bdev_io_pool) != SPDK_BDEV_IO_POOL_SIZE) {
		SPDK_ERRLOG("bdev IO pool count is %zu but should be %u\n",
			    spdk_mempool_count(g_bdev_mgr.bdev_io_pool),
			    SPDK_BDEV_IO_POOL_SIZE);
	}

	if (spdk_mempool_count(g_bdev_mgr.buf_small_pool) != BUF_SMALL_POOL_SIZE) {
		SPDK_ERRLOG("Small buffer pool count is %zu but should be %u\n",
			    spdk_mempool_count(g_bdev_mgr.buf_small_pool),
			    BUF_SMALL_POOL_SIZE);
		assert(false);
	}

	spdk_bdev_module_finish();
	if (spdk_mempool_count(g_bdev_mgr.buf_large_pool) != BUF_LARGE_POOL_SIZE) {
		SPDK_ERRLOG("Large buffer pool count is %zu but should be %u\n",
			    spdk_mempool_count(g_bdev_mgr.buf_large_pool),
			    BUF_LARGE_POOL_SIZE);
		assert(false);
	}

	rc += spdk_bdev_check_pool(g_bdev_mgr.buf_small_pool, BUF_SMALL_POOL_SIZE);
	rc += spdk_bdev_check_pool(g_bdev_mgr.buf_large_pool, BUF_LARGE_POOL_SIZE);
	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);

	return (rc != 0);
	return 0;
}

struct spdk_bdev_io *