From: Mike Christie <[EMAIL PROTECTED]>

This merges the actors used with fc_fcp_cleanup_each_cmd, becuase
it seems like we should be calling the exch_done in call cases.
The mgr reset code call after the abort io or cleanup call would
actually for this, but it is cleanup for the upper layer to clean
it self up when called to do so.

This patch also fixes some error codes.

fc_fcp_abort_io is used during lport destruction so we want to use
DID_NO_CONNECT, so there are no retries. There also does not seem
to be much us in not calling exch_done if FC_SRB_RCV_STATUS is set
because it will be so rare that we hit this race where it will succeed
(the mgr reset call will kill this command too).

fc_fcp_cleanup is used during possibly recoverable errors so we do not
want to use DID_NO_CONNECT and want to use DID_ERROR.

Signed-off-by: Mike Christie <[EMAIL PROTECTED]>
---
 drivers/scsi/libfc/fc_fcp.c |   57 +++++++++++++------------------------------
 1 files changed, 17 insertions(+), 40 deletions(-)

diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index c519b43..99bfadf 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -850,20 +850,28 @@ static void fc_fcp_complete(struct fc_fcp_pkt *fsp)
        fc_io_compl(fsp);
 }
 
+static void fc_fcp_cleanup_cmd(struct fc_fcp_pkt *fsp, int error)
+{
+       struct fc_lport *lp = fsp->lp;
+
+       if (fsp->seq_ptr) {
+               lp->tt.exch_done(fsp->seq_ptr);
+               fsp->seq_ptr = NULL;
+       }
+       fsp->status_code = error;
+}
+
 /**
  * fc_fcp_cleanup_each_cmd - run fn on each active command
  * @lp:                logical port
  * @id:                target id
  * @lun:       lun
- * @fn:                actor function
+ * @error:     fsp status code
  *
  * If lun or id is -1, they are ignored.
- *
- * @fn must not call fs_io_compl on the fsp.
  */
 static void fc_fcp_cleanup_each_cmd(struct fc_lport *lp, unsigned int id,
-                                   unsigned int lun,
-                                   void (*fn)(struct fc_fcp_pkt *))
+                                   unsigned int lun, int error)
 {
        struct fc_fcp_internal *si = fc_get_scsi_internal(lp);
        struct fc_fcp_pkt *fsp;
@@ -884,7 +892,7 @@ restart:
                spin_unlock_irqrestore(lp->host->host_lock, flags);
 
                if (!fc_fcp_lock_pkt(fsp)) {
-                       fn(fsp);
+                       fc_fcp_cleanup_cmd(fsp, error);
                        fc_io_compl(fsp);
                        fc_fcp_unlock_pkt(fsp);
                }
@@ -900,23 +908,9 @@ restart:
        spin_unlock_irqrestore(lp->host->host_lock, flags);
 }
 
-static void fc_fcp_cleanup_aborted_io(struct fc_fcp_pkt *fsp)
-{
-       struct fc_lport *lp = fsp->lp;
-
-       if (!(fsp->state & FC_SRB_RCV_STATUS)) {
-               if (fsp->seq_ptr) {
-                       lp->tt.exch_done(fsp->seq_ptr);
-                       fsp->seq_ptr = NULL;
-               }
-       }
-       fsp->status_code = FC_ERROR;
-       fsp->io_status = (SUGGEST_RETRY << 24);
-}
-
 static void fc_fcp_abort_io(struct fc_lport *lp)
 {
-       fc_fcp_cleanup_each_cmd(lp, -1, -1, fc_fcp_cleanup_aborted_io);
+       fc_fcp_cleanup_each_cmd(lp, -1, -1, FC_HRD_ERROR);
 }
 
 /**
@@ -1121,17 +1115,6 @@ unlock:
        spin_unlock_bh(&fsp->scsi_pkt_lock);
 }
 
-static void fc_fcp_cleanup_lun_reset(struct fc_fcp_pkt *fsp)
-{
-       struct fc_lport *lp = fsp->lp;
-
-       fsp->status_code = FC_CMD_ABORTED;
-       if (fsp->seq_ptr) {
-               lp->tt.exch_done(fsp->seq_ptr);
-               fsp->seq_ptr = NULL;
-       }
-}
-
 /*
  * Scsi device reset handler- send a LUN RESET to the device
  * and wait for reset reply
@@ -1186,7 +1169,7 @@ static int fc_lun_reset(struct fc_lport *lp, struct 
fc_fcp_pkt *fsp,
                return FAILED;
 
        FC_DBG("lun reset to lun %u completed\n", lun);
-       fc_fcp_cleanup_each_cmd(lp, id, lun, fc_fcp_cleanup_lun_reset);
+       fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED);
        return SUCCESS;
 }
 
@@ -1231,14 +1214,9 @@ static void fc_tm_done(struct fc_seq *sp, struct 
fc_frame *fp, void *arg)
        spin_unlock_bh(&fsp->scsi_pkt_lock);
 }
 
-static void fc_fcp_cleanup_io(struct fc_fcp_pkt *fsp)
-{
-       fsp->status_code = FC_HRD_ERROR;
-}
-
 static void fc_fcp_cleanup(struct fc_lport *lp)
 {
-       fc_fcp_cleanup_each_cmd(lp, -1, -1, fc_fcp_cleanup_io);
+       fc_fcp_cleanup_each_cmd(lp, -1, -1, FC_ERROR);
 }
 
 /*
@@ -1490,7 +1468,6 @@ out:
  */
 static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 {
-       struct fc_lport *lp = fsp->lp;
        int error = PTR_ERR(fp);
 
        if (fc_fcp_lock_pkt(fsp))
-- 
1.5.4.1

_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel

Reply via email to