diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-05-14 00:58:52 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-05-14 00:58:52 -0400 |
commit | c21770573319922e3f3fcb331cfaa290c49f1c81 (patch) | |
tree | ee21ebb2d73d4d3b19d7e391e7accf00704371d9 /fs/ext4/extents.c | |
parent | 12b7ac176831df1aa58a787e67c3e5d698b30163 (diff) |
ext4: Define a new set of flags for ext4_get_blocks()
The functions ext4_get_blocks(), ext4_ext_get_blocks(), and
ext4_ind_get_blocks() used an ad-hoc set of integer variables used as
boolean flags passed in as arguments. Use a single flags parameter
and a setandard set of bitfield flags instead. This saves space on
the call stack, and it also makes the code a bit more understandable.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 7e7d02dd2739..27c383c7b43c 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -2784,7 +2784,7 @@ fix_extent_len: | |||
2784 | int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | 2784 | int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, |
2785 | ext4_lblk_t iblock, | 2785 | ext4_lblk_t iblock, |
2786 | unsigned int max_blocks, struct buffer_head *bh_result, | 2786 | unsigned int max_blocks, struct buffer_head *bh_result, |
2787 | int create, int extend_disksize) | 2787 | int flags) |
2788 | { | 2788 | { |
2789 | struct ext4_ext_path *path = NULL; | 2789 | struct ext4_ext_path *path = NULL; |
2790 | struct ext4_extent_header *eh; | 2790 | struct ext4_extent_header *eh; |
@@ -2803,7 +2803,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
2803 | cache_type = ext4_ext_in_cache(inode, iblock, &newex); | 2803 | cache_type = ext4_ext_in_cache(inode, iblock, &newex); |
2804 | if (cache_type) { | 2804 | if (cache_type) { |
2805 | if (cache_type == EXT4_EXT_CACHE_GAP) { | 2805 | if (cache_type == EXT4_EXT_CACHE_GAP) { |
2806 | if (!create) { | 2806 | if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { |
2807 | /* | 2807 | /* |
2808 | * block isn't allocated yet and | 2808 | * block isn't allocated yet and |
2809 | * user doesn't want to allocate it | 2809 | * user doesn't want to allocate it |
@@ -2869,9 +2869,9 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
2869 | EXT4_EXT_CACHE_EXTENT); | 2869 | EXT4_EXT_CACHE_EXTENT); |
2870 | goto out; | 2870 | goto out; |
2871 | } | 2871 | } |
2872 | if (create == EXT4_CREATE_UNINITIALIZED_EXT) | 2872 | if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) |
2873 | goto out; | 2873 | goto out; |
2874 | if (!create) { | 2874 | if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { |
2875 | if (allocated > max_blocks) | 2875 | if (allocated > max_blocks) |
2876 | allocated = max_blocks; | 2876 | allocated = max_blocks; |
2877 | /* | 2877 | /* |
@@ -2903,7 +2903,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
2903 | * requested block isn't allocated yet; | 2903 | * requested block isn't allocated yet; |
2904 | * we couldn't try to create block if create flag is zero | 2904 | * we couldn't try to create block if create flag is zero |
2905 | */ | 2905 | */ |
2906 | if (!create) { | 2906 | if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { |
2907 | /* | 2907 | /* |
2908 | * put just found gap into cache to speed up | 2908 | * put just found gap into cache to speed up |
2909 | * subsequent requests | 2909 | * subsequent requests |
@@ -2932,10 +2932,10 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
2932 | * EXT_UNINIT_MAX_LEN. | 2932 | * EXT_UNINIT_MAX_LEN. |
2933 | */ | 2933 | */ |
2934 | if (max_blocks > EXT_INIT_MAX_LEN && | 2934 | if (max_blocks > EXT_INIT_MAX_LEN && |
2935 | create != EXT4_CREATE_UNINITIALIZED_EXT) | 2935 | !(flags & EXT4_GET_BLOCKS_UNINIT_EXT)) |
2936 | max_blocks = EXT_INIT_MAX_LEN; | 2936 | max_blocks = EXT_INIT_MAX_LEN; |
2937 | else if (max_blocks > EXT_UNINIT_MAX_LEN && | 2937 | else if (max_blocks > EXT_UNINIT_MAX_LEN && |
2938 | create == EXT4_CREATE_UNINITIALIZED_EXT) | 2938 | (flags & EXT4_GET_BLOCKS_UNINIT_EXT)) |
2939 | max_blocks = EXT_UNINIT_MAX_LEN; | 2939 | max_blocks = EXT_UNINIT_MAX_LEN; |
2940 | 2940 | ||
2941 | /* Check if we can really insert (iblock)::(iblock+max_blocks) extent */ | 2941 | /* Check if we can really insert (iblock)::(iblock+max_blocks) extent */ |
@@ -2966,7 +2966,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
2966 | /* try to insert new extent into found leaf and return */ | 2966 | /* try to insert new extent into found leaf and return */ |
2967 | ext4_ext_store_pblock(&newex, newblock); | 2967 | ext4_ext_store_pblock(&newex, newblock); |
2968 | newex.ee_len = cpu_to_le16(ar.len); | 2968 | newex.ee_len = cpu_to_le16(ar.len); |
2969 | if (create == EXT4_CREATE_UNINITIALIZED_EXT) /* Mark uninitialized */ | 2969 | if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) /* Mark uninitialized */ |
2970 | ext4_ext_mark_uninitialized(&newex); | 2970 | ext4_ext_mark_uninitialized(&newex); |
2971 | err = ext4_ext_insert_extent(handle, inode, path, &newex); | 2971 | err = ext4_ext_insert_extent(handle, inode, path, &newex); |
2972 | if (err) { | 2972 | if (err) { |
@@ -2983,7 +2983,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, | |||
2983 | newblock = ext_pblock(&newex); | 2983 | newblock = ext_pblock(&newex); |
2984 | allocated = ext4_ext_get_actual_len(&newex); | 2984 | allocated = ext4_ext_get_actual_len(&newex); |
2985 | outnew: | 2985 | outnew: |
2986 | if (extend_disksize) { | 2986 | if (flags & EXT4_GET_BLOCKS_EXTEND_DISKSIZE) { |
2987 | disksize = ((loff_t) iblock + ar.len) << inode->i_blkbits; | 2987 | disksize = ((loff_t) iblock + ar.len) << inode->i_blkbits; |
2988 | if (disksize > i_size_read(inode)) | 2988 | if (disksize > i_size_read(inode)) |
2989 | disksize = i_size_read(inode); | 2989 | disksize = i_size_read(inode); |
@@ -2994,7 +2994,7 @@ outnew: | |||
2994 | set_buffer_new(bh_result); | 2994 | set_buffer_new(bh_result); |
2995 | 2995 | ||
2996 | /* Cache only when it is _not_ an uninitialized extent */ | 2996 | /* Cache only when it is _not_ an uninitialized extent */ |
2997 | if (create != EXT4_CREATE_UNINITIALIZED_EXT) | 2997 | if ((flags & EXT4_GET_BLOCKS_UNINIT_EXT) == 0) |
2998 | ext4_ext_put_in_cache(inode, iblock, allocated, newblock, | 2998 | ext4_ext_put_in_cache(inode, iblock, allocated, newblock, |
2999 | EXT4_EXT_CACHE_EXTENT); | 2999 | EXT4_EXT_CACHE_EXTENT); |
3000 | out: | 3000 | out: |
@@ -3153,7 +3153,7 @@ retry: | |||
3153 | map_bh.b_state = 0; | 3153 | map_bh.b_state = 0; |
3154 | ret = ext4_get_blocks(handle, inode, block, | 3154 | ret = ext4_get_blocks(handle, inode, block, |
3155 | max_blocks, &map_bh, | 3155 | max_blocks, &map_bh, |
3156 | EXT4_CREATE_UNINITIALIZED_EXT, 0, 0); | 3156 | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT); |
3157 | if (ret <= 0) { | 3157 | if (ret <= 0) { |
3158 | #ifdef EXT4FS_DEBUG | 3158 | #ifdef EXT4FS_DEBUG |
3159 | WARN_ON(ret <= 0); | 3159 | WARN_ON(ret <= 0); |