]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: during pass1b delete_file, only free a cluster once
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 26 Jul 2014 20:28:58 +0000 (16:28 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 26 Jul 2014 20:28:58 +0000 (16:28 -0400)
If we're forced to delete a crosslinked file, only call
ext2fs_block_alloc_stats2() on cluster boundaries, since the block
bitmaps are all cluster bitmaps at this point.  It's safe to do this
only once per cluster since we know all the blocks are going away.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1b.c
e2fsck/pass2.c

index ec6c2bc0e3010960888a811970dea7c780c024b0..bb81d5e99de90113f4b798c629999238b0645c45 100644 (file)
@@ -625,7 +625,8 @@ static int delete_file_block(ext2_filsys fs,
                            _("internal error: can't find dup_blk for %llu\n"),
                                *block_nr);
        } else {
-               ext2fs_block_alloc_stats2(fs, *block_nr, -1);
+               if ((*block_nr % EXT2FS_CLUSTER_RATIO(ctx->fs)) == 0)
+                       ext2fs_block_alloc_stats2(fs, *block_nr, -1);
                pb->dup_blocks++;
        }
        pb->cur_cluster = lc;
index 8fcb4ac26ea1d990899cc5dbc94088de7eb9ae93..2b7bff4aee9177e695485c552bd004654f79ba09 100644 (file)
@@ -1171,7 +1171,8 @@ static int deallocate_inode_block(ext2_filsys fs,
        if ((*block_nr < fs->super->s_first_data_block) ||
            (*block_nr >= ext2fs_blocks_count(fs->super)))
                return 0;
-       ext2fs_block_alloc_stats2(fs, *block_nr, -1);
+       if ((*block_nr % EXT2FS_CLUSTER_RATIO(fs)) == 0)
+               ext2fs_block_alloc_stats2(fs, *block_nr, -1);
        p->num++;
        return 0;
 }