From nobody Thu Apr 9 20:26:03 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 BA7BC2DE709; Thu, 5 Mar 2026 18:53:14 +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=1772736794; cv=none; b=hF80Qohz4Oqih67zfXTH0Cnj2V/iUJAX/bHabkbPAQFBXSBYZfbMOL9lPB3MXTMX7SJ1ph7U38OBdB2hkXp+jyvk/S2VUWd0+PlGzoZuhcbkzrwrvTxgrx90li0CjkxuICKclfsWMr++obka0dSIWplj6UmcpwsrOUYT76jLFIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772736794; c=relaxed/simple; bh=g2igT+ahgcS7QSpap1Cf/wWgQ6g5HUPnMGKeQOS2u4o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cVtsf/wDHyD0O4sN8XQH23xGaw5M6q8+qVBtwn50+so+kB+yjggtSVA0DiI+IkChQAPoVD+Y79EzemrOMKX2b05T6r6B62cKskf2tcL2dFT7PloEa5d/sTIUajeRK0KfzeIEJE4Hj5+R9oZ55cCvlpre9VxtUymRNXVRl7acfWY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=euQFlkQF; 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="euQFlkQF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CA8FC19422; Thu, 5 Mar 2026 18:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772736794; bh=g2igT+ahgcS7QSpap1Cf/wWgQ6g5HUPnMGKeQOS2u4o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=euQFlkQFIpMb3Z+HSU03FiN1GAD9FnfhLWGz6cyerBOjIrF9/EnhnCRWXNkssQ59V Oc8QlbkglsKU1pBJaXzinGlYTOa3lrv5csYfqyOSl9KEMG/aqwaJYUD1sISjcJqJqX K4A5x9487coeuVmIGnlHjzn/EpjGpoyK2YuntFNOEDozOh26eLQbPf7ZfPndy5xjCy yLj9xZNKXyZSGLVPo+7BajnCVvEcoHyjOsE5apYhQs1ULU/7ivyeNdSwuhYFPLMzAC MIBNs82YLjMwK21FXc2C9BgHr/eOXuvvSsFJfU/jKm7/d7GSm62bvIhu47QZ9v+8+2 221Ip5bRXkX1A== From: Jeff Layton Date: Thu, 05 Mar 2026 13:53:03 -0500 Subject: [PATCH 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: <20260305-nfs-7-1-v1-1-e2200f69e543@kernel.org> References: <20260305-nfs-7-1-v1-0-e2200f69e543@kernel.org> In-Reply-To: <20260305-nfs-7-1-v1-0-e2200f69e543@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=1624; i=jlayton@kernel.org; h=from:subject:message-id; bh=g2igT+ahgcS7QSpap1Cf/wWgQ6g5HUPnMGKeQOS2u4o=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBpqdEYnM4fpCgBGHhQcnL0jbwKgG/hRvV3Yc4CD pK44U4t06KJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaanRGAAKCRAADmhBGVaC FYuMEAC2emzo3UG9BMOgGCRE1C7j03/0FVfw6swXBtsi48LN6Iwgp87Mk7zxSvzjcnPBBcm4gis i7G2lHJMOcQBD3Vny+OuhlUrBis0IQ4h4Uue3q/6yoHsr/1b4fIEAih/UdQXNFl3RjUnjEnsCrq zuYLF01HjwS1/asOiZr4HU7BoiYfi+84cJjzTxIvmOBDtmWznDVxkLbwBgDn2JXB46H5XAyXOJ+ hi0jXAqqZWoSh/M++CqTRSluTfE8W1ljDnF00iwSnkbQgESEUnfXcDgsQNXz3B4Kpe+MLR61o43 5ZeiJToLvTt3U9isnlaKQrYD3OOFQe1VhzLsbZLYfKk/pII+Eq9pLHphxJitssu2LW0gLtcdNtw 3eHifvsNd78F8foANvH7ocGj+RbkcqFjt7dRhf8dbYkl+KWXWPNUW1uU00R8LfIGd5AMEG6TyRn rtuc3RhnFI6/IiLyTwXrYbU38g2UNbl7EXGksggU2D5VcHuQFb6Vkg0JCo0HFkKWTtoVLTgdlHe QoNu6z0221UueeExRkCK0avBghh2J9GuLOXyyLLBbZ5iKThHMVPhMM4lJFSZ8AV5PmA9Srcq/bB 4PpJJP1+tpjBnP+tUvbD3w3S3jlAGqpq1GLeS70bYR4xs9OZ6Js54BKvO/ga+VtkKkH9ylSlepK WSLenMv3R0Z3lYQ== 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. 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 Thu Apr 9 20:26:03 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 B80022EBBA4; Thu, 5 Mar 2026 18:53:15 +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=1772736795; cv=none; b=WJuPaDx5HqlV1uo0uMLOIElVGE/JtF6U1pthou4xfud2cCPAGuvEOw/kxVOHAPPX3wegTnA6BKA+6+DxevNIvHp3xy4Y1ydrtHV2wFFU9J+7EpoR2auYNBeITxEFsdvTSpHcjW2dEzxpDO6xo/JHn/G4z278mAIPC/S9NWQq3lc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772736795; c=relaxed/simple; bh=pUQvmH62q2O6eU04poXvkWXDGCmvlv+pRppn5LiGz3M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sKeFZR2qmoK1cfm/EkbnJ0epbP2XGvx6SioxI9HXrsyNhic7BOHq+le/IFLNCtJfK2FkcJYGlhk6sjVjCvXu0iZebVtaKrdUwzjMTh+GVFwq/5/mU0YaS2cxXh7dZZBMYTOKFDAamoLt10Mc3QcE9iQ2f9RYUQ9DTOCS6qo4z3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tkGcpx5D; 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="tkGcpx5D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB279C19422; Thu, 5 Mar 2026 18:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772736795; bh=pUQvmH62q2O6eU04poXvkWXDGCmvlv+pRppn5LiGz3M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tkGcpx5DiaPzSNgTrAbDbGAUtNDZUc0/3qFMJ1CN6CLZDKGk4NxlQB32Hk74r6952 Ettp7b+Pc1PScCnd7GC1ub7LQywzO3g5KlGzsAqXCvfXWiJKQYAM1KfYaIE5yq4aqd Hz8Y0EvBgHO6ivIlaudc69K1TtJJ1ASbv62DqrXyXMiPPGxhm0AdXbs7JmEBbs02W9 wjd1kxfBfzHC1unl5aaymwXQ9rIjE9yhWdL0sKoXBnL8x647HsickjUCV/G71A1wlJ 0uOKdGdl2ETR5HL3x9xS/fEo/QniJzd+9IKqVffviwM5Cmx1+fj1h5SBIISL4QH1gr zji7C1XBhjxnQ== From: Jeff Layton Date: Thu, 05 Mar 2026 13:53:04 -0500 Subject: [PATCH 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: <20260305-nfs-7-1-v1-2-e2200f69e543@kernel.org> References: <20260305-nfs-7-1-v1-0-e2200f69e543@kernel.org> In-Reply-To: <20260305-nfs-7-1-v1-0-e2200f69e543@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=4123; i=jlayton@kernel.org; h=from:subject:message-id; bh=pUQvmH62q2O6eU04poXvkWXDGCmvlv+pRppn5LiGz3M=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBpqdEYn1kc8sRDr4A5o60VmBzy4eiw8w9CuAZkl bA+Ac8Qb86JAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaanRGAAKCRAADmhBGVaC FZeLD/99ss8LG9n5TZ+JPUkF3bq8zUOmOjXUA/qvFueRQ8YrT7f/8OxIXPTXQtmqAXpLM+yOy5Y SzqHgnRb7BpM+HyW6b2Jir8K6d5duBsYqHx8mC7uPnkF0tYN5J7PDiUTZfx3d7NgzHzetDi2ivn aCCt4doEmlvwRdbaSuR/NwsbAUN5MgZs/c7Oa2isvMzsDDJMGwyC/qR2kiVsN+fmFezxEFm9+MA tvl4zXIJJFLgUCLdkJfSmSqDMfeS0yC9HRVTjKEUcCIG1XNo0c7wwudKdtAWQ9pp58ONVcHP9n+ Q8W1Rby+aLBC1vEt2se8H5wHaZUMME6paryATDGJ6v6uqGgHuWQuN1VLT5EmB0+Rqr4ahADZrA8 CutLb8oi3CScbDB8yaAIgh3HhydxIN60cdigag7f+gFwXF5tWEvBrKdWjS/fDwH2Iaf09+zpmeI 1ccD7xkJ1KpI6JY6raFE+ZLqivwKLsdv2/WRwSGRZl+S1dOdu+vce3d6NcZuGeH+uXvS1eEJx13 THCQvHr7Ol/EvEVom/2ZjOHrQbRALQNvqyHGt70ck+F0obcA21qNRSWkNm1YSjJEJE4VjKj54lU Epgt+YR3xiZXsyff2f2cKRjH6/AbOfOZsdR0kGeaillHqtVQh7a+IRFyF7cVwXoII3wqV+6tP0e 6sTSV/II/Ijn+rQ== 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. 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