From: Mike Snitzer <snitzer@kernel.org>
To: linux-nfs@vger.kernel.org
Cc: Jeff Layton <jlayton@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>,
Trond Myklebust <trondmy@hammerspace.com>,
NeilBrown <neilb@suse.de>,
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 [thread overview]
Message-ID: <20240612030752.31754-14-snitzer@kernel.org> (raw)
In-Reply-To: <20240612030752.31754-1-snitzer@kernel.org>
Eliminates duplicate functions in various files.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
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 <linux/sunrpc/svcauth_gss.h>
#include <linux/sunrpc/clnt.h>
#include <linux/nfs.h>
+#include <linux/nfs_fs.h>
+#include <linux/nfs_xdr.h>
#include <linux/string.h>
#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
next prev parent reply other threads:[~2024-06-12 3:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 3:07 [RFC PATCH v2 00/15] nfs/nfsd: add support for localio Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 01/15] nfs: pass nfs_client to nfs_initiate_pgio Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 02/15] nfs: pass descriptor thru nfs_initiate_pgio path Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 03/15] nfs: pass struct file to nfs_init_pgio and nfs_init_commit Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 04/15] sunrpc: add rpcauth_map_to_svc_cred_local Mike Snitzer
2024-06-12 4:28 ` NeilBrown
2024-06-12 18:32 ` Anna Schumaker
2024-06-12 3:07 ` [RFC PATCH v2 05/15] nfs: move nfs_stat_to_errno to nfs.h Mike Snitzer
2024-06-12 3:23 ` NeilBrown
2024-06-12 3:50 ` Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 06/15] nfs_common: add NFS LOCALIO protocol extension enablement Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 07/15] nfs/nfsd: add "localio" support Mike Snitzer
2024-06-12 4:36 ` NeilBrown
2024-06-12 4:51 ` Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 08/15] NFS: for localio don't call filesystem read() and write() routines directly Mike Snitzer
2024-06-12 4:39 ` NeilBrown
2024-06-12 3:07 ` [RFC PATCH v2 09/15] NFS: Enable localio for non-pNFS I/O Mike Snitzer
2024-06-12 5:12 ` NeilBrown
2024-06-12 3:07 ` [RFC PATCH v2 10/15] pnfs/flexfiles: Enable localio for flexfiles I/O Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 11/15] nfs: implement v3 and v4 client support for NFS_LOCALIO_PROGRAM Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 12/15] nfsd: implement v3 and v4 server " Mike Snitzer
2024-06-12 3:07 ` Mike Snitzer [this message]
2024-06-12 3:07 ` [RFC PATCH v2 14/15] nfs/localio: move managing nfsd_open_local_fh symbol to nfs_common Mike Snitzer
2024-06-12 3:07 ` [RFC PATCH v2 15/15] nfs/nfsd: ensure localio server always uses its network namespace Mike Snitzer
2024-06-12 5:11 ` NeilBrown
2024-06-12 3:12 ` [RFC PATCH v2 00/15] nfs/nfsd: add support for localio Mike Snitzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240612030752.31754-14-snitzer@kernel.org \
--to=snitzer@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=snitzer@hammerspace.com \
--cc=trondmy@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox