From: Christoph Hellwig <hch@infradead.org>
To: Morduan Zang <zhangdandan@uniontech.com>
Cc: brauner@kernel.org, linux-fsdevel@vger.kernel.org,
linux-xfs@vger.kernel.org, djwong@kernel.org
Subject: Re: [PATCH] iomap: guard io_size EOF trim against concurrent truncate underflow
Date: Thu, 18 Jun 2026 02:08:12 -0700 [thread overview]
Message-ID: <ajO1fOJZlmICeSAv@infradead.org> (raw)
In-Reply-To: <863D407CB3ECEB04+20260618053820.506635-1-zhangdandan@uniontech.com>
On Thu, Jun 18, 2026 at 01:38:20PM +0800, Morduan Zang wrote:
> However, ioend can be created before a concurrent truncate shrinks
> the file. In that case, end_pos can move below ioend->io_offset
> before the trim happens. The subtraction then becomes negative, but
> the result is stored in size_t io_size, causing an unsigned wrap to
> a huge value.
>
> A wrapped io_size can mislead append detection and corrupt
> completion-time size handling, since filesystem end_io paths consume
> io_size for decisions such as on-disk EOF updates and unwritten/COW
> completion ranges.
Do you have examples for this? I.e. did you hit this with a workload,
or did you just look over the code for issues?
> + if (ioend->io_offset + ioend->io_size > end_pos) {
> + if (end_pos > ioend->io_offset)
> + ioend->io_size = end_pos - ioend->io_offset;
> + else
> + ioend->io_size = 0;
> + }
I find this a bit hard to read due to different paramter ordering,
i.e. why not:
if (ioend->io_offset + ioend->io_size > end_pos) {
if (ioend->io_offset >= end_pos)
ioend->io_size = 0;
else
ioend->io_size = end_pos - ioend->io_offset;
}
next prev parent reply other threads:[~2026-06-18 9:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-18 5:38 [PATCH] iomap: guard io_size EOF trim against concurrent truncate underflow Morduan Zang
2026-06-18 9:08 ` Christoph Hellwig [this message]
2026-06-18 11:03 ` Morduan Zang
2026-06-18 13:36 ` Christoph Hellwig
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=ajO1fOJZlmICeSAv@infradead.org \
--to=hch@infradead.org \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zhangdandan@uniontech.com \
/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