HPFS

HPFS includes features that make it an efficient manager of large hard-disk volumes. HPFS also supports long filenames (up to 255 characters), which allows users to give files descriptive names.

When HPFS formats a volume, it reserves the first 18 sectors for the boot block, the super block, and the spare block. These three structures are used to boot the operating system, maintain the file system, and recover from possible errors.

HPFS also reserves space for a pair of 2K bitmaps at 16 MB intervals throughout the volume. Each bitmap contains one bit for each allocation unit (equal to one sector) in the 8 MB band, showing which allocation units are in use.

Figure 5.3 illustrates how HPFS organizes a volume.

Figure 5.3 An HPFS Volume

The bitmaps are alternately located at the end and beginning of each band to allow a maximum amount of contiguous space for data (almost 16 MB instead of almost 8 MB). In addition, HPFS plans where it writes new files, leaving room between new and existing files so that each has room to expand into contiguous space on the disk. This feature helps HPFS to allow fast data retrieval and to minimize file fragmentation.

Another feature that accounts for fast directory searches is HPFS's use of B-trees. A B-tree is a tree structure with a root and several nodes. It contains data organized in some logical way so that the whole structure can be quickly traversed. The root contains a small amount of administrative information, a map to the rest of the structure, and possibly a small amount of data. The nodes contain most of the data. On large directories, B-trees perform much better than the linear lists used by the FAT file system.

HPFS uses B-trees to structure each of its directories and each of its files. Each directory points to Fnodes for files contained in that directory. An Fnode is 512 bytes in length and contains a header, the filename (truncated to 15 characters), the file length, extended attributes (EA) and access control list (ACL) information, and the location of the file's data.

Note HPFS ACLs are supported by the OS/2 operating system but not by Windows NT. If you want access control list support, use NTFS.

Figure 5.4 shows the Fnode for a file whose data is contained in Extent1, Extent2, and Extent3 (where an extent is a range of contiguous sectors).

Figure 5.4 An HPFS File

Because of the arrangement of bitmaps on the volume shown in Figure 5.3, a file extent can be almost 16 MB. Depending on the size of the file, the Fnode can point to as many as eight extents. If the file is so large that it cannot be contained within eight extents, the Fnode includes up to 12 pointers to allocation nodes that have space for more file extents.

If the extended attribute and ACL information cannot be contained in the Fnode, the Fnode includes a pointer to that information.

In short, HPFS includes powerful features and works efficiently on disks of up to 2 GB. The HPFS design does have some weaknesses. For example, if something damages the first portion of the volume, which contains boot information and a pointer to the root directory, use of the volume is lost. HPFS's use of chkdsk at each system boot and to repair disk errors can be time-consuming. In addition, its design requiring 512-byte sectors is not well-suited for larger volumes.