Commit bc436b27 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] libiscsi: grab eh_mutex during host reset

I thought we may not need the eh mutex during host reset, but that is wrong
with the new shutdown code. When start_session_recovery sets the state to
terminate then drops the session lock. The scsi eh thread could then grab the
session lock see that we are terminating and then return failed to scsi-ml.
scsi-ml's eh then owns the command and will do whatever it wants
with it. But then the iscsi eh thread could grab the session lock
and want to complete the scsi commands that we in the LLD, but
it no longer owns them and kaboom.
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent d8bf541e
...@@ -1079,17 +1079,19 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc) ...@@ -1079,17 +1079,19 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc)
struct iscsi_session *session = iscsi_hostdata(host->hostdata); struct iscsi_session *session = iscsi_hostdata(host->hostdata);
struct iscsi_conn *conn = session->leadconn; struct iscsi_conn *conn = session->leadconn;
mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
if (session->state == ISCSI_STATE_TERMINATE) { if (session->state == ISCSI_STATE_TERMINATE) {
failed: failed:
debug_scsi("failing host reset: session terminated " debug_scsi("failing host reset: session terminated "
"[CID %d age %d]\n", conn->id, session->age); "[CID %d age %d]\n", conn->id, session->age);
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex);
return FAILED; return FAILED;
} }
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex);
/* /*
* we drop the lock here but the leadconn cannot be destoyed while * we drop the lock here but the leadconn cannot be destoyed while
* we are in the scsi eh * we are in the scsi eh
...@@ -1104,13 +1106,14 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc) ...@@ -1104,13 +1106,14 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc)
if (signal_pending(current)) if (signal_pending(current))
flush_signals(current); flush_signals(current);
mutex_lock(&session->eh_mutex);
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
if (session->state == ISCSI_STATE_LOGGED_IN) if (session->state == ISCSI_STATE_LOGGED_IN)
printk(KERN_INFO "iscsi: host reset succeeded\n"); printk(KERN_INFO "iscsi: host reset succeeded\n");
else else
goto failed; goto failed;
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
mutex_unlock(&session->eh_mutex);
return SUCCESS; return SUCCESS;
} }
EXPORT_SYMBOL_GPL(iscsi_eh_host_reset); EXPORT_SYMBOL_GPL(iscsi_eh_host_reset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment