All of lore.kernel.org
 help / color / mirror / Atom feed
* SCSI fix (a621bac3)missing in stable
@ 2016-06-08 16:47 Jinpu Wang
  2016-06-08 17:11 ` Greg KH
  2016-06-14 20:03 ` Greg KH
  0 siblings, 2 replies; 13+ messages in thread
From: Jinpu Wang @ 2016-06-08 16:47 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen, Christoph Hellwig,
	stable, Greg KH, Jiri Slaby
  Cc: Sebastian Parschauer, Yun Wang, Gi-Oh Kim

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

Hi all,

We found the SCSI fix is missing in any stable only in linux 4.7-rc2
[PATCH] scsi_lib: correctly retry failed zero length REQ_TYPE_FS
 commands

commit a621bac3044ed6f7ec5fa0326491b2d4838bfa93 upstream.

So we backport & tested on linux-3.12 (as we're using this kernel).
Could you review if we did it right?


-- 
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

[-- Attachment #2: 0001-scsi_lib-correctly-retry-failed-zero-length-REQ_TYPE.patch --]
[-- Type: text/x-patch, Size: 2681 bytes --]

From 0cd7e60c45205b0b7347160a01943cb6e29515d5 Mon Sep 17 00:00:00 2001
From: James Bottomley <James.Bottomley@HansenPartnership.com>
Date: Fri, 13 May 2016 12:04:06 -0700
Subject: [PATCH] scsi_lib: correctly retry failed zero length REQ_TYPE_FS
 commands

commit a621bac3044ed6f7ec5fa0326491b2d4838bfa93 upstream.

When SCSI was written, all commands coming from the filesystem
(REQ_TYPE_FS commands) had data.  This meant that our signal for needing
to complete the command was the number of bytes completed being equal to
the number of bytes in the request.  Unfortunately, with the advent of
flush barriers, we can now get zero length REQ_TYPE_FS commands, which
confuse this logic because they satisfy the condition every time.  This
means they never get retried even for retryable conditions, like UNIT
ATTENTION because we complete them early assuming they're done.  Fix
this by special casing the early completion condition to recognise zero
length commands with errors and let them drop through to the retry code.

Cc: stable@vger.kernel.org
Reported-by: Sebastian Parschauer <s.parschauer@gmx.de>
Signed-off-by: James E.J. Bottomley <jejb@linux.vnet.ibm.com>
Tested-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[ ywang: backport from upstream 4.7 to fix scsi resize issue ]
Signed-off-by: Michael Wang <yun.wang@profitbricks.com>
Signed-off-by: Jack Wang <jinpu.wang@profitbricks.com>
---
 drivers/scsi/scsi_lib.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index fd206c9..ad0f826 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -880,9 +880,30 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	 * are leftovers and there is some kind of error
 	 * (result != 0), retry the rest.
 	 */
-	if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
+	if (!(blk_rq_bytes(req) == 0 && error) &&
+	    scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
 		return;
 
+	/*
+	 * Failed zero length commands won't do scsi_end_request()
+	 * which check no retrys and requeue cases, do them here.
+	 *
+	 * For other cases scsi_end_request() will take care and
+	 * we won't reach here.
+	 */
+	if (error && scsi_noretry_cmd(cmd)) {
+		blk_end_request_all(req, error);
+		__scsi_release_buffers(cmd, 0);
+		scsi_next_command(cmd);
+		return;
+	}
+
+	if (result == 0) {
+		scsi_release_buffers(cmd);
+		scsi_requeue_command(q, cmd);
+		return;
+	}
+
 	error = __scsi_error_from_host_byte(cmd, result);
 
 	if (host_byte(result) == DID_RESET) {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-07-12  9:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-08 16:47 SCSI fix (a621bac3)missing in stable Jinpu Wang
2016-06-08 17:11 ` Greg KH
2016-06-09  8:15   ` Jinpu Wang
2016-06-14 20:03 ` Greg KH
2016-06-15  8:04   ` Jinpu Wang
2016-06-17 15:29     ` Jinpu Wang
2016-06-17 15:51       ` James Bottomley
2016-06-20 10:23         ` Jinpu Wang
2016-06-21 14:45           ` James Bottomley
2016-06-21 15:31             ` Jinpu Wang
2016-06-29 12:36               ` Jinpu Wang
2016-06-29 16:41                 ` Greg KH
2016-07-12  9:40               ` Jiri Slaby

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.