From nobody Fri Dec 27 11:25:16 2024 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 BFDEA19E836; Mon, 9 Dec 2024 21:14:16 +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=1733778856; cv=none; b=shBTL9iYCeCscfY1vB8Xsd7MVZoErUGLX/X1OwKGyG79j+gYsPvNvhxim6oOF5co9ENW2mJAw+/sq8ShO6gKkfJ+T37acUL95rvLaaZgW/aF+uzDRLN0k7VTwy7rMMWODKYAfaxOhsRG3S9Rh4siUyTYBwsnA/liTZx5AbhmRhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778856; c=relaxed/simple; bh=qRO220jVJDpFhT0mNgCOk0gbt3XROXVxU97ICxTeQCs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AnbfnCcxwlCba3tKuYd/wo09J+t+0X7FtzLmM3bH+Dr6Ksmork2OCeCe2McrNNhRz6imzE6iZp6jM2yER7Sjd02EjUeufZBVnZ8Hh4Dkci8gxP+gFR5K8XpYYgHEdDaLG0mQxu7iLl6pPutjbjYZR2PmDpn8SrJEJ5tHYsGyG2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DskQUNlN; 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="DskQUNlN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BA04C4CEE0; Mon, 9 Dec 2024 21:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778856; bh=qRO220jVJDpFhT0mNgCOk0gbt3XROXVxU97ICxTeQCs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DskQUNlN1mh85QKNkc6veYrTVI5Ph6QfAFy9HgxTE5w+2xxuaK5Vg5+qcBe45K3kg wWNY8IxBpllOWCVDFGpd/2/fFs7N7LQQ0T/4u26AlHsI/8MBMJJ5P595/hiMv+iejL dqTHVRtSLOgr5Eh62AeFEp5gyv1gBGvAZ4+RVLUk9TziuOYYqpJyDJswy/BwBRxp0M YfUeDJut1SZl1j+RDC4blQj0ZTQvFS7oV8GG7QV22hhAS4dVxdo+MR698F9wIeExYI WsYdeogQb4KS1YR/OzSPoYHFkRkSgXRABB4FVOKS4Zhd4t38Ayis1sXtYHB0C4woM3 LZUlOhJS3Kufg== From: Jeff Layton Date: Mon, 09 Dec 2024 16:13:53 -0500 Subject: [PATCH v5 01/10] nfsd: fix handling of delegated change attr 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: <20241209-delstid-v5-1-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3275; i=jlayton@kernel.org; h=from:subject:message-id; bh=qRO220jVJDpFhT0mNgCOk0gbt3XROXVxU97ICxTeQCs=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12k69ReI8d+0F0XPYrnqoW/OJc2dTaG1nUrP kmxaevKRKWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpAAKCRAADmhBGVaC Fa2MEACPpDFkn4+h6Ba7N3BEU8kRdEr0TZd004E3F839c2Keu8BWc2t3tgwdjEs410pz9nKXld7 BnWkFJu3iMOOyfDfrz3qEcvd5CW2K/8JS6JLX9zp9YwlPYM5UH2MM7cBvTObUJYFuNMQZI6isqd mc622dC0nnoWUkvimq3xuPFkklV/uBSASqdxfLQkPTOTcdbbn/aQEFTCugiWWgqbo3NPKTEDvtt h6+cv3AQeyUlCEA3f0aNLcn5iUCMNdobt6Enlnmid9Geo3dR2wnOdi3VMw+fPa5wtZqapeblrsM 4ZBN+O2/+MSUsp++/HYPC1x7R1atUB+iv+Opy9X1zc6X3nZuIISxSfo5yAFcQeW+WFjp92+MoC/ +OXb2rJ/JB4q3qy5sxABRiHa08FxtKN5WInDERsstPuvEG5XXm/67OHdeaI2Eh4KpHxUGQLFNXB 7uBm2MEWnZyTFr3L5LFqckJVovU0hNezoCN4hyb20xFxwWWqjcCdPqAoq7ciN2/K4y7RVYGPOYs kQmvQi/cS8o4P50iNHSwSgtJeOuTGuq7bse2U63DgC+EwFz0A+XhBlUa8jzP6Ckf79sGvto6scc +KQC+14knTS3DowcYsUdUM775/8qmuoxg65h5moXX2LGYgNhGIpMB0N1Rxip4oyTm2QgmSd3NmM q6sNo0QtIPlKbAw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 RFC8881, section 10.4.3 has some specific guidance as to how the delegated change attribute should be handled. We currently don't follow that guidance properly. In particular, when the file is modified, the server always reports the initial change attribute + 1. Section 10.4.3 however indicates that it should be incremented on every GETATTR request from other clients. Only request the change attribute until the file has been modified. If there is an outstanding delegation, then increment the cached change attribute on every GETATTR. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 8 +++++--- fs/nfsd/nfs4xdr.c | 15 +++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 3877b53e429fd89899d7dc35086bee8bda6eed07..25acb8624b854f5d0d184efec66= 0e1f72cad8885 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -361,12 +361,14 @@ static void encode_cb_getattr4args(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr= *hdr, struct nfs4_cb_fattr *fattr) { - struct nfs4_delegation *dp =3D - container_of(fattr, struct nfs4_delegation, dl_cb_fattr); + struct nfs4_delegation *dp =3D container_of(fattr, struct nfs4_delegation= , dl_cb_fattr); struct knfsd_fh *fh =3D &dp->dl_stid.sc_file->fi_fhandle; + struct nfs4_cb_fattr *ncf =3D &dp->dl_cb_fattr; u32 bmap[1]; =20 - bmap[0] =3D FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE; + bmap[0] =3D FATTR4_WORD0_SIZE; + if (!ncf->ncf_file_modified) + bmap[0] |=3D FATTR4_WORD0_CHANGE; =20 encode_nfs_cb_opnum4(xdr, OP_CB_GETATTR); encode_nfs_fh4(xdr, fh); diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 53fac037611c05ff8ba2618f9e324a9cb54c3890..c8e8d3f0dff4bb5288186369aad= 821906e684db7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2919,6 +2919,7 @@ struct nfsd4_fattr_args { struct kstat stat; struct kstatfs statfs; struct nfs4_acl *acl; + u64 change_attr; #ifdef CONFIG_NFSD_V4_SECURITY_LABEL void *context; int contextlen; @@ -3018,7 +3019,6 @@ static __be32 nfsd4_encode_fattr4_change(struct xdr_s= tream *xdr, const struct nfsd4_fattr_args *args) { const struct svc_export *exp =3D args->exp; - u64 c; =20 if (unlikely(exp->ex_flags & NFSEXP_V4ROOT)) { u32 flush_time =3D convert_to_wallclock(exp->cd->flush_time); @@ -3029,9 +3029,7 @@ static __be32 nfsd4_encode_fattr4_change(struct xdr_s= tream *xdr, return nfserr_resource; return nfs_ok; } - - c =3D nfsd4_change_attribute(&args->stat); - return nfsd4_encode_changeid4(xdr, c); + return nfsd4_encode_changeid4(xdr, args->change_attr); } =20 static __be32 nfsd4_encode_fattr4_size(struct xdr_stream *xdr, @@ -3556,11 +3554,16 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct = xdr_stream *xdr, if (dp) { struct nfs4_cb_fattr *ncf =3D &dp->dl_cb_fattr; =20 - if (ncf->ncf_file_modified) + if (ncf->ncf_file_modified) { + ++ncf->ncf_initial_cinfo; args.stat.size =3D ncf->ncf_cur_fsize; - + } + args.change_attr =3D ncf->ncf_initial_cinfo; nfs4_put_stid(&dp->dl_stid); + } else { + args.change_attr =3D nfsd4_change_attribute(&args.stat); } + if (err) goto out_nfserr; =20 --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 4174919F436; Mon, 9 Dec 2024 21:14:17 +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=1733778860; cv=none; b=l6vfpYQRv0p9rPI2kxE5S6X2/XqxNweI4Pqu0tj5VubbFoTA7O1WioGO8Gf3IT7Zebj89aMKaIzbNcJWZE+rtrWtbT3qmUUcwX07o8O9Pzhr8u0sSq/5+oUQrbMYWMtm4/ALzIezgmI7+63Zgd0kBub63f3Yg6MOTjgK+4GA+DQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778860; c=relaxed/simple; bh=k6D/xznXL7Ujt/DhjQvDIYN/Z7rO1SKO/5a0I6u3VX8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UrmXgB/UrNCovTnmDIyfWIOzrz2po1sl5hj+qs0qc3bqKzyCx1f4gUr9Pl69abh38eyDRMxUZEItHpxoRCk8bs56ur1ynBD7VnlcE5d8qPiNSCCBwza/J8CBLoY49NgjkA5emi+czS+8v5Lps+4fDc6AA3TxNo3iUW6HIFcgeb8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XhAzCfNU; 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="XhAzCfNU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7B8FC4CEE1; Mon, 9 Dec 2024 21:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778857; bh=k6D/xznXL7Ujt/DhjQvDIYN/Z7rO1SKO/5a0I6u3VX8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XhAzCfNUEUeyreTNWpUbAudbrbeNVRy+7Bkia3upOonrfFfFyhSXLIIp3UWniLIWO VyyW4EDZdwx2/WVII6J2YFWKPWu35ZhPkDxvU9jub1XJPaL1UKGJwnxrlz6ADTT8PZ y95Uo1dSMz4b4oWVXgmFuWEobvUMTwakAhKmJsIUhC+Xr9s6y9B4tjAS/hm264U1Bs /RIxkBmrow0RMwwZdhYFRV4wExTsoTA6KyXgmZ+9/TuGoV6zi/jFUG95BwCsSvdYxk uW27cHusEVgFDBNzjlPBlxfFpfKmFSMwde6rYJ8l/N/zbnXm8RLG50XeBJm1c2muRc WK93y59lSjjow== From: Jeff Layton Date: Mon, 09 Dec 2024 16:13:54 -0500 Subject: [PATCH v5 02/10] nfs_common: make include/linux/nfs4.h include generated nfs4_1.h 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: <20241209-delstid-v5-2-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=21224; i=jlayton@kernel.org; h=from:subject:message-id; bh=k6D/xznXL7Ujt/DhjQvDIYN/Z7rO1SKO/5a0I6u3VX8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12ky2SuXGKtb0z2k0PhR+3pV94Rz85A4za0r YU+RKR2kUuJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpAAKCRAADmhBGVaC FfHQEACt+EyAcoKcxkIiXn/2VRBuiY7wjWPx0T2ekWzH/2J09SVdqWPpZS9G8puEvF1FcXNJyPU QsAheG8EOPEuyMIlt0MbGAv1ra3gdLToAvQljBmer9xhMCLd2Q89p58imaYJTnhAXpfc/XKEiq2 Ft5NXZEBOKloE3OUiI5YaLWHi0jLJmXEzSAUcTF6a/N5COkOKRZu8CFSvOXcak+kW/TUq3ljGF2 i9ruigEPA+1XNXxM98EevKYEFtbl3zzAKMIkvWYJdAr7fXgXuVnoZILe/yKTUYXI7u98sumA3/t SyjfAJEXoYXooLIexe3ZKtFhFx+wOsomVELAfyHIT7KbHGSmXFrP3Fe2ueMi02homuyvRIdBo9x 6JMfPd+/OOUOmZVtUoqBULCRhlPtLEfBCAUW48C5CClyWJ3V86IGA5ujRRgFYFj548QJ5c2c/wx UNcvbRLERXofFqUHHVVV4kKR6Uvm5LwDmIHboyIUaCCEXOl8zKSSgiaTm3DmwjGjwfKQZJiuLy/ iYrdkX7w1ZyIl6Y/YOWz1pKgRXgdYpOjhNkhH7pOIpm+mFWqLwqxyzs3ZAKTxqKQF//W+qQF7uW rtWu4sh4aQICADqI+1Qk6HM3ulHGXr7QIuTSQGCBYrYFVVxyN/vKBMsKc+8RqrVWui5SgRkaHan Zq21kCsn9RO6PDw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 In the long run, the NFS development community intends to autogenerate a lot of the XDR handling code. Both the NFS client and server include "include/linux/nfs4.hi". That file was hand-rolled, and some of the symbols in it conflict with the autogenerated symbols. Add a small nfs4_1.x to Documentation that currently just has the necessary definitions for the delstid draft, and generate the relevant header and source files. Make include/linux/nfs4.h include the generated include/linux/sunrpc/xdrgen/nfs4_1.h and remove the conflicting definitions from it and nfs_xdr.h. Signed-off-by: Jeff Layton --- Documentation/sunrpc/xdr/nfs4_1.x | 166 ++++++++++++++++++++++++ fs/nfsd/Makefile | 16 ++- fs/nfsd/nfs4xdr_gen.c | 239 +++++++++++++++++++++++++++++++= ++++ fs/nfsd/nfs4xdr_gen.h | 25 ++++ include/linux/nfs4.h | 7 +- include/linux/nfs_xdr.h | 5 - include/linux/sunrpc/xdrgen/nfs4_1.h | 124 ++++++++++++++++++ 7 files changed, 570 insertions(+), 12 deletions(-) diff --git a/Documentation/sunrpc/xdr/nfs4_1.x b/Documentation/sunrpc/xdr/n= fs4_1.x new file mode 100644 index 0000000000000000000000000000000000000000..fc37d1ecba0f40e46c6986df90d= 07a0e6e6ae9b2 --- /dev/null +++ b/Documentation/sunrpc/xdr/nfs4_1.x @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2010 IETF Trust and the persons identified + * as the document authors. All rights reserved. + * + * The document authors are identified in RFC 3530 and + * RFC 5661. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * - Neither the name of Internet Society, IETF or IETF + * Trust, nor the names of specific contributors, may be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +pragma header nfs4; + +/* + * Basic typedefs for RFC 1832 data type definitions + */ +typedef hyper int64_t; +typedef unsigned int uint32_t; + +/* + * Basic data types + */ +typedef uint32_t bitmap4<>; + +/* + * Timeval + */ +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; + + +/* + * The following content was extracted from draft-ietf-nfsv4-delstid + */ + +typedef bool fattr4_offline; + + +const FATTR4_OFFLINE =3D 83; + + +struct open_arguments4 { + bitmap4 oa_share_access; + bitmap4 oa_share_deny; + bitmap4 oa_share_access_want; + bitmap4 oa_open_claim; + bitmap4 oa_create_mode; +}; + + +enum open_args_share_access4 { + OPEN_ARGS_SHARE_ACCESS_READ =3D 1, + OPEN_ARGS_SHARE_ACCESS_WRITE =3D 2, + OPEN_ARGS_SHARE_ACCESS_BOTH =3D 3 +}; + + +enum open_args_share_deny4 { + OPEN_ARGS_SHARE_DENY_NONE =3D 0, + OPEN_ARGS_SHARE_DENY_READ =3D 1, + OPEN_ARGS_SHARE_DENY_WRITE =3D 2, + OPEN_ARGS_SHARE_DENY_BOTH =3D 3 +}; + + +enum open_args_share_access_want4 { + OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG =3D 3, + OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG =3D 4, + OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL =3D 5, + OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL + =3D 17, + OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED + =3D 18, + OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 20, + OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 21 +}; + + +enum open_args_open_claim4 { + OPEN_ARGS_OPEN_CLAIM_NULL =3D 0, + OPEN_ARGS_OPEN_CLAIM_PREVIOUS =3D 1, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR =3D 2, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV =3D 3, + OPEN_ARGS_OPEN_CLAIM_FH =3D 4, + OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH =3D 5, + OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH =3D 6 +}; + + +enum open_args_createmode4 { + OPEN_ARGS_CREATEMODE_UNCHECKED4 =3D 0, + OPEN_ARGS_CREATE_MODE_GUARDED =3D 1, + OPEN_ARGS_CREATEMODE_EXCLUSIVE4 =3D 2, + OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 =3D 3 +}; + + +typedef open_arguments4 fattr4_open_arguments; +pragma public fattr4_open_arguments; + + +%/* +% * Determine what OPEN supports. +% */ +const FATTR4_OPEN_ARGUMENTS =3D 86; + + +const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 0x200000; + + +const OPEN4_RESULT_NO_OPEN_STATEID =3D 0x00000010; + + +/* + * attributes for the delegation times being + * cached and served by the "client" + */ +typedef nfstime4 fattr4_time_deleg_access; +typedef nfstime4 fattr4_time_deleg_modify; +pragma public fattr4_time_deleg_access; +pragma public fattr4_time_deleg_modify; + + +%/* +% * New RECOMMENDED Attribute for +% * delegation caching of times +% */ +const FATTR4_TIME_DELEG_ACCESS =3D 84; +const FATTR4_TIME_DELEG_MODIFY =3D 85; + + +const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 0x100000; + diff --git a/fs/nfsd/Makefile b/fs/nfsd/Makefile index 18cbd3fa7691a27b39a3b1264637b9422aeb42ba..2f687619f65b38ddcfa0126aca6= 9b6f98dd731f4 100644 --- a/fs/nfsd/Makefile +++ b/fs/nfsd/Makefile @@ -18,9 +18,23 @@ nfsd-$(CONFIG_NFSD_V2) +=3D nfsproc.o nfsxdr.o nfsd-$(CONFIG_NFSD_V2_ACL) +=3D nfs2acl.o nfsd-$(CONFIG_NFSD_V3_ACL) +=3D nfs3acl.o nfsd-$(CONFIG_NFSD_V4) +=3D nfs4proc.o nfs4xdr.o nfs4state.o nfs4idmap.o \ - nfs4acl.o nfs4callback.o nfs4recover.o + nfs4acl.o nfs4callback.o nfs4recover.o nfs4xdr_gen.o nfsd-$(CONFIG_NFSD_PNFS) +=3D nfs4layouts.o nfsd-$(CONFIG_NFSD_BLOCKLAYOUT) +=3D blocklayout.o blocklayoutxdr.o nfsd-$(CONFIG_NFSD_SCSILAYOUT) +=3D blocklayout.o blocklayoutxdr.o nfsd-$(CONFIG_NFSD_FLEXFILELAYOUT) +=3D flexfilelayout.o flexfilelayoutxdr= .o nfsd-$(CONFIG_NFS_LOCALIO) +=3D localio.o + + +.PHONY: xdrgen + +xdrgen: ../../include/linux/sunrpc/xdrgen/nfs4_1.h nfs4xdr_gen.h nfs4xdr_g= en.c + +../../include/linux/sunrpc/xdrgen/nfs4_1.h: ../../Documentation/sunrpc/xdr= /nfs4_1.x + ../../tools/net/sunrpc/xdrgen/xdrgen definitions $< > $@ + +nfs4xdr_gen.h: ../../Documentation/sunrpc/xdr/nfs4_1.x + ../../tools/net/sunrpc/xdrgen/xdrgen declarations $< > $@ + +nfs4xdr_gen.c: ../../Documentation/sunrpc/xdr/nfs4_1.x + ../../tools/net/sunrpc/xdrgen/xdrgen source $< > $@ diff --git a/fs/nfsd/nfs4xdr_gen.c b/fs/nfsd/nfs4xdr_gen.c new file mode 100644 index 0000000000000000000000000000000000000000..e5d34f9a3147d9d51fb3b9db4c2= 9b048b1083cbf --- /dev/null +++ b/fs/nfsd/nfs4xdr_gen.c @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: GPL-2.0 +// Generated by xdrgen. Manual edits will be lost. +// XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x +// XDR specification modification time: Thu Oct 3 11:30:59 2024 + +#include + +#include "nfs4xdr_gen.h" + +static bool __maybe_unused +xdrgen_decode_int64_t(struct xdr_stream *xdr, int64_t *ptr) +{ + return xdrgen_decode_hyper(xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_uint32_t(struct xdr_stream *xdr, uint32_t *ptr) +{ + return xdrgen_decode_unsigned_int(xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_bitmap4(struct xdr_stream *xdr, bitmap4 *ptr) +{ + if (xdr_stream_decode_u32(xdr, &ptr->count) < 0) + return false; + for (u32 i =3D 0; i < ptr->count; i++) + if (!xdrgen_decode_uint32_t(xdr, &ptr->element[i])) + return false; + return true; +}; + +static bool __maybe_unused +xdrgen_decode_nfstime4(struct xdr_stream *xdr, struct nfstime4 *ptr) +{ + if (!xdrgen_decode_int64_t(xdr, &ptr->seconds)) + return false; + if (!xdrgen_decode_uint32_t(xdr, &ptr->nseconds)) + return false; + return true; +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_offline(struct xdr_stream *xdr, fattr4_offline *ptr) +{ + return xdrgen_decode_bool(xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_open_arguments4(struct xdr_stream *xdr, struct open_argument= s4 *ptr) +{ + if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_share_access)) + return false; + if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_share_deny)) + return false; + if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_share_access_want)) + return false; + if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_open_claim)) + return false; + if (!xdrgen_decode_bitmap4(xdr, &ptr->oa_create_mode)) + return false; + return true; +}; + +static bool __maybe_unused +xdrgen_decode_open_args_share_access4(struct xdr_stream *xdr, open_args_sh= are_access4 *ptr) +{ + u32 val; + + if (xdr_stream_decode_u32(xdr, &val) < 0) + return false; + *ptr =3D val; + return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_deny4(struct xdr_stream *xdr, open_args_shar= e_deny4 *ptr) +{ + u32 val; + + if (xdr_stream_decode_u32(xdr, &val) < 0) + return false; + *ptr =3D val; + return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_access_want4(struct xdr_stream *xdr, open_ar= gs_share_access_want4 *ptr) +{ + u32 val; + + if (xdr_stream_decode_u32(xdr, &val) < 0) + return false; + *ptr =3D val; + return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_open_claim4(struct xdr_stream *xdr, open_args_open= _claim4 *ptr) +{ + u32 val; + + if (xdr_stream_decode_u32(xdr, &val) < 0) + return false; + *ptr =3D val; + return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_createmode4(struct xdr_stream *xdr, open_args_crea= temode4 *ptr) +{ + u32 val; + + if (xdr_stream_decode_u32(xdr, &val) < 0) + return false; + *ptr =3D val; + return true; +} + +bool +xdrgen_decode_fattr4_open_arguments(struct xdr_stream *xdr, fattr4_open_ar= guments *ptr) +{ + return xdrgen_decode_open_arguments4(xdr, ptr); +}; + +bool +xdrgen_decode_fattr4_time_deleg_access(struct xdr_stream *xdr, fattr4_time= _deleg_access *ptr) +{ + return xdrgen_decode_nfstime4(xdr, ptr); +}; + +bool +xdrgen_decode_fattr4_time_deleg_modify(struct xdr_stream *xdr, fattr4_time= _deleg_modify *ptr) +{ + return xdrgen_decode_nfstime4(xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_encode_int64_t(struct xdr_stream *xdr, const int64_t value) +{ + return xdrgen_encode_hyper(xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_uint32_t(struct xdr_stream *xdr, const uint32_t value) +{ + return xdrgen_encode_unsigned_int(xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_bitmap4(struct xdr_stream *xdr, const bitmap4 value) +{ + if (xdr_stream_encode_u32(xdr, value.count) !=3D XDR_UNIT) + return false; + for (u32 i =3D 0; i < value.count; i++) + if (!xdrgen_encode_uint32_t(xdr, value.element[i])) + return false; + return true; +}; + +static bool __maybe_unused +xdrgen_encode_nfstime4(struct xdr_stream *xdr, const struct nfstime4 *valu= e) +{ + if (!xdrgen_encode_int64_t(xdr, value->seconds)) + return false; + if (!xdrgen_encode_uint32_t(xdr, value->nseconds)) + return false; + return true; +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_offline(struct xdr_stream *xdr, const fattr4_offline = value) +{ + return xdrgen_encode_bool(xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_open_arguments4(struct xdr_stream *xdr, const struct open_ar= guments4 *value) +{ + if (!xdrgen_encode_bitmap4(xdr, value->oa_share_access)) + return false; + if (!xdrgen_encode_bitmap4(xdr, value->oa_share_deny)) + return false; + if (!xdrgen_encode_bitmap4(xdr, value->oa_share_access_want)) + return false; + if (!xdrgen_encode_bitmap4(xdr, value->oa_open_claim)) + return false; + if (!xdrgen_encode_bitmap4(xdr, value->oa_create_mode)) + return false; + return true; +}; + +static bool __maybe_unused +xdrgen_encode_open_args_share_access4(struct xdr_stream *xdr, open_args_sh= are_access4 value) +{ + return xdr_stream_encode_u32(xdr, value) =3D=3D XDR_UNIT; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_deny4(struct xdr_stream *xdr, open_args_shar= e_deny4 value) +{ + return xdr_stream_encode_u32(xdr, value) =3D=3D XDR_UNIT; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_access_want4(struct xdr_stream *xdr, open_ar= gs_share_access_want4 value) +{ + return xdr_stream_encode_u32(xdr, value) =3D=3D XDR_UNIT; +} + +static bool __maybe_unused +xdrgen_encode_open_args_open_claim4(struct xdr_stream *xdr, open_args_open= _claim4 value) +{ + return xdr_stream_encode_u32(xdr, value) =3D=3D XDR_UNIT; +} + +static bool __maybe_unused +xdrgen_encode_open_args_createmode4(struct xdr_stream *xdr, open_args_crea= temode4 value) +{ + return xdr_stream_encode_u32(xdr, value) =3D=3D XDR_UNIT; +} + +bool +xdrgen_encode_fattr4_open_arguments(struct xdr_stream *xdr, const fattr4_o= pen_arguments *value) +{ + return xdrgen_encode_open_arguments4(xdr, value); +}; + +bool +xdrgen_encode_fattr4_time_deleg_access(struct xdr_stream *xdr, const fattr= 4_time_deleg_access *value) +{ + return xdrgen_encode_nfstime4(xdr, value); +}; + +bool +xdrgen_encode_fattr4_time_deleg_modify(struct xdr_stream *xdr, const fattr= 4_time_deleg_modify *value) +{ + return xdrgen_encode_nfstime4(xdr, value); +}; diff --git a/fs/nfsd/nfs4xdr_gen.h b/fs/nfsd/nfs4xdr_gen.h new file mode 100644 index 0000000000000000000000000000000000000000..c4c6a5075b17be3f931e2a20e28= 2e33dc6e10ef1 --- /dev/null +++ b/fs/nfsd/nfs4xdr_gen.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Generated by xdrgen. Manual edits will be lost. */ +/* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ +/* XDR specification modification time: Thu Oct 3 11:30:59 2024 */ + +#ifndef _LINUX_XDRGEN_NFS4_1_DECL_H +#define _LINUX_XDRGEN_NFS4_1_DECL_H + +#include + +#include +#include +#include +#include + +bool xdrgen_decode_fattr4_open_arguments(struct xdr_stream *xdr, fattr4_op= en_arguments *ptr); +bool xdrgen_encode_fattr4_open_arguments(struct xdr_stream *xdr, const fat= tr4_open_arguments *value); + +bool xdrgen_decode_fattr4_time_deleg_access(struct xdr_stream *xdr, fattr4= _time_deleg_access *ptr); +bool xdrgen_encode_fattr4_time_deleg_access(struct xdr_stream *xdr, const = fattr4_time_deleg_access *value); + +bool xdrgen_decode_fattr4_time_deleg_modify(struct xdr_stream *xdr, fattr4= _time_deleg_modify *ptr); +bool xdrgen_encode_fattr4_time_deleg_modify(struct xdr_stream *xdr, const = fattr4_time_deleg_modify *value); + +#endif /* _LINUX_XDRGEN_NFS4_1_DECL_H */ diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 8d7430d9f2183f08fc995b12370d0ddddf0bffba..b907192447755a614289554a019= 28c1ebb61c3dc 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -17,6 +17,7 @@ #include #include #include +#include =20 enum nfs4_acl_whotype { NFS4_ACL_WHO_NAMED =3D 0, @@ -512,12 +513,6 @@ enum { FATTR4_XATTR_SUPPORT =3D 82, }; =20 -enum { - FATTR4_TIME_DELEG_ACCESS =3D 84, - FATTR4_TIME_DELEG_MODIFY =3D 85, - FATTR4_OPEN_ARGUMENTS =3D 86, -}; - /* * The following internal definitions enable processing the above * attribute bits within 32-bit word boundaries. diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 559273a0f16d81ef93b66c088cc0c5f86ab3109c..e74a87bb18a44be8b757039a0d5= 27078034ced47 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1315,11 +1315,6 @@ struct nfs4_fsid_present_res { =20 #endif /* CONFIG_NFS_V4 */ =20 -struct nfstime4 { - u64 seconds; - u32 nseconds; -}; - #ifdef CONFIG_NFS_V4_1 =20 struct pnfs_commit_bucket { diff --git a/include/linux/sunrpc/xdrgen/nfs4_1.h b/include/linux/sunrpc/xd= rgen/nfs4_1.h new file mode 100644 index 0000000000000000000000000000000000000000..6025ab6b739833aad33567102e2= 16c162003f408 --- /dev/null +++ b/include/linux/sunrpc/xdrgen/nfs4_1.h @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Generated by xdrgen. Manual edits will be lost. */ +/* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ +/* XDR specification modification time: Thu Oct 3 11:30:59 2024 */ + +#ifndef _LINUX_XDRGEN_NFS4_1_DEF_H +#define _LINUX_XDRGEN_NFS4_1_DEF_H + +#include +#include + +typedef s64 int64_t; + +typedef u32 uint32_t; + +typedef struct { + u32 count; + uint32_t *element; +} bitmap4; + +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; + +typedef bool fattr4_offline; + +enum { FATTR4_OFFLINE =3D 83 }; + +struct open_arguments4 { + bitmap4 oa_share_access; + bitmap4 oa_share_deny; + bitmap4 oa_share_access_want; + bitmap4 oa_open_claim; + bitmap4 oa_create_mode; +}; + +enum open_args_share_access4 { + OPEN_ARGS_SHARE_ACCESS_READ =3D 1, + OPEN_ARGS_SHARE_ACCESS_WRITE =3D 2, + OPEN_ARGS_SHARE_ACCESS_BOTH =3D 3, +}; +typedef enum open_args_share_access4 open_args_share_access4; + +enum open_args_share_deny4 { + OPEN_ARGS_SHARE_DENY_NONE =3D 0, + OPEN_ARGS_SHARE_DENY_READ =3D 1, + OPEN_ARGS_SHARE_DENY_WRITE =3D 2, + OPEN_ARGS_SHARE_DENY_BOTH =3D 3, +}; +typedef enum open_args_share_deny4 open_args_share_deny4; + +enum open_args_share_access_want4 { + OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG =3D 3, + OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG =3D 4, + OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL =3D 5, + OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL =3D 17, + OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED =3D 18, + OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 20, + OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 21, +}; +typedef enum open_args_share_access_want4 open_args_share_access_want4; + +enum open_args_open_claim4 { + OPEN_ARGS_OPEN_CLAIM_NULL =3D 0, + OPEN_ARGS_OPEN_CLAIM_PREVIOUS =3D 1, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR =3D 2, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV =3D 3, + OPEN_ARGS_OPEN_CLAIM_FH =3D 4, + OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH =3D 5, + OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH =3D 6, +}; +typedef enum open_args_open_claim4 open_args_open_claim4; + +enum open_args_createmode4 { + OPEN_ARGS_CREATEMODE_UNCHECKED4 =3D 0, + OPEN_ARGS_CREATE_MODE_GUARDED =3D 1, + OPEN_ARGS_CREATEMODE_EXCLUSIVE4 =3D 2, + OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 =3D 3, +}; +typedef enum open_args_createmode4 open_args_createmode4; + +typedef struct open_arguments4 fattr4_open_arguments; + +enum { FATTR4_OPEN_ARGUMENTS =3D 86 }; + +enum { OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 0x200000 }; + +enum { OPEN4_RESULT_NO_OPEN_STATEID =3D 0x00000010 }; + +typedef struct nfstime4 fattr4_time_deleg_access; + +typedef struct nfstime4 fattr4_time_deleg_modify; + +enum { FATTR4_TIME_DELEG_ACCESS =3D 84 }; + +enum { FATTR4_TIME_DELEG_MODIFY =3D 85 }; + +enum { OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 0x100000 }; + +#define NFS4_int64_t_sz \ + (XDR_hyper) +#define NFS4_uint32_t_sz \ + (XDR_unsigned_int) +#define NFS4_bitmap4_sz (XDR_unsigned_int) +#define NFS4_nfstime4_sz \ + (NFS4_int64_t_sz + NFS4_uint32_t_sz) +#define NFS4_fattr4_offline_sz \ + (XDR_bool) +#define NFS4_open_arguments4_sz \ + (NFS4_bitmap4_sz + NFS4_bitmap4_sz + NFS4_bitmap4_sz + NFS4_bitmap4_sz + = NFS4_bitmap4_sz) +#define NFS4_open_args_share_access4_sz (XDR_int) +#define NFS4_open_args_share_deny4_sz (XDR_int) +#define NFS4_open_args_share_access_want4_sz (XDR_int) +#define NFS4_open_args_open_claim4_sz (XDR_int) +#define NFS4_open_args_createmode4_sz (XDR_int) +#define NFS4_fattr4_open_arguments_sz \ + (NFS4_open_arguments4_sz) +#define NFS4_fattr4_time_deleg_access_sz \ + (NFS4_nfstime4_sz) +#define NFS4_fattr4_time_deleg_modify_sz \ + (NFS4_nfstime4_sz) + +#endif /* _LINUX_XDRGEN_NFS4_1_DEF_H */ --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 2785A19F119; Mon, 9 Dec 2024 21:14: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=1733778859; cv=none; b=U2dhSS0b17QLTz+3Ggt+6JqTFIhWPfghnUIkfXRCJ3DgG9ZWPfVbM3S6ZJ0/nXiBHmGP1Ctgx5aH3jj9ET9CFBh284hPbuf2Q012rFiE0uP7eSO4qoZ7BThRJQUZH7w3LMPLTeWsOE56yGJmt4DS84OUL6E1dQJ5a8dnX5EnYnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778859; c=relaxed/simple; bh=3si8j3lSEkeRRpO/9BBiyWD86Yw3ikSlJSYDWuYCyEw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mvdyIhcW91/a+XMsl8Lq13xBnK4VLnUqANDDno2JvyVcUm+dW7l7MpL57V7YxoDLrf+U7ZhDAwPSy0B/lcBRCp46K9ocUL4XYhjT/cJnHfAZ7Wm0MoT82oGbgmv8YjIUwdjUY+5zAvT00hyzBXAv9A7jo6llKtqGYj5pDcuraKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Inywus6Q; 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="Inywus6Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04610C4CEE2; Mon, 9 Dec 2024 21:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778859; bh=3si8j3lSEkeRRpO/9BBiyWD86Yw3ikSlJSYDWuYCyEw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Inywus6QSamnpTKLQ7FA/6i/xmIbYlLMEdglK5zLyuaCGndw/vrcvim41MIfiUms6 AsZ1utODQP4mFhqaKT0oMHxyra83qxfKYFka+0Roo3fNU5YNP7+LEUteLS9fKDHuLg qGBwIyXHYY05Llf7+/tgg/5Bjk24DZO+jdi4Ba/gwB6PKnBsfKXwVTn+1FPklvfjeI iYod3fFLMhPVCdxqlku5fztGYZYrcyhnAFA8OVL+Y/Ik0BKUIBbofOTFciPxMRTFSd BOOr78ZzA1hqI/3JcYpFKEQOER2tppovHnLm5IL4Y4CPykoM6ZNQsvvF+pGMvGuSig QtaLqx1UmRgiA== From: Jeff Layton Date: Mon, 09 Dec 2024 16:13:55 -0500 Subject: [PATCH v5 03/10] nfsd: switch to autogenerated definitions for open_delegation_type4 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: <20241209-delstid-v5-3-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=11695; i=jlayton@kernel.org; h=from:subject:message-id; bh=3si8j3lSEkeRRpO/9BBiyWD86Yw3ikSlJSYDWuYCyEw=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12kRpgouaWKmQ3PTSq2VAznB+jImSgaQc/fE 2uh0gtNPLGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpAAKCRAADmhBGVaC FeghEAC8aRYzWCnWh6xeShjq7vWLxOYc6VdBNFGOM3ieDYNky6Vk1rhHWkA2ehJ082FxuDiLa1i 9afN5jt/4JzbeWFebjtk2QNpTszwYDVVwn2Bx2ALk7LghW8sizn3t/1CNdqD9me9zeY7shZi0QW zZ3Dj3DMN7zXDR/4zPvsnlTASX3Iq1M9NX5PFIK1g4YST9cuV7T65RiumwlaqNX6k2uRK3VmM2q Eg9Zzj+w5HYWnxRWXsesSI4BS6mD2kKorJ1StUrFgEg9DErTR/uYHaxwv/9pproL1AMrK2+6UsR xCao5As69hQRHMsse/wzPdzVOPY3WRsJMBxb8TcldbmdcQOwXDTgz3OndmtnE/ZaxOdOJa36Ukp TgvNXXyDMo/kz7d6T3yZZra5UOtuTX1do8gC2BKQtRAGxyJsFXTC7+zARhKJ8W70tSzE+zhxHx0 3RM9FEDPvpsA4LyR96GqyOYM2KLVZgBk6/yyHkQ7+XeCUCHvOdZBITa2cwzTbp3ZdZoI3XN7tGy AuOjySrm6HZjEMsLg9G+rYtx9ENifzjgxqi9pZwRXU4wLUf4JcOD4hdqrIRF830AvFtoq5vJB60 vOfONag9lwFGYofEiLKltrc7C4C4pqqqUyQQlHaYBPhwF+cvl5MasC7S0HuoS+IpRmIRc06RFNj wd+jWZSB8bTS+qA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Rename the enum with the same name in include/linux/nfs4.h, add the proper enum to nfs4_1.x and regenerate the headers and source files. Do a mass rename of all NFS4_OPEN_DELEGATE_* to OPEN_DELEGATE_* in the nfsd directory. Signed-off-by: Jeff Layton --- Documentation/sunrpc/xdr/nfs4_1.x | 9 ++++++++- fs/nfsd/nfs4state.c | 34 +++++++++++++++++---------------= -- fs/nfsd/nfs4xdr.c | 8 ++++---- fs/nfsd/nfs4xdr_gen.c | 19 ++++++++++++++++++- fs/nfsd/nfs4xdr_gen.h | 2 +- include/linux/nfs4.h | 2 +- include/linux/sunrpc/xdrgen/nfs4_1.h | 13 ++++++++++++- 7 files changed, 61 insertions(+), 26 deletions(-) diff --git a/Documentation/sunrpc/xdr/nfs4_1.x b/Documentation/sunrpc/xdr/n= fs4_1.x index fc37d1ecba0f40e46c6986df90d07a0e6e6ae9b2..ee9f8f249f1e71dbfc383007a69= 50ebc4104ed67 100644 --- a/Documentation/sunrpc/xdr/nfs4_1.x +++ b/Documentation/sunrpc/xdr/nfs4_1.x @@ -161,6 +161,13 @@ pragma public fattr4_time_deleg_modify; const FATTR4_TIME_DELEG_ACCESS =3D 84; const FATTR4_TIME_DELEG_MODIFY =3D 85; =20 - const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 0x100000; =20 +enum open_delegation_type4 { + OPEN_DELEGATE_NONE =3D 0, + OPEN_DELEGATE_READ =3D 1, + OPEN_DELEGATE_WRITE =3D 2, + OPEN_DELEGATE_NONE_EXT =3D 3, /* new to v4.1 */ + OPEN_DELEGATE_READ_ATTRS_DELEG =3D 4, + OPEN_DELEGATE_WRITE_ATTRS_DELEG =3D 5 +}; diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 741b9449f727defc794347f1b116c955d715e691..c0e46ce0e068d8c73226dfe73ad= c58c24a630d77 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2887,7 +2887,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct= nfs4_stid *st) seq_puts(s, ": { type: deleg, "); =20 seq_printf(s, "access: %s", - ds->dl_type =3D=3D NFS4_OPEN_DELEGATE_READ ? "r" : "w"); + ds->dl_type =3D=3D OPEN_DELEGATE_READ ? "r" : "w"); =20 /* XXX: lease time, whether it's being recalled. */ =20 @@ -5472,7 +5472,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *csta= te, static inline __be32 nfs4_check_delegmode(struct nfs4_delegation *dp, int flags) { - if ((flags & WR_STATE) && (dp->dl_type =3D=3D NFS4_OPEN_DELEGATE_READ)) + if ((flags & WR_STATE) && (dp->dl_type =3D=3D OPEN_DELEGATE_READ)) return nfserr_openmode; else return nfs_ok; @@ -5714,7 +5714,7 @@ static struct file_lease *nfs4_alloc_init_lease(struc= t nfs4_delegation *dp, return NULL; fl->fl_lmops =3D &nfsd_lease_mng_ops; fl->c.flc_flags =3D FL_DELEG; - fl->c.flc_type =3D flag =3D=3D NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK; + fl->c.flc_type =3D flag =3D=3D OPEN_DELEGATE_READ ? F_RDLCK : F_WRLCK; fl->c.flc_owner =3D (fl_owner_t)dp; fl->c.flc_pid =3D current->tgid; fl->c.flc_file =3D dp->dl_stid.sc_file->fi_deleg_file->nf_file; @@ -5860,7 +5860,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct n= fs4_ol_stateid *stp, */ if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) =3D=3D NFS4_SHARE_AC= CESS_BOTH) { nf =3D find_rw_file(fp); - dl_type =3D NFS4_OPEN_DELEGATE_WRITE; + dl_type =3D OPEN_DELEGATE_WRITE; } =20 /* @@ -5869,7 +5869,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct n= fs4_ol_stateid *stp, */ if (!nf && (open->op_share_access & NFS4_SHARE_ACCESS_READ)) { nf =3D find_readable_file(fp); - dl_type =3D NFS4_OPEN_DELEGATE_READ; + dl_type =3D OPEN_DELEGATE_READ; } =20 if (!nf) @@ -5958,7 +5958,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct n= fs4_ol_stateid *stp, =20 static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status) { - open->op_delegate_type =3D NFS4_OPEN_DELEGATE_NONE_EXT; + open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; if (status =3D=3D -EAGAIN) open->op_why_no_deleg =3D WND4_CONTENTION; else { @@ -6074,20 +6074,20 @@ nfs4_open_delegation(struct nfsd4_open *open, struc= t nfs4_ol_stateid *stp, destroy_delegation(dp); goto out_no_deleg; } - open->op_delegate_type =3D NFS4_OPEN_DELEGATE_WRITE; + open->op_delegate_type =3D 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); trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid); } else { - open->op_delegate_type =3D NFS4_OPEN_DELEGATE_READ; + open->op_delegate_type =3D OPEN_DELEGATE_READ; trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid); } nfs4_put_stid(&dp->dl_stid); return; out_no_deleg: - open->op_delegate_type =3D NFS4_OPEN_DELEGATE_NONE; + open->op_delegate_type =3D OPEN_DELEGATE_NONE; if (open->op_claim_type =3D=3D NFS4_OPEN_CLAIM_PREVIOUS && - open->op_delegate_type !=3D NFS4_OPEN_DELEGATE_NONE) { + open->op_delegate_type !=3D OPEN_DELEGATE_NONE) { dprintk("NFSD: WARNING: refusing delegation reclaim\n"); open->op_recall =3D true; } @@ -6102,17 +6102,17 @@ static void nfsd4_deleg_xgrade_none_ext(struct nfsd= 4_open *open, struct nfs4_delegation *dp) { if (open->op_deleg_want =3D=3D NFS4_SHARE_WANT_READ_DELEG && - dp->dl_type =3D=3D NFS4_OPEN_DELEGATE_WRITE) { - open->op_delegate_type =3D NFS4_OPEN_DELEGATE_NONE_EXT; + dp->dl_type =3D=3D OPEN_DELEGATE_WRITE) { + open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_SUPP_DOWNGRADE; } else if (open->op_deleg_want =3D=3D NFS4_SHARE_WANT_WRITE_DELEG && - dp->dl_type =3D=3D NFS4_OPEN_DELEGATE_WRITE) { - open->op_delegate_type =3D NFS4_OPEN_DELEGATE_NONE_EXT; + dp->dl_type =3D=3D OPEN_DELEGATE_WRITE) { + open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_SUPP_UPGRADE; } /* Otherwise the client must be confused wanting a delegation * it already has, therefore we don't return - * NFS4_OPEN_DELEGATE_NONE_EXT and reason. + * OPEN_DELEGATE_NONE_EXT and reason. */ } =20 @@ -6202,7 +6202,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct sv= c_fh *current_fh, struct nf =20 if (nfsd4_has_session(&resp->cstate)) { if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) { - open->op_delegate_type =3D NFS4_OPEN_DELEGATE_NONE_EXT; + open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_WANTED; goto nodeleg; } @@ -6218,7 +6218,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct sv= c_fh *current_fh, struct nf trace_nfsd_open(&stp->st_stid.sc_stateid); out: /* 4.1 client trying to upgrade/downgrade delegation? */ - if (open->op_delegate_type =3D=3D NFS4_OPEN_DELEGATE_NONE && dp && + if (open->op_delegate_type =3D=3D OPEN_DELEGATE_NONE && dp && open->op_deleg_want) nfsd4_deleg_xgrade_none_ext(open, dp); =20 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index c8e8d3f0dff4bb5288186369aad821906e684db7..593cf8c2ffe9dad90549ae0d0d5= d9cbcbf18a690 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4232,18 +4232,18 @@ nfsd4_encode_open_delegation4(struct xdr_stream *xd= r, struct nfsd4_open *open) if (xdr_stream_encode_u32(xdr, open->op_delegate_type) !=3D XDR_UNIT) return nfserr_resource; switch (open->op_delegate_type) { - case NFS4_OPEN_DELEGATE_NONE: + case OPEN_DELEGATE_NONE: status =3D nfs_ok; break; - case NFS4_OPEN_DELEGATE_READ: + case OPEN_DELEGATE_READ: /* read */ status =3D nfsd4_encode_open_read_delegation4(xdr, open); break; - case NFS4_OPEN_DELEGATE_WRITE: + case OPEN_DELEGATE_WRITE: /* write */ status =3D nfsd4_encode_open_write_delegation4(xdr, open); break; - case NFS4_OPEN_DELEGATE_NONE_EXT: + case OPEN_DELEGATE_NONE_EXT: /* od_whynone */ status =3D nfsd4_encode_open_none_delegation4(xdr, open); break; diff --git a/fs/nfsd/nfs4xdr_gen.c b/fs/nfsd/nfs4xdr_gen.c index e5d34f9a3147d9d51fb3b9db4c29b048b1083cbf..a0e01f50a28d7f6828f3e6ef02f= 90b84bf180841 100644 --- a/fs/nfsd/nfs4xdr_gen.c +++ b/fs/nfsd/nfs4xdr_gen.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x -// XDR specification modification time: Thu Oct 3 11:30:59 2024 +// XDR specification modification time: Sat Oct 12 08:10:54 2024 =20 #include =20 @@ -135,6 +135,17 @@ xdrgen_decode_fattr4_time_deleg_modify(struct xdr_stre= am *xdr, fattr4_time_deleg return xdrgen_decode_nfstime4(xdr, ptr); }; =20 +static bool __maybe_unused +xdrgen_decode_open_delegation_type4(struct xdr_stream *xdr, open_delegatio= n_type4 *ptr) +{ + u32 val; + + if (xdr_stream_decode_u32(xdr, &val) < 0) + return false; + *ptr =3D val; + return true; +} + static bool __maybe_unused xdrgen_encode_int64_t(struct xdr_stream *xdr, const int64_t value) { @@ -237,3 +248,9 @@ xdrgen_encode_fattr4_time_deleg_modify(struct xdr_strea= m *xdr, const fattr4_time { return xdrgen_encode_nfstime4(xdr, value); }; + +static bool __maybe_unused +xdrgen_encode_open_delegation_type4(struct xdr_stream *xdr, open_delegatio= n_type4 value) +{ + return xdr_stream_encode_u32(xdr, value) =3D=3D XDR_UNIT; +} diff --git a/fs/nfsd/nfs4xdr_gen.h b/fs/nfsd/nfs4xdr_gen.h index c4c6a5075b17be3f931e2a20e282e33dc6e10ef1..3fc8bde2b3b5db6f80f17b41e7f= 5991487cfa959 100644 --- a/fs/nfsd/nfs4xdr_gen.h +++ b/fs/nfsd/nfs4xdr_gen.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Thu Oct 3 11:30:59 2024 */ +/* XDR specification modification time: Sat Oct 12 08:10:54 2024 */ =20 #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H #define _LINUX_XDRGEN_NFS4_1_DECL_H diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index b907192447755a614289554a01928c1ebb61c3dc..71fbebfa43c7e2bd27708814c73= 00c506ce64c1b 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -366,7 +366,7 @@ enum limit_by4 { NFS4_LIMIT_BLOCKS =3D 2 }; =20 -enum open_delegation_type4 { +enum nfs4_open_delegation_type4 { NFS4_OPEN_DELEGATE_NONE =3D 0, NFS4_OPEN_DELEGATE_READ =3D 1, NFS4_OPEN_DELEGATE_WRITE =3D 2, diff --git a/include/linux/sunrpc/xdrgen/nfs4_1.h b/include/linux/sunrpc/xd= rgen/nfs4_1.h index 6025ab6b739833aad33567102e216c162003f408..9ca83a4a04cff8ebb5aafa08a24= a2db771d6c1ef 100644 --- a/include/linux/sunrpc/xdrgen/nfs4_1.h +++ b/include/linux/sunrpc/xdrgen/nfs4_1.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Thu Oct 3 11:30:59 2024 */ +/* XDR specification modification time: Sat Oct 12 08:10:54 2024 */ =20 #ifndef _LINUX_XDRGEN_NFS4_1_DEF_H #define _LINUX_XDRGEN_NFS4_1_DEF_H @@ -98,6 +98,16 @@ enum { FATTR4_TIME_DELEG_MODIFY =3D 85 }; =20 enum { OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 0x100000 }; =20 +enum open_delegation_type4 { + OPEN_DELEGATE_NONE =3D 0, + OPEN_DELEGATE_READ =3D 1, + OPEN_DELEGATE_WRITE =3D 2, + OPEN_DELEGATE_NONE_EXT =3D 3, + OPEN_DELEGATE_READ_ATTRS_DELEG =3D 4, + OPEN_DELEGATE_WRITE_ATTRS_DELEG =3D 5, +}; +typedef enum open_delegation_type4 open_delegation_type4; + #define NFS4_int64_t_sz \ (XDR_hyper) #define NFS4_uint32_t_sz \ @@ -120,5 +130,6 @@ enum { OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 0x1= 00000 }; (NFS4_nfstime4_sz) #define NFS4_fattr4_time_deleg_modify_sz \ (NFS4_nfstime4_sz) +#define NFS4_open_delegation_type4_sz (XDR_int) =20 #endif /* _LINUX_XDRGEN_NFS4_1_DEF_H */ --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 AAB9719D082; Mon, 9 Dec 2024 21:14:20 +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=1733778860; cv=none; b=AAiyFuU0aVLoicO00ePlAwAiQ4uMMCAwAKhEFPuM5eVhO5XnZMna2TgasyRJfMPRIBvEvqlAZdYEo1erWGRm6PWom3jB8iMUTlZg4prwBWZ+h2OwsHe6n47udraSDsy/01Mx2H/9PD1L1/a6BPjsjvtSmbtN61rpdeNCRwvkGLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778860; c=relaxed/simple; bh=b2Ye+YODeDDeRQCGrTVpIs2PnPSb+KXT7Cr6qu+61Nc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mrwtSHpNnk5Zg6ehucUH5j8njQnlxeSSk7+elTjOut+qeHTo/lJEr+yxKxo54zE8U6D4B6LAqkC7nHK2d35/Sv7hUmTiKficvMvfALV+Icp3hD0uwNr7BDgKBHz6z2QJy1d97IT7ZFt7aMLzmETTLMSfh+giU3xqmMuWc1yNz9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rEjtJpdT; 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="rEjtJpdT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 425DDC4CEE0; Mon, 9 Dec 2024 21:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778860; bh=b2Ye+YODeDDeRQCGrTVpIs2PnPSb+KXT7Cr6qu+61Nc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rEjtJpdTeCjKKfbQyEhgcaNg6658loKxO4inIbNwy/LjHjQqPemxkAMBC6Bdo15ew QYAv4NPnGr2PTQJgU1fBa34Eifmnm2pDRstidTXgRpSmCU3LRF1ys6ddp1U2Ty8s1i x40Gl1XiKlONXa3+DGYqUTjyszgv//vDy3jAlscWZLrNnNR7N6mHyF2nHy8+wAFFRg 406zNrX9o9v6J8X/Qa7obhDrxttStgqiAuZZ4YVO/MqcF+DzsKFgJFQXdAxZwzu7at IIKzJ4P5bWHpzkDW7sFs6vxVFhgRe0sOuyNs1ZjRVfQDgeqfEPKngc+wRCuvBqfzm2 tz1LIriVVzOlA== From: Jeff Layton Date: Mon, 09 Dec 2024 16:13:56 -0500 Subject: [PATCH v5 04/10] nfsd: rename NFS4_SHARE_WANT_* constants to OPEN4_SHARE_ACCESS_WANT_* 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: <20241209-delstid-v5-4-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8255; i=jlayton@kernel.org; h=from:subject:message-id; bh=b2Ye+YODeDDeRQCGrTVpIs2PnPSb+KXT7Cr6qu+61Nc=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12k2LsgwIa94XJbHdyUKfJSE088fr6DKYBOF KDF0n487L6JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpAAKCRAADmhBGVaC FXCyEACxg2BlOVtZBUk2eOT5QOkhDMqkf8a7BYiS04uwN/2myPODxkPfcCYJCe9bJ5oJOFUuTe+ KZ0m/6FTNxRTGbbgwYs2bYdWthfl+rfbS5fPdd4i49mlsiIj1X6mZngLjlPVk7jHZaYLMEerLzX qy3BtPDjMUom/O/vDAEgVrTlEeNbHzshDJ2p00+wPbUGpIsmwFszw3oQLhilVq6yBLc3XNViS7B HtoZ06g2PpfkZSB1qPree6M5HDZLglfZaoOTy5ruAmP0SVExKPAbKxr4+Fvl9W0FsjTQOo74FRj OQ8Fc0ZQgEb91hDC/f/KRv6IPWQbH84lPzalTbRgD95Xh6qwX8+PbaBPzGU6NDE2orRhFgD3UQb 9Mfp3fV6vZHekDt/3bBo/zdvY62Ikhk7rXO0v58GcqWhrmwEm5WGZkbijsu3+P2Ui8dhj9d31BD sChIR2TtdrgucNzfexGjNc95Kte3lKDoDKRzawKswgYjBU1HS+5LHYphTlBqCFgjKpNWm7aRKui dPN9scemQ6Fb5Nd2LA2wHBfCXTnpQAC1bX0mf4im3ad0otrfZ8be8NaXhfypgWUze3Xg1snLg+V r5WM75O7lHsIthW1/BjczsPe5NJrHpUty35fkyKrKmmpFK2+m+81E/71qQRywIHu9w/KfFE7g0A +I4+elbVUjRhFqA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Add the OPEN4_SHARE_ACCESS_WANT constants from the nfs4.1 and delstid draft into the nfs4_1.x file, and regenerate the headers and source files. Do a mass renaming of NFS4_SHARE_WANT_* to OPEN4_SHARE_ACCESS_WANT_* in the nfsd directory. Signed-off-by: Jeff Layton --- Documentation/sunrpc/xdr/nfs4_1.x | 15 ++++++++++++++- fs/nfsd/nfs4state.c | 16 ++++++++-------- fs/nfsd/nfs4xdr.c | 12 ++++++------ fs/nfsd/nfs4xdr_gen.c | 2 +- fs/nfsd/nfs4xdr_gen.h | 2 +- include/linux/sunrpc/xdrgen/nfs4_1.h | 24 +++++++++++++++++++++--- 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/Documentation/sunrpc/xdr/nfs4_1.x b/Documentation/sunrpc/xdr/n= fs4_1.x index ee9f8f249f1e71dbfc383007a6950ebc4104ed67..ca95150a3a29fc5418991bf2395= 326bd73645ea8 100644 --- a/Documentation/sunrpc/xdr/nfs4_1.x +++ b/Documentation/sunrpc/xdr/nfs4_1.x @@ -138,7 +138,6 @@ pragma public fattr4_open_arguments; const FATTR4_OPEN_ARGUMENTS =3D 86; =20 =20 -const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 0x200000; =20 =20 const OPEN4_RESULT_NO_OPEN_STATEID =3D 0x00000010; @@ -161,7 +160,21 @@ pragma public fattr4_time_deleg_modify; const FATTR4_TIME_DELEG_ACCESS =3D 84; const FATTR4_TIME_DELEG_MODIFY =3D 85; =20 + + +/* new flags for share_access field of OPEN4args */ +const OPEN4_SHARE_ACCESS_WANT_DELEG_MASK =3D 0xFF00; +const OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE =3D 0x0000; +const OPEN4_SHARE_ACCESS_WANT_READ_DELEG =3D 0x0100; +const OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG =3D 0x0200; +const OPEN4_SHARE_ACCESS_WANT_ANY_DELEG =3D 0x0300; +const OPEN4_SHARE_ACCESS_WANT_NO_DELEG =3D 0x0400; +const OPEN4_SHARE_ACCESS_WANT_CANCEL =3D 0x0500; + +const OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL =3D 0x10000; +const OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED =3D 0x20000; const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 0x100000; +const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 0x200000; =20 enum open_delegation_type4 { OPEN_DELEGATE_NONE =3D 0, diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c0e46ce0e068d8c73226dfe73adc58c24a630d77..76b07c78559a0f59c0864b62472= 14f7136cd3dd2 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5964,14 +5964,14 @@ static void nfsd4_open_deleg_none_ext(struct nfsd4_= open *open, int status) else { open->op_why_no_deleg =3D WND4_RESOURCE; switch (open->op_deleg_want) { - case NFS4_SHARE_WANT_READ_DELEG: - case NFS4_SHARE_WANT_WRITE_DELEG: - case NFS4_SHARE_WANT_ANY_DELEG: + case OPEN4_SHARE_ACCESS_WANT_READ_DELEG: + case OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG: + case OPEN4_SHARE_ACCESS_WANT_ANY_DELEG: break; - case NFS4_SHARE_WANT_CANCEL: + case OPEN4_SHARE_ACCESS_WANT_CANCEL: open->op_why_no_deleg =3D WND4_CANCELLED; break; - case NFS4_SHARE_WANT_NO_DELEG: + case OPEN4_SHARE_ACCESS_WANT_NO_DELEG: WARN_ON_ONCE(1); } } @@ -6101,11 +6101,11 @@ nfs4_open_delegation(struct nfsd4_open *open, struc= t nfs4_ol_stateid *stp, static void nfsd4_deleg_xgrade_none_ext(struct nfsd4_open *open, struct nfs4_delegation *dp) { - if (open->op_deleg_want =3D=3D NFS4_SHARE_WANT_READ_DELEG && + if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_READ_DELEG && dp->dl_type =3D=3D OPEN_DELEGATE_WRITE) { open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_SUPP_DOWNGRADE; - } else if (open->op_deleg_want =3D=3D NFS4_SHARE_WANT_WRITE_DELEG && + } else if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG= && dp->dl_type =3D=3D OPEN_DELEGATE_WRITE) { open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_SUPP_UPGRADE; @@ -6201,7 +6201,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct sv= c_fh *current_fh, struct nf mutex_unlock(&stp->st_mutex); =20 if (nfsd4_has_session(&resp->cstate)) { - if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) { + if (open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_NO_DELEG) { open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_WANTED; goto nodeleg; diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 593cf8c2ffe9dad90549ae0d0d5d9cbcbf18a690..39a3b21bb90590f9f2711ca1cc0= f44a68819d4a0 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1067,12 +1067,12 @@ static __be32 nfsd4_decode_share_access(struct nfsd= 4_compoundargs *argp, u32 *sh if (!argp->minorversion) return nfserr_bad_xdr; switch (w & NFS4_SHARE_WANT_MASK) { - case NFS4_SHARE_WANT_NO_PREFERENCE: - case NFS4_SHARE_WANT_READ_DELEG: - case NFS4_SHARE_WANT_WRITE_DELEG: - case NFS4_SHARE_WANT_ANY_DELEG: - case NFS4_SHARE_WANT_NO_DELEG: - case NFS4_SHARE_WANT_CANCEL: + case OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE: + case OPEN4_SHARE_ACCESS_WANT_READ_DELEG: + case OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG: + case OPEN4_SHARE_ACCESS_WANT_ANY_DELEG: + case OPEN4_SHARE_ACCESS_WANT_NO_DELEG: + case OPEN4_SHARE_ACCESS_WANT_CANCEL: break; default: return nfserr_bad_xdr; diff --git a/fs/nfsd/nfs4xdr_gen.c b/fs/nfsd/nfs4xdr_gen.c index a0e01f50a28d7f6828f3e6ef02f90b84bf180841..a17b5d8e60b3579caa2e2a8b40e= d757070e1a622 100644 --- a/fs/nfsd/nfs4xdr_gen.c +++ b/fs/nfsd/nfs4xdr_gen.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. // XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x -// XDR specification modification time: Sat Oct 12 08:10:54 2024 +// XDR specification modification time: Mon Oct 14 09:10:13 2024 =20 #include =20 diff --git a/fs/nfsd/nfs4xdr_gen.h b/fs/nfsd/nfs4xdr_gen.h index 3fc8bde2b3b5db6f80f17b41e7f5991487cfa959..41a0033b72562ee3c1fcdcd4a88= 7ce635385b22b 100644 --- a/fs/nfsd/nfs4xdr_gen.h +++ b/fs/nfsd/nfs4xdr_gen.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Sat Oct 12 08:10:54 2024 */ +/* XDR specification modification time: Mon Oct 14 09:10:13 2024 */ =20 #ifndef _LINUX_XDRGEN_NFS4_1_DECL_H #define _LINUX_XDRGEN_NFS4_1_DECL_H diff --git a/include/linux/sunrpc/xdrgen/nfs4_1.h b/include/linux/sunrpc/xd= rgen/nfs4_1.h index 9ca83a4a04cff8ebb5aafa08a24a2db771d6c1ef..cf21a14aa8850f4b21cd365cb7b= c22a02c6097ce 100644 --- a/include/linux/sunrpc/xdrgen/nfs4_1.h +++ b/include/linux/sunrpc/xdrgen/nfs4_1.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs4_1.x */ -/* XDR specification modification time: Sat Oct 12 08:10:54 2024 */ +/* XDR specification modification time: Mon Oct 14 09:10:13 2024 */ =20 #ifndef _LINUX_XDRGEN_NFS4_1_DEF_H #define _LINUX_XDRGEN_NFS4_1_DEF_H @@ -84,8 +84,6 @@ typedef struct open_arguments4 fattr4_open_arguments; =20 enum { FATTR4_OPEN_ARGUMENTS =3D 86 }; =20 -enum { OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 0x200000 }; - enum { OPEN4_RESULT_NO_OPEN_STATEID =3D 0x00000010 }; =20 typedef struct nfstime4 fattr4_time_deleg_access; @@ -96,8 +94,28 @@ enum { FATTR4_TIME_DELEG_ACCESS =3D 84 }; =20 enum { FATTR4_TIME_DELEG_MODIFY =3D 85 }; =20 +enum { OPEN4_SHARE_ACCESS_WANT_DELEG_MASK =3D 0xFF00 }; + +enum { OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE =3D 0x0000 }; + +enum { OPEN4_SHARE_ACCESS_WANT_READ_DELEG =3D 0x0100 }; + +enum { OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG =3D 0x0200 }; + +enum { OPEN4_SHARE_ACCESS_WANT_ANY_DELEG =3D 0x0300 }; + +enum { OPEN4_SHARE_ACCESS_WANT_NO_DELEG =3D 0x0400 }; + +enum { OPEN4_SHARE_ACCESS_WANT_CANCEL =3D 0x0500 }; + +enum { OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL =3D 0x10000 }; + +enum { OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED =3D 0x20000 }; + enum { OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =3D 0x100000 }; =20 +enum { OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =3D 0x200000 }; + enum open_delegation_type4 { OPEN_DELEGATE_NONE =3D 0, OPEN_DELEGATE_READ =3D 1, --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 F374119CD0E; Mon, 9 Dec 2024 21:14:21 +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=1733778862; cv=none; b=ACnMpbX7f+oqdLGtnd6SlHCowRKlWy1JZtthrHul1maefe1GutamUt81CPM6tzzn6GsHL4L+lQaaxfynf0Xc6km6tHyrBFluhGgujcRZUCugQRfbjITksg8iCctmzrEtw1DeOnBOEEke2Lh/Y3iARm1YGcxMv5h9nWXbKJ9uCTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778862; c=relaxed/simple; bh=Ei9QY/Q91nGMwiwpS6SgihvnJDZBcQSLaAo+HH/qVFY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O2p6PnZ4sl43v9R4SKF1FhWnd4ym5GO73JbQOLDO80AteSWE7diF5ndWxeYh3KOPmeVHcllspDWnY04tFxUDEVczjUcIFOstqIy+NsDmqtfkQkg8WcQHcPcAg8mm5wVOYjPZvY4lbKUFYZ5Rt1GP6T6tS4pTOUA9svh36MwW1Rw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sjxrdq3/; 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="sjxrdq3/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 808B4C4CEE1; Mon, 9 Dec 2024 21:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778861; bh=Ei9QY/Q91nGMwiwpS6SgihvnJDZBcQSLaAo+HH/qVFY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sjxrdq3/MDhyF8tyNCBisi0mcP70oglEk57EMWQNeOOmrfxtMqLrKj42CtHFU5edX aNbyeaHAZoR5vr72PJNTFjEqRrrcm1ffh75qnUuuYVyNIkTlTPs035yn4Cx1EPe3LG N0XBt9L6j95s+Isrupgd9tHWuGKsQH1yLrgjurpckbGlB2LXUujG7uuyG9IH5Kjfer n/xpslwF7rcSqW/fVkVnLnUGofVJOJ/zZMlFNmsE2+nIIlzAtnF0+aOg8A+KJHofpc wRXiN0RJJyMiyBT7fsQClrtXIzn1GDr1Kg2O6/i2SYanNlOoZCWOpIbqqom+EgPilv eYGdKxDCE2yhQ== From: Jeff Layton Date: Mon, 09 Dec 2024 16:13:57 -0500 Subject: [PATCH v5 05/10] nfsd: prepare delegation code for handing out *_ATTRS_DELEG delegations 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: <20241209-delstid-v5-5-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5735; i=jlayton@kernel.org; h=from:subject:message-id; bh=Ei9QY/Q91nGMwiwpS6SgihvnJDZBcQSLaAo+HH/qVFY=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12kxgkTP9BnwaOg+U1c1tDCGn6LPiBtqohr+ NzSbzWxlHWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpAAKCRAADmhBGVaC Ff0MD/9jwUZsrnaM9bVcRVVMhdvEZN25bk4yEIpcX3cNz9lDUjonJIPZipmouN4cqIB81pKtbjH gdA3ng1/8XpnXp2C63fqS15CrEvX6sIH39n0H+op/quDApRF07wYSt0xcyB4xB+ibkMsjD39C45 JuhmFfh3WXHlH+1yJenOqXdsMWF4RBKSBcqtHfXB6bm5ng1Cgaab25TxuO8dEuw8X035tkv4qgn f990c+guHaSYgk6bry5RoJmdQER1oT2nNTC9HAlV+HVKTlT6sMGcSd1wAr7f084RrU94GkRcxJ6 cYHsreSGAbUFl+nW5zaF67p7pnRtTaESWfRDXTtBY7HTae3P3ojfw0cDK0aCFeDsLCb/j71FdnR J5hTRf8sspxrxonH1mxg9Ge3Lj9Ays4Cqnh4xDI1ctuiXid4OFF4s3psXrsmoslrMdiW9UCnuqA dcowjkImEy+JtuU3SHlP6qR4rlPltyAhEZ6M16XRr3BCYq19Ky45MAQwieMDOCGpFMQ4K16VEqU AktMN3ICIqglpYwFw0ek0iqEeIXy6LIl595e7Bnd6j+DZk6jdJkgTVn7QWNHMM64y90yWAkNyXz XIyob1YVBwsvEEFXzV/8F12YfhQN/NrimUYY+hAAlh2QbkOcD3AG8vLPwCU0HznxLBJ6hUv7sQz zOIALC5oYxbzPeQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Add some preparatory code to various functions that handle delegation types to allow them to handle the OPEN_DELEGATE_*_ATTRS_DELEG constants. Add helpers for detecting whether it's a read or write deleg, and whether the attributes are delegated. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 43 ++++++++++++++++++++++++++++--------------- fs/nfsd/nfs4xdr.c | 2 ++ fs/nfsd/state.h | 16 ++++++++++++++++ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 76b07c78559a0f59c0864b6247214f7136cd3dd2..b1e71462b9d91119457a60210a0= 7021febedaf5c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2873,6 +2873,21 @@ static int nfs4_show_lock(struct seq_file *s, struct= nfs4_stid *st) return 0; } =20 +static char *nfs4_show_deleg_type(u32 dl_type) +{ + switch (dl_type) { + case OPEN_DELEGATE_READ: + return "r"; + case OPEN_DELEGATE_WRITE: + return "w"; + case OPEN_DELEGATE_READ_ATTRS_DELEG: + return "ra"; + case OPEN_DELEGATE_WRITE_ATTRS_DELEG: + return "wa"; + } + return "?"; +} + static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st) { struct nfs4_delegation *ds; @@ -2886,8 +2901,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct= nfs4_stid *st) nfs4_show_stateid(s, &st->sc_stateid); seq_puts(s, ": { type: deleg, "); =20 - seq_printf(s, "access: %s", - ds->dl_type =3D=3D OPEN_DELEGATE_READ ? "r" : "w"); + seq_printf(s, "access: %s", nfs4_show_deleg_type(ds->dl_type)); =20 /* XXX: lease time, whether it's being recalled. */ =20 @@ -5472,7 +5486,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *csta= te, static inline __be32 nfs4_check_delegmode(struct nfs4_delegation *dp, int flags) { - if ((flags & WR_STATE) && (dp->dl_type =3D=3D OPEN_DELEGATE_READ)) + if ((flags & WR_STATE) && deleg_is_read(dp->dl_type)) return nfserr_openmode; else return nfs_ok; @@ -5704,8 +5718,7 @@ static bool nfsd4_cb_channel_good(struct nfs4_client = *clp) return clp->cl_minorversion && clp->cl_cb_state =3D=3D NFSD4_CB_UNKNOWN; } =20 -static struct file_lease *nfs4_alloc_init_lease(struct nfs4_delegation *dp, - int flag) +static struct file_lease *nfs4_alloc_init_lease(struct nfs4_delegation *dp) { struct file_lease *fl; =20 @@ -5714,7 +5727,7 @@ static struct file_lease *nfs4_alloc_init_lease(struc= t nfs4_delegation *dp, return NULL; fl->fl_lmops =3D &nfsd_lease_mng_ops; fl->c.flc_flags =3D FL_DELEG; - fl->c.flc_type =3D flag =3D=3D OPEN_DELEGATE_READ ? F_RDLCK : F_WRLCK; + fl->c.flc_type =3D deleg_is_read(dp->dl_type) ? F_RDLCK : F_WRLCK; fl->c.flc_owner =3D (fl_owner_t)dp; fl->c.flc_pid =3D current->tgid; fl->c.flc_file =3D dp->dl_stid.sc_file->fi_deleg_file->nf_file; @@ -5901,7 +5914,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct n= fs4_ol_stateid *stp, if (!dp) goto out_delegees; =20 - fl =3D nfs4_alloc_init_lease(dp, dl_type); + fl =3D nfs4_alloc_init_lease(dp); if (!fl) goto out_clnt_odstate; =20 @@ -6101,14 +6114,14 @@ nfs4_open_delegation(struct nfsd4_open *open, struc= t nfs4_ol_stateid *stp, static void nfsd4_deleg_xgrade_none_ext(struct nfsd4_open *open, struct nfs4_delegation *dp) { - if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_READ_DELEG && - dp->dl_type =3D=3D OPEN_DELEGATE_WRITE) { - open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; - open->op_why_no_deleg =3D WND4_NOT_SUPP_DOWNGRADE; - } else if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG= && - dp->dl_type =3D=3D OPEN_DELEGATE_WRITE) { - open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; - open->op_why_no_deleg =3D WND4_NOT_SUPP_UPGRADE; + if (deleg_is_write(dp->dl_type)) { + if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_READ_DELEG) { + open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; + open->op_why_no_deleg =3D WND4_NOT_SUPP_DOWNGRADE; + } else if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_WRITE_DELE= G) { + open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; + open->op_why_no_deleg =3D WND4_NOT_SUPP_UPGRADE; + } } /* Otherwise the client must be confused wanting a delegation * it already has, therefore we don't return diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 39a3b21bb90590f9f2711ca1cc0f44a68819d4a0..8c48da421a07bf460ace6eddc14= 0ed5fedffd408 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4236,10 +4236,12 @@ nfsd4_encode_open_delegation4(struct xdr_stream *xd= r, struct nfsd4_open *open) status =3D nfs_ok; break; case OPEN_DELEGATE_READ: + case OPEN_DELEGATE_READ_ATTRS_DELEG: /* read */ status =3D nfsd4_encode_open_read_delegation4(xdr, open); break; case OPEN_DELEGATE_WRITE: + case OPEN_DELEGATE_WRITE_ATTRS_DELEG: /* write */ status =3D nfsd4_encode_open_write_delegation4(xdr, open); break; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index e16bb3717fb9bb4725b9498c70dd3da72552845a..d8d7e568cf15e5cd84e00ed5548= d164892ba7639 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -207,6 +207,22 @@ struct nfs4_delegation { struct nfs4_cb_fattr dl_cb_fattr; }; =20 +static inline bool deleg_is_read(u32 dl_type) +{ + return (dl_type =3D=3D OPEN_DELEGATE_READ || dl_type =3D=3D OPEN_DELEGATE= _READ_ATTRS_DELEG); +} + +static inline bool deleg_is_write(u32 dl_type) +{ + return (dl_type =3D=3D OPEN_DELEGATE_WRITE || dl_type =3D=3D OPEN_DELEGAT= E_WRITE_ATTRS_DELEG); +} + +static inline bool deleg_attrs_deleg(u32 dl_type) +{ + return dl_type =3D=3D OPEN_DELEGATE_READ_ATTRS_DELEG || + dl_type =3D=3D OPEN_DELEGATE_WRITE_ATTRS_DELEG; +} + #define cb_to_delegation(cb) \ container_of(cb, struct nfs4_delegation, dl_recall) =20 --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 390391A08AF; Mon, 9 Dec 2024 21:14:22 +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=1733778863; cv=none; b=KfeZ4ZTqeKgir2eOv8OZwMePTSSynm+fuJDPUWpd36fj/jr/Q/HYiT1lLLiJh+7axd4tB2uYhEu8FDmXCjA0XOzSoltTqh+9gaMm6bYoh/CT4QBLGH67JLEclJkv80dCX/gy6LnwENct51N0tQTyYm1bKGDQZTAwYWu/1KT7mfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778863; c=relaxed/simple; bh=9WoUPZjHr8bK84+akahdLMLMXcoDDgjY9wWCKOM+HkQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HiWdxGKrDLNvr9OXD9CFG4eHUmvKdciA+oQYIyRxAKiBpqe2Hjab5cd2ZpFlHx4aikP7iTmiq4+NGva3vpP5925TQT/WTuXXV4ubu57EeILsq7SPBtIZgvE0xY8SJNFI8k+++sQEjkJ1qRPHfVz+xkmOGm+V6lDfd/c4xs1zesI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WGVdm4Jl; 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="WGVdm4Jl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3B12C4CEE4; Mon, 9 Dec 2024 21:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778862; bh=9WoUPZjHr8bK84+akahdLMLMXcoDDgjY9wWCKOM+HkQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WGVdm4JlgZKwyrWIJtTh4T87O5x7SeMpbVTkF5QXHeP7UaF6hJJeGeae8+axUx/hE 0+BEYYwPNUDkfdSuqvzz9jatfilqBW/ntC1XA9cIOmWpTJNqQHBiBIwH2tFXSt6gra /Vs51vIBRYRnFg2M0F1vnhsd6YTlo4SQCSWpJOA0f43ku7qvvLZW0zuHm+Ngcoq0k/ VJYR0rExhIaqj2LyfSbOM4hRlII0GZfNw4527P4RYUw7g4Ya5fhAN5caCrCQt0ycyQ tImtJYoU1zLQl/acJMl7Ty3RuhotxHF6cS2A2CSq3pNpauIyn2bXdhrELftZdJUCGM OY/t1ptI1MWiA== From: Jeff Layton Date: Mon, 09 Dec 2024 16:13:58 -0500 Subject: [PATCH v5 06/10] nfsd: add support for FATTR4_OPEN_ARGUMENTS 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: <20241209-delstid-v5-6-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3826; i=jlayton@kernel.org; h=from:subject:message-id; bh=9WoUPZjHr8bK84+akahdLMLMXcoDDgjY9wWCKOM+HkQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12lqKSDRdIiTE1ufOsYdle1KCEQAxu9zlT3v 3HLsSEXd9+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpQAKCRAADmhBGVaC FdB/EACwVd+VXDypvgUJ7QQO15F0DNal7mIHMf8+1p16ZFS+9PnQqKZ23MeA+X9R3UaxUgfO6Fg tcEprOXFlkejEo/HZiWUvkpZ9RZgTH19zBraZ+aG0u7hgdcoVzaqkFcWQ0amFL+y5KLt3N+cS8Y NPcvRzOzWeENic3ZUvseztcRCSfZ6C8uem6FijAX21NtfSUBsJbqtKl8wg74l5PaQ6kAldbNVIY ESvS82TlJsFoRNBSLFoBtlORXw2PPF92QN4udBPp/jq+c0dbUvIqLbO17fJFTfTHzu8WCKW4ze5 1ytGgSyD8iriy0S4Ysn2ceI/AYwQXzrcKQn0qbWjaKxKbHgK9rvD+ICpT6H2e4DouJeT2EJz1Ly 4Jj1Z4+zQOZ/uVmFJWPpX8UU5VA+sSGk4rUohh8K4ntb2CkQP0FrsyF+qhAe1/ZKHC3l856nDHo Q3OzuMVAI3XCvnODl/8qkFK0HWtayfwTF3gJr1Lw7SjrgVgSpc4y0Z9EuT236sFJp7X64u76fEM ogkGP6b68CpwnOA/Fo+qOhjUB5FBYeP0uWIVVPztk2alC5GsDZhwB08fRGXg4LWoQE431C7jOhF 8PrArZmQlJbniWvXPxEzUmIYrPPD/czXwhQuFeS5Q0uqpLzabm1cpuoJ29uSW/ee1QPml5Kjq4C If1wa2cab7QqMLQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Add support for FATTR4_OPEN_ARGUMENTS. This a new mechanism for the client to discover what OPEN features the server supports. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4xdr.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfsd.h | 3 ++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 8c48da421a07bf460ace6eddc140ed5fedffd408..3006406aac8332e27ca9310288c= 724954f804e75 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -55,6 +55,7 @@ #include "netns.h" #include "pnfs.h" #include "filecache.h" +#include "nfs4xdr_gen.h" =20 #include "trace.h" =20 @@ -3387,6 +3388,54 @@ static __be32 nfsd4_encode_fattr4_xattr_support(stru= ct xdr_stream *xdr, return nfsd4_encode_bool(xdr, err =3D=3D 0); } =20 +#define NFSD_OA_SHARE_ACCESS (BIT(OPEN_ARGS_SHARE_ACCESS_READ) | \ + BIT(OPEN_ARGS_SHARE_ACCESS_WRITE) | \ + BIT(OPEN_ARGS_SHARE_ACCESS_BOTH)) + +#define NFSD_OA_SHARE_DENY (BIT(OPEN_ARGS_SHARE_DENY_NONE) | \ + BIT(OPEN_ARGS_SHARE_DENY_READ) | \ + BIT(OPEN_ARGS_SHARE_DENY_WRITE) | \ + BIT(OPEN_ARGS_SHARE_DENY_BOTH)) + +#define NFSD_OA_SHARE_ACCESS_WANT (BIT(OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DEL= EG) | \ + BIT(OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG) | \ + BIT(OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL)) + +#define NFSD_OA_OPEN_CLAIM (BIT(OPEN_ARGS_OPEN_CLAIM_NULL) | \ + BIT(OPEN_ARGS_OPEN_CLAIM_PREVIOUS) | \ + BIT(OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR) | \ + BIT(OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV)| \ + BIT(OPEN_ARGS_OPEN_CLAIM_FH) | \ + BIT(OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH) | \ + BIT(OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH)) + +#define NFSD_OA_CREATE_MODE (BIT(OPEN_ARGS_CREATEMODE_UNCHECKED4) | \ + BIT(OPEN_ARGS_CREATE_MODE_GUARDED) | \ + BIT(OPEN_ARGS_CREATEMODE_EXCLUSIVE4) | \ + BIT(OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1)) + +static uint32_t oa_share_access =3D NFSD_OA_SHARE_ACCESS; +static uint32_t oa_share_deny =3D NFSD_OA_SHARE_DENY; +static uint32_t oa_share_access_want =3D NFSD_OA_SHARE_ACCESS_WANT; +static uint32_t oa_open_claim =3D NFSD_OA_OPEN_CLAIM; +static uint32_t oa_create_mode =3D NFSD_OA_CREATE_MODE; + +static const struct open_arguments4 nfsd_open_arguments =3D { + .oa_share_access =3D { .count =3D 1, .element =3D &oa_share_access }, + .oa_share_deny =3D { .count =3D 1, .element =3D &oa_share_deny }, + .oa_share_access_want =3D { .count =3D 1, .element =3D &oa_share_access_w= ant }, + .oa_open_claim =3D { .count =3D 1, .element =3D &oa_open_claim }, + .oa_create_mode =3D { .count =3D 1, .element =3D &oa_create_mode }, +}; + +static __be32 nfsd4_encode_fattr4_open_arguments(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + if (!xdrgen_encode_fattr4_open_arguments(xdr, &nfsd_open_arguments)) + return nfserr_resource; + return nfs_ok; +} + static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_ops[] =3D { [FATTR4_SUPPORTED_ATTRS] =3D nfsd4_encode_fattr4_supported_attrs, [FATTR4_TYPE] =3D nfsd4_encode_fattr4_type, @@ -3487,6 +3536,7 @@ static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_o= ps[] =3D { =20 [FATTR4_MODE_UMASK] =3D nfsd4_encode_fattr4__noop, [FATTR4_XATTR_SUPPORT] =3D nfsd4_encode_fattr4_xattr_support, + [FATTR4_OPEN_ARGUMENTS] =3D nfsd4_encode_fattr4_open_arguments, }; =20 /* diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 4b56ba1e8e48d08c4e3e52f378822c311193c3d4..1955c8e9c4c793728fa75dd136c= adc735245483f 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -458,7 +458,8 @@ enum { (NFSD4_1_SUPPORTED_ATTRS_WORD2 | \ FATTR4_WORD2_MODE_UMASK | \ NFSD4_2_SECURITY_ATTRS | \ - FATTR4_WORD2_XATTR_SUPPORT) + FATTR4_WORD2_XATTR_SUPPORT | \ + FATTR4_WORD2_OPEN_ARGUMENTS) =20 extern const u32 nfsd_suppattrs[3][3]; =20 --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 695551A0BE3; Mon, 9 Dec 2024 21:14:24 +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=1733778864; cv=none; b=UsZPSEc1ieXaiWorEMzleMDFIsUXS5Fg8Rh78qo4qQYKJ57YXW7TAR+Bcmo5cFplN8pcHeKMEVNDrzv+eHE1phX9Kf2DFWyjfdi0Uemu+Hpj8mkiDX5wGFCovznVK59sNX5TTrg+TKG8A1M6yzeV3eLfQsCzvxD6IY1GSK7rfRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778864; c=relaxed/simple; bh=rQEx98rn8d9+pbS2nmZE+3Rzrcgee4u6M78asDv5644=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TcGRC57Psy+Xnf6TemF3BnEplxS7NVGXxGfnkoguz/WwQaK3TJ5jVA8qnIaUTrzHDU0VZLTQ/IPSrOCcJaSJ0V9ex7QUz7AZH5FmiF/d7t954LQkiGulpv/SYe+DDqF7AnWJwIp1vVRaujEmswKMhxXLIE5AEhZYj6zSe3T5qn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o+8OTdKs; 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="o+8OTdKs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C4C1C4CED1; Mon, 9 Dec 2024 21:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778864; bh=rQEx98rn8d9+pbS2nmZE+3Rzrcgee4u6M78asDv5644=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=o+8OTdKsrn1sltLnY7OEjSRjDrx2/i1K3HV+daj1gdJGj3iLJhl7CvC4rUbxjBqhl MaFW5ulxGEpkPORn3ydqs9+7e3OpLn+saCpdI2XfIQE7Gr5X/eiBRBaGsnjPSEUd7u oYMCAy+JnbRAAtz79LDT74PksJjrn46t5pI37NLQPceCxYGpn72N4BURxrh0ftQfFu J1t93BHJJ5v7x47IlHY+PUQy2EPoHJfi3AhRWssGMcu2w7BoeNitasgqXr2Jff+Sx+ 4kaH5UHlHiS3bBJkykV2nOheVq0XeWIOk0ZCWdIAaAAynPCP6JahRxSK1JjFk+ZC3b zyqirx3n10U6w== From: Jeff Layton Date: Mon, 09 Dec 2024 16:13:59 -0500 Subject: [PATCH v5 07/10] nfsd: rework NFS4_SHARE_WANT_* flag handling 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: <20241209-delstid-v5-7-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3253; i=jlayton@kernel.org; h=from:subject:message-id; bh=rQEx98rn8d9+pbS2nmZE+3Rzrcgee4u6M78asDv5644=; b=kA0DAAgBAA5oQRlWghUByyZiAGdXXaWiZQK7EixCCJzVU33DBioa0QVfbEGFjYd6POSvVydKr YkCMwQAAQgAHRYhBEvA17JEcbKhhOr10wAOaEEZVoIVBQJnV12lAAoJEAAOaEEZVoIV96QQAIPs Z2D8rdr8xesCz4br6nT1rY46GeGtI4vBBm13lLl/uRD69/HxrOEKonImHusiwreDRJ4+5O3lVtW EwUloHYnRilp6qZfbx8M6hgkY7+QKSxU80aFNdywqDo5lFnu3oiIcPNwHUuWOms4albC7F2vBY1 vr4/SkOygTSStKt0h6+uPLFGT6OxL4uY2ImP/pZBoTyAsNr1nHVDoPPL95sI2OuhgrkuYJZHhri qoELDiZYbyZLPoCt3gM9sRjYySLgoCqbaJaoQ8ne2dBxhiazhraQNLHRxrdm5FrgQftnkJy+gmY E6whZ9TiuR0BiaP98GLgALq8RGq85OuGqZyM1KJVcvYb2s0V3ItZhQbu0sLiBsY03VXWDFlKY+o ksLG1DJ9bWNFmU9PizHPSsDXAYP0IRZoWVcLUDQ+fTtKkbmmUJ6kkvi/MZnKfiEbJ2+n34mG1eD k8NwWThzlbM+IRd17rBxHrZ4EH9beDfyvQCqYxvOwsXW3Rp1xFfMXtzAEV+3xtEcFTKTr1F1j5Y Z9M+YdORFWEhyd4xVMTrxHx67erQjCuqa2zYvk/ZGQrmx2KdfOw5O9V4zta1AA1eBtnh/oNg2CV QNUtVyzruR3Tlc84euMMf1IFBqfbnu8t74I1CbGIyjHvNaD0MrI7f3RzXv+RM3igj+CeSIhTmvm rrnit X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 The delstid draft adds new NFS4_SHARE_WANT_TYPE_MASK values that don't fit neatly into the existing WANT_MASK or WHEN_MASK. Add a new NFS4_SHARE_WANT_MOD_MASK value and redefine NFS4_SHARE_WANT_MASK to include it. Also fix the checks in nfsd4_deleg_xgrade_none_ext() to check for the flags instead of equality, since there may be modifier flags in the value. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 4 ++-- fs/nfsd/nfs4xdr.c | 2 +- include/uapi/linux/nfs4.h | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index b1e71462b9d91119457a60210a07021febedaf5c..4c36e50b9eda119948461411ae8= bc851907b2eb3 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6115,10 +6115,10 @@ static void nfsd4_deleg_xgrade_none_ext(struct nfsd= 4_open *open, struct nfs4_delegation *dp) { if (deleg_is_write(dp->dl_type)) { - if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_READ_DELEG) { + if (open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_READ_DELEG) { open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_SUPP_DOWNGRADE; - } else if (open->op_deleg_want =3D=3D OPEN4_SHARE_ACCESS_WANT_WRITE_DELE= G) { + } else if (open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG) { open->op_delegate_type =3D OPEN_DELEGATE_NONE_EXT; open->op_why_no_deleg =3D WND4_NOT_SUPP_UPGRADE; } diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 3006406aac8332e27ca9310288c724954f804e75..7b867d0e5099608cc199c216a61= 40f3d45292376 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1067,7 +1067,7 @@ static __be32 nfsd4_decode_share_access(struct nfsd4_= compoundargs *argp, u32 *sh return nfs_ok; if (!argp->minorversion) return nfserr_bad_xdr; - switch (w & NFS4_SHARE_WANT_MASK) { + switch (w & NFS4_SHARE_WANT_TYPE_MASK) { case OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE: case OPEN4_SHARE_ACCESS_WANT_READ_DELEG: case OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG: diff --git a/include/uapi/linux/nfs4.h b/include/uapi/linux/nfs4.h index caf4db2fcbb94686631ec2232a8ff189c97c8617..4273e0249fcbb54996f5642f992= 0826b9d68b7b9 100644 --- a/include/uapi/linux/nfs4.h +++ b/include/uapi/linux/nfs4.h @@ -58,7 +58,7 @@ #define NFS4_SHARE_DENY_BOTH 0x0003 =20 /* nfs41 */ -#define NFS4_SHARE_WANT_MASK 0xFF00 +#define NFS4_SHARE_WANT_TYPE_MASK 0xFF00 #define NFS4_SHARE_WANT_NO_PREFERENCE 0x0000 #define NFS4_SHARE_WANT_READ_DELEG 0x0100 #define NFS4_SHARE_WANT_WRITE_DELEG 0x0200 @@ -66,13 +66,16 @@ #define NFS4_SHARE_WANT_NO_DELEG 0x0400 #define NFS4_SHARE_WANT_CANCEL 0x0500 =20 -#define NFS4_SHARE_WHEN_MASK 0xF0000 +#define NFS4_SHARE_WHEN_MASK 0xF0000 #define NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL 0x10000 #define NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED 0x20000 =20 +#define NFS4_SHARE_WANT_MOD_MASK 0xF00000 #define NFS4_SHARE_WANT_DELEG_TIMESTAMPS 0x100000 #define NFS4_SHARE_WANT_OPEN_XOR_DELEGATION 0x200000 =20 +#define NFS4_SHARE_WANT_MASK (NFS4_SHARE_WANT_TYPE_MASK | NFS4_SHARE_WANT_= MOD_MASK) + #define NFS4_CDFC4_FORE 0x1 #define NFS4_CDFC4_BACK 0x2 #define NFS4_CDFC4_BOTH 0x3 --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 BC03A1A2872; Mon, 9 Dec 2024 21:14: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=1733778865; cv=none; b=LN2mCmroYmhAsLwjlQgr6E5pLG1ebCCKiPxgUM48BkgEuVwtzECCqproeR4xMtbp1ULM3q1m18feyKfzfp2uwzsc9pTOpwTyWcg5Mm1B1+7T9xZJZ0dGpmmZ8IbYMRNVaLizV6QADBbhFk9iKohnwrmd5ywakxh1PJKQSTkR4e8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778865; c=relaxed/simple; bh=jEIHZHGB3LcQ5OA6n0zIqwT6xIC1e/cBXnH0LpUlWAo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eBcC2vmbHU3waeNGBGJyFk+Pa9c08QtB4VcE/xkuIOCNockFeDgq43IYyHr9ZlGV9vS18yRLn4teQZR7hVBdJCwVkqePHfrgUuuo9WD407LL1lkOgOSodh2jm/TFwz8bdexTvrykMIL+ng6dwhVHDkBNZpa90+XUJxkjpPJk6Q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p3on9JWu; 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="p3on9JWu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48C27C4CEE2; Mon, 9 Dec 2024 21:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778865; bh=jEIHZHGB3LcQ5OA6n0zIqwT6xIC1e/cBXnH0LpUlWAo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=p3on9JWuv/6k2Dv5Tyfty/33mRf66NZwgIZpmcTSe0X1p5+3RA6t7BObl+h17rzs7 eICs92ZM56LjMBitS/jVx2EyP1OU6R/pzsFgj5tp9+Y9Kkxp3xtjUlR7EEmp6p7idu S22cZzQW0C8N4M11Q/KIcD+jwoTGNqWEuNUPIAk0hTAjD37W2HLWEV5s0rvMC5Rd5N VSgmnGULGHjByENHxIxKMcl/N11u8wyPdck1nHd4h/AlJ6SvCyZDSWrHGli/KO8LTr 4w+MxKruwZmg6hinWK6ioq9rYL28tVVPrGbLyKF7I0ehWhLrfPyBBKWYfVTQS38sps eZbvKfEtqTNFA== From: Jeff Layton Date: Mon, 09 Dec 2024 16:14:00 -0500 Subject: [PATCH v5 08/10] nfsd: add support 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: <20241209-delstid-v5-8-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=14535; i=jlayton@kernel.org; h=from:subject:message-id; bh=jEIHZHGB3LcQ5OA6n0zIqwT6xIC1e/cBXnH0LpUlWAo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12lrukETtO4v7y15z0rkNJ6T3c9oVCfFQh1h SKl0RU4Q7yJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpQAKCRAADmhBGVaC FZ/wEACYkSd4VQSCK7FgaKN4TdmwYwKXPfPyQXrlCvU/TIy4NRJnA6PHLgXleOvWY0mozOsvaW4 6vwZJgc6t0i28iAq+oZS2hS78ztJ13BaARH8vgvTnl1Uy6ksYzg9c1egpIY9ZQYIQ4U3YUCYmPf pRJkH4ePROFJlNbqZiigkJ04Is8U+1L/3eqqSDI+FsVxTU8wuFrW+GIFB/+NwqIrlp0AvdZBC4/ cgCmCOHTV8Vl1lvZVlXTUaUT8yDKbC+lgEQ09CXktM+JUI6yHerv72a9en0wW0OuR2E7cP7MfEu C3FSwU7cU6hYuChobPNt2Fe9RRaacNOPdctLm/hiCoTrDObUDgTjez5GKCmiB0subwQHkpBbuaj 5/yYNsQsH5VEzCBLhyPOo+4xKbpKSKvsVRRv2SLFD3In/LQ8I+M+E4IzcQ8sqKw1ygXbyVFh4qX w5QN0sL+bGTilzBZ41uouFpDoxf2u0z45UAKbuavxGztEAdapx3qXP2eWfvc/2BD9Vlx1ANi3ko UrA71FTGAuqJh58Y6ERKk4s+JP79R0zTiNYYltVUHK1MUixBt9wxB2z74ybuMcW5Cn4kqVqEMTS dwqsSqugJkcI5V2XeW15cllMlggo5wKUrryGEr2VgakQysDqu3NDC3QN1PHmblLZeAO+T5whQQe ZtXnaNMk5PLqm2Q== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Add support for the delegated timestamps on write delegations. This allows the server to proxy timestamps from the delegation holder to other clients that are doing GETATTRs vs. the same inode. When OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS bit is set in the OPEN call, set the dl_type to the *_ATTRS_DELEG flavor of delegation. Add timespec64 fields to nfs4_cb_fattr and decode the timestamps into those. Vet those timestamps according to the delstid spec and update the inode attrs if necessary. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 42 +++++++++++++++++++-- fs/nfsd/nfs4state.c | 99 +++++++++++++++++++++++++++++++++++++++++++---= ---- fs/nfsd/nfs4xdr.c | 15 +++++++- fs/nfsd/nfsd.h | 2 + fs/nfsd/state.h | 2 + fs/nfsd/xdr4cb.h | 10 +++-- include/linux/time64.h | 5 +++ 7 files changed, 152 insertions(+), 23 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 25acb8624b854f5d0d184efec660e1f72cad8885..0d1ebeaca14a40980d08e223cb6= 598e20c6ce21a 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -42,6 +42,7 @@ #include "trace.h" #include "xdr4cb.h" #include "xdr4.h" +#include "nfs4xdr_gen.h" =20 #define NFSDDBG_FACILITY NFSDDBG_PROC =20 @@ -93,12 +94,35 @@ static int decode_cb_fattr4(struct xdr_stream *xdr, uin= t32_t *bitmap, { fattr->ncf_cb_change =3D 0; fattr->ncf_cb_fsize =3D 0; + fattr->ncf_cb_atime.tv_sec =3D 0; + fattr->ncf_cb_atime.tv_nsec =3D 0; + fattr->ncf_cb_mtime.tv_sec =3D 0; + fattr->ncf_cb_mtime.tv_nsec =3D 0; + if (bitmap[0] & FATTR4_WORD0_CHANGE) if (xdr_stream_decode_u64(xdr, &fattr->ncf_cb_change) < 0) return -NFSERR_BAD_XDR; if (bitmap[0] & FATTR4_WORD0_SIZE) if (xdr_stream_decode_u64(xdr, &fattr->ncf_cb_fsize) < 0) return -NFSERR_BAD_XDR; + if (bitmap[2] & FATTR4_WORD2_TIME_DELEG_ACCESS) { + fattr4_time_deleg_access access; + + if (!xdrgen_decode_fattr4_time_deleg_access(xdr, &access)) + return -NFSERR_BAD_XDR; + fattr->ncf_cb_atime.tv_sec =3D access.seconds; + fattr->ncf_cb_atime.tv_nsec =3D access.nseconds; + + } + if (bitmap[2] & FATTR4_WORD2_TIME_DELEG_MODIFY) { + fattr4_time_deleg_modify modify; + + if (!xdrgen_decode_fattr4_time_deleg_modify(xdr, &modify)) + return -NFSERR_BAD_XDR; + fattr->ncf_cb_mtime.tv_sec =3D modify.seconds; + fattr->ncf_cb_mtime.tv_nsec =3D modify.nseconds; + + } return 0; } =20 @@ -364,15 +388,21 @@ encode_cb_getattr4args(struct xdr_stream *xdr, struct= nfs4_cb_compound_hdr *hdr, struct nfs4_delegation *dp =3D container_of(fattr, struct nfs4_delegation= , dl_cb_fattr); struct knfsd_fh *fh =3D &dp->dl_stid.sc_file->fi_fhandle; struct nfs4_cb_fattr *ncf =3D &dp->dl_cb_fattr; - u32 bmap[1]; + u32 bmap_size =3D 1; + u32 bmap[3]; =20 bmap[0] =3D FATTR4_WORD0_SIZE; if (!ncf->ncf_file_modified) bmap[0] |=3D FATTR4_WORD0_CHANGE; =20 + if (deleg_attrs_deleg(dp->dl_type)) { + bmap[1] =3D 0; + bmap[2] =3D FATTR4_WORD2_TIME_DELEG_ACCESS | FATTR4_WORD2_TIME_DELEG_MOD= IFY; + bmap_size =3D 3; + } encode_nfs_cb_opnum4(xdr, OP_CB_GETATTR); encode_nfs_fh4(xdr, fh); - encode_bitmap4(xdr, bmap, ARRAY_SIZE(bmap)); + encode_bitmap4(xdr, bmap, bmap_size); hdr->nops++; } =20 @@ -636,7 +666,7 @@ static int nfs4_xdr_dec_cb_getattr(struct rpc_rqst *rqs= tp, struct nfs4_cb_compound_hdr hdr; int status; u32 bitmap[3] =3D {0}; - u32 attrlen; + u32 attrlen, maxlen; struct nfs4_cb_fattr *ncf =3D container_of(cb, struct nfs4_cb_fattr, ncf_getattr); =20 @@ -655,7 +685,11 @@ static int nfs4_xdr_dec_cb_getattr(struct rpc_rqst *rq= stp, return -NFSERR_BAD_XDR; if (xdr_stream_decode_u32(xdr, &attrlen) < 0) return -NFSERR_BAD_XDR; - if (attrlen > (sizeof(ncf->ncf_cb_change) + sizeof(ncf->ncf_cb_fsize))) + maxlen =3D sizeof(ncf->ncf_cb_change) + sizeof(ncf->ncf_cb_fsize); + if (bitmap[2] !=3D 0) + maxlen +=3D (sizeof(ncf->ncf_cb_mtime.tv_sec) + + sizeof(ncf->ncf_cb_mtime.tv_nsec)) * 2; + if (attrlen > maxlen) return -NFSERR_BAD_XDR; status =3D decode_cb_fattr4(xdr, bitmap, ncf); return status; diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 4c36e50b9eda119948461411ae8bc851907b2eb3..c882eeba7830b0249ccd74654f8= 1e63b12a30f14 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5842,13 +5842,14 @@ static struct nfs4_delegation * nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, struct svc_fh *parent) { - int status =3D 0; + bool deleg_ts =3D open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_DELEG_TIM= ESTAMPS; struct nfs4_client *clp =3D stp->st_stid.sc_client; struct nfs4_file *fp =3D stp->st_stid.sc_file; struct nfs4_clnt_odstate *odstate =3D stp->st_clnt_odstate; struct nfs4_delegation *dp; struct nfsd_file *nf =3D NULL; struct file_lease *fl; + int status =3D 0; u32 dl_type; =20 /* @@ -5873,7 +5874,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct n= fs4_ol_stateid *stp, */ if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) =3D=3D NFS4_SHARE_AC= CESS_BOTH) { nf =3D find_rw_file(fp); - dl_type =3D OPEN_DELEGATE_WRITE; + dl_type =3D deleg_ts ? OPEN_DELEGATE_WRITE_ATTRS_DELEG : OPEN_DELEGATE_W= RITE; } =20 /* @@ -5882,7 +5883,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct n= fs4_ol_stateid *stp, */ if (!nf && (open->op_share_access & NFS4_SHARE_ACCESS_READ)) { nf =3D find_readable_file(fp); - dl_type =3D OPEN_DELEGATE_READ; + dl_type =3D deleg_ts ? OPEN_DELEGATE_READ_ATTRS_DELEG : OPEN_DELEGATE_RE= AD; } =20 if (!nf) @@ -6040,13 +6041,14 @@ static void nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, struct svc_fh *currentfh) { - struct nfs4_delegation *dp; + bool deleg_ts =3D open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_DELEG_TIM= ESTAMPS; struct nfs4_openowner *oo =3D openowner(stp->st_stateowner); struct nfs4_client *clp =3D stp->st_stid.sc_client; struct svc_fh *parent =3D NULL; - int cb_up; - int status =3D 0; + struct nfs4_delegation *dp; struct kstat stat; + int status =3D 0; + int cb_up; =20 cb_up =3D nfsd4_cb_channel_good(oo->oo_owner.so_client); open->op_recall =3D false; @@ -6087,12 +6089,14 @@ nfs4_open_delegation(struct nfsd4_open *open, struc= t nfs4_ol_stateid *stp, destroy_delegation(dp); goto out_no_deleg; } - open->op_delegate_type =3D OPEN_DELEGATE_WRITE; + open->op_delegate_type =3D deleg_ts ? OPEN_DELEGATE_WRITE_ATTRS_DELEG : + 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); trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid); } else { - open->op_delegate_type =3D OPEN_DELEGATE_READ; + open->op_delegate_type =3D deleg_ts ? OPEN_DELEGATE_READ_ATTRS_DELEG : + OPEN_DELEGATE_READ; trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid); } nfs4_put_stid(&dp->dl_stid); @@ -8901,6 +8905,78 @@ nfsd4_get_writestateid(struct nfsd4_compound_state *= cstate, get_stateid(cstate, &u->write.wr_stateid); } =20 +/** + * set_cb_time - vet and set the timespec for a cb_getattr update + * @cb: timestamp from the CB_GETATTR response + * @orig: original timestamp in the inode + * @now: current time + * + * Given a timestamp in a CB_GETATTR 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. + */ +static bool set_cb_time(struct timespec64 *cb, const struct timespec64 *or= ig, + const struct timespec64 *now) +{ + + /* + * "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) + return false; + + /* + * "When the time presented is in the future, the server can either + * 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; + } + + return true; +} + +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; + + if (deleg_attrs_deleg(dp->dl_type)) { + struct timespec64 atime =3D inode_get_atime(inode); + struct timespec64 mtime =3D inode_get_mtime(inode); + + attrs.ia_atime =3D ncf->ncf_cb_atime; + attrs.ia_mtime =3D ncf->ncf_cb_mtime; + + if (set_cb_time(&attrs.ia_atime, &atime, &now)) + attrs.ia_valid |=3D ATTR_ATIME | ATTR_ATIME_SET; + + if (set_cb_time(&attrs.ia_mtime, &mtime, &now)) { + attrs.ia_valid |=3D ATTR_CTIME | 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; + } + + if (!attrs.ia_valid) + return 0; + + attrs.ia_valid |=3D ATTR_DELEG; + inode_lock(inode); + ret =3D notify_change(&nop_mnt_idmap, dentry, &attrs, NULL); + inode_unlock(inode); + return ret; +} + /** * nfsd4_deleg_getattr_conflict - Recall if GETATTR causes conflict * @rqstp: RPC transaction context @@ -8927,7 +9003,6 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, = struct dentry *dentry, struct file_lock_context *ctx; struct nfs4_delegation *dp =3D NULL; struct file_lease *fl; - struct iattr attrs; struct nfs4_cb_fattr *ncf; struct inode *inode =3D d_inode(dentry); =20 @@ -8989,11 +9064,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp,= struct dentry *dentry, * not update the file's metadata with the client's * modified size */ - attrs.ia_mtime =3D attrs.ia_ctime =3D current_time(inode); - attrs.ia_valid =3D ATTR_MTIME | ATTR_CTIME | ATTR_DELEG; - inode_lock(inode); - err =3D notify_change(&nop_mnt_idmap, dentry, &attrs, NULL); - inode_unlock(inode); + err =3D cb_getattr_update_times(dentry, dp); if (err) { status =3D nfserrno(err); goto out_status; diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 7b867d0e5099608cc199c216a6140f3d45292376..0561c99b5def2eccf679bf3ea0e= 5b1a57d5d8374 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3399,7 +3399,8 @@ static __be32 nfsd4_encode_fattr4_xattr_support(struc= t xdr_stream *xdr, =20 #define NFSD_OA_SHARE_ACCESS_WANT (BIT(OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DEL= EG) | \ BIT(OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG) | \ - BIT(OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL)) + BIT(OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL) | \ + BIT(OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS)) =20 #define NFSD_OA_OPEN_CLAIM (BIT(OPEN_ARGS_OPEN_CLAIM_NULL) | \ BIT(OPEN_ARGS_OPEN_CLAIM_PREVIOUS) | \ @@ -3592,7 +3593,11 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct x= dr_stream *xdr, if (status) goto out; } - if (attrmask[0] & (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE)) { + if ((attrmask[0] & (FATTR4_WORD0_CHANGE | + FATTR4_WORD0_SIZE)) || + (attrmask[1] & (FATTR4_WORD1_TIME_ACCESS | + FATTR4_WORD1_TIME_MODIFY | + FATTR4_WORD1_TIME_METADATA))) { status =3D nfsd4_deleg_getattr_conflict(rqstp, dentry, &dp); if (status) goto out; @@ -3607,8 +3612,14 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct x= dr_stream *xdr, if (ncf->ncf_file_modified) { ++ncf->ncf_initial_cinfo; args.stat.size =3D ncf->ncf_cur_fsize; + if (!timespec64_is_epoch(&ncf->ncf_cb_mtime)) + args.stat.mtime =3D ncf->ncf_cb_mtime; } args.change_attr =3D ncf->ncf_initial_cinfo; + + if (!timespec64_is_epoch(&ncf->ncf_cb_atime)) + args.stat.atime =3D ncf->ncf_cb_atime; + nfs4_put_stid(&dp->dl_stid); } else { args.change_attr =3D nfsd4_change_attribute(&args.stat); diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 1955c8e9c4c793728fa75dd136cadc735245483f..004415651295891b3440f52a4c9= 86e3a668a48cb 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -459,6 +459,8 @@ enum { FATTR4_WORD2_MODE_UMASK | \ NFSD4_2_SECURITY_ATTRS | \ FATTR4_WORD2_XATTR_SUPPORT | \ + FATTR4_WORD2_TIME_DELEG_ACCESS | \ + FATTR4_WORD2_TIME_DELEG_MODIFY | \ FATTR4_WORD2_OPEN_ARGUMENTS) =20 extern const u32 nfsd_suppattrs[3][3]; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index d8d7e568cf15e5cd84e00ed5548d164892ba7639..554041da8593e14987439cb1c15= 2d1a072bd00ad 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -159,6 +159,8 @@ struct nfs4_cb_fattr { /* from CB_GETATTR reply */ u64 ncf_cb_change; u64 ncf_cb_fsize; + struct timespec64 ncf_cb_mtime; + struct timespec64 ncf_cb_atime; =20 unsigned long ncf_cb_flags; bool ncf_file_modified; diff --git a/fs/nfsd/xdr4cb.h b/fs/nfsd/xdr4cb.h index e8b00309c449fe2667f7d48cda88ec0cff924f93..f1a315cd31b74f73f1d52702ae7= b5c93d51ddf82 100644 --- a/fs/nfsd/xdr4cb.h +++ b/fs/nfsd/xdr4cb.h @@ -59,16 +59,20 @@ * 1: CB_GETATTR opcode (32-bit) * N: file_handle * 1: number of entry in attribute array (32-bit) - * 1: entry 0 in attribute array (32-bit) + * 3: entry 0-2 in attribute array (32-bit * 3) */ #define NFS4_enc_cb_getattr_sz (cb_compound_enc_hdr_sz + \ cb_sequence_enc_sz + \ - 1 + enc_nfs4_fh_sz + 1 + 1) + 1 + enc_nfs4_fh_sz + 1 + 3) /* * 4: fattr_bitmap_maxsz * 1: attribute array len * 2: change attr (64-bit) * 2: size (64-bit) + * 2: atime.seconds (64-bit) + * 1: atime.nanoseconds (32-bit) + * 2: mtime.seconds (64-bit) + * 1: mtime.nanoseconds (32-bit) */ #define NFS4_dec_cb_getattr_sz (cb_compound_dec_hdr_sz + \ - cb_sequence_dec_sz + 4 + 1 + 2 + 2 + op_dec_sz) + cb_sequence_dec_sz + 4 + 1 + 2 + 2 + 2 + 1 + 2 + 1 + op_dec_sz) diff --git a/include/linux/time64.h b/include/linux/time64.h index f1bcea8c124a361b6c1e3c98ef915840c22a8413..9934331c7b86b7fb981c7aec049= 4ac2f5e72977e 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -49,6 +49,11 @@ static inline int timespec64_equal(const struct timespec= 64 *a, return (a->tv_sec =3D=3D b->tv_sec) && (a->tv_nsec =3D=3D b->tv_nsec); } =20 +static inline bool timespec64_is_epoch(const struct timespec64 *ts) +{ + return ts->tv_sec =3D=3D 0 && ts->tv_nsec =3D=3D 0; +} + /* * lhs < rhs: return <0 * lhs =3D=3D rhs: return 0 --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 0AD2F1A3BC0; Mon, 9 Dec 2024 21:14:26 +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=1733778867; cv=none; b=TDSMKJl6cl4IovN1ue+Lh0sVmjXK7m4iCTHbrdpACr4BNhlw+xrE3J2rWkXLGQD4D9n1RPFHitq5dp8QCSSmy4Dg7OV1xX2h0QWeMduT/cSLJZy0/dThu7/BRDxwyfaI7X8XPhTuD68oEwSYZxQKaKNz23EQrIKO3JPm9nn6Qhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778867; c=relaxed/simple; bh=9NJX85GvEHx3pviPGV6znyL1sYiMugX+xws57Sc8Y6k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OQMgMsicOadmz72zZhULJxCpMUtECkqwyn5p6Eud68okZ039xqwoZkYh6ewZRgdCLqcOGjnO9hi6AZDK9mb0B2imx65j2ue5GqPbqabBOX9XEaJ7NZmm5AAHoczDrFXX00gZJ6Q3G7wjQ9C1/57kntjHr8t/ISQKnIP7DxXK3mE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ORJ1BZml; 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="ORJ1BZml" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86078C4CEE1; Mon, 9 Dec 2024 21:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778866; bh=9NJX85GvEHx3pviPGV6znyL1sYiMugX+xws57Sc8Y6k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ORJ1BZmliSs5CZ7Ob/RLZAHsTaW7rdsdQ6zPXo4yChNf2SbCNLF/cXDcBIVAo5mhD z7ugMqGBJxxDn3JQvZdL/koxo3XJwsjp7sn0+RNfRmz4P2Gi3hWC6YSRTmBTPMg7Zd 5zPcIxVb/v7lKy8o3sFApt9442j2hQNE8ynN41PdpHoGesOA+sxWhudKryxg3CnDPF VsffYDr8UipL3yQqnklHXrmE5hSnUpAGHwBUQlnr9epY2SY25ygpzep+k7DYfTLALq nhNaC50jo4rk6KB3NuKZbgTClsVaC5XbjHBpxCIphT0T+rwFDLb31Za73hFqsJLAov Qi1YXwe32UJYA== From: Jeff Layton Date: Mon, 09 Dec 2024 16:14:01 -0500 Subject: [PATCH v5 09/10] nfsd: handle delegated timestamps in SETATTR 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: <20241209-delstid-v5-9-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4513; i=jlayton@kernel.org; h=from:subject:message-id; bh=9NJX85GvEHx3pviPGV6znyL1sYiMugX+xws57Sc8Y6k=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12lfVqz00RZH6/V7ywker8cJwTZE0Nm/wpBT WjnTmZLPomJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpQAKCRAADmhBGVaC FV3lD/9jigxpb6CXnv0+V/iQzXFYgI6ThtyE4LAYzVMeQjIo4dHzushIs6FIykK+sYUuoLDq8cT 2S8ZyKC6z29Tgfu4WwkRRQzyZqBmVU+ktxO/LSwLeCtzdcBLl+ntkYYF4Pb+ePL+rBtOZk3+f3y /q94u/HELjlLuLF8p8WdhwP+eYlviuyJDkB/i+Ro0itJ8UJmdSCU9Xx8lUxe7Ubwjubo1hu1GL1 DP/fgnvU/2xrFAYC5gqUn9vmNWqDlwfJwqAkXt4SaJF/mLHb1/Tz/C6QA8uhpabSEmILhvTFBVp +yZAuDwiTZUvz+1bKEFUTK5TPLPJgBdzVGV5ktW1bSP540X2l0ZgDCy9icIww3WVG7apgoFeLvt TNGJGCaailzitpWoPM31JRS1t3hSiaA8Jj3/xBc9B9JoMFIV0VZ8wHqgWjJWlO9rkpQ1hgR+EPE Ooinbz2SSch1TbLZNI68pkOye+n/01zL2el1ec41WNbCm2MH96Vq/vt5KDWqTXOaOHst/K4DOO4 z7IQdEAh/ENeLYl8s1RvkYSvO3SODlHbgb4LjBeTWoJ7edjeRQMIcjNpopO2tbXSHn7tmMw9Wa+ q/1fBZWJb7txsNwB1hNtsDlMCLWRN138Ai1gDg3BNKpr4TWGcQEasJCEWK5We06wJfwo9WWZw4W 1XaBkLK9qNyVVGA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Allow SETATTR to handle delegated timestamps. This patch assumes that only the delegation holder has the ability to set the timestamps in this way, so we allow this only if the SETATTR stateid refers to a *_ATTRS_DELEG delegation. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4proc.c | 31 ++++++++++++++++++++++++++++--- fs/nfsd/nfs4state.c | 2 +- fs/nfsd/nfs4xdr.c | 20 ++++++++++++++++++++ fs/nfsd/nfsd.h | 5 ++++- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index f8a10f90bc7a4b288c20d2733c85f331cc0a8dba..fea171ffed623818c61886b7863= 39b0b73f1053d 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1135,18 +1135,43 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_= compound_state *cstate, .na_iattr =3D &setattr->sa_iattr, .na_seclabel =3D &setattr->sa_label, }; + bool save_no_wcc, deleg_attrs; + struct nfs4_stid *st =3D NULL; struct inode *inode; __be32 status =3D nfs_ok; - bool save_no_wcc; int err; =20 - if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { + deleg_attrs =3D setattr->sa_bmval[2] & (FATTR4_WORD2_TIME_DELEG_ACCESS | + FATTR4_WORD2_TIME_DELEG_MODIFY); + + if (deleg_attrs || (setattr->sa_iattr.ia_valid & ATTR_SIZE)) { + int flags =3D WR_STATE; + + if (setattr->sa_bmval[2] & FATTR4_WORD2_TIME_DELEG_ACCESS) + flags |=3D RD_STATE; + status =3D nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, &setattr->sa_stateid, - WR_STATE, NULL, NULL); + flags, NULL, &st); if (status) return status; } + + if (deleg_attrs) { + status =3D nfserr_bad_stateid; + if (st->sc_type & SC_TYPE_DELEG) { + struct nfs4_delegation *dp =3D delegstateid(st); + + /* Only for *_ATTRS_DELEG flavors */ + if (deleg_attrs_deleg(dp->dl_type)) + status =3D nfs_ok; + } + } + if (st) + nfs4_put_stid(st); + if (status) + return status; + err =3D fh_want_write(&cstate->current_fh); if (err) return nfserrno(err); diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c882eeba7830b0249ccd74654f81e63b12a30f14..a76e35f86021c5657e31e4fddf0= 8cb5781f01e32 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5486,7 +5486,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *csta= te, static inline __be32 nfs4_check_delegmode(struct nfs4_delegation *dp, int flags) { - if ((flags & WR_STATE) && deleg_is_read(dp->dl_type)) + if (!(flags & RD_STATE) && deleg_is_read(dp->dl_type)) return nfserr_openmode; else return nfs_ok; diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 0561c99b5def2eccf679bf3ea0e5b1a57d5d8374..ce93a31ac5cec75b0f944d288e7= 96e7a73641572 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -521,6 +521,26 @@ nfsd4_decode_fattr4(struct nfsd4_compoundargs *argp, u= 32 *bmval, u32 bmlen, *umask =3D mask & S_IRWXUGO; iattr->ia_valid |=3D ATTR_MODE; } + if (bmval[2] & FATTR4_WORD2_TIME_DELEG_ACCESS) { + fattr4_time_deleg_access access; + + if (!xdrgen_decode_fattr4_time_deleg_access(argp->xdr, &access)) + return nfserr_bad_xdr; + iattr->ia_atime.tv_sec =3D access.seconds; + iattr->ia_atime.tv_nsec =3D access.nseconds; + iattr->ia_valid |=3D ATTR_ATIME | ATTR_ATIME_SET | ATTR_DELEG; + } + if (bmval[2] & FATTR4_WORD2_TIME_DELEG_MODIFY) { + fattr4_time_deleg_modify modify; + + if (!xdrgen_decode_fattr4_time_deleg_modify(argp->xdr, &modify)) + return nfserr_bad_xdr; + 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_valid |=3D ATTR_CTIME | ATTR_MTIME | ATTR_MTIME_SET | ATTR_DEL= EG; + } =20 /* request sanity: did attrlist4 contain the expected number of words? */ if (attrlist4_count !=3D xdr_stream_pos(argp->xdr) - starting_pos) diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 004415651295891b3440f52a4c986e3a668a48cb..f007699aa397fe39042d80ccd56= 8db4654d19dd5 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -531,7 +531,10 @@ static inline bool nfsd_attrs_supported(u32 minorversi= on, const u32 *bmval) #endif #define NFSD_WRITEABLE_ATTRS_WORD2 \ (FATTR4_WORD2_MODE_UMASK \ - | MAYBE_FATTR4_WORD2_SECURITY_LABEL) + | MAYBE_FATTR4_WORD2_SECURITY_LABEL \ + | FATTR4_WORD2_TIME_DELEG_ACCESS \ + | FATTR4_WORD2_TIME_DELEG_MODIFY \ + ) =20 #define NFSD_SUPPATTR_EXCLCREAT_WORD0 \ NFSD_WRITEABLE_ATTRS_WORD0 --=20 2.47.1 From nobody Fri Dec 27 11:25:16 2024 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 E578319C54A; Mon, 9 Dec 2024 21:14: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=1733778868; cv=none; b=cmrWk8Svu10Dsodc2tNMb5UTvXcQ/C1N/xwbCJ2Ghtuo6MVBKm6Rh9L3/HRHHLHQm27rIvFGSOANovK1YpimuBunx4fgG+qhPxWSXgCB/pFygYUMvJu1i+sBw2eDr+Nkh0EXWGRJup6Ln5hyYlYZs8ppNh0vrB1rwuJfzScIX6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733778868; c=relaxed/simple; bh=VEHOwStO+gCYUuq2M8p9wjztvUB56YWilUi6AG2I/f8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ilQTNWsZy3k0awsDPg6jzPOd6kXRSvj5NI+E0WGQBp4BDO0eX3IV4re4TgHen/PN7yIko/mOLwd8KSM7U2Be3LdTr/ta6keynMg2Vb4dnZupKFwS8O9kCEmQBjBbu8ofI9Z6ryuDbPBpAAjA8CuS9J8un4V+YNDUYaSM5BdxXqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IDCKm370; 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="IDCKm370" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2C94C4CEE2; Mon, 9 Dec 2024 21:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733778867; bh=VEHOwStO+gCYUuq2M8p9wjztvUB56YWilUi6AG2I/f8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IDCKm3705RmAGHAtlm3HPX56Y4wGyMY07MwgDLsr+9ulGNmhYZujqblChXOA7VJS1 dr1SQNE84PmnZsIJAGoxHBZV7Fl1ChiXMOHYyvmajYUaewLoSnpk/yzBh+99snAXc8 QVikNsErrUQpFXAbtrKPAze6HkH+8kgoOMaURdcVeLh+3iAVng3RevrQquMr//wnzJ 48SynlcooGvtcO2qUk8S7dlIrV46KMc+qQcu9ChH3lZ/G3JW9NPpxwoDD6ZKu0rZXb w93JtdgOENi++Q+JeNJfQ6m8LyJ7UzJDUwgSkoSziKrvOJt+sHN6EZHwlxm57aDZtT og82S7+CpAfOQ== From: Jeff Layton Date: Mon, 09 Dec 2024 16:14:02 -0500 Subject: [PATCH v5 10/10] nfsd: implement OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_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: <20241209-delstid-v5-10-42308228f692@kernel.org> References: <20241209-delstid-v5-0-42308228f692@kernel.org> In-Reply-To: <20241209-delstid-v5-0-42308228f692@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jonathan Corbet , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3288; i=jlayton@kernel.org; h=from:subject:message-id; bh=VEHOwStO+gCYUuq2M8p9wjztvUB56YWilUi6AG2I/f8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnV12lk9ogCkJbqZJMFHgnaOWaAVxC9Y8QixTFV CA5Lx+zw1WJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ1ddpQAKCRAADmhBGVaC FabhD/0akETMOmSpdewrRO7opexkUgUPGuMbPxBnNiiM7qYtxbci+I4kYOKozUPeMvargF88AWx 2eP1fLMOkcPNpEQF/k+w2BkfNTUTzcstSIHE5+Kij3NNaiqkJVa9QwAXVmLg+N+8hdLS1Qw3z2+ hdpvZhO8KY0dpPlVqRjZYkzrgw3sJQo5XDS9pzRsTuwX4DrCYIUyH+xgqP0h5bwepLZsDqaaPyK pRXoWPki6/1osnr3WJSLQp8j8CWvTrBh8DFrzQIYsi3UdHWsqneG/1OS1TGd+/Sw0lyjyZUQqeW bh/adNxZRL+E6O6DZaHTeTkFvUxYgfoG7ut9bPVuDmTSmDzJTr2qRY+d87R/bps8e0q9eAgV4tR fJMfrGkL4yIoAzDMhBLltYRrbphRASUhU+OF3Gi2VrmAMuiSlbfhix2pvGzsnIMQNtr+1WSz13V i1nhl6bwwMN3Mfu6jFHpj24IoFFi9X81M7gNXoiClmFTMGzez0JUiZWzHWQ8vku/GdmwHXdvuR+ Enzc4OBZtw9TiHb8tIl+okbFXfjhSSFwy94bgNQ3KauHr1zHXgwjv8VqLX2oyvulDJsTBqfN0j+ 99fK0wpDj6ux1BEpEXx3pf5y58RtoEQ7y//zORN18mxv+CLnZzcpw3IOJC33FSViIFFENpdwNRv nwtn+nSj4eOWJkQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Allow clients to request getting a delegation xor an open stateid if a delegation isn't available. This allows the client to avoid sending a final CLOSE for the (useless) open stateid, when it is granted a delegation. If this flag is requested by the client and there isn't already a new open stateid, discard the new open stateid before replying. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 24 +++++++++++++++++++++++- fs/nfsd/nfs4xdr.c | 3 ++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a76e35f86021c5657e31e4fddf08cb5781f01e32..82d2aee484d9ee6604a8096227e= 0a958d58d3128 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6133,6 +6133,17 @@ static void nfsd4_deleg_xgrade_none_ext(struct nfsd4= _open *open, */ } =20 +/* Are we only returning a delegation stateid? */ +static bool open_xor_delegation(struct nfsd4_open *open) +{ + if (!(open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION)) + return false; + /* Did we actually get a delegation? */ + if (!deleg_is_read(open->op_delegate_type) && !deleg_is_write(open->op_de= legate_type)) + return false; + return true; +} + /** * nfsd4_process_open2 - finish open processing * @rqstp: the RPC transaction being executed @@ -6230,6 +6241,17 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct s= vc_fh *current_fh, struct nf * OPEN succeeds even if we fail. */ nfs4_open_delegation(open, stp, &resp->cstate.current_fh); + + /* + * If there is an existing open stateid, it must be updated and + * returned. Only respect WANT_OPEN_XOR_DELEGATION when a new + * open stateid would have to be created. + */ + if (new_stp && open_xor_delegation(open)) { + memcpy(&open->op_stateid, &zero_stateid, sizeof(open->op_stateid)); + open->op_rflags |=3D OPEN4_RESULT_NO_OPEN_STATEID; + release_open_stateid(stp); + } nodeleg: status =3D nfs_ok; trace_nfsd_open(&stp->st_stid.sc_stateid); @@ -6246,7 +6268,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct sv= c_fh *current_fh, struct nf /* * To finish the open response, we just need to set the rflags. */ - open->op_rflags =3D NFS4_OPEN_RESULT_LOCKTYPE_POSIX; + open->op_rflags |=3D NFS4_OPEN_RESULT_LOCKTYPE_POSIX; if (nfsd4_has_session(&resp->cstate)) open->op_rflags |=3D NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK; else if (!(open->op_openowner->oo_flags & NFS4_OO_CONFIRMED)) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ce93a31ac5cec75b0f944d288e796e7a73641572..2b6a64b4d2a3e3295b9f72e2993= dd469945b6114 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3420,7 +3420,8 @@ static __be32 nfsd4_encode_fattr4_xattr_support(struc= t xdr_stream *xdr, #define NFSD_OA_SHARE_ACCESS_WANT (BIT(OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DEL= EG) | \ BIT(OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG) | \ BIT(OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL) | \ - BIT(OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS)) + BIT(OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS) | \ + BIT(OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION)) =20 #define NFSD_OA_OPEN_CLAIM (BIT(OPEN_ARGS_OPEN_CLAIM_NULL) | \ BIT(OPEN_ARGS_OPEN_CLAIM_PREVIOUS) | \ --=20 2.47.1