aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/extents.c
diff options
context:
space:
mode:
authorZheng Liu <wenqing.lz@taobao.com>2013-03-10 21:20:23 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-03-10 21:20:23 -0400
commit3a2256702e47f68f921dfad41b1764d05c572329 (patch)
tree977a89ffbb1bd91cc6ebe001c9820a496ea24073 /fs/ext4/extents.c
parentadb2355104b2109e06ba5276485d187d023b2fd2 (diff)
ext4: fix the wrong number of the allocated blocks in ext4_split_extent()
This commit fixes a wrong return value of the number of the allocated blocks in ext4_split_extent. When the length of blocks we want to allocate is greater than the length of the current extent, we return a wrong number. Let's see what happens in the following case when we call ext4_split_extent(). map: [48, 72] ex: [32, 64, u] 'ex' will be split into two parts: ex1: [32, 47, u] ex2: [48, 64, w] 'map->m_len' is returned from this function, and the value is 24. But the real length is 16. So it should be fixed. Meanwhile in this commit we use right length of the allocated blocks when get_reserved_cluster_alloc in ext4_ext_handle_uninitialized_extents is called. Signed-off-by: Zheng Liu <wenqing.lz@taobao.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Dmitry Monakhov <dmonakhov@openvz.org> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r--fs/ext4/extents.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 7e37018d1753..69df02ff96aa 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3067,6 +3067,7 @@ static int ext4_split_extent(handle_t *handle,
3067 int err = 0; 3067 int err = 0;
3068 int uninitialized; 3068 int uninitialized;
3069 int split_flag1, flags1; 3069 int split_flag1, flags1;
3070 int allocated = map->m_len;
3070 3071
3071 depth = ext_depth(inode); 3072 depth = ext_depth(inode);
3072 ex = path[depth].p_ext; 3073 ex = path[depth].p_ext;
@@ -3086,6 +3087,8 @@ static int ext4_split_extent(handle_t *handle,
3086 map->m_lblk + map->m_len, split_flag1, flags1); 3087 map->m_lblk + map->m_len, split_flag1, flags1);
3087 if (err) 3088 if (err)
3088 goto out; 3089 goto out;
3090 } else {
3091 allocated = ee_len - (map->m_lblk - ee_block);
3089 } 3092 }
3090 /* 3093 /*
3091 * Update path is required because previous ext4_split_extent_at() may 3094 * Update path is required because previous ext4_split_extent_at() may
@@ -3115,7 +3118,7 @@ static int ext4_split_extent(handle_t *handle,
3115 3118
3116 ext4_ext_show_leaf(inode, path); 3119 ext4_ext_show_leaf(inode, path);
3117out: 3120out:
3118 return err ? err : map->m_len; 3121 return err ? err : allocated;
3119} 3122}
3120 3123
3121/* 3124/*
@@ -3730,6 +3733,7 @@ out:
3730 allocated - map->m_len); 3733 allocated - map->m_len);
3731 allocated = map->m_len; 3734 allocated = map->m_len;
3732 } 3735 }
3736 map->m_len = allocated;
3733 3737
3734 /* 3738 /*
3735 * If we have done fallocate with the offset that is already 3739 * If we have done fallocate with the offset that is already