From 435138b76d21cea6066433b7b71ac2604bb3b8dc Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 14 Nov 2017 14:02:02 -0700 Subject: [PATCH] scsi: Register all pollers to the current core Register all pollers to the current core. If necessary, send an event to the correct core before registering. Change-Id: Ie34cc8b11143a58c0f621c87c409a3d09d929648 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/387682 Reviewed-by: Dariusz Stojaczyk Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp --- lib/iscsi/conn.c | 4 ++-- lib/scsi/lun.c | 21 +++++++++++++++++++-- test/unit/lib/scsi/lun.c/lun_ut.c | 16 ++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 49145b590..948bd052c 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -392,7 +392,7 @@ int spdk_initialize_iscsi_conns(void) } spdk_poller_register(&g_idle_conn_poller, spdk_iscsi_conn_idle_do_work, NULL, - rte_get_master_lcore(), 0); + spdk_env_get_current_core(), 0); return 0; } @@ -860,7 +860,7 @@ void spdk_shutdown_iscsi_conns(void) pthread_mutex_unlock(&g_conns_mutex); spdk_poller_register(&g_shutdown_timer, spdk_iscsi_conn_check_shutdown, NULL, - rte_get_master_lcore(), 1000); + spdk_env_get_current_core(), 1000); } int diff --git a/lib/scsi/lun.c b/lib/scsi/lun.c index c7d3c8b22..73dd02062 100644 --- a/lib/scsi/lun.c +++ b/lib/scsi/lun.c @@ -235,9 +235,11 @@ spdk_scsi_lun_hotplug(void *arg) } static void -spdk_scsi_lun_hot_remove(void *remove_ctx) +_spdk_scsi_lun_hot_remove(void *arg1, void *arg2) { - struct spdk_scsi_lun *lun = (struct spdk_scsi_lun *)remove_ctx; + struct spdk_scsi_lun *lun = arg1; + + assert(lun->lcore == spdk_env_get_current_core()); lun->removed = true; if (lun->hotremove_cb) { @@ -247,6 +249,21 @@ spdk_scsi_lun_hot_remove(void *remove_ctx) spdk_poller_register(&lun->hotplug_poller, spdk_scsi_lun_hotplug, lun, lun->lcore, 0); } +static void +spdk_scsi_lun_hot_remove(void *remove_ctx) +{ + struct spdk_scsi_lun *lun = (struct spdk_scsi_lun *)remove_ctx; + + if (lun->lcore != spdk_env_get_current_core()) { + struct spdk_event *event; + + event = spdk_event_allocate(lun->lcore, _spdk_scsi_lun_hot_remove, lun, NULL); + spdk_event_call(event); + } else { + _spdk_scsi_lun_hot_remove(lun, NULL); + } +} + /** * \brief Constructs a new spdk_scsi_lun object based on the provided parameters. * diff --git a/test/unit/lib/scsi/lun.c/lun_ut.c b/test/unit/lib/scsi/lun.c/lun_ut.c index bd6ccb45d..f55caed37 100644 --- a/test/unit/lib/scsi/lun.c/lun_ut.c +++ b/test/unit/lib/scsi/lun.c/lun_ut.c @@ -66,6 +66,22 @@ spdk_poller_unregister(struct spdk_poller **ppoller, { } +struct spdk_event * +spdk_event_allocate(uint32_t lcore, spdk_event_fn fn, + void *arg1, void *arg2) +{ + return NULL; +} + +/** + * \brief Pass the given event to the associated lcore and call the function. + */ +void +spdk_event_call(struct spdk_event *event) +{ + +} + uint32_t spdk_env_get_current_core(void) {