From: Eric Sandeen Date: Sun, 2 Apr 2017 01:51:39 +0000 (+0800) Subject: LU-1365 resize2fs: clear uninit if allocating from new group X-Git-Tag: v1.42.13.wc6^0 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=6ba8ad101d4a8331b8131abb56ea821b77b7d2b0;p=tools%2Fe2fsprogs.git LU-1365 resize2fs: clear uninit if allocating from new group If resize2fs_get_alloc_block() allocates from a BLOCK_UNINIT group, we need to make sure that the UNINIT flag is cleared on both file system structures which are maintained by resize2fs. This causes the modified bitmaps to not get written out, which leads to post-resize2fs e2fsck errors; used blocks in UNINIT groups, not marked in the block bitmap. This was seen on r_ext4_small_bg. This patch uses clear_block_uninit() to clear the flag, and my problem goes away. E2fsprogs-commit: f3745728bc254892da4c569ba3fd8801895f3524 Change-Id: I5aa430cf6a9e7f07088b0accabccbdec5f93647e Signed-off-by: Eric Sandeen Signed-off-by: Niu Yawei Signed-off-by: Li Xi Reviewed-on: https://review.whamcloud.com/23831 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo --- diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c index 2061b9d..4567993 100644 --- a/lib/ext2fs/alloc.c +++ b/lib/ext2fs/alloc.c @@ -29,7 +29,7 @@ /* * Clear the uninit block bitmap flag if necessary */ -static void clear_block_uninit(ext2_filsys fs, dgrp_t group) +void ext2fs_clear_block_uninit(ext2_filsys fs, dgrp_t group) { if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) || @@ -160,7 +160,7 @@ errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal, if (retval) return retval; - clear_block_uninit(fs, ext2fs_group_of_blk2(fs, b)); + ext2fs_clear_block_uninit(fs, ext2fs_group_of_blk2(fs, b)); *ret = b; return 0; } diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 9eb6d56..cdd141d 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -653,6 +653,7 @@ static inline int ext2fs_needs_large_file_feature(unsigned long long file_size) } /* alloc.c */ +extern void ext2fs_clear_block_uninit(ext2_filsys fs, dgrp_t group); extern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode, ext2fs_inode_bitmap map, ext2_ino_t *ret); extern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, diff --git a/resize/resize2fs.c b/resize/resize2fs.c index c1a4446..198cbd9 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -1289,6 +1289,7 @@ static errcode_t resize2fs_get_alloc_block(ext2_filsys fs, blk64_t goal, { ext2_resize_t rfs = (ext2_resize_t) fs->priv_data; blk64_t blk; + int group; blk = get_new_block(rfs); if (!blk) @@ -1301,6 +1302,12 @@ static errcode_t resize2fs_get_alloc_block(ext2_filsys fs, blk64_t goal, ext2fs_mark_block_bitmap2(rfs->old_fs->block_map, blk); ext2fs_mark_block_bitmap2(rfs->new_fs->block_map, blk); + + group = ext2fs_group_of_blk2(rfs->old_fs, blk); + ext2fs_clear_block_uninit(rfs->old_fs, group); + group = ext2fs_group_of_blk2(rfs->new_fs, blk); + ext2fs_clear_block_uninit(rfs->new_fs, group); + *ret = (blk64_t) blk; return 0; }