Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


struct dquot *i_dquot[MAXQUOTAS];

struct list_head i_devices;
union {
struct pipe_inode_info *i_pipe;
struct block_device *i_bdev;
struct cdev *i_cdev;
};

int i_cindex;

__u32 i_generation;

unsigned long i_state;
unsigned long dirtied_when; /* jiffies of first dirtying */

unsigned int i_flags;

atomic_t i_writecount;
void *i_security;
};

The structure opens with several list heads that are used to manage each inode instance according to
category. We look at the significance of the individual lists below in this section.

Before explaining the meanings of the individual structural members, it is worth remembering that the
inode structure examined here was designed for processingin memoryand therefore includes a few
elements that arenotpresent in the stored inodes. They are created dynamically or generated by the
kernel itself when the information on the low-level filesystem is read in.

There are also filesystems such as FAT and Reiserfs that do not use inodes in the classic sense and must
therefore generate the information shown here by extracting it from the data they themselves contain.

The majority of the elements are dedicated to managing simple status information; for example,i_atime,
i_mtime,andt_ctimestore the time of the lastaccess, the time of the lastmodification, and the time of the
last inodechange.Modificationis taken to mean a change to the data contents associated with the inode.
A change must be made to the inode structure itself (or to an attribute of the file) to bring about a change
toi_ctime.

The file length in bytes is stored ini_size.i_blocksspecifies the value in blocks. The latter value
is a characteristic of the filesystem rather than of the file itself. When many filesystems are created, a
block size can be selected as the minimum unit for storage space allocation on the hardware medium
(the default for the Ext2 filesystem is 4,096 bytes per block, but smaller or larger values may be
chosen — Chapter 9 discusses this in more detail). The file size in blocks could therefore also be
calculated using the information on the filesystem block size and the file size in bytes. This is not done,
but for convenience, the file size is included in the inode structure.

Each VFS inode (for a given filesystem) is identified by a unique number held ini_ino.i_countis a
usage counter to specify how many processes are accessing the same inode structure. (Inodes are used
simultaneously when, for example, a process duplicates itself withfork, as demonstrated in Chapter 2.)
i_nlinkis the counter used to record the total number ofhardlinks that are using the inode.
Free download pdf