Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


spinlock_t s_next_gen_lock;
u32 s_next_generation;
unsigned long s_dir_count;
u8 *s_debts;
struct percpu_counter s_freeblocks_counter;
struct percpu_counter s_freeinodes_counter;
struct percpu_counter s_dirs_counter;
struct blockgroup_lock s_blockgroup_lock;
};

What is interesting in the structure definition is the fact that machine-specific data types can be used in
place of the bit-oriented variants (u32, etc.). This is because it is not necessary to be able to swap different
forms of data representation in memory between machines. Although most elements of the structure are
already familiar from the on-disk superblock, some elements are found only in the RAM variant.


❑ s_mount_optholds the mount options, and the current mount state is saved ins_mount_state.
The following flags are available fors_mount_opt:
<ext2_fs.h>
#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */
#define EXT2_MOUNT_OLDALLOC 0x0002 /* Don’t use the new Orlov
allocator */
#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory’s
group */
#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
#define EXT2_MOUNT_NOBH 0x0100 /* No buffer_heads */
#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
#define EXT2_MOUNT_XATTR_ER 0x4000 /* Extended user attributes */
#define EXT2_MOUNT_POSIX_ACL 0x8000 /* POSIX Access Control Lists */
#define EXT2_MOUNT_XIP 0x010000 /* Execute in place */
#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
#define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */

To check a givenext2_sb_infoinstancesbfor a mount optionopt,themacro
test_opt(sb,opt)is provided. The calling syntax is somewhat unusual: The mount
option is not specified by the pre-processor constant, but only by the part withoutEXT2_MOUNT_.
To check, for instance, if pre-allocation is required or not requires the following code:
test_opt(sb,RESERVATION). Keep this especially in mind whengreping through the kernel
sources, or analyzing them with LXR: Searching forEXT2_MOUNT_RESERVATIONwill only reveal
the definition of the pre-processor symbol, but none of its uses. Searching forRESERVATION
instead delivers the desired hits.
❑ If the superblock is not read from the default block 1, but from some other block (in case the first
one should be damaged), the corresponding (relative) block is stored ins_sb_block.
❑ Thestatfssystem call (and most users as well) is interested in the number of blocks a filesystem
provides. That means the number of blocks that can be used to store data. Unavoidably, some
space needs to be sacrificed for filesystem management data like superblocks or block group
descriptors. Computing the net block number is easy: the kernel just needs to subtract the
Free download pdf