[Courses] [FS] Lesson 5

Val Henson val at nmt.edu
Wed Dec 10 17:33:00 EST 2003


On Wed, Dec 10, 2003 at 04:20:57PM -0000, James Sutherland wrote:
> 
> Almost all file systems work by dividing the disk into chunks called
> clusters. Each cluster is then either "in use" or "free". This leaves
> a problem: supposing you have 4096 byte (4kb) clusters, and want to
> store a 5kb file? Most file systems (FAT, NTFS, ext2) just allocate
> 2 clusters - wasting the other 3kb of the second cluster.

Just a note: What is here described as a "cluster" is more commonly
called a "block" in UNIX file system terminology.  When someone talks
about "block size," they usually mean the size of a block in a file
system.[1] Another way to approach the problem described above is to
have "frags" which are smaller than ("fragments" of) the "normal"
block size.  A common block size is 4K or 8K, a common frag size is
1K.  A third approach is to have many different block sizes, from 512
bytes up to around 128K - this is the approach ZFS, the file system I
am working on, is currently taking.

Why not have teeny-tiny block sizes?  Performance.  Writing eight 1K
blocks to disk is a lot slower than writing one 8K block.  Explaining
this further will require getting into a lot of disk drive
detail... Let me know if there is interest (and Meredydd hasn't
already covered it).

What is a group of blocks called?  Traditionally, file systems
designers make up a new, slightly different name for a group of blocks
for each file system, and each kind of block grouping has some
slightly different use.  I've heard cylinder groups, allocation
groups, and segments.  ZFs will probably have metaslabs.

-VAL

[1] "Block size" might also refer to the native block size of a disk,
which is the smallest amount that can be read or written at once
(currently 512 bytes), or the block size of the I/O subsystem - the
disk driver, the I/O scheduler, etc.  But usually it means file system
block size, the size of the most common unit of space allocated on disk.



More information about the Courses mailing list