File system structure
The journaled file systems use data structures, such as superblock, allocation groups, inodes, blocks, fragments, and device logs.
The superblock contains control information about a file system, such as the overall size of the file system in 512 byte blocks, the file system name, the file system log device, the version number, the number of inodes, the list of free inodes, the list of free data blocks, date and time of creation, and file system state. All this data is stored in the first logical block of the file system. Corruption of this data may render the file system unusable. This is why the system keeps a second copy of the superblock on logical block 31.
An allocation group consists of inodes and its corresponding data blocks. An allocation groups spans multiple adjacent disk blocks and improves the speed of I/O operations. Both JFS and JFS2 file systems use allocation groups. For a JFS file system, the allocation group size can be specified when the file system is created.
The inode contains control information about the file, such as type, size, owner, and the date and time when the file was created, modified, or last accessed. It also contains pointers to data blocks that store the actual data of the file. Every file has a corresponding inode.
For JFS file systems, the maximum number of inodes, and hence the maximum number of files, is determined by the number of bytes per inode (nbpi) value, which is specified when the file system is created. For every nbpi bytes of your file system, there will be an inode created. The total number of inodes is fixed. The nbpi values needs to be correlated with allocation group size.
The JFS restricts all file systems to 16 MB (224) inodes.
JFS2 file systems manages the necessary space for inodes dynamically so there is not any nbpi parameter.
Data blocks store the actual data of the file or pointers to other data blocks. The default value for disk block size is 4 KB.
Fragments of logical blocks can be used to support files smaller than the standard size of the logical block (4 KB). This rule applies only to the last block of a file smaller than 32 KB.
For JFS file systems only, you have the option to use compression to allow all logical blocks of a file to be stored as a sequence of contiguous fragments. Compression for a file system will increase the amount of CPU and I/O activity when using that file system.
These features can be useful to support a large number of small files. Fragment size must be specified for a file system at installation time. Different file systems can have different fragment sizes.