diff options
| -rw-r--r-- | fs/ext2/ext2.h | 631 | ||||
| -rw-r--r-- | fs/ext2/xattr_security.c | 5 | ||||
| -rw-r--r-- | fs/ext2/xattr_trusted.c | 5 | ||||
| -rw-r--r-- | fs/ext2/xip.c | 2 | ||||
| -rw-r--r-- | include/linux/ext2_fs.h | 521 | ||||
| -rw-r--r-- | include/linux/ext2_fs_sb.h | 126 |
6 files changed, 634 insertions, 656 deletions
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 75ad433c6691..0b2b4db5bdcd 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
| @@ -1,5 +1,636 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 1992, 1993, 1994, 1995 | ||
| 3 | * Remy Card (card@masi.ibp.fr) | ||
| 4 | * Laboratoire MASI - Institut Blaise Pascal | ||
| 5 | * Universite Pierre et Marie Curie (Paris VI) | ||
| 6 | * | ||
| 7 | * from | ||
| 8 | * | ||
| 9 | * linux/include/linux/minix_fs.h | ||
| 10 | * | ||
| 11 | * Copyright (C) 1991, 1992 Linus Torvalds | ||
| 12 | */ | ||
| 1 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
| 2 | #include <linux/ext2_fs.h> | 14 | #include <linux/ext2_fs.h> |
| 15 | #include <linux/blockgroup_lock.h> | ||
| 16 | #include <linux/percpu_counter.h> | ||
| 17 | #include <linux/rbtree.h> | ||
| 18 | |||
| 19 | /* XXX Here for now... not interested in restructing headers JUST now */ | ||
| 20 | |||
| 21 | /* data type for block offset of block group */ | ||
| 22 | typedef int ext2_grpblk_t; | ||
| 23 | |||
| 24 | /* data type for filesystem-wide blocks number */ | ||
| 25 | typedef unsigned long ext2_fsblk_t; | ||
| 26 | |||
| 27 | #define E2FSBLK "%lu" | ||
| 28 | |||
| 29 | struct ext2_reserve_window { | ||
| 30 | ext2_fsblk_t _rsv_start; /* First byte reserved */ | ||
| 31 | ext2_fsblk_t _rsv_end; /* Last byte reserved or 0 */ | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct ext2_reserve_window_node { | ||
| 35 | struct rb_node rsv_node; | ||
| 36 | __u32 rsv_goal_size; | ||
| 37 | __u32 rsv_alloc_hit; | ||
| 38 | struct ext2_reserve_window rsv_window; | ||
| 39 | }; | ||
| 40 | |||
| 41 | struct ext2_block_alloc_info { | ||
| 42 | /* information about reservation window */ | ||
| 43 | struct ext2_reserve_window_node rsv_window_node; | ||
| 44 | /* | ||
| 45 | * was i_next_alloc_block in ext2_inode_info | ||
| 46 | * is the logical (file-relative) number of the | ||
| 47 | * most-recently-allocated block in this file. | ||
| 48 | * We use this for detecting linearly ascending allocation requests. | ||
| 49 | */ | ||
| 50 | __u32 last_alloc_logical_block; | ||
| 51 | /* | ||
| 52 | * Was i_next_alloc_goal in ext2_inode_info | ||
| 53 | * is the *physical* companion to i_next_alloc_block. | ||
| 54 | * it the the physical block number of the block which was most-recentl | ||
| 55 | * allocated to this file. This give us the goal (target) for the next | ||
| 56 | * allocation when we detect linearly ascending requests. | ||
| 57 | */ | ||
| 58 | ext2_fsblk_t last_alloc_physical_block; | ||
| 59 | }; | ||
| 60 | |||
| 61 | #define rsv_start rsv_window._rsv_start | ||
| 62 | #define rsv_end rsv_window._rsv_end | ||
| 63 | |||
| 64 | /* | ||
| 65 | * second extended-fs super-block data in memory | ||
| 66 | */ | ||
| 67 | struct ext2_sb_info { | ||
| 68 | unsigned long s_frag_size; /* Size of a fragment in bytes */ | ||
| 69 | unsigned long s_frags_per_block;/* Number of fragments per block */ | ||
| 70 | unsigned long s_inodes_per_block;/* Number of inodes per block */ | ||
| 71 | unsigned long s_frags_per_group;/* Number of fragments in a group */ | ||
| 72 | unsigned long s_blocks_per_group;/* Number of blocks in a group */ | ||
| 73 | unsigned long s_inodes_per_group;/* Number of inodes in a group */ | ||
| 74 | unsigned long s_itb_per_group; /* Number of inode table blocks per group */ | ||
| 75 | unsigned long s_gdb_count; /* Number of group descriptor blocks */ | ||
| 76 | unsigned long s_desc_per_block; /* Number of group descriptors per block */ | ||
| 77 | unsigned long s_groups_count; /* Number of groups in the fs */ | ||
| 78 | unsigned long s_overhead_last; /* Last calculated overhead */ | ||
| 79 | unsigned long s_blocks_last; /* Last seen block count */ | ||
| 80 | struct buffer_head * s_sbh; /* Buffer containing the super block */ | ||
| 81 | struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */ | ||
| 82 | struct buffer_head ** s_group_desc; | ||
| 83 | unsigned long s_mount_opt; | ||
| 84 | unsigned long s_sb_block; | ||
| 85 | uid_t s_resuid; | ||
| 86 | gid_t s_resgid; | ||
| 87 | unsigned short s_mount_state; | ||
| 88 | unsigned short s_pad; | ||
| 89 | int s_addr_per_block_bits; | ||
| 90 | int s_desc_per_block_bits; | ||
| 91 | int s_inode_size; | ||
| 92 | int s_first_ino; | ||
| 93 | spinlock_t s_next_gen_lock; | ||
| 94 | u32 s_next_generation; | ||
| 95 | unsigned long s_dir_count; | ||
| 96 | u8 *s_debts; | ||
| 97 | struct percpu_counter s_freeblocks_counter; | ||
| 98 | struct percpu_counter s_freeinodes_counter; | ||
| 99 | struct percpu_counter s_dirs_counter; | ||
| 100 | struct blockgroup_lock *s_blockgroup_lock; | ||
| 101 | /* root of the per fs reservation window tree */ | ||
| 102 | spinlock_t s_rsv_window_lock; | ||
| 103 | struct rb_root s_rsv_window_root; | ||
| 104 | struct ext2_reserve_window_node s_rsv_window_head; | ||
| 105 | /* | ||
| 106 | * s_lock protects against concurrent modifications of s_mount_state, | ||
| 107 | * s_blocks_last, s_overhead_last and the content of superblock's | ||
| 108 | * buffer pointed to by sbi->s_es. | ||
| 109 | * | ||
| 110 | * Note: It is used in ext2_show_options() to provide a consistent view | ||
| 111 | * of the mount options. | ||
| 112 | */ | ||
| 113 | spinlock_t s_lock; | ||
| 114 | }; | ||
| 115 | |||
| 116 | static inline spinlock_t * | ||
| 117 | sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group) | ||
| 118 | { | ||
| 119 | return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group); | ||
| 120 | } | ||
| 121 | |||
| 122 | /* | ||
| 123 | * Define EXT2FS_DEBUG to produce debug messages | ||
| 124 | */ | ||
| 125 | #undef EXT2FS_DEBUG | ||
| 126 | |||
| 127 | /* | ||
| 128 | * Define EXT2_RESERVATION to reserve data blocks for expanding files | ||
| 129 | */ | ||
| 130 | #define EXT2_DEFAULT_RESERVE_BLOCKS 8 | ||
| 131 | /*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */ | ||
| 132 | #define EXT2_MAX_RESERVE_BLOCKS 1027 | ||
| 133 | #define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0 | ||
| 134 | /* | ||
| 135 | * The second extended file system version | ||
| 136 | */ | ||
| 137 | #define EXT2FS_DATE "95/08/09" | ||
| 138 | #define EXT2FS_VERSION "0.5b" | ||
| 139 | |||
| 140 | /* | ||
| 141 | * Debug code | ||
| 142 | */ | ||
| 143 | #ifdef EXT2FS_DEBUG | ||
| 144 | # define ext2_debug(f, a...) { \ | ||
| 145 | printk ("EXT2-fs DEBUG (%s, %d): %s:", \ | ||
| 146 | __FILE__, __LINE__, __func__); \ | ||
| 147 | printk (f, ## a); \ | ||
| 148 | } | ||
| 149 | #else | ||
| 150 | # define ext2_debug(f, a...) /**/ | ||
| 151 | #endif | ||
| 152 | |||
| 153 | /* | ||
| 154 | * Special inode numbers | ||
| 155 | */ | ||
| 156 | #define EXT2_BAD_INO 1 /* Bad blocks inode */ | ||
| 157 | #define EXT2_ROOT_INO 2 /* Root inode */ | ||
| 158 | #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ | ||
| 159 | #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ | ||
| 160 | |||
| 161 | /* First non-reserved inode for old ext2 filesystems */ | ||
| 162 | #define EXT2_GOOD_OLD_FIRST_INO 11 | ||
| 163 | |||
| 164 | static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb) | ||
| 165 | { | ||
| 166 | return sb->s_fs_info; | ||
| 167 | } | ||
| 168 | |||
| 169 | /* | ||
| 170 | * Macro-instructions used to manage several block sizes | ||
| 171 | */ | ||
| 172 | #define EXT2_MIN_BLOCK_SIZE 1024 | ||
| 173 | #define EXT2_MAX_BLOCK_SIZE 4096 | ||
| 174 | #define EXT2_MIN_BLOCK_LOG_SIZE 10 | ||
| 175 | #define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) | ||
| 176 | #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32)) | ||
| 177 | #define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) | ||
| 178 | #define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_addr_per_block_bits) | ||
| 179 | #define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size) | ||
| 180 | #define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino) | ||
| 181 | |||
| 182 | /* | ||
| 183 | * Macro-instructions used to manage fragments | ||
| 184 | */ | ||
| 185 | #define EXT2_MIN_FRAG_SIZE 1024 | ||
| 186 | #define EXT2_MAX_FRAG_SIZE 4096 | ||
| 187 | #define EXT2_MIN_FRAG_LOG_SIZE 10 | ||
| 188 | #define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size) | ||
| 189 | #define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block) | ||
| 190 | |||
| 191 | /* | ||
| 192 | * Structure of a blocks group descriptor | ||
| 193 | */ | ||
| 194 | struct ext2_group_desc | ||
| 195 | { | ||
| 196 | __le32 bg_block_bitmap; /* Blocks bitmap block */ | ||
| 197 | __le32 bg_inode_bitmap; /* Inodes bitmap block */ | ||
| 198 | __le32 bg_inode_table; /* Inodes table block */ | ||
| 199 | __le16 bg_free_blocks_count; /* Free blocks count */ | ||
| 200 | __le16 bg_free_inodes_count; /* Free inodes count */ | ||
| 201 | __le16 bg_used_dirs_count; /* Directories count */ | ||
| 202 | __le16 b | ||
