Re: [PATCH 11/13] ext4: correct gdblock calculation in add_new_gdb_meta_bg to support non first group

From: Theodore Ts'o
Date: Fri Aug 18 2023 - 12:55:34 EST


On Fri, Aug 18, 2023 at 03:09:35PM +0800, Kemeng Shi wrote:
> > Is following comment looks good to you:
>
> When all reserved primary blocks are consumed, we create meta_bg group and
> allocate new primary block at first block or block after backup superblock
> (if exsiting) in first group of meta_bg group.
> This function is only called when first group of meta_bg is added.

Well, it's possible to create a file system where all of the block
group descriptors use meta_bg, and there are no "traditional" block
group descriptors. And so what happens is if there is no available
space in the existing block group descriptors for the new block group,
and there are no reserved block group descriptors (I'd remove
"primary" as that's not something that we've used traditionally), then
what happens is that the meta_bg feature will get enabled, and
es->s_first_meta_bg will get set to the first block group that is
managed using meta_bg. s_first_meta_bg must be a multiple of
EXT4_DESC_PER_BLOCK(sb).

Some of this is documented in Documentation/filesystems/ext4/blockgroup.rst
already.

Cheers,

- Ted