The Interface

This lesson discusses the interface of a typical hard-disk.

Let’s start by understanding the interface to a modern disk drive. The basic interface for all modern drives is straightforward. The drive consists of a large number of sectors (512-byte blocks), each of which can be read or written. The sectors are numbered from 00 to n1n-1 on a disk with nn sectors. Thus, we can view the disk as an array of sectors; 00 to n1n-1 is thus the address space of the drive.

Multi-sector operations are possible; indeed, many file systems will read or write 4KB at a time (or more). However, when updating the disk, the only guarantee drive manufacturers make is that a single 512-byte write is atomic (i.e., it will either complete in its entirety or won’t complete at all). Thus, if an untimely power loss occurs, only a portion of a larger write may complete (sometimes called a torn write).

There are some assumptions most clients of disk drives make, but those are not specified directly in the interface. Schlosser and Ganger“MEMS-based storage devices and standard disk interfaces: A square peg in a round hole?” Steven W. Schlosser, Gregory R. Ganger FAST ’04, pp. 87-100, 2004 While the MEMS aspect of this paper hasn’t yet made an impact, the discussion of the contract between file systems and disks is wonderful and a lasting contribution. We later build on this work to study the “Unwritten Contract of Solid State Drives” have called this the “unwritten contract” of disk drives. Specifically, one can usually assume that accessing two blocksWe, and others, often use the terms block and sector interchangeably, assuming the reader will know exactly what is meant per context. Sorry about this! near one-another within the drive’s address space will be faster than accessing two blocks that are far apart. One can also usually assume that accessing blocks in a contiguous chunk (i.e., a sequential read or write) is the fastest access mode, and usually much faster than any more random access pattern.

Get hands-on with 1400+ tech skills courses.