SCSI Disk Medium Defects

Overview

直接从SBC-4文档中摘录一段吧,原文描述非常清晰:
Any medium has the potential for medium defects that cause data to be lost. Therefore, physical blocks and/or logical blocks may contain additional information that allows the detection of changes to the logical block data caused by medium defect or other phenomena. The additional information may also allow the logical block data to be reconstructed following the detection of such a change (e.g., ECC bytes).

A medium defect causes:
a) a recovered error if the device server is able to read or write a logical block within the logical unit’s
recovery limits; or
b) an unrecovered error if the device server is unable to read or write a logical block within the logical
unit’s recovery limits,
where the logical unit’s recovery limits are:
a) specified in the Read-Write Error Recovery mode page (see 6.5.10);
b) specified in the Verify Error Recovery mode page (see 6.5.11); or
c) vendor specific, if the device server does not implement the Read-Write Error Recovery mode page or the Verify Error Recovery mode page.

上面实际上也定义了recovered error和unrecovered error的区别:在规定的限制内,如果logical block中的内容可读或者可写(视操作而定),那么就算是recovered。如果做不到,那么就是unrecovered。这个限制(recovery limits)指的是Read-Write Error Recovery mode page、Verify Error Recovery mode page或者vendor自定义的page中规定的限制(比如最多重试次数、recovery时间限制等等)。

块坏恢复

硬盘本身的支持

Medium defects可能会造成潜在的数据丢失。硬盘可能会提供恢复的机制,但也可能不提供。理想情况下,硬盘可以自动修复这些坏块,将LBA重新映射到好的物理块上。这种机制称为块坏自动重分配(automatic reassignment of defects)。硬盘是否支持这种机制,可以看一下Read-Write Error Recovery mode page。

> sginfo -a /dev/sdc
... # 省略一些输出
Read-Write Error Recovery mode page (0x1)
-----------------------------------------
AWRE                               1
ARRE                               1
TB                                 0
RC                                 0
EER                                0
PER                                0
DTE                                0
DCR                                0
Read Retry Count                   1
Correction Span                    0
Head Offset Count                  0
Data Strobe Offset Count           0
Write Retry Count                  1
Recovery Time Limit (ms)           0
... # 省略一些输出

AWRE:AWRE为0表示硬盘不应该执行automatic write reassignment。AWRE为1表示当硬盘在写过程中遇到recovered或者unrecovered error的时候,会尝试对坏块进行reassignment。
ARRE:ARRE为0表示硬盘不应该执行automatic read reassignment。ARRE为1表示当硬盘在读过程中遇到recovered的时候,会尝试对坏块进行reassignment。注意,读请求与写请求不一样的是,读请求只有遇到recovered error的时候(且ARRE为1),才会尝试reassignment,对于unrecovered error,读请求是不会自动reassign的。
Write Retry Count:这个参数指的不是write的重试次数(虽然看起来特别像),而是指的对于write请求,如果出错了,硬盘的recovery次数。也就是说比如write请求出错了,硬盘尝试进行recovery的次数,最多不超过Write Retry Count规定的次数。
Read Retry Count:跟Write Retry Count类似,针对读请求。

读请求故障处理(Read with unrecovered Medium error)

当读请求不可恢复(unrecovered)的错误时(例如scsi status是CHECK CONDITION,sense key是MEDIUM ERROR,ASC是UNRECOVERED READ ERROR),硬盘是不会触发自动重分配的。需要由上层的应用程序做显式的处理:
a) 如果应用程序可以重新生成相关的数据(例如从RAID的其它硬盘中重新构造出来),并且AWRE bit是1,那么应用程序可以发送一个write命令将数据写入,这个write命令会触发automatic write reassignment。
b) 如果应用程序可以重新生成相关的数据,并且AWRE bit是0,那么应用程序需要先发送REASSIGN BLOCKS命令为故障的LBA重新分配物理块,然后再发送WRITE命令将数据写入。
c) 如果应用程序无法重新生成相关的数据,那么应用程序可以尝试使用REASSIGN BLOCKS命令来重新为LBA分配物理块。但是由于数据无法再生成,所以这些数据就丢失了。

获取defect列表

硬盘为了记录这些有故障的坏块,就需要一个列表,这个列表就是PLIST(primary defect list)和GLIST(grown defect list)。使用sginfo命令可以查看硬盘的PLIST和GLIST列表。

[root@node100 ~]# sginfo -d /dev/sdc
INQUIRY response (cmd: 0x12)
----------------------------
Device Type                        0
Vendor:                    HGST    
Product:                   HUS728T8TAL5204 
Revision level:            C414

>>> Unable to read primary (PLIST) defect data.
Defect Lists
------------
0 entries (0 bytes) in grown (GLIST) table.
Format (4) is: bytes from index [Cyl:Head:Off]
Offset -1 marks whole track as bad.

这个PLIST和GLIST有什么区别呢?简单的说PLIST记录出厂时发现的坏块,在映射LBA的时候会自动跳过这些坏块,不影响性能。而GLIST是使用过程中发现的坏块,这些LBA可能会被重分配到其它的物理块上,访问这些坏块就会影响性能。具体的可以参考这篇文档PLIST基本缺陷列表与GLIST 成长缺陷列表

如何制造硬盘故障(软件)

SBC文档中提到,可以使用WRITE LONG命令来制造假的不可恢复的故障。

参考资料

SBC-4

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、源题QUESTION 36Your database is open and the LISTENER lis...
    猫猫_tomluo阅读 1,476评论 0 2
  • Software Requirements Specifications Document CS330 Softw...
    卤蛋Aunm阅读 285评论 0 0
  • The Great A.I. Awakening How Google used artificial intel...
    图羽阅读 1,474评论 0 3
  • 马莹花是前一天和爸爸住在亲戚家,爸爸的表妹那里。爸爸路过那里,正好看了看自己的病,胸膜炎已经好久了。看了之...
    何亦群阅读 340评论 2 2
  • 昨天,女儿去朋友家玩儿,回来感慨地说:“还是我们家好。” 我问“怎么了?” 她说,“朋友在家不管做什么,她妈妈总是...
    昕明阅读 384评论 1 2

友情链接更多精彩内容