I'm no expert, but i doubt we have a problem here...

Originally Posted By: Technical Note TN1150
Terminology

HFS Plus is a specification of how a volume (files that contain user data, along with the structure to retrieve that data) exists on a disk (the medium on which user data is stored). The storage space on a disk is divided into units called sectors. A sector is the smallest part of a disk that the disk's driver software will read or write in a single operation (without having to read or write additional data before or after the requested data). The size of a sector is usually based on the way the data is physically laid out on the disk. For hard disks, sectors are typically 512 bytes. For optical media, sectors are typically 2048 bytes.

Most of the data structures on an HFS Plus volume do not depend on the size of a sector,
with the exception of the journal. Because the journal does rely on accessing individual sectors, the sector size is stored in the jhdr_size field of the journal header (if the volume has a journal).

HFS Plus allocates space in units called allocation blocks;
an allocation block is simply a group of consecutive bytes. The size (in bytes) of an allocation block is a power of two, greater than or equal to 512, which is set when the volume is initialized. This value cannot be easily changed without reinitializing the volume. Allocation blocks are identified by a 32-bit allocation block number, so there can be at most 2^32 allocation blocks on a volume. Current implementations of the file system are optimized for 4K allocation blocks.

Now i realize that sector != allocation block ( necessarily! )... but i think the bottom line is: HFS+ was designed around pretty much everything being stored and accessed in terms of 4-kilobyte clumps already. [iirc, 4K was an "optimum size/compromise" that Apple settled on when they released HFS+ for System 8.1 (in anticipation of drive sizes growing larger and larger with each year).]

--

A simple way of witnessing this is to save a small plain text file with TextEdit. Just type 123 and save it. Then Get Info with Finder...

Untitled
Kind: Plain text
Size: 4 KB on disk (3 bytes)

That's right, the data is only 3 bytes in length... but HFS+ insists on a minimum of 4096 bytes being allocated for any item. (not 4, 8, 16, 32, 64, 128, 512, 1024 or 2048).

4096.

[edit: and if some file gets as large as 4097 bytes, that would then require 2 allocation blocks on disk... or 8192 bytes.]

Last edited by Hal Itosis; 02/14/10 10:45 PM.