即使分区进一步移动后,文件系统也会报告特定扇区上的写入错误

即使分区进一步移动后,文件系统也会报告特定扇区上的写入错误

我面临以下问题:btrfs 报告设备上扇区 128 的写入错误/dev/sdd

sd 6:0:0:0: [sdd] Invalid command failure
sd 6:0:0:0: [sdd] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
sd 6:0:0:0: [sdd] Sense Key : Illegal Request [current] 
sd 6:0:0:0: [sdd] Add. Sense: Invalid field in cdb
sd 6:0:0:0: [sdd] CDB: Write(10): 2a 08 00 00 00 80 00 00 08 00
end_request: critical target error, dev sdd, sector 128
BTRFS: lost page write due to I/O error on /dev/sdd
BTRFS: bdev /dev/sdd errs: wr 913238, rd 1, flush 150, corrupt 0, gen 0

我已经运行了badblocks /dev/sdd,它没有返回坏块。无论如何,我决定保持安全(在某种程度上),创建了一个从扇区 2048(默认)开始的分区:

# fdisk -l /dev/sdd
Device     Boot Start       End   Sectors   Size Id Type
/dev/sdd1        2048 234441647 234439600 111.8G 83 Linux

并将驱动器重新添加到 btrfs 卷。立即我再次遇到相同的写入错误(请注意,2176 = 2048 + 128):

sd 13:0:0:0: [sdd] Invalid command failure
sd 13:0:0:0: [sdd] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
sd 13:0:0:0: [sdd] Sense Key : Illegal Request [current] 
sd 13:0:0:0: [sdd] Add. Sense: Invalid field in cdb
sd 13:0:0:0: [sdd] CDB: Write(10): 2a 08 00 00 08 80 00 00 08 00
end_request: critical target error, dev sdd, sector 2176
BTRFS: lost page write due to I/O error on /dev/sdd1
BTRFS: bdev /dev/sdd1 errs: wr 12253, rd 0, flush 0, corrupt 0, gen 0

难道128和2176扇区都坏了?好吧,我重新运行badblocks /dev/sdd(再次,它报告没有坏块),并将分区推得更远:

# fdisk -l /dev/sdd
Device     Boot Start       End   Sectors   Size Id Type
/dev/sdd1        4096 234441647 234437552 111.8G 83 Linux

并重新创建 btrfs 卷。在同一个神奇的地方再次出现“坏块”(4224 = 4096 + 128):

sd 6:0:0:0: [sdd] Invalid command failure
sd 6:0:0:0: [sdd] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
sd 6:0:0:0: [sdd] Sense Key : Illegal Request [current] 
sd 6:0:0:0: [sdd] Add. Sense: Invalid field in cdb
sd 6:0:0:0: [sdd] CDB: Write(10): 2a 08 00 00 10 80 00 00 08 00
end_request: critical target error, dev sdd, sector 4224
BTRFS: lost page write due to I/O error on /dev/sdd1
BTRFS: bdev /dev/sdd1 errs: wr 124433, rd 0, flush 0, corrupt 0, gen 0

我不相信巧合,也就是说,在 magic 128 之前和 128 之后没有其他扇区失败,但那个特定的扇区是有问题的。

什么是可以?对我来说听起来像是内核中的一个错误。

附加信息:

消息:

sd 4:0:0:0: [sdb] Attached SCSI disk
scsi 6:0:0:0: Direct-Access     JMicron  Generic          0116 PQ: 0 ANSI: 6
sd 6:0:0:0: Attached scsi generic sg5 type 0
sd 6:0:0:0: [sdd] 234441648 512-byte logical blocks: (120 GB/111 GiB)
sd 6:0:0:0: [sdd] Write Protect is off
sd 6:0:0:0: [sdd] Mode Sense: 47 00 10 08
sd 6:0:0:0: [sdd] Write cache: enabled, read cache: enabled, supports DPO and FUA
sd 6:0:0:0: [sdd] Attached SCSI disk

答案1

看来我找到了问题的根源。它确实与JMicron SATA桥相连,参见外部 USB3 磁盘失败并显示“cdb 中的字段无效”修复提交 bf5c4136fa5ce471bdbf4cf59a813e32755fd014被包含到内核 v3.18.6,发布于 2015-02-06。我尝试过以下内核:

实际修复已提交为9fa62b1a31c96715aef34f25000e882ed4ac4876并且在内核 4.4.x 中可用。

工作内核 v4.4.x 的 dmesg 如下:

scsi host7: uas
scsi 7:0:0:0: Direct-Access     JMicron  Generic          0116 PQ: 0 ANSI: 6
sd 7:0:0:0: [sdc] 234441648 512-byte logical blocks: (120 GB/111 GiB)
sd 7:0:0:0: [sdc] 4096-byte physical blocks
sd 7:0:0:0: [sdc] Write Protect is off
sd 7:0:0:0: [sdc] Mode Sense: 53 00 10 08
sd 7:0:0:0: [sdc] Disabling FUA
sd 7:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA

相关内容