public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Baokun Li <libaokun1@huawei.com>
To: Jan Kara <jack@suse.cz>
Cc: Ted Tso <tytso@mit.edu>, <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 1/2] ext4: always allocate blocks only from groups inode can use
Date: Sat, 10 Jan 2026 08:59:01 +0800	[thread overview]
Message-ID: <79ccd2c3-e8f8-4d4e-a61e-01d7b32fa8b6@huawei.com> (raw)
In-Reply-To: <20260109105354.16008-3-jack@suse.cz>

On 2026-01-09 18:53, Jan Kara wrote:
> For filesystems with more than 2^32 blocks inodes using indirect block
> based format cannot use blocks beyond the 32-bit limit.
> ext4_mb_scan_groups_linear() takes care to not select these unsupported
> groups for such inodes however other functions selecting groups for
> allocation don't. So far this is harmless because the other selection
> functions are used only with mb_optimize_scan and this is currently
> disabled for inodes with indirect blocks however in the following patch
> we want to enable mb_optimize_scan regardless of inode format.
>
> Signed-off-by: Jan Kara <jack@suse.cz>

Looks good, thanks for the patch!

Reviewed-by: Baokun Li <libaokun1@huawei.com>

> ---
>  fs/ext4/mballoc.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 56d50fd3310b..f0e07bf11a93 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -892,6 +892,18 @@ mb_update_avg_fragment_size(struct super_block *sb, struct ext4_group_info *grp)
>  	}
>  }
>  
> +static ext4_group_t ext4_get_allocation_groups_count(
> +				struct ext4_allocation_context *ac)
> +{
> +	ext4_group_t ngroups = ext4_get_groups_count(ac->ac_sb);
> +
> +	/* non-extent files are limited to low blocks/groups */
> +	if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)))
> +		ngroups = EXT4_SB(ac->ac_sb)->s_blockfile_groups;
> +
> +	return ngroups;
> +}
> +
>  static int ext4_mb_scan_groups_xa_range(struct ext4_allocation_context *ac,
>  					struct xarray *xa,
>  					ext4_group_t start, ext4_group_t end)
> @@ -899,7 +911,7 @@ static int ext4_mb_scan_groups_xa_range(struct ext4_allocation_context *ac,
>  	struct super_block *sb = ac->ac_sb;
>  	struct ext4_sb_info *sbi = EXT4_SB(sb);
>  	enum criteria cr = ac->ac_criteria;
> -	ext4_group_t ngroups = ext4_get_groups_count(sb);
> +	ext4_group_t ngroups = ext4_get_allocation_groups_count(ac);
>  	unsigned long group = start;
>  	struct ext4_group_info *grp;
>  
> @@ -951,7 +963,7 @@ static int ext4_mb_scan_groups_p2_aligned(struct ext4_allocation_context *ac,
>  	ext4_group_t start, end;
>  
>  	start = group;
> -	end = ext4_get_groups_count(ac->ac_sb);
> +	end = ext4_get_allocation_groups_count(ac);
>  wrap_around:
>  	for (i = ac->ac_2order; i < MB_NUM_ORDERS(ac->ac_sb); i++) {
>  		ret = ext4_mb_scan_groups_largest_free_order_range(ac, i,
> @@ -1001,7 +1013,7 @@ static int ext4_mb_scan_groups_goal_fast(struct ext4_allocation_context *ac,
>  	ext4_group_t start, end;
>  
>  	start = group;
> -	end = ext4_get_groups_count(ac->ac_sb);
> +	end = ext4_get_allocation_groups_count(ac);
>  wrap_around:
>  	i = mb_avg_fragment_size_order(ac->ac_sb, ac->ac_g_ex.fe_len);
>  	for (; i < MB_NUM_ORDERS(ac->ac_sb); i++) {
> @@ -1083,7 +1095,7 @@ static int ext4_mb_scan_groups_best_avail(struct ext4_allocation_context *ac,
>  		min_order = fls(ac->ac_o_ex.fe_len);
>  
>  	start = group;
> -	end = ext4_get_groups_count(ac->ac_sb);
> +	end = ext4_get_allocation_groups_count(ac);
>  wrap_around:
>  	for (i = order; i >= min_order; i--) {
>  		int frag_order;
> @@ -1182,11 +1194,7 @@ static int ext4_mb_scan_groups(struct ext4_allocation_context *ac)
>  	int ret = 0;
>  	ext4_group_t start;
>  	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
> -	ext4_group_t ngroups = ext4_get_groups_count(ac->ac_sb);
> -
> -	/* non-extent files are limited to low blocks/groups */
> -	if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)))
> -		ngroups = sbi->s_blockfile_groups;
> +	ext4_group_t ngroups = ext4_get_allocation_groups_count(ac);
>  
>  	/* searching for the right group start from the goal value specified */
>  	start = ac->ac_g_ex.fe_group;



  reply	other threads:[~2026-01-10  0:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09 10:53 [PATCH 0/2 v2] ext4: use mb_optimize_scan regardless of inode format Jan Kara
2026-01-09 10:53 ` [PATCH 1/2] ext4: always allocate blocks only from groups inode can use Jan Kara
2026-01-10  0:59   ` Baokun Li [this message]
2026-01-10  1:36   ` Zhang Yi
2026-01-13 16:28   ` Pedro Falcato
2026-01-14 17:26     ` Jan Kara
2026-01-09 10:53 ` [PATCH 2/2] ext4: use optimized mballoc scanning regardless of inode format Jan Kara
2026-01-10  1:00   ` Baokun Li
2026-01-10  1:38   ` Zhang Yi
  -- strict thread matches above, loose matches on Subject: below --
2026-01-14 18:28 [PATCH 0/2 v3] ext4: use mb_optimize_scan " Jan Kara
2026-01-14 18:28 ` [PATCH 1/2] ext4: always allocate blocks only from groups inode can use Jan Kara
2026-01-15 11:59   ` Pedro Falcato
2026-01-28 18:05   ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79ccd2c3-e8f8-4d4e-a61e-01d7b32fa8b6@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox