@@ -344,6 +344,83 @@ static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
344344 return flags & EXT4_OTHER_FLMASK ;
345345}
346346
347+ /*
348+ * Inode flags used for atomic set/get
349+ */
350+ enum {
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+ */
397+ static 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+
347424/* Used to pass group descriptor data when online resize is done */
348425struct ext4_new_group_input {
349426 __u32 group ; /* Group number for this data */
@@ -639,9 +716,8 @@ struct ext4_ext_cache {
639716 */
640717struct ext4_inode_info {
641718 __le32 i_data [15 ]; /* unconverted */
642- __u32 i_flags ;
643- ext4_fsblk_t i_file_acl ;
644719 __u32 i_dtime ;
720+ ext4_fsblk_t i_file_acl ;
645721
646722 /*
647723 * i_block_group is the number of the block group which contains
@@ -652,6 +728,7 @@ struct ext4_inode_info {
652728 */
653729 ext4_group_t i_block_group ;
654730 unsigned long i_state_flags ; /* Dynamic state flags */
731+ unsigned long i_flags ;
655732
656733 ext4_lblk_t i_dir_start_lookup ;
657734#ifdef CONFIG_EXT4_FS_XATTR
@@ -1087,20 +1164,22 @@ enum {
10871164 EXT4_STATE_DIO_UNWRITTEN , /* need convert on dio done*/
10881165};
10891166
1090- static inline int ext4_test_inode_state (struct inode * inode , int bit )
1091- {
1092- return test_bit (bit , & EXT4_I (inode )-> i_state_flags );
1167+ #define EXT4_INODE_BIT_FNS (name , field ) \
1168+ static inline int ext4_test_inode_##name(struct inode *inode, int bit) \
1169+ { \
1170+ return test_bit(bit, &EXT4_I(inode)->i_##field); \
1171+ } \
1172+ static inline void ext4_set_inode_##name(struct inode *inode, int bit) \
1173+ { \
1174+ set_bit(bit, &EXT4_I(inode)->i_##field); \
1175+ } \
1176+ static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \
1177+ { \
1178+ clear_bit(bit, &EXT4_I(inode)->i_##field); \
10931179}
10941180
1095- static inline void ext4_set_inode_state (struct inode * inode , int bit )
1096- {
1097- set_bit (bit , & EXT4_I (inode )-> i_state_flags );
1098- }
1099-
1100- static inline void ext4_clear_inode_state (struct inode * inode , int bit )
1101- {
1102- clear_bit (bit , & EXT4_I (inode )-> i_state_flags );
1103- }
1181+ EXT4_INODE_BIT_FNS (flag , flags )
1182+ EXT4_INODE_BIT_FNS (state , state_flags )
11041183#else
11051184/* Assume that user mode programs are passing in an ext4fs superblock, not
11061185 * a kernel struct super_block. This will allow us to call the feature-test
@@ -1287,7 +1366,7 @@ struct ext4_dir_entry_2 {
12871366
12881367#define is_dx (dir ) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \
12891368 EXT4_FEATURE_COMPAT_DIR_INDEX) && \
1290- (EXT4_I (dir)->i_flags & EXT4_INDEX_FL ))
1369+ ext4_test_inode_flag( (dir), EXT4_INODE_INDEX ))
12911370#define EXT4_DIR_LINK_MAX (dir ) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
12921371#define EXT4_DIR_LINK_EMPTY (dir ) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
12931372
0 commit comments