您的位置:首页 > 其它

Logical block addressing

2009-02-23 22:04 204 查看
quoted from

http://en.wikipedia.org/wiki/Logical_block_addressing

LBA is a particularly simple addressing scheme; blocks are located by an index, with the first block being LBA=0, the second LBA=1, and so on. The LBA scheme replaces earlier schemes which exposed the physical details of the storage device to the software of the operating system. Chief among these was the cylinder-head-sector (CHS) scheme, where blocks were addressed by means of a tuple which defined the cylinder, head, and sector at which they appeared on the hard disk. CHS didn't map well to devices other than hard disks (such as tapes and networked storage), and was generally not used for them. CHS was used in early MFM and RLL drives, and both it and its successor Extended Cylinder-Head-Sector (ECHS) were used in the first ATA drives.

SCSI introduced LBA as an abstraction. While the drive controller still addresses data blocks by their CHS address, this information is generally not used by the SCSI device driver, the OS, filesystem code, or any applications (such as databases) that access the "raw" disk. System calls requiring block-level I/O pass LBA definitions to the storage device driver; for simple cases (where one volume maps to one physical drive), this LBA is then passed directly to the drive controller.

CHS to LBA conversion

C-H-S tuples can be converted to LBA addresses using the following formula:

LBA to CHS mapping

LBA addresses can be mapped to C-H-S tuples using the following formulae:

(start by calculating 'S', as for simplicity it is used for calculating 'C' and 'H')

Where:

LBA is the logical block address

heads is the total number of logical heads

sectors_per_track is the number of logical sectors per track

mod is the modulo operator

Note: the total number of cylinders does not enter into any calculation.

Another formula:

LBA / spt = Result1 + Remainder1
S = Remainder1 + 1
Result1 / heads = Result2 + Remainder2
C = Result2
H = Remainder2

Example:

CHS = (600, 10, 84). Finding CHS for LBA = 1234 would be:

1234 / 84 = 14 R 58
S = 58 + 1 = 59
14 / 10 = 1 R 4
C = 1
H = 4
CHS = (1, 4, 59)

Test: ((1 * 10) + 4) * 84 + 59 - 1 = 14 * 84 + 58 = 1234
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: