From nobody Sun Apr 5 13:04:34 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8C9E240758E; Tue, 24 Mar 2026 17:32:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774373538; cv=none; b=GrYcymlaoL0txqUv1fsKk5z3I5x1dse96AhUv3wARr4sG1lOZVMO/I1rcfUIOlcvLRdMJOZh5L91mYtN1TZpLHC9Af4hV2PDB/tPm4OGVpR03aCTUE2fWbAzPzRNw+xcSkHFahpaHFRS3ee4BMWu/AB+aAGF/mu81LJi9cIhlo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774373538; c=relaxed/simple; bh=AOjD8zFqz3UKl9M/3fUGPTeSXDBXvJKvQHy4gsFjQIQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cThCFF6K5HsbadivwKpL351QwPJx3Hh5gkNZnXAALDmMel8PUpEnin5DvSMCI1Y6Z1IMR5KB4/qgruuMOWj1ATy0FRDb8mMYuPwJc9PPX4gzVm9sGaobxCUi+be7IT9iijxsNA5RKcRxyPmwVM11gSCaNAbR+XgT946hEVYzU7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i/Z4Z/t/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i/Z4Z/t/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B347DC2BC87; Tue, 24 Mar 2026 17:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774373538; bh=AOjD8zFqz3UKl9M/3fUGPTeSXDBXvJKvQHy4gsFjQIQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=i/Z4Z/t/YLBjRHYkS04UwjiLGTVP/DFxGRCLktEh/FhNOXfzLOp0UnHInukFn6pbx ME04fMbl4kAAppaLi44cgH/ZrGw6nyrf3iu6Ls7WkkdfKW5w2tQpF1X8yj6EgaRwcT MRIRsWbjiaaxvTygjXqa8K4/tuM2sZmclKgDIrozasv6N43KXZ3vRdhndKnDG8ix1n DGiP7b3C2kBTP7BX6TYy4yrCfvDtL7C1qqg51xV3kJgHCg6BI6XNV0zRjyxJzwNPmk HvtJaH2vFA7RT466zsydqwTOglaLVZ2MOsQzB2mJRaRUGfRnNrvi73xHJ8HJ4G8czA UwfZedhiYdt7A== From: Jeff Layton Date: Tue, 24 Mar 2026 13:32:11 -0400 Subject: [PATCH v2 1/2] nfs: fix utimensat() for atime with delegated timestamps Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260324-nfs-7-1-v2-1-d110da3c0036@kernel.org> References: <20260324-nfs-7-1-v2-0-d110da3c0036@kernel.org> In-Reply-To: <20260324-nfs-7-1-v2-0-d110da3c0036@kernel.org> To: Trond Myklebust , Anna Schumaker Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1708; i=jlayton@kernel.org; h=from:subject:message-id; bh=AOjD8zFqz3UKl9M/3fUGPTeSXDBXvJKvQHy4gsFjQIQ=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBpwsqgYk2UMGvXNmntncvmMKFZOgYPej1663gYV e+aYzJLDeOJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCacLKoAAKCRAADmhBGVaC FTXHD/4u55JTmrcx1hJrcxAz7gokvtpcBY32elXYkUPQ0eZDKmfjv6gm8eUuUV9vReywKVdwths gvCNgAZEqj15w0h4YOmbVuLRTFiPFQnl1K4DzOp5dbIgJtyBiD45+1TIxtx0alUTMld06KV33J3 2n8mzd3suJJHFcUqGxw/kLLDxOerylAwB3GUIpMc8ln7VBbxCyRHCzz9D/XSJaC+LzRKrhlfedd CZ5dwiIOEyH6rkZfotcLiEzmCTlAxCsiVY8BnynGzrXbKDVoDpCCMaK6C5bv6ZlMHRzggfaMWsP 6/xVJd0ak18qqVBLZXzJypqW5d6wDzP4OeGL6VuonZjLfGrq3L/eFs+V6JNjrtz0XDMioGS/5NO rKDNKJnIZEbk60II/TacelfG6jMmtSu7D/FHxjzwv9a8X55hYWPN85kLVGynkUXGtdiQHrFaun6 aLJDPndOUV7z3VK1kxKNSAoE9ATnhbuz6WaH9Tt82pgHrqR21vznLBZDRUOvag7UIzWsby+9bqH Lwdi9Hvg4MoFcdEXIerg0CF7e2X0xVI5auWDQ8G61eNqQWTv5Vwsh+T9sHOD+gfa/qVUox9LZ2I XB0CnvmiLg01ux3qkyuXQUr7cj1S2gLe9ZzKT94EwAVZpmsaX9gK01kCkWGQl2y2D0Wm1jn7L15 DDoQClmWPVvSRHw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 xfstest generic/221 is failing with delegated timestamps enabled. When the client holds a WRITE_ATTRS_DELEG delegation, and a userland process does a utimensat() for only the atime, the ctime is not properly updated. The problem is that the client tries to cache the atime update, but there is no mtime update, so the delegated attribute update never updates the ctime. Delegated timestamps don't have a mechanism to update the ctime in accordance with atime-only changes due to utimensat() and the like. Change the client to issue an RPC in this case, so that the ctime gets properly updated alongside the atime. Fixes: 40f45ab3814f ("NFS: Further fixes to attribute delegation a/mtime ch= anges") Reported-by: Olga Kornievskaia Signed-off-by: Jeff Layton --- fs/nfs/inode.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 4786343eeee0f874aa1f31ace2f35fdcb83fc7a6..3a5bba7e3c92d4d4fcd65234cd2= f10e56f78dee0 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -757,14 +757,7 @@ nfs_setattr(struct mnt_idmap *idmap, struct dentry *de= ntry, } else if (nfs_have_delegated_atime(inode) && attr->ia_valid & ATTR_ATIME && !(attr->ia_valid & ATTR_MTIME)) { - if (attr->ia_valid & ATTR_ATIME_SET) { - if (uid_eq(task_uid, owner_uid)) { - spin_lock(&inode->i_lock); - nfs_set_timestamps_to_ts(inode, attr); - spin_unlock(&inode->i_lock); - attr->ia_valid &=3D ~(ATTR_ATIME|ATTR_ATIME_SET); - } - } else { + if (!(attr->ia_valid & ATTR_ATIME_SET)) { nfs_update_delegated_atime(inode); attr->ia_valid &=3D ~ATTR_ATIME; } --=20 2.53.0 From nobody Sun Apr 5 13:04:34 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5689140822B; Tue, 24 Mar 2026 17:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774373539; cv=none; b=nDv8kuO+p+uZAaUrYPeFBifvL1wSkS2lf8A0sKGvR440KFwoJKQ0NGYLBw8nichuN6Hiydt2TpF816AI0ta9liRRJUABcPJzNzqgba9PZWnEANdQDlH6JwWTsNQ0G8dOKsWXOsFOn836fmxBu+jZ8nc7woCWUH+/bp/qR0Qhm2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774373539; c=relaxed/simple; bh=KX7ezovIpRtNvZ/WETR7KgqRPNjNPl6LwdPkAvVt7wk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mWbcwQWHWDFCTnTLcBcrq4ZGURv7ddHYEpY9BZBVglcJgRahwUZMlxfhHkO/abtbSxXJlV75Y74PtPBMLPIKth1aHyeGEcGG4y9F319mWSTPOHBkTo3NqoaxEKWvnJVqjRehGFmD47tO7Shni8rCyC8aAb/852aDqPZ7zOi4G2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YnLRgbWU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YnLRgbWU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BF35C2BC9E; Tue, 24 Mar 2026 17:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774373539; bh=KX7ezovIpRtNvZ/WETR7KgqRPNjNPl6LwdPkAvVt7wk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YnLRgbWUZRNThFU1myixTut9Kh6kys0BbMDwv/o6iZpKu3uPhjJd+YalcL0gJDwH/ JUBgBso+RQe6dVQIHCpRy43VbrA6zkdNpVmKtn1vR09MisysVVtXofJOp8G8uJevSN 1QjwasMbRAUovPskO1h/8zzDuJb/neGjLxr3NPznPOIyixcLNBipX0Ik1ZRmk0kDxm w5ELI+oipikwiWyMLqVTMGg2ypH8B17NyMxR3a5MiPKPep7aVuFn2yY4BwvxNXm1VQ PqBm4kSEfEcuFNn5mZn78edoQUSO4JWlMibfmgRLoasK21yWHNeJsgmelBlI6sN5hK skv4/XALKU0NQ== From: Jeff Layton Date: Tue, 24 Mar 2026 13:32:12 -0400 Subject: [PATCH v2 2/2] nfs: update inode ctime after removexattr operation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260324-nfs-7-1-v2-2-d110da3c0036@kernel.org> References: <20260324-nfs-7-1-v2-0-d110da3c0036@kernel.org> In-Reply-To: <20260324-nfs-7-1-v2-0-d110da3c0036@kernel.org> To: Trond Myklebust , Anna Schumaker Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4210; i=jlayton@kernel.org; h=from:subject:message-id; bh=KX7ezovIpRtNvZ/WETR7KgqRPNjNPl6LwdPkAvVt7wk=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBpwsqgJQUx246016YMSNxNz8qxAQ2W8eROHx4tP w2m2hBNdRaJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCacLKoAAKCRAADmhBGVaC FXCqEACejOn80eOot6ONWGQRvG2PaR7MOjGUYwZG2p/LkbTkCl/gHvOQPKysorkcZJNvxC/65LE ee+BcHj9HNu2AVNmaDpVBbyqmLQpSyX0A5JPFv4Zqd2x3I7lUgSVQlpKyTbLT0ObtVPIR9/nyZH +EsG1PN3XfQkF2yLzjV2CQtG602SJwR7eoYPttZxZXzcATimYQ0al9/gQjjOsXL6Xi59e0jARFx 5h+75uEw4ZG/PUHF4CJS3ASfYSr2IxU/R6w5yA5BfR973Cj8iNzeV+S6NkZkKjk9YjwhYl1r46S EamUulRHTrrvS2C65Z2OdbswGX4d+3ioIqTJzciDY0Dvmzef7o2ioYwne6N6bB0MXTyj4Q7Rwwb poy6aYBUh0H5RCEFywxx/s/hLi1vYLwSAZwvhF6QCRUB3EfhA8Yru49kwVneckN4m8S8UGmOQM/ 37C/O5v3NbELhfcuLQn2NCnaQacDnjvn7qFXKhTslu5OVMVZaR0kaT9mKIEJJ7ZAtBkpmJRbWFj Xl1R9i+yZrwRVZoQxz5k0VLXoT9IkRbADuys9G2p7Wo9ZNvgRtZhqyHq8W4uOCjfrodAMjpSE+b Qbdrm9sTG3+6io4waeSmkacdPhyo3qmXDUHllLKiXx+ZxXtg2MQr/I65q6BYkcarznMswMJ0ZQl 7CyNwAzXlFaeX4g== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 xfstest generic/728 fails with delegated timestamps. The client does a removexattr and then a stat to test the ctime, which doesn't change. The stat() doesn't trigger a GETATTR because of the delegated timestamps, so it relies on the cached ctime, which is wrong. The setxattr compound has a trailing GETATTR, which ensures that its ctime gets updated. Follow the same strategy with removexattr. Fixes: 3e1f02123fba ("NFSv4.2: add client side XDR handling for extended at= tributes") Reported-by: Olga Kornievskaia Signed-off-by: Jeff Layton --- fs/nfs/nfs42proc.c | 18 ++++++++++++++++-- fs/nfs/nfs42xdr.c | 10 ++++++++-- include/linux/nfs_xdr.h | 3 +++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 7b3ca68fb4bb3bee293f8621e5ed5fa596f5da3f..7e5c1172fc11c9d5a55b3621977= ac83bb98f7c20 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -1372,11 +1372,15 @@ int nfs42_proc_clone(struct file *src_f, struct fil= e *dst_f, static int _nfs42_proc_removexattr(struct inode *inode, const char *name) { struct nfs_server *server =3D NFS_SERVER(inode); + __u32 bitmask[NFS_BITMASK_SZ]; struct nfs42_removexattrargs args =3D { .fh =3D NFS_FH(inode), + .bitmask =3D bitmask, .xattr_name =3D name, }; - struct nfs42_removexattrres res; + struct nfs42_removexattrres res =3D { + .server =3D server, + }; struct rpc_message msg =3D { .rpc_proc =3D &nfs4_procedures[NFSPROC4_CLNT_REMOVEXATTR], .rpc_argp =3D &args, @@ -1385,12 +1389,22 @@ static int _nfs42_proc_removexattr(struct inode *in= ode, const char *name) int ret; unsigned long timestamp =3D jiffies; =20 + res.fattr =3D nfs_alloc_fattr(); + if (!res.fattr) + return -ENOMEM; + + nfs4_bitmask_set(bitmask, server->cache_consistency_bitmask, + inode, NFS_INO_INVALID_CHANGE); + ret =3D nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1); trace_nfs4_removexattr(inode, name, ret); - if (!ret) + if (!ret) { nfs4_update_changeattr(inode, &res.cinfo, timestamp, 0); + ret =3D nfs_post_op_update_inode(inode, res.fattr); + } =20 + kfree(res.fattr); return ret; } =20 diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 5c7452ce6e8ac94bd24bc3a33d4479d458a29907..ec105c62f721cfe01bfc60f5981= 396958084d627 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -263,11 +263,13 @@ #define NFS4_enc_removexattr_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putfh_maxsz + \ - encode_removexattr_maxsz) + encode_removexattr_maxsz + \ + encode_getattr_maxsz) #define NFS4_dec_removexattr_sz (compound_decode_hdr_maxsz + \ decode_sequence_maxsz + \ decode_putfh_maxsz + \ - decode_removexattr_maxsz) + decode_removexattr_maxsz + \ + decode_getattr_maxsz) =20 /* * These values specify the maximum amount of data that is not @@ -869,6 +871,7 @@ static void nfs4_xdr_enc_removexattr(struct rpc_rqst *r= eq, encode_sequence(xdr, &args->seq_args, &hdr); encode_putfh(xdr, args->fh, &hdr); encode_removexattr(xdr, args->xattr_name, &hdr); + encode_getfattr(xdr, args->bitmask, &hdr); encode_nops(&hdr); } =20 @@ -1818,6 +1821,9 @@ static int nfs4_xdr_dec_removexattr(struct rpc_rqst *= req, goto out; =20 status =3D decode_removexattr(xdr, &res->cinfo); + if (status) + goto out; + status =3D decode_getfattr(xdr, res->fattr, res->server); out: return status; } diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index ff1f12aa73d27b6fd874baf7019dd03195fc36e5..fcbd21b5685f46136a210c8e11c= 20a54d6ed9dad 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1611,12 +1611,15 @@ struct nfs42_listxattrsres { struct nfs42_removexattrargs { struct nfs4_sequence_args seq_args; struct nfs_fh *fh; + const u32 *bitmask; const char *xattr_name; }; =20 struct nfs42_removexattrres { struct nfs4_sequence_res seq_res; struct nfs4_change_info cinfo; + struct nfs_fattr *fattr; + const struct nfs_server *server; }; =20 #endif /* CONFIG_NFS_V4_2 */ --=20 2.53.0