Commit 84532e3d authored by Jim Harris's avatar Jim Harris
Browse files

blobfs: do not defer cache pool allocation to mgmt thread



Before this patch, cache pool allocation would get deferred to a message
sent to the cache pool mgmt spdk_thread. This meant that the cache pool
would get allocated *after* blobfs called the init/load completion callback.

There is no need to defer the allocation, just allocate it directly from the
blobstore init/load completion context.

While here, remove a `sleep 1` from the blobfs.sh test script. This sleep
was masking the underlying issue here, giving blobfs time to run the
deferred function allocating the cache pool.

Fixes issue #3250.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I8f32b86d5a46083697cbc1c42c8207b45fb4f2b9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21730


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent cd85681c
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -249,8 +249,28 @@ blobfs_cache_pool_need_reclaim(void)
static void
__start_cache_pool_mgmt(void *ctx)
{
	assert(g_cache_pool == NULL);
	assert(g_cache_pool_mgmt_poller == NULL);
	g_cache_pool_mgmt_poller = SPDK_POLLER_REGISTER(_blobfs_cache_pool_reclaim, NULL,
				   BLOBFS_CACHE_POOL_POLL_PERIOD_IN_US);
}

static void
__stop_cache_pool_mgmt(void *ctx)
{
	spdk_poller_unregister(&g_cache_pool_mgmt_poller);

	assert(g_cache_pool != NULL);
	assert(spdk_mempool_count(g_cache_pool) == g_fs_cache_size / CACHE_BUFFER_SIZE);
	spdk_mempool_free(g_cache_pool);
	g_cache_pool = NULL;

	spdk_thread_exit(g_cache_pool_thread);
}

static void
allocate_cache_pool(void)
{
	assert(g_cache_pool == NULL);
	g_cache_pool = spdk_mempool_create("spdk_fs_cache",
					   g_fs_cache_size / CACHE_BUFFER_SIZE,
					   CACHE_BUFFER_SIZE,
@@ -267,23 +287,6 @@ __start_cache_pool_mgmt(void *ctx)
		}
		assert(false);
	}

	assert(g_cache_pool_mgmt_poller == NULL);
	g_cache_pool_mgmt_poller = SPDK_POLLER_REGISTER(_blobfs_cache_pool_reclaim, NULL,
				   BLOBFS_CACHE_POOL_POLL_PERIOD_IN_US);
}

static void
__stop_cache_pool_mgmt(void *ctx)
{
	spdk_poller_unregister(&g_cache_pool_mgmt_poller);

	assert(g_cache_pool != NULL);
	assert(spdk_mempool_count(g_cache_pool) == g_fs_cache_size / CACHE_BUFFER_SIZE);
	spdk_mempool_free(g_cache_pool);
	g_cache_pool = NULL;

	spdk_thread_exit(g_cache_pool_thread);
}

static void
@@ -291,6 +294,7 @@ initialize_global_cache(void)
{
	pthread_mutex_lock(&g_cache_init_lock);
	if (g_fs_count == 0) {
		allocate_cache_pool();
		g_cache_pool_thread = spdk_thread_create("cache_pool_mgmt", NULL);
		assert(g_cache_pool_thread != NULL);
		spdk_thread_send_msg(g_cache_pool_thread, __start_cache_pool_mgmt, NULL);
+0 −2
Original line number Diff line number Diff line
@@ -97,8 +97,6 @@ function blobfs_fuse_test() {
	# So directly use default sock path.
	waitforlisten $blobfs_pid /var/tmp/spdk.sock

	sleep 1

	# check mount status
	mount | grep "$mount_dir"