public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Tso" <tytso@mit.edu>
To: Baokun Li <libaokun@linux.alibaba.com>
Cc: Jan Kara <jack@suse.cz>,
	Ext4 Developers List <linux-ext4@vger.kernel.org>
Subject: Re: [RFC PATCH] ext4: handle wraparound when searching for blocks for indirect mapped blocks
Date: Fri, 13 Mar 2026 10:31:01 -0400	[thread overview]
Message-ID: <20260313143101.GA38016@macsyma-wired.lan> (raw)
In-Reply-To: <2a047aeb-6db8-4be9-8908-b12632d5e632@linux.alibaba.com>

On Fri, Mar 13, 2026 at 10:00:04AM +0800, Baokun Li wrote:
> IIUC, ngroups/end here only depend on filesystem size and whether the inode
> is extent-based, and both should stay unchanged during block allocation.
> So doing the check once at the beginning should be sufficient. Am I missing
> anything?

The problem here is that case where we use
ext4_get_allocation_groups_count as ngroups and end are different.  In
some places we do this:

        ext4_group_t ngroups = ext4_get_allocation_groups_count(ac);

and in others we do this:

        end = ext4_get_allocation_groups_count(ac);

Now, if start is zero, then these two are equivalent.  But if start is
not zero, but say, is 2**32 - 8, then where we use
ext4_allocaiton_groups_count() as the last block group to search, then
we only will search exactly 8 block groups, and if
there are free blocks in the first 8 block groups, then the scanning
function will fail.

Alternatively, if we just do the check at the beginning, then 2**32 -
8 is a valid starting point, but if we just search forward by ngroups,
then we may end up returning a block group which won't work for
indirect mapped inodes.

Hence, in *every* function where we call
ext4_get_allocaiton_groups_count(), if the goal is to search all block
groups that are valid for indirect mapped inodes, and start might be
greater than 0, we *have* to handle wraparound.

Does that make sense?

						- Ted

  reply	other threads:[~2026-03-13 14:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 12:28 [RFC PATCH] ext4: handle wraparound when searching for blocks for indirect mapped blocks Theodore Ts'o
2026-03-11  2:38 ` Baokun Li
2026-03-12 14:23   ` Theodore Tso
2026-03-13  2:00     ` Baokun Li
2026-03-13 14:31       ` Theodore Tso [this message]
2026-03-14  7:41         ` Baokun Li

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=20260313143101.GA38016@macsyma-wired.lan \
    --to=tytso@mit.edu \
    --cc=jack@suse.cz \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    /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