Whamcloud - gitweb
LU-1365 resize2fs: clear uninit if allocating from new group 31/23831/9 v1.42.13.wc6
authorEric Sandeen <sandeen@redhat.com>
Sun, 2 Apr 2017 01:51:39 +0000 (09:51 +0800)
committerAndreas Dilger <andreas.dilger@intel.com>
Fri, 5 May 2017 21:02:28 +0000 (21:02 +0000)
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 <sandeen@redhat.com>
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: Li Xi <lixi@ddn.com>
Reviewed-on: https://review.whamcloud.com/23831
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lib/ext2fs/alloc.c
lib/ext2fs/ext2fs.h
resize/resize2fs.c

index 2061b9d..4567993 100644 (file)
@@ -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;
 }
index 9eb6d56..cdd141d 100644 (file)
@@ -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,
index c1a4446..198cbd9 100644 (file)
@@ -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;
 }