change async to sync
This commit is contained in:
76
zv2404fs.c
76
zv2404fs.c
@@ -43,6 +43,10 @@ typedef struct zv2404fs_context_s {
|
||||
|
||||
#endif
|
||||
|
||||
struct spdk_thread *global_thread = NULL;
|
||||
|
||||
|
||||
|
||||
static void zv2404fs_spdk_bs_unload_cb(void *arg, int bserrno) {
|
||||
|
||||
zv2404fs_context_t *ctx = (zv2404fs_context_t*)arg;
|
||||
@@ -236,6 +240,78 @@ static void zv2404fs_entry(void *arg) {
|
||||
|
||||
#if 1
|
||||
|
||||
|
||||
static const int WAITER_MAX_TIME = 100000;
|
||||
|
||||
static bool waiter(struct spdk_thread *thread, spdk_msg_fn start_fn, void *ctx, bool *finished) {
|
||||
|
||||
spdk_thread_send_msg(thread, start_fn, ctx);
|
||||
|
||||
int waiter_count = 0;
|
||||
|
||||
do {
|
||||
spdk_thread_poll(thread, 0, 0);
|
||||
waiter_count ++;
|
||||
} while(!(*finished) && waiter_count < WAITER_MAX_TIME);
|
||||
|
||||
if (!(*finished) && waiter_count >= WAITER_MAX_TIME) {
|
||||
return false; // timeout
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// zvfs.json
|
||||
|
||||
static const char *json_file = "/home/king/share/spdk/examples/5.3.1-zv2404fs/zvfs.json";
|
||||
|
||||
|
||||
static void json_app_load_done(int rc, void *ctx) {
|
||||
|
||||
bool *done = ctx;
|
||||
*done = true;
|
||||
|
||||
SPDK_NOTICELOG("json_app_load_done\n");
|
||||
}
|
||||
|
||||
static void zv2404fs_json_load_fn(void *arg) {
|
||||
|
||||
spdk_subsystem_init_from_json_config(json_file, SPDK_DEFAULT_RPC_ADDR, json_app_load_done,
|
||||
arg, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
struct spdk_env_opts opts;
|
||||
spdk_env_opts_init(&opts);
|
||||
|
||||
if (0 != spdk_env_init(&opts)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
spdk_log_set_print_level(SPDK_LOG_NOTICE);
|
||||
spdk_log_set_level(SPDK_LOG_NOTICE);
|
||||
spdk_log_open(NULL);
|
||||
|
||||
spdk_thread_lib_init(NULL, 0);
|
||||
global_thread = spdk_thread_create("global", NULL);
|
||||
spdk_set_thread(global_thread);
|
||||
|
||||
bool done = false;
|
||||
//zv2404fs_json_load_fn(&done);
|
||||
|
||||
waiter(global_thread, zv2404fs_json_load_fn, &done, &done);
|
||||
SPDK_NOTICELOG("json_app_load_done complete\n");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#elif 0
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc != 2) return -1;
|
||||
|
||||
Reference in New Issue
Block a user