Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796239555; b=W8EbDeIHsrd+dux4uMALihvvGud5Ib9eckovR/7NZQQBod1s0WrB4mXuD84hZfGZqtHY cpb5fpV9n9PEv71kUBBwBDif6kZEYEOlgH20RlWS5UJTKVwQdr35EChEVtgWhULaVOac+ fGktyH2rhOunAAualVJJQ8El5bIKvyl9bXbPM11kZeoeY18JH5lcENxWelbvwzqkYL3xQ U25pGByx9iIwNuW0reiJvnleJlQ5E4Fuf7kK5wqrTHlUHkL+y3YGmM3/eEcnfxYMktGDh pvKAwt4Uk5vyyJTaHclcMzwF7YHSMGUyJq7TUtMfYv8Vqx6ZbL+tLwdKAlvgtcdMd8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796239555; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=aDzP9KuO1tY1q36/ZxF6nzo3NR61ItZfZnkrk2TVI+U=; b=Z/OB55frTWoBGn6RM+n6RVluQoFkWg2dnUjLoED0+Fw5jesXyk6ojkNXxH34fQr4Ewgi fxZjGHEguTfITd26lKvcuxyYoExRYNt11vkyZeEt7oRSW9xiTIwoWUgkOfEiOTV/Uiq2h IC4kc9YT8xGoInoQhblF23xV0PwnAGAyCPrU6B293/z5ZgxpSgYlZg3FFwI8gB5DHnuVj T3zB5Yd9FXfow9vLJ3dZZBrXsT3voQrGV6nuLYwU5++b9sqZRR/P5FSSgarA/5l/v329P RPuyTLm/aLECy/gTrfQHjmgFolgLentrhyijwutmF+/QFs44sAwd8LLcFWo4FDCxtqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YOoyfvkZ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43264606A333 for ; Wed, 2 Dec 2026 19:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YOoyfvkZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D1FF1F0089F; Wed, 2 Dec 2026 19:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796239554; bh=aDzP9KuO1tY1q36/ZxF6nzo3NR61ItZfZnkrk2TVI+U=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=YOoyfvkZdsPcEbUW6a4HdjCPbTx0Uxu661sb77I5JhdiW0ISLrbYRZlor+tAO2Wyw dX3DwxIMwdpJkNajmaO8lYxMHaBeWARJon0r/FlTYQq80fkCvTYJxTFhgczy/adYFG 8PJG0otnsFnfuEenl+ek04w6HkrKDy2S9bjxdvTdVV3dhBfG/PCTuOivmwkyOgSe7D T/qF38hT8lrMUep0w7tReCGj4VJ1ROxXU3sIPzMjtSojdSowD1lVYvKJG2LKkbpNuo T5p5FDs8JhAY890FSJ4vs0muTtC93aYcO72Xfa6MOk0++xWb+xjre73hc9cndKMACt eShmqJNxJxeTg== From: Jeff Layton Date: Wed, 02 Dec 2026 14:25:41 -0500 Subject: [PATCH 4/5] nfsd: check for unchanged CB_GETATTR times under the shared inode_lock X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-delegts-fixes-v1-4-e3b237925b24@kernel.org> References: <20261202-delegts-fixes-v1-0-e3b237925b24@kernel.org> In-Reply-To: <20261202-delegts-fixes-v1-0-e3b237925b24@kernel.org> To: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2341; i=jlayton@kernel.org; h=from:subject:message-id; bh=Nd8paDjrEw5SRYgN6v61WW7rQsq7JpL0CVIFwDZV5qs=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBrEHC/P3gPkJUkQAsuSEXxHrf+UQa372+dzc+gF VCK/LHOo9uJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaxBwvwAKCRAADmhBGVaC FdKFEADR8VaxHecJeQlGw5EF9bJ/Ohic1NJu1O/kAmdZ4zk7Hk5Kx2FK3TxytAKsm0w2ow9bjG4 JNpSu2cK8jEv8eLQDESvv/D5PycN+X754g7Z40NcxCDtv+G/1zxbOCOk3URSCoE5hsLetBcrquA Jxve0GPvWtiV/7ljtylNf9SLgyPPVnMPzQIuS3GsZejPY3vZkc0bUDh5udeHoEAt9YKa7sm1ju9 r1O6+O8I/62FfqERmJKPq2CUSpKGh8kFAZQfPIajsc7puR16Muchm9wv767nIMaJC7uoo8vkO5E /c5+n5Lgvqr0s9mzsq9b8OxCzm0dv7tzxhjUehPuusP0Dtu+0kifNAcEVfWPU8CduKnlMmChr1g YbvD14gs108N7s9XkOQoLHy7C/Hebv4m3hbIi9g3xqY+XGJEIk4dAe2jele6iiAWVQpsS4LlvZt bjL6N5Kk7nBTz1J6mTco+d+x2nEukpJZFVapdy4FQMxRp/wzegPHBtVgHtTSYC0E7u62zus4tTv m+OFdMc68UM3ibuWT6kCbxR3eQNCCfiU6Bu/L6R0hFm8GZjZe4r50UTPU8HE0bzgO5DPwJGRkQL 59qi/uBsdic6qEKN2jODOzYsMZs2Pcb6VZ9KHVNVx0VCdLNMwVGAv2GzEfShrJDGNXjfWKs5ZEJ t98RGj9ebXkRK2w== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 cb_getattr_update_times() takes freeze protection and the exclusive inode_lock before finding that a repeated reply has nothing to apply. Such a GETATTR then waits behind I/O for the exclusive lock, or fails with NFS4ERR_DELAY while the filesystem is frozen. Check for unchanged times under the shared inode_lock first. Take freeze protection and the exclusive inode_lock only when a time is left to apply, and check again under them. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 6de15d7fb09c..f8817e60b0a2 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -10705,7 +10705,7 @@ static bool cb_getattr_time_unchanged(struct inode *inode, /* * Return @attrs->ia_valid without the vetted CB_GETATTR times that * cb_getattr_time_unchanged() drops. ctime moves only with a delegated - * mtime. Caller holds inode_lock. + * mtime. Caller holds inode_lock, shared or exclusive. */ static unsigned int cb_getattr_drop_unchanged(struct inode *inode, const struct nfs4_delegation *dp, @@ -10774,6 +10774,20 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation if (!attrs.ia_valid) return 0; + /* + * A reply that repeats times the inode already holds still passes + * vetting. Check for that under the shared lock first, so that it + * waits for neither freeze protection nor the exclusive lock. + */ + if (deleg_attrs_deleg(dp->dl_type)) { + inode_lock_shared(inode); + valid = cb_getattr_drop_unchanged(inode, dp, &attrs, &cb_atime, + &cb_mtime, &now); + inode_unlock_shared(inode); + if (!(valid & (ATTR_ATIME | ATTR_MTIME))) + return 0; + } + /* * The reference on @dp doesn't keep the delegation's file open. * A racing DELEGRETURN or revocation can put fi_deleg_file, so @@ -10806,6 +10820,7 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation if (!hashed) goto out_unlock; + /* The inode's times can have moved since the shared check */ if (deleg_attrs_deleg(dp->dl_type)) { attrs.ia_valid = cb_getattr_drop_unchanged(inode, dp, &attrs, &cb_atime, &cb_mtime, -- 2.56.1