[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

General Programming Concepts: Writing and Debugging Programs


JFS2 File System Layout

A file system is a set of files, directories and other structures. The file systems maintain information and identify where the data is located on the disk for a file or directory. In addition to files and directories a JFS2 file system contains a superblock, allocation maps and one or more allocation groups. An allocation group contains disk inodes and extents. Each file system occupies one logical volume.

Superblock

The superblock is 4096 bytes in size and starts at byte offset 32768 on the disk. The superblock maintains information about the entire file system and includes the following fields:

Allocation Maps

The file system contains two allocation maps:

Disk I-Nodes

A logical block contains a file or directory's data in units of file system blocks. Each logical block is allocated file system blocks for the storage of its data. Each file and directory has an i-node that contains access information such as file type, access permissions, owner's ID, and number of links to that file. These i-nodes also contain a "B+-tree" for finding the location on the disk where the data for a logical block is stored.

Allocation Groups

Allocation groups divide the space on a file system into chunks. Allocation groups are used for heuristics only. Allocation groups allow JFS2 resource allocation policies to use well known methods for achieving good I/O performance. First, the allocation policies try to cluster disk blocks and disk inodes for related data to achieve good locality for the disk. Files are often read and written sequentially and the files within a directory are often accessed together. Second, the allocation policies try to distribute unrelated data throughout the file system in order to accomodate disk locality.

Alocation groups within a file system are identified by a zero-based allocation group index, the allocation group number.

Allocation Group Sizes

Allocation group sizes must be selected which yield allocation groups that are sufficiently large to provide for contiguous resource allocation over time. Allocation groups are limited to a maximum number of 128 groups. Additionally, the minimum allocation group size is 8192 file system blocks.

Partial Allocation Groups

A file system whose size is not a multiple of the allocation group size will contain a partial allocation group; the last allocation group of the file system is not fully covered by disk blocks. This partial allocation group will be treated as a complete allocation group, except the non-existant disk blocks will be marked as allocated in the block allocation map.

heuristics
Relating to or using a problem-solving technique in which the most appropriate solution of several found by alternative methods is selected at successive stages of a program for use in the next step of the program.

Using File System Subroutines

The most used file system subroutines are:

fscntl Controls file system control operations
getfsent, getfsspec, getfsfile, getfstype, setfsent, or endfsent
  Obtain information about a file system
lseek Moves the read-write pointer
mntctl Returns mount status information
vmount or mount Make a file system ready for use
statfs, fstsfs, or ustat Report file system statistics
sync Updates file systems to disk 

Other subroutines are designed for use on virtual file systems (VFS):

getvfsent, getvfsbytype, getvfsbyname, getvfsbyflag, sevfsent, or endvfsent
  Retrieve a VFS entry
umount or uvmount Remove VFS from the file tree

Related Information

mkfs command

Working with JFS2 i-nodes

Chapter 5, File Systems and Directories

Chapter 13, Logical Volume Programming

How to Add a Journaled File System on a New Logical Volume

Creating New File System Types

JFS File Space Allocation


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]