$ cd /sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0
$ ls -l driver subsystem
lrwxrwxrwx. 1 root root 0 Apr 5 10:48 driver -> ../../../../../../../bus/scsi/drivers/sd
lrwxrwxrwx. 1 root root 0 Apr 3 08:48 subsystem -> ../../../../../../../bus/scsi
$ cat ioerr_cnt
0x38c
:(
After maybe a minute later, not really doing anything:
$ cat ioerr_cnt
0x391
:((
According to an IBM article, ioerr_cnt
means "the number of SCSI commands that completed with an error".
My current kernel log (dmesg
) shows no I/O error, no error from SCSI or ATA or AHCI.
Why might failing SCSI commands like the above not appear in the kernel log? Usually if you have a troublesome DVD, or USB stick, you get lots of nice noise about errors and retries etc.
Can I see the failing SCSI commands, or trace the relevant code somehow?
To be clear, in case it makes any difference this is a SATA device (using the SCSI ATA Translation as usual for Linux). Also it's my laptop internal hard drive, so if there were any "real" IO errors I would like to know :). Ulterior motive for looking at this counter in the first place: I am trying to debug some rather quiet IO errors that cause crashes on resume from suspend.
Kernel version: 4.15.12-301.fc27.x86_64
Edit: blktrace
blktrace
is supposed to be able to monitor SCSI commands and show errors. I ran it over an interval with 0x3a5 - 0x3a0 = 5 errors. Then ran blkparse
with %e
added to the end of the default format string, to show error codes:
blkparse -f "%D %2c %8s %5T.%9t %5p %2a %3d %e\n"
However, searching the output for errors using grep -vE "( 0)|( )$
did not show any results.
Edit: scsi_logging_level
# scsi_logging_level -s --error=7 --ioctl=7 # from sg3-utils package
# dmesg -w
...
[112831.843993] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112831.844004] sd 1:0:0:0: [sda] sd_ioctl: disk=sda, cmd=0x2285
[112831.844007] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112831.844012] sd 1:0:0:0: [sda] sd_ioctl: disk=sda, cmd=0x2285
[112831.844015] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112831.900267] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112831.901394] sd 1:0:0:0: [sda] sd_ioctl: disk=sda, cmd=0x2285
[112831.901397] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112831.987030] sd 1:0:0:0: [sda] sd_ioctl: disk=sda, cmd=0x2285
[112831.987034] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112832.016745] sd 1:0:0:0: [sda] sd_ioctl: disk=sda, cmd=0x2285
[112832.016749] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112832.060156] sd 1:0:0:0: [sda] sd_ioctl: disk=sda, cmd=0x2285
[112832.060160] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
[112832.224840] sd 1:0:0:0: scsi_block_when_processing_errors: rtn: 1
ioerr_cnt
seems to rise at the same time as the above messages.
SCSI ioctl() 0x2285 is SG_IO, i.e. userspace submission of a specific SCSI command.
I'm struggling a bit to work out what process does this. sudo lsof +D /dev/
doesn't seem to show any processes with a SCSI device currently open, but I don't see any relevant open() calls at the time of the errors either (cd /dev && sudo fatrace -c
).
Often the interval between these events (6 ioctls and 5 ioerr, as above) is exactly 10 minutes.