vhost: don't use the second ctx param in spdk_event_allocate

Prepare to switch to spdk_thread_send_msg() which
accepts only one context parameter.

Change-Id: Iea3e8d1e715957d9b3fea12e969f29084a2948dc
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452393
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2019-04-29 09:05:55 +02:00 committed by Jim Harris
parent b643dcd1fd
commit a1d4dcdc85

View File

@ -73,6 +73,9 @@ struct spdk_vhost_session_fn_ctx {
/** Response to be written by enqueued event. */ /** Response to be written by enqueued event. */
int response; int response;
/** Custom user context */
void *user_ctx;
}; };
static int new_connection(int vid); static int new_connection(int vid);
@ -922,7 +925,7 @@ spdk_vhost_event_cb(void *arg1, void *arg2)
if (pthread_mutex_trylock(&g_spdk_vhost_mutex) != 0) { if (pthread_mutex_trylock(&g_spdk_vhost_mutex) != 0) {
ev = spdk_event_allocate(spdk_env_get_current_core(), ev = spdk_event_allocate(spdk_env_get_current_core(),
spdk_vhost_event_cb, arg1, arg2); spdk_vhost_event_cb, arg1, NULL);
spdk_event_call(ev); spdk_event_call(ev);
return; return;
} }
@ -947,7 +950,7 @@ spdk_vhost_event_async_foreach_fn(void *arg1, void *arg2)
if (pthread_mutex_trylock(&g_spdk_vhost_mutex) != 0) { if (pthread_mutex_trylock(&g_spdk_vhost_mutex) != 0) {
ev = spdk_event_allocate(spdk_env_get_current_core(), ev = spdk_event_allocate(spdk_env_get_current_core(),
spdk_vhost_event_async_foreach_fn, arg1, arg2); spdk_vhost_event_async_foreach_fn, arg1, NULL);
spdk_event_call(ev); spdk_event_call(ev);
return; return;
} }
@ -968,20 +971,20 @@ spdk_vhost_event_async_foreach_fn(void *arg1, void *arg2)
* the session thread as many times as necessary. * the session thread as many times as necessary.
*/ */
ev = spdk_event_allocate(vsession->lcore, ev = spdk_event_allocate(vsession->lcore,
spdk_vhost_event_async_foreach_fn, arg1, arg2); spdk_vhost_event_async_foreach_fn, arg1, NULL);
spdk_event_call(ev); spdk_event_call(ev);
pthread_mutex_unlock(&g_spdk_vhost_mutex); pthread_mutex_unlock(&g_spdk_vhost_mutex);
return; return;
} }
rc = ctx->cb_fn(vdev, vsession, arg2); rc = ctx->cb_fn(vdev, vsession, ctx->user_ctx);
if (rc < 0) { if (rc < 0) {
goto out_unlock; goto out_unlock;
} }
out_unlock_continue: out_unlock_continue:
vsession = spdk_vhost_session_next(vdev, ctx->vsession_id); vsession = spdk_vhost_session_next(vdev, ctx->vsession_id);
spdk_vhost_external_event_foreach_continue(vdev, vsession, ctx->cb_fn, arg2); spdk_vhost_external_event_foreach_continue(vdev, vsession, ctx->cb_fn, ctx->user_ctx);
out_unlock: out_unlock:
pthread_mutex_unlock(&g_spdk_vhost_mutex); pthread_mutex_unlock(&g_spdk_vhost_mutex);
free(ctx); free(ctx);
@ -1046,9 +1049,10 @@ spdk_vhost_event_async_send_foreach_continue(struct spdk_vhost_session *vsession
ev_ctx->vdev = vdev; ev_ctx->vdev = vdev;
ev_ctx->vsession_id = vsession->id; ev_ctx->vsession_id = vsession->id;
ev_ctx->cb_fn = cb_fn; ev_ctx->cb_fn = cb_fn;
ev_ctx->user_ctx = arg;
ev = spdk_event_allocate(vsession->lcore, ev = spdk_event_allocate(vsession->lcore,
spdk_vhost_event_async_foreach_fn, ev_ctx, arg); spdk_vhost_event_async_foreach_fn, ev_ctx, NULL);
assert(ev); assert(ev);
spdk_event_call(ev); spdk_event_call(ev);