Commit:     bc436b278776d22eb10e7e75bf3e5257d14550a9
Parent:     d8bf541e657824cb03effd726ac96e2f4dcf58a5
Author:     Mike Christie <[EMAIL PROTECTED]>
AuthorDate: Thu Dec 13 12:43:28 2007 -0600
Committer:  James Bottomley <[EMAIL PROTECTED]>
CommitDate: Fri Jan 11 18:28:31 2008 -0600

    [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 
    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: Mike Christie <[EMAIL PROTECTED]>
    Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
 drivers/scsi/libiscsi.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index b7a2b9a..441e351 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1079,17 +1079,19 @@ int iscsi_eh_host_reset(struct scsi_cmnd *sc)
        struct iscsi_session *session = iscsi_hostdata(host->hostdata);
        struct iscsi_conn *conn = session->leadconn;
+       mutex_lock(&session->eh_mutex);
        if (session->state == ISCSI_STATE_TERMINATE) {
                debug_scsi("failing host reset: session terminated "
                           "[CID %d age %d]\n", conn->id, session->age);
+               mutex_unlock(&session->eh_mutex);
                return FAILED;
+       mutex_unlock(&session->eh_mutex);
         * we drop the lock here but the leadconn cannot be destoyed while
         * we are in the scsi eh
@@ -1104,13 +1106,14 @@ failed:
        if (signal_pending(current))
+       mutex_lock(&session->eh_mutex);
        if (session->state == ISCSI_STATE_LOGGED_IN)
                printk(KERN_INFO "iscsi: host reset succeeded\n");
                goto failed;
+       mutex_unlock(&session->eh_mutex);
        return SUCCESS;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to