## 13.2 Disk
# 13.2.1 Mechanics of Disk: 首先给出一副Disk的结构图
–
– 组成结构的顺序是:disk –> platter –> surface –> track –> block –>sector –> byte\
对于 large vintage-2008 disk 来说: 1
disk –> 1*8 platter –> 1*8*2 surface –>
1*8*2*2^16
track –>
1*8*2*2^16*64
block –>
1*8*2*2^16*64*4
sector –>
1*8*2*2^16*64*4*2^12
byte
# 13.2.2 The Disk Controller
– Accessing (reading or writing) delay
– seek time : 探针定位到cylinder
– rotational latency: 定位到该cylinder的第一个sector
– transfer time: 读写进行时的时间消耗
– 时间消耗比:seek time >
rotational latency >
transfer time
## 13.3 Accelerating Access to Secondary Storage , 加速到外部存储区的访问
1. Place blocks that are accessed together on the same cylinder, so we can often avoid seek time, and possibly rotational latency as well.
2. Divide the data among several smaller disks rather than one large one. Having more head assemblies that can go after blocks independently can increase the number of block accesses per unit time.
3. “Mirror” a disk: making two or more copies of the data on different disks. In addition to saving the data in case one of the disks fails, this strategy, like dividing the data among several disks, lets us access several blocks at
once.
4. Use a disk-scheduling algorithm, either in the operating system, in the DBMS, or in the disk controller, to select the order in which several requested blocks will be read or written.
– 书里面提到了一些列的算法,如磁盘调度算法比First in First serve 好在那个,这些就不写了。
5. Prefetch blocks to main memory in anticipation of their later use.
##
13.4
Disk Failures
– intermittent failure :间断错误,重新读写
– media decay : 媒体损坏,某些sector无法读取
– write failure:断电导致的写了一半另一半没办法写下去
– disk crash:最严重的整个disk crash
# 13.4.2 Checksums
# 13.4.5 Recovery from Disk Crashes
– RAID 1
– 作用:解决一个disk crash
– 实现方式:每个data disk 有一个redundancy,一个crash另一个过去
– RAID 4
– 作用:解决一个disk crash
– 实现:可以几个data disk 对一个 redundancy,图片说明如下:
上述 disk 4 是modolu-2 运算后的redundancy disk
– 缺点:每次update需要多次计算和更新多个disk的值,不能处理多个disk crash的情况
– RAID 5
– RAID4 之上对于计算和更新多个disk的值得一种提升。细节没具体看。
– RAID 6
– 作用:能够同时解决两个disk crash的错误
– 实现方法:如果有4个data disk 则有 3个redundancy。
– 图片说明:(运算方式:异或)
– 关于data disk 和 redundant disk的数量关系: