Windows的disk报错代码153和SCSI代码简要分析
SCSI报错代码示例
Windows服务器上频繁出现event上来源为disk,ID为153的事件,并且影响到了数据库业务的正常运行。
点击该事件的详细信息,可以看到对应的SCSI读写请求及其状态。
上文scsi的译义如下:
- offset 29 SCSI Satus为00,译义为
SCSISTAT_GOOD
,对应SCSI端口和驱动。 - offset 30 SRB Status为04,译义为
SRB_STATUS_ERROR
,对应SCSI请求的数据块。 - offset 31 SCSI command为88,译义为
SCSIOP_READ16
,对应SCSI命令的类型。
由此可见,操作系统在向磁盘2(\Device\MPIODisk2)的逻辑块地址ca190处发起读操作时,磁盘子系统返回了错误,但此时SCSI端口和驱动的状态是正常的。
参考:Guidance for troubleshooting data corruption and disk errors - Windows Server | Microsoft Learn
SCSI Status对照表
SCSI Status记录在scsi.h中,在代码里可见定义:
winsdk-10/scsi.h at master · tpn/winsdk-10 · GitHub
// SCSI bus status codes.
//
#define SCSISTAT_GOOD 0x00
#define SCSISTAT_CHECK_CONDITION 0x02
#define SCSISTAT_CONDITION_MET 0x04
#define SCSISTAT_BUSY 0x08
#define SCSISTAT_INTERMEDIATE 0x10
#define SCSISTAT_INTERMEDIATE_COND_MET 0x14
#define SCSISTAT_RESERVATION_CONFLICT 0x18
#define SCSISTAT_COMMAND_TERMINATED 0x22
#define SCSISTAT_QUEUE_FULL 0x28
SRB Status对照表
SRB Status记录在srb.h中,在代码里可见定义:
winsdk-10/srb.h at master · tpn/winsdk-10 · GitHub
//
// SRB Status
//
#define SRB_STATUS_PENDING 0x00
#define SRB_STATUS_SUCCESS 0x01
#define SRB_STATUS_ABORTED 0x02
#define SRB_STATUS_ABORT_FAILED 0x03
#define SRB_STATUS_ERROR 0x04
#define SRB_STATUS_BUSY 0x05
#define SRB_STATUS_INVALID_REQUEST 0x06
#define SRB_STATUS_INVALID_PATH_ID 0x07
#define SRB_STATUS_NO_DEVICE 0x08
#define SRB_STATUS_TIMEOUT 0x09
#define SRB_STATUS_SELECTION_TIMEOUT 0x0A
#define SRB_STATUS_COMMAND_TIMEOUT 0x0B
#define SRB_STATUS_MESSAGE_REJECTED 0x0D
#define SRB_STATUS_BUS_RESET 0x0E
#define SRB_STATUS_PARITY_ERROR 0x0F
#define SRB_STATUS_REQUEST_SENSE_FAILED 0x10
#define SRB_STATUS_NO_HBA 0x11
#define SRB_STATUS_DATA_OVERRUN 0x12
#define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13
#define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
#define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
#define SRB_STATUS_REQUEST_FLUSHED 0x16
#define SRB_STATUS_INVALID_LUN 0x20
#define SRB_STATUS_INVALID_TARGET_ID 0x21
#define SRB_STATUS_BAD_FUNCTION 0x22
#define SRB_STATUS_ERROR_RECOVERY 0x23
#define SRB_STATUS_NOT_POWERED 0x24
#define SRB_STATUS_LINK_DOWN 0x25
//
// This value is used by the port driver to indicate that a non-scsi-related
// error occured. Miniports must never return this status.
//
#define SRB_STATUS_INTERNAL_ERROR 0x30
//
// Srb status values 0x38 through 0x3f are reserved for internal port driver
// use.
//
//
// SRB Status Masks
//
#define SRB_STATUS_QUEUE_FROZEN 0x40
#define SRB_STATUS_AUTOSENSE_VALID 0x80
SCSI Command对照表
SCSI Command记录在scsi.h中,在代码里可见定义:
winsdk-10/scsi.h at 9b69fd26ac0c7d0b83d378dba01080e93349c2ed · tpn/winsdk-10 · GitHub
//
// SCSI CDB operation codes
//
// 6-byte commands:
#define SCSIOP_TEST_UNIT_READY 0x00
#define SCSIOP_REZERO_UNIT 0x01
#define SCSIOP_REWIND 0x01
#define SCSIOP_REQUEST_BLOCK_ADDR 0x02
#define SCSIOP_REQUEST_SENSE 0x03
#define SCSIOP_FORMAT_UNIT 0x04
#define SCSIOP_READ_BLOCK_LIMITS 0x05
#define SCSIOP_REASSIGN_BLOCKS 0x07
#define SCSIOP_INIT_ELEMENT_STATUS 0x07
#define SCSIOP_READ6 0x08
#define SCSIOP_RECEIVE 0x08
#define SCSIOP_WRITE6 0x0A
#define SCSIOP_PRINT 0x0A
#define SCSIOP_SEND 0x0A
#define SCSIOP_SEEK6 0x0B
#define SCSIOP_TRACK_SELECT 0x0B
#define SCSIOP_SLEW_PRINT 0x0B
#define SCSIOP_SET_CAPACITY 0x0B // tape
#define SCSIOP_SEEK_BLOCK 0x0C
#define SCSIOP_PARTITION 0x0D
#define SCSIOP_READ_REVERSE 0x0F
#define SCSIOP_WRITE_FILEMARKS 0x10
#define SCSIOP_FLUSH_BUFFER 0x10
#define SCSIOP_SPACE 0x11
#define SCSIOP_INQUIRY 0x12
#define SCSIOP_VERIFY6 0x13
#define SCSIOP_RECOVER_BUF_DATA 0x14
#define SCSIOP_MODE_SELECT 0x15
#define SCSIOP_RESERVE_UNIT 0x16
#define SCSIOP_RELEASE_UNIT 0x17
#define SCSIOP_COPY 0x18
#define SCSIOP_ERASE 0x19
#define SCSIOP_MODE_SENSE 0x1A
#define SCSIOP_START_STOP_UNIT 0x1B
#define SCSIOP_STOP_PRINT 0x1B
#define SCSIOP_LOAD_UNLOAD 0x1B
#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
#define SCSIOP_SEND_DIAGNOSTIC 0x1D
#define SCSIOP_MEDIUM_REMOVAL 0x1E
// 10-byte commands
#define SCSIOP_READ_FORMATTED_CAPACITY 0x23
#define SCSIOP_READ_CAPACITY 0x25
#define SCSIOP_READ 0x28
#define SCSIOP_WRITE 0x2A
#define SCSIOP_SEEK 0x2B
#define SCSIOP_LOCATE 0x2B
#define SCSIOP_POSITION_TO_ELEMENT 0x2B
#define SCSIOP_WRITE_VERIFY 0x2E
#define SCSIOP_VERIFY 0x2F
#define SCSIOP_SEARCH_DATA_HIGH 0x30
#define SCSIOP_SEARCH_DATA_EQUAL 0x31
#define SCSIOP_SEARCH_DATA_LOW 0x32
#define SCSIOP_SET_LIMITS 0x33
#define SCSIOP_READ_POSITION 0x34
#define SCSIOP_SYNCHRONIZE_CACHE 0x35
#define SCSIOP_COMPARE 0x39
#define SCSIOP_COPY_COMPARE 0x3A
#define SCSIOP_WRITE_DATA_BUFF 0x3B
#define SCSIOP_READ_DATA_BUFF 0x3C
#define SCSIOP_WRITE_LONG 0x3F
#define SCSIOP_CHANGE_DEFINITION 0x40
#define SCSIOP_WRITE_SAME 0x41
#define SCSIOP_READ_SUB_CHANNEL 0x42
#define SCSIOP_UNMAP 0x42 // block device
#define SCSIOP_READ_TOC 0x43
#define SCSIOP_READ_HEADER 0x44
#define SCSIOP_REPORT_DENSITY_SUPPORT 0x44 // tape
#define SCSIOP_PLAY_AUDIO 0x45
#define SCSIOP_GET_CONFIGURATION 0x46
#define SCSIOP_PLAY_AUDIO_MSF 0x47
#define SCSIOP_PLAY_TRACK_INDEX 0x48
#define SCSIOP_SANITIZE 0x48 // block device
#define SCSIOP_PLAY_TRACK_RELATIVE 0x49
#define SCSIOP_GET_EVENT_STATUS 0x4A
#define SCSIOP_PAUSE_RESUME 0x4B
#define SCSIOP_LOG_SELECT 0x4C
#define SCSIOP_LOG_SENSE 0x4D
#define SCSIOP_STOP_PLAY_SCAN 0x4E
#define SCSIOP_XDWRITE 0x50
#define SCSIOP_XPWRITE 0x51
#define SCSIOP_READ_DISK_INFORMATION 0x51
#define SCSIOP_READ_DISC_INFORMATION 0x51 // proper use of disc over disk
#define SCSIOP_READ_TRACK_INFORMATION 0x52
#define SCSIOP_XDWRITE_READ 0x53
#define SCSIOP_RESERVE_TRACK_RZONE 0x53
#define SCSIOP_SEND_OPC_INFORMATION 0x54 // optimum power calibration
#define SCSIOP_MODE_SELECT10 0x55
#define SCSIOP_RESERVE_UNIT10 0x56
#define SCSIOP_RESERVE_ELEMENT 0x56
#define SCSIOP_RELEASE_UNIT10 0x57
#define SCSIOP_RELEASE_ELEMENT 0x57
#define SCSIOP_REPAIR_TRACK 0x58
#define SCSIOP_MODE_SENSE10 0x5A
#define SCSIOP_CLOSE_TRACK_SESSION 0x5B
#define SCSIOP_READ_BUFFER_CAPACITY 0x5C
#define SCSIOP_SEND_CUE_SHEET 0x5D
#define SCSIOP_PERSISTENT_RESERVE_IN 0x5E
#define SCSIOP_PERSISTENT_RESERVE_OUT 0x5F
// 12-byte commands
#define SCSIOP_REPORT_LUNS 0xA0
#define SCSIOP_BLANK 0xA1
#define SCSIOP_ATA_PASSTHROUGH12 0xA1
#define SCSIOP_SEND_EVENT 0xA2
#define SCSIOP_SECURITY_PROTOCOL_IN 0xA2
#define SCSIOP_SEND_KEY 0xA3
#define SCSIOP_MAINTENANCE_IN 0xA3
#define SCSIOP_REPORT_KEY 0xA4
#define SCSIOP_MAINTENANCE_OUT 0xA4
#define SCSIOP_MOVE_MEDIUM 0xA5
#define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
#define SCSIOP_EXCHANGE_MEDIUM 0xA6
#define SCSIOP_SET_READ_AHEAD 0xA7
#define SCSIOP_MOVE_MEDIUM_ATTACHED 0xA7
#define SCSIOP_READ12 0xA8
#define SCSIOP_GET_MESSAGE 0xA8
#define SCSIOP_SERVICE_ACTION_OUT12 0xA9
#define SCSIOP_WRITE12 0xAA
#define SCSIOP_SEND_MESSAGE 0xAB
#define SCSIOP_SERVICE_ACTION_IN12 0xAB
#define SCSIOP_GET_PERFORMANCE 0xAC
#define SCSIOP_READ_DVD_STRUCTURE 0xAD
#define SCSIOP_WRITE_VERIFY12 0xAE
#define SCSIOP_VERIFY12 0xAF
#define SCSIOP_SEARCH_DATA_HIGH12 0xB0
#define SCSIOP_SEARCH_DATA_EQUAL12 0xB1
#define SCSIOP_SEARCH_DATA_LOW12 0xB2
#define SCSIOP_SET_LIMITS12 0xB3
#define SCSIOP_READ_ELEMENT_STATUS_ATTACHED 0xB4
#define SCSIOP_REQUEST_VOL_ELEMENT 0xB5
#define SCSIOP_SECURITY_PROTOCOL_OUT 0xB5
#define SCSIOP_SEND_VOLUME_TAG 0xB6
#define SCSIOP_SET_STREAMING 0xB6 // C/DVD
#define SCSIOP_READ_DEFECT_DATA 0xB7
#define SCSIOP_READ_ELEMENT_STATUS 0xB8
#define SCSIOP_READ_CD_MSF 0xB9
#define SCSIOP_SCAN_CD 0xBA
#define SCSIOP_REDUNDANCY_GROUP_IN 0xBA
#define SCSIOP_SET_CD_SPEED 0xBB
#define SCSIOP_REDUNDANCY_GROUP_OUT 0xBB
#define SCSIOP_PLAY_CD 0xBC
#define SCSIOP_SPARE_IN 0xBC
#define SCSIOP_MECHANISM_STATUS 0xBD
#define SCSIOP_SPARE_OUT 0xBD
#define SCSIOP_READ_CD 0xBE
#define SCSIOP_VOLUME_SET_IN 0xBE
#define SCSIOP_SEND_DVD_STRUCTURE 0xBF
#define SCSIOP_VOLUME_SET_OUT 0xBF
#define SCSIOP_INIT_ELEMENT_RANGE 0xE7
// 16-byte commands
#define SCSIOP_XDWRITE_EXTENDED16 0x80 // disk
#define SCSIOP_WRITE_FILEMARKS16 0x80 // tape
#define SCSIOP_REBUILD16 0x81 // disk
#define SCSIOP_READ_REVERSE16 0x81 // tape
#define SCSIOP_REGENERATE16 0x82 // disk
#define SCSIOP_EXTENDED_COPY 0x83
#define SCSIOP_POPULATE_TOKEN 0x83 // disk
#define SCSIOP_WRITE_USING_TOKEN 0x83 // disk
#define SCSIOP_RECEIVE_COPY_RESULTS 0x84
#define SCSIOP_RECEIVE_ROD_TOKEN_INFORMATION 0x84 //disk
#define SCSIOP_ATA_PASSTHROUGH16 0x85
#define SCSIOP_ACCESS_CONTROL_IN 0x86
#define SCSIOP_ACCESS_CONTROL_OUT 0x87
#define SCSIOP_READ16 0x88
#define SCSIOP_COMPARE_AND_WRITE 0x89
#define SCSIOP_WRITE16 0x8A
#define SCSIOP_READ_ATTRIBUTES 0x8C
#define SCSIOP_WRITE_ATTRIBUTES 0x8D
#define SCSIOP_WRITE_VERIFY16 0x8E
#define SCSIOP_VERIFY16 0x8F
#define SCSIOP_PREFETCH16 0x90
#define SCSIOP_SYNCHRONIZE_CACHE16 0x91
#define SCSIOP_SPACE16 0x91 // tape
#define SCSIOP_LOCK_UNLOCK_CACHE16 0x92
#define SCSIOP_LOCATE16 0x92 // tape
#define SCSIOP_WRITE_SAME16 0x93
#define SCSIOP_ERASE16 0x93 // tape
#define SCSIOP_READ_CAPACITY16 0x9E
#define SCSIOP_GET_LBA_STATUS 0x9E
#define SCSIOP_SERVICE_ACTION_IN16 0x9E
#define SCSIOP_SERVICE_ACTION_OUT16 0x9F
// 32-byte commands
#define SCSIOP_OPERATION32 0x7F