Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ext4: reject impossible group free cluster counts
@ 2026-11-19 12:25 Zhao Gongyi
  2026-11-19 12:26 ` [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery Zhao Gongyi
  2026-11-19 12:26 ` [PATCH v2 2/2] ext4: reject impossible group free cluster counts Zhao Gongyi
  0 siblings, 2 replies; 5+ messages in thread
From: Zhao Gongyi @ 2026-11-19 12:25 UTC (permalink / raw)
  To: linux-ext4
  Cc: Zhao Gongyi, linux-kernel, tytso, adilger.kernel, libaokun, jack,
	ojaswin, ritesh.list, yi.zhang

ext4 initializes its free-space counters from the group descriptors. A
corrupt descriptor can advertise more free clusters than its group can
hold. Journal block replay can also replace the superblock and group
descriptors that were examined when mounting.

This series adds an optional JBD2 recovery callback and uses it in ext4
to validate the recovered geometry and group descriptors. It checks the
metadata before fast commit replay consumes it and checks the
descriptors again after fast commit replay. The ext4 check reads both
halves of the free-cluster count while holding the group lock.

Changes since v1

- Defer full descriptor validation on recovery mounts until journal
  block replay completes. Keep the initial checks needed to load the
  internal journal.
- Revalidate the superblock geometry and reload the descriptor table
  when replay changes its layout. Validate the free-cluster counts
  against the recovered geometry.
- Put the JBD2 interface in its own patch. Sample the group free-cluster
  count under the existing group lock.

Testing

The earlier combined patch was tested in an amd64 QEMU/KVM guest
running a 7.4.0-rc2-based kernel. The runs covered these cases.

- ext4 rejected the corrupted bigalloc image before free-space
  accounting. Valid read-only mounts succeeded and read-only mounts
  with an out-of-range count failed.
- Ordinary journal recovery succeeded and mounted read-write when the
  recovered group descriptors were valid.
- The recovery callback rejected an out-of-range count with an empty
  journal and during recovery with a nonempty journal when corruption
  remained in a separate group descriptor block.

The recovery tests used additional diagnostic logging to identify the
callback. The QEMU runs preceded the split and group-lock change.
Fast commit replay and recovery from an online resize that crosses a
group descriptor block boundary still need runtime coverage.

Built fs/ext4/ and fs/jbd2/ on the ext4 dev base with arm64 GCC 15.2
and W=1 after applying each patch in the series.

Link: https://lore.kernel.org/linux-ext4/20261102042428.65204-1-zhaogongyi@bytedance.com/

Zhao Gongyi (2):
  jbd2: add a metadata validation hook to journal recovery
  ext4: reject impossible group free cluster counts

 fs/ext4/balloc.c     |  10 +-
 fs/ext4/ext4.h       |   2 +
 fs/ext4/super.c      | 294 +++++++++++++++++++++++++++++++++----------
 fs/jbd2/journal.c    |  22 +++-
 fs/jbd2/recovery.c   |  38 ++++--
 include/linux/jbd2.h |   7 +-
 6 files changed, 287 insertions(+), 86 deletions(-)

base-commit: 4aa05e642bade8cf8405936b03cabf848fe6c456

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

* [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery
  2026-11-19 12:25 [PATCH v2 0/2] ext4: reject impossible group free cluster counts Zhao Gongyi
@ 2026-11-19 12:26 ` Zhao Gongyi
  2026-11-19 12:34   ` sashiko-bot
  2026-11-19 12:26 ` [PATCH v2 2/2] ext4: reject impossible group free cluster counts Zhao Gongyi
  1 sibling, 1 reply; 5+ messages in thread
From: Zhao Gongyi @ 2026-11-19 12:26 UTC (permalink / raw)
  To: linux-ext4
  Cc: Zhao Gongyi, linux-kernel, tytso, adilger.kernel, libaokun, jack,
	ojaswin, ritesh.list, yi.zhang

Filesystems can need to validate metadata that block replay has changed
before fast commit replay consumes it. They can also need to check
metadata that fast commit replay updates before completing recovery.

Provide an optional callback after block replay, including when the
journal is empty, and after fast commit replay. Propagate validation
errors before resetting the journal. Keep the existing replay flow for
callers of jbd2_journal_load().

Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
---
 fs/jbd2/journal.c    | 22 ++++++++++++++++------
 fs/jbd2/recovery.c   | 38 +++++++++++++++++++++++++++-----------
 include/linux/jbd2.h |  7 ++++++-
 3 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index eb8e944..383606a 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2079,20 +2079,24 @@ void jbd2_journal_update_sb_errno(journal_t *journal)
 EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
 
 /**
- * jbd2_journal_load() - Read journal from disk.
+ * jbd2_journal_load_with_callback() - Read journal from disk.
  * @journal: Journal to act on.
+ * @callback: Optional validation callback for recovery.
+ * @data: Private data for the replay callback.
  *
- * Given a journal_t structure which tells us which disk blocks contain
- * a journal, read the journal from disk to initialise the in-memory
- * structures.
+ * Read the journal from disk and initialise the in-memory structures.
+ * Call @callback with after_fast_commit false after block replay,
+ * including for an empty journal, and with true after fast commit
+ * replay. A callback error stops recovery before the journal is reset.
  */
-int jbd2_journal_load(journal_t *journal)
+int jbd2_journal_load_with_callback(journal_t *journal,
+				    jbd2_replay_callback_t callback, void *data)
 {
 	int err;
 
 	/* Let the recovery code check whether it needs to recover any
 	 * data from the journal. */
-	err = jbd2_journal_recover(journal);
+	err = jbd2_journal_recover(journal, callback, data);
 	if (err) {
 		pr_warn("JBD2: journal recovery failed\n");
 		return err;
@@ -2125,6 +2129,12 @@ int jbd2_journal_load(journal_t *journal)
 	write_unlock(&journal->j_state_lock);
 	return 0;
 }
+EXPORT_SYMBOL(jbd2_journal_load_with_callback);
+
+int jbd2_journal_load(journal_t *journal)
+{
+	return jbd2_journal_load_with_callback(journal, NULL, NULL);
+}
 
 /**
  * jbd2_journal_destroy() - Release a journal_t structure.
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
index cac8c2c..be4fd27 100644
--- a/fs/jbd2/recovery.c
+++ b/fs/jbd2/recovery.c
@@ -37,8 +37,9 @@ struct recovery_info
 	int		nr_revoke_hits;
 };
 
-static int do_one_pass(journal_t *journal,
-				struct recovery_info *info, enum passtype pass);
+static int do_one_pass(journal_t *journal, struct recovery_info *info,
+		       enum passtype pass, jbd2_replay_callback_t callback,
+		       void *data);
 static int scan_revoke_records(journal_t *, enum passtype, struct buffer_head *,
 				tid_t, struct recovery_info *);
 
@@ -270,6 +271,8 @@ static int fc_do_one_pass(journal_t *journal,
 /**
  * jbd2_journal_recover - recovers a on-disk journal
  * @journal: the journal to recover
+ * @callback: optional check after each replay stage
+ * @data: private data for the replay callback
  *
  * The primary function for recovering the log contents when mounting a
  * journaled device.
@@ -279,7 +282,8 @@ static int fc_do_one_pass(journal_t *journal,
  * blocks.  In the third and final pass, we replay any un-revoked blocks
  * in the log.
  */
-int jbd2_journal_recover(journal_t *journal)
+int jbd2_journal_recover(journal_t *journal,
+			 jbd2_replay_callback_t callback, void *data)
 {
 	int			err, err2;
 	struct recovery_info	info;
@@ -300,14 +304,14 @@ int jbd2_journal_recover(journal_t *journal)
 			  be32_to_cpu(sb->s_sequence), be32_to_cpu(sb->s_head));
 		journal->j_transaction_sequence = be32_to_cpu(sb->s_sequence) + 1;
 		journal->j_head = be32_to_cpu(sb->s_head);
-		return 0;
+		return callback ? callback(journal, data, false) : 0;
 	}
 
-	err = do_one_pass(journal, &info, PASS_SCAN);
+	err = do_one_pass(journal, &info, PASS_SCAN, NULL, NULL);
 	if (!err)
-		err = do_one_pass(journal, &info, PASS_REVOKE);
+		err = do_one_pass(journal, &info, PASS_REVOKE, NULL, NULL);
 	if (!err)
-		err = do_one_pass(journal, &info, PASS_REPLAY);
+		err = do_one_pass(journal, &info, PASS_REPLAY, callback, data);
 
 	jbd2_debug(1, "JBD2: recovery, exit status %d, "
 		  "recovered transactions %u to %u\n",
@@ -365,7 +369,7 @@ int jbd2_journal_skip_recovery(journal_t *journal)
 
 	memset (&info, 0, sizeof(info));
 
-	err = do_one_pass(journal, &info, PASS_SCAN);
+	err = do_one_pass(journal, &info, PASS_SCAN, NULL, NULL);
 
 	if (err) {
 		printk(KERN_ERR "JBD2: error %d scanning journal\n", err);
@@ -585,8 +589,9 @@ skip_write:
 	return ret;
 }
 
-static int do_one_pass(journal_t *journal,
-			struct recovery_info *info, enum passtype pass)
+static int do_one_pass(journal_t *journal, struct recovery_info *info,
+		       enum passtype pass, jbd2_replay_callback_t callback,
+		       void *data)
 {
 	unsigned int		first_commit_ID, next_commit_ID;
 	unsigned long		next_log_block, head_block;
@@ -936,10 +941,21 @@ chksum_ok:
 		}
 	}
 
-	if (jbd2_has_feature_fast_commit(journal) &&  pass != PASS_REVOKE) {
+	/* Only PASS_REPLAY can carry a validation callback. */
+	if (callback) {
+		if (success)
+			return success;
+		err = callback(journal, data, false);
+		if (err)
+			return err;
+	}
+
+	if (jbd2_has_feature_fast_commit(journal) && pass != PASS_REVOKE) {
 		err = fc_do_one_pass(journal, info, pass);
 		if (err)
 			success = err;
+		else if (callback)
+			success = callback(journal, data, true);
 	}
 
 	return success;
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 69f1236..28358c6 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1565,9 +1565,14 @@ extern int	   jbd2_journal_set_features
 		   (journal_t *, unsigned long, unsigned long, unsigned long);
 extern void	   jbd2_journal_clear_features
 		   (journal_t *, unsigned long, unsigned long, unsigned long);
+typedef int (*jbd2_replay_callback_t)(journal_t *journal, void *data,
+				      bool after_fast_commit);
 extern int	   jbd2_journal_load       (journal_t *journal);
+int jbd2_journal_load_with_callback(journal_t *journal,
+				    jbd2_replay_callback_t callback, void *data);
 extern int	   jbd2_journal_destroy    (journal_t *);
-extern int	   jbd2_journal_recover    (journal_t *journal);
+int jbd2_journal_recover(journal_t *journal,
+			 jbd2_replay_callback_t callback, void *data);
 extern int	   jbd2_journal_wipe       (journal_t *, int);
 extern int	   jbd2_journal_skip_recovery	(journal_t *);
 extern void	   jbd2_journal_update_sb_errno(journal_t *);

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

* [PATCH v2 2/2] ext4: reject impossible group free cluster counts
  2026-11-19 12:25 [PATCH v2 0/2] ext4: reject impossible group free cluster counts Zhao Gongyi
  2026-11-19 12:26 ` [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery Zhao Gongyi
@ 2026-11-19 12:26 ` Zhao Gongyi
  2026-11-19 13:02   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: Zhao Gongyi @ 2026-11-19 12:26 UTC (permalink / raw)
  To: linux-ext4
  Cc: Zhao Gongyi, linux-kernel, tytso, adilger.kernel, libaokun, jack,
	ojaswin, ritesh.list, yi.zhang

ext4_count_free_clusters() sums the free-cluster counts from the group
descriptors when initializing the mount's free-space counters. A corrupt
bigalloc filesystem can report 201327130 free clusters in a group that
holds only 32. Reject counts above the group's capacity, using the same
calculation as the block bitmap, including for short final groups and
read-only mounts. Read both halves of the count under the group lock so
updates from deferred EA inode eviction cannot yield a mixed value.

Journal replay can replace both the group descriptors and the
superblock used to interpret them. For mounts that need recovery,
validate the descriptor for the internal journal inode before loading
it. Validate the recovered superblock geometry and all descriptors
after replaying journal blocks. Reload the descriptor table if replay
of an online resize changed the group count or descriptor layout.

Use the JBD2 recovery callback to validate recovered metadata before
fast commit replay consumes it. Check the descriptors again after
fast commit replay modifies them. Both checks run before JBD2 resets
the journal and before ext4 initializes its free-space counters.

Link: https://lore.kernel.org/linux-ext4/20261102042428.65204-1-zhaogongyi@bytedance.com/
Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
---
 fs/ext4/balloc.c |  10 +-
 fs/ext4/ext4.h   |   2 +
 fs/ext4/super.c  | 294 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 238 insertions(+), 68 deletions(-)

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 778fe87..0f36630 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -159,8 +159,8 @@ static unsigned ext4_num_overhead_clusters(struct super_block *sb,
 	return num_clusters;
 }
 
-static unsigned int num_clusters_in_group(struct super_block *sb,
-					  ext4_group_t block_group)
+unsigned int ext4_num_clusters_in_group(struct super_block *sb,
+					ext4_group_t block_group)
 {
 	unsigned int blocks;
 
@@ -228,7 +228,7 @@ static int ext4_init_block_bitmap(struct super_block *sb,
 	 * the blocksize * 8 ( which is the size of bitmap ), set rest
 	 * of the block bitmap to 1
 	 */
-	ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group),
+	ext4_mark_bitmap_end(ext4_num_clusters_in_group(sb, block_group),
 			     sb->s_blocksize * 8, bh->b_data);
 	return 0;
 }
@@ -240,7 +240,7 @@ unsigned ext4_free_clusters_after_init(struct super_block *sb,
 				       ext4_group_t block_group,
 				       struct ext4_group_desc *gdp)
 {
-	return num_clusters_in_group(sb, block_group) -
+	return ext4_num_clusters_in_group(sb, block_group) -
 		ext4_num_overhead_clusters(sb, block_group, gdp);
 }
 
@@ -313,7 +313,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap_padding(struct super_block *sb,
 {
 	ext4_grpblk_t next_zero_bit;
 	unsigned long bitmap_size = sb->s_blocksize * 8;
-	unsigned int offset = num_clusters_in_group(sb, block_group);
+	unsigned int offset = ext4_num_clusters_in_group(sb, block_group);
 
 	if (bitmap_size <= offset)
 		return 0;
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index aa0f230..598528f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3480,6 +3480,8 @@ extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
 				      struct ext4_group_desc *bg);
 extern ext4_fsblk_t ext4_inode_table(struct super_block *sb,
 				     struct ext4_group_desc *bg);
+unsigned int ext4_num_clusters_in_group(struct super_block *sb,
+					ext4_group_t block_group);
 extern __u32 ext4_free_group_clusters(struct super_block *sb,
 				      struct ext4_group_desc *bg);
 extern __u32 ext4_free_inodes_count(struct super_block *sb,
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 359f9d4..68c33a9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -66,7 +66,8 @@ static DEFINE_MUTEX(ext4_li_mtx);
 static struct ratelimit_state ext4_mount_msg_ratelimit;
 
 static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
-			     unsigned long journal_devnum);
+			     unsigned long journal_devnum,
+			     ext4_group_t *first_not_zeroed);
 static int ext4_show_options(struct seq_file *seq, struct dentry *root);
 static void ext4_update_super(struct super_block *sb);
 static int ext4_commit_super(struct super_block *sb);
@@ -3366,7 +3367,9 @@ void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group,
 /* Called at mount-time, super-block is locked */
 static int ext4_check_descriptors(struct super_block *sb,
 				  ext4_fsblk_t sb_block,
-				  ext4_group_t *first_not_zeroed)
+				  unsigned int journal_inum,
+				  ext4_group_t *first_not_zeroed,
+				  bool readonly)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
@@ -3376,15 +3379,27 @@ static int ext4_check_descriptors(struct super_block *sb,
 	ext4_fsblk_t inode_bitmap;
 	ext4_fsblk_t inode_table;
 	int flexbg_flag = 0;
-	ext4_group_t i, grp = sbi->s_groups_count;
+	ext4_group_t i = 0, end = sbi->s_groups_count, grp = end;
 
 	if (ext4_has_feature_flex_bg(sb))
 		flexbg_flag = 1;
 
+	/* Before recovery, check the group needed to load the journal inode. */
+	if (journal_inum) {
+		if (journal_inum < EXT4_ROOT_INO ||
+		    journal_inum > le32_to_cpu(sbi->s_es->s_inodes_count))
+			return 0;
+		i = (journal_inum - 1) / EXT4_INODES_PER_GROUP(sb);
+		end = i + 1;
+		if (!flexbg_flag)
+			first_block = ext4_group_first_block_no(sb, i);
+	}
+
 	ext4_debug("Checking group descriptors");
 
-	for (i = 0; i < sbi->s_groups_count; i++) {
+	for (; i < end; i++) {
 		struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, NULL);
+		unsigned int free_clusters = 0;
 
 		if (i == sbi->s_groups_count - 1 || flexbg_flag)
 			last_block = ext4_blocks_count(sbi->s_es) - 1;
@@ -3401,7 +3416,7 @@ static int ext4_check_descriptors(struct super_block *sb,
 			ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
 				 "Block bitmap for group %u overlaps "
 				 "superblock", i);
-			if (!sb_rdonly(sb))
+			if (!readonly)
 				return 0;
 		}
 		if (block_bitmap >= sb_block + 1 &&
@@ -3409,7 +3424,7 @@ static int ext4_check_descriptors(struct super_block *sb,
 			ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
 				 "Block bitmap for group %u overlaps "
 				 "block group descriptors", i);
-			if (!sb_rdonly(sb))
+			if (!readonly)
 				return 0;
 		}
 		if (block_bitmap < first_block || block_bitmap > last_block) {
@@ -3423,7 +3438,7 @@ static int ext4_check_descriptors(struct super_block *sb,
 			ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
 				 "Inode bitmap for group %u overlaps "
 				 "superblock", i);
-			if (!sb_rdonly(sb))
+			if (!readonly)
 				return 0;
 		}
 		if (inode_bitmap >= sb_block + 1 &&
@@ -3431,7 +3446,7 @@ static int ext4_check_descriptors(struct super_block *sb,
 			ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
 				 "Inode bitmap for group %u overlaps "
 				 "block group descriptors", i);
-			if (!sb_rdonly(sb))
+			if (!readonly)
 				return 0;
 		}
 		if (inode_bitmap < first_block || inode_bitmap > last_block) {
@@ -3445,7 +3460,7 @@ static int ext4_check_descriptors(struct super_block *sb,
 			ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
 				 "Inode table for group %u overlaps "
 				 "superblock", i);
-			if (!sb_rdonly(sb))
+			if (!readonly)
 				return 0;
 		}
 		if (inode_table >= sb_block + 1 &&
@@ -3453,11 +3468,12 @@ static int ext4_check_descriptors(struct super_block *sb,
 			ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
 				 "Inode table for group %u overlaps "
 				 "block group descriptors", i);
-			if (!sb_rdonly(sb))
+			if (!readonly)
 				return 0;
 		}
 		if (inode_table < first_block ||
-		    inode_table + sbi->s_itb_per_group - 1 > last_block) {
+		    inode_table > last_block ||
+		    sbi->s_itb_per_group - 1 > last_block - inode_table) {
 			ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
 			       "Inode table for group %u not in group "
 			       "(block %llu)!", i, inode_table);
@@ -3469,16 +3485,30 @@ static int ext4_check_descriptors(struct super_block *sb,
 				 "Checksum for group %u failed (%u!=%u)",
 				 i, le16_to_cpu(ext4_group_desc_csum(sb, i,
 				     gdp)), le16_to_cpu(gdp->bg_checksum));
-			if (!sb_rdonly(sb)) {
+			if (!readonly) {
 				ext4_unlock_group(sb, i);
 				return 0;
 			}
 		}
+		/* Sample both halves of the count under the group lock. */
+		if (!journal_inum)
+			free_clusters = ext4_free_group_clusters(sb, gdp);
 		ext4_unlock_group(sb, i);
+
+		if (!journal_inum) {
+			unsigned int capacity = ext4_num_clusters_in_group(sb, i);
+
+			if (free_clusters > capacity) {
+				ext4_msg(sb, KERN_ERR,
+					 "group %u has invalid free clusters count %u > %u",
+					 i, free_clusters, capacity);
+				return 0;
+			}
+		}
 		if (!flexbg_flag)
 			first_block += EXT4_BLOCKS_PER_GROUP(sb);
 	}
-	if (NULL != first_not_zeroed)
+	if (first_not_zeroed)
 		*first_not_zeroed = grp;
 	return 1;
 }
@@ -4875,7 +4905,8 @@ static int ext4_check_feature_compatibility(struct super_block *sb,
 }
 
 static int ext4_check_geometry(struct super_block *sb,
-			       struct ext4_super_block *es)
+			       struct ext4_super_block *es,
+			       ext4_group_t *groups_count)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	__u64 blocks_count;
@@ -4939,88 +4970,193 @@ static int ext4_check_geometry(struct super_block *sb,
 		       EXT4_BLOCKS_PER_GROUP(sb));
 		return -EINVAL;
 	}
-	sbi->s_groups_count = blocks_count;
-	sbi->s_blockfile_groups = min(sbi->s_groups_count,
-			(EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
-	if (((u64)sbi->s_groups_count * sbi->s_inodes_per_group) !=
+	if (blocks_count * sbi->s_inodes_per_group !=
 	    le32_to_cpu(es->s_inodes_count)) {
 		ext4_msg(sb, KERN_ERR, "inodes count not valid: %u vs %llu",
 			 le32_to_cpu(es->s_inodes_count),
-			 ((u64)sbi->s_groups_count * sbi->s_inodes_per_group));
+			 blocks_count * sbi->s_inodes_per_group);
 		return -EINVAL;
 	}
 
+	*groups_count = blocks_count;
 	return 0;
 }
 
-static int ext4_group_desc_init(struct super_block *sb,
-				struct ext4_super_block *es,
+/* Mount and recovery load the table before publishing the superblock. */
+static int ext4_load_group_desc(struct super_block *sb,
 				ext4_fsblk_t logical_sb_block,
-				ext4_group_t *first_not_zeroed)
+				ext4_group_t groups_count)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+	struct ext4_super_block *es = sbi->s_es;
+	struct buffer_head **group_desc;
 	unsigned int db_count;
 	ext4_fsblk_t block;
-	int i;
+	int err, i;
 
-	db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
-		   EXT4_DESC_PER_BLOCK(sb);
-	if (ext4_has_feature_meta_bg(sb)) {
-		if (le32_to_cpu(es->s_first_meta_bg) > db_count) {
-			ext4_msg(sb, KERN_WARNING,
-				 "first meta block group too large: %u "
-				 "(group descriptor block count %u)",
-				 le32_to_cpu(es->s_first_meta_bg), db_count);
-			return -EINVAL;
-		}
-	}
-	rcu_assign_pointer(sbi->s_group_desc,
-			   kvmalloc_objs(struct buffer_head *, db_count));
-	if (sbi->s_group_desc == NULL) {
-		ext4_msg(sb, KERN_ERR, "not enough memory");
-		return -ENOMEM;
+	db_count = DIV_ROUND_UP(groups_count, EXT4_DESC_PER_BLOCK(sb));
+	if (ext4_has_feature_meta_bg(sb) &&
+	    le32_to_cpu(es->s_first_meta_bg) > db_count) {
+		ext4_msg(sb, KERN_ERR,
+			 "first meta block group too large: %u (group descriptor block count %u)",
+			 le32_to_cpu(es->s_first_meta_bg), db_count);
+		return -EINVAL;
 	}
 
-	bgl_lock_init(sbi->s_blockgroup_lock);
+	group_desc = kvmalloc_objs(struct buffer_head *, db_count);
+	if (!group_desc)
+		return -ENOMEM;
 
-	/* Pre-read the descriptors into the buffer cache */
+	/* Pre-read the descriptors into the buffer cache. */
 	for (i = 0; i < db_count; i++) {
 		block = descriptor_loc(sb, logical_sb_block, i);
+		if (block >= ext4_blocks_count(es)) {
+			ext4_msg(sb, KERN_ERR,
+				 "group descriptor block %d outside filesystem", i);
+			kvfree(group_desc);
+			return -EFSCORRUPTED;
+		}
 		ext4_sb_breadahead_unmovable(sb, block);
 	}
 
 	for (i = 0; i < db_count; i++) {
-		struct buffer_head *bh;
-
 		block = descriptor_loc(sb, logical_sb_block, i);
-		bh = ext4_sb_bread_unmovable(sb, block);
-		if (IS_ERR(bh)) {
+		group_desc[i] = ext4_sb_bread_unmovable(sb, block);
+		if (IS_ERR(group_desc[i])) {
 			ext4_msg(sb, KERN_ERR,
-			       "can't read group descriptor %d", i);
-			sbi->s_gdb_count = i;
-			return PTR_ERR(bh);
+				 "can't read group descriptor %d", i);
+			err = PTR_ERR(group_desc[i]);
+			goto out_free;
 		}
-		rcu_read_lock();
-		rcu_dereference(sbi->s_group_desc)[i] = bh;
-		rcu_read_unlock();
 	}
+
+	ext4_group_desc_free(sbi);
+	rcu_assign_pointer(sbi->s_group_desc, group_desc);
 	sbi->s_gdb_count = db_count;
-	if (!ext4_check_descriptors(sb, logical_sb_block, first_not_zeroed)) {
-		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
+	sbi->s_groups_count = groups_count;
+	sbi->s_blockfile_groups = min(groups_count,
+				      EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb));
+	return 0;
+
+out_free:
+	while (i--)
+		brelse(group_desc[i]);
+	kvfree(group_desc);
+	return err;
+}
+
+struct ext4_replay_callback_data {
+	struct ext4_super_block super;
+	ext4_group_t *first_not_zeroed;
+	bool readonly;
+};
+
+static int ext4_validate_replayed_metadata(journal_t *journal, void *data,
+					   bool after_fast_commit)
+{
+	struct ext4_replay_callback_data *replay = data;
+	struct super_block *sb = journal->j_private;
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+	struct ext4_super_block *es = sbi->s_es;
+	struct ext4_super_block *old = &replay->super;
+	ext4_fsblk_t sb_block = sbi->s_sbh->b_blocknr;
+	ext4_group_t groups_count;
+	unsigned int inode_size, first_ino;
+	u32 incompat, ro_compat;
+	int err;
+
+	/* Fast commits only change descriptor contents, such as counts. */
+	if (after_fast_commit) {
+		if (!(sbi->s_mount_state & EXT4_FC_REPLAY))
+			return 0;
+		goto check_descriptors;
+	}
+
+	incompat = le32_to_cpu(es->s_feature_incompat ^ old->s_feature_incompat);
+	ro_compat = le32_to_cpu(es->s_feature_ro_compat ^ old->s_feature_ro_compat);
+	if (es->s_rev_level == cpu_to_le32(EXT4_GOOD_OLD_REV)) {
+		inode_size = EXT4_GOOD_OLD_INODE_SIZE;
+		first_ino = EXT4_GOOD_OLD_FIRST_INO;
+	} else {
+		inode_size = le16_to_cpu(es->s_inode_size);
+		first_ino = le32_to_cpu(es->s_first_ino);
+	}
+
+	/* Online resize can grow the filesystem without changing group units. */
+	if (es->s_magic != old->s_magic ||
+	    es->s_log_block_size != old->s_log_block_size ||
+	    es->s_log_cluster_size != old->s_log_cluster_size ||
+	    es->s_blocks_per_group != old->s_blocks_per_group ||
+	    es->s_clusters_per_group != old->s_clusters_per_group ||
+	    es->s_inodes_per_group != old->s_inodes_per_group ||
+	    es->s_first_data_block != old->s_first_data_block ||
+	    inode_size != sbi->s_inode_size || first_ino != sbi->s_first_ino ||
+	    es->s_desc_size != old->s_desc_size ||
+	    es->s_log_groups_per_flex != old->s_log_groups_per_flex ||
+	    ext4_blocks_count(es) < ext4_blocks_count(old) ||
+	    (incompat & (EXT4_FEATURE_INCOMPAT_64BIT |
+			 EXT4_FEATURE_INCOMPAT_FLEX_BG)) ||
+	    (ro_compat & (EXT4_FEATURE_RO_COMPAT_BIGALLOC |
+			  EXT4_FEATURE_RO_COMPAT_METADATA_CSUM |
+			  EXT4_FEATURE_RO_COMPAT_GDT_CSUM |
+			  EXT4_FEATURE_RO_COMPAT_READONLY))) {
+		ext4_msg(sb, KERN_ERR, "invalid filesystem geometry after journal replay");
 		return -EFSCORRUPTED;
 	}
 
+	/* An unreplayed superblock can contain mount-time hash flags. */
+	if (memcmp(es, old, sizeof(*es)) &&
+	    (!ext4_verify_csum_type(sb, es) ||
+	     !ext4_superblock_csum_verify(sb, es))) {
+		ext4_msg(sb, KERN_ERR, "invalid superblock checksum after journal replay");
+		return -EFSBADCRC;
+	}
+
+	if (ext4_has_feature_metadata_csum(sb) &&
+	    sbi->s_csum_seed != (ext4_has_feature_csum_seed(sb) ?
+		le32_to_cpu(es->s_checksum_seed) :
+		ext4_chksum(~0, es->s_uuid, sizeof(es->s_uuid)))) {
+		ext4_msg(sb, KERN_ERR, "metadata checksum seed changed during journal replay");
+		return -EFSCORRUPTED;
+	}
+
+	if (!ext4_feature_set_ok(sb, replay->readonly))
+		return -EINVAL;
+
+	err = ext4_check_geometry(sb, es, &groups_count);
+	if (err)
+		return err;
+
+	if (groups_count != sbi->s_groups_count ||
+	    es->s_first_meta_bg != old->s_first_meta_bg ||
+	    (incompat & EXT4_FEATURE_INCOMPAT_META_BG) ||
+	    (ro_compat & EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) ||
+	    ((es->s_feature_compat ^ old->s_feature_compat) &
+	     cpu_to_le32(EXT4_FEATURE_COMPAT_SPARSE_SUPER2)) ||
+	    memcmp(es->s_backup_bgs, old->s_backup_bgs, sizeof(es->s_backup_bgs))) {
+		err = ext4_load_group_desc(sb, sb_block, groups_count);
+		if (err)
+			return err;
+	}
+
+	super_set_uuid(sb, es->s_uuid, sizeof(es->s_uuid));
+
+check_descriptors:
+	if (!ext4_check_descriptors(sb, sb_block, 0, replay->first_not_zeroed,
+				    replay->readonly))
+		return -EFSCORRUPTED;
 	return 0;
 }
 
 static int ext4_load_and_init_journal(struct super_block *sb,
 				      struct ext4_super_block *es,
-				      struct ext4_fs_context *ctx)
+				      struct ext4_fs_context *ctx,
+				      ext4_group_t *first_not_zeroed)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	int err;
 
-	err = ext4_load_journal(sb, es, ctx->journal_devnum);
+	err = ext4_load_journal(sb, es, ctx->journal_devnum, first_not_zeroed);
 	if (err)
 		return err;
 
@@ -5406,7 +5542,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 	struct inode *root;
 	int needs_recovery;
 	int err;
-	ext4_group_t first_not_zeroed;
+	ext4_group_t first_not_zeroed, groups_count;
 	struct ext4_fs_context *ctx = fc->fs_private;
 	int silent = fc->sb_flags & SB_SILENT;
 
@@ -5496,7 +5632,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 	if (err)
 		goto failed_mount;
 
-	err = ext4_check_geometry(sb, es);
+	err = ext4_check_geometry(sb, es, &groups_count);
 	if (err)
 		goto failed_mount;
 
@@ -5505,10 +5641,19 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 	mutex_init(&sbi->s_error_notify_mutex);
 	INIT_WORK(&sbi->s_sb_upd_work, update_super_work);
 
-	err = ext4_group_desc_init(sb, es, logical_sb_block, &first_not_zeroed);
+	bgl_lock_init(sbi->s_blockgroup_lock);
+	err = ext4_load_group_desc(sb, logical_sb_block, groups_count);
 	if (err)
 		goto failed_mount3;
 
+	if ((test_opt(sb, NOLOAD) || !ext4_has_feature_journal(sb) ||
+	     !ext4_has_feature_journal_needs_recovery(sb)) &&
+	    !ext4_check_descriptors(sb, logical_sb_block, 0, &first_not_zeroed,
+				    sb_rdonly(sb))) {
+		err = -EFSCORRUPTED;
+		goto failed_mount3;
+	}
+
 	err = ext4_es_register_shrinker(sbi);
 	if (err)
 		goto failed_mount3;
@@ -5574,7 +5719,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 	 * root first: it may be modified in the journal!
 	 */
 	if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) {
-		err = ext4_load_and_init_journal(sb, es, ctx);
+		err = ext4_load_and_init_journal(sb, es, ctx, &first_not_zeroed);
 		if (err)
 			goto failed_mount3a;
 		if (bdev_read_only(sb->s_bdev))
@@ -6169,10 +6314,15 @@ out_bdev:
 
 static int ext4_load_journal(struct super_block *sb,
 			     struct ext4_super_block *es,
-			     unsigned long journal_devnum)
+			     unsigned long journal_devnum,
+			     ext4_group_t *first_not_zeroed)
 {
+	struct ext4_sb_info *sbi = EXT4_SB(sb);
+	struct ext4_replay_callback_data *replay = NULL;
+	jbd2_replay_callback_t callback = NULL;
 	journal_t *journal;
 	unsigned int journal_inum = le32_to_cpu(es->s_journal_inum);
+	bool recover = ext4_has_feature_journal_needs_recovery(sb);
 	dev_t journal_dev;
 	int err = 0;
 	int really_read_only;
@@ -6197,6 +6347,10 @@ static int ext4_load_journal(struct super_block *sb,
 	}
 
 	if (journal_inum) {
+		if (recover &&
+		    !ext4_check_descriptors(sb, sbi->s_sbh->b_blocknr,
+					    journal_inum, NULL, sb_rdonly(sb)))
+			return -EFSCORRUPTED;
 		journal = ext4_open_inode_journal(sb, journal_inum);
 		if (IS_ERR(journal))
 			return PTR_ERR(journal);
@@ -6221,7 +6375,7 @@ static int ext4_load_journal(struct super_block *sb,
 	 * crash?  For recovery, we need to check in advance whether we
 	 * can get read-write access to the device.
 	 */
-	if (ext4_has_feature_journal_needs_recovery(sb)) {
+	if (recover) {
 		if (sb_rdonly(sb)) {
 			ext4_msg(sb, KERN_INFO, "INFO: recovery "
 					"required on readonly filesystem");
@@ -6241,8 +6395,19 @@ static int ext4_load_journal(struct super_block *sb,
 	if (!(journal->j_flags & JBD2_BARRIER))
 		ext4_msg(sb, KERN_INFO, "barriers disabled");
 
-	if (!ext4_has_feature_journal_needs_recovery(sb))
+	if (recover) {
+		replay = kmalloc_obj(*replay);
+		if (!replay) {
+			err = -ENOMEM;
+			goto err_out;
+		}
+		replay->super = *es;
+		replay->first_not_zeroed = first_not_zeroed;
+		replay->readonly = sb_rdonly(sb);
+		callback = ext4_validate_replayed_metadata;
+	} else {
 		err = jbd2_journal_wipe(journal, !really_read_only);
+	}
 	if (!err) {
 		char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL);
 		__le16 orig_state;
@@ -6261,9 +6426,11 @@ static int ext4_load_journal(struct super_block *sb,
 		 */
 		if (enable_write)
 			sb->s_flags &= ~SB_RDONLY;
-		err = jbd2_journal_load(journal);
+		err = jbd2_journal_load_with_callback(journal, callback, replay);
 		if (enable_write)
 			sb->s_flags |= SB_RDONLY;
+		kfree(replay);
+
 		if (save && memcmp(((char *) es) + EXT4_S_ERR_START,
 				   save, EXT4_S_ERR_LEN)) {
 			memcpy(((char *) es) + EXT4_S_ERR_START,
@@ -6285,6 +6452,7 @@ static int ext4_load_journal(struct super_block *sb,
 	}
 
 	if (err) {
+		ext4_fc_replay_cleanup(sb);
 		ext4_msg(sb, KERN_ERR, "error loading journal");
 		goto err_out;
 	}

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

* Re: [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery
  2026-11-19 12:26 ` [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery Zhao Gongyi
@ 2026-11-19 12:34   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-19 12:34 UTC (permalink / raw)
  To: Zhao Gongyi, linux-ext4; +Cc: tytso

> Filesystems can need to validate metadata that block replay has changed
> before fast commit replay consumes it. They can also need to check
> metadata that fast commit replay updates before completing recovery.
> 
> Provide an optional callback after block replay, including when the
> journal is empty, and after fast commit replay. Propagate validation
> errors before resetting the journal. Keep the existing replay flow for
> callers of jbd2_journal_load().
> 
> Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119122601.85293-1-zhaogongyi@bytedance.com?part=1


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

* Re: [PATCH v2 2/2] ext4: reject impossible group free cluster counts
  2026-11-19 12:26 ` [PATCH v2 2/2] ext4: reject impossible group free cluster counts Zhao Gongyi
@ 2026-11-19 13:02   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-19 13:02 UTC (permalink / raw)
  To: Zhao Gongyi, linux-ext4; +Cc: tytso

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] ext4: corrupt replayed superblock committed on error in
  ext4_load_journal()
- [Medium] ext4: early ext4_fc_replay_cleanup() in ext4_load_journal()
  before work flush
- [Medium] ext4: missing s_ea_inode_work flush in
  ext4_validate_replayed_metadata()
- [Medium] ext4: uninitialized sb->s_encoding when replay enables
  casefold feature
--

commit 8d754fdcbde13550773a9fc6bd6d91302151721b
Author: Zhao Gongyi <zhaogongyi@bytedance.com>

ext4: reject impossible group free cluster counts

This commit rejects group descriptor free-cluster counts that exceed the
group's cluster capacity and validates recovered superblock geometry and
group descriptors during journal and fast commit replay.

Link: https://lore.kernel.org/linux-ext4/20261102042428.65204-1-zhaogongyi@bytedance.com/

> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 359f9d4ed4479..68c33a9542897 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c

[ ... ]

> @@ -4939,88 +4970,193 @@ static int ext4_check_geometry(struct super_block *sb,

[ ... ]

> +static int ext4_validate_replayed_metadata(journal_t *journal, void *data,
> +					   bool after_fast_commit)
> +{
> +	struct ext4_replay_callback_data *replay = data;
> +	struct super_block *sb = journal->j_private;
> +	struct ext4_sb_info *sbi = EXT4_SB(sb);
> +	struct ext4_super_block *es = sbi->s_es;
> +	struct ext4_super_block *old = &replay->super;
> +	ext4_fsblk_t sb_block = sbi->s_sbh->b_blocknr;
> +	ext4_group_t groups_count;
> +	unsigned int inode_size, first_ino;
> +	u32 incompat, ro_compat;
> +	int err;
> +
> +	/* Fast commits only change descriptor contents, such as counts. */
> +	if (after_fast_commit) {
> +		if (!(sbi->s_mount_state & EXT4_FC_REPLAY))
> +			return 0;
> +		goto check_descriptors;
> +	}

[Severity: Medium]
Should ext4_validate_replayed_metadata() flush sbi->s_ea_inode_work before
jumping to check_descriptors when after_fast_commit is true?

When fast commit replay unlinks an inode that drops the last reference to an
EA inode, ext4_put_ea_inode() schedules sbi->s_ea_inode_work with a 1-jiffy
delay.  Without flushing that delayed work here, the bg_free_blocks_count
updates from freeing the EA inode's blocks run after descriptor validation has
already completed, and on a read-only mount requiring recovery the work runs
after ext4_load_journal() restores SB_RDONLY, hitting
WARN_ON_ONCE(sb_rdonly(sb)) and failing with -EROFS in
ext4_journal_check_start().

> +	incompat = le32_to_cpu(es->s_feature_incompat ^ old->s_feature_incompat);
> +	ro_compat = le32_to_cpu(es->s_feature_ro_compat ^ old->s_feature_ro_compat);
> +	if (es->s_rev_level == cpu_to_le32(EXT4_GOOD_OLD_REV)) {
> +		inode_size = EXT4_GOOD_OLD_INODE_SIZE;
> +		first_ino = EXT4_GOOD_OLD_FIRST_INO;
> +	} else {
> +		inode_size = le16_to_cpu(es->s_inode_size);
> +		first_ino = le32_to_cpu(es->s_first_ino);
> +	}
> +
> +	/* Online resize can grow the filesystem without changing group units. */
> +	if (es->s_magic != old->s_magic ||
> +	    es->s_log_block_size != old->s_log_block_size ||
> +	    es->s_log_cluster_size != old->s_log_cluster_size ||
> +	    es->s_blocks_per_group != old->s_blocks_per_group ||
> +	    es->s_clusters_per_group != old->s_clusters_per_group ||
> +	    es->s_inodes_per_group != old->s_inodes_per_group ||
> +	    es->s_first_data_block != old->s_first_data_block ||
> +	    inode_size != sbi->s_inode_size || first_ino != sbi->s_first_ino ||
> +	    es->s_desc_size != old->s_desc_size ||
> +	    es->s_log_groups_per_flex != old->s_log_groups_per_flex ||
> +	    ext4_blocks_count(es) < ext4_blocks_count(old) ||
> +	    (incompat & (EXT4_FEATURE_INCOMPAT_64BIT |
> +			 EXT4_FEATURE_INCOMPAT_FLEX_BG)) ||

[Severity: Medium]
Can journal replay enable EXT4_FEATURE_INCOMPAT_CASEFOLD while leaving
sb->s_encoding NULL?

ext4_encoding_init() runs in __ext4_fill_super() before journal replay and
returns early if EXT4_FEATURE_INCOMPAT_CASEFOLD is not set in the unrecovered
superblock.  If journal replay sets EXT4_FEATURE_INCOMPAT_CASEFOLD in
es->s_feature_incompat, ext4_validate_replayed_metadata() neither rejects the
change nor initializes sb->s_encoding, so looking up or hashing any directory
with EXT4_CASEFOLD_FL causes a NULL pointer dereference of sb->s_encoding in
utf8_casefold() -> utf8nlookup().

[ ... ]

> @@ -6261,9 +6426,11 @@ static int ext4_load_journal(struct super_block *sb,
>  		 */
>  		if (enable_write)
>  			sb->s_flags &= ~SB_RDONLY;
> -		err = jbd2_journal_load(journal);
> +		err = jbd2_journal_load_with_callback(journal, callback, replay);
>  		if (enable_write)
>  			sb->s_flags |= SB_RDONLY;
> +		kfree(replay);
> +
>  		if (save && memcmp(((char *) es) + EXT4_S_ERR_START,
>  				   save, EXT4_S_ERR_LEN)) {
>  			memcpy(((char *) es) + EXT4_S_ERR_START,
> @@ -6285,6 +6452,7 @@ static int ext4_load_journal(struct super_block *sb,
>  	}

[Severity: Medium]
If jbd2_journal_load_with_callback() fails because
ext4_validate_replayed_metadata() rejected a corrupt replayed superblock in
es, does the error restoration block right below still write that corrupt
superblock to disk?

When the replayed superblock in sbi->s_sbh differs from the pre-replay save
buffer in EXT4_S_ERR_START..EXT4_S_ERR_END (or EXT4_ERROR_FS is set in
sbi->s_mount_state), changed is set to true even when err is non-zero, and
ext4_commit_super(sb) stamps a newly computed valid checksum onto the rejected
replayed superblock and commits it to disk.

>  	if (err) {
> +		ext4_fc_replay_cleanup(sb);
>  		ext4_msg(sb, KERN_ERR, "error loading journal");
>  		goto err_out;
>  	}

[Severity: Medium]
Does calling ext4_fc_replay_cleanup(sb) here clear EXT4_FC_REPLAY before
failed_mount3a in __ext4_fill_super() flushes sbi->s_ea_inode_work?

In __ext4_fill_super(), failed_mount3a calls
flush_delayed_work(&sbi->s_ea_inode_work) right before
ext4_fc_replay_cleanup(sb) so that any EA inode evictions queued during fast
commit replay run while EXT4_FC_REPLAY is still set.  Clearing EXT4_FC_REPLAY
early in ext4_load_journal() causes those flushed evictions to run in normal
non-replay mode while sbi->s_group_info is still NULL (before ext4_mb_init()),
so ext4_free_inode() sees ext4_get_group_info() == NULL and triggers
ext4_std_error(sb, -EFSCORRUPTED).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119122601.85293-1-zhaogongyi@bytedance.com?part=2

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

end of thread, other threads:[~2026-11-19 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 12:25 [PATCH v2 0/2] ext4: reject impossible group free cluster counts Zhao Gongyi
2026-11-19 12:26 ` [PATCH v2 1/2] jbd2: add a metadata validation hook to journal recovery Zhao Gongyi
2026-11-19 12:34   ` sashiko-bot
2026-11-19 12:26 ` [PATCH v2 2/2] ext4: reject impossible group free cluster counts Zhao Gongyi
2026-11-19 13:02   ` sashiko-bot

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