Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


❑ rsv_alloc_hitskeeps track of the pre-allocation hits, that is, how many allocations were per-
formed from within the reservation window.
❑ Most importantly, the reserve window itself is given byrsv_window.

Ext2 reservation
windows

struct ext2_reserve_
window

struct ext2_reserve_
window_node

struct ext2_block_
alloc_info

struct ext2_Inode_
info

struct rb_node

ext2_sb_info

f_rsv_window_root

Figure 9-7: Data structures used by the pre-allocation mechanism.

If an inode is equipped with pre-allocation information, thenext2_inode_info->i_block_alloc_info
points to an instance ofstruct ext2_block_alloc_info. In addition to an embedded instance of
ext2_reserve_window_nodethat brings the connection with the red-black tree, the data structure
contains information about the last allocated block:last_alloc_logical_blockdenotes the file-relative
number of the last allocated block, whilelast_alloc_physical_blockstores the corresponding physical
number on the block device.

9.2.3 Creating a Filesystem


Filesystems are not created by the kernel itself but by themke2fsuserspace tool. Although I am more
concerned with the work of the kernel, I discuss this important aspect of filesystem work briefly below.
mk2efsnot only shares the space on a partition between management information and useful data, but
also creates a simple directory structure on the storage medium so that the filesystem can be mounted.

Which management information is meant? When a newly formatted^12 Ext2 partition is mounted,
it already contains a standard subdirectory namedlost+foundto hold defective blocks of the data

(^12) It is, of course, possible to argue about the subtle difference between low-level formatting and filesystem creation and to insist on
a distinction between the two terms. I take a pragmatic approach and use both terms synonymously, as mostUnixusers do, because
there is no danger of confusing the two.

Free download pdf