stephen tweedie
stephen w. tweedie associate professor emeritus department of geography oklahoma state university stillwater, oklahoma 74078 - 4073 office: 358 murray hall phone: (405) 744 - 6250 fax: (405) 744 - 5620 e - mail: stephen. tweedie @ urltoken
posted in programming, technology. tags: advantages of ext3, availability, data integrity, easy transition, ext2, ext3, ext3 vs ext2, file systems, journaling, red hat linux, speed, stephen tweedie. leave a comment »
the original presentation of this talk occurred in room a of the ottawa linux symposium, ottawa congress centre, ottawa, ontario, canada on the 20th of july, 2000 at 13: 45 local time. this presentation was given by dr. stephen tweedie .
tweedie & associates consulting engineers can provide our award - winning geothermal heat pump design services for your project. 506 - 383 - 8223
rémy card, laboratoire masi - - institut blaise pascal, e - mail: card @ masi. ibp. fr, and theodore ts' o, massachussets institute of technology, e - mail: tytso @ mit. edu, and stephen tweedie, university of edinburgh, e - mail: sct @ urltoken
r. card, t. y. ts' o, and s. tweedie, '` design and implementation of the second extended filesystem,'' in
stephen tweedie, p. eng. , leed ap, cbcp is the principal of tweedie & associates consulting engineers ltd. (tace) and is a engineer with 31 years of experience. prior to establishing tace, stephen worked as a mechanical design engineer with the province of nova scotia, dept. of government services where he was involved in the design and project supervision of hvac, plumbing, fire protection and medical gas systems in public buildings, including government offices, and hospitals. he later worked as a process engineer with combustion engineering superheater ltd. where he was responsible for supervision of process control and equipment maintenance in nuclear fuel bundle production for candu reactors .
working for dec for two years, stephen worked on vms kernel internals for high - availability clustered filesystems. he is now employed full - time by red hat, which lets him work on linux exclusively .
stephen has been awarded the 1999 ashrae technology award for institutional buildings, for outstanding achievement in energy - efficient building design for the nova institution, a federal women' s correctional facility located in truro, nova scotia .
ext3 is a journaling filesystem developed by stephen tweedie. it is compatible to ext2 filesystems; actually you can look at it as an ext2 filesystem with a journal file. the journaling capability means no more waiting for fsck’s or worrying about metadata corruption. what is most noticeable is that you can switch back and forth between ext2 and ext3 on a partition without any problem: it is just a matter of giving the mount command the right filesystem type .
stephen has been involved with the development of the linux kernel since its early days. his work has been primarily on the filesystem and virtual memory code, with miscellaneous contributions all over the kernel. however he never goes near the network code. his recent and current projects include several high - end features such as raw i / o, fast zero - copy filesystem i / o and high availability .
this paper was first published in the proceedings of the first dutch international symposium on linux, isbn 90 - 367 - 0385 - 9 .
linux is a unix - like operating system, which runs on pc - 386 computers. it was implemented first as extension to the minix operating system
and its first versions included support for the minix filesystem only. the minix filesystem contains two serious limitations: block addresses are stored in 16 bit integers, thus the maximal filesystem size is restricted to 64 mega bytes, and directories contain fixed - size entries and the maximal file name is 14 characters .
we have designed and implemented two new filesystems that are included in the standard linux kernel. these filesystems, called '` extended file system'' (ext fs) and '` second extended file system'' (ext2 fs) raise the limitations and add new features .
in this paper, we describe the history of linux filesystems. we briefly introduce the fundamental concepts implemented in unix filesystems. we present the implementation of the virtual file system layer in linux and we detail the second extended file system kernel code and user mode tools. last, we present performance measurements made on linux and bsd filesystems and we conclude with the current status of ext2fs and the future directions .
in its very early days, linux was cross - developed under the minix operating system. it was easier to share disks between the two systems than to design a new filesystem, so linus torvalds decided to implement support for the minix filesystem in linux. the minix filesystem was an efficient and relatively bug - free piece of software .
however, the restrictions in the design of the minix filesystem were too limiting, so people started thinking and working on the implementation of new filesystems in linux .
in order to ease the addition of new filesystems into the linux kernel, a virtual file system (vfs) layer was developed. the vfs layer was initially written by chris provenzano, and later rewritten by linus torvalds before it was integrated into the linux kernel. it is described in
after the integration of the vfs in the kernel, a new filesystem, called the '` extended file system'' was implemented in april 1992 and added to linux 0. 96c. this new filesystem removed the two big minix limitations: its maximal size was 2 giga bytes and the maximal file name size was 255 characters. it was an improvement over the minix filesystem but some problems were still present in it. there was no support for the separate access, inode modification, and data modification timestamps. the filesystem used linked lists to keep track of free blocks and inodes and this produced bad performances: as the filesystem was used, the lists became unsorted and the filesystem became fragmented .
as a response to these problems, two new filesytems were released in alpha version in january 1993: the xia filesystem and the second extended file system. the xia filesystem was heavily based on the minix filesystem kernel code and only added a few improvements over this filesystem. basically, it provided long file names, support for bigger partitions and support for the three timestamps. on the other hand, ext2fs was based on the extfs code with many reorganizations and many improvements. it had been designed with evolution in mind and contained space for future improvements. it will be described with more details in
when the two new filesystems were first released, they provided essentially the same features. due to its minimal design, xia fs was more stable than ext2fs. as the filesystems were used more widely, bugs were fixed in ext2fs and lots of improvements and new features were integrated. ext2fs is now very stable and has become the de - facto standard linux filesystem .
files are represented by inodes, directories are simply files containing a list of entries and devices can be accessed by requesting i / o on special files .
each file is represented by a structure, called an inode. each inode contains the description of the file: file type, access rights, owners, timestamps, size, pointers to data blocks. the addresses of data blocks allocated to a file are stored in its inode. when a user requests an i / o operation on the file, the kernel code converts the current offset to a block number, uses this number as an index in the block addresses table and reads or writes the physical block. this figure represents the structure of an inode :
directories are structured in a hierarchical tree. each directory can contain files and subdirectories .
directories are implemented as a special type of files. actually, a directory is a file containing a list of entries. each entry contains an inode number and a file name. when a process uses a pathname, the kernel code searchs in the directories to find the corresponding inode number. after the name has been converted to an inode number, the inode is loaded into memory and is used by subsequent requests .
unix filesystems implement the concept of link. several names can be associated with a inode. the inode contains a field containing the number associated with the file. adding a link simply consists in creating a directory entry, where the inode number points to the inode, and in incrementing the links count in the inode. when a link is deleted, i. e. when one uses the
command to remove a filename, the kernel decrements the links count and deallocates the inode if this count becomes zero .
this type of link is called a hard link and can only be used within a single filesystem: it is impossible to create cross - filesystem hard links. moreover, hard links can only point on files: a directory hard link cannot be created to prevent the apparition of a cycle in the directory tree .
another kind of links exists in most unix filesystems. symbolic links are simply files which contain a filename. when the kernel encounters a symbolic link during a pathname to inode conversion, it replaces the name of the link by its contents, i. e. the name of the target file, and restarts the pathname interpretation. since a symbolic link does not point to an inode, it is possible to create cross - filesystems symbolic links. symbolic links can point to any type of file, even on nonexistent files. symbolic links are very useful because they don' t have the limitations associated to hard links. however, they use some disk space, allocated for their inode and their data blocks, and cause an overhead in the pathname to inode conversion because the kernel has to restart the name interpretation when it encounters a symbolic link .
in unix - like operating systems, devices can be accessed via special files. a device special file does not use any space on the filesystem. it is only an access point to the device driver .
two types of special files exist: character and block special files. the former allows i / o operations in character mode while the later requires data to be written in block mode via the buffer cache functions. when an i / o request is made on a special file, it is forwarded to a (pseudo) device driver. a special file is referenced by a major number, which identifies the device type, and a minor number, which identifies the unit .
the linux kernel contains a virtual file system layer which is used during system calls acting on files. the vfs is an indirection layer which handles the file oriented system calls and calls the necessary functions in the physical filesystem code to do the i / o .
when a process issues a file oriented system call, the kernel calls a function contained in the vfs. this function handles the structure independent manipulations and redirects the call to a function contained in the physical filesystem code, which is responsible for handling the structure dependent operations. filesystem code uses the buffer cache functions to request i / o on devices. this scheme is illustrated in this figure :
the vfs defines a set of functions that every filesystem has to implement. this interface is made up of a set of operations associated to three kinds of objects: filesystems, inodes, and open files .
the vfs knows about filesystem types supported in the kernel. it uses a table defined during the kernel configuration. each entry in this table describes a filesystem type: it contains the name of the filesystem type and a pointer on a function called during the mount operation. when a filesystem is to be mounted, the appropriate mount function is called. this function is responsible for reading the superblock from the disk, initializing its internal variables, and returning a mounted filesystem descriptor to the vfs. after the filesystem is mounted, the vfs functions can use this descriptor to access the physical filesystem routines .
a mounted filesystem descriptor contains several kinds of data: informations that are common to every filesystem types, pointers to functions provided by the physical filesystem kernel code, and private data maintained by the physical filesystem code. the function pointers contained in the filesystem descriptors allow the vfs to access the filesystem internal routines .
two other types of descriptors are used by the vfs: an inode descriptor and an open file descriptor. each descriptor contains informations related to files in use and a set of operations provided by the physical filesystem code. while the inode descriptor contains pointers to functions that can be used to act on any file (e. g .
), the file descriptors contains pointer to functions which can only act on open files (e. g .
the second extended file system has been designed and implemented to fix some problems present in the first extended file system. our goal was to provide a powerful filesystem, which implements unix file semantics and offers advanced features .
of course, we wanted to ext2fs to have excellent performance. we also wanted to provide a very robust filesystem in order to reduce the risk of data loss in intensive use. last, but not least, ext2fs had to include provision for extensions to allow users to benefit from new features without reformatting their filesystem .
the ext2fs supports standard unix file types: regular files, directories, device special files and symbolic links .
ext2fs is able to manage filesystems created on really big partitions. while the original kernel code restricted the maximal filesystem size to 2 gb, recent work in the vfs layer have raised this limit to 4 tb. thus, it is now possible to use big disks without the need of creating many partitions .
ext2fs provides long file names. it uses variable length directory entries. the maximal file name size is 255 characters. this limit could be extended to 1012 if needed .
). normally, 5% of the blocks are reserved. this allows the administrator to recover easily from situations where user processes fill up filesystems .
in addition to the standard unix features, ext2fs supports some extensions which are not usually present in unix filesystems .
file attributes allow the users to modify the kernel behavior when acting on a set of files. one can set attributes on a file or on a directory. in the later case, new files created in the directory inherit these attributes .
bsd or system v release 4 semantics can be selected at mount time. a mount option allows the administrator to choose the file creation semantics. on a filesystem mounted with bsd semantics, files are created with the same group id as their parent directory. system v semantics are a bit more complex: if a directory has the setgid bit set, new files inherit the group id of the directory and subdirectories inherit the group id and the setgid bit; in the other case, files and subdirectories are created with the primary group id of the calling process .
bsd - like synchronous updates can be used in ext2fs. a mount option allows the administrator to request that metadata (inodes, bitmap blocks, indirect blocks and directory blocks) be written synchronously on the disk when they are modified. this can be useful to maintain a strict metadata consistency but this leads to poor performances. actually, this feature is not normally used, since in addition to the performance loss associated with using synchronous updates of the metadata, it can cause corruption in the user data which will not be flagged by the filesystem checker .
ext2fs allows the administrator to choose the logical block size when creating the filesystem. block sizes can typically be 1024, 2048 and 4096 bytes. using big block sizes can speed up i / o since fewer i / o requests, and thus fewer disk head seeks, need to be done to access a file. on the other hand, big blocks waste more disk space: on the average, the last block allocated to a file is only half full, so as blocks get bigger, more space is wasted in the last block of each file. in addition, most of the advantages of larger block sizes are obtained by ext2 filesystem' s preallocation techniques (see section
ext2fs implements fast symbolic links. a fast symbolic link does not use any data block on the filesystem. the target name is not stored in a data block but in the inode itself. this policy can save some disk space (no data block needs to be allocated) and speeds up link operations (there is no need to read a data block when accessing such a link). of course, the space available in the inode is limited so not every link can be implemented as a fast symbolic link. the maximal size of the target name in a fast symbolic link is 60 characters. we plan to extend this scheme to small files in the near future .
ext2fs keeps track of the filesystem state. a special field in the superblock is used by the kernel code to indicate the status of the file system. when a filesystem is mounted in read / write mode, its state is set to '` not clean''. when it is unmounted or remounted in read - only mode, its state is reset to '` clean''. at boot time, the filesystem checker uses this information to decide if a filesystem must be checked. the kernel code also records errors in this field. when an inconsistency is detected by the kernel code, the filesystem is marked as '` erroneous''. the filesystem checker tests this to force the check of the filesystem regardless of its apparently clean state .
always skipping filesystem checks may sometimes be dangerous, so ext2fs provides two ways to force checks at regular intervals. a mount counter is maintained in the superblock. each time the filesystem is mounted in read / write mode, this counter is incremented. when it reaches a maximal value (also recorded in the superblock), the filesystem checker forces the check even if the filesystem is '` clean''. a last check time and a maximal check interval are also maintained in the superblock. these two fields allow the administrator to request periodical checks. when the maximal check interval has been reached, the checker ignores the filesystem state and forces a filesystem check. ext2fs offers tools to tune the filesystem behavior. the
the error behavior. when an inconsistency is detected by the kernel code, the filesystem is marked as '` erroneous'' and one of the three following actions can be done: continue normal execution, remount the filesystem in read - only mode to avoid corrupting the filesystem, make the kernel panic and reboot to run the filesystem checker .
an attribute allows the users to request secure deletion on files. when such a file is deleted, random data is written in the disk blocks previously allocated to the file. this prevents malicious people from gaining access to the previous content of the file by using a disk editor .
last, new types of files inspired from the 4. 4 bsd filesystem have recently been added to ext2fs. immutable files can only be read: nobody can write or delete them. this can be used to protect sensitive configuration files. append - only files can be opened in write mode but data is always appended at the end of the file. like immutable files, they cannot be deleted or renamed. this is especially useful for log files which can only grow .
. a filesystem is made up of block groups. block groups are analogous to bsd ffs' s cylinder groups. however, block groups are not tied to the physical layout of the blocks on the disk, since modern drives tend to be optimized for sequential access and hide their physical geometry to the operating system .
each block group contains a redundant copy of crucial filesystem control informations (superblock and the filesystem descriptors) and also contains a part of the filesystem (a block bitmap, an inode bitmap, a piece of the inode table, and data blocks). the structure of a block group is represented in this table :
using block groups is a big win in terms of reliability: since the control structures are replicated in each block group, it is easy to recover from a filesystem where the superblock has been corrupted. this structure also helps to get good performances: by reducing the distance between the inode table and the data blocks, it is possible to reduce the disk head seeks during i / o on files .
in ext2fs, directories are managed as linked lists of variable length entries. each entry contains the inode number, the entry length, the file name and its length. by using variable length entries, it is possible to implement long file names without wasting disk space in directories. the structure of a directory entry is shown in this table :
the ext2fs kernel code contains many performance optimizations, which tend to improve i / o speed when reading and writing files .
ext2fs takes advantage of the buffer cache management by performing readaheads: when a block has to be read, the kernel code requests the i / o on several contiguous blocks. this way, it tries to ensure that the next block to read will already be loaded into the buffer cache. readaheads are normally performed during sequential reads on files and ext2fs extends them to directory reads, either explicit reads (
ext2fs also contains many allocation optimizations. block groups are used to cluster together related inodes and data: the kernel code always tries to allocate data blocks for a file in the same group as its inode. this is intended to reduce the disk head seeks made when the kernel reads an inode and its data blocks .
when writing data to a file, ext2fs preallocates up to 8 adjacent blocks when allocating a new block. preallocation hit rates are around 75% even on very full filesystems. this preallocation achieves good write performances under heavy load. it also allows contiguous blocks to be allocated to files, thus it speeds up the future sequential reads .
to allow user mode programs to manipulate the control structures of an ext2 filesystem, the libext2fs library was developed. this library provides routines which can be used to examine and modify the data of an ext2 filesystem, by accessing the filesystem directly through the physical device .
the ext2fs library was designed to allow maximal code reuse through the use of software abstraction techniques. for example, several different iterators are provided. a program can simply pass in a function to
, which will be called for each block in an inode. another iterator function allows an user - provided function to be called for each file in a directory .
) use the ext2fs library. this greatly simplifies the maintainance of these utilities, since any changes to reflect new features in the ext2 filesystem format need only be made in one place - - in the ext2fs library. this code reuse also results in smaller binaries, since the ext2fs library can be built as a shared library image .
because the interfaces of the ext2fs library are so abstract and general, new programs which require direct access to the ext2fs filesystem can very easily be written. for example, the ext2fs library was used during the port of the 4. 4bsd dump and restore backup utilities. very few changes were needed to adapt these tools to linux: only a few filesystem dependent functions had to be replaced by calls to the ext2fs library .
the ext2fs library provides access to several classes of operations. the first class are the filesystem - oriented operations. a program can open and close a filesystem, read and write the bitmaps, and create a new filesystem on the disk. functions are also available to manipulate the filesystem' s bad blocks list .
the second class of operations affect directories. a caller of the ext2fs library can create and expand directories, as well as add and remove directory entries. functions are also provided to both resolve a pathname to an inode number, and to determine a pathname of an inode given its inode number .
the final class of operations are oriented around inodes. it is possible to scan the inode table, read and write inodes, and scan through all of the blocks in an inode. allocation and deallocation routines are also available and allow user mode programs to allocate and free blocks and inodes .
powerful management tools have been developed for ext2fs. these utilities are used to create, modify, and correct any inconsistencies in ext2 filesystems. the
, it can change the error behavior, the maximal mount count, the maximal check interval, and the number of logical blocks reserved for the super user .
is intended to repair filesystem inconsistencies after an unclean shutdown of the system. the original version of
was based on linus torvald' s fsck program for the minix filesystem. however, the current version of
was rewritten from scratch, using the ext2fs library, and is much faster and can correct more filesystem inconsistencies than the original version .
program is designed to run as quickly as possible. since filesystem checkers tend to be disk bound, this was done by optimizing the algorithms used by
so that filesystem structures are not repeatedly accessed from the disk. in addition, the order in which inodes and directories are checked are sorted by block number to reduce the amount of time in disk seeks. many of these ideas were originally explored by
iterates over all of the inodes in the filesystem and performs checks over each inode as an unconnected object in the filesystem. that is, these checks do not require any cross - checks to other filesystem objects. examples of such checks include making sure the file mode is legal, and that all of the blocks in the inode are valid block numbers. during pass 1, bitmaps indicating which blocks and inodes are in use are compiled .
notices data blocks which are claimed by more than one inode, it invokes passes 1b through 1d to resolve these conflicts, either by cloning the shared blocks so that each inode has its own copy of the shared block, or by deallocating one or more of the inodes .
pass 1 takes the longest time to execute, since all of the inodes have to be read into memory and checked. to reduce the i / o time necessary in future passes, critical filesystem information is cached in memory. the most important example of this technique is the location on disk of all of the directory blocks on the filesystem. this obviates the need to re - read the directory inodes structures during pass 2 to obtain this information .
pass 2 checks directories as unconnected objects. since directory entries do not span disk blocks, each directory block can be checked individually without reference to other directory blocks. this allows
to sort all of the directory blocks by block number, and check directory blocks in ascending order, thus decreasing disk seek time. the directory blocks are checked to make sure that the directory entries are valid, and contain references to inode numbers which are in use (as determined by pass 1) .
for the first directory block in each directory inode, the `.' and `. .' entries are checked to make sure they exist, and that the inode number for the `.' entry matches the current directory. (the inode number for the `. .' entry is not checked until pass 3. )
pass 2 also caches information concerning the parent directory in which each directory is linked. (if a directory is referenced by more than one directory, the second reference of the directory is treated as an illegal hard link, and it is removed) .
needs to perform is complete. information required by passes 3, 4 and 5 are cached in memory; hence, the remaining passes of
traces the path of each directory back to the root, using information that was cached during pass 2. at this time, the `. .' entry for each directory is also checked to make sure it is valid. any directories which cannot be traced back to the root are linked to the
checks the reference counts for all inodes, by iterating over all the inodes and comparing the link counts (which were cached in pass 1) against internal counters computed during passes 2 and 3. any undeleted files with a zero link count is also linked to the
checks the validity of the filesystem summary information. it compares the block and inode bitmaps which were constructed during the previous passes against the actual bitmaps on the filesystem, and corrects the on - disk copies if necessary .
is a powerful program which can be used to examine and change the state of a filesystem. basically, it provides an interactive interface to the ext2fs library: commands typed by the user are translated into calls to the library routines .
. unfortunately, this program can be dangerous if it is used by people who do not know what they are doing; it is very easy to destroy a filesystem with this tool. for this reason ,
opens filesytems for read - only access by default. the user must explicitly specify the
we have run benchmarks to measure filesystem performances. benchmarks have been made on a middle - end pc, based on a i486dx2 processor, using 16 mb of memory and two 420 mb ide disks. the tests were run on ext2 fs and xia fs (linux 1. 1. 62) and on the bsd fast filesystem in asynchronous and synchronous mode (freebsd 2. 0 alpha - - based on the 4. 4bsd lite distribution) .
we have run two different benchmarks. the bonnie benchmark tests i / o speed on a big file - - the file size was set to 60 mb during the tests. it writes data to the file using character based i / o, rewrites the contents of the whole file, writes data using block based i / o, reads the file using character i / o and block i / o, and seeks into the file. the andrew benchmark was developed at carneggie mellon university and has been used at the university of berkeley to benchmark bsd ffs and lfs. it runs in five phases: it creates a directory hierarchy, makes a copy of the data, recursively examine the status of every file, examine every byte of every file, and compile several of the files .
the results are very good in block oriented i / o: ext2 fs outperforms other filesystems. this is clearly a benefit of the optimizations included in the allocation routines. writes are fast because data is written in cluster mode. reads are fast because contiguous blocks have been allocated to the file. thus there is no head seek between two reads and the readahead optimizations can be fully used .
on the other hand, performance is better in the freebsd operating system in character oriented i / o. this is probably due to the fact that freebsd and linux do not use the same stdio routines in their respective c libraries. it seems that freebsd has a more optimized character i / o library and its performance is better .
the results of the two first passes show that linux benefits from its asynchronous metadata i / o. in passes 1 and 2, directories and files are created and bsd synchronously writes inodes and directory entries. there is an anomaly, though: even in asynchronous mode, the performance under bsd is poor. we suspect that the asynchronous support under freebsd is not fully implemented .
in pass 3, the linux and bsd times are very similar. this is a big progress against the same benchmark run six months ago. while bsd used to outperform linux by a factor of 3 in this test, the addition of a file name cache in the vfs has fixed this performance problem .
in passes 4 and 5, linux is faster than freebsd mainly because it uses an unified buffer cache management. the buffer cache space can grow when needed and use more memory than the one in freebsd, which uses a fixed size buffer cache. comparison of the ext2fs and xiafs results shows that the optimizations included in ext2fs are really useful: the performance gain between ext2fs and xiafs is around 5 - 10% .
the second extended file system is probably the most widely used filesystem in the linux community. it provides standard unix file semantics and advanced features. moreover, thanks to the optimizations included in the kernel code, it is robust and offers excellent performance .
since ext2fs has been designed with evolution in mind, it contains hooks that can be used to add new features. some people are working on extensions to the current filesystem: access control lists conforming to the posix semantics
ext2fs was first developed and integrated in the linux kernel and is now actively being ported to other operating systems. an ext2fs server running on top of the gnu hurd has been implemented. people are also working on an ext2fs port in the lites server, running on top of the mach microkernel
, and in the vsta operating system. last, but not least, ext2fs is an important part of the masix operating system
the ext2fs kernel code and tools have been written mostly by the authors of this paper. some other people have also contributed to the development of ext2fs either by suggesting new features or by sending patches. we want to thank these contributors for their help .
m. accetta, r. baron, w. bolosky, d. golub, r. rashid, a. tevanian, and m. young. mach: a new kernel foundation for unix development. in
e. bina and p. emrath. a faster fsck for bsd unix. in
r. card, e. commelin, s. dayras, and f. mével. the masix multi - server operating system. in
s. kleiman. vnodes: an architecture for multiple file system types in sun unix. in
m. mckusick, w. joy, s. leffler, and r. fabry. a fast file system for unix .
m. seltzer, k. bostic, m. mckusick, and c. staelin. an implementation of a log - structured file system for unix. in
thanks to michael johnson for htmlizing it (originally for use in the kernel hacker' s guide) .
the ext2 filesystem was designed with the goal of expandability while maintaining compatibility. this paper describes ways in which advanced filesystem features can be added to the ext2 filesystem while retaining forwards and backwards compatibility as much as possible. some of the filesystem extensions that are discussed include directory indexing, online resizing, an expanded inode, extended attributes and access control lists support, extensible inode tables, extent maps, and preallocation .
] (also known as ext2) was first introduced into the linux kernel in january, 1993. at the time, it was a significant improvement over the previous filesystems used in the 0. 97 and earlier kernels, the minix and the '` extended'' or (ext) filesystem. fundamentally, the design of the ext2 filesystem is very similar to that of the bsd fast filesystem [
which are essentially identical to the ffs' s cylinder group; each block group contains a copy of the superblock, allocation bitmaps, part of a fixed, statically allocated inode table, and data blocks which can be allocated for directories or files. like most classic unix filesystems, ext2 / 3 uses direct, indirect, double indirect, and triple indirection blocks to map logical block numbers to physical block numbers. ext2' s directory format is also essentially identical to traditional unix filesystems in that a simple linked list data structure is used to store directory entries .
over the years, various improvements have been added to the ext2 filesystem. this has been facilitated by a number of superblock fields that were added to the ext2 filesystem just before linux 2. 0 was released. the most important of these fields, the compatibility bitmaps, enable new features to be added to the filesystem safely. there are three such compatibility bitmaps: read - write, read - only, and incompat. a kernel will mount a filesystem that has a bit in the read - write compatibility bitmask that it doesn' t understand. however, an unknown bit in the read - only compatibility bitmap cause the kernel to only be willing to mount the filesystem read - only, and the kernel will refuse to mount in any way a filesystem with an unknown bit in the incompat bitmask. these bitmaps have allowed the ext2 filesystem to evolve in very clean fashion .
today, more developers than ever have expressed interest in working on the ext2 / 3 filesystem, and have wanted to add or integrate various new exciting features. some of these features include: preallocation, journaling, extended attributes and access control lists, on - line resizing, tail - merging, and compression. some of these features have yet to be merged into the mainline ext2 code base, or are only available in prototype form. in the case of the journaling support, although filesystems with journaling support are fully backwards compatible with non - journalled ext2 filesystems, the implementation required enough changes that the resulting filesystem has been named
the goal of this paper is to discuss how these features might be added to the filesystem in a coordinated fashion. many of these new features are expected of modern filesystems; the challenge is to add them while maintaining ext2 / 3' s advantages of a relatively small and simple code base, robustness in the face of i / o errors, and high levels of forwards and backwards compatibility .
we will discuss a number of extensions to the ext2 / 3 filesystem which will likely be implemented in the near future. for the most part, these extensions are independent of each other, and can be implemented in any order, although some extensions have synergistic effects. for example, two new features that will be described below, extent maps and persistent preallocation, are far more effective when used in combination with each other .
]. this replaces the linear directory search algorithm currently in use with traditional ext2 filesystems, and significantly improves performance for very large directories (thousands of files in a single directory) .
the interior, or index, nodes in the tree are formatted to look like deleted directory entries, and the leaf nodes use the same format as existing ext2 directory blocks. as a result, read - only backwards compatibility is trivially achieved. furthermore, starting in the linux 2. 2 kernel, whenever a directory is modified, the
) is cleared. this allows us to guarantee read / write compatibility with linux 2. 2 kernels, since the filesystem can detect that the internal indexing nodes are probably no longer consistent, and thus should be ignored until they can be reconstructed (via the
daniel phillip' s directory indexing code is currently available as a set of patches versus the 2. 4 ext2 code base. as of this writing, the patches still need to be merged with the ext3 journaling code base. in addition, there are plans to select a better hash function that has better distribution characteristics for filenames commonly found in workloads such as mail queue directories. there are also plans to add hinting information in the interior nodes of the tree to indicate that a particular leaf node is nearly empty and that its contents could be merged with an adjacent leaf node .
andreas dilger has implemented patches to the ext2 filesystem that support dynamically increasing the size of the filesystem while the filesystem is on - line. before logical volume managers (lvms) became available for linux, off - line resizing tools such as
first, were sufficient for most users' needs. however, with the advent of lvm systems that allow block devices to be dynamically grown, it is much more important filesystems to be able to grow and take advantage of new storage space which has been made available by the lvm subsystem without needing to unmount the filesystem first. indeed, administrators of enterprise - class systems take such capabilities for granted. (dynamically shrinking mounted filesystems is a much more difficult task, and most filesystems do not offer this functionality. for ext2 / 3 filesystems, filesystems can be shrunk using the off - line resizing tool
a disadvantage of the current ext2 resizing patches is that they require that the filesystem be prepared before the filesystem can be resized on - line. this preparation process, which must be done with the filesystem unmounted, finds the inodes using the blocks immediately following the block group descriptors, and relocates these blocks so they can be reserved for the resizing process. these blocks must be reserved since the current layout of the ext2 superblock and block group descriptors require an additional block group descriptor block for each 256mb, 2gb, or 16gb of disk space for filesystems with 1kb, 2kb, and 4kb blocksizes, respectively. although the requirement for an off - line preparation step is quite inconvenient, this scheme does have the advantage that the filesystem format remains unmodified, so it is fully compatible with kernels that do not support on - line resizing. still, if the system administrator knows in advance how much a filesystem may need to be grown, reserving blocks for use by the block group descriptors may be a workable solution .
requiring advance preparation of the filesystem can be obviated if we are willing to let the filesystem become incompatible with older kernels after it has been extended. given that many 2. 0 and 2. 2 kernels do not support lvm devices (and so would be unable to read a filesystem stored on an lvm anyway), this may be acceptable. the change in the filesystem format replaces the current scheme where the superblock is followed by a variable - length set of block group descriptors. instead, the superblock and a
. a meta - block group is a collection of block groups which can be described by a single block group descriptor block. since the size of the block group descriptor structure is 32 bytes, a meta - block group contains 32 block groups for filesystems with a 1kb block size, and 128 block groups for filesystems with a 4kb blocksize. filesystems can either be created using this new block group descriptor layout, or existing filesystems can be resized on - line, and a new field in the superblock will indicate the first block group using this new layout .
this new scheme is much more efficient, while retaining enough redundancy in case of hardware failures. most importantly, it allows new block groups to be added to the filesystem without needing to change block group descriptors in the earlier parts of the disk. hence, it should be very simple to write an ext2 / 3 filesystem extension using this design that provides on - line resizing capabilities .
the size of the on - disk inode in the ext2 / 3 filesystem has been 128 bytes long during its entire lifetime. although we have been very careful about packing as much information as possible into the inode, we are finally getting to the point where there simply is not enough room for all of the extensions that people would like to add to the ext2 / 3 filesystem .
fortunately, just before the release of linux 2. 0, most of the work to allow for an expanded inode was added. as part of the changes to version 1 of the ext2 superblock, the size of the inode in the filesystem was added as a parameter in the superblock. the only restriction on the size of inode is that it must evenly divide the filesystem blocksize. unfortunately, some safety - checking code which aborted the filesystem from being mounted if the inode size was not 128 bytes was never removed from the kernel. hence, in order to support larger inodes, a small patch will have to made to the 2. 0, 2. 2, and 2. 4 kernels. fortunately the change is simple enough that it should be relatively easy to get the change accepted into production kernels .
one of the most important features that requires additional space in the inode is the addition of sub - second resolution timestamps. this is needed because given today' s very fast computers, storing file modification times with only second granularity is not sufficient for programs like
command will not be able to determine whether or not the library needs to be updated. )
, which limits the number of subdirectories that can be created in a single directory. the actual limit of 32, 000 is smaller than what is possible with an unsigned 16 - bit field, but even if the kernel were changed to allow 65, 535 subdirectories, this would be too small for some users or applications .
in addition, extra inode space can also enable support 64 - bit block numbers. currently, using 4kb blocks, the largest filesystem that ext2 can support is 16tb. although this is larger than any commonly available individual disks, there certainly are raid systems that export block devices which are larger than this size .
] (mac) or audit labels. the nsa se (security - enhanced) linux [
] implementation requires a single 32 - bit field for both purposes; other schemes may require two separate 32 - bit fields to encode mac and audit label .
in order to maximize backwards compatibility, the inode will be expanded without changing the layout of the first 128 bytes. this allows for full backwards compatibility if the the new features in use are themselves backwards compatible - - for example, sub - second resolution timestamps .
doubling the inode size from 128 bytes to 256 bytes gives us room for 32 additional 32 - bit fields, which is a lot of extra flexibility for new features. however, the 32 new fields can be very quickly consumed by designers proposing filesystem extensions. for example, adding support for 64 - bit block pointers will consume almost half of the new fields. hence, allocation of these new inode fields will have to be very carefully done. new filesystem features which do not have general applicability, or which require a large amount of space, will likely
dr. stephen c. tweedie is a software developer who is known for his work on the linux kernel , in particular his work on filesystems . after becoming involved with the development of the ext2 filesystem working on performance issues , he led the development of the ext3 filesystem which involved adding a journaling layer to the ext2 filesystem . for his work on the journaling layer , he has been described by fellow linux developer andrew morton as " a true artisan " . born in edinburgh , scotland in 1969 , tweedie studied computer science at churchill college , cambridge and the university of edinburgh , where he did his thesis on contention and achieved performance in multicomputer wormhole routing networks . after contributing to the linux kernel in his spare time since the early nineties and working on vms filesystem support for dec for two years , tweedie was employed by linux distributor red hat where he continues to work on the linux kernel . tweedie has published a number of papers on linux , including design and implementation of the second extended filesystem in 1994 , journaling the linux ext2fs filesystem in 1998 , and planned extensions to the linux ext2/ext3 filesystem in 2002 . tweedie is also a frequent speaker on the subject of linux kernel development at technical conferences . amongst others , he has given talks on linux kernel development at the 1997 and 1998 usenix annual technical conferences , the 2000 ukuug conference in london , and he gave the keynote speech at the ottawa linux symposium in 2002 . 
dr. stephen c. tweedie is a software developer who is known for his work on the linux kernel, in particular his work on filesystems. after becoming involved with the development of the ext2 filesystem working on performance issues, he led the development of the ext3 filesystem which involved adding a journaling layer to the ext2 filesystem. for his work on the journaling layer, he has been described by fellow linux developer andrew morton as " a true artisan ". born in edinburgh, scotland in 1969, tweedie studied computer science at churchill college, cambridge and the university of edinburgh, where he did his thesis on contention and achieved performance in multicomputer wormhole routing networks. after contributing to the linux kernel in his spare time since the early nineties and working on vms filesystem support for dec for two years, tweedie was employed by linux distributor red hat where he continues to work on the linux kernel. tweedie has published a number of papers on linux, including design and implementation of the second extended filesystem in 1994, journaling the linux ext2fs filesystem in 1998, and planned extensions to the linux ext2/ext3 filesystem in 2002. tweedie is also a frequent speaker on the subject of linux kernel development at technical conferences. amongst others, he has given talks on linux kernel development at the 1997 and 1998 usenix annual technical conferences, the 2000 ukuug conference in london, and he gave the keynote speech at the ottawa linux symposium in 2002.
dr. stephen c. tweedie is a software developer who is known for his work on the linux kernel, in particular his work on filesystems. after becoming involved with the development of the ext2 filesystem working on performance issues, he led the development of the ext3 filesystem which involved adding a journaling layer to the ext2 filesystem. for his work on the journaling layer, he has been described by fellow linux developer andrew morton as " a true artisan ". born in edinburgh, scotland in 1969, tweedie studied computer science at churchill college, cambridge and the university of edinburgh, where he did his thesis on contention and achieved performance in multicomputer wormhole routing networks. after contributing to the linux kernel in his spare time since the early nineties and working on vms filesystem support for dec for two years, tweedie was employed by linux distributor red hat where he continues to work on the linux kernel. tweedie has published a number of papers on linux, including design and implementation of the second extended filesystem in 1994, journaling the linux ext2fs filesystem in 1998, and planned extensions to the linux ext2/ext3 filesystem in 2002. tweedie is also a frequent speaker on the subject of linux kernel development at technical conferences. amongst others, he has given talks on linux kernel development at the 1997 and 1998 usenix annual technical conferences, the 2000 ukuug conference in london, and he gave the keynote speech at the ottawa linux symposium in 2002.