* [PATCH] uas: set host status byte on data completion error
[not found] <675774215.2024605.1717624320352.ref@mail.yahoo.com>
@ 2024-06-05 21:52 ` Shantanu Goel
2024-06-06 6:30 ` Oliver Neukum
0 siblings, 1 reply; 3+ messages in thread
From: Shantanu Goel @ 2024-06-05 21:52 UTC (permalink / raw)
To: Oliver Neukum; +Cc: linux-usb@vger.kernel.org, linux-scsi@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]
Hi,
I have a disk enclosure which is prone to data completion errors during initialization and because the UAS driver
only sets the resid on a data completion error and not the host status byte, the SD driver ends up using invalid zero'ed data.
The attached patch against v6.6.32 fixes this by setting the host status byte to DID_ERROR so the SD driver will notice
the error and retry the command.
This bug is present in all stable kernels (4.19, 5.4, 5.15, 6.1, 6,6) and the current 6.9.3 kernel.
This is the behavior prior to applying the patch.
[ 11.872824] sd 0:0:0:1: [sdf] tag#9 data cmplt err -75 uas-tag 1 inflight:
[ 11.872826] sd 0:0:0:1: [sdf] tag#9 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.872830] sd 0:0:0:1: [sdf] Sector size 0 reported, assuming 512.
[ 11.872995] sd 2:0:0:1: [sdn] Preferred minimum I/O size 4096 bytes
[ 11.872996] sd 2:0:0:1: [sdn] Optimal transfer size 33553920 bytes not a multiple of preferred minimum block size (4096 bytes)
[ 11.873466] sd 1:0:0:0: [sdd] tag#29 data cmplt err -75 uas-tag 1 inflight:
[ 11.873468] sd 1:0:0:0: [sdd] tag#29 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.873472] sd 1:0:0:0: [sdd] Sector size 0 reported, assuming 512.
[ 11.873824] sd 7:0:0:0: [sde] Attached SCSI disk
[ 11.874064] sd 3:0:0:1: [sdk] tag#16 data cmplt err -75 uas-tag 1 inflight:
[ 11.874065] sd 3:0:0:1: [sdk] tag#16 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.874070] sd 3:0:0:1: [sdk] Sector size 0 reported, assuming 512.
[ 11.874465] sd 5:0:0:0: [sdo] tag#10 data cmplt err -75 uas-tag 1 inflight:
[ 11.874466] sd 5:0:0:0: [sdo] tag#10 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.874474] sd 5:0:0:0: [sdo] Sector size 0 reported, assuming 512.
[ 11.876151] sd 4:0:0:1: [sdj] tag#10 data cmplt err -75 uas-tag 2 inflight:
[ 11.876153] sd 4:0:0:1: [sdj] tag#10 CDB: Read capacity(16) 9e 10 00 00 00 00 00 00 00 00 00 00 00 20 00 00
[ 11.876158] sd 4:0:0:1: [sdj] Sector size 0 reported, assuming 512.
After applying the patch I no longer see the zero sector sizes above and all sizes are detected correctly despite
the presence of completion errors.
Thanks
Signed-off-by: Shantanu Goel <sgoel01@yahoo.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-6.6.32-uas-set-data-result.diff --]
[-- Type: text/x-patch, Size: 426 bytes --]
--- .orig/drivers/usb/storage/uas.c 2024-06-02 11:46:49.144457253 -0400
+++ linux-6.6.32-1.sg.1.el9.x86_64/drivers/usb/storage/uas.c 2024-06-02 11:44:21.523375517 -0400
@@ -422,6 +422,7 @@
uas_log_cmd_state(cmnd, "data cmplt err", status);
/* error: no data transfered */
scsi_set_resid(cmnd, sdb->length);
+ set_host_byte(cmnd, DID_ERROR);
} else {
scsi_set_resid(cmnd, sdb->length - urb->actual_length);
}
^ permalink raw reply [flat|nested] 3+ messages in thread