[Open-FCoE] [PATCH 2/3] libfc: fix last pkt jiffies test

michaelc at cs.wisc.edu michaelc at cs.wisc.edu
Wed Sep 17 21:36:39 UTC 2008


From: Mike Christie <michaelc at cs.wisc.edu>

This fixes jiffies wrap around by using the time_after_eq
wrapper.

This also sets the last pkt time to jiffies when we send the cmd.
It was getting set to zero when the command is allocated.

Signed-off-by: Mike Christie <michaelc at cs.wisc.edu>
---
 drivers/scsi/libfc/fc_fcp.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 67efa6f..20ef99b 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -1068,6 +1068,7 @@ static int fc_fcp_send_cmd(struct fc_fcp_pkt *fsp)
 		rc = -1;
 		goto unlock;
 	}
+	fsp->last_pkt_time = jiffies;
 	fsp->seq_ptr = sp;
 	fc_fcp_pkt_hold(fsp);	/* hold for fc_fcp_pkt_destroy */
 
@@ -1316,14 +1317,13 @@ static void fc_fcp_timeout(unsigned long data)
 
 	if (rp->flags & FC_RP_FLAGS_REC_SUPPORTED)
 		fc_fcp_rec(fsp);
-	/* TODO: change this to time_before/after */
-	else if (jiffies - fsp->last_pkt_time < FC_SCSI_ER_TIMEOUT / 2)
+	else if (time_after_eq(fsp->last_pkt_time + (FC_SCSI_ER_TIMEOUT / 2),
+			       jiffies))
 		fc_fcp_timer_set(fsp, FC_SCSI_ER_TIMEOUT);
 	else if (fsp->state & FC_SRB_RCV_STATUS)
 		fc_fcp_complete(fsp);
 	else
 		fc_timeout_error(fsp);
-
 	fsp->state &= ~FC_SRB_FCP_PROCESSING_TMO;
 unlock:
 	fc_fcp_unlock_pkt(fsp);
-- 
1.5.1.2




More information about the devel mailing list