All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Chuck Lever <cel@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org, Chuck Lever <chuck.lever@oracle.com>,
	Mike Snitzer <snitzer@kernel.org>
Subject: Re: [RFC PATCH] NFSD: Make FILE_SYNC WRITEs comply with spec
Date: Thu, 23 Oct 2025 06:34:53 -0700	[thread overview]
Message-ID: <aPou_ewrAmf4rA6O@infradead.org> (raw)
In-Reply-To: <4a5f32c7-7369-414e-b93f-70804aecc157@kernel.org>

On Thu, Oct 23, 2025 at 08:46:02AM -0400, Chuck Lever wrote:
> On 10/23/25 2:38 AM, Christoph Hellwig wrote:
> > On Wed, Oct 22, 2025 at 12:22:37PM -0400, Chuck Lever wrote:
> >> -		kiocb.ki_flags |= IOCB_DSYNC;
> >> +		kiocb.ki_flags |=
> >> +			(stable == NFS_FILE_SYNC ? IOCB_SYNC : IOCB_DSYNC);
> > 
> > IOCB_SYNC without IOCB_DSYNC is always wrong, see my reply to the
> > previous thread.
> > 
> 
> I see only one API consumer that sets both: NFS LOCALIO. There are not
> enough examples for me to draw any kind of conclusion, and I haven't
> found documentation for these flags, fwiw.

The primary way to set IOCB_DSYNC and IOCB_SYNC is iocb_flags() in
include/linux/fs.h, which sets IOCB_DSYNC for O_DSYNC, and IOCB_SYNC for
__O_SYNC.  O_SYNC is defined as O_DSYNC | __O_SYNC for the historic
reasons explained in the other thread.

The main consumer of IOCB_DSYNC and IOCB_SYNC is generic_write_sync in
include/linux/fs.h, which calls into vfs_fsync_range if IOCB_DSYNC is set
(or IS_SYNC() is true on the inode, but that's irrelevant here), and
only uses IOCB_SYNC to clear the datasync flag to vfs_fsync_range if
it is set, i.e. no syncing is done without IOCB_DSYNC.

As for other uses of these flags:

fuse_write_flags should be assigning __O_SYNC instead of O_SYNC for
clarify, but the code is not incorrect.
__iomap_dio_rw does the right thing in checking IOCB_SYNC for
controlling the REQ_FUA use.
netfs_perform_write should just be checking IOCB_DYSNC, but that whole
area looks bogus.  I'll follow up with Dave.
nfs_do_local_write does the right thing assuming nfs stable writes
want O_SYNC.
I don't understand what ovl_write_iter tries to do from just reading the
code.


      reply	other threads:[~2025-10-23 13:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 16:22 [RFC PATCH] NFSD: Make FILE_SYNC WRITEs comply with spec Chuck Lever
2025-10-22 17:22 ` Tom Talpey
2025-10-22 17:46   ` Mike Snitzer
2025-10-22 18:25     ` Tom Talpey
2025-10-22 18:39       ` Mike Snitzer
2025-10-23  6:39   ` Christoph Hellwig
2025-10-22 17:27 ` Mike Snitzer
2025-10-28 22:28   ` Dave Chinner
2025-10-23  6:38 ` Christoph Hellwig
2025-10-23 12:46   ` Chuck Lever
2025-10-23 13:34     ` Christoph Hellwig [this message]

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=aPou_ewrAmf4rA6O@infradead.org \
    --to=hch@infradead.org \
    --cc=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=tom@talpey.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 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.