Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp561990lqs; Thu, 13 Jun 2024 20:44:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6jbW0o9y+xkwsOyUYwWGKm6fiIgh/bQhrO+sy+8XN/4ksTHYFXQOeC3DkTTVf53C9O9H81dAHcJ+3zIK27Eh2K7WUc/G3K7p8u9db2A== X-Google-Smtp-Source: AGHT+IHRS5AWH6EN08ZJDU/t3cCSpLx32b8E5r6CMGAN8NSpFRCDgyjPmIVU3bHjC8Oxzt+kUmXH X-Received: by 2002:a17:906:4887:b0:a6f:354d:9893 with SMTP id a640c23a62f3a-a6f5245cd55mr305837966b.28.1718336697380; Thu, 13 Jun 2024 20:44:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718336697; cv=pass; d=google.com; s=arc-20160816; b=oVaGGXnEhMP2YWNhmZCEsh8XtWFcnRqsnys37QhsUll/OdEQZqiWwwtWURYZcnFQkZ iZkbN2s1EGOEYwtSnmPVM2WrvACP+bAJ7Ghj8NUAeFQ+XNoGUw4RHoC0AtO1gXYBMwrx aIEnbacEaYSdJziLHS3py0UnAq/Fg4ygL38jxYVQqSjuoH9JlX2o7c5jhZjVwPhUFf8X Q1xxeEYC3cvvzsqpNeuGtHvZcmALhBl2li/hHO6Bw2yUam8wRtw9S89PZ0f2TqmD68xZ F+ULilYs9fLo9f9s5pzizYoaopzp8O+EhnLF+5XilCm7cYH5KXVVY60+Xc3WvLTkuzGZ NyxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=P48ef0l4l+CYDXSL4msiFXklS9YlV4qczMABANLujQ8=; fh=+HdF1SWcNPggmowVZtzfZ2+SYSXLLgvZBECjaw6UQek=; b=AowK+S4j0kbUYjYwazRlPBO3HrUA6+ik27a4nrm1fpkTgzuniLjQYhWJZcuRNKMDQ+ xkt6HR3XmQmFkOjxar+9APen//keNNQHbEk/9OdYoqfpTju1FrR+19bD5RTjA7+Rn6eG mM4xytmMPw3xbRx/T3VMeAHOEITMy1H9o+Yxk1sqHDJVijrA5mftgKtaGu4xRpKhZv0m Nuc3s188Wdnw9bOae147k4nFLD7CR36bODUtsaMrdlgXxq3E4QIe6FUrilqWMOpIOx8H Mh61qup1cXUU5kusK0yEmsFVa9fRBZ8ajTTKREWBZlt2W9jTpIh8Xf+PLn38P1OAxoVy e3Dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O1oLn+72; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3812-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56dd5e8dsi128611466b.400.2024.06.13.20.44.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 20:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O1oLn+72; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3812-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1C6561F241F6 for ; Fri, 14 Jun 2024 03:44:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77318146D73; Fri, 14 Jun 2024 03:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O1oLn+72" X-Original-To: linux-nfs@vger.kernel.org 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 534FF146D40 for ; Fri, 14 Jun 2024 03:44: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=1718336684; cv=none; b=BUc+VwsxRxoKpgCFUEZBGoWPxHJOpKqqf0WA7n7H7g9qbNy54Gr0PgSF0SEfa1cPev+ckgiJJDGPZPSOKSm4SdGq9sAUif4yrYbNPOgjkKT8KzFFG33ajy5YUcjaTVIAnbC/jo9PIMR1U5TyJVOdIXKKI4F9AvwNFP7vliZXWPA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718336684; c=relaxed/simple; bh=abK5oPUtz+Jhmhx7HxELuk/43QgqF1f5Zo34E08TUKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XIcgYsQzMCd22xvmDXQ8jg55xo8ybDySQp/QEgNjP9MLW/Rr2lCc5yCJJkFOcjUW/OdfC1MTY+VfKXTOdYotd9fT7+vHNxREPzkGEGoPFJnbDFSdszik8T2wO8i4F+sWaY/TYheE8p0UE2jYIigKKpq/MjoelYgpQZOudrR5Iws= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O1oLn+72; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2D23C2BBFC; Fri, 14 Jun 2024 03:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718336684; bh=abK5oPUtz+Jhmhx7HxELuk/43QgqF1f5Zo34E08TUKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O1oLn+72qpMYdrKfTEAqc2QyXjz4WQOGuF0z/wxMuEXLD/Qk3SjG5ySXb05ci+5ef X3V/55Xo2jr/SyHS+z39GMYj4EYH9jbRrNpe4koF9E2V0bRZRwkBhi4YNVovJk3Ky9 O/iBfCgU+RWf8lYDcR9592+x96i6/fNu49XGjByQ9tnOCl7NEWgS0X8OEmZYxkg+bc Egi8UvEL0ooW0N5T4yKd0rvYLvJRk1hWRwCCGcuchbWd16eTn8NVohpO0zd9Y5rNER GzCexdIUiD3ANZkuudGLGuo0qCtmVOTHL4IORSqRHu6wy9/o83mhODcgbMobIZApKn iEiMwaMnyyvvA== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , NeilBrown , snitzer@hammerspace.com Subject: [PATCH v3 12/18] nfs/nfsd: consolidate {encode,decode}_opaque_fixed in nfs_xdr.h Date: Thu, 13 Jun 2024 23:44:20 -0400 Message-ID: <20240614034426.31043-13-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240614034426.31043-1-snitzer@kernel.org> References: <20240614034426.31043-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Eliminates duplicate functions in various files. Signed-off-by: Mike Snitzer --- fs/nfs/flexfilelayout/flexfilelayout.c | 6 ------ fs/nfs/nfs3xdr.c | 9 --------- fs/nfs/nfs4xdr.c | 13 ------------- fs/nfsd/localio.c | 7 ++----- include/linux/nfs_xdr.h | 20 +++++++++++++++++++- 5 files changed, 21 insertions(+), 34 deletions(-) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index ec6aaa110a7b..8b9096ad0663 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -2185,12 +2185,6 @@ static int ff_layout_encode_ioerr(struct xdr_stream *xdr, return ff_layout_encode_ds_ioerr(xdr, &ff_args->errors); } -static void -encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) -{ - WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0); -} - static void ff_layout_encode_ff_iostat_head(struct xdr_stream *xdr, const nfs4_stateid *stateid, diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index d2a17ecd12b8..95a2fb0733ae 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c @@ -2591,15 +2591,6 @@ static void nfs3_xdr_enc_getuuidargs(struct rpc_rqst *req, /* void function */ } -// FIXME: factor out from fs/nfs/nfs4xdr.c -static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) -{ - ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); - if (unlikely(ret < 0)) - return -EIO; - return 0; -} - static inline int nfs3_decode_getuuidresok(struct xdr_stream *xdr, struct nfs_getuuidres *result) { diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index d3b4fa3245f0..6b35b1d7d7ce 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -968,11 +968,6 @@ static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) return p; } -static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) -{ - WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0); -} - static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) { WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0); @@ -4352,14 +4347,6 @@ static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) return 0; } -static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) -{ - ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); - if (unlikely(ret < 0)) - return -EIO; - return 0; -} - static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) { return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c index bb84e165dbe1..7ecd72406dc0 100644 --- a/fs/nfsd/localio.c +++ b/fs/nfsd/localio.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include "nfsd.h" @@ -267,11 +269,6 @@ static __be32 nfsd_proc_getuuid(struct svc_rqst *rqstp) #define NFS_getuuid_sz XDR_QUADLEN(UUID_SIZE) -static inline void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) -{ - WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0); -} - static void encode_uuid(struct xdr_stream *xdr, uuid_t *src_uuid) { u8 uuid[UUID_SIZE]; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 2a438f4c2d6d..daa4115f6be6 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1826,6 +1826,24 @@ struct nfs_rpc_ops { void (*init_localioclient)(struct nfs_client *); }; +/* + * Helper functions used by NFS client and/or server + */ +static inline void encode_opaque_fixed(struct xdr_stream *xdr, + const void *buf, size_t len) +{ + WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0); +} + +static inline int decode_opaque_fixed(struct xdr_stream *xdr, + void *buf, size_t len) +{ + ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); + if (unlikely(ret < 0)) + return -EIO; + return 0; +} + /* * Function vectors etc. for the NFS client */ @@ -1844,4 +1862,4 @@ extern const struct rpc_program nfslocalio_program3; extern const struct rpc_version nfslocalio_version4; extern const struct rpc_program nfslocalio_program4; -#endif +#endif /* _LINUX_NFS_XDR_H */ -- 2.44.0