diff options
| author | Zheng Liu <wenqing.lz@taobao.com> | 2013-08-28 14:47:06 -0400 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2013-08-28 14:47:06 -0400 |
| commit | d7b2a00c2e2eedf460ce2a15237f28de40412d86 (patch) | |
| tree | 5a6b062e0973a84cab9b66f75a7a573361ccdf69 | |
| parent | 70261f568f3c08552f034742e3d5cb78c3877766 (diff) | |
ext4: isolate ext4_extents.h file
After applied the commit (4a092d73), we have reduced the number of
source files that need to #include ext4_extents.h. But we can do
better.
This commit defines ext4_zeroout_es() in extents.c and move
EXT_MAX_BLOCKS into ext4.h in order not to include ext4_extents.h in
indirect.c and ioctl.c. Meanwhile we just need to include this file in
extent_status.c when ES_AGGRESSIVE_TEST is defined. Otherwise, this
commit removes a duplicated declaration in trace/events/ext4.h.
After applied this patch, we just need to include ext4_extents.h file
in {super,migrate,move_extents,extents}.c, and it is easy for us to
define a new extent disk layout.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
| -rw-r--r-- | fs/ext4/ext4.h | 6 | ||||
| -rw-r--r-- | fs/ext4/ext4_extents.h | 6 | ||||
| -rw-r--r-- | fs/ext4/extents.c | 21 | ||||
| -rw-r--r-- | fs/ext4/extents_status.c | 20 | ||||
| -rw-r--r-- | fs/ext4/extents_status.h | 1 | ||||
| -rw-r--r-- | fs/ext4/indirect.c | 1 | ||||
| -rw-r--r-- | fs/ext4/ioctl.c | 1 | ||||
| -rw-r--r-- | include/trace/events/ext4.h | 1 |
8 files changed, 27 insertions, 30 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 3dbc56eb4849..28896655ad41 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
| @@ -2686,6 +2686,12 @@ extern int ext4_check_blockref(const char *, unsigned int, | |||
| 2686 | struct ext4_ext_path; | 2686 | struct ext4_ext_path; |
| 2687 | struct ext4_extent; | 2687 | struct ext4_extent; |
| 2688 | 2688 | ||
| 2689 | /* | ||
| 2690 | * Maximum number of logical blocks in a file; ext4_extent's ee_block is | ||
| 2691 | * __le32. | ||
| 2692 | */ | ||
| 2693 | #define EXT_MAX_BLOCKS 0xffffffff | ||
| 2694 | |||
| 2689 | extern int ext4_ext_tree_init(handle_t *handle, struct inode *); | 2695 | extern int ext4_ext_tree_init(handle_t *handle, struct inode *); |
| 2690 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); | 2696 | extern int ext4_ext_writepage_trans_blocks(struct inode *, int); |
| 2691 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents); | 2697 | extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents); |
diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h index 51bc821ade90..5074fe23f19e 100644 --- a/fs/ext4/ext4_extents.h +++ b/fs/ext4/ext4_extents.h | |||
| @@ -134,12 +134,6 @@ struct ext4_ext_path { | |||
| 134 | */ | 134 | */ |
| 135 | 135 | ||
| 136 | /* | 136 | /* |
| 137 | * Maximum number of logical blocks in a file; ext4_extent's ee_block is | ||
| 138 | * __le32. | ||
| 139 | */ | ||
| 140 | #define EXT_MAX_BLOCKS 0xffffffff | ||
| 141 | |||
| 142 | /* | ||
| 143 | * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an | 137 | * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an |
| 144 | * initialized extent. This is 2^15 and not (2^16 - 1), since we use the | 138 | * initialized extent. This is 2^15 and not (2^16 - 1), since we use the |
| 145 | * MSB of ee_len field in the extent datastructure to signify if this | 139 | * MSB of ee_len field in the extent datastructure to signify if this |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 916e88498c87..54d52afcdb19 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
| @@ -3048,6 +3048,23 @@ void ext4_ext_release(struct super_block *sb) | |||
| 3048 | #endif | 3048 | #endif |
| 3049 | } | 3049 | } |
| 3050 | 3050 | ||
| 3051 | static int ext4_zeroout_es(struct inode *inode, struct ext4_extent *ex) | ||
| 3052 | { | ||
| 3053 | ext4_lblk_t ee_block; | ||
| 3054 | ext4_fsblk_t ee_pblock; | ||
| 3055 | unsigned int ee_len; | ||
| 3056 | |||
| 3057 | ee_block = le32_to_cpu(ex->ee_block); | ||
| 3058 | ee_len = ext4_ext_get_actual_len(ex); | ||
| 3059 | ee_pblock = ext4_ext_pblock(ex); | ||
| 3060 | |||
| 3061 | if (ee_len == 0) | ||
| 3062 | return 0; | ||
| 3063 | |||
| 3064 | return ext4_es_insert_extent(inode, ee_block, ee_len, ee_pblock, | ||
| 3065 | EXTENT_STATUS_WRITTEN); | ||
| 3066 | } | ||
| 3067 | |||
| 3051 | /* FIXME!! we need to try to merge to left or right after zero-out */ | 3068 | /* FIXME!! we need to try to merge to left or right after zero-out */ |
| 3052 | static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex) | 3069 | static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex) |
| 3053 | { | 3070 | { |
| @@ -3200,7 +3217,7 @@ static int ext4_split_extent_at(handle_t *handle, | |||
| 3200 | goto fix_extent_len; | 3217 | goto fix_extent_len; |
| 3201 | 3218 | ||
| 3202 | /* update extent status tree */ | 3219 | /* update extent status tree */ |
| 3203 | err = ext4_es_zeroout(inode, &zero_ex); | 3220 | err = ext4_zeroout_es(inode, &zero_ex); |
| 3204 | 3221 | ||
| 3205 | goto out; | 3222 | goto out; |
| 3206 | } else if (err) | 3223 | } else if (err) |
| @@ -3551,7 +3568,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, | |||
| 3551 | out: | 3568 | out: |
| 3552 | /* If we have gotten a failure, don't zero out status tree */ | 3569 | /* If we have gotten a failure, don't zero out status tree */ |
| 3553 | if (!err) | 3570 | if (!err) |
| 3554 | err = ext4_es_zeroout(inode, &zero_ex); | 3571 | err = ext4_zeroout_es(inode, &zero_ex); |
| 3555 | return err ? err : allocated; | 3572 | return err ? err : allocated; |
| 3556 | } | 3573 | } |
| 3557 | 3574 | ||
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 0e88a367b535..2d1bdbe78c04 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | #include <linux/list_sort.h> | 13 | #include <linux/list_sort.h> |
| 14 | #include "ext4.h" | 14 | #include "ext4.h" |
| 15 | #include "extents_status.h" | 15 | #include "extents_status.h" |
| 16 | #include "ext4_extents.h" | ||
| 17 | 16 | ||
| 18 | #include <trace/events/ext4.h> | 17 | #include <trace/events/ext4.h> |
| 19 | 18 | ||
| @@ -409,6 +408,8 @@ ext4_es_try_to_merge_right(struct inode *inode, struct extent_status *es) | |||
| 409 | } | 408 | } |
| 410 | 409 | ||
| 411 | #ifdef ES_AGGRESSIVE_TEST | 410 | #ifdef ES_AGGRESSIVE_TEST |
| 411 | #include "ext4_extents.h" /* Needed when ES_AGGRESSIVE_TEST is defined */ | ||
| 412 | |||
| 412 | static void ext4_es_insert_extent_ext_check(struct inode *inode, | 413 | static void ext4_es_insert_extent_ext_check(struct inode *inode, |
| 413 | struct extent_status *es) | 414 | struct extent_status *es) |
| 414 | { | 415 | { |
| @@ -903,23 +904,6 @@ int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk, | |||
| 903 | return err; | 904 | return err; |
| 904 | } | 905 | } |
| 905 | 906 | ||
| 906 | int ext4_es_zeroout(struct inode *inode, struct ext4_extent *ex) | ||
| 907 | { | ||
| 908 | ext4_lblk_t ee_block; | ||
| 909 | ext4_fsblk_t ee_pblock; | ||
| 910 | unsigned int ee_len; | ||
| 911 | |||
| 912 | ee_block = le32_to_cpu(ex->ee_block); | ||
| 913 | ee_len = ext4_ext_get_actual_len(ex); | ||
| 914 | ee_pblock = ext4_ext_pblock(ex); | ||
| 915 | |||
| 916 | if (ee_len == 0) | ||
| 917 | return 0; | ||
| 918 | |||
| 919 | return ext4_es_insert_extent(inode, ee_block, ee_len, ee_pblock, | ||
| 920 | EXTENT_STATUS_WRITTEN); | ||
| 921 | } | ||
| 922 | |||
| 923 | static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a, | 907 | static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a, |
| 924 | struct list_head *b) | 908 | struct list_head *b) |
| 925 | { | 909 | { |
diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h index 3e83aef3653a..167f4ab8ecc3 100644 --- a/fs/ext4/extents_status.h +++ b/fs/ext4/extents_status.h | |||
| @@ -81,7 +81,6 @@ extern void ext4_es_find_delayed_extent_range(struct inode *inode, | |||
| 81 | struct extent_status *es); | 81 | struct extent_status *es); |
| 82 | extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, | 82 | extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, |
| 83 | struct extent_status *es); | 83 | struct extent_status *es); |
| 84 | extern int ext4_es_zeroout(struct inode *inode, struct ext4_extent *ex); | ||
| 85 | 84 | ||
| 86 | static inline int ext4_es_is_written(struct extent_status *es) | 85 | static inline int ext4_es_is_written(struct extent_status *es) |
| 87 | { | 86 | { |
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c index 87b30cd357e7..594009f5f523 100644 --- a/fs/ext4/indirect.c +++ b/fs/ext4/indirect.c | |||
| @@ -23,7 +23,6 @@ | |||
| 23 | #include <linux/aio.h> | 23 | #include <linux/aio.h> |
| 24 | #include "ext4_jbd2.h" | 24 | #include "ext4_jbd2.h" |
| 25 | #include "truncate.h" | 25 | #include "truncate.h" |
| 26 | #include "ext4_extents.h" /* Needed for EXT_MAX_BLOCKS */ | ||
| 27 | 26 | ||
| 28 | #include <trace/events/ext4.h> | 27 | #include <trace/events/ext4.h> |
| 29 | 28 | ||
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 5498f75a1648..a569d335f804 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
| 18 | #include "ext4_jbd2.h" | 18 | #include "ext4_jbd2.h" |
| 19 | #include "ext4.h" | 19 | #include "ext4.h" |
| 20 | #include "ext4_extents.h" | ||
| 21 | 20 | ||
| 22 | #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1) | 21 | #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1) |
| 23 | 22 | ||
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index d892b55d91ab..197d3125df2a 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h | |||
| @@ -14,7 +14,6 @@ struct ext4_prealloc_space; | |||
| 14 | struct ext4_inode_info; | 14 | struct ext4_inode_info; |
| 15 | struct mpage_da_data; | 15 | struct mpage_da_data; |
| 16 | struct ext4_map_blocks; | 16 | struct ext4_map_blocks; |
| 17 | struct ext4_extent; | ||
| 18 | struct extent_status; | 17 | struct extent_status; |
| 19 | 18 | ||
| 20 | #define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode)) | 19 | #define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode)) |
