[04/10] ext2fs: Don't create filesystems with meta_bg and resize_inode

Message ID 20180530125118.25274-5-jack@suse.cz
State Superseded, archived
Headers show
Series
  • e2fsprogs: Handle s_inodes_count overflow better
Related show

Commit Message

Jan Kara May 30, 2018, 12:51 p.m.
ext2fs_initialize() may end up enabling meta_bg feature for filesystem
which have resize_inode. Such combination is invalid to make sure we
disable resize_inode when enabling meta_bg.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 lib/ext2fs/initialize.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Andreas Dilger June 4, 2018, 4:27 a.m. | #1
On May 30, 2018, at 6:51 AM, Jan Kara <jack@suse.cz> wrote:
> 
> ext2fs_initialize() may end up enabling meta_bg feature for filesystem
> which have resize_inode. Such combination is invalid to make sure we
> disable resize_inode when enabling meta_bg.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> lib/ext2fs/initialize.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
> index e1eff22eac33..8c9e97fee831 100644
> --- a/lib/ext2fs/initialize.c
> +++ b/lib/ext2fs/initialize.c
> @@ -382,6 +382,13 @@ ipg_retry:
> 		retval = EXT2_ET_RES_GDT_BLOCKS;
> 		goto cleanup;
> 	}
> +	/* Enable meta_bg if we'd lose more than 3/4 of a BG to GDT blocks. */
> +	if (super->s_reserved_gdt_blocks + fs->desc_blocks >
> +	    super->s_blocks_per_group * 3 / 4) {
> +		ext2fs_set_feature_meta_bg(fs->super);
> +		ext2fs_clear_feature_resize_inode(fs->super);
> +		set_field(s_reserved_gdt_blocks, 0);
> +	}
> 
> 	/*
> 	 * Calculate the maximum number of bookkeeping blocks per
> @@ -392,11 +399,6 @@ ipg_retry:
> 	overhead = (int) (3 + fs->inode_blocks_per_group +
> 			  super->s_reserved_gdt_blocks);
> 
> -	/* Enable meta_bg if we'd lose more than 3/4 of a BG to GDT blocks. */
> -	if (super->s_reserved_gdt_blocks + fs->desc_blocks >
> -	    super->s_blocks_per_group * 3 / 4)
> -		ext2fs_set_feature_meta_bg(fs->super);
> -
> 	if (ext2fs_has_feature_meta_bg(fs->super))
> 		overhead++;
> 	else
> --
> 2.13.6
> 


Cheers, Andreas

Patch

diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index e1eff22eac33..8c9e97fee831 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -382,6 +382,13 @@  ipg_retry:
 		retval = EXT2_ET_RES_GDT_BLOCKS;
 		goto cleanup;
 	}
+	/* Enable meta_bg if we'd lose more than 3/4 of a BG to GDT blocks. */
+	if (super->s_reserved_gdt_blocks + fs->desc_blocks >
+	    super->s_blocks_per_group * 3 / 4) {
+		ext2fs_set_feature_meta_bg(fs->super);
+		ext2fs_clear_feature_resize_inode(fs->super);
+		set_field(s_reserved_gdt_blocks, 0);
+	}
 
 	/*
 	 * Calculate the maximum number of bookkeeping blocks per
@@ -392,11 +399,6 @@  ipg_retry:
 	overhead = (int) (3 + fs->inode_blocks_per_group +
 			  super->s_reserved_gdt_blocks);
 
-	/* Enable meta_bg if we'd lose more than 3/4 of a BG to GDT blocks. */
-	if (super->s_reserved_gdt_blocks + fs->desc_blocks >
-	    super->s_blocks_per_group * 3 / 4)
-		ext2fs_set_feature_meta_bg(fs->super);
-
 	if (ext2fs_has_feature_meta_bg(fs->super))
 		overhead++;
 	else