Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/fs.h> |
| 14 | #include <linux/ext2_fs.h> |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 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 | |
Jan Kara | 7a2508e | 2016-02-22 22:35:22 -0500 | [diff] [blame] | 64 | struct mb_cache; |
Jan Kara | be0726d | 2016-02-22 11:56:38 -0500 | [diff] [blame] | 65 | |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 66 | /* |
| 67 | * second extended-fs super-block data in memory |
| 68 | */ |
| 69 | struct ext2_sb_info { |
| 70 | unsigned long s_frag_size; /* Size of a fragment in bytes */ |
| 71 | unsigned long s_frags_per_block;/* Number of fragments per block */ |
| 72 | unsigned long s_inodes_per_block;/* Number of inodes per block */ |
| 73 | unsigned long s_frags_per_group;/* Number of fragments in a group */ |
| 74 | unsigned long s_blocks_per_group;/* Number of blocks in a group */ |
| 75 | unsigned long s_inodes_per_group;/* Number of inodes in a group */ |
| 76 | unsigned long s_itb_per_group; /* Number of inode table blocks per group */ |
| 77 | unsigned long s_gdb_count; /* Number of group descriptor blocks */ |
| 78 | unsigned long s_desc_per_block; /* Number of group descriptors per block */ |
| 79 | unsigned long s_groups_count; /* Number of groups in the fs */ |
| 80 | unsigned long s_overhead_last; /* Last calculated overhead */ |
| 81 | unsigned long s_blocks_last; /* Last seen block count */ |
| 82 | struct buffer_head * s_sbh; /* Buffer containing the super block */ |
| 83 | struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */ |
| 84 | struct buffer_head ** s_group_desc; |
| 85 | unsigned long s_mount_opt; |
| 86 | unsigned long s_sb_block; |
Eric W. Biederman | b8a9f9e | 2012-02-07 15:39:12 -0800 | [diff] [blame] | 87 | kuid_t s_resuid; |
| 88 | kgid_t s_resgid; |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 89 | unsigned short s_mount_state; |
| 90 | unsigned short s_pad; |
| 91 | int s_addr_per_block_bits; |
| 92 | int s_desc_per_block_bits; |
| 93 | int s_inode_size; |
| 94 | int s_first_ino; |
| 95 | spinlock_t s_next_gen_lock; |
| 96 | u32 s_next_generation; |
| 97 | unsigned long s_dir_count; |
| 98 | u8 *s_debts; |
| 99 | struct percpu_counter s_freeblocks_counter; |
| 100 | struct percpu_counter s_freeinodes_counter; |
| 101 | struct percpu_counter s_dirs_counter; |
| 102 | struct blockgroup_lock *s_blockgroup_lock; |
| 103 | /* root of the per fs reservation window tree */ |
| 104 | spinlock_t s_rsv_window_lock; |
| 105 | struct rb_root s_rsv_window_root; |
| 106 | struct ext2_reserve_window_node s_rsv_window_head; |
| 107 | /* |
| 108 | * s_lock protects against concurrent modifications of s_mount_state, |
| 109 | * s_blocks_last, s_overhead_last and the content of superblock's |
| 110 | * buffer pointed to by sbi->s_es. |
| 111 | * |
| 112 | * Note: It is used in ext2_show_options() to provide a consistent view |
| 113 | * of the mount options. |
| 114 | */ |
| 115 | spinlock_t s_lock; |
Jan Kara | 7a2508e | 2016-02-22 22:35:22 -0500 | [diff] [blame] | 116 | struct mb_cache *s_mb_cache; |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | static inline spinlock_t * |
| 120 | sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group) |
| 121 | { |
| 122 | return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group); |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | * Define EXT2FS_DEBUG to produce debug messages |
| 127 | */ |
| 128 | #undef EXT2FS_DEBUG |
| 129 | |
| 130 | /* |
| 131 | * Define EXT2_RESERVATION to reserve data blocks for expanding files |
| 132 | */ |
| 133 | #define EXT2_DEFAULT_RESERVE_BLOCKS 8 |
| 134 | /*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */ |
| 135 | #define EXT2_MAX_RESERVE_BLOCKS 1027 |
| 136 | #define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0 |
| 137 | /* |
| 138 | * The second extended file system version |
| 139 | */ |
| 140 | #define EXT2FS_DATE "95/08/09" |
| 141 | #define EXT2FS_VERSION "0.5b" |
| 142 | |
| 143 | /* |
| 144 | * Debug code |
| 145 | */ |
| 146 | #ifdef EXT2FS_DEBUG |
| 147 | # define ext2_debug(f, a...) { \ |
| 148 | printk ("EXT2-fs DEBUG (%s, %d): %s:", \ |
| 149 | __FILE__, __LINE__, __func__); \ |
| 150 | printk (f, ## a); \ |
| 151 | } |
| 152 | #else |
| 153 | # define ext2_debug(f, a...) /**/ |
| 154 | #endif |
| 155 | |
| 156 | /* |
| 157 | * Special inode numbers |
| 158 | */ |
| 159 | #define EXT2_BAD_INO 1 /* Bad blocks inode */ |
| 160 | #define EXT2_ROOT_INO 2 /* Root inode */ |
| 161 | #define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ |
| 162 | #define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ |
| 163 | |
| 164 | /* First non-reserved inode for old ext2 filesystems */ |
| 165 | #define EXT2_GOOD_OLD_FIRST_INO 11 |
| 166 | |
| 167 | static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb) |
| 168 | { |
| 169 | return sb->s_fs_info; |
| 170 | } |
| 171 | |
| 172 | /* |
| 173 | * Macro-instructions used to manage several block sizes |
| 174 | */ |
| 175 | #define EXT2_MIN_BLOCK_SIZE 1024 |
| 176 | #define EXT2_MAX_BLOCK_SIZE 4096 |
| 177 | #define EXT2_MIN_BLOCK_LOG_SIZE 10 |
| 178 | #define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) |
| 179 | #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32)) |
| 180 | #define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) |
| 181 | #define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_addr_per_block_bits) |
| 182 | #define EXT2_INODE_SIZE(s) (EXT2_SB(s)->s_inode_size) |
| 183 | #define EXT2_FIRST_INO(s) (EXT2_SB(s)->s_first_ino) |
| 184 | |
| 185 | /* |
| 186 | * Macro-instructions used to manage fragments |
| 187 | */ |
| 188 | #define EXT2_MIN_FRAG_SIZE 1024 |
| 189 | #define EXT2_MAX_FRAG_SIZE 4096 |
| 190 | #define EXT2_MIN_FRAG_LOG_SIZE 10 |
| 191 | #define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size) |
| 192 | #define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block) |
| 193 | |
| 194 | /* |
| 195 | * Structure of a blocks group descriptor |
| 196 | */ |
| 197 | struct ext2_group_desc |
| 198 | { |
| 199 | __le32 bg_block_bitmap; /* Blocks bitmap block */ |
| 200 | __le32 bg_inode_bitmap; /* Inodes bitmap block */ |
| 201 | __le32 bg_inode_table; /* Inodes table block */ |
| 202 | __le16 bg_free_blocks_count; /* Free blocks count */ |
| 203 | __le16 bg_free_inodes_count; /* Free inodes count */ |
| 204 | __le16 bg_used_dirs_count; /* Directories count */ |
| 205 | __le16 bg_pad; |
| 206 | __le32 bg_reserved[3]; |
| 207 | }; |
| 208 | |
| 209 | /* |
| 210 | * Macro-instructions used to manage group descriptors |
| 211 | */ |
| 212 | #define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) |
| 213 | #define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->s_desc_per_block) |
| 214 | #define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) |
| 215 | #define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits) |
| 216 | |
| 217 | /* |
| 218 | * Constants relative to the data blocks |
| 219 | */ |
| 220 | #define EXT2_NDIR_BLOCKS 12 |
| 221 | #define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS |
| 222 | #define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) |
| 223 | #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) |
| 224 | #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) |
| 225 | |
| 226 | /* |
| 227 | * Inode flags (GETFLAGS/SETFLAGS) |
| 228 | */ |
| 229 | #define EXT2_SECRM_FL FS_SECRM_FL /* Secure deletion */ |
| 230 | #define EXT2_UNRM_FL FS_UNRM_FL /* Undelete */ |
| 231 | #define EXT2_COMPR_FL FS_COMPR_FL /* Compress file */ |
| 232 | #define EXT2_SYNC_FL FS_SYNC_FL /* Synchronous updates */ |
| 233 | #define EXT2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */ |
| 234 | #define EXT2_APPEND_FL FS_APPEND_FL /* writes to file may only append */ |
| 235 | #define EXT2_NODUMP_FL FS_NODUMP_FL /* do not dump file */ |
| 236 | #define EXT2_NOATIME_FL FS_NOATIME_FL /* do not update atime */ |
| 237 | /* Reserved for compression usage... */ |
| 238 | #define EXT2_DIRTY_FL FS_DIRTY_FL |
| 239 | #define EXT2_COMPRBLK_FL FS_COMPRBLK_FL /* One or more compressed clusters */ |
| 240 | #define EXT2_NOCOMP_FL FS_NOCOMP_FL /* Don't compress */ |
| 241 | #define EXT2_ECOMPR_FL FS_ECOMPR_FL /* Compression error */ |
| 242 | /* End compression flags --- maybe not all used */ |
| 243 | #define EXT2_BTREE_FL FS_BTREE_FL /* btree format dir */ |
| 244 | #define EXT2_INDEX_FL FS_INDEX_FL /* hash-indexed directory */ |
| 245 | #define EXT2_IMAGIC_FL FS_IMAGIC_FL /* AFS directory */ |
| 246 | #define EXT2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL /* Reserved for ext3 */ |
| 247 | #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */ |
| 248 | #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */ |
| 249 | #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/ |
| 250 | #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */ |
| 251 | |
| 252 | #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */ |
| 253 | #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */ |
| 254 | |
| 255 | /* Flags that should be inherited by new inodes from their parent. */ |
| 256 | #define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\ |
| 257 | EXT2_SYNC_FL | EXT2_NODUMP_FL |\ |
| 258 | EXT2_NOATIME_FL | EXT2_COMPRBLK_FL |\ |
| 259 | EXT2_NOCOMP_FL | EXT2_JOURNAL_DATA_FL |\ |
| 260 | EXT2_NOTAIL_FL | EXT2_DIRSYNC_FL) |
| 261 | |
| 262 | /* Flags that are appropriate for regular files (all but dir-specific ones). */ |
| 263 | #define EXT2_REG_FLMASK (~(EXT2_DIRSYNC_FL | EXT2_TOPDIR_FL)) |
| 264 | |
| 265 | /* Flags that are appropriate for non-directories/regular files. */ |
| 266 | #define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL) |
| 267 | |
| 268 | /* Mask out flags that are inappropriate for the given type of inode. */ |
| 269 | static inline __u32 ext2_mask_flags(umode_t mode, __u32 flags) |
| 270 | { |
| 271 | if (S_ISDIR(mode)) |
| 272 | return flags; |
| 273 | else if (S_ISREG(mode)) |
| 274 | return flags & EXT2_REG_FLMASK; |
| 275 | else |
| 276 | return flags & EXT2_OTHER_FLMASK; |
| 277 | } |
| 278 | |
| 279 | /* |
| 280 | * ioctl commands |
| 281 | */ |
| 282 | #define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS |
| 283 | #define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS |
| 284 | #define EXT2_IOC_GETVERSION FS_IOC_GETVERSION |
| 285 | #define EXT2_IOC_SETVERSION FS_IOC_SETVERSION |
| 286 | #define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) |
| 287 | #define EXT2_IOC_SETRSVSZ _IOW('f', 6, long) |
| 288 | |
| 289 | /* |
| 290 | * ioctl commands in 32 bit emulation |
| 291 | */ |
| 292 | #define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS |
| 293 | #define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS |
| 294 | #define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION |
| 295 | #define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION |
| 296 | |
| 297 | /* |
| 298 | * Structure of an inode on the disk |
| 299 | */ |
| 300 | struct ext2_inode { |
| 301 | __le16 i_mode; /* File mode */ |
| 302 | __le16 i_uid; /* Low 16 bits of Owner Uid */ |
| 303 | __le32 i_size; /* Size in bytes */ |
| 304 | __le32 i_atime; /* Access time */ |
| 305 | __le32 i_ctime; /* Creation time */ |
| 306 | __le32 i_mtime; /* Modification time */ |
| 307 | __le32 i_dtime; /* Deletion Time */ |
| 308 | __le16 i_gid; /* Low 16 bits of Group Id */ |
| 309 | __le16 i_links_count; /* Links count */ |
| 310 | __le32 i_blocks; /* Blocks count */ |
| 311 | __le32 i_flags; /* File flags */ |
| 312 | union { |
| 313 | struct { |
| 314 | __le32 l_i_reserved1; |
| 315 | } linux1; |
| 316 | struct { |
| 317 | __le32 h_i_translator; |
| 318 | } hurd1; |
| 319 | struct { |
| 320 | __le32 m_i_reserved1; |
| 321 | } masix1; |
| 322 | } osd1; /* OS dependent 1 */ |
| 323 | __le32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ |
| 324 | __le32 i_generation; /* File version (for NFS) */ |
| 325 | __le32 i_file_acl; /* File ACL */ |
| 326 | __le32 i_dir_acl; /* Directory ACL */ |
| 327 | __le32 i_faddr; /* Fragment address */ |
| 328 | union { |
| 329 | struct { |
| 330 | __u8 l_i_frag; /* Fragment number */ |
| 331 | __u8 l_i_fsize; /* Fragment size */ |
| 332 | __u16 i_pad1; |
| 333 | __le16 l_i_uid_high; /* these 2 fields */ |
| 334 | __le16 l_i_gid_high; /* were reserved2[0] */ |
| 335 | __u32 l_i_reserved2; |
| 336 | } linux2; |
| 337 | struct { |
| 338 | __u8 h_i_frag; /* Fragment number */ |
| 339 | __u8 h_i_fsize; /* Fragment size */ |
| 340 | __le16 h_i_mode_high; |
| 341 | __le16 h_i_uid_high; |
| 342 | __le16 h_i_gid_high; |
| 343 | __le32 h_i_author; |
| 344 | } hurd2; |
| 345 | struct { |
| 346 | __u8 m_i_frag; /* Fragment number */ |
| 347 | __u8 m_i_fsize; /* Fragment size */ |
| 348 | __u16 m_pad1; |
| 349 | __u32 m_i_reserved2[2]; |
| 350 | } masix2; |
| 351 | } osd2; /* OS dependent 2 */ |
| 352 | }; |
| 353 | |
| 354 | #define i_size_high i_dir_acl |
| 355 | |
| 356 | #define i_reserved1 osd1.linux1.l_i_reserved1 |
| 357 | #define i_frag osd2.linux2.l_i_frag |
| 358 | #define i_fsize osd2.linux2.l_i_fsize |
| 359 | #define i_uid_low i_uid |
| 360 | #define i_gid_low i_gid |
| 361 | #define i_uid_high osd2.linux2.l_i_uid_high |
| 362 | #define i_gid_high osd2.linux2.l_i_gid_high |
| 363 | #define i_reserved2 osd2.linux2.l_i_reserved2 |
| 364 | |
| 365 | /* |
| 366 | * File system states |
| 367 | */ |
| 368 | #define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ |
| 369 | #define EXT2_ERROR_FS 0x0002 /* Errors detected */ |
Carlos Maiolino | ff0031d | 2016-07-05 22:02:41 -0400 | [diff] [blame] | 370 | #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 371 | |
| 372 | /* |
| 373 | * Mount flags |
| 374 | */ |
| 375 | #define EXT2_MOUNT_CHECK 0x000001 /* Do mount-time checks */ |
| 376 | #define EXT2_MOUNT_OLDALLOC 0x000002 /* Don't use the new Orlov allocator */ |
| 377 | #define EXT2_MOUNT_GRPID 0x000004 /* Create files with directory's group */ |
| 378 | #define EXT2_MOUNT_DEBUG 0x000008 /* Some debugging messages */ |
| 379 | #define EXT2_MOUNT_ERRORS_CONT 0x000010 /* Continue on errors */ |
| 380 | #define EXT2_MOUNT_ERRORS_RO 0x000020 /* Remount fs ro on errors */ |
| 381 | #define EXT2_MOUNT_ERRORS_PANIC 0x000040 /* Panic on errors */ |
| 382 | #define EXT2_MOUNT_MINIX_DF 0x000080 /* Mimics the Minix statfs */ |
| 383 | #define EXT2_MOUNT_NOBH 0x000100 /* No buffer_heads */ |
| 384 | #define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */ |
| 385 | #define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */ |
| 386 | #define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */ |
Matthew Wilcox | 9c3ce9e | 2015-02-16 15:59:31 -0800 | [diff] [blame] | 387 | #define EXT2_MOUNT_XIP 0x010000 /* Obsolete, use DAX */ |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 388 | #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */ |
| 389 | #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */ |
| 390 | #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */ |
Matthew Wilcox | 9c3ce9e | 2015-02-16 15:59:31 -0800 | [diff] [blame] | 391 | #ifdef CONFIG_FS_DAX |
| 392 | #define EXT2_MOUNT_DAX 0x100000 /* Direct Access */ |
| 393 | #else |
| 394 | #define EXT2_MOUNT_DAX 0 |
| 395 | #endif |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 396 | |
| 397 | |
| 398 | #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt |
| 399 | #define set_opt(o, opt) o |= EXT2_MOUNT_##opt |
| 400 | #define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ |
| 401 | EXT2_MOUNT_##opt) |
| 402 | /* |
| 403 | * Maximal mount counts between two filesystem checks |
| 404 | */ |
| 405 | #define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ |
| 406 | #define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ |
| 407 | |
| 408 | /* |
| 409 | * Behaviour when detecting errors |
| 410 | */ |
| 411 | #define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ |
| 412 | #define EXT2_ERRORS_RO 2 /* Remount fs read-only */ |
| 413 | #define EXT2_ERRORS_PANIC 3 /* Panic */ |
| 414 | #define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE |
| 415 | |
| 416 | /* |
| 417 | * Structure of the super block |
| 418 | */ |
| 419 | struct ext2_super_block { |
| 420 | __le32 s_inodes_count; /* Inodes count */ |
| 421 | __le32 s_blocks_count; /* Blocks count */ |
| 422 | __le32 s_r_blocks_count; /* Reserved blocks count */ |
| 423 | __le32 s_free_blocks_count; /* Free blocks count */ |
| 424 | __le32 s_free_inodes_count; /* Free inodes count */ |
| 425 | __le32 s_first_data_block; /* First Data Block */ |
| 426 | __le32 s_log_block_size; /* Block size */ |
| 427 | __le32 s_log_frag_size; /* Fragment size */ |
| 428 | __le32 s_blocks_per_group; /* # Blocks per group */ |
| 429 | __le32 s_frags_per_group; /* # Fragments per group */ |
| 430 | __le32 s_inodes_per_group; /* # Inodes per group */ |
| 431 | __le32 s_mtime; /* Mount time */ |
| 432 | __le32 s_wtime; /* Write time */ |
| 433 | __le16 s_mnt_count; /* Mount count */ |
| 434 | __le16 s_max_mnt_count; /* Maximal mount count */ |
| 435 | __le16 s_magic; /* Magic signature */ |
| 436 | __le16 s_state; /* File system state */ |
| 437 | __le16 s_errors; /* Behaviour when detecting errors */ |
| 438 | __le16 s_minor_rev_level; /* minor revision level */ |
| 439 | __le32 s_lastcheck; /* time of last check */ |
| 440 | __le32 s_checkinterval; /* max. time between checks */ |
| 441 | __le32 s_creator_os; /* OS */ |
| 442 | __le32 s_rev_level; /* Revision level */ |
| 443 | __le16 s_def_resuid; /* Default uid for reserved blocks */ |
| 444 | __le16 s_def_resgid; /* Default gid for reserved blocks */ |
| 445 | /* |
| 446 | * These fields are for EXT2_DYNAMIC_REV superblocks only. |
| 447 | * |
| 448 | * Note: the difference between the compatible feature set and |
| 449 | * the incompatible feature set is that if there is a bit set |
| 450 | * in the incompatible feature set that the kernel doesn't |
| 451 | * know about, it should refuse to mount the filesystem. |
| 452 | * |
| 453 | * e2fsck's requirements are more strict; if it doesn't know |
| 454 | * about a feature in either the compatible or incompatible |
| 455 | * feature set, it must abort and not try to meddle with |
| 456 | * things it doesn't understand... |
| 457 | */ |
| 458 | __le32 s_first_ino; /* First non-reserved inode */ |
| 459 | __le16 s_inode_size; /* size of inode structure */ |
| 460 | __le16 s_block_group_nr; /* block group # of this superblock */ |
| 461 | __le32 s_feature_compat; /* compatible feature set */ |
| 462 | __le32 s_feature_incompat; /* incompatible feature set */ |
| 463 | __le32 s_feature_ro_compat; /* readonly-compatible feature set */ |
| 464 | __u8 s_uuid[16]; /* 128-bit uuid for volume */ |
| 465 | char s_volume_name[16]; /* volume name */ |
| 466 | char s_last_mounted[64]; /* directory where last mounted */ |
| 467 | __le32 s_algorithm_usage_bitmap; /* For compression */ |
| 468 | /* |
| 469 | * Performance hints. Directory preallocation should only |
| 470 | * happen if the EXT2_COMPAT_PREALLOC flag is on. |
| 471 | */ |
| 472 | __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ |
| 473 | __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ |
| 474 | __u16 s_padding1; |
| 475 | /* |
| 476 | * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. |
| 477 | */ |
| 478 | __u8 s_journal_uuid[16]; /* uuid of journal superblock */ |
| 479 | __u32 s_journal_inum; /* inode number of journal file */ |
| 480 | __u32 s_journal_dev; /* device number of journal file */ |
| 481 | __u32 s_last_orphan; /* start of list of inodes to delete */ |
| 482 | __u32 s_hash_seed[4]; /* HTREE hash seed */ |
| 483 | __u8 s_def_hash_version; /* Default hash version to use */ |
| 484 | __u8 s_reserved_char_pad; |
| 485 | __u16 s_reserved_word_pad; |
| 486 | __le32 s_default_mount_opts; |
| 487 | __le32 s_first_meta_bg; /* First metablock block group */ |
| 488 | __u32 s_reserved[190]; /* Padding to the end of the block */ |
| 489 | }; |
| 490 | |
| 491 | /* |
| 492 | * Codes for operating systems |
| 493 | */ |
| 494 | #define EXT2_OS_LINUX 0 |
| 495 | #define EXT2_OS_HURD 1 |
| 496 | #define EXT2_OS_MASIX 2 |
| 497 | #define EXT2_OS_FREEBSD 3 |
| 498 | #define EXT2_OS_LITES 4 |
| 499 | |
| 500 | /* |
| 501 | * Revision levels |
| 502 | */ |
| 503 | #define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ |
| 504 | #define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ |
| 505 | |
| 506 | #define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV |
| 507 | #define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV |
| 508 | |
| 509 | #define EXT2_GOOD_OLD_INODE_SIZE 128 |
| 510 | |
| 511 | /* |
| 512 | * Feature set definitions |
| 513 | */ |
| 514 | |
| 515 | #define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ |
| 516 | ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) ) |
| 517 | #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ |
| 518 | ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) ) |
| 519 | #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ |
| 520 | ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) ) |
| 521 | #define EXT2_SET_COMPAT_FEATURE(sb,mask) \ |
| 522 | EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask) |
| 523 | #define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \ |
| 524 | EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask) |
| 525 | #define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \ |
| 526 | EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask) |
| 527 | #define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \ |
| 528 | EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask) |
| 529 | #define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ |
| 530 | EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask) |
| 531 | #define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ |
| 532 | EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask) |
| 533 | |
| 534 | #define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 |
| 535 | #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 |
| 536 | #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 |
| 537 | #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 |
| 538 | #define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 |
| 539 | #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 |
| 540 | #define EXT2_FEATURE_COMPAT_ANY 0xffffffff |
| 541 | |
| 542 | #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 |
| 543 | #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 |
| 544 | #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 |
| 545 | #define EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff |
| 546 | |
| 547 | #define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 |
| 548 | #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 |
| 549 | #define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 |
| 550 | #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 |
| 551 | #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 |
| 552 | #define EXT2_FEATURE_INCOMPAT_ANY 0xffffffff |
| 553 | |
| 554 | #define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR |
| 555 | #define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \ |
| 556 | EXT2_FEATURE_INCOMPAT_META_BG) |
| 557 | #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ |
| 558 | EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ |
| 559 | EXT2_FEATURE_RO_COMPAT_BTREE_DIR) |
| 560 | #define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP |
| 561 | #define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP |
| 562 | |
| 563 | /* |
| 564 | * Default values for user and/or group using reserved blocks |
| 565 | */ |
| 566 | #define EXT2_DEF_RESUID 0 |
| 567 | #define EXT2_DEF_RESGID 0 |
| 568 | |
| 569 | /* |
| 570 | * Default mount options |
| 571 | */ |
| 572 | #define EXT2_DEFM_DEBUG 0x0001 |
| 573 | #define EXT2_DEFM_BSDGROUPS 0x0002 |
| 574 | #define EXT2_DEFM_XATTR_USER 0x0004 |
| 575 | #define EXT2_DEFM_ACL 0x0008 |
| 576 | #define EXT2_DEFM_UID16 0x0010 |
| 577 | /* Not used by ext2, but reserved for use by ext3 */ |
| 578 | #define EXT3_DEFM_JMODE 0x0060 |
| 579 | #define EXT3_DEFM_JMODE_DATA 0x0020 |
| 580 | #define EXT3_DEFM_JMODE_ORDERED 0x0040 |
| 581 | #define EXT3_DEFM_JMODE_WBACK 0x0060 |
| 582 | |
| 583 | /* |
| 584 | * Structure of a directory entry |
| 585 | */ |
| 586 | |
| 587 | struct ext2_dir_entry { |
| 588 | __le32 inode; /* Inode number */ |
| 589 | __le16 rec_len; /* Directory entry length */ |
| 590 | __le16 name_len; /* Name length */ |
| 591 | char name[]; /* File name, up to EXT2_NAME_LEN */ |
| 592 | }; |
| 593 | |
| 594 | /* |
| 595 | * The new version of the directory entry. Since EXT2 structures are |
| 596 | * stored in intel byte order, and the name_len field could never be |
| 597 | * bigger than 255 chars, it's safe to reclaim the extra byte for the |
| 598 | * file_type field. |
| 599 | */ |
| 600 | struct ext2_dir_entry_2 { |
| 601 | __le32 inode; /* Inode number */ |
| 602 | __le16 rec_len; /* Directory entry length */ |
| 603 | __u8 name_len; /* Name length */ |
| 604 | __u8 file_type; |
| 605 | char name[]; /* File name, up to EXT2_NAME_LEN */ |
| 606 | }; |
| 607 | |
| 608 | /* |
| 609 | * Ext2 directory file types. Only the low 3 bits are used. The |
| 610 | * other bits are reserved for now. |
| 611 | */ |
| 612 | enum { |
| 613 | EXT2_FT_UNKNOWN = 0, |
| 614 | EXT2_FT_REG_FILE = 1, |
| 615 | EXT2_FT_DIR = 2, |
| 616 | EXT2_FT_CHRDEV = 3, |
| 617 | EXT2_FT_BLKDEV = 4, |
| 618 | EXT2_FT_FIFO = 5, |
| 619 | EXT2_FT_SOCK = 6, |
| 620 | EXT2_FT_SYMLINK = 7, |
| 621 | EXT2_FT_MAX |
| 622 | }; |
| 623 | |
| 624 | /* |
| 625 | * EXT2_DIR_PAD defines the directory entries boundaries |
| 626 | * |
| 627 | * NOTE: It must be a multiple of 4 |
| 628 | */ |
| 629 | #define EXT2_DIR_PAD 4 |
| 630 | #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) |
| 631 | #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ |
| 632 | ~EXT2_DIR_ROUND) |
| 633 | #define EXT2_MAX_REC_LEN ((1<<16)-1) |
| 634 | |
| 635 | static inline void verify_offsets(void) |
| 636 | { |
| 637 | #define A(x,y) BUILD_BUG_ON(x != offsetof(struct ext2_super_block, y)); |
| 638 | A(EXT2_SB_MAGIC_OFFSET, s_magic); |
| 639 | A(EXT2_SB_BLOCKS_OFFSET, s_blocks_count); |
| 640 | A(EXT2_SB_BSIZE_OFFSET, s_log_block_size); |
| 641 | #undef A |
| 642 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | |
| 644 | /* |
Jan Kara | 50a5223 | 2005-07-12 13:58:29 -0700 | [diff] [blame] | 645 | * ext2 mount options |
| 646 | */ |
| 647 | struct ext2_mount_options { |
| 648 | unsigned long s_mount_opt; |
Eric W. Biederman | b8a9f9e | 2012-02-07 15:39:12 -0800 | [diff] [blame] | 649 | kuid_t s_resuid; |
| 650 | kgid_t s_resgid; |
Jan Kara | 50a5223 | 2005-07-12 13:58:29 -0700 | [diff] [blame] | 651 | }; |
| 652 | |
| 653 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | * second extended file system inode data in memory |
| 655 | */ |
| 656 | struct ext2_inode_info { |
| 657 | __le32 i_data[15]; |
| 658 | __u32 i_flags; |
| 659 | __u32 i_faddr; |
| 660 | __u8 i_frag_no; |
| 661 | __u8 i_frag_size; |
| 662 | __u16 i_state; |
| 663 | __u32 i_file_acl; |
| 664 | __u32 i_dir_acl; |
| 665 | __u32 i_dtime; |
| 666 | |
| 667 | /* |
| 668 | * i_block_group is the number of the block group which contains |
| 669 | * this file's inode. Constant across the lifetime of the inode, |
Ali Gholami Rudi | 88164ff | 2009-03-30 16:49:27 +0430 | [diff] [blame] | 670 | * it is used for making block allocation decisions - we try to |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | * place a file's data blocks near its inode block, and new inodes |
| 672 | * near to their parent directory's inode. |
| 673 | */ |
| 674 | __u32 i_block_group; |
| 675 | |
Martin J. Bligh | a686cd8 | 2007-10-16 23:30:46 -0700 | [diff] [blame] | 676 | /* block reservation info */ |
| 677 | struct ext2_block_alloc_info *i_block_alloc_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | __u32 i_dir_start_lookup; |
| 680 | #ifdef CONFIG_EXT2_FS_XATTR |
| 681 | /* |
| 682 | * Extended attributes can be read independently of the main file |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 683 | * data. Taking i_mutex even when reading would cause contention |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | * between readers of EAs and writers of regular file data, so |
| 685 | * instead we synchronize on xattr_sem when reading or changing |
| 686 | * EAs. |
| 687 | */ |
| 688 | struct rw_semaphore xattr_sem; |
| 689 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | rwlock_t i_meta_lock; |
Ross Zwisler | 5726b27 | 2015-10-13 16:25:37 -0600 | [diff] [blame] | 691 | #ifdef CONFIG_FS_DAX |
| 692 | struct rw_semaphore dax_sem; |
| 693 | #endif |
Martin J. Bligh | a686cd8 | 2007-10-16 23:30:46 -0700 | [diff] [blame] | 694 | |
| 695 | /* |
| 696 | * truncate_mutex is for serialising ext2_truncate() against |
| 697 | * ext2_getblock(). It also protects the internals of the inode's |
| 698 | * reservation data structures: ext2_reserve_window and |
| 699 | * ext2_reserve_window_node. |
| 700 | */ |
| 701 | struct mutex truncate_mutex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | struct inode vfs_inode; |
Martin J. Bligh | a686cd8 | 2007-10-16 23:30:46 -0700 | [diff] [blame] | 703 | struct list_head i_orphan; /* unlinked but open inodes */ |
Jan Kara | 6424111 | 2014-09-25 16:44:45 +0200 | [diff] [blame] | 704 | #ifdef CONFIG_QUOTA |
| 705 | struct dquot *i_dquot[MAXQUOTAS]; |
| 706 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | }; |
| 708 | |
Ross Zwisler | 5726b27 | 2015-10-13 16:25:37 -0600 | [diff] [blame] | 709 | #ifdef CONFIG_FS_DAX |
| 710 | #define dax_sem_down_write(ext2_inode) down_write(&(ext2_inode)->dax_sem) |
| 711 | #define dax_sem_up_write(ext2_inode) up_write(&(ext2_inode)->dax_sem) |
| 712 | #else |
| 713 | #define dax_sem_down_write(ext2_inode) |
| 714 | #define dax_sem_up_write(ext2_inode) |
| 715 | #endif |
| 716 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | /* |
| 718 | * Inode dynamic state flags |
| 719 | */ |
| 720 | #define EXT2_STATE_NEW 0x00000001 /* inode is newly created */ |
| 721 | |
| 722 | |
| 723 | /* |
| 724 | * Function prototypes |
| 725 | */ |
| 726 | |
| 727 | /* |
| 728 | * Ok, these declarations are also in <linux/kernel.h> but none of the |
| 729 | * ext2 source programs needs to include it so they are duplicated here. |
| 730 | */ |
| 731 | |
| 732 | static inline struct ext2_inode_info *EXT2_I(struct inode *inode) |
| 733 | { |
| 734 | return container_of(inode, struct ext2_inode_info, vfs_inode); |
| 735 | } |
| 736 | |
| 737 | /* balloc.c */ |
| 738 | extern int ext2_bg_has_super(struct super_block *sb, int group); |
| 739 | extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group); |
Martin J. Bligh | a686cd8 | 2007-10-16 23:30:46 -0700 | [diff] [blame] | 740 | extern ext2_fsblk_t ext2_new_block(struct inode *, unsigned long, int *); |
| 741 | extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long, |
| 742 | unsigned long *, int *); |
Carlos Maiolino | ff0031d | 2016-07-05 22:02:41 -0400 | [diff] [blame] | 743 | extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk, |
| 744 | unsigned int count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | extern void ext2_free_blocks (struct inode *, unsigned long, |
| 746 | unsigned long); |
| 747 | extern unsigned long ext2_count_free_blocks (struct super_block *); |
| 748 | extern unsigned long ext2_count_dirs (struct super_block *); |
| 749 | extern void ext2_check_blocks_bitmap (struct super_block *); |
| 750 | extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, |
| 751 | unsigned int block_group, |
| 752 | struct buffer_head ** bh); |
Martin J. Bligh | a686cd8 | 2007-10-16 23:30:46 -0700 | [diff] [blame] | 753 | extern void ext2_discard_reservation (struct inode *); |
| 754 | extern int ext2_should_retry_alloc(struct super_block *sb, int *retries); |
| 755 | extern void ext2_init_block_alloc_info(struct inode *); |
| 756 | extern void ext2_rsv_window_add(struct super_block *sb, struct ext2_reserve_window_node *rsv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | |
| 758 | /* dir.c */ |
| 759 | extern int ext2_add_link (struct dentry *, struct inode *); |
Al Viro | ac3ba64 | 2016-07-20 22:47:26 -0400 | [diff] [blame] | 760 | extern ino_t ext2_inode_by_name(struct inode *, const struct qstr *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | extern int ext2_make_empty(struct inode *, struct inode *); |
Al Viro | ac3ba64 | 2016-07-20 22:47:26 -0400 | [diff] [blame] | 762 | extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,const struct qstr *, struct page **); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *); |
| 764 | extern int ext2_empty_dir (struct inode *); |
| 765 | extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **); |
Jan Kara | 39fe755 | 2009-06-17 16:26:20 -0700 | [diff] [blame] | 766 | extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | /* ialloc.c */ |
Al Viro | 3ea40bc | 2011-07-26 02:46:18 -0400 | [diff] [blame] | 769 | extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | extern void ext2_free_inode (struct inode *); |
| 771 | extern unsigned long ext2_count_free_inodes (struct super_block *); |
| 772 | extern void ext2_check_inodes_bitmap (struct super_block *); |
| 773 | extern unsigned long ext2_count_free (struct buffer_head *, unsigned); |
| 774 | |
| 775 | /* inode.c */ |
David Howells | 52fcf70 | 2008-02-07 00:15:35 -0800 | [diff] [blame] | 776 | extern struct inode *ext2_iget (struct super_block *, unsigned long); |
Christoph Hellwig | a9185b4 | 2010-03-05 09:21:37 +0100 | [diff] [blame] | 777 | extern int ext2_write_inode (struct inode *, struct writeback_control *); |
Al Viro | 72edc4d | 2010-06-04 23:32:28 -0400 | [diff] [blame] | 778 | extern void ext2_evict_inode(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | extern int ext2_setattr (struct dentry *, struct iattr *); |
| 781 | extern void ext2_set_inode_flags(struct inode *inode); |
Josef Bacik | 68c9d70 | 2008-10-03 17:32:43 -0400 | [diff] [blame] | 782 | extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
| 783 | u64 start, u64 len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | |
| 785 | /* ioctl.c */ |
Andi Kleen | 14f9f7b | 2008-02-06 01:40:10 -0800 | [diff] [blame] | 786 | extern long ext2_ioctl(struct file *, unsigned int, unsigned long); |
David Howells | e322ff0 | 2006-08-29 19:06:20 +0100 | [diff] [blame] | 787 | extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | |
Adrian Bunk | 2c22129 | 2006-03-24 03:15:53 -0800 | [diff] [blame] | 789 | /* namei.c */ |
| 790 | struct dentry *ext2_get_parent(struct dentry *child); |
| 791 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | /* super.c */ |
Joe Perches | b9075fa | 2011-10-31 17:11:33 -0700 | [diff] [blame] | 793 | extern __printf(3, 4) |
| 794 | void ext2_error(struct super_block *, const char *, const char *, ...); |
| 795 | extern __printf(3, 4) |
| 796 | void ext2_msg(struct super_block *, const char *, const char *, ...); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | extern void ext2_update_dynamic_rev (struct super_block *sb); |
Jan Kara | 6554766 | 2017-04-05 13:32:52 +0200 | [diff] [blame] | 798 | extern void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es, |
| 799 | int wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | |
| 801 | /* |
| 802 | * Inodes and files operations |
| 803 | */ |
| 804 | |
| 805 | /* dir.c */ |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 806 | extern const struct file_operations ext2_dir_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | |
| 808 | /* file.c */ |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 809 | extern int ext2_fsync(struct file *file, loff_t start, loff_t end, |
| 810 | int datasync); |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 811 | extern const struct inode_operations ext2_file_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 812 | extern const struct file_operations ext2_file_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
| 814 | /* inode.c */ |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 815 | extern const struct address_space_operations ext2_aops; |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 816 | extern const struct address_space_operations ext2_nobh_aops; |
Christoph Hellwig | 8ff6daa | 2017-01-27 23:20:26 -0800 | [diff] [blame] | 817 | extern const struct iomap_ops ext2_iomap_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | |
| 819 | /* namei.c */ |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 820 | extern const struct inode_operations ext2_dir_inode_operations; |
| 821 | extern const struct inode_operations ext2_special_inode_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | |
| 823 | /* symlink.c */ |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 824 | extern const struct inode_operations ext2_fast_symlink_inode_operations; |
| 825 | extern const struct inode_operations ext2_symlink_inode_operations; |
Tobias Poschwatta | 6454d1f | 2007-11-28 16:21:45 -0800 | [diff] [blame] | 826 | |
| 827 | static inline ext2_fsblk_t |
| 828 | ext2_group_first_block_no(struct super_block *sb, unsigned long group_no) |
| 829 | { |
| 830 | return group_no * (ext2_fsblk_t)EXT2_BLOCKS_PER_GROUP(sb) + |
| 831 | le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block); |
| 832 | } |
Akinobu Mita | f312eff | 2011-03-23 16:42:14 -0700 | [diff] [blame] | 833 | |
| 834 | #define ext2_set_bit __test_and_set_bit_le |
| 835 | #define ext2_clear_bit __test_and_clear_bit_le |
| 836 | #define ext2_test_bit test_bit_le |
| 837 | #define ext2_find_first_zero_bit find_first_zero_bit_le |
| 838 | #define ext2_find_next_zero_bit find_next_zero_bit_le |