aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r--fs/ext4/ext4.h109
1 files changed, 94 insertions, 15 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 413321ff1e20..74414884580c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -344,6 +344,83 @@ static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
344 return flags & EXT4_OTHER_FLMASK; 344 return flags & EXT4_OTHER_FLMASK;
345} 345}
346 346
347/*
348 * Inode flags used for atomic set/get
349 */
350enum {
351 EXT4_INODE_SECRM = 0, /* Secure deletion */
352 EXT4_INODE_UNRM = 1, /* Undelete */
353 EXT4_INODE_COMPR = 2, /* Compress file */
354 EXT4_INODE_SYNC = 3, /* Synchronous updates */
355 EXT4_INODE_IMMUTABLE = 4, /* Immutable file */
356 EXT4_INODE_APPEND = 5, /* writes to file may only append */
357 EXT4_INODE_NODUMP = 6, /* do not dump file */
358 EXT4_INODE_NOATIME = 7, /* do not update atime */
359/* Reserved for compression usage... */
360 EXT4_INODE_DIRTY = 8,
361 EXT4_INODE_COMPRBLK = 9, /* One or more compressed clusters */
362 EXT4_INODE_NOCOMPR = 10, /* Don't compress */
363 EXT4_INODE_ECOMPR = 11, /* Compression error */
364/* End compression flags --- maybe not all used */
365 EXT4_INODE_INDEX = 12, /* hash-indexed directory */
366 EXT4_INODE_IMAGIC = 13, /* AFS directory */
367 EXT4_INODE_JOURNAL_DATA = 14, /* file data should be journaled */
368 EXT4_INODE_NOTAIL = 15, /* file tail should not be merged */
369 EXT4_INODE_DIRSYNC = 16, /* dirsync behaviour (directories only) */
370 EXT4_INODE_TOPDIR = 17, /* Top of directory hierarchies*/
371 EXT4_INODE_HUGE_FILE = 18, /* Set to each huge file */
372 EXT4_INODE_EXTENTS = 19, /* Inode uses extents */
373 EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */
374 EXT4_INODE_EOFBLOCKS = 22, /* Blocks allocated beyond EOF */
375 EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */
376};
377
378#define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1 << EXT4_INODE_##FLAG))
379#define CHECK_FLAG_VALUE(FLAG) if (!TEST_FLAG_VALUE(FLAG)) { \
380 printk(KERN_EMERG "EXT4 flag fail: " #FLAG ": %d %d\n", \
381 EXT4_##FLAG##_FL, EXT4_INODE_##FLAG); BUG_ON(1); }
382
383/*
384 * Since it's pretty easy to mix up bit numbers and hex values, and we
385 * can't do a compile-time test for ENUM values, we use a run-time
386 * test to make sure that EXT4_XXX_FL is consistent with respect to
387 * EXT4_INODE_XXX. If all is well the printk and BUG_ON will all drop
388 * out so it won't cost any extra space in the compiled kernel image.
389 * But it's important that these values are the same, since we are
390 * using EXT4_INODE_XXX to test for the flag values, but EXT4_XX_FL
391 * must be consistent with the values of FS_XXX_FL defined in
392 * include/linux/fs.h and the on-disk values found in ext2, ext3, and
393 * ext4 filesystems, and of course the values defined in e2fsprogs.
394 *
395 * It's not paranoia if the Murphy's Law really *is* out to get you. :-)
396 */
397static inline void ext4_check_flag_values(void)
398{
399 CHECK_FLAG_VALUE(SECRM);
400 CHECK_FLAG_VALUE(UNRM);
401 CHECK_FLAG_VALUE(COMPR);
402 CHECK_FLAG_VALUE(SYNC);
403 CHECK_FLAG_VALUE(IMMUTABLE);
404 CHECK_FLAG_VALUE(APPEND);
405 CHECK_FLAG_VALUE(NODUMP);
406 CHECK_FLAG_VALUE(NOATIME);
407 CHECK_FLAG_VALUE(DIRTY);
408 CHECK_FLAG_VALUE(COMPRBLK);
409 CHECK_FLAG_VALUE(NOCOMPR);
410 CHECK_FLAG_VALUE(ECOMPR);
411 CHECK_FLAG_VALUE(INDEX);
412 CHECK_FLAG_VALUE(IMAGIC);
413 CHECK_FLAG_VALUE(JOURNAL_DATA);
414 CHECK_FLAG_VALUE(NOTAIL);
415 CHECK_FLAG_VALUE(DIRSYNC);
416 CHECK_FLAG_VALUE(TOPDIR);
417 CHECK_FLAG_VALUE(HUGE_FILE);
418 CHECK_FLAG_VALUE(EXTENTS);
419 CHECK_FLAG_VALUE(EA_INODE);
420 CHECK_FLAG_VALUE(EOFBLOCKS);
421 CHECK_FLAG_VALUE(RESERVED);
422}
423
347/* Used to pass group descriptor data when online resize is done */ 424/* Used to pass group descriptor data when online resize is done */
348struct ext4_new_group_input { 425struct ext4_new_group_input {
349 __u32 group; /* Group number for this data */ 426 __u32 group; /* Group number for this data */
@@ -639,9 +716,8 @@ struct ext4_ext_cache {
639 */ 716 */
640struct ext4_inode_info { 717struct ext4_inode_info {
641 __le32 i_data[15]; /* unconverted */ 718 __le32 i_data[15]; /* unconverted */
642 __u32 i_flags;
643 ext4_fsblk_t i_file_acl;
644 __u32 i_dtime; 719 __u32 i_dtime;
720 ext4_fsblk_t i_file_acl;
645 721
646 /* 722 /*
647 * i_block_group is the number of the block group which contains 723 * i_block_group is the number of the block group which contains
@@ -652,6 +728,7 @@ struct ext4_inode_info {
652 */ 728 */
653 ext4_group_t i_block_group; 729 ext4_group_t i_block_group;
654 unsigned long i_state_flags; /* Dynamic state flags */ 730 unsigned long i_state_flags; /* Dynamic state flags */
731 unsigned long i_flags;
655 732
656 ext4_lblk_t i_dir_start_lookup; 733 ext4_lblk_t i_dir_start_lookup;
657#ifdef CONFIG_EXT4_FS_XATTR 734#ifdef CONFIG_EXT4_FS_XATTR
@@ -1087,20 +1164,22 @@ enum {
1087 EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/ 1164 EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/
1088}; 1165};
1089 1166
1090static inline int ext4_test_inode_state(struct inode *inode, int bit) 1167#define EXT4_INODE_BIT_FNS(name, field) \
1091{ 1168static inline int ext4_test_inode_##name(struct inode *inode, int bit) \
1092 return test_bit(bit, &EXT4_I(inode)->i_state_flags); 1169{ \
1170 return test_bit(bit, &EXT4_I(inode)->i_##field); \
1171} \
1172static inline void ext4_set_inode_##name(struct inode *inode, int bit) \
1173{ \
1174 set_bit(bit, &EXT4_I(inode)->i_##field); \
1175} \
1176static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \
1177{ \
1178 clear_bit(bit, &EXT4_I(inode)->i_##field); \
1093} 1179}
1094 1180
1095static inline void ext4_set_inode_state(struct inode *inode, int bit) 1181EXT4_INODE_BIT_FNS(flag, flags)
1096{ 1182EXT4_INODE_BIT_FNS(state, state_flags)
1097 set_bit(bit, &EXT4_I(inode)->i_state_flags);
1098}
1099
1100static inline void ext4_clear_inode_state(struct inode *inode, int bit)
1101{
1102 clear_bit(bit, &EXT4_I(inode)->i_state_flags);
1103}
1104#else 1183#else
1105/* Assume that user mode programs are passing in an ext4fs superblock, not 1184/* Assume that user mode programs are passing in an ext4fs superblock, not
1106 * a kernel struct super_block. This will allow us to call the feature-test 1185 * a kernel struct super_block. This will allow us to call the feature-test
@@ -1287,7 +1366,7 @@ struct ext4_dir_entry_2 {
1287 1366
1288#define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \ 1367#define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \
1289 EXT4_FEATURE_COMPAT_DIR_INDEX) && \ 1368 EXT4_FEATURE_COMPAT_DIR_INDEX) && \
1290 (EXT4_I(dir)->i_flags & EXT4_INDEX_FL)) 1369 ext4_test_inode_flag((dir), EXT4_INODE_INDEX))
1291#define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX) 1370#define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
1292#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) 1371#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
1293 1372