From: Dave Chinner <david@fromorbit.com>
To: Jinliang Zheng <alexjlzheng@gmail.com>
Cc: cem@kernel.org, djwong@kernel.org, hch@infradead.org,
dchinner@redhat.com, chandanbabu@kernel.org,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Jinliang Zheng <alexjlzheng@tencent.com>
Subject: Re: [RESEND PATCH v2] xfs: fix the entry condition of exact EOF block allocation optimization
Date: Wed, 4 Dec 2024 07:40:20 +1100 [thread overview]
Message-ID: <Z09stGvgxKV91XfX@dread.disaster.area> (raw)
In-Reply-To: <20241130111132.1359138-1-alexjlzheng@tencent.com>
On Sat, Nov 30, 2024 at 07:11:32PM +0800, Jinliang Zheng wrote:
> When we call create(), lseek() and write() sequentially, offset != 0
> cannot be used as a judgment condition for whether the file already
> has extents.
>
> Furthermore, when xfs_bmap_adjacent() has not given a better blkno,
> it is not necessary to use exact EOF block allocation.
>
> Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
> ---
> Changelog:
> - V2: Fix the entry condition
> - V1: https://lore.kernel.org/linux-xfs/ZyFJm7xg7Msd6eVr@dread.disaster.area/T/#t
> ---
> fs/xfs/libxfs/xfs_bmap.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 36dd08d13293..c1e5372b6b2e 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -3531,12 +3531,14 @@ xfs_bmap_btalloc_at_eof(
> int error;
>
> /*
> - * If there are already extents in the file, try an exact EOF block
> - * allocation to extend the file as a contiguous extent. If that fails,
> - * or it's the first allocation in a file, just try for a stripe aligned
> - * allocation.
> + * If there are already extents in the file, and xfs_bmap_adjacent() has
> + * given a better blkno, try an exact EOF block allocation to extend the
> + * file as a contiguous extent. If that fails, or it's the first
> + * allocation in a file, just try for a stripe aligned allocation.
> */
> - if (ap->offset) {
> + if (ap->prev.br_startoff != NULLFILEOFF &&
> + !isnullstartblock(ap->prev.br_startblock) &&
> + xfs_bmap_adjacent_valid(ap, ap->blkno, ap->prev.br_startblock)) {
There's no need for calling xfs_bmap_adjacent_valid() here -
we know that ap->blkno is valid because the
bounds checking has already been done by xfs_bmap_adjacent().
Actually, for another patch, the bounds checking in
xfs_bmap_adjacent_valid() is incorrect. What happens if the last AG
is a runt? i.e. it open codes xfs_verify_fsbno() and gets it wrong.
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-12-03 20:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-30 11:11 [RESEND PATCH v2] xfs: fix the entry condition of exact EOF block allocation optimization Jinliang Zheng
2024-12-03 20:40 ` Dave Chinner [this message]
2024-12-05 12:18 ` Jinliang Zheng
2024-12-05 23:48 ` Dave Chinner
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=Z09stGvgxKV91XfX@dread.disaster.area \
--to=david@fromorbit.com \
--cc=alexjlzheng@gmail.com \
--cc=alexjlzheng@tencent.com \
--cc=cem@kernel.org \
--cc=chandanbabu@kernel.org \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.