From: harshads Date: Tue, 13 Mar 2018 23:19:07 +0000 (-0700) Subject: e2fsck: release clusters only once in release_inode_blocks X-Git-Tag: v1.44.1~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=707599bf;p=thirdparty%2Fe2fsprogs.git e2fsck: release clusters only once in release_inode_blocks 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 Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/super.c b/e2fsck/super.c index 5501c9e27..5e29b64ef 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -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)