aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2012-03-19 23:05:43 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-03-19 23:05:43 -0400
commit7877191c28b1e140795c0c951dde8aad43757378 (patch)
tree2ce9989e43ad3a072a109e6df8a7cb1939f55e6b /fs
parent5f95d21fb6f2aaa52830e5b7fb405f6c71d3ab85 (diff)
ext4: remove unused code from ext4_ext_map_blocks()
Since the commit 'Rewrite punch hole to use ext4_ext_remove_space()' reworked the punch hole implementation to use ext4_ext_remove_space() instead of ext4_ext_map_blocks(), we can remove the code which is no longer needed from the ext4_ext_map_blocks(). Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/extents.c119
1 files changed, 13 insertions, 106 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 4726a3a447a5..9ac89b671047 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3776,8 +3776,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
3776 int free_on_err = 0, err = 0, depth, ret; 3776 int free_on_err = 0, err = 0, depth, ret;
3777 unsigned int allocated = 0, offset = 0; 3777 unsigned int allocated = 0, offset = 0;
3778 unsigned int allocated_clusters = 0; 3778 unsigned int allocated_clusters = 0;
3779 unsigned int punched_out = 0;
3780 unsigned int result = 0;
3781 struct ext4_allocation_request ar; 3779 struct ext4_allocation_request ar;
3782 ext4_io_end_t *io = EXT4_I(inode)->cur_aio_dio; 3780 ext4_io_end_t *io = EXT4_I(inode)->cur_aio_dio;
3783 ext4_lblk_t cluster_offset; 3781 ext4_lblk_t cluster_offset;
@@ -3787,8 +3785,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
3787 trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags); 3785 trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);
3788 3786
3789 /* check in cache */ 3787 /* check in cache */
3790 if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) && 3788 if (ext4_ext_in_cache(inode, map->m_lblk, &newex)) {
3791 ext4_ext_in_cache(inode, map->m_lblk, &newex)) {
3792 if (!newex.ee_start_lo && !newex.ee_start_hi) { 3789 if (!newex.ee_start_lo && !newex.ee_start_hi) {
3793 if ((sbi->s_cluster_ratio > 1) && 3790 if ((sbi->s_cluster_ratio > 1) &&
3794 ext4_find_delalloc_cluster(inode, map->m_lblk, 0)) 3791 ext4_find_delalloc_cluster(inode, map->m_lblk, 0))
@@ -3856,113 +3853,25 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
3856 3853
3857 /* if found extent covers block, simply return it */ 3854 /* if found extent covers block, simply return it */
3858 if (in_range(map->m_lblk, ee_block, ee_len)) { 3855 if (in_range(map->m_lblk, ee_block, ee_len)) {
3859 struct ext4_map_blocks punch_map;
3860 ext4_fsblk_t partial_cluster = 0;
3861
3862 newblock = map->m_lblk - ee_block + ee_start; 3856 newblock = map->m_lblk - ee_block + ee_start;
3863 /* number of remaining blocks in the extent */ 3857 /* number of remaining blocks in the extent */
3864 allocated = ee_len - (map->m_lblk - ee_block); 3858 allocated = ee_len - (map->m_lblk - ee_block);
3865 ext_debug("%u fit into %u:%d -> %llu\n", map->m_lblk, 3859 ext_debug("%u fit into %u:%d -> %llu\n", map->m_lblk,
3866 ee_block, ee_len, newblock); 3860 ee_block, ee_len, newblock);
3867 3861
3868 if ((flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) == 0) {
3869 /*
3870 * Do not put uninitialized extent
3871 * in the cache
3872 */
3873 if (!ext4_ext_is_uninitialized(ex)) {
3874 ext4_ext_put_in_cache(inode, ee_block,
3875 ee_len, ee_start);
3876 goto out;
3877 }
3878 ret = ext4_ext_handle_uninitialized_extents(
3879 handle, inode, map, path, flags,
3880 allocated, newblock);
3881 return ret;
3882 }
3883
3884 /*
3885 * Punch out the map length, but only to the
3886 * end of the extent
3887 */
3888 punched_out = allocated < map->m_len ?
3889 allocated : map->m_len;
3890
3891 /* 3862 /*
3892 * Sense extents need to be converted to 3863 * Do not put uninitialized extent
3893 * uninitialized, they must fit in an 3864 * in the cache
3894 * uninitialized extent
3895 */ 3865 */
3896 if (punched_out > EXT_UNINIT_MAX_LEN) 3866 if (!ext4_ext_is_uninitialized(ex)) {
3897 punched_out = EXT_UNINIT_MAX_LEN; 3867 ext4_ext_put_in_cache(inode, ee_block,
3898 3868 ee_len, ee_start);
3899 punch_map.m_lblk = map->m_lblk; 3869 goto out;
3900 punch_map.m_pblk = newblock;
3901 punch_map.m_len = punched_out;
3902 punch_map.m_flags = 0;
3903
3904 /* Check to see if the extent needs to be split */
3905 if (punch_map.m_len != ee_len ||
3906 punch_map.m_lblk != ee_block) {
3907
3908 ret = ext4_split_extent(handle, inode,
3909 path, &punch_map, 0,
3910 EXT4_GET_BLOCKS_PUNCH_OUT_EXT |
3911 EXT4_GET_BLOCKS_PRE_IO);
3912
3913 if (ret < 0) {
3914 err = ret;
3915 goto out2;
3916 }
3917 /*
3918 * find extent for the block at
3919 * the start of the hole
3920 */
3921 ext4_ext_drop_refs(path);
3922 kfree(path);
3923
3924 path = ext4_ext_find_extent(inode,
3925 map->m_lblk, NULL);
3926 if (IS_ERR(path)) {
3927 err = PTR_ERR(path);
3928 path = NULL;
3929 goto out2;
3930 }
3931
3932 depth = ext_depth(inode);
3933 ex = path[depth].p_ext;
3934 ee_len = ext4_ext_get_actual_len(ex);
3935 ee_block = le32_to_cpu(ex->ee_block);
3936 ee_start = ext4_ext_pblock(ex);
3937
3938 }
3939
3940 ext4_ext_mark_uninitialized(ex);
3941
3942 ext4_ext_invalidate_cache(inode);
3943
3944 err = ext4_ext_rm_leaf(handle, inode, path,
3945 &partial_cluster, map->m_lblk,
3946 map->m_lblk + punched_out);
3947
3948 if (!err && path->p_hdr->eh_entries == 0) {
3949 /*
3950 * Punch hole freed all of this sub tree,
3951 * so we need to correct eh_depth
3952 */
3953 err = ext4_ext_get_access(handle, inode, path);
3954 if (err == 0) {
3955 ext_inode_hdr(inode)->eh_depth = 0;
3956 ext_inode_hdr(inode)->eh_max =
3957 cpu_to_le16(ext4_ext_space_root(
3958 inode, 0));
3959
3960 err = ext4_ext_dirty(
3961 handle, inode, path);
3962 }
3963 } 3870 }
3964 3871 ret = ext4_ext_handle_uninitialized_extents(
3965 goto out2; 3872 handle, inode, map, path, flags,
3873 allocated, newblock);
3874 return ret;
3966 } 3875 }
3967 } 3876 }
3968 3877
@@ -4231,13 +4140,11 @@ out2:
4231 ext4_ext_drop_refs(path); 4140 ext4_ext_drop_refs(path);
4232 kfree(path); 4141 kfree(path);
4233 } 4142 }
4234 result = (flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) ?
4235 punched_out : allocated;
4236 4143
4237 trace_ext4_ext_map_blocks_exit(inode, map->m_lblk, 4144 trace_ext4_ext_map_blocks_exit(inode, map->m_lblk,
4238 newblock, map->m_len, err ? err : result); 4145 newblock, map->m_len, err ? err : allocated);
4239 4146
4240 return err ? err : result; 4147 return err ? err : allocated;
4241} 4148}
4242 4149
4243void ext4_ext_truncate(struct inode *inode) 4150void ext4_ext_truncate(struct inode *inode)