mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@kernel.org>
To: Jeff Layton <jlayton@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: Chuck Lever <cel@kernel.org>,
	linux-nfs@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] NFS: don't wait for writeback on close() with a write delegation
Date: Fri, 20 Nov 2026 10:04:48 -0800	[thread overview]
Message-ID: <c9d7a4bf79247d7cfcd23460d351412c343d546c.camel@kernel.org> (raw)
In-Reply-To: <20261116-nfs-space-limit-v1-1-fcc1335169a7@kernel.org>

On Mon, 2026-11-16 at 15:55 -0500, Jeff Layton wrote:
> Commit 5445b1fbd123 ("NFSv4: Respect the server imposed limit on how
> many changes we may cache") made close() write back, COMMIT and wait
> whenever outstanding requests exceed the write delegation's
> space_limit. Servers that send a limit of 0, knfsd included,
> therefore
> get no close() benefit from write delegations, which knfsd now grants
> even on write-only opens.
> 
> That flush buys nothing:
> 
> - CTO: no other client can open the file until the delegation is
>   recalled, and the recall writes back our dirty data first.
> - Error reporting is all that's left, and it's pointless. close() is
>   not required to flush, and most filesystems don't, so checking for
>   writeback errors there is unreliable at best: the failing writeback
>   may not have happened yet. Applications that care must fsync(),
>   which this doesn't change; errors are still recorded in the mapping
>   and reported there.
> - RFC 8881 says only that the client "should" abide by space_limit;
>   exceeding it leaves the server's behavior undefined, and knfsd just
>   returns NFS4ERR_NOSPC/NFS4ERR_DQUOT on WRITE or COMMIT.
> 
> Go back to just starting writeback on close() whenever we hold a
> write
> delegation. In testing against a knfsd patched to send a nonzero
> space_limit, single-threaded create/write/close went from ~92 to
> ~1,500 files/s.
> 
> User-visible change: ENOSPC/EDQUOT for data written just before
> close()
> now shows up only via fsync(), not close().
> 
> For now, the pagemod_limit is still decoded but unused.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> I started looking at wiring up space_limit for nfsd's write
> delegations,
> but afrer looking at how the client uses it, I think we're best off
> just
> not bothering to respect it at all. Thoughts?
> ---
>  fs/nfs/delegation.c | 25 -------------------------
>  fs/nfs/delegation.h |  1 -
>  fs/nfs/nfs4file.c   |  7 ++++---
>  3 files changed, 4 insertions(+), 29 deletions(-)
> 
> diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
> index ad774316f716..3a141d5ee0bd 100644
> --- a/fs/nfs/delegation.c
> +++ b/fs/nfs/delegation.c
> @@ -1587,31 +1587,6 @@ bool nfs4_copy_delegation_stateid(struct inode
> *inode, fmode_t flags,
>  	return ret;
>  }
>  
> -/**
> - * nfs4_delegation_flush_on_close - Check if we must flush file on
> close
> - * @inode: inode to check
> - *
> - * This function checks the number of outstanding writes to the file
> - * against the delegation 'space_limit' field to see if
> - * the spec requires us to flush the file on close.
> - */
> -bool nfs4_delegation_flush_on_close(const struct inode *inode)
> -{
> -	struct nfs_inode *nfsi = NFS_I(inode);
> -	struct nfs_delegation *delegation;
> -	bool ret = true;
> -
> -	rcu_read_lock();
> -	delegation = rcu_dereference(nfsi->delegation);
> -	if (delegation == NULL || !(delegation->type & FMODE_WRITE))
> -		goto out;
> -	if (atomic_long_read(&nfsi->nrequests) < delegation-
> >pagemod_limit)
> -		ret = false;
> -out:
> -	rcu_read_unlock();
> -	return ret;
> -}
> -
>  int nfs4_delegation_hash_alloc(struct nfs_server *server)
>  {
>  	int delegation_buckets, i;
> diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
> index fba4699952b8..75f0edde65ea 100644
> --- a/fs/nfs/delegation.h
> +++ b/fs/nfs/delegation.h
> @@ -83,7 +83,6 @@ void nfs_put_delegation(struct nfs_delegation
> *delegation);
>  void nfs_mark_delegation_referenced(struct nfs_delegation
> *delegation);
>  int nfs4_have_delegation(struct inode *inode, fmode_t type, int
> flags);
>  int nfs4_check_delegation(struct inode *inode, fmode_t type);
> -bool nfs4_delegation_flush_on_close(const struct inode *inode);
>  void nfs_inode_find_delegation_state_and_recover(struct inode
> *inode,
>  		const nfs4_stateid *stateid);
>  void nfs4_inode_make_writeable(struct inode *inode);
> diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
> index 9a434f5dda8d..04f4d8967e5b 100644
> --- a/fs/nfs/nfs4file.c
> +++ b/fs/nfs/nfs4file.c
> @@ -122,10 +122,11 @@ nfs4_file_flush(struct file *file, fl_owner_t
> id)
>  		return 0;
>  
>  	/*
> -	 * If we're holding a write delegation, then check if we're
> required
> -	 * to flush the i/o on close. If not, then just start the
> i/o now.
> +	 * A write delegation already provides close-to-open
> consistency:
> +	 * no other client can open the file until it is recalled,
> and the
> +	 * recall writes back our dirty data. Just start the i/o.
>  	 */
> -	if (!nfs4_delegation_flush_on_close(inode))
> +	if (nfs_have_write_delegation(inode))
>  		return filemap_fdatawrite(file->f_mapping);
>  
>  	/* Flush writes to the server and return any errors */
> 
> ---
> base-commit: 9d66f26fefacebfeed15de31c1123451a17ff119
> change-id: 20261113-nfs-space-limit-025199334e52
> 
> Best regards,

Maybe we can call filemap_flush() in order to kick off non-blocking
writes in this situation?

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@kernel.org, trond.myklebust@hammerspace.com

      reply	other threads:[~2026-11-20 18:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 20:55 Jeff Layton
2026-11-20 18:04 ` Trond Myklebust [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=c9d7a4bf79247d7cfcd23460d351412c343d546c.camel@kernel.org \
    --to=trondmy@kernel.org \
    --cc=anna@kernel.org \
    --cc=cel@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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®