Messages in this thread | | | Date | Wed, 3 Feb 1999 18:58:31 +0100 | From | Matthew Wilcox <> | Subject | Re: linux capabilities and ACLs |
| |
I've just written a document which is intended to be distributed as linux/Documentation/filesystems/ext2.txt. I've updated it to deal with this misunderstanding. I'll quote the whole thing here now (as more people are likely to review it); the most up to date version is available from http://pocket.fluff.org/~mrw/linux/ext2.txt
Patches gratefully received in diff -u format. All comments will be read.
The Second Extended Filesystem ==============================
ext2 shares many properties with traditional Unix filesystems. It has the concepts of blocks, inodes and directories. It has space in the specification for Access Control Lists (ACLs), fragments, undeletion and compression though these are not yet implemented (some are available as separate patches). There is also a versioning mechanism to allow new features (such as journalling) to be added in a maximally compatible manner.
Options =======
When mounting an ext2 filesystem, the following options are accepted. Defaults are marked with (*).
bsddf (*) Makes `df' act like BSD. minixdf Makes `df' act like Minix.
check=none, nocheck Perform no checks upon the filesystem. check=normal (*) Perform normal checks on the filesystem. check=strict Perform extra checks on the filesystem.
debug For developers only.
errors=continue (*) Keep going on a filesystem error. errors=remount-ro Remount the filesystem read-only on an error. errors=panic Panic and halt the machine if an error occurs.
grpid, bsdgroups Give objects the same group ID as their parent. nogrpid, sysvgroups (*) New objects have the group ID of their creator.
resuid=n The user which may use the reserved blocks. resgid=n The group which may use the reserved blocks.
sb=n Use alternate superblock at this location.
grpquota,noquota,quota,usrquota Quota options are silently ignored by ext2.
Specification =============
Blocks ------
The space in the device or file is split up into blocks. These are a fixed size, of 1024, 2048 or 4096 bytes which is determined when the filesystem is created. Smaller blocks mean less wasted space per file, but require slightly more accounting overhead. Blocks are clustered into block groups. Each block group has a block usage bitmap and an inode usage bitmap associated with it which shows which blocks and inodes are used.
The Superblock --------------
The superblock contains all the information about the configuration of the filing system. It is stored in block 1 of the filesystem (numbering from 0) and it is essential to mounting it. Since it is so important, backup copies of the superblock are stored at regular intervals throughout the filesystem. It is typically replicated at an interval of 8192 blocks (ie alternative superblocks are at 8193, 16385, 24577, 32769, ...).
The information in the superblock contains fields such as how many inodes and blocks are in the filesystem and how many are unused, how many inodes and blocks are in a block group, when the filesystem was mounted, when it was modified, what version of the filesystem it is (see the Revisions section below) and which OS created it.
If the revision of the filesystem is recent enough then there are extra fields, such as a volume name, a unique identifier, the inode size, support for compression, block preallocation and creating fewer backup superblocks.
Inodes ------
The inode (index node) is the fundamental concept in the ext2 filesystem. Each object in the filesystem is represented by an inode. The inode structure contains pointers to the filesystem blocks which contain the data held in the object and all of the metadata about an object except its name. The metadata about an object includes the permissions, owner, group, flags, size, number of blocks used, access time, creation time, modification time, deletion time, number of links, fragments, version (for NFS) and ACLs.
There are several reserved fields which are currently unused in the inode structure and several which are overloaded. One field is used for the directory ACL if the inode is a directory and for the top 32 bits of the file size if the inode is a regular file. The translator field is unused under Linux, but is used by the HURD to reference the inode of a program which will be used to interpret this object. The HURD also has larger permissions, owner and group fields, so it uses some of the other unused by Linux fields to store the extra bits.
There are pointers to the first 12 blocks which contain the file's data in the inode. There is a pointer to an indirect block (which contains pointers to the next set of blocks), a pointer to a doubly-indirect block (which contains pointers to indirect blocks) and a pointer to a trebly-indirect block (which contains pointers to doubly-indirect blocks).
The flags field contains some ext2-specific flags which aren't catered for by the standard chmod flags. These flags can be listed with lsattr and changed with the chattr command. There are flags for secure deletion, undeletable, compression, synchronous updates, immutability, append-only, dumpable, no-atime, and btree directories.
Directories -----------
A directory is an inode which is formatted in a particular way in order to associate names with inodes. It is formed of records which contain the inode number and the name. Later revisions also encode the type of the object (file, directory, symlink, device, fifo, socket) in the directory entry for speed.
Revisions ---------
The revisioning mechanism used in ext2 is sophisticated. The revisioning mechanism is not supported by version 0 (EXT2_GOOD_OLD_REV) of ext2 but was introduced in version 1. There are three 32-bit fields, one for compatible features, one for read-only compatible features and one for incompatible features.
Reserved Space --------------
In ext2, there is a mechanism for reserving a certain number of blocks for a particular user (normally the super-user). This is intended to allow for the system to continue functioning even if a user fills up all the available space.
Filesystem check ----------------
At boot time, most systems run a consistency check (e2fsck) on their filesystems. The superblock of the ext2 filesystem contains several fields which indicate whether fsck should actually run (since checking the filesystem at boot can take a long time if it is large). fsck will run if the filesystem was not unmounted without errors, if the maximum mount count has been exceeded or if the maximum time between checks has been exceeded.
Metadata --------
It is frequently claimed that the ext2 implementation of writing asynchronous metadata is faster than the ffs synchronous metadata but less reliable. Both methods are equally resolvable by their respective fsck programs.
If you're exceptionally paranoid, there are 3 ways of making metadata writes synchronous:
per-file if you have the source: use the O_SYNC argument to open() per-file if you don't have the source: use chattr +S per-filesystem: mount -o sync
the first and last are not ext2 specific but do force the metadata to be written synchronously.
-- Matthew Wilcox <willy@bofh.ai> "I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science." -- Donald E. Knuth, TAoCP vol 3
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |