error-handling - ASC/ASCQ 号码的 Sense Key

标签 error-handling disk error-code scsi

在 SCSI 接口(interface)错误通过 3 个数字的串联来识别:SenseKey + ASC + ASCQ。 asc/ascq pair description根据 asc/ascq 值描述所有错误的含义。但并不是所有的 asc/ascq 对都对所有的感觉键都有意义。我应该如何知道每个 asc/ascq 对将返回哪个感知 key ?

最佳答案

ASC/ASCQ 不绑定(bind)到 Sense Key。

Sense key 是您的主要错误代码。 ASC 和 ASCQ 是 附加 感知代码和限定符。回答 I_T_L_Q 关系中的问题是一个小技巧。

所以回答你的问题 - 没有办法知道每个 ASC/ASCQ 对将返回哪个感知 key 一般 .

但是有一些众所周知的“感知键”+ ASC + ASCQ 组合,因为大多数操作系统仅对一小部分错误实现错误处理。不幸的是,您只能通过检查源代码才能找到该子集。

例如,在 Mac OS X Darwin 内核中,您可以查找 ADDITIONAL_SENSE_CODEIOSCSIArchitectureModelFamily .这是来自 IOSCSIBlockCommands/IOSCSIBlockCommandsDevicePM.cpp 的示例,第 659 行:

// Check the sense key to see if it is an error group we know how to handle
if  ( ( ( senseBuffer.SENSE_KEY & kSENSE_KEY_Mask ) == kSENSE_KEY_NOT_READY ) || 
      ( ( senseBuffer.SENSE_KEY & kSENSE_KEY_Mask ) == kSENSE_KEY_MEDIUM_ERROR ) )
{

    // The SenseKey is an 02 ( Not Ready ) or 03 ( Medium Error ). Check to see
    // if we can do something about this

    if ( ( senseBuffer.ADDITIONAL_SENSE_CODE == 0x04 ) && 
         ( senseBuffer.ADDITIONAL_SENSE_CODE_QUALIFIER == 0x02 ) )
    {

        // Device requires a start command before we can tell if media is there
        if ( START_STOP_UNIT ( request, 0x00, 0x00, 0x00, 0x01, 0x00 ) == true )
        {

            STATUS_LOG ( ( "Sending START_STOP_UNIT.\n" ) );
            serviceResponse = SendCommand ( request, 0 );

        }

        STATUS_LOG ( ( "%s::drive NOT READY\n", getName ( ) ) );

        IOSleep ( 200 );
        continue;

    }

    else if ( ( senseBuffer.ADDITIONAL_SENSE_CODE == 0x3A ) && 
              ( senseBuffer.ADDITIONAL_SENSE_CODE_QUALIFIER == 0x00 ) )
    {

        STATUS_LOG ( ( "No Media.\n" ) );
        // No media is present, return false
        driveReady = true;
        mediaPresent = false;

    }

    else
    {

        STATUS_LOG ( ( "%s::drive NOT READY\n", getName ( ) ) );
        IOSleep ( 200 );
        continue;

    }

}

使用过的 SK+ASC+ASCQ 元组:
  • 0x02/0x03, 0x04, 0x02 - 未准备好/中等错误,逻辑单元未准备好,需要初始化命令;
  • 0x02/0x03, 0x3A, 0x00 - 未就绪/介质错误,介质不存在。

  • 正如您在此处看到的,ASC/ASCQ 对与 0x02 或 0x03 Sense 键一起使用,并且要采取的操作取决于 ASC/ASCQ 对,因此 ASC/ASCQ 对如何在 Sense 键之间划分并不重要。

    关于error-handling - ASC/ASCQ 号码的 Sense Key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22297233/

    相关文章:

    java - 如何使用Spring Boot引发自定义异常而不是500

    jsf - 使用 JSF 生成 HTTP 错误代码页面以及异常错误页面?

    c++ - 将 std::error_code 与整数进行比较

    windows - 如何在 Windows 中从命令提示符或 powershell 更改驱动器号

    c++ - 插入加密U盘后,如何使用WMI找到 'launcher'逻辑盘?

    php - 缓存——磁盘还是数据库?

    mysql - 错误代码: 1826. Duplicate foreign key constraint name 'menu_ibfk_1'

    php - Carbon (laravel) 处理无效日期

    logging - NLog 自定义 LayoutRenderer 不工作

    error-handling - JSLint 错误 : Expected 'ignore' and instead saw 'ex'