2022-06-29 04:03:11

by Theodore Ts'o

[permalink] [raw]
Subject: [PATCH 1/2] ext4: update s_overhead_clusters in the superblock during an on-line resize

When doing an online resize, the on-disk superblock on-disk wasn't
updated. This means that when the file system is unmounted and
remounted, and the on-disk overhead value is non-zero, this would
result in the results of statfs(2) to be incorrect.

This was partially fixed by Commits 10b01ee92df5 ("ext4: fix overhead
calculation to account for the reserved gdt blocks"), 85d825dbf489
("ext4: force overhead calculation if the s_overhead_cluster makes no
sense"), and eb7054212eac ("ext4: update the cached overhead value in
the superblock").

However, since it was too expensive to forcibly recalculate the
overhead for bigalloc file systems at every mount, this didn't fix the
problem for bigalloc file systems. This commit should address the
problem when resizing file systems with the bigalloc feature enabled.

Signed-off-by: Theodore Ts'o <[email protected]>
Cc: [email protected]
---
fs/ext4/resize.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 8b70a4701293..e5c2713aa11a 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1484,6 +1484,7 @@ static void ext4_update_super(struct super_block *sb,
* Update the fs overhead information
*/
ext4_calculate_overhead(sb);
+ es->s_overhead_clusters = cpu_to_le32(sbi->s_overhead);

if (test_opt(sb, DEBUG))
printk(KERN_DEBUG "EXT4-fs: added group %u:"
--
2.31.0


2022-07-04 20:48:51

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext4: update s_overhead_clusters in the superblock during an on-line resize

On Jun 28, 2022, at 10:00 PM, Theodore Ts'o <[email protected]> wrote:
>
> When doing an online resize, the on-disk superblock on-disk wasn't
> updated. This means that when the file system is unmounted and
> remounted, and the on-disk overhead value is non-zero, this would
> result in the results of statfs(2) to be incorrect.
>
> This was partially fixed by Commits 10b01ee92df5 ("ext4: fix overhead
> calculation to account for the reserved gdt blocks"), 85d825dbf489
> ("ext4: force overhead calculation if the s_overhead_cluster makes no
> sense"), and eb7054212eac ("ext4: update the cached overhead value in
> the superblock").

Would these be better referenced by Fixes: labels?

> However, since it was too expensive to forcibly recalculate the
> overhead for bigalloc file systems at every mount, this didn't fix the
> problem for bigalloc file systems. This commit should address the
> problem when resizing file systems with the bigalloc feature enabled.
>
> Signed-off-by: Theodore Ts'o <[email protected]>
> Cc: [email protected]

Reviewed-by: Andreas Dilger <[email protected]>

> ---
> fs/ext4/resize.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
> index 8b70a4701293..e5c2713aa11a 100644
> --- a/fs/ext4/resize.c
> +++ b/fs/ext4/resize.c
> @@ -1484,6 +1484,7 @@ static void ext4_update_super(struct super_block *sb,
> * Update the fs overhead information
> */
> ext4_calculate_overhead(sb);
> + es->s_overhead_clusters = cpu_to_le32(sbi->s_overhead);
>
> if (test_opt(sb, DEBUG))
> printk(KERN_DEBUG "EXT4-fs: added group %u:"
> --
> 2.31.0
>


Cheers, Andreas






Attachments:
signature.asc (890.00 B)
Message signed with OpenPGP

2022-07-07 14:35:17

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext4: update s_overhead_clusters in the superblock during an on-line resize

On Mon, Jul 04, 2022 at 02:47:43PM -0600, Andreas Dilger wrote:
> On Jun 28, 2022, at 10:00 PM, Theodore Ts'o <[email protected]> wrote:
> >
> > When doing an online resize, the on-disk superblock on-disk wasn't
> > updated. This means that when the file system is unmounted and
> > remounted, and the on-disk overhead value is non-zero, this would
> > result in the results of statfs(2) to be incorrect.
> >
> > This was partially fixed by Commits 10b01ee92df5 ("ext4: fix overhead
> > calculation to account for the reserved gdt blocks"), 85d825dbf489
> > ("ext4: force overhead calculation if the s_overhead_cluster makes no
> > sense"), and eb7054212eac ("ext4: update the cached overhead value in
> > the superblock").
>
> Would these be better referenced by Fixes: labels?

This commit doesn't actually _fix_ the above-mentioned commits. They
just didn't fix the bug which is addressed by this one.

Cheers,

- Ted

2022-07-08 03:20:40

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext4: update s_overhead_clusters in the superblock during an on-line resize

On Wed, 29 Jun 2022 00:00:25 -0400, Theodore Ts'o wrote:
> When doing an online resize, the on-disk superblock on-disk wasn't
> updated. This means that when the file system is unmounted and
> remounted, and the on-disk overhead value is non-zero, this would
> result in the results of statfs(2) to be incorrect.
>
> This was partially fixed by Commits 10b01ee92df5 ("ext4: fix overhead
> calculation to account for the reserved gdt blocks"), 85d825dbf489
> ("ext4: force overhead calculation if the s_overhead_cluster makes no
> sense"), and eb7054212eac ("ext4: update the cached overhead value in
> the superblock").
>
> [...]

Applied, thanks!

[1/2] ext4: update s_overhead_clusters in the superblock during an on-line resize
commit: e781b8ce9261f353df91b94303e53c31fdf9871e
[2/2] ext4: update the s_overhead_clusters in the backup sb's when resizing
commit: 2c8204b83ceaf439dff2d1a94a7e2d3ad7619287

Best regards,
--
Theodore Ts'o <[email protected]>