0

I am facing the following problem: btrfs reports write errors for sector 128 on device /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

I have run badblocks /dev/sdd and it returned no badblocks. Anyway, I decided to stay on safe side (in a way), created a partition that starts at sector 2048 (default):

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

and re-added the drive to btrfs volume. Instantly I got the same write error again (note that 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

Could it be that both sectors 128 and 2176 are bad? Well, I have re-run badblocks /dev/sdd (again, it has reported no bad blocks), and pushed the partition further away:

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

and re-created btrfs volume. Again "bad block" at the same magic place (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

I don't believe in co-incidences, namely, that no other sector before magic 128 and after 128 are failing, but that specific one is problematic.

What is can be? For me sounds like a bug in kernel.

Additional info:

  • Linux kernel v3.16.0
  • /dev/sdd is connected via SATA-to-USB adapter JMicron (ID 152d:0567, see how it looks like):

dmesg:

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
  • I suspect the problem is not a bad block at all, but a controller or driver bug, possibly one that's triggered by a certain access pattern that btrfs happens to make. – Gilles Oct 19 '15 at 23:31
2

It seems like I have found the root of the problem. It is really connected with JMicron SATA bridge, see External USB3 disk fails with "Invalid field in cdb". The fix with commit bf5c4136fa5ce471bdbf4cf59a813e32755fd014 is included into kernel v3.18.6, released on 2015-02-06. I have tried the following kernels:

The actual fix was committed as 9fa62b1a31c96715aef34f25000e882ed4ac4876 and available in kernel 4.4.x.

dmesg for working kernel v4.4.x is the following:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.