SCSI错误定位:hostbyte和driverbyte

1. 错误打印log

硬盘跑IO的时候,经常会见到下面这种错误log,这是SCSI做的打印。这是什么错误?该怎么定位?

[ 6304.176111] sd 0:0:4:0: [sde] tag#7 UNKNOWN(0x2003) Result: hostbyte=0x07 driverbyte=0x00
[ 6304.184281] sd 0:0:4:0: [sde] tag#7 CDB: opcode=0x28 28 00 00 0a 88 00 00 04 00 00
[ 6304.191838] print_req_error: I/O error, dev sde, sector 690176
[ 6333.587832] sd 0:0:4:0: [sde] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x05 driverbyte=0x00
[ 6333.596010] sd 0:0:4:0: [sde] tag#0 CDB: opcode=0x28 28 00 00 0a 8c 00 00 04 00 00

2. log打印位置

首先,我们看这个日志是在哪里打印的。drivers/scsi/scsi_lib.c中scsi_io_completion()。两行分别对应scsi_print_result()和scsi_print_command()。

1012         switch (action) {
1013         case ACTION_FAIL:
1014                 /* Give up and fail the remainder of the request */
1015                 if (!(req->rq_flags & RQF_QUIET)) {
1016                         static DEFINE_RATELIMIT_STATE(_rs,
1017                                         DEFAULT_RATELIMIT_INTERVAL,
1018                                         DEFAULT_RATELIMIT_BURST);
1019
1020                         if (unlikely(scsi_logging_level))
1021                                 level = SCSI_LOG_LEVEL(SCSI_LOG_MLCOMPLETE_SHIFT,
1022                                                        SCSI_LOG_MLCOMPLETE_BITS);
1023
1024                         /*
1025                          * if logging is enabled the failure will be printed
1026                          * in scsi_log_completion(), so avoid duplicate messages
1027                          */
1028                         if (!level && __ratelimit(&_rs)) {
1029                                 scsi_print_result(cmd, NULL, FAILED);
1030                                 if (driver_byte(result) & DRIVER_SENSE)
1031                                         scsi_print_sense(cmd);
1032                                 scsi_print_command(cmd);
1033                         }
1034                 }
1035                 if (!scsi_end_request(req, error, blk_rq_err_bytes(req), 0))
1036                         return;
1037                 /*FALLTHRU*/
1038         case ACTION_REPREP:

3. hostbyte和driverbyte含义

hostbyte和driverbyte是cmd->result中的域,如下所示。

210 #define status_byte(result) (((result) >> 1) & 0x7f)
211 #define msg_byte(result)    (((result) >> 8) & 0xff)
212 #define host_byte(result)   (((result) >> 16) & 0xff)
213 #define driver_byte(result) (((result) >> 24) & 0xff)

hostbyte码值对应的含义如下:

132 /*
133  * Host byte codes
134  */
135
136 #define DID_OK          0x00    /* NO error                                */
137 #define DID_NO_CONNECT  0x01    /* Couldn't connect before timeout period  */
138 #define DID_BUS_BUSY    0x02    /* BUS stayed busy through time out period */
139 #define DID_TIME_OUT    0x03    /* TIMED OUT for other reason              */
140 #define DID_BAD_TARGET  0x04    /* BAD target.                             */
141 #define DID_ABORT       0x05    /* Told to abort for some other reason     */
142 #define DID_PARITY      0x06    /* Parity error                            */
143 #define DID_ERROR       0x07    /* Internal error                          */
144 #define DID_RESET       0x08    /* Reset by somebody.                      */
145 #define DID_BAD_INTR    0x09    /* Got an interrupt we weren't expecting.  */
146 #define DID_PASSTHROUGH 0x0a    /* Force command past mid-layer            */
147 #define DID_SOFT_ERROR  0x0b    /* The low level driver just wish a retry  */
148 #define DID_IMM_RETRY   0x0c    /* Retry without decrementing retry count  */
149 #define DID_REQUEUE     0x0d    /* Requeue command (no immediate retry) also
150                                  * without decrementing the retry count    */
151 #define DID_TRANSPORT_DISRUPTED 0x0e /* Transport error disrupted execution
152                                       * and the driver blocked the port to
153                                       * recover the link. Transport class will
154                                       * retry or fail IO */
155 #define DID_TRANSPORT_FAILFAST  0x0f /* Transport class fastfailed the io */
156 #define DID_TARGET_FAILURE 0x10 /* Permanent target failure, do not retry on
157                                  * other paths */
158 #define DID_NEXUS_FAILURE 0x11  /* Permanent nexus failure, retry on other
159                                  * paths might yield different results */
160 #define DID_ALLOC_FAILURE 0x12  /* Space allocation on the device failed */
161 #define DID_MEDIUM_ERROR  0x13  /* Medium error */

4. hostbyte跟底层的转换关系

SAS_DATA_UNDERRUN --> DID_ERROR

SAS_DATA_OVERRUN --> DID_ERROR

SAS_ABORTED_TASK --> DID_ABORT

drivers/scsi/libsas/sas_scsi_host.c中的sas_end_task()

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
"failed result: hostbyte=did_error" 是一个错误信息,通常在计算机网络通信中出现。这个错误信息意味着在与主机通信的过程中出现了错误。 具体而言,"hostbyte" 代表主机错误,而 "did_error" 表示发生了错误。这可能是由于以下几个原因导致的: 1. 连接问题:可能由于网络连接问题,无法与目标主机建立稳定的连接,导致数据传输失败。 2. 主机故障:目标主机可能遇到硬件或软件故障,无法正常处理请求或提供所需的服务。 3. 配置错误:可能由于配置错误或设置不正确,导致主机无法正确处理请求,从而出现错误。 4. 安全限制:目标主机可能受到安全限制,例如防火墙或访问控制列表,阻止了与主机的通信。 在解决这个问题的过程中,可以尝试以下步骤: 1. 检查网络连接:确保网络连接正常,尝试与其他主机进行通信,以确定是否存在网络问题。 2. 检查主机状态:确认目标主机是否正常运行,并检查主机上的系统日志或错误日志,以获取更多有关错误的详细信息。 3. 检查配置:核实与目标主机通信所使用的协议、端口号和其他配置是否正确。 4. 检查安全设置:如果存在安全限制,确保已正确配置防火墙或访问控制列表,以允许与目标主机的通信。 如果以上步骤都没有解决问题,可以尝试联系网络管理员或技术支持团队,他们可能能够提供更进一步的帮助和指导。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值