Disk Block
- Tags
- comp-arch
Is a portion of a disk that is reserved for storing the contents of a file or directory. Most file-systems refer to portions of a hard disk in terms of blocks.
You can think of a block as a contiguous region on disk, the size of which is often determined by some property of the underlying hardware but more frequently based on the size of a page in memory (to allow disk data to be cached in memory for faster access).
Indirect Blocks
In the common case of a file being larger than the max-space addressable by its direct blocks we store an indirect block instead. Each indirect block points to multiple data blocks. And in some cases we may store indirect-indirect blocks which point to multiple indirect-blocks.
Take heed:
“All problems in computer science can be solved by another level of indirection.”
- David Wheeler
Indirection allows an exponential increase in the amount of space an inode can track. Consider a disk divided into 4KiB ( = \( 4 \times 2^{10} \) bytes) blocks. Each block contains 4-bits meaning on a 32-bit system (4-byte pointers) a single indirect block can store \( \frac{4 \times 2^{10}}{4} = 1024 \) pointers to other blocks, each of which is 4KiB for a total of 4MiB of referenced memory. Adding one more layer of indirection means a single indirect-indirect block can reference up-to \( 1024 \times 4\text{MiB} = 4\text{GiB} \). Warn: Each level of indirection makes the read-times for blocks slower.