diff options
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 320 |
1 files changed, 265 insertions, 55 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index bf938cf7c5f0..889ec9d5e6ad 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -29,6 +29,9 @@ | |||
29 | #include <linux/wait.h> | 29 | #include <linux/wait.h> |
30 | #include <linux/blockgroup_lock.h> | 30 | #include <linux/blockgroup_lock.h> |
31 | #include <linux/percpu_counter.h> | 31 | #include <linux/percpu_counter.h> |
32 | #ifdef __KERNEL__ | ||
33 | #include <linux/compat.h> | ||
34 | #endif | ||
32 | 35 | ||
33 | /* | 36 | /* |
34 | * The fourth extended filesystem constants/structures | 37 | * The fourth extended filesystem constants/structures |
@@ -54,10 +57,13 @@ | |||
54 | #endif | 57 | #endif |
55 | 58 | ||
56 | #define EXT4_ERROR_INODE(inode, fmt, a...) \ | 59 | #define EXT4_ERROR_INODE(inode, fmt, a...) \ |
57 | ext4_error_inode(__func__, (inode), (fmt), ## a); | 60 | ext4_error_inode((inode), __func__, __LINE__, 0, (fmt), ## a) |
61 | |||
62 | #define EXT4_ERROR_INODE_BLOCK(inode, block, fmt, a...) \ | ||
63 | ext4_error_inode((inode), __func__, __LINE__, (block), (fmt), ## a) | ||
58 | 64 | ||
59 | #define EXT4_ERROR_FILE(file, fmt, a...) \ | 65 | #define EXT4_ERROR_FILE(file, fmt, a...) \ |
60 | ext4_error_file(__func__, (file), (fmt), ## a); | 66 | ext4_error_file(__func__, __LINE__, (file), (fmt), ## a) |
61 | 67 | ||
62 | /* data type for block offset of block group */ | 68 | /* data type for block offset of block group */ |
63 | typedef int ext4_grpblk_t; | 69 | typedef int ext4_grpblk_t; |
@@ -72,7 +78,7 @@ typedef __u32 ext4_lblk_t; | |||
72 | typedef unsigned int ext4_group_t; | 78 | typedef unsigned int ext4_group_t; |
73 | 79 | ||
74 | /* | 80 | /* |
75 | * Flags used in mballoc's allocation_context flags field. | 81 | * Flags used in mballoc's allocation_context flags field. |
76 | * | 82 | * |
77 | * Also used to show what's going on for debugging purposes when the | 83 | * Also used to show what's going on for debugging purposes when the |
78 | * flag field is exported via the traceport interface | 84 | * flag field is exported via the traceport interface |
@@ -126,6 +132,29 @@ struct ext4_allocation_request { | |||
126 | }; | 132 | }; |
127 | 133 | ||
128 | /* | 134 | /* |
135 | * Logical to physical block mapping, used by ext4_map_blocks() | ||
136 | * | ||
137 | * This structure is used to pass requests into ext4_map_blocks() as | ||
138 | * well as to store the information returned by ext4_map_blocks(). It | ||
139 | * takes less room on the stack than a struct buffer_head. | ||
140 | */ | ||
141 | #define EXT4_MAP_NEW (1 << BH_New) | ||
142 | #define EXT4_MAP_MAPPED (1 << BH_Mapped) | ||
143 | #define EXT4_MAP_UNWRITTEN (1 << BH_Unwritten) | ||
144 | #define EXT4_MAP_BOUNDARY (1 << BH_Boundary) | ||
145 | #define EXT4_MAP_UNINIT (1 << BH_Uninit) | ||
146 | #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ | ||
147 | EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\ | ||
148 | EXT4_MAP_UNINIT) | ||
149 | |||
150 | struct ext4_map_blocks { | ||
151 | ext4_fsblk_t m_pblk; | ||
152 | ext4_lblk_t m_lblk; | ||
153 | unsigned int m_len; | ||
154 | unsigned int m_flags; | ||
155 | }; | ||
156 | |||
157 | /* | ||
129 | * For delayed allocation tracking | 158 | * For delayed allocation tracking |
130 | */ | 159 | */ |
131 | struct mpage_da_data { | 160 | struct mpage_da_data { |
@@ -141,13 +170,15 @@ struct mpage_da_data { | |||
141 | }; | 170 | }; |
142 | #define EXT4_IO_UNWRITTEN 0x1 | 171 | #define EXT4_IO_UNWRITTEN 0x1 |
143 | typedef struct ext4_io_end { | 172 | typedef struct ext4_io_end { |
144 | struct list_head list; /* per-file finished AIO list */ | 173 | struct list_head list; /* per-file finished IO list */ |
145 | struct inode *inode; /* file being written to */ | 174 | struct inode *inode; /* file being written to */ |
146 | unsigned int flag; /* unwritten or not */ | 175 | unsigned int flag; /* unwritten or not */ |
147 | struct page *page; /* page struct for buffer write */ | 176 | struct page *page; /* page struct for buffer write */ |
148 | loff_t offset; /* offset in the file */ | 177 | loff_t offset; /* offset in the file */ |
149 | ssize_t size; /* size of the extent */ | 178 | ssize_t size; /* size of the extent */ |
150 | struct work_struct work; /* data work queue */ | 179 | struct work_struct work; /* data work queue */ |
180 | struct kiocb *iocb; /* iocb struct for AIO */ | ||
181 | int result; /* error value for AIO */ | ||
151 | } ext4_io_end_t; | 182 | } ext4_io_end_t; |
152 | 183 | ||
153 | /* | 184 | /* |
@@ -321,6 +352,83 @@ static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags) | |||
321 | return flags & EXT4_OTHER_FLMASK; | 352 | return flags & EXT4_OTHER_FLMASK; |
322 | } | 353 | } |
323 | 354 | ||
355 | /* | ||
356 | * Inode flags used for atomic set/get | ||
357 | */ | ||
358 | enum { | ||
359 | EXT4_INODE_SECRM = 0, /* Secure deletion */ | ||
360 | EXT4_INODE_UNRM = 1, /* Undelete */ | ||
361 | EXT4_INODE_COMPR = 2, /* Compress file */ | ||
362 | EXT4_INODE_SYNC = 3, /* Synchronous updates */ | ||
363 | EXT4_INODE_IMMUTABLE = 4, /* Immutable file */ | ||
364 | EXT4_INODE_APPEND = 5, /* writes to file may only append */ | ||
365 | EXT4_INODE_NODUMP = 6, /* do not dump file */ | ||
366 | EXT4_INODE_NOATIME = 7, /* do not update atime */ | ||
367 | /* Reserved for compression usage... */ | ||
368 | EXT4_INODE_DIRTY = 8, | ||
369 | EXT4_INODE_COMPRBLK = 9, /* One or more compressed clusters */ | ||
370 | EXT4_INODE_NOCOMPR = 10, /* Don't compress */ | ||
371 | EXT4_INODE_ECOMPR = 11, /* Compression error */ | ||
372 | /* End compression flags --- maybe not all used */ | ||
373 | EXT4_INODE_INDEX = 12, /* hash-indexed directory */ | ||
374 | EXT4_INODE_IMAGIC = 13, /* AFS directory */ | ||
375 | EXT4_INODE_JOURNAL_DATA = 14, /* file data should be journaled */ | ||
376 | EXT4_INODE_NOTAIL = 15, /* file tail should not be merged */ | ||
377 | EXT4_INODE_DIRSYNC = 16, /* dirsync behaviour (directories only) */ | ||
378 | EXT4_INODE_TOPDIR = 17, /* Top of directory hierarchies*/ | ||
379 | EXT4_INODE_HUGE_FILE = 18, /* Set to each huge file */ | ||
380 | EXT4_INODE_EXTENTS = 19, /* Inode uses extents */ | ||
381 | EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */ | ||
382 | EXT4_INODE_EOFBLOCKS = 22, /* Blocks allocated beyond EOF */ | ||
383 | EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */ | ||
384 | }; | ||
385 | |||
386 | #define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1 << EXT4_INODE_##FLAG)) | ||
387 | #define CHECK_FLAG_VALUE(FLAG) if (!TEST_FLAG_VALUE(FLAG)) { \ | ||
388 | printk(KERN_EMERG "EXT4 flag fail: " #FLAG ": %d %d\n", \ | ||
389 | EXT4_##FLAG##_FL, EXT4_INODE_##FLAG); BUG_ON(1); } | ||
390 | |||
391 | /* | ||
392 | * Since it's pretty easy to mix up bit numbers and hex values, and we | ||
393 | * can't do a compile-time test for ENUM values, we use a run-time | ||
394 | * test to make sure that EXT4_XXX_FL is consistent with respect to | ||
395 | * EXT4_INODE_XXX. If all is well the printk and BUG_ON will all drop | ||
396 | * out so it won't cost any extra space in the compiled kernel image. | ||
397 | * But it's important that these values are the same, since we are | ||
398 | * using EXT4_INODE_XXX to test for the flag values, but EXT4_XX_FL | ||
399 | * must be consistent with the values of FS_XXX_FL defined in | ||
400 | * include/linux/fs.h and the on-disk values found in ext2, ext3, and | ||
401 | * ext4 filesystems, and of course the values defined in e2fsprogs. | ||
402 | * | ||
403 | * It's not paranoia if the Murphy's Law really *is* out to get you. :-) | ||
404 | */ | ||
405 | static inline void ext4_check_flag_values(void) | ||
406 | { | ||
407 | CHECK_FLAG_VALUE(SECRM); | ||
408 | CHECK_FLAG_VALUE(UNRM); | ||
409 | CHECK_FLAG_VALUE(COMPR); | ||
410 | CHECK_FLAG_VALUE(SYNC); | ||
411 | CHECK_FLAG_VALUE(IMMUTABLE); | ||
412 | CHECK_FLAG_VALUE(APPEND); | ||
413 | CHECK_FLAG_VALUE(NODUMP); | ||
414 | CHECK_FLAG_VALUE(NOATIME); | ||
415 | CHECK_FLAG_VALUE(DIRTY); | ||
416 | CHECK_FLAG_VALUE(COMPRBLK); | ||
417 | CHECK_FLAG_VALUE(NOCOMPR); | ||
418 | CHECK_FLAG_VALUE(ECOMPR); | ||
419 | CHECK_FLAG_VALUE(INDEX); | ||
420 | CHECK_FLAG_VALUE(IMAGIC); | ||
421 | CHECK_FLAG_VALUE(JOURNAL_DATA); | ||
422 | CHECK_FLAG_VALUE(NOTAIL); | ||
423 | CHECK_FLAG_VALUE(DIRSYNC); | ||
424 | CHECK_FLAG_VALUE(TOPDIR); | ||
425 | CHECK_FLAG_VALUE(HUGE_FILE); | ||
426 | CHECK_FLAG_VALUE(EXTENTS); | ||
427 | CHECK_FLAG_VALUE(EA_INODE); | ||
428 | CHECK_FLAG_VALUE(EOFBLOCKS); | ||
429 | CHECK_FLAG_VALUE(RESERVED); | ||
430 | } | ||
431 | |||
324 | /* Used to pass group descriptor data when online resize is done */ | 432 | /* Used to pass group descriptor data when online resize is done */ |
325 | struct ext4_new_group_input { | 433 | struct ext4_new_group_input { |
326 | __u32 group; /* Group number for this data */ | 434 | __u32 group; /* Group number for this data */ |
@@ -332,6 +440,18 @@ struct ext4_new_group_input { | |||
332 | __u16 unused; | 440 | __u16 unused; |
333 | }; | 441 | }; |
334 | 442 | ||
443 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) | ||
444 | struct compat_ext4_new_group_input { | ||
445 | u32 group; | ||
446 | compat_u64 block_bitmap; | ||
447 | compat_u64 inode_bitmap; | ||
448 | compat_u64 inode_table; | ||
449 | u32 blocks_count; | ||
450 | u16 reserved_blocks; | ||
451 | u16 unused; | ||
452 | }; | ||
453 | #endif | ||
454 | |||
335 | /* The struct ext4_new_group_input in kernel space, with free_blocks_count */ | 455 | /* The struct ext4_new_group_input in kernel space, with free_blocks_count */ |
336 | struct ext4_new_group_data { | 456 | struct ext4_new_group_data { |
337 | __u32 group; | 457 | __u32 group; |
@@ -345,7 +465,7 @@ struct ext4_new_group_data { | |||
345 | }; | 465 | }; |
346 | 466 | ||
347 | /* | 467 | /* |
348 | * Flags used by ext4_get_blocks() | 468 | * Flags used by ext4_map_blocks() |
349 | */ | 469 | */ |
350 | /* Allocate any needed blocks and/or convert an unitialized | 470 | /* Allocate any needed blocks and/or convert an unitialized |
351 | extent to be an initialized ext4 */ | 471 | extent to be an initialized ext4 */ |
@@ -355,7 +475,7 @@ struct ext4_new_group_data { | |||
355 | #define EXT4_GET_BLOCKS_CREATE_UNINIT_EXT (EXT4_GET_BLOCKS_UNINIT_EXT|\ | 475 | #define EXT4_GET_BLOCKS_CREATE_UNINIT_EXT (EXT4_GET_BLOCKS_UNINIT_EXT|\ |
356 | EXT4_GET_BLOCKS_CREATE) | 476 | EXT4_GET_BLOCKS_CREATE) |
357 | /* Caller is from the delayed allocation writeout path, | 477 | /* Caller is from the delayed allocation writeout path, |
358 | so set the magic i_delalloc_reserve_flag after taking the | 478 | so set the magic i_delalloc_reserve_flag after taking the |
359 | inode allocation semaphore for */ | 479 | inode allocation semaphore for */ |
360 | #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004 | 480 | #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004 |
361 | /* caller is from the direct IO path, request to creation of an | 481 | /* caller is from the direct IO path, request to creation of an |
@@ -398,6 +518,7 @@ struct ext4_new_group_data { | |||
398 | #define EXT4_IOC_ALLOC_DA_BLKS _IO('f', 12) | 518 | #define EXT4_IOC_ALLOC_DA_BLKS _IO('f', 12) |
399 | #define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent) | 519 | #define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent) |
400 | 520 | ||
521 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) | ||
401 | /* | 522 | /* |
402 | * ioctl commands in 32 bit emulation | 523 | * ioctl commands in 32 bit emulation |
403 | */ | 524 | */ |
@@ -408,11 +529,13 @@ struct ext4_new_group_data { | |||
408 | #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int) | 529 | #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int) |
409 | #define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int) | 530 | #define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int) |
410 | #define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int) | 531 | #define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int) |
532 | #define EXT4_IOC32_GROUP_ADD _IOW('f', 8, struct compat_ext4_new_group_input) | ||
411 | #ifdef CONFIG_JBD2_DEBUG | 533 | #ifdef CONFIG_JBD2_DEBUG |
412 | #define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int) | 534 | #define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int) |
413 | #endif | 535 | #endif |
414 | #define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION | 536 | #define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION |
415 | #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION | 537 | #define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION |
538 | #endif | ||
416 | 539 | ||
417 | 540 | ||
418 | /* | 541 | /* |
@@ -616,9 +739,8 @@ struct ext4_ext_cache { | |||
616 | */ | 739 | */ |
617 | struct ext4_inode_info { | 740 | struct ext4_inode_info { |
618 | __le32 i_data[15]; /* unconverted */ | 741 | __le32 i_data[15]; /* unconverted */ |
619 | __u32 i_flags; | ||
620 | ext4_fsblk_t i_file_acl; | ||
621 | __u32 i_dtime; | 742 | __u32 i_dtime; |
743 | ext4_fsblk_t i_file_acl; | ||
622 | 744 | ||
623 | /* | 745 | /* |
624 | * i_block_group is the number of the block group which contains | 746 | * i_block_group is the number of the block group which contains |
@@ -629,6 +751,7 @@ struct ext4_inode_info { | |||
629 | */ | 751 | */ |
630 | ext4_group_t i_block_group; | 752 | ext4_group_t i_block_group; |
631 | unsigned long i_state_flags; /* Dynamic state flags */ | 753 | unsigned long i_state_flags; /* Dynamic state flags */ |
754 | unsigned long i_flags; | ||
632 | 755 | ||
633 | ext4_lblk_t i_dir_start_lookup; | 756 | ext4_lblk_t i_dir_start_lookup; |
634 | #ifdef CONFIG_EXT4_FS_XATTR | 757 | #ifdef CONFIG_EXT4_FS_XATTR |
@@ -755,7 +878,6 @@ struct ext4_inode_info { | |||
755 | #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */ | 878 | #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */ |
756 | #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */ | 879 | #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */ |
757 | #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */ | 880 | #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */ |
758 | #define EXT4_MOUNT_NOBH 0x40000 /* No bufferheads */ | ||
759 | #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */ | 881 | #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */ |
760 | #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ | 882 | #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ |
761 | #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ | 883 | #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ |
@@ -864,7 +986,7 @@ struct ext4_super_block { | |||
864 | __le32 s_last_orphan; /* start of list of inodes to delete */ | 986 | __le32 s_last_orphan; /* start of list of inodes to delete */ |
865 | __le32 s_hash_seed[4]; /* HTREE hash seed */ | 987 | __le32 s_hash_seed[4]; /* HTREE hash seed */ |
866 | __u8 s_def_hash_version; /* Default hash version to use */ | 988 | __u8 s_def_hash_version; /* Default hash version to use */ |
867 | __u8 s_reserved_char_pad; | 989 | __u8 s_jnl_backup_type; |
868 | __le16 s_desc_size; /* size of group descriptor */ | 990 | __le16 s_desc_size; /* size of group descriptor */ |
869 | /*100*/ __le32 s_default_mount_opts; | 991 | /*100*/ __le32 s_default_mount_opts; |
870 | __le32 s_first_meta_bg; /* First metablock block group */ | 992 | __le32 s_first_meta_bg; /* First metablock block group */ |
@@ -882,12 +1004,34 @@ struct ext4_super_block { | |||
882 | __le64 s_mmp_block; /* Block for multi-mount protection */ | 1004 | __le64 s_mmp_block; /* Block for multi-mount protection */ |
883 | __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ | 1005 | __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ |
884 | __u8 s_log_groups_per_flex; /* FLEX_BG group size */ | 1006 | __u8 s_log_groups_per_flex; /* FLEX_BG group size */ |
885 | __u8 s_reserved_char_pad2; | 1007 | __u8 s_reserved_char_pad; |
886 | __le16 s_reserved_pad; | 1008 | __le16 s_reserved_pad; |
887 | __le64 s_kbytes_written; /* nr of lifetime kilobytes written */ | 1009 | __le64 s_kbytes_written; /* nr of lifetime kilobytes written */ |
888 | __u32 s_reserved[160]; /* Padding to the end of the block */ | 1010 | __le32 s_snapshot_inum; /* Inode number of active snapshot */ |
1011 | __le32 s_snapshot_id; /* sequential ID of active snapshot */ | ||
1012 | __le64 s_snapshot_r_blocks_count; /* reserved blocks for active | ||
1013 | snapshot's future use */ | ||
1014 | __le32 s_snapshot_list; /* inode number of the head of the | ||
1015 | on-disk snapshot list */ | ||
1016 | #define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count) | ||
1017 | __le32 s_error_count; /* number of fs errors */ | ||
1018 | __le32 s_first_error_time; /* first time an error happened */ | ||
1019 | __le32 s_first_error_ino; /* inode involved in first error */ | ||
1020 | __le64 s_first_error_block; /* block involved of first error */ | ||
1021 | __u8 s_first_error_func[32]; /* function where the error happened */ | ||
1022 | __le32 s_first_error_line; /* line number where error happened */ | ||
1023 | __le32 s_last_error_time; /* most recent time of an error */ | ||
1024 | __le32 s_last_error_ino; /* inode involved in last error */ | ||
1025 | __le32 s_last_error_line; /* line number where error happened */ | ||
1026 | __le64 s_last_error_block; /* block involved of last error */ | ||
1027 | __u8 s_last_error_func[32]; /* function where the error happened */ | ||
1028 | #define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts) | ||
1029 | __u8 s_mount_opts[64]; | ||
1030 | __le32 s_reserved[112]; /* Padding to the end of the block */ | ||
889 | }; | 1031 | }; |
890 | 1032 | ||
1033 | #define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START) | ||
1034 | |||
891 | #ifdef __KERNEL__ | 1035 | #ifdef __KERNEL__ |
892 | 1036 | ||
893 | /* | 1037 | /* |
@@ -1025,6 +1169,9 @@ struct ext4_sb_info { | |||
1025 | 1169 | ||
1026 | /* workqueue for dio unwritten */ | 1170 | /* workqueue for dio unwritten */ |
1027 | struct workqueue_struct *dio_unwritten_wq; | 1171 | struct workqueue_struct *dio_unwritten_wq; |
1172 | |||
1173 | /* timer for periodic error stats printing */ | ||
1174 | struct timer_list s_err_report; | ||
1028 | }; | 1175 | }; |
1029 | 1176 | ||
1030 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) | 1177 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) |
@@ -1062,22 +1209,25 @@ enum { | |||
1062 | EXT4_STATE_DA_ALLOC_CLOSE, /* Alloc DA blks on close */ | 1209 | EXT4_STATE_DA_ALLOC_CLOSE, /* Alloc DA blks on close */ |
1063 | EXT4_STATE_EXT_MIGRATE, /* Inode is migrating */ | 1210 | EXT4_STATE_EXT_MIGRATE, /* Inode is migrating */ |
1064 | EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/ | 1211 | EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/ |
1212 | EXT4_STATE_NEWENTRY, /* File just added to dir */ | ||
1065 | }; | 1213 | }; |
1066 | 1214 | ||
1067 | static inline int ext4_test_inode_state(struct inode *inode, int bit) | 1215 | #define EXT4_INODE_BIT_FNS(name, field) \ |
1068 | { | 1216 | static inline int ext4_test_inode_##name(struct inode *inode, int bit) \ |
1069 | return test_bit(bit, &EXT4_I(inode)->i_state_flags); | 1217 | { \ |
1218 | return test_bit(bit, &EXT4_I(inode)->i_##field); \ | ||
1219 | } \ | ||
1220 | static inline void ext4_set_inode_##name(struct inode *inode, int bit) \ | ||
1221 | { \ | ||
1222 | set_bit(bit, &EXT4_I(inode)->i_##field); \ | ||
1223 | } \ | ||
1224 | static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \ | ||
1225 | { \ | ||
1226 | clear_bit(bit, &EXT4_I(inode)->i_##field); \ | ||
1070 | } | 1227 | } |
1071 | 1228 | ||
1072 | static inline void ext4_set_inode_state(struct inode *inode, int bit) | 1229 | EXT4_INODE_BIT_FNS(flag, flags) |
1073 | { | 1230 | EXT4_INODE_BIT_FNS(state, state_flags) |
1074 | set_bit(bit, &EXT4_I(inode)->i_state_flags); | ||
1075 | } | ||
1076 | |||
1077 | static inline void ext4_clear_inode_state(struct inode *inode, int bit) | ||
1078 | { | ||
1079 | clear_bit(bit, &EXT4_I(inode)->i_state_flags); | ||
1080 | } | ||
1081 | #else | 1231 | #else |
1082 | /* Assume that user mode programs are passing in an ext4fs superblock, not | 1232 | /* Assume that user mode programs are passing in an ext4fs superblock, not |
1083 | * a kernel struct super_block. This will allow us to call the feature-test | 1233 | * a kernel struct super_block. This will allow us to call the feature-test |
@@ -1192,6 +1342,10 @@ static inline void ext4_clear_inode_state(struct inode *inode, int bit) | |||
1192 | #define EXT4_DEFM_JMODE_DATA 0x0020 | 1342 | #define EXT4_DEFM_JMODE_DATA 0x0020 |
1193 | #define EXT4_DEFM_JMODE_ORDERED 0x0040 | 1343 | #define EXT4_DEFM_JMODE_ORDERED 0x0040 |
1194 | #define EXT4_DEFM_JMODE_WBACK 0x0060 | 1344 | #define EXT4_DEFM_JMODE_WBACK 0x0060 |
1345 | #define EXT4_DEFM_NOBARRIER 0x0100 | ||
1346 | #define EXT4_DEFM_BLOCK_VALIDITY 0x0200 | ||
1347 | #define EXT4_DEFM_DISCARD 0x0400 | ||
1348 | #define EXT4_DEFM_NODELALLOC 0x0800 | ||
1195 | 1349 | ||
1196 | /* | 1350 | /* |
1197 | * Default journal batch times | 1351 | * Default journal batch times |
@@ -1258,13 +1412,50 @@ struct ext4_dir_entry_2 { | |||
1258 | #define EXT4_MAX_REC_LEN ((1<<16)-1) | 1412 | #define EXT4_MAX_REC_LEN ((1<<16)-1) |
1259 | 1413 | ||
1260 | /* | 1414 | /* |
1415 | * If we ever get support for fs block sizes > page_size, we'll need | ||
1416 | * to remove the #if statements in the next two functions... | ||
1417 | */ | ||
1418 | static inline unsigned int | ||
1419 | ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize) | ||
1420 | { | ||
1421 | unsigned len = le16_to_cpu(dlen); | ||
1422 | |||
1423 | #if (PAGE_CACHE_SIZE >= 65536) | ||
1424 | if (len == EXT4_MAX_REC_LEN || len == 0) | ||
1425 | return blocksize; | ||
1426 | return (len & 65532) | ((len & 3) << 16); | ||
1427 | #else | ||
1428 | return len; | ||
1429 | #endif | ||
1430 | } | ||
1431 | |||
1432 | static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) | ||
1433 | { | ||
1434 | if ((len > blocksize) || (blocksize > (1 << 18)) || (len & 3)) | ||
1435 | BUG(); | ||
1436 | #if (PAGE_CACHE_SIZE >= 65536) | ||
1437 | if (len < 65536) | ||
1438 | return cpu_to_le16(len); | ||
1439 | if (len == blocksize) { | ||
1440 | if (blocksize == 65536) | ||
1441 | return cpu_to_le16(EXT4_MAX_REC_LEN); | ||
1442 | else | ||
1443 | return cpu_to_le16(0); | ||
1444 | } | ||
1445 | return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); | ||
1446 | #else | ||
1447 | return cpu_to_le16(len); | ||
1448 | #endif | ||
1449 | } | ||
1450 | |||
1451 | /* | ||
1261 | * Hash Tree Directory indexing | 1452 | * Hash Tree Directory indexing |
1262 | * (c) Daniel Phillips, 2001 | 1453 | * (c) Daniel Phillips, 2001 |
1263 | */ | 1454 | */ |
1264 | 1455 | ||
1265 | #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \ | 1456 | #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \ |
1266 | EXT4_FEATURE_COMPAT_DIR_INDEX) && \ | 1457 | EXT4_FEATURE_COMPAT_DIR_INDEX) && \ |
1267 | (EXT4_I(dir)->i_flags & EXT4_INDEX_FL)) | 1458 | ext4_test_inode_flag((dir), EXT4_INODE_INDEX)) |
1268 | #define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX) | 1459 | #define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX) |
1269 | #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) | 1460 | #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) |
1270 | 1461 | ||
@@ -1389,16 +1580,18 @@ extern unsigned ext4_init_block_bitmap(struct super_block *sb, | |||
1389 | ext4_init_block_bitmap(sb, NULL, group, desc) | 1580 | ext4_init_block_bitmap(sb, NULL, group, desc) |
1390 | 1581 | ||
1391 | /* dir.c */ | 1582 | /* dir.c */ |
1392 | extern int ext4_check_dir_entry(const char *, struct inode *, | 1583 | extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *, |
1393 | struct ext4_dir_entry_2 *, | 1584 | struct ext4_dir_entry_2 *, |
1394 | struct buffer_head *, unsigned int); | 1585 | struct buffer_head *, unsigned int); |
1586 | #define ext4_check_dir_entry(dir, de, bh, offset) \ | ||
1587 | __ext4_check_dir_entry(__func__, __LINE__, (dir), (de), (bh), (offset)) | ||
1395 | extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, | 1588 | extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, |
1396 | __u32 minor_hash, | 1589 | __u32 minor_hash, |
1397 | struct ext4_dir_entry_2 *dirent); | 1590 | struct ext4_dir_entry_2 *dirent); |
1398 | extern void ext4_htree_free_dir_info(struct dir_private_info *p); | 1591 | extern void ext4_htree_free_dir_info(struct dir_private_info *p); |
1399 | 1592 | ||
1400 | /* fsync.c */ | 1593 | /* fsync.c */ |
1401 | extern int ext4_sync_file(struct file *, struct dentry *, int); | 1594 | extern int ext4_sync_file(struct file *, int); |
1402 | 1595 | ||
1403 | /* hash.c */ | 1596 | /* hash.c */ |
1404 | extern int ext4fs_dirhash(const char *name, int len, struct | 1597 | extern int ext4fs_dirhash(const char *name, int len, struct |
@@ -1450,7 +1643,8 @@ extern int ext4_write_inode(struct inode *, struct writeback_control *); | |||
1450 | extern int ext4_setattr(struct dentry *, struct iattr *); | 1643 | extern int ext4_setattr(struct dentry *, struct iattr *); |
1451 | extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, | 1644 | extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, |
1452 | struct kstat *stat); | 1645 | struct kstat *stat); |
1453 | extern void ext4_delete_inode(struct inode *); | 1646 | extern void ext4_evict_inode(struct inode *); |
1647 | extern void ext4_clear_inode(struct inode *); | ||
1454 | extern int ext4_sync_inode(handle_t *, struct inode *); | 1648 | extern int ext4_sync_inode(handle_t *, struct inode *); |
1455 | extern void ext4_dirty_inode(struct inode *); | 1649 | extern void ext4_dirty_inode(struct inode *); |
1456 | extern int ext4_change_inode_journal_flag(struct inode *, int); | 1650 | extern int ext4_change_inode_journal_flag(struct inode *, int); |
@@ -1480,8 +1674,6 @@ extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long); | |||
1480 | extern int ext4_ext_migrate(struct inode *); | 1674 | extern int ext4_ext_migrate(struct inode *); |
1481 | 1675 | ||
1482 | /* namei.c */ | 1676 | /* namei.c */ |
1483 | extern unsigned int ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize); | ||
1484 | extern __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize); | ||
1485 | extern int ext4_orphan_add(handle_t *, struct inode *); | 1677 | extern int ext4_orphan_add(handle_t *, struct inode *); |
1486 | extern int ext4_orphan_del(handle_t *, struct inode *); | 1678 | extern int ext4_orphan_del(handle_t *, struct inode *); |
1487 | extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, | 1679 | extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, |
@@ -1495,25 +1687,38 @@ extern int ext4_group_extend(struct super_block *sb, | |||
1495 | ext4_fsblk_t n_blocks_count); | 1687 | ext4_fsblk_t n_blocks_count); |
1496 | 1688 | ||
1497 | /* super.c */ | 1689 | /* super.c */ |
1498 | extern void __ext4_error(struct super_block *, const char *, const char *, ...) | 1690 | extern void __ext4_error(struct super_block *, const char *, unsigned int, |
1499 | __attribute__ ((format (printf, 3, 4))); | 1691 | const char *, ...) |
1500 | #define ext4_error(sb, message...) __ext4_error(sb, __func__, ## message) | 1692 | __attribute__ ((format (printf, 4, 5))); |
1501 | extern void ext4_error_inode(const char *, struct inode *, const char *, ...) | 1693 | #define ext4_error(sb, message...) __ext4_error(sb, __func__, \ |
1502 | __attribute__ ((format (printf, 3, 4))); | 1694 | __LINE__, ## message) |
1503 | extern void ext4_error_file(const char *, struct file *, const char *, ...) | 1695 | extern void ext4_error_inode(struct inode *, const char *, unsigned int, |
1504 | __attribute__ ((format (printf, 3, 4))); | 1696 | ext4_fsblk_t, const char *, ...) |
1505 | extern void __ext4_std_error(struct super_block *, const char *, int); | 1697 | __attribute__ ((format (printf, 5, 6))); |
1506 | extern void ext4_abort(struct super_block *, const char *, const char *, ...) | 1698 | extern void ext4_error_file(struct file *, const char *, unsigned int, |
1507 | __attribute__ ((format (printf, 3, 4))); | 1699 | const char *, ...) |
1508 | extern void __ext4_warning(struct super_block *, const char *, | 1700 | __attribute__ ((format (printf, 4, 5))); |
1701 | extern void __ext4_std_error(struct super_block *, const char *, | ||
1702 | unsigned int, int); | ||
1703 | extern void __ext4_abort(struct super_block *, const char *, unsigned int, | ||
1704 | const char *, ...) | ||
1705 | __attribute__ ((format (printf, 4, 5))); | ||
1706 | #define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \ | ||
1707 | __LINE__, ## message) | ||
1708 | extern void __ext4_warning(struct super_block *, const char *, unsigned int, | ||
1509 | const char *, ...) | 1709 | const char *, ...) |
1510 | __attribute__ ((format (printf, 3, 4))); | 1710 | __attribute__ ((format (printf, 4, 5))); |
1511 | #define ext4_warning(sb, message...) __ext4_warning(sb, __func__, ## message) | 1711 | #define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \ |
1712 | __LINE__, ## message) | ||
1512 | extern void ext4_msg(struct super_block *, const char *, const char *, ...) | 1713 | extern void ext4_msg(struct super_block *, const char *, const char *, ...) |
1513 | __attribute__ ((format (printf, 3, 4))); | 1714 | __attribute__ ((format (printf, 3, 4))); |
1514 | extern void ext4_grp_locked_error(struct super_block *, ext4_group_t, | 1715 | extern void __ext4_grp_locked_error(const char *, unsigned int, \ |
1515 | const char *, const char *, ...) | 1716 | struct super_block *, ext4_group_t, \ |
1516 | __attribute__ ((format (printf, 4, 5))); | 1717 | unsigned long, ext4_fsblk_t, \ |
1718 | const char *, ...) | ||
1719 | __attribute__ ((format (printf, 7, 8))); | ||
1720 | #define ext4_grp_locked_error(sb, grp, message...) \ | ||
1721 | __ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message) | ||
1517 | extern void ext4_update_dynamic_rev(struct super_block *sb); | 1722 | extern void ext4_update_dynamic_rev(struct super_block *sb); |
1518 | extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb, | 1723 | extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb, |
1519 | __u32 compat); | 1724 | __u32 compat); |
@@ -1647,7 +1852,7 @@ static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi) | |||
1647 | #define ext4_std_error(sb, errno) \ | 1852 | #define ext4_std_error(sb, errno) \ |
1648 | do { \ | 1853 | do { \ |
1649 | if ((errno)) \ | 1854 | if ((errno)) \ |
1650 | __ext4_std_error((sb), __func__, (errno)); \ | 1855 | __ext4_std_error((sb), __func__, __LINE__, (errno)); \ |
1651 | } while (0) | 1856 | } while (0) |
1652 | 1857 | ||
1653 | #ifdef CONFIG_SMP | 1858 | #ifdef CONFIG_SMP |
@@ -1678,6 +1883,7 @@ struct ext4_group_info { | |||
1678 | ext4_grpblk_t bb_first_free; /* first free block */ | 1883 | ext4_grpblk_t bb_first_free; /* first free block */ |
1679 | ext4_grpblk_t bb_free; /* total free blocks */ | 1884 | ext4_grpblk_t bb_free; /* total free blocks */ |
1680 | ext4_grpblk_t bb_fragments; /* nr of freespace fragments */ | 1885 | ext4_grpblk_t bb_fragments; /* nr of freespace fragments */ |
1886 | ext4_grpblk_t bb_largest_free_order;/* order of largest frag in BG */ | ||
1681 | struct list_head bb_prealloc_list; | 1887 | struct list_head bb_prealloc_list; |
1682 | #ifdef DOUBLE_CHECK | 1888 | #ifdef DOUBLE_CHECK |
1683 | void *bb_bitmap; | 1889 | void *bb_bitmap; |
@@ -1738,6 +1944,12 @@ static inline void ext4_unlock_group(struct super_block *sb, | |||
1738 | spin_unlock(ext4_group_lock_ptr(sb, group)); | 1944 | spin_unlock(ext4_group_lock_ptr(sb, group)); |
1739 | } | 1945 | } |
1740 | 1946 | ||
1947 | static inline void ext4_mark_super_dirty(struct super_block *sb) | ||
1948 | { | ||
1949 | if (EXT4_SB(sb)->s_journal == NULL) | ||
1950 | sb->s_dirt =1; | ||
1951 | } | ||
1952 | |||
1741 | /* | 1953 | /* |
1742 | * Inodes and files operations | 1954 | * Inodes and files operations |
1743 | */ | 1955 | */ |
@@ -1772,9 +1984,8 @@ extern int ext4_ext_tree_init(handle_t *handle, struct inode *); | |||
1772 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); | 1984 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); |
1773 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, | 1985 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks, |
1774 | int chunk); | 1986 | int chunk); |
1775 | extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | 1987 | extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, |
1776 | ext4_lblk_t iblock, unsigned int max_blocks, | 1988 | struct ext4_map_blocks *map, int flags); |
1777 | struct buffer_head *bh_result, int flags); | ||
1778 | extern void ext4_ext_truncate(struct inode *); | 1989 | extern void ext4_ext_truncate(struct inode *); |
1779 | extern void ext4_ext_init(struct super_block *); | 1990 | extern void ext4_ext_init(struct super_block *); |
1780 | extern void ext4_ext_release(struct super_block *); | 1991 | extern void ext4_ext_release(struct super_block *); |
@@ -1782,9 +1993,8 @@ extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, | |||
1782 | loff_t len); | 1993 | loff_t len); |
1783 | extern int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, | 1994 | extern int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, |
1784 | ssize_t len); | 1995 | ssize_t len); |
1785 | extern int ext4_get_blocks(handle_t *handle, struct inode *inode, | 1996 | extern int ext4_map_blocks(handle_t *handle, struct inode *inode, |
1786 | sector_t block, unsigned int max_blocks, | 1997 | struct ext4_map_blocks *map, int flags); |
1787 | struct buffer_head *bh, int flags); | ||
1788 | extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | 1998 | extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
1789 | __u64 start, __u64 len); | 1999 | __u64 start, __u64 len); |
1790 | /* move_extent.c */ | 2000 | /* move_extent.c */ |