diff --git a/lib/rocksdb/env_spdk.cc b/lib/rocksdb/env_spdk.cc index d5b02339b..8f00a2c1c 100644 --- a/lib/rocksdb/env_spdk.cc +++ b/lib/rocksdb/env_spdk.cc @@ -59,8 +59,7 @@ std::string g_bdev_name; volatile bool g_spdk_ready = false; volatile bool g_spdk_start_failure = false; -void SpdkInitializeThread(void); -void SpdkFinalizeThread(void); +static void SpdkInitializeThread(void); class SpdkThreadCtx { @@ -74,7 +73,10 @@ public: ~SpdkThreadCtx(void) { - SpdkFinalizeThread(); + if (channel) { + spdk_fs_free_thread_ctx(channel); + channel = NULL; + } } private: @@ -598,25 +600,23 @@ public: } }; -void SpdkInitializeThread(void) +/* The thread local constructor doesn't work for the main thread, since + * the filesystem hasn't been loaded yet. So we break out this + * SpdkInitializeThread function, so that the main thread can explicitly + * call it after the filesystem has been loaded. + */ +static void SpdkInitializeThread(void) { struct spdk_thread *thread; - if (g_fs != NULL && g_sync_args.channel == NULL) { + assert(g_sync_args.channel == NULL); + if (g_fs != NULL) { thread = spdk_thread_create("spdk_rocksdb", NULL); spdk_set_thread(thread); g_sync_args.channel = spdk_fs_alloc_thread_ctx(g_fs); } } -void SpdkFinalizeThread(void) -{ - if (g_sync_args.channel) { - spdk_fs_free_thread_ctx(g_sync_args.channel); - g_sync_args.channel = NULL; - } -} - static void fs_load_cb(__attribute__((unused)) void *ctx, struct spdk_filesystem *fs, int fserrno) diff --git a/test/blobfs/rocksdb/rocksdb_commit_id b/test/blobfs/rocksdb/rocksdb_commit_id index 3d861c9eb..efac5a55d 100644 --- a/test/blobfs/rocksdb/rocksdb_commit_id +++ b/test/blobfs/rocksdb/rocksdb_commit_id @@ -1 +1 @@ -803b318a9e1c0244030c1775c1b84b4f385a8908 +526c73bd94150cc8fbd651f736e1ca95f50d8e13