diff options
Diffstat (limited to 'fs/ext4/resize.c')
-rw-r--r-- | fs/ext4/resize.c | 60 |
1 files changed, 18 insertions, 42 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 6df797eb9aeb..dc963929de65 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -226,23 +226,13 @@ static int setup_new_group_blocks(struct super_block *sb, | |||
226 | } | 226 | } |
227 | 227 | ||
228 | /* Zero out all of the reserved backup group descriptor table blocks */ | 228 | /* Zero out all of the reserved backup group descriptor table blocks */ |
229 | for (i = 0, bit = gdblocks + 1, block = start + bit; | 229 | ext4_debug("clear inode table blocks %#04llx -> %#04llx\n", |
230 | i < reserved_gdb; i++, block++, bit++) { | 230 | block, sbi->s_itb_per_group); |
231 | struct buffer_head *gdb; | 231 | err = sb_issue_zeroout(sb, gdblocks + start + 1, reserved_gdb, |
232 | 232 | GFP_NOFS); | |
233 | ext4_debug("clear reserved block %#04llx (+%d)\n", block, bit); | 233 | if (err) |
234 | 234 | goto exit_bh; | |
235 | if ((err = extend_or_restart_transaction(handle, 1, bh))) | ||
236 | goto exit_bh; | ||
237 | 235 | ||
238 | if (IS_ERR(gdb = bclean(handle, sb, block))) { | ||
239 | err = PTR_ERR(gdb); | ||
240 | goto exit_bh; | ||
241 | } | ||
242 | ext4_handle_dirty_metadata(handle, NULL, gdb); | ||
243 | ext4_set_bit(bit, bh->b_data); | ||
244 | brelse(gdb); | ||
245 | } | ||
246 | ext4_debug("mark block bitmap %#04llx (+%llu)\n", input->block_bitmap, | 236 | ext4_debug("mark block bitmap %#04llx (+%llu)\n", input->block_bitmap, |
247 | input->block_bitmap - start); | 237 | input->block_bitmap - start); |
248 | ext4_set_bit(input->block_bitmap - start, bh->b_data); | 238 | ext4_set_bit(input->block_bitmap - start, bh->b_data); |
@@ -251,28 +241,18 @@ static int setup_new_group_blocks(struct super_block *sb, | |||
251 | ext4_set_bit(input->inode_bitmap - start, bh->b_data); | 241 | ext4_set_bit(input->inode_bitmap - start, bh->b_data); |
252 | 242 | ||
253 | /* Zero out all of the inode table blocks */ | 243 | /* Zero out all of the inode table blocks */ |
254 | for (i = 0, block = input->inode_table, bit = block - start; | 244 | block = input->inode_table; |
255 | i < sbi->s_itb_per_group; i++, bit++, block++) { | 245 | ext4_debug("clear inode table blocks %#04llx -> %#04llx\n", |
256 | struct buffer_head *it; | 246 | block, sbi->s_itb_per_group); |
257 | 247 | err = sb_issue_zeroout(sb, block, sbi->s_itb_per_group, GFP_NOFS); | |
258 | ext4_debug("clear inode block %#04llx (+%d)\n", block, bit); | 248 | if (err) |
259 | 249 | goto exit_bh; | |
260 | if ((err = extend_or_restart_transaction(handle, 1, bh))) | ||
261 | goto exit_bh; | ||
262 | |||
263 | if (IS_ERR(it = bclean(handle, sb, block))) { | ||
264 | err = PTR_ERR(it); | ||
265 | goto exit_bh; | ||
266 | } | ||
267 | ext4_handle_dirty_metadata(handle, NULL, it); | ||
268 | brelse(it); | ||
269 | ext4_set_bit(bit, bh->b_data); | ||
270 | } | ||
271 | 250 | ||
272 | if ((err = extend_or_restart_transaction(handle, 2, bh))) | 251 | if ((err = extend_or_restart_transaction(handle, 2, bh))) |
273 | goto exit_bh; | 252 | goto exit_bh; |
274 | 253 | ||
275 | mark_bitmap_end(input->blocks_count, sb->s_blocksize * 8, bh->b_data); | 254 | ext4_mark_bitmap_end(input->blocks_count, sb->s_blocksize * 8, |
255 | bh->b_data); | ||
276 | ext4_handle_dirty_metadata(handle, NULL, bh); | 256 | ext4_handle_dirty_metadata(handle, NULL, bh); |
277 | brelse(bh); | 257 | brelse(bh); |
278 | /* Mark unused entries in inode bitmap used */ | 258 | /* Mark unused entries in inode bitmap used */ |
@@ -283,8 +263,8 @@ static int setup_new_group_blocks(struct super_block *sb, | |||
283 | goto exit_journal; | 263 | goto exit_journal; |
284 | } | 264 | } |
285 | 265 | ||
286 | mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, | 266 | ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, |
287 | bh->b_data); | 267 | bh->b_data); |
288 | ext4_handle_dirty_metadata(handle, NULL, bh); | 268 | ext4_handle_dirty_metadata(handle, NULL, bh); |
289 | exit_bh: | 269 | exit_bh: |
290 | brelse(bh); | 270 | brelse(bh); |
@@ -921,8 +901,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) | |||
921 | &sbi->s_flex_groups[flex_group].free_inodes); | 901 | &sbi->s_flex_groups[flex_group].free_inodes); |
922 | } | 902 | } |
923 | 903 | ||
924 | ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh); | 904 | ext4_handle_dirty_super(handle, sb); |
925 | sb->s_dirt = 1; | ||
926 | 905 | ||
927 | exit_journal: | 906 | exit_journal: |
928 | mutex_unlock(&sbi->s_resize_lock); | 907 | mutex_unlock(&sbi->s_resize_lock); |
@@ -953,7 +932,6 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, | |||
953 | ext4_fsblk_t n_blocks_count) | 932 | ext4_fsblk_t n_blocks_count) |
954 | { | 933 | { |
955 | ext4_fsblk_t o_blocks_count; | 934 | ext4_fsblk_t o_blocks_count; |
956 | ext4_group_t o_groups_count; | ||
957 | ext4_grpblk_t last; | 935 | ext4_grpblk_t last; |
958 | ext4_grpblk_t add; | 936 | ext4_grpblk_t add; |
959 | struct buffer_head *bh; | 937 | struct buffer_head *bh; |
@@ -965,7 +943,6 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, | |||
965 | * yet: we're going to revalidate es->s_blocks_count after | 943 | * yet: we're going to revalidate es->s_blocks_count after |
966 | * taking the s_resize_lock below. */ | 944 | * taking the s_resize_lock below. */ |
967 | o_blocks_count = ext4_blocks_count(es); | 945 | o_blocks_count = ext4_blocks_count(es); |
968 | o_groups_count = EXT4_SB(sb)->s_groups_count; | ||
969 | 946 | ||
970 | if (test_opt(sb, DEBUG)) | 947 | if (test_opt(sb, DEBUG)) |
971 | printk(KERN_DEBUG "EXT4-fs: extending last group from %llu uto %llu blocks\n", | 948 | printk(KERN_DEBUG "EXT4-fs: extending last group from %llu uto %llu blocks\n", |
@@ -1045,13 +1022,12 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, | |||
1045 | goto exit_put; | 1022 | goto exit_put; |
1046 | } | 1023 | } |
1047 | ext4_blocks_count_set(es, o_blocks_count + add); | 1024 | ext4_blocks_count_set(es, o_blocks_count + add); |
1048 | ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); | ||
1049 | sb->s_dirt = 1; | ||
1050 | mutex_unlock(&EXT4_SB(sb)->s_resize_lock); | 1025 | mutex_unlock(&EXT4_SB(sb)->s_resize_lock); |
1051 | ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count, | 1026 | ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count, |
1052 | o_blocks_count + add); | 1027 | o_blocks_count + add); |
1053 | /* We add the blocks to the bitmap and set the group need init bit */ | 1028 | /* We add the blocks to the bitmap and set the group need init bit */ |
1054 | ext4_add_groupblocks(handle, sb, o_blocks_count, add); | 1029 | ext4_add_groupblocks(handle, sb, o_blocks_count, add); |
1030 | ext4_handle_dirty_super(handle, sb); | ||
1055 | ext4_debug("freed blocks %llu through %llu\n", o_blocks_count, | 1031 | ext4_debug("freed blocks %llu through %llu\n", o_blocks_count, |
1056 | o_blocks_count + add); | 1032 | o_blocks_count + add); |
1057 | if ((err = ext4_journal_stop(handle))) | 1033 | if ((err = ext4_journal_stop(handle))) |