现象举例
1. hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OKlinux
Jul 16 08:06:53 localhost kernel: sd 11:0:0:0: [sdh] Synchronize Cache(10) failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OKJul 16 08:06:53 localhost kernel: sd 11:0:0:0: [sdh] Start/Stop Unit failed: Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
web
微信
2. hostbyte=DID_OK driverbyte=DRIVER_SENSEapp
[ 37.404796] sd 0:0:0:0: [sda] tag#3 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE[ 37.404806] blk_update_request: I/O error, dev sda, sector 0
ide
flex
3. hostbyte=DID_ERROR driverbyte=DRIVER_OKthis
Dec 6 18:12:13 localhost kernel: sd 20:0:0:0: [sdb] FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OKDec 6 18:12:13 localhost kernel: blk_update_request: I/O error, dev sdb, sector 512
spa
.net
hostbyte和driverbyte
定义
linux/include/scsi/scsi.hcode
/* * Use these to separate status msg and our bytes * * These are set by: * * status byte = set from target device * msg_byte = return status from host adapter itself. * host_byte = set by low-level driver to indicate status. * driver_byte = set by mid-level. */#define status_byte(result) (((result) >> 1) & 0x7f)#define msg_byte(result) (((result) >> 8) & 0xff)#define host_byte(result) (((result) >> 16) & 0xff)#define driver_byte(result) (((result) >> 24) & 0xff)
hostbyte
hostbyte | 符号(Symbol) | 含义 |
---|---|---|
0x00 | DID_OK | 没有错误 |
0x01 | DID_NO_CONNECT | 在超时以前,不能链接 |
0x02 | DID_BUS_BUSY | 在超时期间,BUS一直处于忙状态 |
0x03 | DID_TIME_OUT | 由于其余缘由超时 |
0x04 | DID_BAD_TARGET | BAD target |
0x05 | DID_ABORT | 由于其余缘由取消 |
0x06 | DID_PARITY | Parity错误 |
0x07 | DID_ERROR | 内部错误(internal error) |
0x08 | DID_RESET | 被复位 |
0x09 | DID_BAD_INTR | 获得一个未被指望的中断 |
driverbyte
driverbyte | 符号(Symbol) | 含义 |
---|---|---|
0x00 | DRIVER_OK | 没有错误 |
0x01 | DRIVER_BUSY | - |
0x02 | DRIVER_SOFT | - |
0x03 | DRIVER_MEDIA | - |
0x04 | DRIVER_ERROR | 内部驱动错误 |
0x05 | DRIVER_INVALID | 完成(DIDBADTARGET或DID_ABORT) |
0x06 | DRIVER_TIMEOUT | 超时完成 |
0x07 | DRIVER_HARD | 完成,但有致命错误 |
0x08 | DRIVER_SENSE | 有sense信息 |
0x10 | SUGGEST_RETRY | 重试SCSI请求 |
0x20 | SUGGEST_ABORT | 取消请求 |
0x30 | SUGGEST_REMAP | 从新映射block,但没有完成 |
0x40 | SUGGEST_DIE | 让内核Panic |
0x80 | SUGGEST_SENSE | 从设备上获取Sense信息 |
0xff | SUGGESTISOK | 不须要作任何操做 |
附录
source code
file: linux/include/scsi/scsi.h
....../* * Host byte codes */#define DID_OK 0x00 /* NO error */#define DID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */#define DID_BUS_BUSY 0x02 /* BUS stayed busy through time out period */#define DID_TIME_OUT 0x03 /* TIMED OUT for other reason */#define DID_BAD_TARGET 0x04 /* BAD target. */#define DID_ABORT 0x05 /* Told to abort for some other reason */#define DID_PARITY 0x06 /* Parity error */#define DID_ERROR 0x07 /* Internal error */#define DID_RESET 0x08 /* Reset by somebody. */#define DID_BAD_INTR 0x09 /* Got an interrupt we weren't expecting. */#define DID_PASSTHROUGH 0x0a /* Force command past mid-layer */#define DID_SOFT_ERROR 0x0b /* The low level driver just wish a retry */#define DID_IMM_RETRY 0x0c /* Retry without decrementing retry count */#define DID_REQUEUE 0x0d /* Requeue command (no immediate retry) also * without decrementing the retry count */#define DID_TRANSPORT_DISRUPTED 0x0e /* Transport error disrupted execution * and the driver blocked the port to * recover the link. Transport class will * retry or fail IO */#define DID_TRANSPORT_FAILFAST 0x0f /* Transport class fastfailed the io */#define DID_TARGET_FAILURE 0x10 /* Permanent target failure, do not retry on * other paths */#define DID_NEXUS_FAILURE 0x11 /* Permanent nexus failure, retry on other * paths might yield different results */#define DID_ALLOC_FAILURE 0x12 /* Space allocation on the device failed */#define DID_MEDIUM_ERROR 0x13 /* Medium error */#define DRIVER_OK 0x00 /* Driver status *//* * These indicate the error that occurred, and what is available. */#define DRIVER_BUSY 0x01#define DRIVER_SOFT 0x02#define DRIVER_MEDIA 0x03#define DRIVER_ERROR 0x04#define DRIVER_INVALID 0x05#define DRIVER_TIMEOUT 0x06#define DRIVER_HARD 0x07#define DRIVER_SENSE 0x08....../* * Use these to separate status msg and our bytes * * These are set by: * * status byte = set from target device * msg_byte = return status from host adapter itself. * host_byte = set by low-level driver to indicate status. * driver_byte = set by mid-level. */#define status_byte(result) (((result) >> 1) & 0x7f)#define msg_byte(result) (((result) >> 8) & 0xff)#define host_byte(result) (((result) >> 16) & 0xff)#define driver_byte(result) (((result) >> 24) & 0xff)#define sense_class(sense) (((sense) >> 4) & 0x7)#define sense_error(sense) ((sense) & 0xf)#define sense_valid(sense) ((sense) & 0x80)......
SCSI SENSE
A SCSI sense buffer is the error reporting facility in SCSI. It reports the error code and possibly also additional information that helps to locate thesource of the problem so the administrator or developer can help resolve the issue.
A SCSI sense has several top-level attributes that one would care about the most:
Sense type, either fixed or descriptor,
What command it relates to, current or previous,
Sense Key,
ASC/ASCQ — Additional Sense Code and Additional Sense Code Qualifier.
The easiest way to decode a sense buffer is to use a tool, I know of two:
sg3utils provides sgdecode_sense since version 1.31
libscsicmd implements it
a web tool is available to Decode the sense data that is based on libscsicmd
参考连接
Linux内核I/O报错信息中hostbyte与driverbyte含义(http://ilinuxkernel.com/?p=760) /usr/src/kernels/3.10.0-957.el7.x86_64/include/scsi/scsi.h
本文分享自微信公众号 - WriteSimpleDemo(this_is_a_wechat)。
若有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一块儿分享。