Hi,
I have a server with old server with lsi2308 ("it" mode) and sas2x36 expander
in front. I've been testing how it handles ssd drives (among those if/how it
copes with unmap). And it looks like
stomped on a bug (it's 100% reproducible in 4.14.74 and 4.18.12).
The hardware in question:
mpt2sas_cm0: LSISAS2308: FWVersion(20.00.07.00), ChipRevision(0x05),
BiosVersion(07.39.02.00)
scsi host6: Fusion MPT SAS Host
scsi 6:0:19:0: Enclosure LSI SAS2X36 0e12 PQ: 0 ANSI: 5
Tested with old Samsung 840 pro drive.
Initially I was just doing a simple blkdiscard (which on the drive in question
works just fine in plain sata controller), which greeted me with unexpected:
16:00 # blkdiscard /dev/sdt
blkdiscard: /dev/sdt: BLKDISCARD ioctl failed: Remote I/O error
Log in dmesg:
[ 391.870979] sd 7:0:20:0: [sdt] 250069680 512-byte logical blocks: (128
GB/119 GiB)
[ 391.872702] sd 7:0:20:0: [sdt] Write Protect is off
[ 391.872705] sd 7:0:20:0: [sdt] Mode Sense: 7f 00 10 08
[ 391.872962] sd 7:0:20:0: [sdt] Write cache: enabled, read cache: enabled,
supports DPO and FUA
...
[ 529.907273] sd 7:0:20:0: [sdt] tag#3625 FAILED Result: hostbyte=DID_OK
driverbyte=DRIVER_SENSE
[ 529.907277] sd 7:0:20:0: [sdt] tag#3625 Sense Key : Illegal Request [current]
[ 529.907279] sd 7:0:20:0: [sdt] tag#3625 Add. Sense: Logical block address
out of range
[ 529.907281] sd 7:0:20:0: [sdt] tag#3625 CDB: Unmap/Read sub-channel 42 00 00
00 00 00 00 00 18 00
[ 529.907283] print_req_error: critical target error, dev sdt, sector 247463877
Then I started testing it more manually and it turned out that if I try to
discard any range that includes the last sector, the command fail in this
fashion. For example:
2 sectors from the end, 1 sector (works):
blkdiscard -o $(( 250069678*512 )) -l 512 /dev/sdt
1 sectors from the end, 1 sector (fails):
blkdiscard -o $(( 250069679*512 )) -l 512 /dev/sdt
blkdiscard: /dev/sdt: BLKDISCARD ioctl failed: Remote I/O error
[ 702.139612] sd 7:0:20:0: [sdt] tag#2511 FAILED Result: hostbyte=DID_OK
driverbyte=DRIVER_SENSE
[ 702.139618] sd 7:0:20:0: [sdt] tag#2511 Sense Key : Illegal Request [current]
[ 702.139622] sd 7:0:20:0: [sdt] tag#2511 Add. Sense: Logical block address
out of range
[ 702.139627] sd 7:0:20:0: [sdt] tag#2511 CDB: Unmap/Read sub-channel 42 00 00
00 00 00 00 00 18 00
[ 702.139631] print_req_error: critical target error, dev sdt, sector 250069679
Similar results with sg_unmap:
16:36 # sg_unmap -f -l 250069678 -n 1 /dev/sdt
16:36 # sg_unmap -f -l 250069679 -n 1 /dev/sdt
sg_unmap failed: LBA out of range
The last sector on its own is of course normally readable/writable otherwise.
This looks like some +/-1 division/reminder issue somewhere.