public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: dillowda-1Heg1YXhbW8@public.gmane.org,
	roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org
Subject: [PATCH 01/15] ib_srp: Enlarge block layer timeout
Date: Sun, 25 Mar 2012 14:47:06 +0000	[thread overview]
Message-ID: <1385797.u8D4MDGaaX@asus> (raw)
In-Reply-To: <5207288.nSt5MkVMpO@asus>

Enlarge the block layer timeout for disks such that it is above
the InfiniBand transport layer timeout. This is necessary to avoid
that an SRP response is received after the SCSI layer has already
killed the associated SCSI command.

Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: David Dillow <dillowda-1Heg1YXhbW8@public.gmane.org>
Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
---
 drivers/infiniband/ulp/srp/ib_srp.c |   45 +++++++++++++++++++++++++++++++++++
 drivers/infiniband/ulp/srp/ib_srp.h |    2 +
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index bcbf22e..5543c2b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1372,6 +1372,33 @@ err:
 	return -ENOMEM;
 }
 
+static uint32_t srp_compute_rq_tmo(struct ib_qp_attr *qp_attr, int attr_mask)
+{
+	uint64_t T_tr_ns, max_compl_time_ms;
+	uint32_t rq_tmo_jiffies;
+
+	/*
+	 * According to section 11.2.4.2 in the IBTA spec (Modify Queue Pair,
+	 * table 91), both the QP timeout and the retry count have to be set
+	 * for RC QP's during the RTR to RTS transition.
+	 */
+	WARN_ON((attr_mask & (IB_QP_TIMEOUT | IB_QP_RETRY_CNT)) !=
+		(IB_QP_TIMEOUT | IB_QP_RETRY_CNT));
+
+	/*
+	 * Set target->rq_tmo_jiffies to one second more than the largest time
+	 * it can take before an error completion is generated. See also
+	 * C9-140..C9-142 in the IBTA spec for more information about how to
+	 * convert the QP Local ACK Timeout value to nanoseconds.
+	 */
+	T_tr_ns = 4096 * (1ULL << qp_attr->timeout);
+	max_compl_time_ms = qp_attr->retry_cnt * 4 * T_tr_ns;
+	do_div(max_compl_time_ms, NSEC_PER_MSEC);
+	rq_tmo_jiffies = msecs_to_jiffies(max_compl_time_ms + 1000);
+
+	return rq_tmo_jiffies;
+}
+
 static void srp_cm_rep_handler(struct ib_cm_id *cm_id,
 			       struct srp_login_rsp *lrsp,
 			       struct srp_target_port *target)
@@ -1431,6 +1458,8 @@ static void srp_cm_rep_handler(struct ib_cm_id *cm_id,
 	if (ret)
 		goto error_free;
 
+	target->rq_tmo_jiffies = srp_compute_rq_tmo(qp_attr, attr_mask);
+
 	ret = ib_modify_qp(target->qp, qp_attr, attr_mask);
 	if (ret)
 		goto error_free;
@@ -1689,6 +1718,21 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
 	return ret;
 }
 
+static int srp_slave_configure(struct scsi_device *sdev)
+{
+	struct Scsi_Host *shost = sdev->host;
+	struct srp_target_port *target = host_to_target(shost);
+	struct request_queue *q = sdev->request_queue;
+	unsigned long timeout;
+
+	if (sdev->type == TYPE_DISK) {
+		timeout = max_t(unsigned, 30 * HZ, target->rq_tmo_jiffies);
+		blk_queue_rq_timeout(q, timeout);
+	}
+
+	return 0;
+}
+
 static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr,
 			   char *buf)
 {
@@ -1821,6 +1865,7 @@ static struct scsi_host_template srp_template = {
 	.module				= THIS_MODULE,
 	.name				= "InfiniBand SRP initiator",
 	.proc_name			= DRV_NAME,
+	.slave_configure		= srp_slave_configure,
 	.info				= srp_target_info,
 	.queuecommand			= srp_queuecommand,
 	.eh_abort_handler		= srp_abort,
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 020caf0..e3a6304 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -163,6 +163,8 @@ struct srp_target_port {
 	struct ib_sa_query     *path_query;
 	int			path_query_id;
 
+	u32			rq_tmo_jiffies;
+
 	struct ib_cm_id	       *cm_id;
 
 	int			max_ti_iu_len;
-- 
1.7.7


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2012-03-25 14:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-25 14:45 [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
2012-03-25 14:47 ` Bart Van Assche [this message]
2012-03-29 16:59   ` [PATCH 01/15] ib_srp: Enlarge block layer timeout Dave Dillow
     [not found]     ` <20120329165931.GA19700-1Heg1YXhbW8@public.gmane.org>
2012-04-22 16:01       ` Bart Van Assche
     [not found]         ` <4F942B74.4040106-HInyCGIudOg@public.gmane.org>
2012-04-30 15:11           ` David Dillow
     [not found]             ` <1335798691.441.2.camel-zHLflQxYYDO4Hhoo1DtQwJ9G+ZOsUmrO@public.gmane.org>
2012-05-19 10:50               ` Bart Van Assche
     [not found]                 ` <4FB77AEE.7030100-HInyCGIudOg@public.gmane.org>
2012-05-30  4:56                   ` David Dillow
2012-03-25 14:48 ` [PATCH 02/15] ib_srp: Introduce srp_handle_qp_err() Bart Van Assche
2012-03-25 14:50 ` [PATCH 03/15] ib_srp: Micro-optimize srp_queuecommand() Bart Van Assche
2012-03-25 14:52 ` [PATCH 04/15] ib_srp: Suppress superfluous error messages Bart Van Assche
2012-03-25 14:53 ` [PATCH 05/15] ib_srp: Avoid that SCSI error handling triggers a crash Bart Van Assche
2012-03-25 14:54 ` [PATCH 06/15] ib_srp: Introduce the helper function srp_remove_target() Bart Van Assche
2012-03-25 14:55 ` [PATCH 07/15] ib_srp: Eliminate state SRP_TARGET_DEAD Bart Van Assche
2012-03-25 14:56 ` [PATCH 08/15] ib_srp: Make srp_disconnect_target() wait for IB completions Bart Van Assche
2012-03-25 14:57 ` [PATCH 09/15] srp_transport: Fix atttribute registration Bart Van Assche
2012-03-25 14:58 ` [PATCH 10/15] srp_transport: Simplify attribute initialization code Bart Van Assche
2012-03-25 14:59 ` [PATCH 11/15] srp_transport: Document sysfs attributes Bart Van Assche
2012-03-25 15:00 ` [PATCH 12/15] ib_srp: " Bart Van Assche
2012-03-25 15:01 ` [PATCH 13/15] ib_srp: Allow SRP disconnect through sysfs Bart Van Assche
2012-07-16 22:20   ` Mike Christie
     [not found]     ` <500493B4.4010303-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
2012-07-17 12:55       ` bart-LmZ/31Jx5xYUl6sPKNhdgg
2012-03-25 15:02 ` [PATCH 14/15] ib_srp: Introduce a temporary variable in srp_remove_target() Bart Van Assche
2012-03-25 15:03 ` [PATCH 15/15] ib_srp: Maintain a single connection per I_T nexus Bart Van Assche
2012-03-25 15:18 ` [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
2012-03-27 16:37   ` Dave Dillow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1385797.u8D4MDGaaX@asus \
    --to=bvanassche-hinycgiudog@public.gmane.org \
    --cc=dillowda-1Heg1YXhbW8@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox