diff --git a/lib/scsi/lun.c b/lib/scsi/lun.c index f2e7495a3..a25764347 100644 --- a/lib/scsi/lun.c +++ b/lib/scsi/lun.c @@ -237,12 +237,10 @@ spdk_scsi_lun_hotplug(void *arg) } static void -_spdk_scsi_lun_hot_remove(void *arg1, void *arg2) +_spdk_scsi_lun_hot_remove(void *arg1) { struct spdk_scsi_lun *lun = arg1; - assert(lun->lcore == spdk_env_get_current_core()); - lun->removed = true; if (lun->hotremove_cb) { lun->hotremove_cb(lun, lun->hotremove_ctx); @@ -255,14 +253,18 @@ static void spdk_scsi_lun_hot_remove(void *remove_ctx) { struct spdk_scsi_lun *lun = (struct spdk_scsi_lun *)remove_ctx; + struct spdk_thread *thread; - if (lun->lcore != spdk_env_get_current_core()) { - struct spdk_event *event; + if (lun->io_channel == NULL) { + _spdk_scsi_lun_hot_remove(lun); + return; + } - event = spdk_event_allocate(lun->lcore, _spdk_scsi_lun_hot_remove, lun, NULL); - spdk_event_call(event); + thread = spdk_io_channel_get_thread(lun->io_channel); + if (thread != spdk_get_thread()) { + spdk_thread_send_msg(thread, _spdk_scsi_lun_hot_remove, lun); } else { - _spdk_scsi_lun_hot_remove(lun, NULL); + _spdk_scsi_lun_hot_remove(lun); } } @@ -311,6 +313,7 @@ spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev, TAILQ_INIT(&lun->pending_tasks); lun->bdev = bdev; + lun->io_channel = NULL; snprintf(lun->name, sizeof(lun->name), "%s", name); lun->hotremove_cb = hotremove_cb; lun->hotremove_ctx = hotremove_ctx; @@ -369,8 +372,6 @@ int spdk_scsi_lun_allocate_io_channel(struct spdk_scsi_lun *lun) return -1; } - lun->lcore = spdk_env_get_current_core(); - lun->io_channel = spdk_bdev_get_io_channel(lun->bdev_desc); if (lun->io_channel == NULL) { return -1; diff --git a/lib/scsi/scsi_internal.h b/lib/scsi/scsi_internal.h index 6b09757dc..3624ddd9e 100644 --- a/lib/scsi/scsi_internal.h +++ b/lib/scsi/scsi_internal.h @@ -101,9 +101,6 @@ struct spdk_scsi_lun { /** Poller to release the resource of the lun when it is hot removed */ struct spdk_poller *hotplug_poller; - /** The core hotplug_poller is assigned */ - uint32_t lcore; - /** The LUN is removed */ bool removed; diff --git a/test/unit/lib/scsi/lun.c/lun_ut.c b/test/unit/lib/scsi/lun.c/lun_ut.c index 16d4fba9b..3a86f5d68 100644 --- a/test/unit/lib/scsi/lun.c/lun_ut.c +++ b/test/unit/lib/scsi/lun.c/lun_ut.c @@ -67,26 +67,9 @@ 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) +spdk_thread_send_msg(const struct spdk_thread *thread, spdk_thread_fn fn, void *ctx) { - -} - -uint32_t -spdk_env_get_current_core(void) -{ - return 0; } void spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,