public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Long Li <leo.lilong@huawei.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: <djwong@kernel.org>, <cem@kernel.org>, <brauner@kernel.org>,
	<linux-xfs@vger.kernel.org>, <david@fromorbit.com>,
	<yi.zhang@huawei.com>, <houtao1@huawei.com>,
	<yangerkun@huawei.com>, <lonuxli.64@gmail.com>
Subject: Re: [PATCH] iomap: fix zero padding data issue in concurrent append writes
Date: Sat, 9 Nov 2024 15:13:53 +0800	[thread overview]
Message-ID: <Zy8Lsee7EDodz5Xk@localhost.localdomain> (raw)
In-Reply-To: <Zy4mW6r3rjMEsNir@infradead.org>

On Fri, Nov 08, 2024 at 06:55:23AM -0800, Christoph Hellwig wrote:
> On Fri, Nov 08, 2024 at 08:27:38PM +0800, Long Li wrote:
> > After reboot, file has zero padding in range [A+B, A+B+C]:
> > 
> >   |<         Block Size (BS)      >|
> >   |DDDDDDDDDDDDDDDD0000000000000000|
> >   ^               ^        ^
> >   A              A+B      A+B+C (EOF)
> > 
> >   D = Valid Data
> >   0 = Zero Padding
> > 
> > The issue stems from disk size being set to min(io_offset + io_size,
> > inode->i_size) at I/O completion. Since io_offset+io_size is block
> > size granularity, it may exceed the actual valid file data size. In
> > the case of concurrent append writes, inode->i_size may be larger
> > than the actual range of valid file data written to disk, leading to
> > inaccurate disk size updates.
> 
> Oh, interesting one.  Do you have a reproducer we could wire up
> to xfstests?
> 

Yes, I have a simple reproducer, but it would require significant
work to incorporate it into xfstestis.

> > This patch introduce ioend->io_end to trace the end position of the
> > valid data in ioend, rather than solely relying on ioend->io_size.
> > It ensures more precise disk size updates and avoids the zero padding
> > issue. Another benefit is that it makes the xfs_ioend_is_append()
> > check more accurate, which can reduce unnecessary end bio callbacks
> > of xfs_end_bio() in certain scenarios, such as repeated writes at the
> > file tail without extending the file size.
> 
> Hmm.  Can we do away with two members for the size by just rounding
> up the block size for the block based operations?
> 

If we only use one size record, we can remove io_size and keep only
io_end to record the tail end of valid file data in ioend. Meanwhile,
we can add a wrapper function iomep_ioend_iosize() to get the extent
size of ioend, replacing the existing ioend->io_size. Would this work?

Thanks,
Long Li

  reply	other threads:[~2024-11-09  7:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08 12:27 [PATCH] iomap: fix zero padding data issue in concurrent append writes Long Li
2024-11-08 14:55 ` Christoph Hellwig
2024-11-09  7:13   ` Long Li [this message]
2024-11-11  5:45     ` Christoph Hellwig
2024-11-11 14:16       ` Long 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=Zy8Lsee7EDodz5Xk@localhost.localdomain \
    --to=leo.lilong@huawei.com \
    --cc=brauner@kernel.org \
    --cc=cem@kernel.org \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=houtao1@huawei.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lonuxli.64@gmail.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.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