Debian + USB3 HDD + UAS: I/O errors

With the precious help from @A.B I managed to fix this. As he said, my kernel (probably every armbian SBC kernel) doesn't have usb_storage loaded as a module, it is built-in.

In this case, we need to change the boot options that are visible under /proc/cmdline:

root=UUID=b58.... rootfstype=ext4 console=tty1 console=ttyS0,115200 panic=10 consoleblank=0 loglevel=1 ubootpart=096d26e5-01 usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u   cgroup_enable=memory swapaccount=1

At the end there is usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u already set. We can't edit this file directly, in armbian this options are stored on the file /boot/armbianEnv.txt:

verbosity=1
console=both
overlay_prefix=sun50i-h5
overlays=usbhost1 usbhost2
rootdev=UUID=b58048d3-ca7b-4ea6-9812-95d403fddadd
rootfstype=ext4
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

So I just added my device in the last line as ,174c:55aa:u, making it:

usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u,174c:55aa:u

Just in case I re-run update-initramfs -u and after a reboot the USB HD now uses only usb-store instead of uas:

lsusb -t
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M

As you can see here, uas is now properly blacklisted for the device:

dmesg | grep "usb 5-1"
[    2.308569] usb 5-1: new high-speed USB device number 2 using ehci-platform
[    2.467087] usb 5-1: New USB device found, idVendor=174c, idProduct=55aa
[    2.467106] usb 5-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[    2.467117] usb 5-1: Product: ASM1153E
[    2.467127] usb 5-1: Manufacturer: Inateck
[    2.467137] usb 5-1: SerialNumber: 12345678910E
[    2.468297] usb 5-1: UAS is blacklisted for this device, using usb-storage instead

I had a similar problem on Debian 9 and my answer turned out to be quite similar but not exactly the same:

(as root:)

    echo "options usb-storage quirks=4971:8017:u" >> /etc/modprobe.d/usb-storage-quirks.conf
    update-initramfs -u

The 4971:8017 device id is a "SimpleTech" based Rosewill RX307-PU3-35B USB-3 disk enclosure advertised as supporting UASB. With some drives, at least, it has to be reset frequently, generating many alarming messages in syslog like this:

Nov 16 13:12:10 guy kernel: [226970.895835] sd 8:0:0:0: [sda] tag#8 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD IN
Nov 16 13:12:10 guy kernel: [226970.895840] sd 8:0:0:0: [sda] tag#8 CDB: ATA command pass through(16) 85 08 0e 00 d0 00 01 00 00 00 4f 00 c2 00 b0 00
Nov 16 13:12:10 guy kernel: [226970.919935] scsi host8: uas_eh_device_reset_handler start
Nov 16 13:12:10 guy smartd[1079]: Device: /dev/sda [SAT], failed to read SMART Attribute Data
Nov 16 13:12:10 guy kernel: [226971.217025] scsi host8: uas_eh_device_reset_handler success
Nov 16 13:13:11 guy kernel: [227032.337409] sd 8:0:0:0: [sda] tag#8 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD IN
Nov 16 13:13:11 guy kernel: [227032.337412] sd 8:0:0:0: [sda] tag#8 CDB: ATA command pass through(16) 85 08 0e 00 d5 00 01 00 06 00 4f 00 c2 00 b0 00
Nov 16 13:13:11 guy kernel: [227032.361403] scsi host8: uas_eh_device_reset_handler start
Nov 16 13:13:12 guy smartd[1079]: Device: /dev/sda [SAT], Read SMART Self Test Log Failed
Nov 16 13:13:12 guy kernel: [227032.654494] scsi host8: uas_eh_device_reset_handler success

Weirdly, at least for bulk data transfers, it appears to be actually faster now than it was with the uas driver!