mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Chi Zhiling <chizhiling@163.com>,
	Brian Foster <bfoster@redhat.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	Amir Goldstein <amir73il@gmail.com>,
	cem@kernel.org, linux-xfs@vger.kernel.org,
	linux-kernel@vger.kernel.org, Chi Zhiling <chizhiling@kylinos.cn>,
	John Garry <john.g.garry@oracle.com>
Subject: Re: [PATCH] xfs: Remove i_rwsem lock in buffered read
Date: Wed, 29 Jan 2025 11:59:53 +1100	[thread overview]
Message-ID: <Z5l9ieD8zkCQYHFV@dread.disaster.area> (raw)
In-Reply-To: <Z5hn_cRb_cLzHX4Z@infradead.org>

On Mon, Jan 27, 2025 at 09:15:41PM -0800, Christoph Hellwig wrote:
> On Tue, Jan 28, 2025 at 07:49:17AM +1100, Dave Chinner wrote:
> > > As for why an exclusive lock is needed for append writes, it's because
> > > we don't want the EOF to be modified during the append write.
> > 
> > We don't care if the EOF moves during the append write at the
> > filesystem level. We set kiocb->ki_pos = i_size_read() from
> > generic_write_checks() under shared locking, and if we then race
> > with another extending append write there are two cases:
> > 
> > 	1. the other task has already extended i_size; or
> > 	2. we have two IOs at the same offset (i.e. at i_size).
> > 
> > In either case, we don't need exclusive locking for the IO because
> > the worst thing that happens is that two IOs hit the same file
> > offset. IOWs, it has always been left up to the application
> > serialise RWF_APPEND writes on XFS, not the filesystem.
> 
> I disagree.  O_APPEND (RWF_APPEND is just the Linux-specific
> per-I/O version of that) is extensively used for things like
> multi-thread loggers where you have multiple threads doing O_APPEND
> writes to a single log file, and they expect to not lose data
> that way.

Sure, but we don't think we need full file offset-scope IO exclusion
to solve that problem.  We can still safely do concurrent writes
within EOF to occur whilst another buffered append write is doing
file extension work.

IOWs, where we really need to get to is a model that allows
concurrent buffered IO at all times, except for the case where IO
operations that change the inode size need to serialise against
other similar operations (e.g. other EOF extending IOs, truncate,
etc).

Hence I think we can largely ignore O_APPEND for the
purposes of prototyping shared buffered IO and getting rid of the
IOLOCK from the XFS IO path. I may end up re-using the i_rwsem as
a "EOF modification" serialisation mechanism for O_APPEND and
extending writes in general, but I don't think we need a general
write IO exclusion mechanism for this...

-Dave.
-- 
Dave Chinner
david@fromorbit.com

  parent reply	other threads:[~2025-01-29  0:59 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-26  6:16 Chi Zhiling
2024-12-26 21:50 ` Dave Chinner
2024-12-28  7:37   ` Chi Zhiling
2024-12-28 22:17     ` Dave Chinner
2024-12-30  2:42       ` Chi Zhiling
2025-01-07 12:13         ` Amir Goldstein
2025-01-07 17:12           ` Christoph Hellwig
2025-01-08  7:43           ` Chi Zhiling
2025-01-08 11:33             ` Amir Goldstein
2025-01-08 11:45               ` Amir Goldstein
2025-01-08 12:15               ` John Garry
2025-01-09 10:07                 ` Amir Goldstein
2025-01-09 12:40                   ` John Garry
2025-01-09  8:37               ` Chi Zhiling
2025-01-09 10:25                 ` Amir Goldstein
2025-01-09 12:10                   ` Chi Zhiling
2025-01-09 12:25                     ` John Garry
2025-01-08 17:35             ` Darrick J. Wong
2025-01-09 23:28               ` Dave Chinner
2025-01-10  1:31                 ` Chi Zhiling
2025-01-10 17:07                 ` Amir Goldstein
2025-01-12 10:05                   ` Chi Zhiling
2025-01-13  2:44                     ` Darrick J. Wong
2025-01-13  5:59                       ` Chi Zhiling
2025-01-13 13:40                       ` Brian Foster
2025-01-13 16:19                         ` Darrick J. Wong
2025-01-15  5:55                         ` Christoph Hellwig
2025-01-15 21:41                           ` Dave Chinner
2025-01-16  4:36                             ` Christoph Hellwig
2025-01-17 22:20                               ` Dave Chinner
2025-01-16 14:23                             ` Brian Foster
2025-01-17 13:27                             ` Amir Goldstein
2025-01-17 22:19                               ` Dave Chinner
2025-01-18 13:03                                 ` Amir Goldstein
2025-01-20  5:11                                   ` Dave Chinner
2025-01-22  6:08                                 ` Christoph Hellwig
2025-01-22 23:35                                   ` Dave Chinner
2025-01-17 16:12                             ` Chi Zhiling
2025-01-24  7:57                             ` Chi Zhiling
2025-01-27 20:49                               ` Dave Chinner
2025-01-28  5:15                                 ` Christoph Hellwig
2025-01-28 21:23                                   ` David Laight
2025-01-29  0:59                                   ` Dave Chinner [this message]
2025-01-29  5:20                                     ` Christoph Hellwig
2025-02-10  1:44                                 ` Chi Zhiling
2025-01-14  0:09                   ` Dave Chinner
2025-01-25  8:43           ` Jinliang Zheng
2025-01-25 14:14             ` Amir Goldstein
2025-06-20 14:03   ` 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=Z5l9ieD8zkCQYHFV@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=amir73il@gmail.com \
    --cc=bfoster@redhat.com \
    --cc=cem@kernel.org \
    --cc=chizhiling@163.com \
    --cc=chizhiling@kylinos.cn \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=john.g.garry@oracle.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®