• John Soni Jose's avatar
    libiscsi: Fix host busy blocking during connection teardown · 660d0831
    John Soni Jose authored
    In case of hw iscsi offload, an host can have N-number of active
    connections. There can be IO's running on some connections which
    make host->host_busy always TRUE. Now if logout from a connection
    is tried then the code gets into an infinite loop as host->host_busy
    is always TRUE.
    
     iscsi_conn_teardown(....)
     {
       .........
        /*
         * Block until all in-progress commands for this connection
         * time out or fail.
         */
         for (;;) {
          spin_lock_irqsave(session->host->host_lock, flags);
          if (!atomic_read(&session->host->host_busy)) { /* OK for ERL == 0 */
    	      spin_unlock_irqrestore(session->host->host_lock, flags);
                  break;
          }
         spin_unlock_irqrestore(session->host->host_lock, flags);
         msleep_interruptible(500);
         iscsi_conn_printk(KERN_INFO, conn, "iscsi conn_destroy(): "
                     "host_busy %d host_failed %d\n",
    	          atomic_read(&session->host->host_busy),
    	          session->host->host_failed);
    
    	................
    	...............
         }
      }
    
    This is not an issue with software-iscsi/iser as each cxn is a separate
    host.
    
    Fix:
    Acquiring eh_mutex in iscsi_conn_teardown() before setting
    session->state = ISCSI_STATE_TERMINATE.
    Signed-off-by: default avatarJohn Soni Jose <sony.john@avagotech.com>
    Reviewed-by: default avatarMike Christie <michaelc@cs.wisc.edu>
    Reviewed-by: default avatarChris Leech <cleech@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarJames Bottomley <JBottomley@Odin.com>
    660d0831
libiscsi.c 96.6 KB