Registering Inodes

When directories and files are created, the ext2_new_inode function is used to find a free inode for the new filesystem entry. However, the search strategy varies according to situation — this can be distinguished by the mode argument (S_IFDIR is set for directories but not for regular files).

The search itself is not performance-critical, but it is very important for filesystem performance that the inode be optimally positioned to permit rapid access to data. For this reason, this section is devoted to an examination of the inode distribution strategy adopted by the kernel.

The kernel applies three different strategies:

1. Orlov allocation for directory inodes.

2. Classic allocation for directory inodes. This is only used if the oldalloc option is passed to the kernel, which disables Orlov allocation. Normally, Orlov allocation is the default strategy.

3. Inode allocation for regular files. The three options are investigated below.

Orlov Allocation

A standard scheme proposed and implemented for the OpenBSD kernel by Grigoriv Orlov is used to find a directory inode. The Linux version was developed later. The goal of the allocator is to ensure that directory inodes of child directories are in the same block group as the parent directory so that they are physically closer to each other and costly hard disk seek operations are minimized. Of course, not all directory inodes should end up in the same block group because they would then be too far away from their associated data.

The scheme distinguishes whether a new directory is to be created directly in the (global) root directory or at another point in the filesystem, as the code flow diagram for find_group_orlov in Figure 9-20 shows.

While entries for subdirectories should be as close to the parent directory as possible, subdirectories of the filesystem root should be diverted as well as possible. Otherwise, directories would again accumulate in a distinguished block group.

Ifind_group_orlov|

Parent inode is root inode?

Search starts in present group

Iterate over all groups

Search starts in random group

Test suitability of group

Fallback selection

Return group number [

Continue reading here: Figure 920 Code flow diagram for findgrouporlov

Was this article helpful?

0 0