Commit 91fcde06 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

rocksdb: use spdk_thread_send_msg() instead of spdk_event_call()



All bdev calls must be made from an spdk_thread context. Use this instead of
relying on hack in reactor code that sets the spdk_thread context before
calling an event. This new approach is much cleaner and lets us remove the
hack in an upcoming patch.

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


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 9934e414
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ namespace rocksdb

struct spdk_filesystem *g_fs = NULL;
struct spdk_bs_dev *g_bs_dev;
uint32_t g_lcore = 0;
struct spdk_thread *g_app_thread;
std::string g_bdev_name;
volatile bool g_spdk_ready = false;
volatile bool g_spdk_start_failure = false;
@@ -64,22 +64,10 @@ set_channel()
	}
}

static void
__call_fn(void *arg1, void *arg2)
{
	fs_request_fn fn;

	fn = (fs_request_fn)arg1;
	fn(arg2);
}

static void
__send_request(fs_request_fn fn, void *arg)
{
	struct spdk_event *event;

	event = spdk_event_allocate(g_lcore, __call_fn, (void *)fn, arg);
	spdk_event_call(event);
	spdk_thread_send_msg(g_app_thread, fn, arg);
}

static std::string
@@ -645,7 +633,7 @@ rocksdb_run(__attribute__((unused)) void *arg1)
		exit(1);
	}

	g_lcore = spdk_env_get_first_core();
	g_app_thread = spdk_get_thread();

	printf("using bdev %s\n", g_bdev_name.c_str());
	spdk_fs_load(g_bs_dev, __send_request, fs_load_cb, NULL);