From: "Darrick J. Wong" <djwong@kernel.org>
To: Jinliang Zheng <alexjlzheng@gmail.com>
Cc: dchinner@redhat.com, cem@kernel.org, chandanbabu@kernel.org,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Jinliang Zheng <alexjlzheng@tencent.com>
Subject: Re: [PATCH v2] xfs: check the remaining length of extent after roundup
Date: Thu, 7 Nov 2024 12:05:39 -0800 [thread overview]
Message-ID: <20241107200539.GR2386201@frogsfrogsfrogs> (raw)
In-Reply-To: <20241107084044.182463-1-alexjlzheng@tencent.com>
On Thu, Nov 07, 2024 at 04:40:44PM +0800, Jinliang Zheng wrote:
> In xfs_alloc_compute_diff(), ensure that the remaining length of extent
> still meets the wantlen requirements after newbno1 is rounded.
What problem are you observing?
--D
> Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
> ---
> Changelog:
>
> V2: Fix the error logic
>
> V1: https://lore.kernel.org/linux-xfs/20241107070300.13535-1-alexjlzheng@tencent.com/#R
> ---
> fs/xfs/libxfs/xfs_alloc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 22bdbb3e9980..1d4cc75b7318 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -393,7 +393,8 @@ xfs_alloc_compute_diff(
> * grows in the short term.
> */
> if (freebno >= wantbno || (userdata && freeend < wantend)) {
> - if ((newbno1 = roundup(freebno, alignment)) >= freeend)
> + newbno1 = roundup(freebno, alignment);
> + if (newbno1 >= freeend || newbno1 > freeend - wantlen)
> newbno1 = NULLAGBLOCK;
> } else if (freeend >= wantend && alignment > 1) {
> newbno1 = roundup(wantbno, alignment);
> @@ -414,6 +415,8 @@ xfs_alloc_compute_diff(
> newbno1 = newbno2;
> } else if (newbno2 != NULLAGBLOCK)
> newbno1 = newbno2;
> + if (newbno1 > freeend - wantlen)
> + newbno1 = NULLAGBLOCK;
> } else if (freeend >= wantend) {
> newbno1 = wantbno;
> } else if (alignment > 1) {
> --
> 2.41.1
>
>
next prev parent reply other threads:[~2024-11-07 20:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 8:40 Jinliang Zheng
2024-11-07 20:05 ` Darrick J. Wong [this message]
2024-11-08 9:32 ` Jinliang Zheng
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=20241107200539.GR2386201@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=alexjlzheng@gmail.com \
--cc=alexjlzheng@tencent.com \
--cc=cem@kernel.org \
--cc=chandanbabu@kernel.org \
--cc=dchinner@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@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
all inboxes | Powered by JetHome®