All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: [PATCH v1 13/16] SUNRPC: Add encoders for list item discriminators
Date: Thu, 27 Feb 2020 19:31:55 -0500	[thread overview]
Message-ID: <158284991530.38468.7171819678223366860.stgit@seurat29.1015granger.net> (raw)
In-Reply-To: <158284930886.38468.17045380766660946827.stgit@seurat29.1015granger.net>

Clean up. These are taken from the client-side RPC/RDMA transport
to a more global header file so they can be used elsewhere.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 include/linux/sunrpc/xdr.h     |   38 ++++++++++++++++++++++++++++++++++++++
 net/sunrpc/xprtrdma/rpc_rdma.c |   36 +++++-------------------------------
 2 files changed, 43 insertions(+), 31 deletions(-)

diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 80972512edfd..cddfab4a5440 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -316,6 +316,44 @@ xdr_pad_size(size_t n)
 	return xdr_align_size(n) - n;
 }
 
+/**
+ * xdr_stream_encode_item_present - Encode a "present" list item
+ * @xdr: pointer to xdr_stream
+ *
+ * Return values:
+ *   On success, returns length in bytes of XDR buffer consumed
+ *   %-EMSGSIZE on XDR buffer overflow
+ */
+static inline ssize_t xdr_stream_encode_item_present(struct xdr_stream *xdr)
+{
+	const size_t len = sizeof(__be32);
+	__be32 *p = xdr_reserve_space(xdr, len);
+
+	if (unlikely(!p))
+		return -EMSGSIZE;
+	*p = xdr_one;
+	return len;
+}
+
+/**
+ * xdr_stream_encode_item_absent - Encode a "not present" list item
+ * @xdr: pointer to xdr_stream
+ *
+ * Return values:
+ *   On success, returns length in bytes of XDR buffer consumed
+ *   %-EMSGSIZE on XDR buffer overflow
+ */
+static inline int xdr_stream_encode_item_absent(struct xdr_stream *xdr)
+{
+	const size_t len = sizeof(__be32);
+	__be32 *p = xdr_reserve_space(xdr, len);
+
+	if (unlikely(!p))
+		return -EMSGSIZE;
+	*p = xdr_zero;
+	return len;
+}
+
 /**
  * xdr_stream_encode_u32 - Encode a 32-bit integer
  * @xdr: pointer to xdr_stream
diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index b51e92d43dfd..737a54c3ad53 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -275,32 +275,6 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
 	return n;
 }
 
-static inline int
-encode_item_present(struct xdr_stream *xdr)
-{
-	__be32 *p;
-
-	p = xdr_reserve_space(xdr, sizeof(*p));
-	if (unlikely(!p))
-		return -EMSGSIZE;
-
-	*p = xdr_one;
-	return 0;
-}
-
-static inline int
-encode_item_not_present(struct xdr_stream *xdr)
-{
-	__be32 *p;
-
-	p = xdr_reserve_space(xdr, sizeof(*p));
-	if (unlikely(!p))
-		return -EMSGSIZE;
-
-	*p = xdr_zero;
-	return 0;
-}
-
 static void
 xdr_encode_rdma_segment(__be32 *iptr, struct rpcrdma_mr *mr)
 {
@@ -414,7 +388,7 @@ static int rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt,
 	} while (nsegs);
 
 done:
-	return encode_item_not_present(xdr);
+	return xdr_stream_encode_item_absent(xdr);
 }
 
 /* Register and XDR encode the Write list. Supports encoding a list
@@ -453,7 +427,7 @@ static int rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt,
 	if (nsegs < 0)
 		return nsegs;
 
-	if (encode_item_present(xdr) < 0)
+	if (xdr_stream_encode_item_present(xdr) < 0)
 		return -EMSGSIZE;
 	segcount = xdr_reserve_space(xdr, sizeof(*segcount));
 	if (unlikely(!segcount))
@@ -480,7 +454,7 @@ static int rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt,
 	*segcount = cpu_to_be32(nchunks);
 
 done:
-	return encode_item_not_present(xdr);
+	return xdr_stream_encode_item_absent(xdr);
 }
 
 /* Register and XDR encode the Reply chunk. Supports encoding an array
@@ -507,14 +481,14 @@ static int rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt,
 	__be32 *segcount;
 
 	if (wtype != rpcrdma_replych)
-		return encode_item_not_present(xdr);
+		return xdr_stream_encode_item_absent(xdr);
 
 	seg = req->rl_segments;
 	nsegs = rpcrdma_convert_iovs(r_xprt, &rqst->rq_rcv_buf, 0, wtype, seg);
 	if (nsegs < 0)
 		return nsegs;
 
-	if (encode_item_present(xdr) < 0)
+	if (xdr_stream_encode_item_present(xdr) < 0)
 		return -EMSGSIZE;
 	segcount = xdr_reserve_space(xdr, sizeof(*segcount));
 	if (unlikely(!segcount))


  parent reply	other threads:[~2020-02-28  0:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28  0:30 [PATCH v1 00/16] NFS/RDMA server patches maybe for v5.7 Chuck Lever
2020-02-28  0:30 ` [PATCH v1 01/16] nfsd: Fix NFSv4 READ on RDMA when using readv Chuck Lever
2020-02-28  0:30 ` [PATCH v1 02/16] NFSD: Clean up nfsd4_encode_readv Chuck Lever
2020-02-28  0:30 ` [PATCH v1 03/16] svcrdma: Fix double svc_rdma_send_ctxt_put() in an error path Chuck Lever
2020-02-28  0:30 ` [PATCH v1 04/16] SUNRPC: Add xdr_pad_size() helper Chuck Lever
2020-02-28  0:30 ` [PATCH v1 05/16] svcrdma: Create a generic tracing class for displaying xdr_buf layout Chuck Lever
2020-02-28 22:02   ` Fwd: " Chuck Lever
2020-02-28  0:31 ` [PATCH v1 06/16] svcrdma: Remove svcrdma_cm_event() trace point Chuck Lever
2020-02-28  0:31 ` [PATCH v1 07/16] svcrdma: Use struct xdr_stream to decode ingress transport headers Chuck Lever
2020-02-28  0:31 ` [PATCH v1 08/16] svcrdma: De-duplicate code that locates Write and Reply chunks Chuck Lever
2020-02-28  0:31 ` [PATCH v1 09/16] svcrdma: Update synopsis of svc_rdma_send_reply_chunk() Chuck Lever
2020-02-28  0:31 ` [PATCH v1 10/16] svcrdma: Update synopsis of svc_rdma_map_reply_msg() Chuck Lever
2020-02-28  0:31 ` [PATCH v1 11/16] svcrdma: Update synopsis of svc_rdma_send_reply_msg() Chuck Lever
2020-02-28  0:31 ` [PATCH v1 12/16] svcrdma: Rename svcrdma_encode trace points in send routines Chuck Lever
2020-02-28  0:31 ` Chuck Lever [this message]
2020-02-28  0:32 ` [PATCH v1 14/16] svcrdma: Refactor chunk list encoders Chuck Lever
2020-02-28  0:32 ` [PATCH v1 15/16] svcrdma: Fix double sync of transport header buffer Chuck Lever
2020-02-28  0:32 ` [PATCH v1 16/16] svcrdma: Avoid DMA mapping small RPC Replies Chuck Lever

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=158284991530.38468.7171819678223366860.stgit@seurat29.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.