]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: Fix block allocation for holes in extent-mapped directories
authorTheodore Ts'o <tytso@mit.edu>
Sun, 29 Nov 2009 06:12:12 +0000 (01:12 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Nov 2009 06:12:12 +0000 (01:12 -0500)
In pass 2, when allocating new blocks for holes in directories, use
ext2fs_set_bmap() instead of ext2fs_block_iterate2() with a helper
function so that the newly allocated directory blocks are correctly
assigned in extent-mapped directories.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/pass2.c

index 889e39d1689258f1c8fca30ddf9bc7b47a9f5ab8..761c2f1f66f34e2491c2930cbb0200b2877f4201 100644 (file)
@@ -66,12 +66,6 @@ static int check_dir_block(ext2_filsys fs,
 static int allocate_dir_block(e2fsck_t ctx,
                              struct ext2_db_entry *dir_blocks_info,
                              char *buf, struct problem_context *pctx);
-static int update_dir_block(ext2_filsys fs,
-                           blk_t       *block_nr,
-                           e2_blkcnt_t blockcnt,
-                           blk_t       ref_block,
-                           int         ref_offset,
-                           void        *priv_data);
 static void clear_htree(e2fsck_t ctx, ext2_ino_t ino);
 static int htree_depth(struct dx_dir_info *dx_dir,
                       struct dx_dirblock_info *dx_db);
@@ -1463,8 +1457,8 @@ static int allocate_dir_block(e2fsck_t ctx,
         * Finally, update the block pointers for the inode
         */
        db->blk = blk;
-       pctx->errcode = ext2fs_block_iterate2(fs, db->ino, BLOCK_FLAG_HOLE,
-                                     0, update_dir_block, db);
+       pctx->errcode = ext2fs_bmap(fs, db->ino, &inode, 0, BMAP_SET,
+                                   db->blockcnt, &blk);
        if (pctx->errcode) {
                pctx->str = "ext2fs_block_iterate";
                fix_problem(ctx, PR_2_ALLOC_DIRBOCK, pctx);
@@ -1473,23 +1467,3 @@ static int allocate_dir_block(e2fsck_t ctx,
 
        return 0;
 }
-
-/*
- * This is a helper function for allocate_dir_block().
- */
-static int update_dir_block(ext2_filsys fs EXT2FS_ATTR((unused)),
-                           blk_t       *block_nr,
-                           e2_blkcnt_t blockcnt,
-                           blk_t ref_block EXT2FS_ATTR((unused)),
-                           int ref_offset EXT2FS_ATTR((unused)),
-                           void *priv_data)
-{
-       struct ext2_db_entry *db;
-
-       db = (struct ext2_db_entry *) priv_data;
-       if (db->blockcnt == (int) blockcnt) {
-               *block_nr = db->blk;
-               return BLOCK_CHANGED;
-       }
-       return 0;
-}