Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


struct block_device *s_bdev;
struct list_head s_instances;

char s_id[32]; /* Informational name */
void *s_fs_info; /* Filesystem private info */

/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
};

❑ s_blocksizeands_blocksize_bitsspecify the block size of the filesystem (this is of particular
interest for data organization on hard disk, etc., as discussed in Chapter 9). Basically, the two
variables represent the same information expressed in different ways. The unit fors_blocksize
is kilobytes, whereas_bitsstores the corresponding log2 value.^14
❑ s_maxbytesholds the maximum file size that the filesystem can handle and therefore varies from
implementation to implementation.
❑ s_typepoints to thefile_system_typeinstance (discussed in Section 8.4.1), which holds gen-
eral type information on the filesystem.
❑ s_rootassociates the superblock with the dentry entry of the global root directory as seen by the
filesystem.

Only the superblocks of normally visible filesystems point to the dentry instance of
the/(root) directory. Versions for filesystems that have special functions and do not
appear in the regular directory hierarchy(e.g., pipe or socket filesystems) point to
special entries thatcannotbe accessed by normal file commands.

Code that deals with filesystem objects often needs to check if a filesystem is mounted or not, and
s_rootprovides a possibility to do this. If it isNULL, then the filesystem is a pseudo-filesystem
that is only visible within the kernel. Otherwise, the filesystem is visible in userspace.
❑ xattr_handleris a pointer to the structure that determines the functions to use for handling
extended attributes.
❑ s_devands_bdevspecify the block device on which the data of the underlying filesystem reside.
The former uses the internal kernel number, whereas the latter is a pointer to theblock_device
structure in memory that is used to define device operations and capabilities in more detail
(Chapter 6 takes a closer look at both types).
Thes_deventry is always supplied with a number (even for virtual filesystems that
do not require block devices). In contrast, thes_bdevpointer may also contain a null
pointer.
❑ s_fs_infois a pointer to private data of the filesystem implementation and is not manipulated
by the VFS.
❑ s_time_granspecifies the maximal granularity that is possible for the various time stamps sup-
ported by the filesystem. The value is identical for all time stamps and is given in nanoseconds,
that is, the 10−^9 -th part of a second.

(^14) Standard Ext2 filesystems use 1,024 KiB so thats_blocksizeholds the value 1024 ands_blocksize_bitsthe value 10
(because 210 =1, 024).

Free download pdf