Skip to contentSkip to conversation

ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem

PATCH Applied Darrick J. Wong 2 participants 3 messages Dec 20, 2013 – May 12, 2014 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Find the group descriptors on a 1k-block bigalloc,meta_bg filesystem

On a filesystem with a 1k block size, the group descriptors live in block 2, not block 1. If the filesystem has bigalloc,meta_bg set, however, the calculation of the group descriptor table location does not take this into account and returns the wrong block number. Fix the calculation to return the correct value for this case.

---
 fs/ext4/super.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
fs/ext4/super.c +10 -0
index 7f52a54..d968c64 100644
@@ -2420,6 +2420,16 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
 	if (ext4_bg_has_super(sb, bg))
 		has_super = 1;
 
+	/*
+	 * If we have a meta_bg fs with 1k blocks, group 0's GDT is at
+	 * block 2, not 1.  If s_first_data_block == 0 (bigalloc is enabled
+	 * on modern mke2fs or blksize > 1k on older mke2fs) then we must
+	 * compensate.
+	 */
+	if (sb->s_blocksize == 1024 && nr == 0 &&
+	    le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) == 0)
+		has_super++;
+
 	return (has_super + ext4_group_first_block_no(sb, bg));
 }
 
#1 lore raw
Quoted 5 lines · Darrick J. Wong

On a filesystem with a 1k block size, the group descriptors live in block 2, not block 1. If the filesystem has bigalloc,meta_bg set, however, the calculation of the group descriptor table location does not take this into account and returns the wrong block number. Fix the calculation to return the correct value for this case.

Hey Ted,

Any comments on this one?

--D

Quoted 31 lines
---
 fs/ext4/super.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
fs/ext4/super.c +10 -1
index 7f52a54..d968c64 100644
@@ -2420,6 +2420,16 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
 	if (ext4_bg_has_super(sb, bg))
 		has_super = 1;
 
+	/*
+	 * If we have a meta_bg fs with 1k blocks, group 0's GDT is at
+	 * block 2, not 1.  If s_first_data_block == 0 (bigalloc is enabled
+	 * on modern mke2fs or blksize > 1k on older mke2fs) then we must
+	 * compensate.
+	 */
+	if (sb->s_blocksize == 1024 && nr == 0 &&
+	    le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) == 0)
+		has_super++;
+
 	return (has_super + ext4_group_first_block_no(sb, bg));
 }
 
--

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#2 lore raw
In reply to Darrick J. Wong
Quoted 7 lines · Darrick J. Wong

On a filesystem with a 1k block size, the group descriptors live in block 2, not block 1. If the filesystem has bigalloc,meta_bg set, however, the calculation of the group descriptor table location does not take this into account and returns the wrong block number. Fix the calculation to return the correct value for this case.

Thanks, applied.

- Ted