提交 a621bac3 编写于 作者: J James Bottomley 提交者: Martin K. Petersen

scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands

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: NSebastian Parschauer <s.parschauer@gmx.de>
Signed-off-by: NJames E.J. Bottomley <jejb@linux.vnet.ibm.com>
Tested-by: NJack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 97f00905
......@@ -821,9 +821,12 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
}
/*
* If we finished all bytes in the request we are done now.
* special case: failed zero length commands always need to
* drop down into the retry code. Otherwise, if we finished
* all bytes in the request we are done now.
*/
if (!scsi_end_request(req, error, good_bytes, 0))
if (!(blk_rq_bytes(req) == 0 && error) &&
!scsi_end_request(req, error, good_bytes, 0))
return;
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册