Skip to contentSkip to conversation

ext4: recalculate s_blockfile_groups during resize2fs

PATCH In review Eric Sandeen 4 participants 5 messages May 3, 2013 – May 6, 2013 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: recalculate s_blockfile_groups during resize2fs

s_blockfile_groups is used to limit allocations for non-extent files to block groups with block numbers less than 2^32. However, it's not updated when the filesystem is resized online, so the new groups are unavailable to non-extent files until a remount.

Fix this by updating the value in ext4_update_super() at resize time.

---

fs/ext4/resize.c +2 -0
index c169477..1357260 100644
@@ -1341,6 +1341,8 @@ static void ext4_update_super(struct super_block *sb,
 
 	/* Update the global fs size fields */
 	sbi->s_groups_count += flex_gd->count;
+	sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
+			(EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
 
 	/* Update the reserved block counts only once the new group is
 	 * active. */
#1 lore raw

----- Original Message -----

Quoted 26 lines

s_blockfile_groups is used to limit allocations for non-extent files to block groups with block numbers less than 2^32. However, it's not updated when the filesystem is resized online, so the new groups are unavailable to non-extent files until a remount.

Fix this by updating the value in ext4_update_super() at resize time.

---

fs/ext4/resize.c +2 -1
index c169477..1357260 100644
@@ -1341,6 +1341,8 @@ static void ext4_update_super(struct super_block *sb,
 
 	/* Update the global fs size fields */
 	sbi->s_groups_count += flex_gd->count;
+	sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
+			(EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
 
 	/* Update the reserved block counts only once the new group is
 	 * active. */
 
--
Quoted 4 lines

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

Good catch Eric - this would have prevented the bug in ext4_mb_regular_allocator() too. Looks good to me.

#2 lore raw
Quoted 26 lines · Lachlan McIlroy

----- Original Message -----

Quoted 25 lines

s_blockfile_groups is used to limit allocations for non-extent files to block groups with block numbers less than 2^32. However, it's not updated when the filesystem is resized online, so the new groups are unavailable to non-extent files until a remount.

Fix this by updating the value in ext4_update_super() at resize time.

---

fs/ext4/resize.c +2 -0
index c169477..1357260 100644
@@ -1341,6 +1341,8 @@ static void ext4_update_super(struct super_block *sb,
 
 	/* Update the global fs size fields */
 	sbi->s_groups_count += flex_gd->count;
+	sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
+			(EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
 
 	/* Update the reserved block counts only once the new group is
 	 * active. */
Quoted 8 lines
Quoted 5 lines

--
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

Good catch Eric - this would have prevented the bug in ext4_mb_regular_allocator() too. Looks good to me.

Yep - at least until the filesystem grows > 16TB :)

-Eric

maintainer
#3 lore raw
In reply to Eric Sandeen
Quoted 9 lines · Eric Sandeen

s_blockfile_groups is used to limit allocations for non-extent files to block groups with block numbers less than 2^32. However, it's not updated when the filesystem is resized online, so the new groups are unavailable to non-extent files until a remount.

Fix this by updating the value in ext4_update_super() at resize time.

I sent out a patch about two weeks ago, which has since been accepted into Linus's tree as commit c5c72d814cf0. It's been marked for the for backporting into the stable trees.

Cheers,

- Ted

commit c5c72d814cf0f650010337c73638b25e6d14d2d4

Author: Theodore Ts'o <[email protected]>
Date:   Sun Apr 21 20:19:43 2013 -0400

ext4: fix online resizing for ext3-compat file systems

Commit fb0a387dcdc restricts block allocations for indirect-mapped files to block groups less than s_blockfile_groups. However, the online resizing code wasn't setting s_blockfile_groups, so the newly added block groups were not available for non-extent mapped files.

#4 lore raw
Quoted 6 lines · Theodore Ts'o
Quoted 5 lines · Eric Sandeen

s_blockfile_groups is used to limit allocations for non-extent files to block groups with block numbers less than 2^32. However, it's not updated when the filesystem is resized online, so the new groups are unavailable to non-extent files until a remount.

Quoted 9 lines
Quoted 4 lines

Fix this by updating the value in ext4_update_super() at resize time.

I sent out a patch about two weeks ago, which has since been accepted into Linus's tree as commit c5c72d814cf0. It's been marked for the for backporting into the stable trees.

Argh, so you did! One demerit for me for forgetting, and another for patching an old tree....

Thanks,
Eric

Quoted 18 lines

Cheers,

- Ted

commit c5c72d814cf0f650010337c73638b25e6d14d2d4

Author: Theodore Ts'o <[email protected]>
Date:   Sun Apr 21 20:19:43 2013 -0400

ext4: fix online resizing for ext3-compat file systems

Commit fb0a387dcdc restricts block allocations for indirect-mapped files to block groups less than s_blockfile_groups. However, the online resizing code wasn't setting s_blockfile_groups, so the newly added block groups were not available for non-extent mapped files.