From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ABFB230BD5; Thu, 2 Jul 2026 20:27:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783024073; cv=none; b=FoGUTmC5iSivNuB7CDUwY5VpiyRu4VL32w5qvsCMZ57myIjLLE/nbgLMibdtHkN4rv2Mjgcz6if+AnSRcxX17Ps1B/qFXwryg1B5GMpqs7geFyn8SpCJGHFkGx618hYPCNX10odZirwx+dbbPQCSwtSrJlpu7sF5aM+Vjgr1yNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783024073; c=relaxed/simple; bh=2MZhzQUcpUAFJ1uTEsvBezeJgNP5m7hMZepcIWvqRyI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Vc4WqW+lBTAGRmmgBWExQZTbm0EHJSqnqy3CZZ1Nlx1WOIGguk+hXKCkAABAdLpjZ6+oV/b7UxowY4XyF0PZyITq2hGwiMtP37ejHHkRz4WVGidwk5Ze0bzJAgLaOHeKe/DD/RAHM4iPFpqcAkzHSkkMoM6ZUivAoIY/Yugdydo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UjxokLHJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UjxokLHJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA4701F000E9; Thu, 2 Jul 2026 20:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783024072; bh=IH4BeaYTSkDPAfmCv7pI/j3z0eaRPyPqOgEH3MQKdJI=; h=From:To:Cc:Subject:Date; b=UjxokLHJyOkjh0fyIlKWt1a3rsQy/eabCuruualCwND135R7Mpcs1GtFH+JnGGJOX j4REXeLrvd0UYHb7oVllW8zK9ndjYF2Igzhw6OEQuuReN3mnYU/YokNLfW+45uijnc B2nsy/i8RJNPmLMocC9v+3D8S9N+SkgmyDsaB5YoRzd3atVibG69dHuiM0JGPRol3i 0KVVVxwUe11DmmWJj+4qZA4Se7M0gEu10tcpAaGRM5+93kiAAxWmqKpMNgfca+WG3m +ETs46RUqST6vTLKJN8n4P+4NHC4BRflUBj0VNTgLUg4H5+AayUk6yFnKCmES9XvO7 KOCqQ1OjtrKSA== From: Chuck Lever To: Cc: , Scott Mayhew Subject: [PATCH 6.12.y 1/2] nfsd: fix file change detection in CB_GETATTR Date: Thu, 2 Jul 2026 16:27:48 -0400 Message-ID: <20260702202749.1618630-1-cel@kernel.org> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Scott Mayhew commit 304d81a2fbf2b454def4debcb38ea173911b72cd upstream. 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 the size reported by the client holding 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. Remove the unnecessary initialization of ncf_cur_fsize in nfs4_open_delegation(). 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") Cc: stable@vger.kernel.org Signed-off-by: Scott Mayhew Signed-off-by: Chuck Lever [ cel: no deleg_ts in 6.12.y; dropped the now-dead ncf_cur_fsize init ] Signed-off-by: Chuck Lever --- fs/nfsd/nfs4state.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2d9174729782..33102bc65b7c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6085,7 +6085,6 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, goto out_no_deleg; } open->op_delegate_type = NFS4_OPEN_DELEGATE_WRITE; - dp->dl_cb_fattr.ncf_cur_fsize = stat.size; dp->dl_cb_fattr.ncf_initial_cinfo = nfsd4_change_attribute(&stat); trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid); } else { @@ -9039,11 +9038,15 @@ 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.54.0