struct super_block {

struct list_head dev_t unsigned long unsigned char unsigned char unsigned long long struct file_system_type struct super_operations unsigned long unsigned long struct dentry struct xattr handler s_list, /

s_blocksize, s_blocksize_bits, s_dirt; s_maxbytes, *s_type; *s_op; s_flags s_magic *s_root **s_xattr;

Keep this first */ search index; _not_ kdev_

struct list_head struct list_head struct list_head struct list_head struct list head s_inodes;

all inodes */ dirty inodes */ parked for writeback */ parked for more writeback */

struct block_device struct list_head

*s_bdev; s_instances;

/* Informational name */ *s_fs_info; /* Filesystem private info */

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


□ s_blocksize and s_blocksize_bits specify 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 for s_blocksize is kilobytes, whereas _bits stores the corresponding log2 value.14

□ s_maxbytes holds the maximum file size that the filesystem can handle and therefore varies from implementation to implementation.

□ s_type points to the file_system_type instance (discussed in Section 8.4.1), which holds general type information on the filesystem.

□ s_root associates 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 that cannot be accessed by normal file commands.

Code that deals with filesystem objects often needs to check if a filesystem is mounted or not, and s_root provides a possibility to do this. If it is null, then the filesystem is a pseudo-filesystem that is only visible within the kernel. Otherwise, the filesystem is visible in userspace.

□ xattr_handler is a pointer to the structure that determines the functions to use for handling extended attributes.

□ s_dev and s_bdev specify 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 the block_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).

The s_dev entry is always supplied with a number (even for virtual filesystems that do not require block devices). In contrast, the s_bdev pointer may also contain a null pointer.

□ s_fs_info is a pointer to private data of the filesystem implementation and is not manipulated by the VFS.

□ s_time_gran specifies the maximal granularity that is possible for the various time stamps supported 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.

14Standard Ext2 filesystems use 1,024 KiB so that s_blocksize holds the value 1024 and s_blocksize_bits the value 10 (because 210 = 1,024).

Two list heads group together inodes and files associated with the superblock.

□ s_dirty is a list head for the list of "dirty" inodes (discussed in Section 8.3.2) used to achieve major speed gains when synchronizing memory contents with the data on the underlying storage medium. Not all inodes need be scanned to write back changes — only those that have been modified and therefore appear in this list. This field must not be confused with s_dirt, which is not a list head, but a simple integer variable. It is set to 1 if the superblock was altered in any way and needs to be written back to disk. Otherwise, it is 0.

□ s_files is a series of file structures listing all opened files of the filesystem represented by the superblock. The kernel references this list when unmounting filesystems. If it still contains files opened for writing, the filesystem is still in use, and the unmount operation fails with an appropriate error message.

The first element of the structure is also a list element called s_list that is used to group together all superblock elements in the system. The list is headed by the global variable super_blocks defined in fs/super.c.

Finally, the individual superblocks are linked in a further list that combines all instances representing filesystems of the same type, regardless of the underlying block devices but with the condition that the filesystem type is the same for all elements. The list head is the fs_supers element of the file_system_type structure discussed in Section 8.4.1. s_instances links the individual elements.

s_op points to a structure with function pointers that, in the familiar VFS manner, provide a generic interface with operations for working with superblocks. The implementation of the operations must be provided by the underlying low-level code of the filesystems.

The structure is defined as follows:

Continue reading here: Info

Was this article helpful?

0 0