From: "Chuck Lever" <cel@kernel.org>
To: "Scott Mayhew" <smayhew@redhat.com>,
"Chuck Lever" <chuck.lever@oracle.com>,
"Jeff Layton" <jlayton@kernel.org>
Cc: NeilBrown <neil@brown.name>,
"Olga Kornievskaia" <okorniev@redhat.com>,
"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH v3] nfsd: fix file change detection in CB_GETATTR
Date: Tue, 07 Apr 2026 09:56:15 -0400 [thread overview]
Message-ID: <328cf96b-ed6c-4dc9-aee1-a1bcf2efa230@app.fastmail.com> (raw)
In-Reply-To: <20260407113243.1754585-1-smayhew@redhat.com>
On Tue, Apr 7, 2026, at 7:32 AM, Scott Mayhew wrote:
> RFC 8881, section 10.4.3 doesn't say anything about caching the file
> size in the delegation record, nor does it say anything about comparing
> a cached file size with the size reported by the client in the
> CB_GETATTR reply for the purpose of determining if the client holds
> modified data for the file.
>
> What section 10.4.3 of RFC 8881 does say is that the server should
> compare the *current* file size with size reported by the client holding
^with size reported^with the size reported
One more below.
> the delegation in the CB_GETATTR reply, and if they differ to treat it
> as a modification regardless of the change attribute retrieved via the
> CB_GETATTR.
>
> Doing otherwise would cause the server to believe the client holding the
> delegation has a modified version of the file, even if the client
> flushed the modifications to the server prior to the CB_GETATTR. This
> would have the added side effect of subsequent CB_GETATTRs causing
> updates to the mtime, ctime, and change attribute even if the client
> holding the delegation makes no further updates to the file.
>
> Modify nfsd4_deleg_getattr_conflict() to obtain the current file size
> via i_size_read(). Retain the ncf_cur_fsize field, since it's a
> convenient way to return the file size back to nfsd4_encode_fattr4(),
> but don't use it for the purpose of detecting file changes.
>
> Also, if we recall the delegation (because the client didn't respond to
> the CB_GETATTR), then skip the logic that checks the nfs4_cb_fattr
> fields.
>
> Fixes: c5967721e106 ("NFSD: handle GETATTR conflict with write delegation")
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> ---
> fs/nfsd/nfs4state.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index fa657badf5f8..369f30c42115 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -9516,11 +9516,16 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst
> *rqstp, struct dentry *dentry,
> if (status != nfserr_jukebox ||
> !nfsd_wait_for_delegreturn(rqstp, inode))
> goto out_status;
> + status = nfs_ok;
> + goto out_status;
> + }
> + if (!ncf->ncf_file_modified) {
> + if (ncf->ncf_initial_cinfo != ncf->ncf_cb_change) {
> + ncf->ncf_file_modified = true;
> + } else if (i_size_read(inode) != ncf->ncf_cb_fsize) {
> + ncf->ncf_file_modified = true;
> + }
> }
> - if (!ncf->ncf_file_modified &&
> - (ncf->ncf_initial_cinfo != ncf->ncf_cb_change ||
> - ncf->ncf_cur_fsize != ncf->ncf_cb_fsize))
> - ncf->ncf_file_modified = true;
> if (ncf->ncf_file_modified) {
> int err;
>
> --
> 2.53.0
May I request an additional minor related clean-up?
The grant-time write of ncf_cur_fsize has been dead with respect to
the consumer (nfs4xdr.c:3930) since the original commit c5967721e106.
Your patch removes the last other reader of that value -- the now-
incorrect size comparison -- making the dead write obvious.
--
Chuck Lever
prev parent reply other threads:[~2026-04-07 13:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 11:32 [PATCH v3] nfsd: fix file change detection in CB_GETATTR Scott Mayhew
2026-04-07 13:56 ` Chuck Lever [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=328cf96b-ed6c-4dc9-aee1-a1bcf2efa230@app.fastmail.com \
--to=cel@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=smayhew@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).