From patchwork Mon Jun 24 16:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 13709830 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 4DBE419DF65 for ; Mon, 24 Jun 2024 16:27:58 +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=1719246478; cv=none; b=CABds2n1nOYICcTeAch0RdXzWyZg+g4THh/HGvwUvyGzsoj4QfVAdLEvb17No31tUIi4Exq9l6By+NW7I/VzpfgN93uQqMckWOPxzGJb6ynXYcQ2F3y48ZDK38E7mpogU3GHBTGXay3lTuEl0c+BpVGIX+r4PvAzeDURSvPkTE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246478; c=relaxed/simple; bh=i0Hg7Di7ViVzTwEPbXHxTBXT/ZyLE/03WHls5qFK+Sw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tLOu1lTco7EmqpfnEDhkjvZoaNVFr6kBJHKSlYF44UCo/TwIFwpfNSM+CzC5PLH8j9y1wS48VxuFdvGDvwAYZCiBtJ/Tf5Lc7aNg7U/0Cb6I7Xc+z+YPBxAL03NVY74Q6gLMeCfi31NnW2NOYLs5aIQi/KpkkkthOBMRvhcMZzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t86kEGmK; 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="t86kEGmK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6334C2BBFC; Mon, 24 Jun 2024 16:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719246478; bh=i0Hg7Di7ViVzTwEPbXHxTBXT/ZyLE/03WHls5qFK+Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t86kEGmK3sm4kXAIxCQNO0uGsdlK7UXRQb8tOwWe+rZRY+rPupxSOcVSmuyrbQFzc GCHtg+nhdCsBeQFkdq9YImUpURYVOWx5hVZ6BaeaGzZUeddQ1/vMM+7554zK6RjO5e 2/j8UFoHZ2gbVSQ3EDDQK2LON1WOugiLkmgEp0qpN5GBV8PJ5preLj2sTlYLVpVis1 MWhPFsPIEdhEJSa6IDjPR0pfuRmSDpFmj7otQYbQvpz9ZPKjYmpXIxmmc1QTgitaBV 8E8QXf4EAgymZiLsSST0PWByWA+c8nDUuG0Nv74LMB0NVWuu1hHdLOyjQ9PiQh1w3m B00fdH+R3rsUA== From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , NeilBrown , snitzer@hammerspace.com Subject: [PATCH v7 11/20] nfs/nfsd: factor out {encode,decode}_opaque_fixed to nfs_xdr.h Date: Mon, 24 Jun 2024 12:27:32 -0400 Message-ID: <20240624162741.68216-12-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240624162741.68216-1-snitzer@kernel.org> References: <20240624162741.68216-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Eliminates duplicate functions in various files to allow for additional callers. Signed-off-by: Mike Snitzer --- fs/nfs/flexfilelayout/flexfilelayout.c | 6 ------ fs/nfs/nfs4xdr.c | 13 ------------- include/linux/nfs_xdr.h | 20 +++++++++++++++++++- 3 files changed, 19 insertions(+), 20 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/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 1416099dfcd1..ede431ee0ef0 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/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index d09b9773b20c..bb460af0ea1f 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1820,6 +1820,24 @@ struct nfs_rpc_ops { void (*disable_swap)(struct inode *inode); }; +/* + * 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 */ @@ -1833,4 +1851,4 @@ extern const struct rpc_version nfs_version4; extern const struct rpc_version nfsacl_version3; extern const struct rpc_program nfsacl_program; -#endif +#endif /* _LINUX_NFS_XDR_H */