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

From: Kemeng Shi
Date: Mon Aug 21 2023 - 22:48:20 EST




on 8/19/2023 12:54 AM, Theodore Ts'o wrote:
> 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.
>
As these information into comment of add_new_gdb_meta_bg could help to some
dgree. I summary the information to:

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, then
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 and s_first_meta_bg
must be a multiple of EXT4_DESC_PER_BLOCK(sb).
This function will be called when first group of meta_bg is added to bring
new group descriptors block of new added meta_bg.

Or I will leave comments unchange in next version if it's redundant to you.
Thanks!
> Cheers,
>
> - Ted
>