From patchwork Mon Aug 26 12:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13777883 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 6B8521946A9; Mon, 26 Aug 2024 12:46:39 +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=1724676399; cv=none; b=OcRZ/RXMa/K91kVsDDneUuM43NnBOKyICF4WPTjtY890+Q3wVpnJeAhQS4I6WTnGLJu5fXwd3TBy5QQGPDPHAvX8Jh/2rIqeEUYjflLhzlPug6yZp/OvCJ4ga1dSyWZq9s0NNgUcniBh2A/2HsU7nCBkw3+UfJ7PBBDt3qTIOq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724676399; c=relaxed/simple; bh=7jlrRj4kXPzN3gZjrQ6Cust2gbuDWKwrYdd0gLjRSjQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ezh/xsI4jJNr8CWCoC7WpvgXNeVedVYg0NZd6OKOm7PE7pUiky+tYl8Ac7FKvR6ZB3L3TX7i8Q7X2ePpiLQv9CMgbe0jX9olumS55m8pPzc0DktiQQ6D903ptBO2O+xcIrX/Iq//vhgRLQujIGHpJ2710jVZf26m0ptKn4tfzEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=grpfIMos; 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="grpfIMos" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A621C581B7; Mon, 26 Aug 2024 12:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724676398; bh=7jlrRj4kXPzN3gZjrQ6Cust2gbuDWKwrYdd0gLjRSjQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=grpfIMost5Zj4NU3cY1DoXAukCIX5s4aDblfEEmcMo2gV+D0unW5/Hfr+OuWTXVAM GlWVEjO8p5qjXljy58qBRrKrj0ZVNmAUt7uwOj9EARdv2WTwdLwVLnGtWRgkOF1V7I IZf+ggsLs3+SBftDeLbHvo6fPHUOl/BleVsqg+XUS5kQ6F0pqvX0l2tJwaJPXTceXX 73kd3GBTscl+cyj2vDKYCMPBdE5QviCeD8sNe46PL9BM3sPYTg9hOh0dIrB6w6QZqo J2qQwiLrBpAKba2J9UQeSkFrKINfPphedLF1uFmiIrO5vXVOUdrPE1IA2AcFURWSM7 foM/9Cu5yEgfw== From: Jeff Layton Date: Mon, 26 Aug 2024 08:46:11 -0400 Subject: [PATCH v2 1/7] nfsd: add pragma public to delegated timestamp types Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240826-delstid-v2-1-e8ab5c0e39cc@kernel.org> References: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Olga Kornievskaia , Alexander Viro , Christian Brauner , Jan Kara , Jonathan Corbet Cc: Tom Haynes , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3577; i=jlayton@kernel.org; h=from:subject:message-id; bh=7jlrRj4kXPzN3gZjrQ6Cust2gbuDWKwrYdd0gLjRSjQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmzHkq5SiPS5mfhgWmxd7cOMuuf1SQbfCc16Lo0 mpJSYVeTKGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZsx5KgAKCRAADmhBGVaC FbFOD/9uagwI3lUrGKeYqJcGSp6ls/zpL4e/z5sWK9vOe9+O43vv81HwrtnS1ho6sIXWn1VMVMi kMN6PAylkYhkuxb8o2UvMqNmSGtNkAuqthJIKb0K4X3kN8TZ452xeZktlFnEH3171jyz7VAqW5T iV9l1/FO95U9wGbuAgRuCFmiZVIhgrmsRV3u7V7fPQMfPDsx+geZZHTzVdqIS8oVqrVL30oDwLl z5Q8uFC4t/dCPrkY3IQwmYLxtkcb90hJ4JgqOzau1A/dE5PZh+PAGi6yxWrjxMA9gZlpgHr+8FE 4kAE+Jlx8bWRA3l2D1XEm3R0JuplGwcagcodFUWJRWxpF1BjZ4nkm3bwrwclm9WzE4d8auqHWHj P5UGOyTF+6Vl/ziU9cO/odqrv4PUXCwVzZkyeEu/hUWU2uaB1cw5vjqaGyqIqTdDZE9GH38hdA+ 8e9dfzI+uQZGzKWvy4ZRxAnlPG023JTTDRpoed4LklrCGcWXgXFDMqWs9cWIF4Ajs+FeQFXYomI jUSmBYDsqzRXBSHoCr4CUKEdEOp1ZTTa46S2IfKYHI4Z/eEBNf0UIXERAjnpISTQA6MsTicSSl6 aIW2zh4OB8UxGJqH7ycm0gd5MgJxBuFNYSD4Bf4pPWjEXllzS5IXSvxNOWYbbF0gJVYFc9EAqfm S9Oktj2Z4bLm+Eg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 In a later patch we're going to need the ability to decode the delegated timestamp fields. Make the decoders available for the delgated timestamp types, and regenerate the source and header files. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4_1.x | 2 ++ fs/nfsd/nfs4xdr_gen.c | 10 +++++----- fs/nfsd/nfs4xdr_gen.h | 8 +++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4_1.x b/fs/nfsd/nfs4_1.x index d2fde450de5e..fc37d1ecba0f 100644 --- a/fs/nfsd/nfs4_1.x +++ b/fs/nfsd/nfs4_1.x @@ -150,6 +150,8 @@ const OPEN4_RESULT_NO_OPEN_STATEID = 0x00000010; */ typedef nfstime4 fattr4_time_deleg_access; typedef nfstime4 fattr4_time_deleg_modify; +pragma public fattr4_time_deleg_access; +pragma public fattr4_time_deleg_modify; %/* diff --git a/fs/nfsd/nfs4xdr_gen.c b/fs/nfsd/nfs4xdr_gen.c index c22372144a57..0816cfa530e0 100644 --- a/fs/nfsd/nfs4xdr_gen.c +++ b/fs/nfsd/nfs4xdr_gen.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 // Generated by xdrgen. Manual edits will be lost. -// XDR specification modification time: Fri Aug 23 17:28:09 2024 +// XDR specification modification time: Fri Aug 23 18:57:46 2024 #include "nfs4xdr_gen.h" @@ -120,13 +120,13 @@ xdrgen_decode_fattr4_open_arguments(struct xdr_stream *xdr, fattr4_open_argument return xdrgen_decode_open_arguments4(xdr, ptr); }; -static bool __maybe_unused +bool xdrgen_decode_fattr4_time_deleg_access(struct xdr_stream *xdr, fattr4_time_deleg_access *ptr) { return xdrgen_decode_nfstime4(xdr, ptr); }; -static bool __maybe_unused +bool xdrgen_decode_fattr4_time_deleg_modify(struct xdr_stream *xdr, fattr4_time_deleg_modify *ptr) { return xdrgen_decode_nfstime4(xdr, ptr); @@ -223,13 +223,13 @@ xdrgen_encode_fattr4_open_arguments(struct xdr_stream *xdr, const fattr4_open_ar return xdrgen_encode_open_arguments4(xdr, value); }; -static bool __maybe_unused +bool xdrgen_encode_fattr4_time_deleg_access(struct xdr_stream *xdr, const fattr4_time_deleg_access *value) { return xdrgen_encode_nfstime4(xdr, value); }; -static bool __maybe_unused +bool xdrgen_encode_fattr4_time_deleg_modify(struct xdr_stream *xdr, const fattr4_time_deleg_modify *value) { return xdrgen_encode_nfstime4(xdr, value); diff --git a/fs/nfsd/nfs4xdr_gen.h b/fs/nfsd/nfs4xdr_gen.h index 48da108a2427..e79935f973ff 100644 --- a/fs/nfsd/nfs4xdr_gen.h +++ b/fs/nfsd/nfs4xdr_gen.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Generated by xdrgen. Manual edits will be lost. */ -/* XDR specification modification time: Fri Aug 23 17:28:09 2024 */ +/* XDR specification modification time: Fri Aug 23 18:57:46 2024 */ #ifndef _LINUX_NFS4_XDRGEN_H #define _LINUX_NFS4_XDRGEN_H @@ -88,8 +88,14 @@ enum { OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 0x200000 }; enum { OPEN4_RESULT_NO_OPEN_STATEID = 0x00000010 }; typedef struct nfstime4 fattr4_time_deleg_access; +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); + typedef struct nfstime4 fattr4_time_deleg_modify; +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); + enum { FATTR4_TIME_DELEG_ACCESS = 84 }; From patchwork Mon Aug 26 12:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13777884 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 1D15417C9B5; Mon, 26 Aug 2024 12:46:40 +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=1724676401; cv=none; b=JPU/fxHvDxkC4/APg/1QXhv5CjYb1f5SBcI10Myl3P+nPYvukqMbaV0mib8dTp2kygPgdrXy5CSOTi9RlfpfisFDWWF/LA/cA+xhDzHOx4otE6NEFAwyIKpsCDTUThq8VceROKy4pTSNMooPAZDiCoHoj+drDOeZkK3fbPXtbIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724676401; c=relaxed/simple; bh=Rita/RK8sbI3aAYesZmLle/wA6UaJC2j1C6ZpQoaOsQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aQIEu9CRqbmXZwgffHhZoiLTrAahWgycEezABO0HXxC+4DcdCFuhubRhUDGCEgIwr8VeX5fjRIaZONx8jk/pKPHQakB4YmFEmy0qOTz0ii+JG3vYwY5I5YKXuISKyw/H/7wPAMR85SOmeJhtroIZeFo+yAn1ah3TP9QYnt+28XM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tbuayevS; 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="tbuayevS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 283FFC58285; Mon, 26 Aug 2024 12:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724676400; bh=Rita/RK8sbI3aAYesZmLle/wA6UaJC2j1C6ZpQoaOsQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tbuayevS14zGa+/4AMLybjNEjHAE5gc0qcbegl83QMJ8hUGqhvuVXUfl2ysaMhR8W E9xZ9nikcDfOFEPkLGb54FU3wnkTnjiLxxtIkV+cZYKKNLh1cl52pIK7GDHxd+TsPp job+PKEitcy3L3XKU5kgiMNuoOMbePrg+CPSNrxBRZ3daVKXCKvdleo+7WciCNKUox lE/xViVU92rv68h10ZvH/69P5JyNB2aBSOCjyFXfOkskv5I3KAZUIQGxTZb/8rBg+/ zKxiruK2HNoJOV3eecF5m7E7KLNPqZwJlGcmAGCGNv1ey1PeSYFH4+LaXcnW7r7die hC13k18M4ZjWg== From: Jeff Layton Date: Mon, 26 Aug 2024 08:46:12 -0400 Subject: [PATCH v2 2/7] nfs_common: make nfs4.h include generated nfs4_1.h Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240826-delstid-v2-2-e8ab5c0e39cc@kernel.org> References: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Olga Kornievskaia , Alexander Viro , Christian Brauner , Jan Kara , Jonathan Corbet Cc: Tom Haynes , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3784; i=jlayton@kernel.org; h=from:subject:message-id; bh=Rita/RK8sbI3aAYesZmLle/wA6UaJC2j1C6ZpQoaOsQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmzHkqKuN5PHDEKNhstw0JqwBFrSLYKzm6eWleT V6AV11uA32JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZsx5KgAKCRAADmhBGVaC FQRdD/9bi5AT6HYU73MPDktzS2M65HmQ8X0D7GtYB5kRKGeGwthcpFWpX1qP0wTzbsRQ3Tt6vnZ Bb2FS3W5DSsvP6BUkNyQybpD3FHxj6Oef00Kf/M76SQtax9KpfltsstqU1AO5HE65NXgclCPZqr 7kJeJ2ML0LjOivIVr0RiDcRsyEi8e4I+l8v4VsrHEVYSPSOppXhjj18q+4UxQl3W/ilXnXIS3Az 8bMkB+3ywM2TtbmOYAkwq5xGAHV41zOuV8shrRWE8tx6UJiyWhDXLnWktr9+xE4RcWmSbn9lk90 WQWHc5jYxelDM066moa4fhc4YKeVMRMLZ2pfbUY+gVBGiB4EZoa0fl8tkRe6TPg2bSxueuayqau RdRmYXdaFk/vkCK8ZzGfld3MeRSYu25DmLLT+ilsSzWakr6XrG4+ea+OMkQkTi7/2XbRtxy0sV4 im5oPONfqzISSiTL+w0n3zBJdvgy7M8FCyWHQOsgWM3BXAOjtWgQU5wkZZyDuV6lsNVmSEkkcfN UpMjV8e2VwnWE+mURgfGxOHYGsfrOECjiQuzMsI6W3bOL5pGrJ2h2a/TVWtdr2RDfqe2O3jgtpr nnOeynQEiRIyPnER4o1Iudxj31xdC4SuJnE3SLzRhnQd5N3F4X9gc0mOvnWmggkfxv50qnlfb7Y uu/djCMtyRG0KeA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Long term, we'd like to move to autogenerating a lot of our XDR code. Both the client and server include include/linux/nfs4.h. That file is hand-rolled and some of the symbols in it conflict with the autogenerated symbols from the spec. Move nfs4_1.x to Documentation/sunrpc/xdr. Create a new include/linux/sunrpc/xdrgen directory in which we can keep autogenerated header files. Move the new, generated nfs4xdr_gen.h file to nfs4_1.h in that directory. Have include/linux/nfs4.h include the newly renamed file and then remove conflicting definitions from it and nfs_xdr.h. For now, the .x file from which we're generating the header is fairly small and just covers the delstid draft, but we can expand that in the future and just remove conflicting definitions as we go. Signed-off-by: Jeff Layton --- {fs/nfsd => Documentation/sunrpc/xdr}/nfs4_1.x | 0 fs/nfsd/nfs4xdr_gen.c | 2 +- include/linux/nfs4.h | 7 +------ include/linux/nfs_xdr.h | 5 ----- fs/nfsd/nfs4xdr_gen.h => include/linux/sunrpc/xdrgen/nfs4_1.h | 6 +++--- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4_1.x b/Documentation/sunrpc/xdr/nfs4_1.x similarity index 100% rename from fs/nfsd/nfs4_1.x rename to Documentation/sunrpc/xdr/nfs4_1.x diff --git a/fs/nfsd/nfs4xdr_gen.c b/fs/nfsd/nfs4xdr_gen.c index 0816cfa530e0..3e55dd1e6530 100644 --- a/fs/nfsd/nfs4xdr_gen.c +++ b/fs/nfsd/nfs4xdr_gen.c @@ -2,7 +2,7 @@ // Generated by xdrgen. Manual edits will be lost. // XDR specification modification time: Fri Aug 23 18:57:46 2024 -#include "nfs4xdr_gen.h" +#include static bool __maybe_unused xdrgen_decode_int64_t(struct xdr_stream *xdr, int64_t *ptr) diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 8d7430d9f218..b90719244775 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -17,6 +17,7 @@ #include #include #include +#include enum nfs4_acl_whotype { NFS4_ACL_WHO_NAMED = 0, @@ -512,12 +513,6 @@ enum { FATTR4_XATTR_SUPPORT = 82, }; -enum { - FATTR4_TIME_DELEG_ACCESS = 84, - FATTR4_TIME_DELEG_MODIFY = 85, - FATTR4_OPEN_ARGUMENTS = 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 45623af3e7b8..d3fe47baf110 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1315,11 +1315,6 @@ struct nfs4_fsid_present_res { #endif /* CONFIG_NFS_V4 */ -struct nfstime4 { - u64 seconds; - u32 nseconds; -}; - #ifdef CONFIG_NFS_V4_1 struct pnfs_commit_bucket { diff --git a/fs/nfsd/nfs4xdr_gen.h b/include/linux/sunrpc/xdrgen/nfs4_1.h similarity index 96% rename from fs/nfsd/nfs4xdr_gen.h rename to include/linux/sunrpc/xdrgen/nfs4_1.h index e79935f973ff..0272c2ee8739 100644 --- a/fs/nfsd/nfs4xdr_gen.h +++ b/include/linux/sunrpc/xdrgen/nfs4_1.h @@ -2,8 +2,8 @@ /* Generated by xdrgen. Manual edits will be lost. */ /* XDR specification modification time: Fri Aug 23 18:57:46 2024 */ -#ifndef _LINUX_NFS4_XDRGEN_H -#define _LINUX_NFS4_XDRGEN_H +#ifndef _LINUX_XDRGEN_NFS4_H +#define _LINUX_XDRGEN_NFS4_H #include #include @@ -103,4 +103,4 @@ enum { FATTR4_TIME_DELEG_MODIFY = 85 }; enum { OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000 }; -#endif /* _LINUX_NFS4_XDRGEN_H */ +#endif /* _LINUX_XDRGEN_NFS4_H */ From patchwork Mon Aug 26 12:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13777885 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 DB33D197A72; Mon, 26 Aug 2024 12:46:42 +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=1724676403; cv=none; b=naKsc/menb//Icdm92mJIG2hbDyqWLrCwKsIhbN+F9+EvHhYw9+R9FvTOcefcQGDOzvMwM9OeRSAOCbBkuUaGNT92BxKLk/c+4X1m+RJZyWppCGBvmqkjnJkmePZY5aIn3obLAyxg8EYJsDGTqTItXJbm+6yl55lRXOB63LK99w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724676403; c=relaxed/simple; bh=rKoPX2aFnfuNciBlyHag/9kJn1ArYzxDDv3KOmqc830=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FlQ9lWUNaQPewwOz0KDNDBux7mhmiKfDhaWS/Bh5BIjqfsits5KcZeFTaUDonfC3sz3vvyQI1NimGoUdYNi+jVKy1wC6nKe+cYS2krL6yPm5oaIGMqdeZIm3+nGNS8vCyNQRLYgUPfY+mMIzLyySHjI0FWdOcTUHRETY8wwSxjI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gq1hs73g; 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="Gq1hs73g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE3B4C581B8; Mon, 26 Aug 2024 12:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724676402; bh=rKoPX2aFnfuNciBlyHag/9kJn1ArYzxDDv3KOmqc830=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Gq1hs73gUyANERB1YldOUPxfSZyI3lQmbrARU2nUWflL6DPt2zUQDTnrzBpuT6gpG 52cvg6kRxM98h02fN7VrHgCjVA251PdIxnYLk/YGXIdk+qLlM3pwVomlwEbIPtFB1v dWe4obuTVkpwFGrbB/42mntKxnSKkGJlIo4oO226EaVNZpoyvEkw83Iv13YXKJoRvJ AzN0ybtDmd0pWsxTc49G1w03JLKydKWyEiA1idhxTKiIwq5l8zIY8yLuTcfni7sbSb mZ2KVMn9vlzgc8p3lqByq9LPPVLi+XNS0xUiRmjhu/DTyGvm9Vb/LWQbxhs9VgcDST dNZvkXEGl/3XQ== From: Jeff Layton Date: Mon, 26 Aug 2024 08:46:13 -0400 Subject: [PATCH v2 3/7] nfsd: add support for FATTR4_OPEN_ARGUMENTS Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240826-delstid-v2-3-e8ab5c0e39cc@kernel.org> References: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Olga Kornievskaia , Alexander Viro , Christian Brauner , Jan Kara , Jonathan Corbet Cc: Tom Haynes , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4252; i=jlayton@kernel.org; h=from:subject:message-id; bh=rKoPX2aFnfuNciBlyHag/9kJn1ArYzxDDv3KOmqc830=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmzHkqas/6T5SLXv4qCPcBKtChYhIQGZKZQqQkp IaMKDB3Zp+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZsx5KgAKCRAADmhBGVaC FQDgD/9Tanc3VGL/ESU3EB+wzeQUC5DMe1qL9Uzdoyv3HEudQ74qBe6LBenVlNe2v+oxIqqMxAw Ux9Gmuj+/MeliCuTh738N99hkLP4CasEAxToRqUoxF5wINAIGmix1lDAk4NDYEWxhuJCw/yT0co BZxuvziT8KRsPJvTS6vP2hRr0vhIJ1RDZtVhgURxxxT1JzLYDWez+R3xZHiENzdWlLhue4nh/jj BMHxHA/GuZ7IbU/bIAoAzyAmN8qK+wJsk5cvIoBCr37YpO4eMtEzUBnTmvvuvk8fwkYY/MywCMl unSRxRo0Iw86KK6u2c2bTIfeORwpZ9U2HcVuHbYMSeSM7IwWiT4iinC4IJDCXCkSl/NDAgfyssX fROBRhjD2MMd4RiSdUHqGNoMy2RC6ZkH923XgN19JXjYZOfzntYop+b3nL2kkDm2dTZaVWWSUm2 fbrkk4ymrpp1Ri8ZqSQB96kRhKgNxgs8QxvKvmmwq+QBNSKSQFkZjEDAhTveeNYv82EplIqDUTs N37xPTMcjm24GmNc39srQb0ynFWeU6tF1A6f32ixta/515uIttkrRrgtYHDuh9u1PzppxZ9T4Fx rB3PumM6LztBT4bruh8yPUC1LZvWzKH3tt7N+05kDrIc/llhHOsIt5djyokTf0hdNE2zVy8TP/F UJuZ50zBE4zWEGg== 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/Makefile | 2 +- fs/nfsd/nfs4xdr.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfsd.h | 3 ++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/Makefile b/fs/nfsd/Makefile index b8736a82e57c..d6ab3ae7d0a0 100644 --- a/fs/nfsd/Makefile +++ b/fs/nfsd/Makefile @@ -18,7 +18,7 @@ nfsd-$(CONFIG_NFSD_V2) += nfsproc.o nfsxdr.o nfsd-$(CONFIG_NFSD_V2_ACL) += nfs2acl.o nfsd-$(CONFIG_NFSD_V3_ACL) += nfs3acl.o nfsd-$(CONFIG_NFSD_V4) += 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) += nfs4layouts.o nfsd-$(CONFIG_NFSD_BLOCKLAYOUT) += blocklayout.o blocklayoutxdr.o nfsd-$(CONFIG_NFSD_SCSILAYOUT) += blocklayout.o blocklayoutxdr.o diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index f118921250c3..1c8219ea8af7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3399,6 +3399,54 @@ static __be32 nfsd4_encode_fattr4_xattr_support(struct xdr_stream *xdr, return nfsd4_encode_bool(xdr, err == 0); } +#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_DELEG) | \ + 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 = NFSD_OA_SHARE_ACCESS; +static uint32_t oa_share_deny = NFSD_OA_SHARE_DENY; +static uint32_t oa_share_access_want = NFSD_OA_SHARE_ACCESS_WANT; +static uint32_t oa_open_claim = NFSD_OA_OPEN_CLAIM; +static uint32_t oa_create_mode = NFSD_OA_CREATE_MODE; + +static const struct open_arguments4 nfsd_open_arguments = { + .oa_share_access = { .count = 1, .element = &oa_share_access }, + .oa_share_deny = { .count = 1, .element = &oa_share_deny }, + .oa_share_access_want = { .count = 1, .element = &oa_share_access_want }, + .oa_open_claim = { .count = 1, .element = &oa_open_claim }, + .oa_create_mode = { .count = 1, .element = &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[] = { [FATTR4_SUPPORTED_ATTRS] = nfsd4_encode_fattr4_supported_attrs, [FATTR4_TYPE] = nfsd4_encode_fattr4_type, @@ -3499,6 +3547,7 @@ static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_ops[] = { [FATTR4_MODE_UMASK] = nfsd4_encode_fattr4__noop, [FATTR4_XATTR_SUPPORT] = nfsd4_encode_fattr4_xattr_support, + [FATTR4_OPEN_ARGUMENTS] = nfsd4_encode_fattr4_open_arguments, }; /* diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 4ccbf014a2c7..c98fb104ba7d 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -454,7 +454,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) extern const u32 nfsd_suppattrs[3][3]; From patchwork Mon Aug 26 12:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13777886 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 8D27B198853; Mon, 26 Aug 2024 12:46:44 +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=1724676404; cv=none; b=MTiWNcMJmxeo19N4XNRGNc8nSfraAL9VYqJs/Xnd0h+RQhf/MQgpqzJZj905pKWFIhl1hmO1rU15+0pzGwNfYOfXcAl5RiQopK5WFcT5KO+lSBHa8EdpbjyrH4cQu3syg6YGLRwI6kBJ9/eGEuoDy5z3kFiIw0mzbHDpcOC28So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724676404; c=relaxed/simple; bh=sVpxrgIziSW8Pox+j3rWuGkFmCBxDs6hJ/Qy+5YLVr0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=flpfWrQHgvZe3nU7DF1DUCZSECyqiMC/0OLo+lFcsKK089ty4NYCU1t6faWJQj9G9+7ME5S6T0ORhcUqe3ESzyEJU6k4amXmko8S6IANpqFd4DOmijTtx2Mm1+P/QZvdzJDeU3JvEE27BlsjFFwQ+2iFi+YAmxSFdKhEeFqFg8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BCI9jWeo; 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="BCI9jWeo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A02D1C58280; Mon, 26 Aug 2024 12:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724676404; bh=sVpxrgIziSW8Pox+j3rWuGkFmCBxDs6hJ/Qy+5YLVr0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BCI9jWeoEzDiJBlol7jAJppyphKl7zrKfn076kkJPE+mM5MLwKOQZTgxCMke7OUij 0hJTvTvNoKDDjK6IzKarhsua2U4OQjN7z83ZjymriTpJauVNhcJeTYfd9IBpI0HZEO iOQx/bkc9dWmZ+kLy9od83tEpWZKzutkOfVBJ72mjPN/0dIfOP6l4vX4HPz65cX4A0 ji4K/cukMelXTqB0iNfStTnrs9U5fv+6NAgV+3mxg+yGiit8uQ6UrcrGi/VDZJdewt 0MBqE3bzFBXKlDaIOUqiOQ4ELLp1bqzRJCeTJ+7WwXWOAnA5mg4SnJ46zcy/AlwHen Ep5HxTvA2+rlA== From: Jeff Layton Date: Mon, 26 Aug 2024 08:46:14 -0400 Subject: [PATCH v2 4/7] nfsd: implement OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240826-delstid-v2-4-e8ab5c0e39cc@kernel.org> References: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Olga Kornievskaia , Alexander Viro , Christian Brauner , Jan Kara , Jonathan Corbet Cc: Tom Haynes , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5596; i=jlayton@kernel.org; h=from:subject:message-id; bh=sVpxrgIziSW8Pox+j3rWuGkFmCBxDs6hJ/Qy+5YLVr0=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmzHkrmZZRnuYFixPQFcBX8dKlXQRH74gaS7OaQ qRI7ltDSKaJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZsx5KwAKCRAADmhBGVaC FfsDD/9RNBUr7+ZYVFVpwJFIB8MlNcYCrsUOVuuzNIL8J3vPn3VhcpHq0ZXTi0bSLkIVrUSMSaI CVU/vyl0OCGNQmP089KRc8B0O7kF6Hh8MhOx41jcLew7pwccNixySSfV5vAEwrv9xVGbGUyBhxU Ztqd/jT3I4a3dQ/bDCAGIjpbejV/YWI0W9SDwl/pvKc1mubbInq4ub4emC9xrnIjcWUlxdGthe4 3kmxONOpoybhGPzY/JtqLnyqR8wYg964oEfxia0XOUeXD8DwFmQ9oArmrNhtoOGYiGqol1DPeZF vGEJr0T1zuqdxxjJbc1oK/LZ0Um/j3UWrqUYCtCVkiIWWcK/M92C8O/3YKDbtTIkMTz4Jj6q82R 2X2nWMXvyqwk8/bGs7G0Lu0F8/MPH1d6Oq9dxZdW350C7Z+tkybnlspk9iH5hO25njCX3IDki+Z KTtwsufrV7v8VEjerCSY4wC41ERERtf/IMRS96daLMYNL9jbpxV1G218RBUzmlzh1MdDQpssVrt vz79E+uHqOgfFVFSy0jHeHRvqhhyciNl/U4tEg8afyqqWkqlEcoXialv2R3XvTb0WAfQSHvPOJ2 7teHEEms4p1eICs26MEWNQNnvGqbKW1TdjC7UCl0AjE+nY4gZX7dM72f17IVR4YQA9SMyO91z2g TqPtn19BZGymzYA== 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. This is done by moving the increment of the open stateid and unlocking of the st_mutex until after we acquire a delegation. If we get a delegation, we zero out the op_stateid field and set the NO_OPEN_STATEID flag. If the open stateid was brand new, then unhash it too in this case since it won't be needed. If we can't get a delegation or the new flag wasn't requested, then just increment and copy the open stateid as usual. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 28 ++++++++++++++++++++++++---- fs/nfsd/nfs4xdr.c | 5 +++-- include/uapi/linux/nfs4.h | 7 +++++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 9fe67c412f9b..b544320246bf 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6029,6 +6029,17 @@ static void nfsd4_deleg_xgrade_none_ext(struct nfsd4_open *open, */ } +/* 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; + if (open->op_delegate_type != NFS4_OPEN_DELEGATE_READ && + open->op_delegate_type != NFS4_OPEN_DELEGATE_WRITE) + return false; + return true; +} + /** * nfsd4_process_open2 - finish open processing * @rqstp: the RPC transaction being executed @@ -6051,6 +6062,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf struct nfs4_delegation *dp = NULL; __be32 status; bool new_stp = false; + bool deleg_only = false; /* * Lookup file; if found, lookup stateid and check open request, @@ -6105,9 +6117,6 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf open->op_odstate = NULL; } - nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); - mutex_unlock(&stp->st_mutex); - if (nfsd4_has_session(&resp->cstate)) { if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) { open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; @@ -6121,7 +6130,18 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf * OPEN succeeds even if we fail. */ nfs4_open_delegation(open, stp, &resp->cstate.current_fh); + deleg_only = open_xor_delegation(open); nodeleg: + if (deleg_only) { + memcpy(&open->op_stateid, &zero_stateid, sizeof(open->op_stateid)); + open->op_rflags |= OPEN4_RESULT_NO_OPEN_STATEID; + if (new_stp) + release_open_stateid(stp); + } else { + nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); + } + mutex_unlock(&stp->st_mutex); + status = nfs_ok; trace_nfsd_open(&stp->st_stid.sc_stateid); out: @@ -6137,7 +6157,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf /* * To finish the open response, we just need to set the rflags. */ - open->op_rflags = NFS4_OPEN_RESULT_LOCKTYPE_POSIX; + open->op_rflags |= NFS4_OPEN_RESULT_LOCKTYPE_POSIX; if (nfsd4_has_session(&resp->cstate)) open->op_rflags |= 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 1c8219ea8af7..8266f910d847 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1066,7 +1066,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 NFS4_SHARE_WANT_NO_PREFERENCE: case NFS4_SHARE_WANT_READ_DELEG: case NFS4_SHARE_WANT_WRITE_DELEG: @@ -3410,7 +3410,8 @@ static __be32 nfsd4_encode_fattr4_xattr_support(struct xdr_stream *xdr, #define NFSD_OA_SHARE_ACCESS_WANT (BIT(OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG) | \ 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_OPEN_XOR_DELEGATION)) #define NFSD_OA_OPEN_CLAIM (BIT(OPEN_ARGS_OPEN_CLAIM_NULL) | \ BIT(OPEN_ARGS_OPEN_CLAIM_PREVIOUS) | \ diff --git a/include/uapi/linux/nfs4.h b/include/uapi/linux/nfs4.h index caf4db2fcbb9..4273e0249fcb 100644 --- a/include/uapi/linux/nfs4.h +++ b/include/uapi/linux/nfs4.h @@ -58,7 +58,7 @@ #define NFS4_SHARE_DENY_BOTH 0x0003 /* 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 -#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 +#define NFS4_SHARE_WANT_MOD_MASK 0xF00000 #define NFS4_SHARE_WANT_DELEG_TIMESTAMPS 0x100000 #define NFS4_SHARE_WANT_OPEN_XOR_DELEGATION 0x200000 +#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 From patchwork Mon Aug 26 12:46:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13777887 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 F1B87198E6D; Mon, 26 Aug 2024 12:46:45 +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=1724676406; cv=none; b=hAdUwelPMUnq/dVQBUNaBCWOcN5Zv4KPwjzeb3DZuXSVWdZeF3rlSPAzBZRaFRnWcfIixxWIqgSq0JUjpBlHrRoQlSztCw1Y8OquUZgUaDW+7/luYnqTTLpSJMOVGS2sExKLJfMyqxFUVOMr00MUq/DzlzpAlnjl61jDEnci2gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724676406; c=relaxed/simple; bh=PSgvoG/VeBHlNw/xybnGmp2VjTgkoJJ22Of1xt8QDDI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N5rOb85OVnx7uAsA6JQvJMrqvd15m5hLPpFiRciH2JnciyPsbWdEesd6AyQaKDAOYMNsP7xL1gvhi6iraoHfyV9+oB6Mjs0b3a9hgloP0KCaMtboNosNFY2PU+0Gv7HsaQhLzTu644JAObvUKX9l18OjSx7KYdKbybwlmwfxcjc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vJLtM6BS; 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="vJLtM6BS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E6D6C58282; Mon, 26 Aug 2024 12:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724676405; bh=PSgvoG/VeBHlNw/xybnGmp2VjTgkoJJ22Of1xt8QDDI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vJLtM6BSBsNCn020oOq8TSo8GFLvfaEQje9ZWWH76s3srFqLSu6w64Q+F+/r5aNuP 3tBpK3GUXt2xcD6EPn8fXDMOgkpE4h6mbjV9WopISOtc5iICVtzvvqqmnKjy7/MZHV zVP3D3NfKQgppfS7sdQgi+sHK6uRXUBZU6H/GgOP1p/Cl4q/2NpJBO5IoFV40r4Gjs iBIssJHdlqK6RHa7mJqPvQUED+YTphTqU0hVYyWmWHGzFQw3qYNSApV6A10WcNNVGX /Xm9n707OJBYqADZQdFMthFMb2eB7v7r0I3gEDi2snqtuxKaPp3jdpCgSXyvLblSWb fwKqlD1VLD59Q== From: Jeff Layton Date: Mon, 26 Aug 2024 08:46:15 -0400 Subject: [PATCH v2 5/7] fs: add an ATTR_CTIME_DLG flag Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240826-delstid-v2-5-e8ab5c0e39cc@kernel.org> References: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Olga Kornievskaia , Alexander Viro , Christian Brauner , Jan Kara , Jonathan Corbet Cc: Tom Haynes , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2163; i=jlayton@kernel.org; h=from:subject:message-id; bh=PSgvoG/VeBHlNw/xybnGmp2VjTgkoJJ22Of1xt8QDDI=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmzHkrdyhy3gi+oajGUxNAMQ0Q6Svd6kHWNGjQR 3Smswpvt4mJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZsx5KwAKCRAADmhBGVaC FY4sEACv7DYAfyiucP/hI8/ZRylosazMVKdyQmg0KjRjpVgiqshJ+2sew4NQcCvv1oAFKpobhP6 pACEowXVpY60WS2Mpvja/G2yO0uGFe62WTLP26a7+hMjDxlhYMh+PeTn6RW8YWCGzP0t5VhVW3j 4iu23WO6yOJ3EaDqv7sCNlhcfKUwGkmeap0h0e9n/XXPRhO5KoUb9KukYEwARucPIPrNondwmZP SE4NE1y8vUWHCaj/iLRDTH1+EA52J9mYFlB3I5vZdntPrX83XhdPg/aEzRT2xQr+ftZT+pMh8zT gGddT1orKMKq5iJKR6UNcQG7IdYJoSeentoun5CA/IWQWR6SqJVBO8KemI7cXOQhA4nvqghXoYR K2WPPCaoNhKdJtz2COnwLZV033amZAt7hhXtuUQGYfk99Sox3PMHQ/9wABxbN+3rJChbEsD7OYQ w/gT2zjrsXxn7uOjlN6krpt1bq7w2BUj9rv/pgfHwdjlNHx6gH4vyJxEMExE8HCbcbeMcJfozKU 0arZWgvWmSVjjcc6gqRY61aHHViX1s7HHf4C1D6YEaR7pPgAvwsNyvZH20OUBLAxYM9mF9BxH6Y qSw3SwKv1thdenCTgS4XHEhJvZPet2U5kXNCgdq91Q/2+2C20B78Wf7D1gfqBxSEVKGdjdtvFPI VBt+0lPmjTlN7kw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 When updating the ctime on an inode for a setattr with a multigrain filesystem, we usually want to take the latest time we can get for the ctime. The exception to this rule is when there is a nfsd write delegation and the server is proxying timestamps from the client. When nfsd gets a CB_GETATTR response, we want to update the timestamp value in the inode to the values that the client is tracking. The client doesn't send a ctime value (since that's always determined by the exported filesystem), but it does send a mtime value. In the case where it does, then we may also need to update the ctime to a value commensurate with that. Add a ATTR_CTIME_DELEG flag, which tells the underlying setattr machinery to respect that value and not to set it to the current time. Signed-off-by: Jeff Layton --- fs/attr.c | 10 +++++++++- include/linux/fs.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/attr.c b/fs/attr.c index 7144b207e715..0eb7b228b94d 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -295,7 +295,15 @@ static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr) return; } - now = inode_set_ctime_current(inode); + /* + * In the case of an update for a write delegation, we must respect + * the value in ia_ctime and not use the current time. + */ + if (ia_valid & ATTR_CTIME_DLG) + inode_set_ctime_to_ts(inode, attr->ia_ctime); + else + now = inode_set_ctime_current(inode); + if (ia_valid & ATTR_ATIME_SET) inode_set_atime_to_ts(inode, attr->ia_atime); else if (ia_valid & ATTR_ATIME) diff --git a/include/linux/fs.h b/include/linux/fs.h index 7c1da3c687bd..43a802b2cb0d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -211,6 +211,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, #define ATTR_TIMES_SET (1 << 16) #define ATTR_TOUCH (1 << 17) #define ATTR_DELEG (1 << 18) /* Delegated attrs (don't break) */ +#define ATTR_CTIME_DLG (1 << 19) /* Delegation in effect */ /* * Whiteout is represented by a char device. The following constants define the From patchwork Mon Aug 26 12:46:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13777888 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 AF33B1990A5; Mon, 26 Aug 2024 12:46:47 +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=1724676407; cv=none; b=iYEoprLiKbicrInzRFF5EgBMhkw0HR4AuCD3b1f4r4IOi/bygJgNqxlmwuwjSC9W2T4w/lgWTHvDI+JO7X9p0DRtTW5/ZKXRfWHMfjkXbOz7MqzNNr/9EG2E/w2HtendwJnEfUHxWnxaGOSkl+18tx7kL+Jm4k9DF5L9CXSZYe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724676407; c=relaxed/simple; bh=yl4UFuynbiJ98Ciyso+Lbsj/YmQM0+7vnTVk3AZWOGI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dENbYIyXMu+iPdFQdrINUqMi4P1Pz8z8HpWkAe45FLv2oHVR5GXIYCHBqEPbQ3CZmLLWRUiV1M7aJlCaPD8u5IcODxSbHdiEdRBYgEjFx89OPdS7KLjSrP2+BBfSrRBIEZWXtW7VoSDPby2Gz//qKtzxA0zoeCDJii3YgAlNPck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BLBsmIgS; 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="BLBsmIgS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C503C581BE; Mon, 26 Aug 2024 12:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724676407; bh=yl4UFuynbiJ98Ciyso+Lbsj/YmQM0+7vnTVk3AZWOGI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BLBsmIgSbc2y3pU7lYPKNez6ask0MRUa8bDPzOj2BDQX11iLWEt/s/4O+ytVy+1PB N21v7D+FIfKLWlF9LWcB0dAh6tLDQ1zEVgGyyun43R8t8e7nhvhpY+yK2S2TDHBT6k 3Uj77xuhZhVsyJ2DEjRC2jNHGqguDA8JeMYK3YzjNGeTu4gQOWnwmYRIF8D0PGV+AC letGqHBRMpQSEwWoxGhM3nUcid3i2TtVbYu8pXO+ziQvzdTMQ1mekz0hTkLf3YH1tm BBosRkhJ/aPwq/4MUtrmYKZTeyuMVf8oz/Ni/h0W0yqiO1xB/2Taq4VUbw0IGpVAsm c/8Ln7bq+M0Jg== From: Jeff Layton Date: Mon, 26 Aug 2024 08:46:16 -0400 Subject: [PATCH v2 6/7] nfsd: drop the ncf_cb_bmap field Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240826-delstid-v2-6-e8ab5c0e39cc@kernel.org> References: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Olga Kornievskaia , Alexander Viro , Christian Brauner , Jan Kara , Jonathan Corbet Cc: Tom Haynes , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2063; i=jlayton@kernel.org; h=from:subject:message-id; bh=yl4UFuynbiJ98Ciyso+Lbsj/YmQM0+7vnTVk3AZWOGI=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmzHkrsuxhyr2MFrH+pUCecIKuNzFZRj2s1RCsr R28DmsULE+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZsx5KwAKCRAADmhBGVaC FY3MD/4kHmhHVT1T2FL/qgzN84FPawf5+TQMMDNlpiyYzi+5E9wnRzG378nSxpqyGeIWj/7iFjG R00h21QU5v6WMzrjZd95duOVOu5Punw2j6dOQH+RmK9mI3nG8mw6eT0JGwCXr798KGJanQTFBJG Bxe28+7UhnT9J+pZL/EePm0E6xadpMQw3tassGZbv+4FkVx4sO4B8xaYdlMiputqsz6qeOXO5Tu ZYexFGTPkTaK4BFqgVT07Zn/U0xEuQ7ADBv6+Ek0Cyc9o6HsVBOo2u3GJnbaqXkm79bVAviGllV WQ56rOaJl3PiIRSWEwMLL2tEuhUNvRi3NUnaIjc62irFdDZJtMuqGf/jkwx8UxR+PKCz3H7+CJ0 +NDRGJ3Yx7kaM/PtgMahFh8WJdxvIAusliMf3Nn8m289BDHEOCkoFZ9fPsnmBz5TUuWmU2DTOzP qaPNennGk0FUfU26P9U/fU1tYLH9922ot+0QxO5j5POu+WKKZQxE+hqdkoQhD7tLe2jn2x88cRo RRKVaaAPQSG6VFhJXUiyslHv430kZKUbjgtvgl6q1CnuBefuvawR5OuXJQd59X6NEtoB9snCF6r rEI9GBx5KDhhw32lBUtuDOnfwy+UMoAlvQp4sjowNRX6wa9D+QFc2ZjSGGVKXB8SXmYxFvo7Tau wy9/9S/Pf2Cmekg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 This is always the same value, and in a later patch we're going to need to set bits in WORD2. We can simplify this code and save a little space in the delegation too. Just hardcode the bitmap in the callback encode function. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 5 ++++- fs/nfsd/nfs4state.c | 1 - fs/nfsd/state.h | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index d756f443fc44..988232086589 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -364,10 +364,13 @@ encode_cb_getattr4args(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr, struct nfs4_delegation *dp = container_of(fattr, struct nfs4_delegation, dl_cb_fattr); struct knfsd_fh *fh = &dp->dl_stid.sc_file->fi_fhandle; + u32 bmap[1]; + + bmap[0] = FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE; encode_nfs_cb_opnum4(xdr, OP_CB_GETATTR); encode_nfs_fh4(xdr, fh); - encode_bitmap4(xdr, fattr->ncf_cb_bmap, ARRAY_SIZE(fattr->ncf_cb_bmap)); + encode_bitmap4(xdr, bmap, ARRAY_SIZE(bmap)); hdr->nops++; } diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index b544320246bf..f353aeb4cc0a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1182,7 +1182,6 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_file *fp, nfsd4_init_cb(&dp->dl_cb_fattr.ncf_getattr, dp->dl_stid.sc_client, &nfsd4_cb_getattr_ops, NFSPROC4_CLNT_CB_GETATTR); dp->dl_cb_fattr.ncf_file_modified = false; - dp->dl_cb_fattr.ncf_cb_bmap[0] = FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE; get_nfs4_file(fp); dp->dl_stid.sc_file = fp; return dp; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index ec4559ecd193..65691457d9ba 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -137,7 +137,6 @@ struct nfs4_cpntf_state { struct nfs4_cb_fattr { struct nfsd4_callback ncf_getattr; u32 ncf_cb_status; - u32 ncf_cb_bmap[1]; /* from CB_GETATTR reply */ u64 ncf_cb_change; From patchwork Mon Aug 26 12:46:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13777889 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 B28DE1946B1; Mon, 26 Aug 2024 12:46:49 +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=1724676409; cv=none; b=My4N0gq9HLa+eQJHAQ4nNmy8oaSHhu7v5gKJE11OtTbwUXNWrK5l1cRJoyHYQLOqA90jF9vd41boA2NBINQBsK6OzEXgPoYjE+P2xTIptK7qsNVq5qZTTnorUiinZCuX170HYpMPHa1lWYON4dFJl8fCdRfcePLv11bCawNNbfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724676409; c=relaxed/simple; bh=sdSxDYPop03aiNFLgfHj/2yfQDSj1gBVwywHfAg6B1o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WdppgKN2FJZKel8CXUPYlCdjisUtWPk2LebOaN0+MZiUY9pf5gVK51WY84GMYZ6jQLLXBxVfSsAl4WZvg81oO8TNPaY1xkJQnkI0nyTcOfOD47DilDaYa0xiE9Rfcuhg/afRAG7nle0yqm7doC14P/oXe3FLRC1MrYL/sqc4daE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MM/DRcOH; 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="MM/DRcOH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD46FC58280; Mon, 26 Aug 2024 12:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724676409; bh=sdSxDYPop03aiNFLgfHj/2yfQDSj1gBVwywHfAg6B1o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MM/DRcOHVhyccozR42sW+tha1/xouT3iNeq2N3py09kH+O+3xQzRuv1NLdPAVARTD kCVS0PHuHpTMttnqOLPbP1xqHj7/07yux28ZVhSagXR8fMzFmCFHvSI3SE5j3izq9g fKLPpRGKobx5/luNuJ/Pn+sAlCj0RSy6CIUDX8wwKro+dXi96wQKBqXwBQyx26u7jo LeHGV0YGW8kTwqat4ouN67RqVMFGkeF5WxrN6utgDcOCDBBDzgzcpm0TItWrxBu1qV qsLIdNFHuIlAqz70K927XvLRG9urBHbMaUS9IcGYMI9e0fLv0BabtnAeLOWX9IXBLe HZfHuPNunAWGQ== From: Jeff Layton Date: Mon, 26 Aug 2024 08:46:17 -0400 Subject: [PATCH v2 7/7] nfsd: add support for delegated timestamps Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240826-delstid-v2-7-e8ab5c0e39cc@kernel.org> References: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Olga Kornievskaia , Alexander Viro , Christian Brauner , Jan Kara , Jonathan Corbet Cc: Tom Haynes , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=10947; i=jlayton@kernel.org; h=from:subject:message-id; bh=sdSxDYPop03aiNFLgfHj/2yfQDSj1gBVwywHfAg6B1o=; b=kA0DAAgBAA5oQRlWghUByyZiAGbMeSug9QeeVoMDQuldltO9W/S4C1aDARH0wCQ3weeXI15Ln 4kCMwQAAQgAHRYhBEvA17JEcbKhhOr10wAOaEEZVoIVBQJmzHkrAAoJEAAOaEEZVoIVuvQP/Axo OhT2KVqh+hY9uz7rG0VEs3br0zXvhJaCpCY1KXwASLj+Z3FST+gtB6pCktI5uGYSPjiNYgQn4WS hHdyKuQhZ15/axQslfqcY7uWJsVyKds2rkc/W08onS9C5y9hCrN92O9L5RNCAtKVE4h7jcC/Pqj yJ1eUasJg1fYbJiUJHoHgsy9Irqj3L//6GQ48GffEmlyOXqR8jo3SOYr8+VkU7etTK3NKz4DPfh rbIFddtEmIul4z1sgerZuuYhgdygsTRfY5flIihWp8AmilAN5qc817NK80sBgvwJkeRXSMdNC1Y e/t9ag8g0TRH5FgX2n/eaFPzQbLuFlXFCH4O3QYtkZrYm/qd0w3+kh40XzKwOt02Nia2rUVtsKv BFnfLX42zkcpTUvZkjngnP0skk0KVs1Ios21uSkXrCyJG+nD+PYKgUPDWDjI19D4wjH5WCNiBuw iHNhSIKnMHumcsyP7ZwkfRd5sHtbhaTUlndX3rviW3jBkPGZcdcLzV7zVNJnx31w5CjnOpxXtJg amRdRhKCf6LQKiZcBJAw60FUiJ0Eh0QB+Ex0jJTKaEBcoAw/RZWdO3k9ZHURPxpop7VJwxYm+ot j2JKrIr41Md409i/RQjUFyEwDQj/ziNmZq0cOiIBTseoxgxByhWjCGvsiZ1UbV1jnbAdj3FJ5PT OzJRC 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. Add a new flag to nfs4_delegation for indicating that the client can provide timestamps in the CB_GETATTR response. Set that when the client sets the appropriate flag in the open request. 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. For multigrain timestamps, ensure that we accept the client's version of the ctime instead of updating to the latest clock as we normally would. That should be fine since the client holds a delegation, and nothing else will be making changes. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 42 +++++++++++++++++++++--- fs/nfsd/nfs4state.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++---- fs/nfsd/nfs4xdr.c | 1 + fs/nfsd/nfsd.h | 3 +- fs/nfsd/state.h | 3 ++ fs/nfsd/xdr4cb.h | 10 ++++-- 6 files changed, 130 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 988232086589..d5004790f2b1 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -93,12 +93,35 @@ static int decode_cb_fattr4(struct xdr_stream *xdr, uint32_t *bitmap, { fattr->ncf_cb_change = 0; fattr->ncf_cb_fsize = 0; + fattr->ncf_cb_atime.tv_sec = 0; + fattr->ncf_cb_atime.tv_nsec = 0; + fattr->ncf_cb_mtime.tv_sec = 0; + fattr->ncf_cb_mtime.tv_nsec = 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 = access.seconds; + fattr->ncf_cb_atime.tv_nsec = 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 = modify.seconds; + fattr->ncf_cb_mtime.tv_nsec = modify.nseconds; + + } return 0; } @@ -364,13 +387,18 @@ encode_cb_getattr4args(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr, struct nfs4_delegation *dp = container_of(fattr, struct nfs4_delegation, dl_cb_fattr); struct knfsd_fh *fh = &dp->dl_stid.sc_file->fi_fhandle; - u32 bmap[1]; + u32 bmap[3]; + u32 bmap_size = 1; bmap[0] = FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE; - + if (dp->dl_deleg_ts) { + bmap[1] = 0; + bmap[2] = FATTR4_WORD2_TIME_DELEG_ACCESS | FATTR4_WORD2_TIME_DELEG_MODIFY; + bmap_size = 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++; } @@ -595,7 +623,7 @@ static int nfs4_xdr_dec_cb_getattr(struct rpc_rqst *rqstp, struct nfs4_cb_compound_hdr hdr; int status; u32 bitmap[3] = {0}; - u32 attrlen; + u32 attrlen, maxlen; struct nfs4_cb_fattr *ncf = container_of(cb, struct nfs4_cb_fattr, ncf_getattr); @@ -614,7 +642,11 @@ static int nfs4_xdr_dec_cb_getattr(struct rpc_rqst *rqstp, 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 = sizeof(ncf->ncf_cb_change) + sizeof(ncf->ncf_cb_fsize); + if (bitmap[2] != 0) + maxlen += (sizeof(ncf->ncf_cb_mtime.tv_sec) + + sizeof(ncf->ncf_cb_mtime.tv_nsec)) * 2; + if (attrlen > maxlen) return -NFSERR_BAD_XDR; status = decode_cb_fattr4(xdr, bitmap, ncf); return status; diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f353aeb4cc0a..ea63c4f0ef0a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5975,6 +5975,8 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid)); + if (open->op_deleg_want & NFS4_SHARE_WANT_DELEG_TIMESTAMPS) + dp->dl_deleg_ts = true; if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) { open->op_delegate_type = NFS4_OPEN_DELEGATE_WRITE; trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid); @@ -8819,6 +8821,83 @@ nfsd4_get_writestateid(struct nfsd4_compound_state *cstate, get_stateid(cstate, &u->write.wr_stateid); } +/** + * 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 *orig, + 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) <= 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 = *now; + } + + return true; +} + +static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation *dp) +{ + struct timespec64 now = current_time(d_inode(dentry)); + struct nfs4_cb_fattr *ncf = &dp->dl_cb_fattr; + struct inode *inode = d_inode(dentry); + struct iattr attrs = { }; + int ret; + + if (dp->dl_deleg_ts) { + struct timespec64 atime = inode_get_atime(inode); + struct timespec64 mtime = inode_get_mtime(inode); + + attrs.ia_atime = ncf->ncf_cb_atime; + attrs.ia_mtime = ncf->ncf_cb_mtime; + + if (set_cb_time(&attrs.ia_atime, &atime, &now)) + attrs.ia_valid |= ATTR_ATIME | ATTR_ATIME_SET; + + if (set_cb_time(&attrs.ia_mtime, &mtime, &now)) { + struct timespec64 ctime = inode_get_ctime(inode); + + attrs.ia_valid |= ATTR_MTIME | ATTR_MTIME_SET; + if (timespec64_compare(&attrs.ia_mtime, &ctime) > 0) { + attrs.ia_valid |= ATTR_CTIME | ATTR_CTIME_DLG; + attrs.ia_ctime = attrs.ia_mtime; + } + } + } else { + attrs.ia_valid |= ATTR_MTIME | ATTR_CTIME; + attrs.ia_mtime = attrs.ia_ctime = now; + } + + if (!attrs.ia_valid) + return 0; + + attrs.ia_valid |= ATTR_DELEG; + inode_lock(inode); + ret = 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 @@ -8846,7 +8925,6 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry, struct file_lock_context *ctx; struct nfs4_cb_fattr *ncf; struct file_lease *fl; - struct iattr attrs; *modified = false; ctx = locks_inode_context(inode); @@ -8905,11 +8983,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 = attrs.ia_ctime = current_time(inode); - attrs.ia_valid = ATTR_MTIME | ATTR_CTIME | ATTR_DELEG; - inode_lock(inode); - err = notify_change(&nop_mnt_idmap, dentry, &attrs, NULL); - inode_unlock(inode); + err = cb_getattr_update_times(dentry, dp); if (err) { nfs4_put_stid(&dp->dl_stid); return nfserrno(err); diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 8266f910d847..c79f7402bc30 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3411,6 +3411,7 @@ static __be32 nfsd4_encode_fattr4_xattr_support(struct xdr_stream *xdr, #define NFSD_OA_SHARE_ACCESS_WANT (BIT(OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG) | \ 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_OPEN_XOR_DELEGATION)) #define NFSD_OA_OPEN_CLAIM (BIT(OPEN_ARGS_OPEN_CLAIM_NULL) | \ diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index c98fb104ba7d..2d89b82e5453 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -421,7 +421,8 @@ enum { | FATTR4_WORD1_TIME_DELTA | FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_CREATE \ | FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID) -#define NFSD4_SUPPORTED_ATTRS_WORD2 0 +#define NFSD4_SUPPORTED_ATTRS_WORD2 (FATTR4_WORD2_TIME_DELEG_MODIFY | \ + FATTR4_WORD2_TIME_DELEG_ACCESS) /* 4.1 */ #ifdef CONFIG_NFSD_PNFS diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 65691457d9ba..b2ffb7d36721 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -141,6 +141,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; unsigned long ncf_cb_flags; bool ncf_file_modified; @@ -184,6 +186,7 @@ struct nfs4_delegation { int dl_retries; struct nfsd4_callback dl_recall; bool dl_recalled; + bool dl_deleg_ts; /* for CB_GETATTR */ struct nfs4_cb_fattr dl_cb_fattr; diff --git a/fs/nfsd/xdr4cb.h b/fs/nfsd/xdr4cb.h index e8b00309c449..f1a315cd31b7 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)