Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


A fourth structure (super_operations) is used for interaction with the superblock (reading, writing, and
allocating inodes). Its values are as follows for the Ext2 filesystem:

fs/ext2/super.c
static struct super_operations ext2_sops = {
.alloc_inode = ext2_alloc_inode,
.destroy_inode = ext2_destroy_inode,
.read_inode = ext2_read_inode,
.write_inode = ext2_write_inode,
.delete_inode = ext2_delete_inode,
.put_super = ext2_put_super,
.write_super = ext2_write_super,
.statfs = ext2_statfs,
.remount_fs = ext2_remount,
.clear_inode = ext2_clear_inode,
.show_options = ext2_show_options,
};

It is neither possible nor does it make sense to discuss the details of all functions listed in the above
structures. Instead, the sections below are restricted to an examination of the most important functions
that illustrate the key mechanisms and principles of the Ext2 implementation. You are encouraged to look
up the remaining functions in the kernel sources: they are not hard to understand with the background
which is provided in the following sections.

Mountingand Unmounting


Recall from Chapter 8 that the kernel requires a further structure to hold mount and unmount informa-
tion when working with filesystems — the information is not provided in any of the structures discussed
above. Thefile_system_typestructure is used for this purpose and is defined as follows for the Second
Extended File System:

fs/ext2/super.c
static struct file_system_type ext2_fs_type = {
.owner = THIS_MODULE,
.name = "ext2",
.get_sb = ext2_get_sb,
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
};

Chapter 8 explained that themountsystem call invokes the function inget_sbto read the superblock
of a filesystem. The Second Extended Filesystem relies on a standard function of the virtual filesystem
(get_sb_bdev)todothis:

fs/ext2/super.c
static int ext2_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
{
return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super, mnt);
}
Free download pdf