]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fnic: Cleanup the I_O that has timed out and is used to issue LUN reset
authorJason Luo <zhangqing.luo@oracle.com>
Thu, 17 Mar 2016 03:14:24 +0000 (11:14 +0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Mon, 21 Mar 2016 16:00:49 +0000 (09:00 -0700)
From: Satish Kharat <satishkh@cisco.com>

In case of LUN reset, the device reset command is issued with one of
the I/Os that has timed out on that LUN. The change is to also return
this I/O with error status set to DID_RESET.
Fnic driver version changed from 1.6.0.19 to 1.6.0.20

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Orabug: 22918200
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
drivers/scsi/fnic/fnic.h
drivers/scsi/fnic/fnic_scsi.c

index 52a53f8a907ada9b21024040e5fea8a36b574367..1023eaea17f3d8e29587417f057ca7ae11c35f1e 100644 (file)
@@ -39,7 +39,7 @@
 
 #define DRV_NAME               "fnic"
 #define DRV_DESCRIPTION                "Cisco FCoE HBA Driver"
-#define DRV_VERSION            "1.6.0.19"
+#define DRV_VERSION            "1.6.0.20"
 #define PFX                    DRV_NAME ": "
 #define DFX                     DRV_NAME "%d: "
 
index 6417e548c90b918e7b39e836d231595bc37a33a3..8b0c5080132c44ab34f515263e17a890142c687e 100644 (file)
@@ -2020,7 +2020,8 @@ lr_io_req_end:
  * successfully aborted, 1 otherwise
  */
 static int fnic_clean_pending_aborts(struct fnic *fnic,
-                                    struct scsi_cmnd *lr_sc)
+                                    struct scsi_cmnd *lr_sc,
+                                        bool new_sc)
 {
        int tag, abt_tag;
        struct fnic_io_req *io_req;
@@ -2038,10 +2039,10 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
                spin_lock_irqsave(io_lock, flags);
                sc = scsi_host_find_tag(fnic->lport->host, tag);
                /*
-                * ignore this lun reset cmd or cmds that do not belong to
-                * this lun
+                * ignore this lun reset cmd if issued using new SC
+                * or cmds that do not belong to this lun
                 */
-               if (!sc || sc == lr_sc || sc->device != lun_dev) {
+               if (!sc || ((sc == lr_sc) && new_sc) || sc->device != lun_dev) {
                        spin_unlock_irqrestore(io_lock, flags);
                        continue;
                }
@@ -2147,11 +2148,26 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
                        goto clean_pending_aborts_end;
                }
                CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
-               CMD_SP(sc) = NULL;
+
+               /* original sc used for lr is handled by dev reset code */
+               if (sc != lr_sc)
+                       CMD_SP(sc) = NULL;
                spin_unlock_irqrestore(io_lock, flags);
+               /* original sc used for lr is handled by dev reset code */
+               if (sc != lr_sc) {
+                       fnic_release_ioreq_buf(fnic, io_req, sc);
+                       mempool_free(io_req, fnic->io_req_pool);
+               }
 
-               fnic_release_ioreq_buf(fnic, io_req, sc);
-               mempool_free(io_req, fnic->io_req_pool);
+               /*
+                * Any IO is returned during reset, it needs to call scsi_done
+                * to return the scsi_cmnd to upper layer.
+                */
+               if (sc->scsi_done) {
+                       /* Set result to let upper SCSI layer retry */
+                       sc->result = DID_RESET << 16;
+                       sc->scsi_done(sc);
+               }
        }
 
        schedule_timeout(msecs_to_jiffies(2 * fnic->config.ed_tov));
@@ -2245,7 +2261,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
        int tag = 0;
        DECLARE_COMPLETION_ONSTACK(tm_done);
        int tag_gen_flag = 0;   /*to track tags allocated by fnic driver*/
-
+       bool new_sc = 0;
        /* Wait for rport to unblock */
        fc_block_scsi_eh(sc);
 
@@ -2431,7 +2447,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
         * the lun reset cmd. If all cmds get cleaned, the lun reset
         * succeeds
         */
-       if (fnic_clean_pending_aborts(fnic, sc)) {
+       if (fnic_clean_pending_aborts(fnic, sc, new_sc)) {
                spin_lock_irqsave(io_lock, flags);
                io_req = (struct fnic_io_req *)CMD_SP(sc);
                FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,