ext4: enable meta_bg only when new desc blocks are needed
authorSrivathsa Dara <srivathsa.d.dara@oracle.com>
Tue, 27 Feb 2024 13:13:29 +0000 (13:13 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 7 Mar 2024 18:32:54 +0000 (13:32 -0500)
This patch addresses an issue observed when resize_inode is disabled
and an online extension of a filesysyem is performed. When a filesystem
is expanded to a size that does not require a addition of a new
descriptor block, the meta_bg feature is being enabled even though no
part of the filesystem uses this layout.

This patch ensures that the meta_bg feature is only enabled if
any of the added block groups utilize meta_bg layout.

Signed-off-by: Srivathsa Dara <srivathsa.d.dara@oracle.com>
Link: https://lore.kernel.org/r/20240227131329.2608466-1-srivathsa.d.dara@oracle.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/resize.c

index 3c0d12382e0609f324152b18f923871df8d2d95e..0ba9837d65cac90d74e6b2ce23050c4cae165953 100644 (file)
@@ -2085,7 +2085,7 @@ retry:
                }
        }
 
-       if ((!resize_inode && !meta_bg) || n_blocks_count == o_blocks_count) {
+       if ((!resize_inode && !meta_bg && n_desc_blocks > o_desc_blocks) || n_blocks_count == o_blocks_count) {
                err = ext4_convert_meta_bg(sb, resize_inode);
                if (err)
                        goto out;