Refactor: Allow the client and server to share this helper function. msg_prot.h now needs linux/kernel.h for cpu_to_be32. #include <msg_prot.h> is removed anywhere it is not required and causes a compilation failure due to the new header dependency. Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx> --- include/linux/sunrpc/msg_prot.h | 13 +++++++++++++ include/linux/sunrpc/svcauth.h | 1 - net/sunrpc/xprtsock.c | 18 +++--------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h index bea40d9f03a1..cceb5a3e39f5 100644 --- a/include/linux/sunrpc/msg_prot.h +++ b/include/linux/sunrpc/msg_prot.h @@ -104,6 +104,19 @@ enum rpc_auth_stat { #define RPC_FRAGMENT_SIZE_MASK (~RPC_LAST_STREAM_FRAGMENT) #define RPC_MAX_FRAGMENT_SIZE ((1U << 31) - 1) +/** + * rpc_stream_record_marker - Construct a 4-octet stream record marker + * @size: number of octets in the RPC message to send + * + * Returns the stream record marker field for a record of length < 2^31-1 + */ +static inline rpc_fraghdr rpc_stream_record_marker(u32 size) +{ + if (!size) + return 0; + return cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | size); +} + /* * RPC call and reply header size as number of 32bit words (verifier * size computed separately, see below) diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h index b0003866a249..aeac5a955cce 100644 --- a/include/linux/sunrpc/svcauth.h +++ b/include/linux/sunrpc/svcauth.h @@ -11,7 +11,6 @@ #define _LINUX_SUNRPC_SVCAUTH_H_ #include <linux/string.h> -#include <linux/sunrpc/msg_prot.h> #include <linux/sunrpc/cache.h> #include <linux/sunrpc/gss_api.h> #include <linux/hash.h> diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index d86c664ea6af..f940179db510 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -929,17 +929,6 @@ static int xs_nospace(struct rpc_rqst *req) return transport->xmit.offset != 0 && req->rq_bytes_sent == 0; } -/* - * Return the stream record marker field for a record of length < 2^31-1 - */ -static rpc_fraghdr -xs_stream_record_marker(struct xdr_buf *xdr) -{ - if (!xdr->len) - return 0; - return cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | (u32)xdr->len); -} - /** * xs_local_send_request - write an RPC request to an AF_LOCAL socket * @req: pointer to RPC request @@ -957,7 +946,7 @@ static int xs_local_send_request(struct rpc_rqst *req) struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); struct xdr_buf *xdr = &req->rq_snd_buf; - rpc_fraghdr rm = xs_stream_record_marker(xdr); + rpc_fraghdr rm = rpc_stream_record_marker(xdr->len); unsigned int msglen = rm ? req->rq_slen + sizeof(rm) : req->rq_slen; int status; int sent = 0; @@ -1104,7 +1093,7 @@ static int xs_tcp_send_request(struct rpc_rqst *req) struct rpc_xprt *xprt = req->rq_xprt; struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); struct xdr_buf *xdr = &req->rq_snd_buf; - rpc_fraghdr rm = xs_stream_record_marker(xdr); + rpc_fraghdr rm = rpc_stream_record_marker(xdr->len); unsigned int msglen = rm ? req->rq_slen + sizeof(rm) : req->rq_slen; bool vm_wait = false; int status; @@ -2652,8 +2641,7 @@ static int bc_sendto(struct rpc_rqst *req) struct msghdr msg = { .msg_flags = MSG_MORE }; - rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | - (u32)xbufp->len); + rpc_fraghdr marker = rpc_stream_record_marker(xbufp->len); struct kvec iov = { .iov_base = &marker, .iov_len = sizeof(marker),