mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Jeff Layton <jlayton@kernel.org>
Subject: [PATCH 05/11] nfsd: set ctime when a SETATTR with delegated times changes other attributes
Date: Fri, 20 Nov 2026 08:40:11 -0800	[thread overview]
Message-ID: <20261120-delegts-fixes-v1-5-c89b37d2d462@kernel.org> (raw)
In-Reply-To: <20261120-delegts-fixes-v1-0-c89b37d2d462@kernel.org>

__nfsd_setattr() adds ATTR_CTIME only when ATTR_DELEG is clear, to keep a
delegated atime-only update from moving ctime. But ATTR_DELEG is set for
the whole iattr, so a holder's chmod or chown sent along with a delegated
atime changes the mode or owner without updating ctime.

Add ATTR_CTIME unless the request is a delegated atime-only update. A
delegated mtime whose ctime failed vetting now gets ctime = now instead
of no ctime update.

Fixes: f9a348e0de19 ("nfsd: don't set the ctime on delegated atime updates")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfsd/vfs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 4f3e480a3981..c0d10c263a93 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -514,10 +514,12 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
 	/*
 	 * If ATTR_DELEG is set, then this is an update from a client that
 	 * holds a delegation. If this is an update for only the atime, the
-	 * ctime should not be changed. If the update contains the mtime
-	 * too, then ATTR_CTIME should already be set.
+	 * ctime should not be changed. Any other attribute change, such as
+	 * a mode or owner change sent along with a delegated atime, must
+	 * update the ctime.
 	 */
-	if (!(iap->ia_valid & ATTR_DELEG))
+	if (!(iap->ia_valid & ATTR_DELEG) ||
+	    (iap->ia_valid & ~(ATTR_DELEG | ATTR_ATIME | ATTR_ATIME_SET)))
 		iap->ia_valid |= ATTR_CTIME;
 
 	return notify_change(&nop_mnt_idmap, dentry, iap, NULL);

-- 
2.56.1


  parent reply	other threads:[~2026-11-20 16:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 16:40 [PATCH 00/11] nfsd: various delegated timestamp fixes Jeff Layton
2026-11-20 16:40 ` [PATCH 01/11] nfsd: don't hold inode_lock while waiting for a delegation in nfsd_setattr() Jeff Layton
2026-11-20 16:40 ` [PATCH 02/11] nfsd: take freeze protection before updating delegation timestamps Jeff Layton
2026-11-20 16:40 ` [PATCH 03/11] nfsd: count a delegation in cl_delegs_in_recall only once Jeff Layton
2026-11-20 16:40 ` [PATCH 04/11] nfsd: don't grant write delegations to NFSv4.0 clients on CLAIM_PREVIOUS Jeff Layton
2026-11-20 16:40 ` Jeff Layton [this message]
2026-11-20 16:40 ` [PATCH 06/11] nfsd: pin the client while a GETATTR holds a conflicting delegation Jeff Layton
2026-11-20 16:40 ` [PATCH 07/11] nfsd: recall when a CB_GETATTR reply omits the size Jeff Layton
2026-11-20 16:40 ` [PATCH 08/11] nfsd: apply delegated times in a separate times-only setattr Jeff Layton
2026-11-20 16:40 ` [PATCH 09/11] nfsd: grant a plain read delegation when timestamps are wanted on a read open Jeff Layton
2026-11-20 16:40 ` [PATCH 10/11] nfsd: check fi_had_conflict under deleg_lock before hashing a delegation Jeff Layton
2026-11-20 16:40 ` [PATCH 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=20261120-delegts-fixes-v1-5-c89b37d2d462@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.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 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®