Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp181317lqp; Tue, 11 Jun 2024 20:08:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV19sJR6mINwZrh7VuOVBFQUNIx2PnvZ82GaPAvbwcVg4WAi5SbMHATLEKkZmW0g4Ivt8tFvC/hGQiMJqJM/LsCeMzfQ3tKpI9whrhkqw== X-Google-Smtp-Source: AGHT+IHhEGN5tWQiOJYrNKwd2Cg8W9UC42YowjiiJS2t+foevjg33cBRNJrrSeno/109v7PEEv2k X-Received: by 2002:a17:906:c419:b0:a6e:f793:fcf6 with SMTP id a640c23a62f3a-a6f34cc5803mr281408666b.16.1718161703194; Tue, 11 Jun 2024 20:08:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718161703; cv=pass; d=google.com; s=arc-20160816; b=sS+JqlfbUu9IYlM2AcPG1MP1cxneIF3lKFFEKFmh7GeDJlxAah+blqvEtxUvGvgX44 9noIwbEQ9QGjPAW7NdjuV71gjlAfRThS79aO/Dsvc1CNDZ/KGkaRCAj9oPwutBsUWJZr KkDFapHvVF1wWNnbLKpSfBVIY+HI2KHdqX0vkAqkMTbWnljk7BDANT2wdu6SwcuD1o1Z o672EzSbfpOjU/v7IoalpYdXHdl0JT6xwZiayf49ds2nmH97btBMMHV9kDnrbzyZ+kcp 0R/WBmMNdtDGPNFCrwyohij4M5t0BgHWSVPSlgetD3DI/bqyMvN7zOLCrqSUVpxXpXOH rinA== 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=MbPj50xB6djx3nq1ACnL9B8pfy0D0RlweXlYjJxQOsE=; fh=+HdF1SWcNPggmowVZtzfZ2+SYSXLLgvZBECjaw6UQek=; b=dU21CfUMag72RciGvx8E54KCNvL+a3nZH4r0RJOufGbVs3A/bU6vnvUsT1ppkKMtCQ Z/hd2UO2xomMseTEvOtY7yXeQQPvUAndqMvEaPtAMDZOmjVfoxyFHDtQYdyPXS4xL5PK D+qhLJ6lpt4MJ+KUHUFrdQPM32RkahPTv9+78M0XhEFUVzSQmbDlzx3HxFUh/Fup3yJ+ BY9S9lkaiFdkc1MMhUfUjOJb/bkP0Pd7Jbs5a6omFkRpIRR+R+izqrT0YbDjahAzsvSK MOaPF7BYIkgW3mNDzRONJ9B1J6YloKffgQs+bZKhvXjtm9zEf6jKRjDgOCChBqwg93Wu ddmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LLjeGDQW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3669-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-a6efea88a44si409113666b.488.2024.06.11.20.08.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 20:08:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3669-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=LLjeGDQW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3669-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 CDFF01F226E9 for ; Wed, 12 Jun 2024 03:08:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE3F729408; Wed, 12 Jun 2024 03:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LLjeGDQW" 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 BA76729413 for ; Wed, 12 Jun 2024 03:08:12 +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=1718161692; cv=none; b=H5SDi5uzwsen8UIisJUzziRAv9sHjVQKXh/Hgja3IWVCUZJ/7PYYdDCBZ4OCb/tUbms5ycJ7OTgqA46CaTC+u8sSTmBODq+zsyzBv0xK7CZvVgggc4a4TNB4meffW6UMSzG6CBeMiMwXeVanLfPnQqplBTXYyVBcxRFj2D37/u0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718161692; c=relaxed/simple; bh=hvvrtj9EQvdttxz6RCaCjY4hSWTpXoeAgbtItksIgP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UAAAlSdNJGgjqkWgViLH981SXaIeY2Og8suSNiJnPmd/kMzIHE8BtOJTKFoiKZ2l4ewE49jx3D9EOwjpuulE07OWHCYdwn/Qs7io1VF3TSp/oLi3vqCSQXfF4DN/NQunMg1k2OgloCIE5rPSg3nzMmi7bvctRc3WBMMqPXP2jWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LLjeGDQW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64916C2BD10; Wed, 12 Jun 2024 03:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718161692; bh=hvvrtj9EQvdttxz6RCaCjY4hSWTpXoeAgbtItksIgP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LLjeGDQWV/7OdbTey3Avbj6fxXchitBnRd5aYSBnDAKVo1LVgYWdNwGITbeOR2p2R 8mXQE5zaDzuRLGvRV+1H2zaAWN11dlRogj67h/6QlJO+JFB7rwHGQQgzbMImmoJ2lz /SRLh3zA1vVk1OMAas2GN9cp+2HiJPCRbdKDoNs0B/MA3EKsN/I8gxTGQw3WzV0kfI AIGi9XAA0C3udvQSSEoi3i1WMl6FNuWsOdfyLTosekN3ZQEwReBZiPcj5W5zMFODJf EAlGKRtFzmPQ4wjt202lVFjbw9cH3bAQ7d9G5J5/hPZzw0jO3O4eHqP9+fhSymvYoj 3XIPfSPPnAJgw== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , NeilBrown , snitzer@hammerspace.com Subject: [RFC PATCH v2 13/15] nfs/nfsd: consolidate {encode,decode}_opaque_fixed in nfs_xdr.h Date: Tue, 11 Jun 2024 23:07:50 -0400 Message-ID: <20240612030752.31754-14-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240612030752.31754-1-snitzer@kernel.org> References: <20240612030752.31754-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 e35480595ec9..866e8c8a5548 100644 --- a/fs/nfsd/localio.c +++ b/fs/nfsd/localio.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include "nfsd.h" @@ -208,11 +210,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