CAM_IO_STATS ignores some I/O errors

From: Alan Somers <asomers_at_freebsd.org>
Date: Thu, 19 Aug 2021 19:07:26 UTC
I use the non-default CAM_IO_STATS kernel option to record how many errors
each HDD experiences.  But it seems like a lot of errors don't get
recorded.  For example, today I saw an error like this in dmesg, but the
kern.cam.da.158.stats.errors still equals 0.  In fact, I've noticed that
MEDIUM ERROR never seems to be recorded.  Is this intentional, or is there
some error path that slipped through the cracks?

(da158:mpr1:0:272:0): READ(10). CDB: 28 00 6a db 2d 7e 00 00 a5 00
(da158:mpr1:0:272:0): CAM status: SCSI Status Error
(da158:mpr1:0:272:0): SCSI status: Check Condition
(da158:mpr1:0:272:0): SCSI sense: MEDIUM ERROR asc:11,0 (Unrecovered read
error)
(da158:mpr1:0:272:0): Info: 0x6adb2dd5
(da158:mpr1:0:272:0): Field Replaceable Unit: 134
(da158:mpr1:0:272:0): Command Specific Info: 0x81037000
(da158:mpr1:0:272:0): Actual Retry Count: 209
(da158:mpr1:0:272:0): Error 5, Unretryable error

-Alan