[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180313231907.215181-1-harshads@google.com>
Date: Tue, 13 Mar 2018 16:19:07 -0700
From: harshads <harshads@...gle.com>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org, harshads <harshads@...gle.com>
Subject: [PATCH] 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 <harshads@...gle.com>
---
e2fsck/super.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 5501c9e2..5e29b64e 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)
--
2.16.2.804.g6dcf76e118-goog
Powered by blists - more mailing lists