[PATCH] befs: Fix incorrect superblock consistency check

Daniel Martín Gómez posted 1 patch 2 days, 22 hours ago
fs/befs/super.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH] befs: Fix incorrect superblock consistency check
Posted by Daniel Martín Gómez 2 days, 22 hours ago
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.

Signed-off-by: Daniel Martín Gómez <dalmemail@gmail.com>
---
 fs/befs/super.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/befs/super.c b/fs/befs/super.c
index 7c50025c99d8..a900ef8402af 100644
--- a/fs/befs/super.c
+++ b/fs/befs/super.c
@@ -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 ||
-- 
2.39.5

Re: [PATCH] befs: Fix incorrect superblock consistency check
Posted by Markus Elfring 1 day, 20 hours ago
> 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