]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: release clusters only once in release_inode_blocks
authorharshads <harshads@google.com>
Tue, 13 Mar 2018 23:19:07 +0000 (16:19 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 16 Mar 2018 12:34:21 +0000 (08:34 -0400)
While releasing inode blocks, if bigalloc feature is turned on,
release clusters only once. We do it by remembering the last released
cluster while iterating through blocks and releasing a cluster only if
it is not already released.

Signed-off-by: Harshad Shirwadkar <harshads@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/super.c

index 5501c9e27fe677ce0bc0600fd96ea535d72b0621..5e29b64ef0556ac7018c9ba8be4e51dd620a0a04 100644 (file)
@@ -71,6 +71,7 @@ struct process_block_struct {
        int             truncated_blocks;
        int             abort;
        errcode_t       errcode;
+       blk64_t last_cluster;
 };
 
 static int release_inode_block(ext2_filsys fs,
@@ -84,6 +85,7 @@ static int release_inode_block(ext2_filsys fs,
        e2fsck_t                ctx;
        struct problem_context  *pctx;
        blk64_t                 blk = *block_nr;
+       blk64_t                 cluster = EXT2FS_B2C(fs, *block_nr);
        int                     retval = 0;
 
        pb = (struct process_block_struct *) priv_data;
@@ -96,6 +98,11 @@ static int release_inode_block(ext2_filsys fs,
        if (blk == 0)
                return 0;
 
+       if (pb->last_cluster == cluster)
+               return 0;
+
+       pb->last_cluster = cluster;
+
        if ((blk < fs->super->s_first_data_block) ||
            (blk >= ext2fs_blocks_count(fs->super))) {
                fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_BLOCK_NUM, pctx);
@@ -188,6 +195,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
        pb.abort = 0;
        pb.errcode = 0;
        pb.pctx = pctx;
+       pb.last_cluster = 0;
        if (inode->i_links_count) {
                pb.truncating = 1;
                pb.truncate_block = (e2_blkcnt_t)