]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
ext2fs_block_iterate2: Preserve the uninit flag in extents
authorTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 00:30:59 +0000 (19:30 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 00:30:59 +0000 (19:30 -0500)
When modifying a block via the block_iterate interface, preserve the
uninit flag in the extent.  Resize2fs uses this interface, so we have
to preserve the uninit status when relocating a block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/block.c

index 51fdd9ad10263ac28766818483c0bbff9733142c..6ac937979e89420792d95c09c14087332569b3ab 100644 (file)
@@ -364,6 +364,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
                e2_blkcnt_t             blockcnt = 0;
                blk_t                   blk, new_blk;
                int                     op = EXT2_EXTENT_ROOT;
+               int                     uninit;
                unsigned int            j;
 
                ctx.errcode = ext2fs_extent_open(fs, ino, &handle);
@@ -419,6 +420,9 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
                                }
                                continue;
                        }
+                       uninit = 0;
+                       if (extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT)
+                               uninit = EXT2_EXTENT_SET_BMAP_UNINIT;
                        for (blockcnt = extent.e_lblk, j = 0;
                             j < extent.e_len;
                             blk++, blockcnt++, j++) {
@@ -432,7 +436,8 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
                                        ctx.errcode =
                                                ext2fs_extent_set_bmap(handle,
                                                       (blk64_t) blockcnt,
-                                                      (blk64_t) new_blk, 0);
+                                                      (blk64_t) new_blk,
+                                                      uninit);
                                        if (ctx.errcode)
                                                goto extent_errout;
                                }