From: Christoph Hellwig <hch@infradead.org>
To: Dan Aloni <dan.aloni@vastdata.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfs: add 'noextend' option for lock-less 'lost writes' prevention
Date: Tue, 18 Jun 2024 22:44:45 -0700 [thread overview]
Message-ID: <ZnJwTaTw5JEOnuLw@infradead.org> (raw)
In-Reply-To: <20240618153313.3167460-1-dan.aloni@vastdata.com>
On Tue, Jun 18, 2024 at 06:33:13PM +0300, Dan Aloni wrote:
> --- a/fs/nfs/write.c
> +++ b/fs/nfs/write.c
> @@ -1315,7 +1315,10 @@ static int nfs_can_extend_write(struct file *file, struct folio *folio,
> struct file_lock_context *flctx = locks_inode_context(inode);
> struct file_lock *fl;
> int ret;
> + unsigned int mntflags = NFS_SERVER(inode)->flags;
>
> + if (mntflags & NFS_MOUNT_NO_EXTEND)
> + return 0;
> if (file->f_flags & O_DSYNC)
> return 0;
> if (!nfs_folio_write_uptodate(folio, pagelen))
I find the logic in nfs_update_folio to extend the write to the entire
folio rather weird, and especially bad with the larger folio support I
just added.
It makes the client write more (and with large page sizes or large
folios) potentially a lot more than what the application asked for.
The comment above nfs_can_extend_write suggest it is done to avoid
"fragmentation". My immediate reaction assumed that would be about file
system fragmentation, which seems odd given that I'd expect servers to
either log data, in which case this just increases write amplification
for no good reason, or use something like the Linux page cache in which
case it would be entirely pointless.
But when following git blame over a few rounds of fixes (that all narrow
down the scope of this optimization because it caused problems) the
"fragmentation" eventually becomes:
/* If we're not using byte range locks, and we know the page
* is entirely in cache, it may be more efficient to avoid
* fragmenting write requests.
*/
Which to me suggests it is about struct nfs_page and the on-the-wire
RPCs. In which case the merging in nfs_try_to_update_request that
merges consecutive I/O should take care of all the interesting cases.
In other words: I strongly suspect everyone is better off if this
extending write behavior is removed or at least not the default.
next prev parent reply other threads:[~2024-06-19 5:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 15:33 [PATCH] nfs: add 'noextend' option for lock-less 'lost writes' prevention Dan Aloni
2024-06-18 18:59 ` Trond Myklebust
2024-06-19 8:37 ` Sagi Grimberg
2024-06-19 14:15 ` Trond Myklebust
2024-06-19 14:31 ` Sagi Grimberg
2024-06-20 5:27 ` Christoph Hellwig
2024-06-20 6:41 ` Sagi Grimberg
2024-06-20 5:26 ` Christoph Hellwig
2024-06-19 5:44 ` Christoph Hellwig [this message]
2024-06-19 13:33 ` Trond Myklebust
2024-06-19 18:03 ` Trond Myklebust
2024-06-20 5:13 ` hch
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=ZnJwTaTw5JEOnuLw@infradead.org \
--to=hch@infradead.org \
--cc=dan.aloni@vastdata.com \
--cc=linux-nfs@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.