Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] libfc: rec tov value and REC_TOV_CONST units usages is incorrect

Added REC_TOV_CONST intent was to have rec tov as e_d_tov + 1s
but currently it is e_d_tov + 1ms since e_d_tov is stored in ms
unit.

Also returned rec tov by get_fsp_rec_tov is in ms and this ms tov
is used as-is with fc_fcp_timer_set expecting jiffies tov.

Fixed this by having get_fsp_rec_tov return rec tov in jiffies
as e_d_tov + 1s and then use jiffies tov w/ fc_fcp_timer_set.

Also some cleanup, no need to cache get_fsp_rec_tov return value
in local rec_tov at various places.

Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

authored by

Vasu Dev and committed by
James Bottomley
f2817ec2 66a5b3ac

+9 -23
+9 -23
drivers/scsi/libfc/fc_fcp.c
··· 57 57 #define FC_SRB_READ (1 << 1) 58 58 #define FC_SRB_WRITE (1 << 0) 59 59 60 - /* constant added to e_d_tov timeout to get rec_tov value */ 61 - #define REC_TOV_CONST 1 62 - 63 60 /* 64 61 * The SCp.ptr should be tested and set under the scsi_pkt_queue lock 65 62 */ ··· 245 248 /** 246 249 * fc_fcp_timer_set() - Start a timer for a fcp_pkt 247 250 * @fsp: The FCP packet to start a timer for 248 - * @delay: The timeout period for the timer 251 + * @delay: The timeout period in jiffies 249 252 */ 250 253 static void fc_fcp_timer_set(struct fc_fcp_pkt *fsp, unsigned long delay) 251 254 { ··· 1095 1098 /** 1096 1099 * get_fsp_rec_tov() - Helper function to get REC_TOV 1097 1100 * @fsp: the FCP packet 1101 + * 1102 + * Returns rec tov in jiffies as rpriv->e_d_tov + 1 second 1098 1103 */ 1099 1104 static inline unsigned int get_fsp_rec_tov(struct fc_fcp_pkt *fsp) 1100 1105 { 1101 - struct fc_rport *rport; 1102 - struct fc_rport_libfc_priv *rpriv; 1106 + struct fc_rport_libfc_priv *rpriv = fsp->rport->dd_data; 1103 1107 1104 - rport = fsp->rport; 1105 - rpriv = rport->dd_data; 1106 - 1107 - return rpriv->e_d_tov + REC_TOV_CONST; 1108 + return msecs_to_jiffies(rpriv->e_d_tov) + HZ; 1108 1109 } 1109 1110 1110 1111 /** ··· 1122 1127 struct fc_rport_libfc_priv *rpriv; 1123 1128 const size_t len = sizeof(fsp->cdb_cmd); 1124 1129 int rc = 0; 1125 - unsigned int rec_tov; 1126 1130 1127 1131 if (fc_fcp_lock_pkt(fsp)) 1128 1132 return 0; ··· 1152 1158 fsp->seq_ptr = seq; 1153 1159 fc_fcp_pkt_hold(fsp); /* hold for fc_fcp_pkt_destroy */ 1154 1160 1155 - rec_tov = get_fsp_rec_tov(fsp); 1156 - 1157 1161 setup_timer(&fsp->timer, fc_fcp_timeout, (unsigned long)fsp); 1158 - 1159 1162 if (rpriv->flags & FC_RP_FLAGS_REC_SUPPORTED) 1160 - fc_fcp_timer_set(fsp, rec_tov); 1163 + fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); 1161 1164 1162 1165 unlock: 1163 1166 fc_fcp_unlock_pkt(fsp); ··· 1231 1240 { 1232 1241 struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data; 1233 1242 struct fc_lport *lport = fsp->lp; 1234 - unsigned int rec_tov; 1235 1243 1236 1244 if (lport->tt.fcp_cmd_send(lport, fsp, fc_tm_done)) { 1237 1245 if (fsp->recov_retry++ >= FC_MAX_RECOV_RETRY) 1238 1246 return; 1239 1247 if (fc_fcp_lock_pkt(fsp)) 1240 1248 return; 1241 - rec_tov = get_fsp_rec_tov(fsp); 1242 1249 setup_timer(&fsp->timer, fc_lun_reset_send, (unsigned long)fsp); 1243 - fc_fcp_timer_set(fsp, rec_tov); 1250 + fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); 1244 1251 fc_fcp_unlock_pkt(fsp); 1245 1252 } 1246 1253 } ··· 1530 1541 } 1531 1542 fc_fcp_srr(fsp, r_ctl, offset); 1532 1543 } else if (e_stat & ESB_ST_SEQ_INIT) { 1533 - unsigned int rec_tov = get_fsp_rec_tov(fsp); 1534 1544 /* 1535 1545 * The remote port has the initiative, so just 1536 1546 * keep waiting for it to complete. 1537 1547 */ 1538 - fc_fcp_timer_set(fsp, rec_tov); 1548 + fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); 1539 1549 } else { 1540 1550 1541 1551 /* ··· 1698 1710 { 1699 1711 struct fc_fcp_pkt *fsp = arg; 1700 1712 struct fc_frame_header *fh; 1701 - unsigned int rec_tov; 1702 1713 1703 1714 if (IS_ERR(fp)) { 1704 1715 fc_fcp_srr_error(fsp, fp); ··· 1724 1737 switch (fc_frame_payload_op(fp)) { 1725 1738 case ELS_LS_ACC: 1726 1739 fsp->recov_retry = 0; 1727 - rec_tov = get_fsp_rec_tov(fsp); 1728 - fc_fcp_timer_set(fsp, rec_tov); 1740 + fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); 1729 1741 break; 1730 1742 case ELS_LS_RJT: 1731 1743 default: