Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


The window needs to be integrated with the other Ext2 data structures. Recall that bothstruct
ext2_inodeandstruct ext2_sb_infocontain fields that point to information about pre-allocation.


fs/ext2/ext2.h
struct ext2_inode_info {
...
struct ext2_block_alloc_info *i_block_alloc_info;
...
}

<ext2_fs_sb.h>
struct ext2_sb_info {
...
spinlock_t s_rsv_window_lock;
struct rb_root s_rsv_window_root;
struct ext2_reserve_window_node s_rsv_window_head;
...
}

The pre-allocation information for each individual inode is contained instruct ext2_block_alloc_info
andstruct ext2_reserve_window_node, which are defined as follows:


<ext2_fs_sb.h>
struct ext2_reserve_window_node {
struct rb_node rsv_node;
__u32 rsv_goal_size;
__u32 rsv_alloc_hit;
struct ext2_reserve_window rsv_window;
};

struct ext2_block_alloc_info {
/* information about reservation window */
struct ext2_reserve_window_node rsv_window_node;

__u32 last_alloc_logical_block;
ext2_fsblk_t last_alloc_physical_block;
};

The data structures are heavily interconnected and embedded within each other, but Figure 9-7 helps to
keep track.


All instances ofext2_reserve_window_nodeare collected in a red-black tree headed by
ext2_sb_info->s_rsv_window_root(refer to Appendix C for more information about such
trees).Thetreenodesareembeddedintoext2_reserve_windowviarsv_node.


The red-black tree allows for sorting the elements by their reservation window borders. This
allows the kernel to quickly find reservations into which a given goal block falls. Additionally,
ext2_reserve_window_nodecontains the following information:


❑ The desired size of the allocation window is given byrsv_goal_size. Note that the ioctl
EXT2_IOC_SETRSVSZcanbeusedtosetthevaluefromuserland,whileEXT2_IOC_GETRESVZ
retrieves the current setting. The maximum allowed reservation window size is
EXT2_MAX_RESERVE_BLOCKS, usually defined to 1,027.
Free download pdf