diff options
author | Vasu Dev <vasu.dev@intel.com> | 2011-04-01 19:06:40 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2011-05-01 11:20:56 -0400 |
commit | f2817ec2e0faece03959888050730ed35e5f2bd2 (patch) | |
tree | 05628b7801247236141d2edbfd21975f31631184 /drivers/scsi/libfc | |
parent | 66a5b3acba563b53cfbca96c7fff2207c94a87e2 (diff) |
[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>
Diffstat (limited to 'drivers/scsi/libfc')
-rw-r--r-- | drivers/scsi/libfc/fc_fcp.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index 3591b872dd0e..2a3a4720a771 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c | |||
@@ -57,9 +57,6 @@ static struct kmem_cache *scsi_pkt_cachep; | |||
57 | #define FC_SRB_READ (1 << 1) | 57 | #define FC_SRB_READ (1 << 1) |
58 | #define FC_SRB_WRITE (1 << 0) | 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 | * The SCp.ptr should be tested and set under the scsi_pkt_queue lock | 61 | * The SCp.ptr should be tested and set under the scsi_pkt_queue lock |
65 | */ | 62 | */ |
@@ -248,7 +245,7 @@ static inline void fc_fcp_unlock_pkt(struct fc_fcp_pkt *fsp) | |||
248 | /** | 245 | /** |
249 | * fc_fcp_timer_set() - Start a timer for a fcp_pkt | 246 | * fc_fcp_timer_set() - Start a timer for a fcp_pkt |
250 | * @fsp: The FCP packet to start a timer for | 247 | * @fsp: The FCP packet to start a timer for |
251 | * @delay: The timeout period for the timer | 248 | * @delay: The timeout period in jiffies |
252 | */ | 249 | */ |
253 | static void fc_fcp_timer_set(struct fc_fcp_pkt *fsp, unsigned long delay) | 250 | static void fc_fcp_timer_set(struct fc_fcp_pkt *fsp, unsigned long delay) |
254 | { | 251 | { |
@@ -1098,16 +1095,14 @@ static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp) | |||
1098 | /** | 1095 | /** |
1099 | * get_fsp_rec_tov() - Helper function to get REC_TOV | 1096 | * get_fsp_rec_tov() - Helper function to get REC_TOV |
1100 | * @fsp: the FCP packet | 1097 | * @fsp: the FCP packet |
1098 | * | ||
1099 | * Returns rec tov in jiffies as rpriv->e_d_tov + 1 second | ||
1101 | */ | 1100 | */ |
1102 | static inline unsigned int get_fsp_rec_tov(struct fc_fcp_pkt *fsp) | 1101 | static inline unsigned int get_fsp_rec_tov(struct fc_fcp_pkt *fsp) |
1103 | { | 1102 | { |
1104 | struct fc_rport *rport; | 1103 | struct fc_rport_libfc_priv *rpriv = fsp->rport->dd_data; |
1105 | struct fc_rport_libfc_priv *rpriv; | ||
1106 | 1104 | ||
1107 | rport = fsp->rport; | 1105 | return msecs_to_jiffies(rpriv->e_d_tov) + HZ; |
1108 | rpriv = rport->dd_data; | ||
1109 | |||
1110 | return rpriv->e_d_tov + REC_TOV_CONST; | ||
1111 | } | 1106 | } |
1112 | 1107 | ||
1113 | /** | 1108 | /** |
@@ -1127,7 +1122,6 @@ static int fc_fcp_cmd_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp, | |||
1127 | struct fc_rport_libfc_priv *rpriv; | 1122 | struct fc_rport_libfc_priv *rpriv; |
1128 | const size_t len = sizeof(fsp->cdb_cmd); | 1123 | const size_t len = sizeof(fsp->cdb_cmd); |
1129 | int rc = 0; | 1124 | int rc = 0; |
1130 | unsigned int rec_tov; | ||
1131 | 1125 | ||
1132 | if (fc_fcp_lock_pkt(fsp)) | 1126 | if (fc_fcp_lock_pkt(fsp)) |
1133 | return 0; | 1127 | return 0; |
@@ -1158,12 +1152,9 @@ static int fc_fcp_cmd_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp, | |||
1158 | fsp->seq_ptr = seq; | 1152 | fsp->seq_ptr = seq; |
1159 | fc_fcp_pkt_hold(fsp); /* hold for fc_fcp_pkt_destroy */ | 1153 | fc_fcp_pkt_hold(fsp); /* hold for fc_fcp_pkt_destroy */ |
1160 | 1154 | ||
1161 | rec_tov = get_fsp_rec_tov(fsp); | ||
1162 | |||
1163 | setup_timer(&fsp->timer, fc_fcp_timeout, (unsigned long)fsp); | 1155 | setup_timer(&fsp->timer, fc_fcp_timeout, (unsigned long)fsp); |
1164 | |||
1165 | if (rpriv->flags & FC_RP_FLAGS_REC_SUPPORTED) | 1156 | if (rpriv->flags & FC_RP_FLAGS_REC_SUPPORTED) |
1166 | fc_fcp_timer_set(fsp, rec_tov); | 1157 | fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); |
1167 | 1158 | ||
1168 | unlock: | 1159 | unlock: |
1169 | fc_fcp_unlock_pkt(fsp); | 1160 | fc_fcp_unlock_pkt(fsp); |
@@ -1240,16 +1231,14 @@ static void fc_lun_reset_send(unsigned long data) | |||
1240 | { | 1231 | { |
1241 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data; | 1232 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data; |
1242 | struct fc_lport *lport = fsp->lp; | 1233 | struct fc_lport *lport = fsp->lp; |
1243 | unsigned int rec_tov; | ||
1244 | 1234 | ||
1245 | if (lport->tt.fcp_cmd_send(lport, fsp, fc_tm_done)) { | 1235 | if (lport->tt.fcp_cmd_send(lport, fsp, fc_tm_done)) { |
1246 | if (fsp->recov_retry++ >= FC_MAX_RECOV_RETRY) | 1236 | if (fsp->recov_retry++ >= FC_MAX_RECOV_RETRY) |
1247 | return; | 1237 | return; |
1248 | if (fc_fcp_lock_pkt(fsp)) | 1238 | if (fc_fcp_lock_pkt(fsp)) |
1249 | return; | 1239 | return; |
1250 | rec_tov = get_fsp_rec_tov(fsp); | ||
1251 | setup_timer(&fsp->timer, fc_lun_reset_send, (unsigned long)fsp); | 1240 | setup_timer(&fsp->timer, fc_lun_reset_send, (unsigned long)fsp); |
1252 | fc_fcp_timer_set(fsp, rec_tov); | 1241 | fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); |
1253 | fc_fcp_unlock_pkt(fsp); | 1242 | fc_fcp_unlock_pkt(fsp); |
1254 | } | 1243 | } |
1255 | } | 1244 | } |
@@ -1541,12 +1530,11 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
1541 | } | 1530 | } |
1542 | fc_fcp_srr(fsp, r_ctl, offset); | 1531 | fc_fcp_srr(fsp, r_ctl, offset); |
1543 | } else if (e_stat & ESB_ST_SEQ_INIT) { | 1532 | } else if (e_stat & ESB_ST_SEQ_INIT) { |
1544 | unsigned int rec_tov = get_fsp_rec_tov(fsp); | ||
1545 | /* | 1533 | /* |
1546 | * The remote port has the initiative, so just | 1534 | * The remote port has the initiative, so just |
1547 | * keep waiting for it to complete. | 1535 | * keep waiting for it to complete. |
1548 | */ | 1536 | */ |
1549 | fc_fcp_timer_set(fsp, rec_tov); | 1537 | fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); |
1550 | } else { | 1538 | } else { |
1551 | 1539 | ||
1552 | /* | 1540 | /* |
@@ -1710,7 +1698,6 @@ static void fc_fcp_srr_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
1710 | { | 1698 | { |
1711 | struct fc_fcp_pkt *fsp = arg; | 1699 | struct fc_fcp_pkt *fsp = arg; |
1712 | struct fc_frame_header *fh; | 1700 | struct fc_frame_header *fh; |
1713 | unsigned int rec_tov; | ||
1714 | 1701 | ||
1715 | if (IS_ERR(fp)) { | 1702 | if (IS_ERR(fp)) { |
1716 | fc_fcp_srr_error(fsp, fp); | 1703 | fc_fcp_srr_error(fsp, fp); |
@@ -1737,8 +1724,7 @@ static void fc_fcp_srr_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
1737 | switch (fc_frame_payload_op(fp)) { | 1724 | switch (fc_frame_payload_op(fp)) { |
1738 | case ELS_LS_ACC: | 1725 | case ELS_LS_ACC: |
1739 | fsp->recov_retry = 0; | 1726 | fsp->recov_retry = 0; |
1740 | rec_tov = get_fsp_rec_tov(fsp); | 1727 | fc_fcp_timer_set(fsp, get_fsp_rec_tov(fsp)); |
1741 | fc_fcp_timer_set(fsp, rec_tov); | ||
1742 | break; | 1728 | break; |
1743 | case ELS_LS_RJT: | 1729 | case ELS_LS_RJT: |
1744 | default: | 1730 | default: |