linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Vu Pham <vu-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Or Gerlitz <or.gerlitz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	David Dillow <dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>,
	Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: [PATCH] IB/srp: Fail I/O requests if the transport is offline
Date: Fri, 15 Feb 2013 10:39:26 +0100	[thread overview]
Message-ID: <511E024E.70002@acm.org> (raw)
In-Reply-To: <5113F056.4020501-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

If an SRP target is no longer reachable and srp_reset_host()
fails to reconnect then ib_srp will invoke scsi_remove_host().
That function will invoke __scsi_remove_device() for each LUN.
And that last function will change the device state from
SDEV_TRANSPORT_OFFLINE into SDEV_CANCEL. Certain user space
software, e.g. older versions of multipathd, continue queueing
I/O to SCSI devices that are in the SDEV_CANCEL state. If these
I/O requests are submitted as SG_IO that means that the
REQ_PREEMPT flag will be set and hence that these requests will
be passed to srp_queuecommand(). These requests will time out.
If new requests are queued fast enough from user space these
active requests will prevent __scsi_remove_device() to finish.
Avoid this by failing I/O requests in the SDEV_CANCEL state if
the transport is offline. Introduce a new variable to keep
track of the transport state instead of failing requests if
(!target->connected || target->qp_in_error) such that the SCSI
error handler has a chance to retry commands after a transport
layer failure occurred.

Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: David Dillow <dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
Cc: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Vu Pham <vu-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/ulp/srp/ib_srp.c |    7 +++++++
 drivers/infiniband/ulp/srp/ib_srp.h |    1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 8a7eb9f..b34752d 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -734,6 +734,7 @@ static int srp_reconnect_target(struct srp_target_port *target)
 
 	scsi_target_unblock(&shost->shost_gendev, ret == 0 ? SDEV_RUNNING :
 			    SDEV_TRANSPORT_OFFLINE);
+	target->transport_offline = ret != 0;
 
 	if (ret)
 		goto err;
@@ -1353,6 +1354,12 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	unsigned long flags;
 	int len;
 
+	if (unlikely(target->transport_offline)) {
+		scmnd->result = DID_NO_CONNECT << 16;
+		scmnd->scsi_done(scmnd);
+		return 0;
+	}
+
 	spin_lock_irqsave(&target->lock, flags);
 	iu = __srp_get_tx_iu(target, SRP_IU_CMD);
 	if (!iu)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index de2d0b3..66fbedd 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -140,6 +140,7 @@ struct srp_target_port {
 	unsigned int		cmd_sg_cnt;
 	unsigned int		indirect_size;
 	bool			allow_ext_sg;
+	bool			transport_offline;
 
 	/* Everything above this point is used in the hot path of
 	 * command processing. Try to keep them packed into cachelines.
-- 
1.7.10.4

--
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

  parent reply	other threads:[~2013-02-15  9:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-01 15:18 [PATCH for 3.8 v3, resend 0/3] IB/SRP patches for kernel 3.8 Bart Van Assche
     [not found] ` <510BDCAA.204-HInyCGIudOg@public.gmane.org>
2013-02-01 15:18   ` [PATCH for 3.8 v3, resend 1/3] IB/srp: Track connection state properly Bart Van Assche
2013-02-01 15:19   ` [PATCH for 3.8 v3, resend 2/3] IB/srp: Avoid sending a task management function needlessly Bart Van Assche
2013-02-01 15:21   ` [PATCH for 3.8 v3, resend 3/3] IB/srp: Avoid endless SCSI error handling loop Bart Van Assche
2013-02-04 21:11   ` [PATCH for 3.8 v3, resend 0/3] IB/SRP patches for kernel 3.8 Or Gerlitz
     [not found]     ` <CAJZOPZLKQV0QvrW5sK8hQJf7AZc+1nUzp+5YCkZ3iVU4oTWbLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-05 16:25       ` Bart Van Assche
     [not found]         ` <5111327F.6050402-HInyCGIudOg@public.gmane.org>
2013-02-05 20:54           ` Or Gerlitz
     [not found]             ` <CAJZOPZ+-Zg=jnqg4ZmFL5Yo4_2DoWGcgy=3u6g3Rf9y80pXnpg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-06  7:22               ` Bart Van Assche
     [not found]                 ` <5112049B.8030406-HInyCGIudOg@public.gmane.org>
2013-02-06  7:44                   ` Or Gerlitz
     [not found]                     ` <511209E5.1010807-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-02-06  7:59                       ` Bart Van Assche
     [not found]                         ` <51120D4F.2070102-HInyCGIudOg@public.gmane.org>
2013-02-06  8:25                           ` Or Gerlitz
2013-02-06 21:42                   ` Vu Pham
     [not found]                     ` <5112CE60.2030607-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-02-07  9:05                       ` Bart Van Assche
     [not found]                         ` <51136E74.9090209-HInyCGIudOg@public.gmane.org>
2013-02-07  9:41                           ` Or Gerlitz
     [not found]                             ` <511376C2.6050100-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-02-07 10:15                               ` Bart Van Assche
2013-02-07 18:20                           ` Vu Pham
     [not found]                             ` <5113F056.4020501-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-02-15  9:39                               ` Bart Van Assche [this message]
     [not found]                                 ` <511E024E.70002-HInyCGIudOg@public.gmane.org>
2013-02-18  4:06                                   ` [PATCH] IB/srp: Fail I/O requests if the transport is offline David Dillow
     [not found]                                     ` <1361160385.7415.2.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2013-02-18  8:11                                       ` Sagi Grimberg
     [not found]                                         ` <5121E217.3080003-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-02-24  8:09                                           ` Bart Van Assche
     [not found]                                             ` <5129CAB6.5030506-HInyCGIudOg@public.gmane.org>
2013-02-24  8:59                                               ` Sagi Grimberg
     [not found]                                                 ` <5129D665.3070206-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-02-24 14:42                                                   ` Or Gerlitz
2013-02-21 16:10                                       ` Bart Van Assche

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=511E024E.70002@acm.org \
    --to=bvanassche-hinycgiudog@public.gmane.org \
    --cc=dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=or.gerlitz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=vu-VPRAkNaXOzVWk0Htik3J/w@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;
as well as URLs for NNTP newsgroup(s).