Page 451 - DCAP103_Principle of operating system
P. 451

Principles of Operating Systems



                   Notes         In order to facilitate certain directory operations and traversals of paths, such as /usr/ast/bin,
                                 VFS supports a dentry data structure which represents a directory entry. This data structure is
                                 created by the file system on the fly. Directory entries are cached in a dentry_ cache. For instance,
                                 the dentry_ cache would contain entries for /, /usr, /usr/ast, etc. If multiple processes access
                                 the same file through the same hard link (i.e., same path) their file object will point to the same
                                 entry in this cache.
                                 Finally, the file data structure is an in-memory representation of an open file, and is created
                                 in response to the open system call. It supports operations such as read, write, sendfile, lock,
                                 and other system calls described in the previous section. The actual file systems implemented
                                 underneath VFS need not use the exact same abstractions and operations internally. They must
                                 however implement semantically equivalent file system operations as the ones specified with
                                 the VFS objects. The elements of the operations data structures for each of the four VFS objects
                                 are pointers to functions in the underlying file system.

                                 14.6.5 Linux Extended File System—Ext2
                                 We next describe the most popular on-disk file system used in Linux — ext2. The first Linux
                                 release used the MINIX file system, and was limited by short filenames and 64 MB file sizes. The
                                 MINIX file system was replaced with the first extended file system, ext, which permitted both
                                 longer file names and larger file sizes. Due to its performance inefficiencies, ext is replaced by
                                 its successor, ext2, which is still in widespread use. An ext2 Linux disk partition contains a file
                                 system with the layout, illustrated in Figure 14.31. Block 0 is not used by Linux and often contains
                                 code to boot the computer. Following block 0, the disk partition is divided into groups of blocks,
                                 without regard to where the disk cylinder boundaries fall each group is organized as follows.

                                 The first block is the superblock. It contains information about the layout of the file system,
                                 including the number of i-nodes, the number of disk blocks, and the start of the list of free
                                 disk blocks (typically a few hundred entries). Next comes the group descriptor, which contains
                                 information about the location of the bitmaps, the number of free blocks and i-nodes in the group
                                 and the number of directories in the group. This information is important since ext2 attempts
                                 to spread directories evenly over the disk.


                                                Figure 14.31: Disk Layout of the Linux ext2 File System















                                 Two bitmaps keep track of the free blocks and free i-nodes, respectively, a choice inherited from
                                 the MINIX 1 file system (and in contrast to most UNIX file systems, which use a free list). Each
                                 map is one block long. With a 1 KB block, this design limits a block group to 8192 blocks and
                                 8192 i-nodes. The former is a real restriction but the latter is not in practice.
                                 Following the superblock are the i-nodes themselves. They are numbered from 1 up to some maximum.
                                 Each i-node is 128 bytes long and describes exactly one file. An i-node contains accounting information
                                 (including all the information returned by stat, which simply takes it from the i-node), as well as
                                 enough information to locate all the disk blocks that hold the file’s data. Following i-nodes are


        444                               LOVELY PROFESSIONAL UNIVERSITY
   446   447   448   449   450   451   452   453   454   455   456