SCSI fix (a621bac3)missing in stable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
From 0cd7e60c45205b0b7347160a01943cb6e29515d5 Mon Sep 17 00:00:00 2001
From: James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxx
Reported-by: Sebastian Parschauer <s.parschauer@xxxxxx>
Signed-off-by: James E.J. Bottomley <jejb@xxxxxxxxxxxxxxxxxx>
Tested-by: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxxx>
Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
[ ywang: backport from upstream 4.7 to fix scsi resize issue ]
Signed-off-by: Michael Wang <yun.wang@xxxxxxxxxxxxxxxx>
Signed-off-by: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxxx>
---
 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


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]