scsi/lun: fix hotremove with no io_channels open
When LUN with no io_channels is being hotremoved, the hotremove poller was being started on the core pointed by lun->lcore. However, this field is only valid when there are io_channels open. For example, when user tries to delete a bdev that's attached to an unused vhost controller (no io_channels ever opened) the scsi layer could start a hotremove poller on lun->lcore == 0. If SPDK runs on a different cpuset - not containing CPU0 - SPDK could even segfault. Change-Id: I31a363352875d944f220b0296d5cfe570319023d Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/371863 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
8b94174a4e
commit
fc03485b9d
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user