From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Christian Brauner <brauner@kernel.org>
Cc: "Aurélien Couderc" <aurelien.couderc2002@gmail.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jeff Layton" <jlayton@kernel.org>
Subject: [PATCH v2 07/11] nfsd: recall when a CB_GETATTR reply omits the size
Date: Mon, 23 Nov 2026 04:59:10 -0800 [thread overview]
Message-ID: <20261123-delegts-fixes-v2-7-960ce0fb2fed@kernel.org> (raw)
In-Reply-To: <20261123-delegts-fixes-v2-0-960ce0fb2fed@kernel.org>
decode_cb_fattr4() zeroes ncf_cb_fsize and fills it in only if the
reply's bitmap includes SIZE. nfsd4_deleg_getattr_conflict() doesn't
look at that bitmap. For a reply without SIZE, a non-empty file's size
doesn't match zero, so the waiter marks the file modified and sets
ncf_cur_fsize to zero. GETATTR replies then report the file as empty to
every client but the delegation holder.
NFSD always requests SIZE in CB_GETATTR, and the holder may have changed
the size. Add ncf_cb_bitmap0 to hold word 0 of the reply's bitmap,
cleared when the callback is issued. In nfsd4_cb_getattr_done(), treat a
reply without SIZE as failed. The waiter then recalls the delegation, as
for any other CB_GETATTR failure.
A reply that omits CHANGE is left alone. The zero change attribute does
not match, so the waiter errs on the safe side and treats the file as
modified.
Fixes: c5967721e106 ("NFSD: handle GETATTR conflict with write delegation")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfsd/nfs4callback.c | 1 +
fs/nfsd/nfs4state.c | 8 ++++++++
fs/nfsd/state.h | 1 +
3 files changed, 10 insertions(+)
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 70ab4fd32195..ac65ba4c4b7d 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -737,6 +737,7 @@ static int nfs4_xdr_dec_cb_getattr(struct rpc_rqst *rqstp,
return status;
if (xdr_stream_decode_uint32_array(xdr, bitmap, 3) < 0)
return -EIO;
+ ncf->ncf_cb_bitmap0 = bitmap[0];
if (xdr_stream_decode_u32(xdr, &attrlen) < 0)
return -EIO;
maxlen = sizeof(ncf->ncf_cb_change) + sizeof(ncf->ncf_cb_fsize);
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 4e7bbaf65050..645ad916d2ef 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3876,6 +3876,13 @@ nfsd4_cb_getattr_done(struct nfsd4_callback *cb, struct rpc_task *task)
trace_nfsd_cb_getattr_done(&dp->dl_stid.sc_stateid, task);
ncf->ncf_cb_status = task->tk_status;
+ /*
+ * A reply without SIZE leaves ncf_cb_fsize at zero, which the
+ * waiter would report as the file's size. Fail the callback, so
+ * the waiter recalls the delegation instead.
+ */
+ if (!task->tk_status && !(ncf->ncf_cb_bitmap0 & FATTR4_WORD0_SIZE))
+ ncf->ncf_cb_status = NFS4ERR_IO;
switch (task->tk_status) {
case -NFS4ERR_DELAY:
rpc_delay(task, 2 * HZ);
@@ -4123,6 +4130,7 @@ static void nfs4_cb_getattr(struct nfs4_cb_fattr *ncf)
/* set to proper status when nfsd4_cb_getattr_done runs */
ncf->ncf_cb_status = NFS4ERR_IO;
+ ncf->ncf_cb_bitmap0 = 0;
/* ensure that wake_bit is done when RUNNING is cleared */
set_bit(NFSD4_CALLBACK_WAKE, &ncf->ncf_getattr.cb_flags);
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index f80abcc278f6..c5f607049aaf 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -205,6 +205,7 @@ struct nfs4_cb_fattr {
u32 ncf_cb_status;
/* from CB_GETATTR reply */
+ u32 ncf_cb_bitmap0; /* word 0 of the returned bitmap */
u64 ncf_cb_change;
u64 ncf_cb_fsize;
struct timespec64 ncf_cb_mtime;
--
2.56.1
next prev parent reply other threads:[~2026-11-23 12:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 12:59 [PATCH v2 00/11] nfsd: various delegated timestamp fixes Jeff Layton
2026-11-23 12:59 ` [PATCH v2 01/11] nfsd: don't hold inode_lock while waiting for a delegation in nfsd_setattr() Jeff Layton
2026-11-23 12:59 ` [PATCH v2 02/11] nfsd: take freeze protection before updating delegation timestamps Jeff Layton
2026-11-23 17:46 ` Chuck Lever
2026-11-23 12:59 ` [PATCH v2 03/11] nfsd: count a delegation in cl_delegs_in_recall only once Jeff Layton
2026-11-23 12:59 ` [PATCH v2 04/11] nfsd: don't grant write delegations to NFSv4.0 clients on CLAIM_PREVIOUS Jeff Layton
2026-11-24 7:39 ` Aurélien Couderc
2026-11-23 12:59 ` [PATCH v2 05/11] nfsd: set ctime when a SETATTR with delegated times changes other attributes Jeff Layton
2026-11-23 12:59 ` [PATCH v2 06/11] nfsd: pin the client while a GETATTR holds a conflicting delegation Jeff Layton
2026-11-23 12:59 ` Jeff Layton [this message]
2026-11-23 12:59 ` [PATCH v2 08/11] nfsd: apply delegated times in a separate times-only setattr Jeff Layton
2026-11-23 12:59 ` [PATCH v2 09/11] nfsd: grant a plain read delegation when timestamps are wanted on a read open Jeff Layton
2026-11-23 12:59 ` [PATCH v2 10/11] nfsd: check fi_had_conflict under deleg_lock before hashing a delegation Jeff Layton
2026-11-23 12:59 ` [PATCH v2 11/11] nfsd: take the write delegation grant stat before hashing Jeff Layton
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=20261123-delegts-fixes-v2-7-960ce0fb2fed@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=aurelien.couderc2002@gmail.com \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@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 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.