public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] e2fsck: delay quotas loading in release_orphan_inodes()
@ 2023-08-17  8:18 Baokun Li
  2023-08-23 17:05 ` Jan Kara
  0 siblings, 1 reply; 11+ messages in thread
From: Baokun Li @ 2023-08-17  8:18 UTC (permalink / raw)
  To: linux-ext4
  Cc: tytso, adilger.kernel, jack, darrick.wong, yi.zhang, yangerkun,
	yukuai3, libaokun1

After 7d79b40b ("e2fsck: adjust quota counters when clearing orphaned
inodes"), we load all the quotas before we process the orphaned inodes,
and when we load the quotas, we check the checsum of the bbitmap for each
group. If one of the bbitmap checksums is wrong, the following error will
be reported:

“Error initializing quota context in support library:
 Block bitmap checksum does not match bitmap”

But loading quotas comes before checking the current superblock for the
EXT2_ERROR_FS flag, which makes it impossible to use e2fsck to repair any
image that contains orphan inodes and has the wrong bbitmap checksum.
So delaying quota loading until after the EXT2_ERROR_FS judgment avoids
the above problem.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
 e2fsck/super.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/e2fsck/super.c b/e2fsck/super.c
index 9495e029..b1aaaed6 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -503,15 +503,6 @@ static int release_orphan_inodes(e2fsck_t ctx)
 	    !ext2fs_has_feature_orphan_present(fs->super))
 		return 0;
 
-	clear_problem_context(&pctx);
-	ino = fs->super->s_last_orphan;
-	pctx.ino = ino;
-	pctx.errcode = e2fsck_read_all_quotas(ctx);
-	if (pctx.errcode) {
-		fix_problem(ctx, PR_0_QUOTA_INIT_CTX, &pctx);
-		return 1;
-	}
-
 	/*
 	 * Win or lose, we won't be using the head of the orphan inode
 	 * list again.
@@ -525,10 +516,16 @@ static int release_orphan_inodes(e2fsck_t ctx)
 	 * be running a full e2fsck run anyway... We clear orphan file contents
 	 * after filesystem is checked to avoid clearing someone else's data.
 	 */
-	if (fs->super->s_state & EXT2_ERROR_FS) {
-		if (ctx->qctx)
-			quota_release_context(&ctx->qctx);
+	if (fs->super->s_state & EXT2_ERROR_FS)
 		return 0;
+
+	clear_problem_context(&pctx);
+	ino = fs->super->s_last_orphan;
+	pctx.ino = ino;
+	pctx.errcode = e2fsck_read_all_quotas(ctx);
+	if (pctx.errcode) {
+		fix_problem(ctx, PR_0_QUOTA_INIT_CTX, &pctx);
+		return 1;
 	}
 
 	if (ino && ((ino < EXT2_FIRST_INODE(fs->super)) ||
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-08-25 13:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-17  8:18 [PATCH] e2fsck: delay quotas loading in release_orphan_inodes() Baokun Li
2023-08-23 17:05 ` Jan Kara
2023-08-24  2:27   ` Baokun Li
2023-08-24 10:08     ` Jan Kara
2023-08-24 12:56       ` Baokun Li
2023-08-24 19:37         ` Jan Kara
2023-08-25  2:08           ` Baokun Li
2023-08-25 12:50             ` Jan Kara
2023-08-25 13:15               ` Baokun Li
2023-08-24 19:49     ` Andreas Dilger
2023-08-25  1:20       ` Baokun Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox