From nobody Mon Oct 6 01:26:47 2025 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 258162253FE; Sun, 27 Jul 2025 18:36:25 +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=1753641386; cv=none; b=W+v99dbU33sfGaQCusdnUt9UhWOKXGl6M0X35BObbshja0z2bTN6KiqZki04OyitZIiTrG8nVdb+uVOJQDAU+2qD/ifIpzXSyakLXFc/9FZ9WCUQbAG+6OuUUT/4GrIRTYc1E3qILIY2KO4eKtnC0gymu57XhQ1gNVlSwGfiBbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641386; c=relaxed/simple; bh=wX+jZhM05ADBnfHIbs04wC7/mLDtqIQ+H+KgWBk6ve0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qAwUeSi6KDtoDhNCYS4ORKsJmVj3I4YqUhQUccmD3/9Zg2D32CUlgbxZjhurLOEgyDgwB0YzVQPXl0BUO0gplix58RbogipCsYgtFVGi+w1sZp21tzM+PHVUCZY6pm94r3nGm14SAMfiGmPShL2OMBaZtHaj5JZlIuRhfkF2XXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n9mG2wYw; 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="n9mG2wYw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64560C4CEF9; Sun, 27 Jul 2025 18:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641385; bh=wX+jZhM05ADBnfHIbs04wC7/mLDtqIQ+H+KgWBk6ve0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=n9mG2wYwa94UbZ4p/3F4N4tvjteq4TYUsHWu0uW9/Sf7PGlIndG3+FDvjgEJxH5QW sVN7V2+Znt70kuGjB27PfDdhuDasZANp/Ajw5jiHxXnWOSITzqkqXlEr2qiZShkrGR mjSkLndFXUxo8hPM2dkvdkSs5+JfVvUuJWyOds0Pig0vL0wWfA5o/pffqzAOB6xTND oA3Cj5fmUtxiAtajIsPRrJwixFL/NzI62GG1Q7+UUNXc4mDD/Nv6x+ZjflHP4IfV1x si2FZwNIzh8vULRasf4atZ0Wc1OLxAPnc3BvpGH9deIiMwqsXO0LQhf+GP+agDwZvi hNCAmesY2vpAw== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:11 -0400 Subject: [PATCH v3 1/8] nfsd: fix assignment of ia_ctime.tv_nsec on delegated mtime update 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: <20250727-nfsd-testing-v3-1-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=892; i=jlayton@kernel.org; h=from:subject:message-id; bh=wX+jZhM05ADBnfHIbs04wC7/mLDtqIQ+H+KgWBk6ve0=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGl7UXl6EFyujtglWHQECzmgMQ3mQNU6ot9j xI7j4TRwEGJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpQAKCRAADmhBGVaC FdGLEADMMRJ+fvYN4+akt/isW2b/MiRfbGI2KUKrtOuD+PgwpMT3dBevsiViI3rtMGciH/jHmAx uCUeVPbrNmAjtTDF6MyTfGu3XgWunL+0cPGKMT/gJNeVawzi82obIohAlj7aTJR7+7n7D2B5/WG FyTCuSeOpINTLvipFs2lBY2WsgZi+YbxcWhfwBeAYxOmyxnjGQCyBTIUDOq8GghA4AemzEHGQ/8 DYEzgbJOpY5fhprY2Q8fWfYsi75Pzdsdhzets+Xsv40uAWVGVq2Q+rJyZ4ZFyehSrgyJL4BfzZP Fyx4RqwjucnyBQ/co2qiA7jULx4uCxTbJLIOX2B+fqeAOB0GbmusK90E5SgkWzFrGwe1PmjTocS WsMoQNv/uuKkWLPl34thQ0YodjkBUTFGojtsMeN2jUQubotjU+OiNJOhjiMZORXmvMa7jL7AROY kIOvXrO/45dE63R5F1PpczjV5DkFehKz8CNN02u3UviWIMc00yYdHWz0ffwpUQqj9qmJNXMVgQ5 X4eZDU6xpwWh9DcqN4PhLK+vaBHV6aahJEseVbedEOddlNJoEmNk+m5noF9vSXKYPUOHwh6BFP2 BCCzvm7e/izb5z+qPXvn3bHLGoBQXRMBB75bYCxHivlApJ/BEO9bx1V9GM/6exxqke7MZwL3ma6 qRl8CcK/2dlBTtQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 The ia_ctime.tv_nsec field should be set to modify.nseconds. Fixes: 7e13f4f8d27d ("nfsd: handle delegated timestamps in SETATTR") Signed-off-by: Jeff Layton --- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 8b68f74a8cf08c6aa1305a2a3093467656085e4a..52033e2d603eb545dda781df545= 8da7d9805a373 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -538,7 +538,7 @@ nfsd4_decode_fattr4(struct nfsd4_compoundargs *argp, u3= 2 *bmval, u32 bmlen, iattr->ia_mtime.tv_sec =3D modify.seconds; iattr->ia_mtime.tv_nsec =3D modify.nseconds; iattr->ia_ctime.tv_sec =3D modify.seconds; - iattr->ia_ctime.tv_nsec =3D modify.seconds; + iattr->ia_ctime.tv_nsec =3D modify.nseconds; iattr->ia_valid |=3D ATTR_CTIME | ATTR_MTIME | ATTR_MTIME_SET | ATTR_DEL= EG; } =20 --=20 2.50.1 From nobody Mon Oct 6 01:26:47 2025 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 BB04422A7E4; Sun, 27 Jul 2025 18:36:27 +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=1753641387; cv=none; b=Ofg+tAjBTHT6mQI8H/m/T9tpB5eo61x76zq/ACij3REHfU3Il5oGnKwW9wnyxUw18Mr7OEwbZaCqk0Jz4KE5vljFwtl0z1vVnB/VKg6X7IcISdKcHal3/eOWiOmEZQoYidZKeDi5IqUQmtrHbRjRTsK7tllugUt1BcvkT9dnAlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641387; c=relaxed/simple; bh=XDfX4u5DGDNsbxUiLltzn/YVAvj+NJLvOFItEakukpE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ThY5ZgVIn8OMuTWjGCLq3z2p28XUyULybhohbQZ+5Wk4z+17/FrtueQHxo9rGU/8CAB0OOCQ8PBkxR37qrCXfwP+wUvF/3hgTEGqVD0sEGq8s2wQi/c0n6b9P2mfcrEDZ4GxYBZVzxftQR0QCZeEPqHcRZa20lMd8R7n58obyz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NSIAwYWL; 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="NSIAwYWL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 016C9C4CEF8; Sun, 27 Jul 2025 18:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641387; bh=XDfX4u5DGDNsbxUiLltzn/YVAvj+NJLvOFItEakukpE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NSIAwYWLn+2BSZjXw1kFjg5U/mLacopZUxPzxh1ctw9m9CSaczv3GP4WPJJwFm1OA BOMXO7oo1a3HyPcEXKXGbQRQiSo4dSYZdiZKBWY91F3Xlu1TvSc18ilmk7wGNsSxj3 daRjvOghqXXRxru+yUk1dDswQs2ShSq8epmFdxI5pMrS1flw35cGqRIwMfuBhc9jIq PrSpe5iVxB5iNFXZ5OrVMtV0dAQWANM8676ngs1tyPLISkBoppd5QUZyt1LHYe2sA0 TpwHyT909OwVI7uTGsQgVqDZQ8Z5rjOm4rn98BnQS860dRRt69GfqpqSFbmP3R+25F gq19ycbUq4wsQ== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:12 -0400 Subject: [PATCH v3 2/8] nfsd: ignore ATTR_DELEG when checking ia_valid before notify_change() 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: <20250727-nfsd-testing-v3-2-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=675; i=jlayton@kernel.org; h=from:subject:message-id; bh=XDfX4u5DGDNsbxUiLltzn/YVAvj+NJLvOFItEakukpE=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGlOH8UIIILD0ORSvdTIZ5UZT88AECxsI6nY 9y/+hOeWwiJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpQAKCRAADmhBGVaC FQ+KD/4xANew4PQHdCK1r7dlcSt105LXkHTJUSnPdbsEK/90zR9S818wFFbh6Irqyu7CMw8K+CE wlslK5Tw9FMeHc1qtatc3Rk1A9VQrEaRcggApd3aNlM+ITvMwCHGlIu6/3WF81rfWjGwipUFH8c YRMnpoT7u9H9xp6QRfAmjFB9f/lbKnEXKW3MBC4uYrw43hj/q72Ii47ufPSn1jtQH17+rJmhEGF hEVQbuQTId47wW9eOO3yf+19gXjsPkUwmiLeQddNoDiox1V3BNKLRBbD2jqfv/UON/bXtPk6P+a EKJ8HB5zMABU9nmb8Pnk8/PKdXV83y5qAzx2NGlrVYhleBRLITxeD+UxMuimfDH4qqDmAwFcQ26 P4uLQqkVzg12QtLiTzVvEgGZHLza/ZFmsZtn8CnVrX3Lu7Jco3Fb3vYBS8MNnJZb6nsu1frrUEA XLksKyjXzU1W9bobwKascP718IpqMpNhbrcxqB9CqHcYJBD/m+HCHQRwrW/s4bn09vtxF76uwYx 2YrZcTqoLlxo8w7gP2LKW98BJ5ZWRjigWJ1AoOBEKEa+DrCsJG3BqG6mpPmKJ5UY2FC7X3jtX8X 3ONhjCnFeAzvVVtuQXS1Jydx3UmqGW1fkjmca1fVkgPHOK0+wJIS8j1MLGYZiOda8EH79xQ9T+g wmU2gT8u8b1CSwA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 If the only flag left is ATTR_DELEG, then there are no changes to be made. Fixes: 7e13f4f8d27d ("nfsd: handle delegated timestamps in SETATTR") Signed-off-by: Jeff Layton --- fs/nfsd/vfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index eaf04751d07fe9be4d1dd08477bc5a38ac99be3a..68d42fc5504d8750174b9a2aef1= 0886ed92f528b 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -467,7 +467,7 @@ static int __nfsd_setattr(struct dentry *dentry, struct= iattr *iap) return 0; } =20 - if (!iap->ia_valid) + if ((iap->ia_valid & ~ATTR_DELEG) =3D=3D 0) return 0; =20 /* --=20 2.50.1 From nobody Mon Oct 6 01:26:47 2025 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 5A7DD22FDE6; Sun, 27 Jul 2025 18:36:29 +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=1753641389; cv=none; b=bB369UShcyyPMKCReH009aW33cUNQZcRWu9XfRaeZSBy5m/1xIPg2qWzoqow/D7Jr84Jyp8hT1VHBVfnSd5UfPDvEGShEiKyXwV4nNba9WN7N09UymTqw87eP6cyQVL2lMIPRVkkGTLc0b2m5U8J/ao3cMjc0fK/83w2gC+WfLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641389; c=relaxed/simple; bh=aP036MEInZMizMlEkvsGvCO+OnhGglaFKY/Y/gbmCZE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WLD7LNBU4Way4B35nGvxJa9lrEhdvex1WBFvyBesyPgrvFKbYhNOzkKsLTVaR0n7+uLWNDc+4UdTm0XRj3zCcA947ljIzbdQ2Fzm0q5YDdwkTwyMU4/dmc4Uw9CQ4eAa4M9EM8SLl1hpDvVuDoB0oKZrQYarDdB0gsPwz+6YNxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YyCUoYyj; 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="YyCUoYyj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91BC2C4CEF7; Sun, 27 Jul 2025 18:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641388; bh=aP036MEInZMizMlEkvsGvCO+OnhGglaFKY/Y/gbmCZE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YyCUoYyjvMqMYuzlR1GY4uv0wTZvrSlaUD7wSb1ZZ0d0KUbH2y/S5fPuI8s6yu4fu NeHQoWLF79aRtMQLF68f6WvNS88GAUVdGSXaGpn45ryrm3eZZXKCzs9vyrlW7WzOAl Aho/y4nagcbSf9XLFpCiWrq7LSG78mjsGfCUF5dH/XLSo5+gheUV5d99it3Ny1iZEj CXv6md/5fTuSMLoN5MDcMdNAopRmTISZXgDGB3P++YEXx8e1Q4s6fh5oe0gqRfBqNW jhqLRAok5x/s13GZzGUOYayJ1Y7P62MEPyCCfq32iCwD/BY6bCa/SVHsTDr6MnCgFR lko3JSQDNTV7Q== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:13 -0400 Subject: [PATCH v3 3/8] vfs: add ATTR_CTIME_SET flag 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: <20250727-nfsd-testing-v3-3-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2144; i=jlayton@kernel.org; h=from:subject:message-id; bh=aP036MEInZMizMlEkvsGvCO+OnhGglaFKY/Y/gbmCZE=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGlNatSEAsI2nkY9cwBq32UW332MKTLEJEM1 0dWQHHTmbaJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpQAKCRAADmhBGVaC FeHxD/4rKGngRhnCLaIvQdMGx5mwjQOs/WouDzHR45dgfaV7tuXq+fxdQavaMHNmC4YLwmJojh/ Icf40CijDQDSdO21b4fj7DbZm9SgYAjqDym+6Eu0A3v1hsr2UrdzQqH1Ohj7Xl+5+KVHORjX/qB dD0gYB9MhisAHvE0La+lS5YH1yutR5yCsNk7l8fa97qEifDeYZ9r7W8Qt3KqI+ex5AMd32WmMPo CX4qXv8OtMsLuN9Peu1mYOKZwXC1Cgwqk2GGfeyZjdHLkV6SRFja1YobrEBfl0mSg1dz3eW1BF8 i1pcSbavV2s4B+x4qG2oNW6+y27tzFbOFywBYONHZ7Qewk0qbkODq5+4OquTRxYoD/obkW9H2ky M4EvWVbqqCLzIbQqIGRDMdvjH/gvt1SHkv4CZpqqX6TRsi0yXvpW1REskKyYaR/5GZub19bv4xf D2FYmlLVy2I4MBDvctPQ7JvGIZSd+0iSW9td6Cj+CD/3KIwBRxcvK39RB9qssJH3bwcurwDRdT/ W1j6UbcDdW6AM4Y6zZcaBQa2UNP2B6HWZtl0GQhm9H06w8Zpy9vqaXSE4ZFKMkxPlnq826ZEVX1 4X2J0Cw/I38Wg3PjCFSZsKNQ9ckPIZ2nqW9EOsi1gZUmuZ+oXdmEy0bc+ZZFMcT4OY32+3QimC0 20C9cLu5rU7cAgg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 When ATTR_ATIME_SET and ATTR_MTIME_SET are set in the ia_valid mask, the notify_change() logic takes that to mean that the request should set those values explicitly, and not override them with "now". With the advent of delegated timestamps, similar functionality is needed for the ctime. Add a ATTR_CTIME_SET flag, and use that to indicate that the ctime should be accepted as-is. Also, clean up the if statements to eliminate the extra negatives. Signed-off-by: Jeff Layton --- fs/attr.c | 15 +++++++++------ include/linux/fs.h | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 9caf63d20d03e86c535e9c8c91d49c2a34d34b7a..f0dabd2985989d283a931536a5f= c53eda366b373 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -463,15 +463,18 @@ int notify_change(struct mnt_idmap *idmap, struct den= try *dentry, =20 now =3D current_time(inode); =20 - attr->ia_ctime =3D now; - if (!(ia_valid & ATTR_ATIME_SET)) - attr->ia_atime =3D now; - else + if (ia_valid & ATTR_ATIME_SET) attr->ia_atime =3D timestamp_truncate(attr->ia_atime, inode); - if (!(ia_valid & ATTR_MTIME_SET)) - attr->ia_mtime =3D now; else + attr->ia_atime =3D now; + if (ia_valid & ATTR_CTIME_SET) + attr->ia_ctime =3D timestamp_truncate(attr->ia_ctime, inode); + else + attr->ia_ctime =3D now; + if (ia_valid & ATTR_MTIME_SET) attr->ia_mtime =3D timestamp_truncate(attr->ia_mtime, inode); + else + attr->ia_mtime =3D now; =20 if (ia_valid & ATTR_KILL_PRIV) { error =3D security_inode_need_killpriv(dentry); diff --git a/include/linux/fs.h b/include/linux/fs.h index 040c0036320fdf87a2379d494ab408a7991875bd..f18f45e88545c39716b917b1378= fb7248367b41d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -237,6 +237,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t o= ffset, #define ATTR_ATIME_SET (1 << 7) #define ATTR_MTIME_SET (1 << 8) #define ATTR_FORCE (1 << 9) /* Not a change, but a change it */ +#define ATTR_CTIME_SET (1 << 10) #define ATTR_KILL_SUID (1 << 11) #define ATTR_KILL_SGID (1 << 12) #define ATTR_FILE (1 << 13) --=20 2.50.1 From nobody Mon Oct 6 01:26:47 2025 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 A406F2343C0; Sun, 27 Jul 2025 18:36:30 +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=1753641390; cv=none; b=RiirG7U+tK2Y4ds6d7OAds5ZtyJ2DKpT9q8bFbOl6aY05LyCXF5KZqqcqFMe+/7UL2JAlPpdZmYIgaVd3mmWGG4btrafJJhjD3Uj0VLuI6Qe5ys52Odv/yCYxt4ger8VsGSeSN79rE/HiKvrKDO4+pb5VE/0A3jeJbzlWEiF05Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641390; c=relaxed/simple; bh=tB28A7UEW/1kAwxOpup/7X4hmWe1RoJvUGt2RZpGRko=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UChe9ciDMVctw2U2LTtFrj5Owfb8Q6X6De8MhqB+6XhQ4Wf+vo3Z/RpWK9kzcMFxh7C66lg1Viwor8fcOn8jj3o5wly01cifhz8jUyFaGVjhFrQ18K58Y+ZquTAOB6y58XZyxWLJzDSbmprgk5vkpX8AcBpzLAXwxZ1gQTJRVNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xq7cGl2M; 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="Xq7cGl2M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DDB7C4CEEB; Sun, 27 Jul 2025 18:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641390; bh=tB28A7UEW/1kAwxOpup/7X4hmWe1RoJvUGt2RZpGRko=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Xq7cGl2MrD/BJSYSAtROGzOlynYxA21pxvfarm4zPIrmZAe2P+YgqI0K5smqsEZZI QAJQtfCeeMSs0VgHWlbIrBqLnMOudeCk2ccKm5ElpxcVfZ/6cmSZonqibb5/tCNtQX Rvck77Px6JSs8cJw0YAj+uhUFT0RexGBAPYFHD3HISJF/8gN2AzP0GhMj6ID5Di4Tm F9KUY5nlaFtlTacFJ4+Jd20XkcA2hsSSDz2KY5YQTRPc69NW/IUNURfqATCqJHiMpN b2PwcoGM5EZHyOqNtZmWF8AmN9sEeXxL8GvEyKA9Y/BXoUwk/72JHepEEISoWSELjI IjUMYBVzvV8xw== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:14 -0400 Subject: [PATCH v3 4/8] nfsd: use ATTR_CTIME_SET for delegated ctime updates 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: <20250727-nfsd-testing-v3-4-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2742; i=jlayton@kernel.org; h=from:subject:message-id; bh=tB28A7UEW/1kAwxOpup/7X4hmWe1RoJvUGt2RZpGRko=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGls1yb2RnpV9ql6Wo1JRJszwnE/7UpUdCym kjUViPElkKJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpQAKCRAADmhBGVaC FRSSD/oCdv0wKgUqqEZE7shc6/M8ZRGEa+AB8MnmPU+lZq2LTq5EP2sIPpUx3il4TeiEOjP3YvB YfmS+xUb0q5sI5sNNOSec8XeiEqTfisInQCrGNKlLrw0I8Imqn1FDdfqtGEa2V/zssbJQMTgVK0 Ge7ir9gw0s79z5AL7EztP5+AgvNINugerG6qX/eSnRhBHQw2RCAptpvoey6Xd+JOZImHbUDwYJG TUjrlBDBUMZ188L+dmUnOk2KQE+I6yWinOqsUri2sfMfNbRmnkOQcIVoHoZg6l8K/n8u8enp1Tn hfJXei42MFhQwRwT0jK+wFMz+8tebQRpP/DroNDB3+xJZ6jxvOThLAiTY2Pz6LVvROskbyIxB3b zZ/NIVH5HKcOfdVUbntWTUrz16aUdC2/iBc5RaHqFqRAx/ro4pr5tNvwEEA76thHfudJ1vF0tKb dVGSzNU9BOAsuPzCZt0HpHh4eE1A9akFGRFRnSp5TkiKDjCU47TYHvJ0wQTi/x+j/2O2Anv0haf 1bw1FfTHOB0WdmndkDNgOuGm3e6dzX6IpMmLORwjhkS9tc9C/5HjqkctGTByo4zgaKHN546XgX6 d/9xZkv7zCOz80TVpRxQP7w01yO8dVQb76FoDhdngA8QJAoqaTNbHNmEfj0mMFMZjFgbsk9jbRn SodUHouIntb6wNA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Ensure that notify_change() doesn't clobber a delegated ctime update with current_time() by setting ATTR_CTIME_SET for those updates. Don't bother setting the timestamps in cb_getattr_update_times() in the non-delegated case. notify_change() will do that itself. Fixes: 7e13f4f8d27d ("nfsd: handle delegated timestamps in SETATTR") Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 6 +++--- fs/nfsd/nfs4xdr.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 88c347957da5b8f352be63f84f207d2225f81cb9..77eea2ad93cc07939f045fc4b98= 3b1ac00d068b8 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -9167,7 +9167,6 @@ static bool set_cb_time(struct timespec64 *cb, const = struct timespec64 *orig, static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_dele= gation *dp) { struct inode *inode =3D d_inode(dentry); - struct timespec64 now =3D current_time(inode); struct nfs4_cb_fattr *ncf =3D &dp->dl_cb_fattr; struct iattr attrs =3D { }; int ret; @@ -9175,6 +9174,7 @@ static int cb_getattr_update_times(struct dentry *den= try, struct nfs4_delegation if (deleg_attrs_deleg(dp->dl_type)) { struct timespec64 atime =3D inode_get_atime(inode); struct timespec64 mtime =3D inode_get_mtime(inode); + struct timespec64 now =3D current_time(inode); =20 attrs.ia_atime =3D ncf->ncf_cb_atime; attrs.ia_mtime =3D ncf->ncf_cb_mtime; @@ -9183,12 +9183,12 @@ static int cb_getattr_update_times(struct dentry *d= entry, struct nfs4_delegation attrs.ia_valid |=3D ATTR_ATIME | ATTR_ATIME_SET; =20 if (set_cb_time(&attrs.ia_mtime, &mtime, &now)) { - attrs.ia_valid |=3D ATTR_CTIME | ATTR_MTIME | ATTR_MTIME_SET; + attrs.ia_valid |=3D ATTR_CTIME | ATTR_CTIME_SET | + ATTR_MTIME | ATTR_MTIME_SET; attrs.ia_ctime =3D attrs.ia_mtime; } } else { attrs.ia_valid |=3D ATTR_MTIME | ATTR_CTIME; - attrs.ia_mtime =3D attrs.ia_ctime =3D now; } =20 if (!attrs.ia_valid) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 52033e2d603eb545dda781df5458da7d9805a373..c0a3c6a7c8bb70d62940115c310= 1e9f897401456 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -539,7 +539,8 @@ nfsd4_decode_fattr4(struct nfsd4_compoundargs *argp, u3= 2 *bmval, u32 bmlen, iattr->ia_mtime.tv_nsec =3D modify.nseconds; iattr->ia_ctime.tv_sec =3D modify.seconds; iattr->ia_ctime.tv_nsec =3D modify.nseconds; - iattr->ia_valid |=3D ATTR_CTIME | ATTR_MTIME | ATTR_MTIME_SET | ATTR_DEL= EG; + iattr->ia_valid |=3D ATTR_CTIME | ATTR_CTIME_SET | + ATTR_MTIME | ATTR_MTIME_SET | ATTR_DELEG; } =20 /* request sanity: did attrlist4 contain the expected number of words? */ --=20 2.50.1 From nobody Mon Oct 6 01:26:47 2025 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 8C32D23909C; Sun, 27 Jul 2025 18:36:32 +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=1753641392; cv=none; b=kMZKU2ZHHSr5H1Cs4Cv642Oe2Jqq9UDud2Z4r2ydoH3QPnXSyqdULhGbVwTBuRRhnHQaxBAtTAYx+9Ku7h6IHdrfV1g7Xh8Cm0EKiXptVRv+01W3JI3y1FhLgfxc5ZXcLDX9KGfCSXkYn8C3el+PqGZXF29Igbb86tPIRT/AyXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641392; c=relaxed/simple; bh=fdO6f13p1GTQnu6FzwkdZ4uJxgGOC3acS3Ht0AFuvgE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=deA5ba0J/RijIiqL4W6shwsIgIaViq8w1Igv43zewydKuDBhN7y2FMsHCm1LkjT3+NpaNepxdjdyTFNMgoyB+Mb26hP6X3cIv+Gpgom7aURRmLNX9CM3MV7Dk4u6uUUjQEa3q2uRlxICk0CyJqcOr9F3PDeVPpAHnihfkUoqvnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tjPUaPbI; 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="tjPUaPbI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE388C4CEEF; Sun, 27 Jul 2025 18:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641392; bh=fdO6f13p1GTQnu6FzwkdZ4uJxgGOC3acS3Ht0AFuvgE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tjPUaPbIkSik7w2Y3GUReyLhpy8l2uYCWtDq6KTsvcVFegt3f54KDQJGWCEQwM4C6 X3To8bgaKDn2xpT2LCHWe95c6tGjDiBInWkG0w8fKKlaCZDRPlTYJAQ/20zdvcrSBT w7n+eIIUZk+2bAScMT68Q0YS8d0uJOSJFPM6h920qyc+LjhSmrQlyZGscira26ZkO8 gi4+Y5r4xB+9Rh0BZEQMCFcJQkOpEVYkBh2MqE+d7BxngY2E6KMk5k67Jddy3jG5Fj V3beodo1QsmVhUVlvvhvakYYXGTeyCmblScIif9MYIohmJajiBkVl18ADLCXYnhUAI MwG2MkqUF44mw== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:15 -0400 Subject: [PATCH v3 5/8] nfsd: track original timestamps in nfs4_delegation 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: <20250727-nfsd-testing-v3-5-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2805; i=jlayton@kernel.org; h=from:subject:message-id; bh=fdO6f13p1GTQnu6FzwkdZ4uJxgGOC3acS3Ht0AFuvgE=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGmlQKzsiog12wrAlno6OgP/0STkBQ+c233u IDzv4lwcJmJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpgAKCRAADmhBGVaC FTf8EACDdtbcx0EjmZAijW3mC6d4HG3fgUAlDWqLLyApRLJgNohVhm91v5qjnFOTP0/9PXIb7ny TgW3O9PEsYkwOvIpHbWlL8cPrh+idAZmYkI5MA/ppn903OGYU9bQh4hqD+vbAfQvZznYFu71IsL ifGxJjPXTAaFytGx0BSAkr7MmznLEb5X+FxvoqbaMCMG5c8lFPAhBUr3Q9/by+A8F4seOvx2cgk tOU+HRu8bAgngsCU0mWwtOWK1fr1moReUPK4qmpWJhICyyb08Vtnf1PsYg5j9KsDJvku2zFrgXu JpLs8wCFlq9P0dbQUT7JEz2hVoxi1fQ+U/4c34P+87kyj/ZyqEZPyXxO4yFPGLH3mKKz4y3X47a aF+ibH5+YWh7o92eMxCFNJTmo3Pjty8ufXD66MC7y8p8Lgm9Nruvad7AOzU4NGeyP75QTJKLtym +t8LOR/d5V1s3Snyg3Sz3ThK/E0QQe4BoNA4AW3Mi8SN+bChpP3pzkGlABphIIgk0D//jGiwhyx gzuZpZ/P2vtuI9e6oSM7CMF4Gfp/zqZuJOtJGMEBjX6N83ffSZNoEjEsC2ckeWjR/upemncNI+p PUQnVkVzWAp9MHvSKP8lcL4sNGkCAKaBUMRe+hUhjlaMQfBKdRNzpYD67BKk0YFpekhLg+JH10Y /e7PXbrVBvDIGmg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 As Trond points out [1], the "original time" mentioned in RFC 9754 refers to the timestamps on the files at the time that the delegation was granted, and not the current timestamp of the file on the server. Store the current timestamps for the file in the nfs4_delegation when granting one. Add STATX_ATIME and STATX_MTIME to the request mask in nfs4_delegation_stat(). When granting OPEN_DELEGATE_READ_ATTRS_DELEG, do a nfs4_delegation_stat() and save the correct atime. If the stat() fails for any reason, fall back to granting a normal read deleg. [1]: https://lore.kernel.org/linux-nfs/47a4e40310e797f21b5137e847b06bb203d9= 9e66.camel@kernel.org/ Fixes: 7e13f4f8d27d ("nfsd: handle delegated timestamps in SETATTR") Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 11 ++++++++--- fs/nfsd/state.h | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 77eea2ad93cc07939f045fc4b983b1ac00d068b8..8737b721daf3433bab46065e751= 175a4dcdd1c89 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6157,7 +6157,8 @@ nfs4_delegation_stat(struct nfs4_delegation *dp, stru= ct svc_fh *currentfh, path.dentry =3D file_dentry(nf->nf_file); =20 rc =3D vfs_getattr(&path, stat, - (STATX_MODE | STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE), + STATX_MODE | STATX_SIZE | STATX_ATIME | + STATX_MTIME | STATX_CTIME | STATX_CHANGE_COOKIE, AT_STATX_SYNC_AS_STAT); =20 nfsd_file_put(nf); @@ -6274,10 +6275,14 @@ nfs4_open_delegation(struct svc_rqst *rqstp, struct= nfsd4_open *open, OPEN_DELEGATE_WRITE; dp->dl_cb_fattr.ncf_cur_fsize =3D stat.size; dp->dl_cb_fattr.ncf_initial_cinfo =3D nfsd4_change_attribute(&stat); + dp->dl_atime =3D stat.atime; + dp->dl_ctime =3D stat.ctime; + dp->dl_mtime =3D stat.mtime; trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid); } else { - open->op_delegate_type =3D deleg_ts ? OPEN_DELEGATE_READ_ATTRS_DELEG : - OPEN_DELEGATE_READ; + open->op_delegate_type =3D deleg_ts && nfs4_delegation_stat(dp, currentf= h, &stat) ? + OPEN_DELEGATE_READ_ATTRS_DELEG : OPEN_DELEGATE_READ; + dp->dl_atime =3D stat.atime; trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid); } nfs4_put_stid(&dp->dl_stid); diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 8adc2550129e67a4e6646395fa2811e1c2acb98e..ce7c0d129ba338e1269ed163266= e1ee192cd02c5 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -224,6 +224,11 @@ struct nfs4_delegation { =20 /* for CB_GETATTR */ struct nfs4_cb_fattr dl_cb_fattr; + + /* For delegated timestamps */ + struct timespec64 dl_atime; + struct timespec64 dl_mtime; + struct timespec64 dl_ctime; }; =20 static inline bool deleg_is_read(u32 dl_type) --=20 2.50.1 From nobody Mon Oct 6 01:26:47 2025 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 26B5E23C4F8; Sun, 27 Jul 2025 18:36:33 +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=1753641394; cv=none; b=rl0OJMQzOrOWEKR+jjtg/ney2FrUq5s3S/Dc1LTVjBbK9om/1d6O/EVN2WV6pbN/D82cDHcwsOpCBMJOnzSOO9AVJgP598CvCNMwWQ7cZCmVyS7ypXmCG2coVbzkhIdovZf3E5szUS1sheUpIhur/Yv7X4iU/usztXJAPkNExZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641394; c=relaxed/simple; bh=GnTr/aETvE3ymkWSwJqsiI1LzQh8lephKpOFz0kWFvQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dUabyc5cxmiJ4wh55MaRFyDqVsY5Lm6ZSuDvcnxunZc3ae6+H9zieCv+a4bUGrAjnO6qNaSTq4mhyaV6VZpq2UFVCLB8VrHF4xLWVsmMVN3nls5FIyqeD5Kgmh9yOoZ+69h9xgGAj+6kWt8g1egYhSj7Fct2YOxiIVJ9oqxC9Uk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TLrXh5UD; 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="TLrXh5UD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A044C4CEEB; Sun, 27 Jul 2025 18:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641393; bh=GnTr/aETvE3ymkWSwJqsiI1LzQh8lephKpOFz0kWFvQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TLrXh5UDZA4XJYXEE6zp7lNBsoyDtoC8OBgGwIzslIiLm/Z5Cwkvhu/dKthDpKuL+ IvGLzxWzuYf+1niORS3o+roPvm8qsRgK36fRkzD8NQgfOJgpu0uHKPVZ8VqkKWyUkL m4fLbgNlrNLY9S4HOxkryiR79kE6a9e4Cb0jvkdlm6GmScZsUYXQhbz626+UWT4YpE wLTmdeRpm3etOYd5K2hfGdKhkMx1yTSDuImTBXzIZXy2JsLj/AEjTri4qAYbIoV+Pu wHOxEtzvOR9V7onPmKs6ctdiZKB2QBpfnsGmivE5nliZu0NphOC7ugjRR2hailJe4l z9w5AMqeeCUyA== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:16 -0400 Subject: [PATCH v3 6/8] nfsd: fix SETATTR updates for 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: <20250727-nfsd-testing-v3-6-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5835; i=jlayton@kernel.org; h=from:subject:message-id; bh=GnTr/aETvE3ymkWSwJqsiI1LzQh8lephKpOFz0kWFvQ=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGmJppesOJnJCdFhrt736m20hLkU7RtpH+nc 3MaARWwfF6JAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpgAKCRAADmhBGVaC FWV1EAC40Zmm3SolVYnz2tGA5suFjSp6VKqhOjLYzFQKZSQRHqZxt7wfqjLRBC85/Mz3Qbth2Mf mauWe6AKGzcgoSPAhYyunxyNd/BNc6rMyfelFqnnDhtB8pzyjUHMCHxt1miRT1Av2WVKw3PRNMR saNa5dhJv1v0zazlVHiqFWbfKrxPqECkPcNtzSy6fjzroqNLYIcr0LYBWrJdjOxKjSMGrfq4bSq 0yLZpCn1ZUBm1YY9YoXPQsWX6Vcnm3l4eIUxJ+eSRDxnznmxIixyEOQ245cYuyarpAzYna51U9N X19iW6aOGM4Bqmkh6HVhF1lFm284fCMUU7+NKXM6diJG3E4pNvGmY+0XuIMLC1Nqtb1Z5mw58o7 aF+et9pslS8WIiS9Kwso6Hh62ZHpP1DewToAuA6hv0wLInEwHjbsEHKmHCiZSDa+1aSkkN1+1Gm Ymia4JoQBaHY8JcLXc/ND/ub9u9o+t5+pavdnDCpwyMQSi/KjSWfRDkjhaN6y3C82NQVHK5T5Wz 4vJtALPNudxhHk1gpQsYmqRGcYu1O1ETDwJqbfEKdn7pQHMYZ6225qKbVykNjfnZQwI7WdebRw/ fDrUc/OQUoJRfLWca7eG0W2MfdGcLQarCa9R83qIBFTnIUzoBThhAp7r7wFsPd4KvmJCzydi0Ie LzKsuO3fBQMeYKQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 SETATTRs containing delegated timestamp updates are currently not being vetted properly. Since we no longer need to compare the timestamps vs. the current timestamps, move the vetting of delegated timestamps wholly into nfsd. Rename the set_cb_time() helper to nfsd4_vet_deleg_time(), and make it non-static. Add a new vet_deleg_attrs() helper that is called from nfsd4_setattr that uses nfsd4_vet_deleg_time() to properly validate the all the timestamps. If the validation indicates that the update should be skipped, unset the appropriate flags in ia_valid. Fixes: 7e13f4f8d27d ("nfsd: handle delegated timestamps in SETATTR") Signed-off-by: Jeff Layton --- fs/nfsd/nfs4proc.c | 31 ++++++++++++++++++++++++++++++- fs/nfsd/nfs4state.c | 24 +++++++++++------------- fs/nfsd/state.h | 3 +++ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 7043fc475458d3b602010b47f489a3caba85e3ca..aacd912a5fbe29ba5ccac206d13= 243308f36b7fa 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1133,6 +1133,33 @@ nfsd4_secinfo_no_name_release(union nfsd4_op_u *u) exp_put(u->secinfo_no_name.sin_exp); } =20 +/* + * Validate that the requested timestamps are within the acceptable range.= If + * timestamp appears to be in the future, then it will be clamped to + * current_time(). + */ +static void +vet_deleg_attrs(struct nfsd4_setattr *setattr, struct nfs4_delegation *dp) +{ + struct timespec64 now =3D current_time(dp->dl_stid.sc_file->fi_inode); + struct iattr *iattr =3D &setattr->sa_iattr; + + if ((setattr->sa_bmval[2] & FATTR4_WORD2_TIME_DELEG_ACCESS) && + !nfsd4_vet_deleg_time(&iattr->ia_atime, &dp->dl_atime, &now)) + iattr->ia_valid &=3D ~(ATTR_ATIME | ATTR_ATIME_SET); + + if (setattr->sa_bmval[2] & FATTR4_WORD2_TIME_DELEG_MODIFY) { + if (nfsd4_vet_deleg_time(&iattr->ia_mtime, &dp->dl_mtime, &now)) { + iattr->ia_ctime =3D iattr->ia_mtime; + if (!nfsd4_vet_deleg_time(&iattr->ia_ctime, &dp->dl_ctime, &now)) + iattr->ia_valid &=3D ~(ATTR_CTIME | ATTR_CTIME_SET); + } else { + iattr->ia_valid &=3D ~(ATTR_CTIME | ATTR_CTIME_SET | + ATTR_MTIME | ATTR_MTIME_SET); + } + } +} + static __be32 nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) @@ -1170,8 +1197,10 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_c= ompound_state *cstate, struct nfs4_delegation *dp =3D delegstateid(st); =20 /* Only for *_ATTRS_DELEG flavors */ - if (deleg_attrs_deleg(dp->dl_type)) + if (deleg_attrs_deleg(dp->dl_type)) { + vet_deleg_attrs(setattr, dp); status =3D nfs_ok; + } } } if (st) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8737b721daf3433bab46065e751175a4dcdd1c89..f2fd0cbe256b9519eaa5cb0cc18= 872e08020edd3 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -9135,25 +9135,25 @@ nfsd4_get_writestateid(struct nfsd4_compound_state = *cstate, } =20 /** - * set_cb_time - vet and set the timespec for a cb_getattr update - * @cb: timestamp from the CB_GETATTR response + * nfsd4_vet_deleg_time - vet and set the timespec for a delegated timesta= mp update + * @req: timestamp from the client * @orig: original timestamp in the inode * @now: current time * - * Given a timestamp in a CB_GETATTR response, check it against the + * Given a timestamp from the client response, check it against the * current timestamp in the inode and the current time. Returns true * if the inode's timestamp needs to be updated, and false otherwise. - * @cb may also be changed if the timestamp needs to be clamped. + * @req may also be changed if the timestamp needs to be clamped. */ -static bool set_cb_time(struct timespec64 *cb, const struct timespec64 *or= ig, - const struct timespec64 *now) +bool nfsd4_vet_deleg_time(struct timespec64 *req, const struct timespec64 = *orig, + const struct timespec64 *now) { =20 /* * "When the time presented is before the original time, then the * update is ignored." Also no need to update if there is no change. */ - if (timespec64_compare(cb, orig) <=3D 0) + if (timespec64_compare(req, orig) <=3D 0) return false; =20 /* @@ -9161,10 +9161,8 @@ static bool set_cb_time(struct timespec64 *cb, const= struct timespec64 *orig, * clamp the new time to the current time, or it may * return NFS4ERR_DELAY to the client, allowing it to retry." */ - if (timespec64_compare(cb, now) > 0) { - /* clamp it */ - *cb =3D *now; - } + if (timespec64_compare(req, now) > 0) + *req =3D *now; =20 return true; } @@ -9184,10 +9182,10 @@ static int cb_getattr_update_times(struct dentry *d= entry, struct nfs4_delegation attrs.ia_atime =3D ncf->ncf_cb_atime; attrs.ia_mtime =3D ncf->ncf_cb_mtime; =20 - if (set_cb_time(&attrs.ia_atime, &atime, &now)) + if (nfsd4_vet_deleg_time(&attrs.ia_atime, &atime, &now)) attrs.ia_valid |=3D ATTR_ATIME | ATTR_ATIME_SET; =20 - if (set_cb_time(&attrs.ia_mtime, &mtime, &now)) { + if (nfsd4_vet_deleg_time(&attrs.ia_mtime, &mtime, &now)) { attrs.ia_valid |=3D ATTR_CTIME | ATTR_CTIME_SET | ATTR_MTIME | ATTR_MTIME_SET; attrs.ia_ctime =3D attrs.ia_mtime; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index ce7c0d129ba338e1269ed163266e1ee192cd02c5..bf9436cdb93c5dd5502ecf83433= ea311e3678711 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -247,6 +247,9 @@ static inline bool deleg_attrs_deleg(u32 dl_type) dl_type =3D=3D OPEN_DELEGATE_WRITE_ATTRS_DELEG; } =20 +bool nfsd4_vet_deleg_time(struct timespec64 *cb, const struct timespec64 *= orig, + const struct timespec64 *now); + #define cb_to_delegation(cb) \ container_of(cb, struct nfs4_delegation, dl_recall) =20 --=20 2.50.1 From nobody Mon Oct 6 01:26:47 2025 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 BC0552417F0; Sun, 27 Jul 2025 18:36:35 +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=1753641395; cv=none; b=H35MMn6r8w0iur8Q2SrVG5ChZDB9NHkxzHNTOaq2aKrb4S+AWlu+1qfswOkINEBQfv4l6CTEWU3PFQo3i4KDc0IfoYZk5eqq2AUYNpWMIoXx7XVMPTSow8NbNsZ44XguGAC88uy4VdkhXhNUTi2i/EYcbSnaFIQ6RvhsobghCz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641395; c=relaxed/simple; bh=+rAzc5qvjz0FCD5vq5bKYPfZ4fICvaRMvsO7vDhd3jo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FDNGJvPyG5zVdZxBiuRMKaxVP9V6eNUzsXtIYzGxuFFX1or7XjpMx8Bo9PO9+3gWNoWH2rRqdin//ZB5B9jQKzuWTH09AOfcccfCV36179c84rA2RqNoX7dAnMWX7sXe7wtwO661EbtduXTU69eU6xwbSCTaKXH1dYbB03QQAuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j//j3UDY; 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="j//j3UDY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA525C4CEEF; Sun, 27 Jul 2025 18:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641395; bh=+rAzc5qvjz0FCD5vq5bKYPfZ4fICvaRMvsO7vDhd3jo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=j//j3UDYEBlIQkfjzSU5NDidUYnRXvyrCfJ6MVCU3Mp2YMWPv3BQoU/4+M28vBago 9DoPerhN1Z9nddbfogYC3RNdZMW+GTpkolJliGrTqjoQ0GUWFjR1BY//9IaY6pHYWX pQg/fYjS9LZABAJ7aGn0/eqyW7DOa91O2AZCDQJTorMdKpg0aA59c6aA2G9/fNo2Fu q332bFm67RRyuVnixm+IDQxAnCNpLcTVyT6YIW9DQadxgGayK+bZDqsnEQR5+YpETP +2xrVAbiCtPehF1pKHOECBVejuj3rliB3ViZz5ZugSUoyRa8m4tFcwNu3qTI/oFVwV bY5RhskdJauHQ== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:17 -0400 Subject: [PATCH v3 7/8] nfsd: fix timestamp updates in CB_GETATTR 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: <20250727-nfsd-testing-v3-7-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1814; i=jlayton@kernel.org; h=from:subject:message-id; bh=+rAzc5qvjz0FCD5vq5bKYPfZ4fICvaRMvsO7vDhd3jo=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGmuzw2tRrbXWdr3BilHRtPPJ+U2fZLJoVIn er1Rg2sIjuJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpgAKCRAADmhBGVaC FSVREACkTRoFThDlr5JQHtbmZEKJP3OfOVnEnDwD3H0VUsYJ98CcOXFEtDd+fj+EvH+xAsHLuij txpxtH7/6LkRxL0gEFU1v2iyebIttThcrg9hBMt2CdbNv5bfl+ytlGqjif1dLgvi4HAMiBSAh8u qscL8XWBOIdr8k+A+eUEUTfybskWlF1noISK0nnsLGqrkZhUzsTxedBvNK5lAaDrfnoSArkB5EQ /wlhiEaGaPZTeSxNxksWw+E+8q+pvOLXv1cz4GlrfNSUO52gfanACHcpcRQW0RtGAfxFsqFJew3 F56DG5Pg4SmmMwJXEOfUUAyuh+JCQpg9E/zf4WBRUYGZM58sISnZ+4dDj1MqHg/eQs6+7+j2INp 0PxwH9xPjS865tqF0fJ990UD3sOsL+X2VGtJTy9eqGa84vwM2ram1ZmOev6rrhfkx1RbdMemgF6 zHuGjOoJ/MBtapzd0As/U25wzpOVc3/nGfaWjjEKHQTMPUnk/MaxvNRE1BsJABIacO5q7+sCydM 0Wt6HYyzeW3PiNf7JY/68RHgSJ/KupwM5PZ9O6s60zODcz5l//OhhJ8fetbAh5ZrFStQJU63ZVJ nuYYHr/znrOh2NkhqQW96uUmSPQnk5D3GLD69L1Y7NKI7cwDxMj/VmHkCIFNtXKhTuBc/JhZTmP 0fAbCIbAL/70naQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 When updating the local timestamps from CB_GETATTR, the updated values are not being properly vetted. Compare the update times vs. the saved times in the delegation rather than the current times in the inode. Also, ensure that the ctime is properly vetted vs. its original value. Fixes: 6ae30d6eb26b ("nfsd: add support for delegated timestamps") Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f2fd0cbe256b9519eaa5cb0cc18872e08020edd3..205ee8cc6fa2b9f74d08f7938b3= 23d03bdf8286c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -9175,20 +9175,19 @@ static int cb_getattr_update_times(struct dentry *d= entry, struct nfs4_delegation int ret; =20 if (deleg_attrs_deleg(dp->dl_type)) { - struct timespec64 atime =3D inode_get_atime(inode); - struct timespec64 mtime =3D inode_get_mtime(inode); struct timespec64 now =3D current_time(inode); =20 attrs.ia_atime =3D ncf->ncf_cb_atime; attrs.ia_mtime =3D ncf->ncf_cb_mtime; =20 - if (nfsd4_vet_deleg_time(&attrs.ia_atime, &atime, &now)) + if (nfsd4_vet_deleg_time(&attrs.ia_atime, &dp->dl_atime, &now)) attrs.ia_valid |=3D ATTR_ATIME | ATTR_ATIME_SET; =20 - if (nfsd4_vet_deleg_time(&attrs.ia_mtime, &mtime, &now)) { - attrs.ia_valid |=3D ATTR_CTIME | ATTR_CTIME_SET | - ATTR_MTIME | ATTR_MTIME_SET; + if (nfsd4_vet_deleg_time(&attrs.ia_mtime, &dp->dl_mtime, &now)) { + attrs.ia_valid |=3D ATTR_MTIME | ATTR_MTIME_SET; attrs.ia_ctime =3D attrs.ia_mtime; + if (nfsd4_vet_deleg_time(&attrs.ia_ctime, &dp->dl_ctime, &now)) + attrs.ia_valid |=3D ATTR_CTIME | ATTR_CTIME_SET; } } else { attrs.ia_valid |=3D ATTR_MTIME | ATTR_CTIME; --=20 2.50.1 From nobody Mon Oct 6 01:26:47 2025 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 51FAD2459FF; Sun, 27 Jul 2025 18:36:37 +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=1753641398; cv=none; b=svau0CNObDTosT2iuTXUhtbjFt/hMkQGIRr3NtD3trE/F+YrPgv5qeCg7D6o2Bj+RTTanmZe29XJAe7p7BabqfPCEUZJiqxi6+wVitvuetONDCppZA3k9BKIzcy+9irS+8QwgcOQytMBqRl2+if8Hd067/IMp1XD9jzkqPLQoT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753641398; c=relaxed/simple; bh=NtCz+vb0FJ2RTT3UYGTBXP803cbE2/PCFHkn1707tww=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JwR22secm1d8n4NcHeRAoIKWBpk8g9BNZ8RjUF51wnSSNmZLchV44lLPEn/axRbCbS895heupjzo/WPrc2btSC8cieszRN6NrYoB1JFehK/+UH4hRds9rE8C5tLxldoKTySHuKD146bzWVkT4MbeQF4l97obFmEKZj2/Cbuy3zo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hJxI2cuI; 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="hJxI2cuI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 868EFC4CEF7; Sun, 27 Jul 2025 18:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753641396; bh=NtCz+vb0FJ2RTT3UYGTBXP803cbE2/PCFHkn1707tww=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hJxI2cuI3DH1/GIEw48+EX0DquTB2rcTDTVYd2LzNqLQvaSW5csGhfD5SJLpYDR2X qqNQt+hr1nBKBz+m44WjEaf1VTrUZ8MbHj+KxfLu7YlXmG0KN/AgOk3MEX+bJRsJJX o2FpekAQvWSOMtQlm2CPoMDCunj4nwaBwDcBlek2WDwtNHPlpoUyBbBx+laysnAVPO BcSD7qDV2zAfOgnf0ySFr7tAcektGQ+GDKsefiiF4iseB1O2QfpU38V0/8hMaB6iis 9tIPm3u28M8DzhHlFvVPiFVAZWfoEAEoqeuVfjY9xMIS/H6iCcSlLcGZjNQPk6LZGc J7Uxrbd/w6OEg== From: Jeff Layton Date: Sun, 27 Jul 2025 14:36:18 -0400 Subject: [PATCH v3 8/8] vfs: remove inode_set_ctime_deleg() 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: <20250727-nfsd-testing-v3-8-8dc2aafb166d@kernel.org> References: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> In-Reply-To: <20250727-nfsd-testing-v3-0-8dc2aafb166d@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: Trond Myklebust , Anna Schumaker , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5364; i=jlayton@kernel.org; h=from:subject:message-id; bh=NtCz+vb0FJ2RTT3UYGTBXP803cbE2/PCFHkn1707tww=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBohnGmVnNPJR2xq+uhg+XDinapempnHwq02CRdG G7IljsE3aSJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaIZxpgAKCRAADmhBGVaC FcRFD/9zexmP3yDw4Z14LO6Gzhk/HVFHrShGljNob9av+LPXX4l29eWRPkIE502/U1T3PgE30Fy DQap8/lMB7waZf7pZRym1xDH28IWwu2yVBpEnUJr3euwjvaodNxoMOXfwFeexHC8S1dFrrkSUN6 CpuO3q5dwnDnX2JLg08xNazziE5NClFL8ok13b2d0IOD8UNu+ptYwIjl//TdJau9mFmOaqjXHG2 RcxQwUwkmvZjLWJ2THHEYi03qz21cbGxiVQ5yf+OgiYmWX8szJVJhwsRYeNc/YanxGvm/jY1sIT Qz0i9/gQZXkOHdp2jT9FNu9QOLHv3aX6SPPb6Oc7u8TzkcmwpCvWAV5QBTceYCO9dUTE1fOxaOR RPOviTRbW4jFGlTp+yGTlG6+KLRxIdeOdmxleyygswAig2ZnNyiiMhMrxiZjuE1u632mUztcuZZ Oyb589tos4GZu6vKnpeXr6ldd9kdJX4ZwMnWRtW05azDfM2xOCpWE/lbqc3fa6IuZ0pJ7csA0gz O9s33vH/haXv6ernDjQRyMPYTiCQ8jrIBOgpD4cQ3d0lDpGUuasCqpP1ivApbY33SJR9GJykVyx sbeSM/p5DIHapuoUUjXBr5dc8U2RIYyxXayIoklapVPn/fCbvLnvtLB6AYeWarSU7/wjICKybvX wS+j3T7WEEGRx0g== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Now that nfsd is vetting the timestamps internally, there is no need for this function. If ATTR_DELEG is set, then skip the multigrain update and set what was requested. Signed-off-by: Jeff Layton --- fs/attr.c | 19 +++----------- fs/inode.c | 73 --------------------------------------------------= ---- include/linux/fs.h | 2 -- 3 files changed, 4 insertions(+), 90 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index f0dabd2985989d283a931536a5fc53eda366b373..e75f06b760015640bafd596457c= d14c746c7e272 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -287,14 +287,7 @@ static void setattr_copy_mgtime(struct inode *inode, c= onst struct iattr *attr) struct timespec64 now; =20 if (ia_valid & ATTR_CTIME) { - /* - * In the case of an update for a write delegation, we must respect - * the value in ia_ctime and not use the current time. - */ - if (ia_valid & ATTR_DELEG) - now =3D inode_set_ctime_deleg(inode, attr->ia_ctime); - else - now =3D inode_set_ctime_current(inode); + now =3D inode_set_ctime_current(inode); } else { /* If ATTR_CTIME isn't set, then ATTR_MTIME shouldn't be either. */ WARN_ON_ONCE(ia_valid & ATTR_MTIME); @@ -352,19 +345,15 @@ void setattr_copy(struct mnt_idmap *idmap, struct ino= de *inode, inode->i_mode =3D mode; } =20 - if (is_mgtime(inode)) + if (!(ia_valid & ATTR_DELEG) && is_mgtime(inode)) return setattr_copy_mgtime(inode, attr); =20 if (ia_valid & ATTR_ATIME) inode_set_atime_to_ts(inode, attr->ia_atime); if (ia_valid & ATTR_MTIME) inode_set_mtime_to_ts(inode, attr->ia_mtime); - if (ia_valid & ATTR_CTIME) { - if (ia_valid & ATTR_DELEG) - inode_set_ctime_deleg(inode, attr->ia_ctime); - else - inode_set_ctime_to_ts(inode, attr->ia_ctime); - } + if (ia_valid & ATTR_CTIME) + inode_set_ctime_to_ts(inode, attr->ia_ctime); } EXPORT_SYMBOL(setattr_copy); =20 diff --git a/fs/inode.c b/fs/inode.c index 99318b157a9a13b3dd8dad0f5f90951f08ef64de..f45054fe48b8a0339e60fd2aa17= daaad5a7957e7 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2783,79 +2783,6 @@ struct timespec64 inode_set_ctime_current(struct ino= de *inode) } EXPORT_SYMBOL(inode_set_ctime_current); =20 -/** - * inode_set_ctime_deleg - try to update the ctime on a delegated inode - * @inode: inode to update - * @update: timespec64 to set the ctime - * - * Attempt to atomically update the ctime on behalf of a delegation holder. - * - * The nfs server can call back the holder of a delegation to get updated - * inode attributes, including the mtime. When updating the mtime, update - * the ctime to a value at least equal to that. - * - * This can race with concurrent updates to the inode, in which - * case the update is skipped. - * - * Note that this works even when multigrain timestamps are not enabled, - * so it is used in either case. - */ -struct timespec64 inode_set_ctime_deleg(struct inode *inode, struct timesp= ec64 update) -{ - struct timespec64 now, cur_ts; - u32 cur, old; - - /* pairs with try_cmpxchg below */ - cur =3D smp_load_acquire(&inode->i_ctime_nsec); - cur_ts.tv_nsec =3D cur & ~I_CTIME_QUERIED; - cur_ts.tv_sec =3D inode->i_ctime_sec; - - /* If the update is older than the existing value, skip it. */ - if (timespec64_compare(&update, &cur_ts) <=3D 0) - return cur_ts; - - ktime_get_coarse_real_ts64_mg(&now); - - /* Clamp the update to "now" if it's in the future */ - if (timespec64_compare(&update, &now) > 0) - update =3D now; - - update =3D timestamp_truncate(update, inode); - - /* No need to update if the values are already the same */ - if (timespec64_equal(&update, &cur_ts)) - return cur_ts; - - /* - * Try to swap the nsec value into place. If it fails, that means - * it raced with an update due to a write or similar activity. That - * stamp takes precedence, so just skip the update. - */ -retry: - old =3D cur; - if (try_cmpxchg(&inode->i_ctime_nsec, &cur, update.tv_nsec)) { - inode->i_ctime_sec =3D update.tv_sec; - mgtime_counter_inc(mg_ctime_swaps); - return update; - } - - /* - * Was the change due to another task marking the old ctime QUERIED? - * - * If so, then retry the swap. This can only happen once since - * the only way to clear I_CTIME_QUERIED is to stamp the inode - * with a new ctime. - */ - if (!(old & I_CTIME_QUERIED) && (cur =3D=3D (old | I_CTIME_QUERIED))) - goto retry; - - /* Otherwise, it was a new timestamp. */ - cur_ts.tv_sec =3D inode->i_ctime_sec; - cur_ts.tv_nsec =3D cur & ~I_CTIME_QUERIED; - return cur_ts; -} -EXPORT_SYMBOL(inode_set_ctime_deleg); - /** * in_group_or_capable - check whether caller is CAP_FSETID privileged * @idmap: idmap of the mount @inode was found from diff --git a/include/linux/fs.h b/include/linux/fs.h index f18f45e88545c39716b917b1378fb7248367b41d..08f2d813dd40b5dd4fe07d9636e= 94252915d6235 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1657,8 +1657,6 @@ static inline bool fsuidgid_has_mapping(struct super_= block *sb, =20 struct timespec64 current_time(struct inode *inode); struct timespec64 inode_set_ctime_current(struct inode *inode); -struct timespec64 inode_set_ctime_deleg(struct inode *inode, - struct timespec64 update); =20 static inline time64_t inode_get_atime_sec(const struct inode *inode) { --=20 2.50.1