]>
Commit | Line | Data |
---|---|---|
9d0aa67b GKH |
1 | From be549d49115422f846b6d96ee8fd7173a5f7ceb0 Mon Sep 17 00:00:00 2001 |
2 | From: Jaesoo Lee <jalee@purestorage.com> | |
3 | Date: Tue, 9 Apr 2019 17:02:22 -0700 | |
4 | Subject: scsi: core: set result when the command cannot be dispatched | |
5 | ||
6 | From: Jaesoo Lee <jalee@purestorage.com> | |
7 | ||
8 | commit be549d49115422f846b6d96ee8fd7173a5f7ceb0 upstream. | |
9 | ||
10 | When SCSI blk-mq is enabled, there is a bug in handling errors in | |
11 | scsi_queue_rq. Specifically, the bug is not setting result field of | |
12 | scsi_request correctly when the dispatch of the command has been | |
13 | failed. Since the upper layer code including the sg_io ioctl expects to | |
14 | receive any error status from result field of scsi_request, the error is | |
15 | silently ignored and this could cause data corruptions for some | |
16 | applications. | |
17 | ||
18 | Fixes: d285203cf647 ("scsi: add support for a blk-mq based I/O path.") | |
19 | Cc: <stable@vger.kernel.org> | |
20 | Signed-off-by: Jaesoo Lee <jalee@purestorage.com> | |
21 | Reviewed-by: Hannes Reinecke <hare@suse.com> | |
22 | Reviewed-by: Bart Van Assche <bvanassche@acm.org> | |
23 | Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> | |
24 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
25 | ||
26 | --- | |
27 | drivers/scsi/scsi_lib.c | 6 +++++- | |
28 | 1 file changed, 5 insertions(+), 1 deletion(-) | |
29 | ||
30 | --- a/drivers/scsi/scsi_lib.c | |
31 | +++ b/drivers/scsi/scsi_lib.c | |
32 | @@ -1763,8 +1763,12 @@ out_put_budget: | |
33 | ret = BLK_STS_DEV_RESOURCE; | |
34 | break; | |
35 | default: | |
36 | + if (unlikely(!scsi_device_online(sdev))) | |
37 | + scsi_req(req)->result = DID_NO_CONNECT << 16; | |
38 | + else | |
39 | + scsi_req(req)->result = DID_ERROR << 16; | |
40 | /* | |
41 | - * Make sure to release all allocated ressources when | |
42 | + * Make sure to release all allocated resources when | |
43 | * we hit an error, as we will never see this command | |
44 | * again. | |
45 | */ |