Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


Whereas each filesystem appears just once infile_system_type,theremaybe
several instances of a superblock for the same filesystem type in the list of
superblock instances because several filesystems of the same type can be stored on
various block devices or partitions. Most systems have, for example, both a root and
a home partition, which may be on different partitions of the hard disk but
normally use the same filesystem type. Only one occurrence of the filesystem type
need appear infile_system_type, but the superblocks for both mounts are
different, although the same filesystem is used in both cases.

An important element of the superblock structure is a list with all modified inodes of the relevant filesys-
tem (the kernel refers to these rather disrespectfully asdirtyinodes). Files and directories that have been
modified are easily identified by reference to this list so that they can be written back to the storage
medium. Writeback must be coordinated and kept to a necessary minimum because it is a very time-
consuming operation (hard disks, floppy disk drives, and other media are very slow as compared to
other system components). On the other hand, it isfatal to write back modified data too infrequently
because a system crash (or, more likely in the case of Linux, a power outage) results in irrecoverable data
loss. The kernel scans the list of dirty blocks at periodic intervals and transfers changes to the underlying
hardware.^5

8.3.2 Inodes


The inode structure of the VFS is as follows:

<fs.h>
struct inode {
struct hlist_node i_hash;
struct list_head i_list;
struct list_head i_sb_list;
struct list_head i_dentry;
unsigned long i_ino;
atomic_t i_count;
unsigned int i_nlink;
uid_t i_uid;
gid_t i_gid;
dev_t i_rdev;
unsigned long i_version;
loff_t i_size;
struct timespec i_atime;
struct timespec i_mtime;
struct timespec i_ctime;
unsigned int i_blkbits;
blkcnt_t i_blocks;
umode_t i_mode;

struct inode_operations *i_op;
const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
struct super_block *i_sb;
struct address_space *i_mapping;
struct address_space i_data;

(^5) There are additional caches between the raw hardware and the kernel, as described in Chapter 6.

Free download pdf