linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Vu Pham <vuhuong-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	David Dillow <dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>,
	Sebastian Parschauer
	<sebastian.riemer-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>,
	linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH 7/9] IB/srp: Avoid triggering an infinite loop if memory mapping fails
Date: Tue, 06 May 2014 14:55:33 +0200	[thread overview]
Message-ID: <5368DBC5.6070609@acm.org> (raw)
In-Reply-To: <5368DA5B.80609-HInyCGIudOg@public.gmane.org>

Only request the SCSI mid-layer to retry a SCSI command after a
temporary mapping failure (-ENOMEM) but not after a permanent
mapping failure. This patch avoids that SCSI commands are retried
indefinitely if a permanent memory mapping failure occurs.

Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Cc: David Dillow <dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
Cc: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Vu Pham <vu-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Sebastian Parschauer <sebastian.riemer-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 1c4b0d3..af94381 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1564,7 +1564,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	struct srp_cmd *cmd;
 	struct ib_device *dev;
 	unsigned long flags;
-	int len, result;
+	int len, result, ret = SCSI_MLQUEUE_HOST_BUSY;
 	const bool in_scsi_eh = !in_interrupt() && current == shost->ehandler;
 
 	/*
@@ -1580,6 +1580,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	if (unlikely(result)) {
 		scmnd->result = result;
 		scmnd->scsi_done(scmnd);
+		ret = 0;
 		goto unlock_rport;
 	}
 
@@ -1613,7 +1614,12 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	len = srp_map_data(scmnd, target, req);
 	if (len < 0) {
 		shost_printk(KERN_ERR, target->scsi_host,
-			     PFX "Failed to map data\n");
+			     PFX "Failed to map data (%d)\n", len);
+		if (len != -ENOMEM) {
+			scmnd->result = DID_ERROR << 16;
+			scmnd->scsi_done(scmnd);
+			ret = 0;
+		}
 		goto err_iu;
 	}
 
@@ -1625,11 +1631,13 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 		goto err_unmap;
 	}
 
+	ret = 0;
+
 unlock_rport:
 	if (in_scsi_eh)
 		mutex_unlock(&rport->mutex);
 
-	return 0;
+	return ret;
 
 err_unmap:
 	srp_unmap_data(scmnd, target, req);
@@ -1643,10 +1651,7 @@ err_iu:
 err_unlock:
 	spin_unlock_irqrestore(&target->lock, flags);
 
-	if (in_scsi_eh)
-		mutex_unlock(&rport->mutex);
-
-	return SCSI_MLQUEUE_HOST_BUSY;
+	goto unlock_rport;
 }
 
 /*
-- 
1.8.4.5

--
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:[~2014-05-06 12:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 12:49 [PATCH 0/9] SRP initiator patches for kernel 3.16 Bart Van Assche
     [not found] ` <5368DA5B.80609-HInyCGIudOg@public.gmane.org>
2014-05-06 12:50   ` [PATCH 1/9] IB/srp: Fix kernel-doc warnings Bart Van Assche
     [not found]     ` <5368DAB2.2070006-HInyCGIudOg@public.gmane.org>
2014-05-07 10:35       ` Sagi Grimberg
2014-05-06 12:51   ` [PATCH 2/9] IB/srp: Introduce an additional local variable Bart Van Assche
     [not found]     ` <5368DADF.2070105-HInyCGIudOg@public.gmane.org>
2014-05-07 10:37       ` Sagi Grimberg
     [not found]         ` <536A0CF7.7080307-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-05-07 13:52           ` Bart Van Assche
     [not found]             ` <536A3AA4.5010100-HInyCGIudOg@public.gmane.org>
2014-05-07 16:58               ` Sagi Grimberg
2014-05-06 12:52   ` [PATCH 3/9] IB/srp: Introduce srp_alloc_fmr_pool() Bart Van Assche
     [not found]     ` <5368DB05.4070600-HInyCGIudOg@public.gmane.org>
2014-05-07 10:38       ` Sagi Grimberg
2014-05-06 12:53   ` [PATCH 4/9] IB/srp: Introduce srp_map_fmr() Bart Van Assche
     [not found]     ` <5368DB2F.8020506-HInyCGIudOg@public.gmane.org>
2014-05-07 10:39       ` Sagi Grimberg
2014-05-06 12:53   ` [PATCH 5/9] IB/srp: Introduce srp_finish_mapping() Bart Van Assche
     [not found]     ` <5368DB58.6070502-HInyCGIudOg@public.gmane.org>
2014-05-07 10:41       ` Sagi Grimberg
2014-05-06 12:54   ` [PATCH 6/9] IB/srp: Make srp_alloc_req_data() reallocate request data Bart Van Assche
     [not found]     ` <5368DB90.9050209-HInyCGIudOg@public.gmane.org>
2014-05-07 10:50       ` Sagi Grimberg
     [not found]         ` <536A0FF7.7050608-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-05-07 14:11           ` Bart Van Assche
     [not found]             ` <536A3F08.7030108-HInyCGIudOg@public.gmane.org>
2014-05-07 16:58               ` Sagi Grimberg
2014-05-06 12:55   ` Bart Van Assche [this message]
     [not found]     ` <5368DBC5.6070609-HInyCGIudOg@public.gmane.org>
2014-05-07 10:50       ` [PATCH 7/9] IB/srp: Avoid triggering an infinite loop if memory mapping fails Sagi Grimberg
2014-05-06 12:56   ` [PATCH 8/9] IB/srp: Rename FMR-related variables Bart Van Assche
2014-05-06 12:56   ` [PATCH 9/9] IB/srp: Add fast registration support Bart Van Assche
     [not found]     ` <5368DC09.70608-HInyCGIudOg@public.gmane.org>
2014-05-07 11:34       ` Sagi Grimberg
     [not found]         ` <536A1A3A.9090208-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-05-07 14:59           ` Bart Van Assche
     [not found]             ` <536A4A68.4080605-HInyCGIudOg@public.gmane.org>
2014-05-07 17:19               ` Sagi Grimberg
     [not found]                 ` <536A6B2F.70807-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-05-08 12:38                   ` Bart Van Assche
     [not found]                     ` <536B7ABE.8080502-HInyCGIudOg@public.gmane.org>
2014-05-08 15:16                       ` Sagi Grimberg
     [not found]                         ` <536B9FB4.5040009-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-05-08 16:00                           ` Bart Van Assche
     [not found]                             ` <536BAA13.3050905-HInyCGIudOg@public.gmane.org>
2014-05-08 16:18                               ` Sagi Grimberg
2014-05-12 13:21                   ` Bart Van Assche
2014-05-06 14:06   ` [PATCH 0/9] SRP initiator patches for kernel 3.16 Jack Wang
     [not found]     ` <5368EC54.8020802-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-06 14:26       ` Bart Van Assche
2014-05-06 14:21   ` [PATCH 3/9] IB/srp: Introduce srp_alloc_fmr_pool() 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=5368DBC5.6070609@acm.org \
    --to=bvanassche-hinycgiudog@public.gmane.org \
    --cc=dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sebastian.riemer-EIkl63zCoXaH+58JC4qpiA@public.gmane.org \
    --cc=vuhuong-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).