Debian

Debian + USB3 HDD + UAS:I/O 錯誤

  • September 7, 2021

我正在執行 rsync 以將遠端電腦備份到 ARM SBC 上的 USB 硬碟驅動器,有時 rsync 會因“從輸入設備讀取錯誤(I/O 錯誤)”而停止。我相信這個問題與 UAS + USB 3.0 + rsync 導致高 I/O 負載有關,因為uas_eh_device_reset_handleron /var/log/messages

sd 0:0:0:0: [sda] tag#1 data cmplt err -32 uas-tag 2 inflight: 
sd 0:0:0:0: [sda] tag#1 CDB: opcode=0x28 28 00 38 80 0a 68 00 00 a0 00
sd 0:0:0:0: [sda] tag#0 data cmplt err -32 uas-tag 1 inflight: CMD 
sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x2a 2a 00 57 50 28 78 00 03 00 00
sd 0:0:0:0: [sda] tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD 
sd 0:0:0:0: [sda] tag#1 CDB: opcode=0x28 28 00 38 80 0a 68 00 00 a0 00
sd 0:0:0:0: [sda] tag#2 uas_eh_abort_handler 0 uas-tag 3 inflight: CMD 
sd 0:0:0:0: [sda] tag#2 CDB: opcode=0x2a 2a 00 19 47 7f 20 00 00 90 00
sd 0:0:0:0: [sda] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD 
sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x2a 2a 00 57 50 28 78 00 03 00 00
scsi host0: uas_eh_device_reset_handler start
usb 5-1: reset high-speed USB device number 2 using ehci-platform
scsi host0: uas_eh_device_reset_handler success
sd 0:0:0:0: [sda] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
sd 0:0:0:0: [sda] tag#0 Sense Key : 0x2 [current] 
sd 0:0:0:0: [sda] tag#0 ASC=0x3a ASCQ=0x0 
sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x2a 2a 00 57 50 28 78 00 03 00 00
sd 0:0:0:0: [sda] tag#1 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
sd 0:0:0:0: [sda] tag#1 Sense Key : 0x2 [current] 
sd 0:0:0:0: [sda] tag#1 ASC=0x3a ASCQ=0x0 
sd 0:0:0:0: [sda] tag#1 CDB: opcode=0x2a 2a 00 19 47 7f 20 00 00 90 00
EXT4-fs warning (device sda1): ext4_end_bio:323: I/O error 10 writing to inode 13001563 (offset 0 size 73728 starting block 53014518)

這個 SBC 沒有 USB 3 埠,但它仍然使用 UAS 載入硬碟驅動器。據此,UAS在一些高畫質外殼晶片上壞了。提供的解決方案是禁用 UAS但是

1-如果我將UAS完全列入黑名單blacklist uas,我/etc/modprobe.d/blacklist-uas.conf會得到:

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=, 480M

查看Class=Mass Storage, Driver=, 480M=> 似乎系統沒有載入任何其他方式來處理驅動器。

2-如果我只是嘗試禁用特定 USB 設備的 UAS,就像推薦的文章一樣,它仍然會載入 UAS

echo options usb-storage quirks=174c:55aa:u | tee /etc/modprobe.d/blacklist-uas.conf
update-initramfs -u
reboot

(...)

dmesg | grep sda
[    2.488105] sd 0:0:0:0: [sda] 2930277168 512-byte logical blocks: (1.50 TB/1.36 TiB)
[    2.488584] sd 0:0:0:0: [sda] Write Protect is off
[    2.488592] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[    2.489335] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    2.539288]  sda: sda1
[    2.543875] sd 0:0:0:0: [sda] Attached SCSI disk
[    6.898109] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: errors=remount-ro,data=ordered

lsusb | grep ASMedia
Bus 005 Device 002: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge

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=uas, 480M

我究竟做錯了什麼?是否可以禁用 UAS 並使系統仍以其他方式使用 HD?為什麼不options usb-storage quirks=174c:55aa:u按應有的方式禁用 UAS?

謝謝你。

一些注意事項

  • 4.14.18-sunxi64作業系統:來自 armbian的 Debian GNU/Linux 9.4 (stretch) 核心
  • SBC:NanoPi NEO2

在@AB 的寶貴幫助下,我設法解決了這個問題。正如他所說,我的核心(可能每個 armbian SBC 核心)沒有usb_storage作為模組載入,它是內置的。

在這種情況下,我們需要更改以下可見的引導選項/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

最後usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u已經設置好了。我們無法直接編輯此文件,在 armbian 中,此選項儲存在文件中/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

所以我只是在最後一行將我的設備添加為,174c:55aa:u,使其成為:

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

以防萬一我重新執行update-initramfs -u並在重新啟動後 USB HD 現在只使用usb-store而不是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

正如您在此處看到的,uas現在已正確地將設備列入黑名單:

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

引用自:https://unix.stackexchange.com/questions/441668