diff options
author | Yongqiang Yang <xiaoqiangnk@gmail.com> | 2012-09-05 01:21:50 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-09-05 01:21:50 -0400 |
commit | 03c1c29053f678234dbd51bf3d65f3b7529021de (patch) | |
tree | 7f46e690871d24c4bc28911685ea2662d66688e5 /fs/ext4 | |
parent | 8a2f8460e816f4786939a0cefbda35af6bd1a1c5 (diff) |
ext4: ignore last group w/o enough space when resizing instead of BUG'ing
If the last group does not have enough space for group tables, ignore
it instead of calling BUG_ON().
Reported-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/resize.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 41f6ef68e2e1..28031c4e15e9 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -200,8 +200,11 @@ static void free_flex_gd(struct ext4_new_flex_group_data *flex_gd) | |||
200 | * be a partial of a flex group. | 200 | * be a partial of a flex group. |
201 | * | 201 | * |
202 | * @sb: super block of fs to which the groups belongs | 202 | * @sb: super block of fs to which the groups belongs |
203 | * | ||
204 | * Returns 0 on a successful allocation of the metadata blocks in the | ||
205 | * block group. | ||
203 | */ | 206 | */ |
204 | static void ext4_alloc_group_tables(struct super_block *sb, | 207 | static int ext4_alloc_group_tables(struct super_block *sb, |
205 | struct ext4_new_flex_group_data *flex_gd, | 208 | struct ext4_new_flex_group_data *flex_gd, |
206 | int flexbg_size) | 209 | int flexbg_size) |
207 | { | 210 | { |
@@ -226,6 +229,8 @@ static void ext4_alloc_group_tables(struct super_block *sb, | |||
226 | (last_group & ~(flexbg_size - 1)))); | 229 | (last_group & ~(flexbg_size - 1)))); |
227 | next_group: | 230 | next_group: |
228 | group = group_data[0].group; | 231 | group = group_data[0].group; |
232 | if (src_group >= group_data[0].group + flex_gd->count) | ||
233 | return -ENOSPC; | ||
229 | start_blk = ext4_group_first_block_no(sb, src_group); | 234 | start_blk = ext4_group_first_block_no(sb, src_group); |
230 | last_blk = start_blk + group_data[src_group - group].blocks_count; | 235 | last_blk = start_blk + group_data[src_group - group].blocks_count; |
231 | 236 | ||
@@ -235,7 +240,6 @@ next_group: | |||
235 | 240 | ||
236 | start_blk += overhead; | 241 | start_blk += overhead; |
237 | 242 | ||
238 | BUG_ON(src_group >= group_data[0].group + flex_gd->count); | ||
239 | /* We collect contiguous blocks as much as possible. */ | 243 | /* We collect contiguous blocks as much as possible. */ |
240 | src_group++; | 244 | src_group++; |
241 | for (; src_group <= last_group; src_group++) | 245 | for (; src_group <= last_group; src_group++) |
@@ -300,6 +304,7 @@ next_group: | |||
300 | group_data[i].free_blocks_count); | 304 | group_data[i].free_blocks_count); |
301 | } | 305 | } |
302 | } | 306 | } |
307 | return 0; | ||
303 | } | 308 | } |
304 | 309 | ||
305 | static struct buffer_head *bclean(handle_t *handle, struct super_block *sb, | 310 | static struct buffer_head *bclean(handle_t *handle, struct super_block *sb, |
@@ -1729,7 +1734,8 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count) | |||
1729 | */ | 1734 | */ |
1730 | while (ext4_setup_next_flex_gd(sb, flex_gd, n_blocks_count, | 1735 | while (ext4_setup_next_flex_gd(sb, flex_gd, n_blocks_count, |
1731 | flexbg_size)) { | 1736 | flexbg_size)) { |
1732 | ext4_alloc_group_tables(sb, flex_gd, flexbg_size); | 1737 | if (ext4_alloc_group_tables(sb, flex_gd, flexbg_size) != 0) |
1738 | break; | ||
1733 | err = ext4_flex_group_add(sb, resize_inode, flex_gd); | 1739 | err = ext4_flex_group_add(sb, resize_inode, flex_gd); |
1734 | if (unlikely(err)) | 1740 | if (unlikely(err)) |
1735 | break; | 1741 | break; |