Skip to contentSkip to conversation

befs: Fix incorrect superblock consistency check

PATCH In review Daniel Martín Gómez 2 participants 2 messages Nov 18, 2024 – Nov 19, 2024 Befs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 befs: Fix incorrect superblock consistency check

The check assumes that blocks_per_ag records the number of blocks in an allocation group, but section 4.5 of Practical File System Design with the Be File System states that "The blocks_per_ag field of the superblock refers to the number of bitmap blocks that are in each allocation group". This causes befs driver to write an error to the log each time a volume is mounted. Change the check to correctly compute the number of blocks on each allocation group using blocks_per_ag.

---
 fs/befs/super.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/befs/super.c +5 -2
index 7c50025c99d8..a900ef8402af 100644
@@ -101,9 +101,12 @@ befs_check_sb(struct super_block *sb)
 
 
 	/* ag_shift also encodes the same information as blocks_per_ag in a
-	 * different way, non-fatal consistency check
+	 * different way, non-fatal consistency check.
+	 * Beware that blocks_per_ag holds the number of bitmap blocks in
+	 * each allocation group.
 	 */
-	if ((1 << befs_sb->ag_shift) != befs_sb->blocks_per_ag)
+	if ((1 << befs_sb->ag_shift) !=
+	    befs_sb->blocks_per_ag * befs_sb->block_size * 8)
 		befs_error(sb, "ag_shift disagrees with blocks_per_ag.");
 
 	if (befs_sb->log_start != befs_sb->log_end ||
Signature · 1 line
2.39.5
#1 lore raw
Quoted 4 lines

The check assumes that blocks_per_ag records the number of blocks in an allocation group, but section 4.5 of Practical File System Design with the Be File System states that "The blocks_per_ag field of the superblock

…

You may occasionally put more than 55 characters into text lines for an improved change description.

Regards,
Markus