Commit d1109aa5 authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Rename TCP receive-specific state variables

Since we will want to introduce similar TCP state variables for the
transmission of requests, let's rename the existing ones to label
that they are for the receive side.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 3a03818f
...@@ -30,15 +30,17 @@ struct sock_xprt { ...@@ -30,15 +30,17 @@ struct sock_xprt {
/* /*
* State of TCP reply receive * State of TCP reply receive
*/ */
__be32 tcp_fraghdr, struct {
tcp_xid, __be32 fraghdr,
tcp_calldir; xid,
calldir;
u32 tcp_offset, u32 offset,
tcp_reclen; len;
unsigned long tcp_copied, unsigned long copied,
tcp_flags; flags;
} recv;
/* /*
* Connection of transports * Connection of transports
......
...@@ -525,11 +525,11 @@ TRACE_EVENT(xs_tcp_data_recv, ...@@ -525,11 +525,11 @@ TRACE_EVENT(xs_tcp_data_recv,
TP_fast_assign( TP_fast_assign(
__assign_str(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR]); __assign_str(addr, xs->xprt.address_strings[RPC_DISPLAY_ADDR]);
__assign_str(port, xs->xprt.address_strings[RPC_DISPLAY_PORT]); __assign_str(port, xs->xprt.address_strings[RPC_DISPLAY_PORT]);
__entry->xid = be32_to_cpu(xs->tcp_xid); __entry->xid = be32_to_cpu(xs->recv.xid);
__entry->flags = xs->tcp_flags; __entry->flags = xs->recv.flags;
__entry->copied = xs->tcp_copied; __entry->copied = xs->recv.copied;
__entry->reclen = xs->tcp_reclen; __entry->reclen = xs->recv.len;
__entry->offset = xs->tcp_offset; __entry->offset = xs->recv.offset;
), ),
TP_printk("peer=[%s]:%s xid=0x%08x flags=%s copied=%lu reclen=%u offset=%lu", TP_printk("peer=[%s]:%s xid=0x%08x flags=%s copied=%lu reclen=%u offset=%lu",
......
...@@ -1169,42 +1169,42 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_rea ...@@ -1169,42 +1169,42 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_rea
size_t len, used; size_t len, used;
char *p; char *p;
p = ((char *) &transport->tcp_fraghdr) + transport->tcp_offset; p = ((char *) &transport->recv.fraghdr) + transport->recv.offset;
len = sizeof(transport->tcp_fraghdr) - transport->tcp_offset; len = sizeof(transport->recv.fraghdr) - transport->recv.offset;
used = xdr_skb_read_bits(desc, p, len); used = xdr_skb_read_bits(desc, p, len);
transport->tcp_offset += used; transport->recv.offset += used;
if (used != len) if (used != len)
return; return;
transport->tcp_reclen = ntohl(transport->tcp_fraghdr); transport->recv.len = ntohl(transport->recv.fraghdr);
if (transport->tcp_reclen & RPC_LAST_STREAM_FRAGMENT) if (transport->recv.len & RPC_LAST_STREAM_FRAGMENT)
transport->tcp_flags |= TCP_RCV_LAST_FRAG; transport->recv.flags |= TCP_RCV_LAST_FRAG;
else else
transport->tcp_flags &= ~TCP_RCV_LAST_FRAG; transport->recv.flags &= ~TCP_RCV_LAST_FRAG;
transport->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK; transport->recv.len &= RPC_FRAGMENT_SIZE_MASK;
transport->tcp_flags &= ~TCP_RCV_COPY_FRAGHDR; transport->recv.flags &= ~TCP_RCV_COPY_FRAGHDR;
transport->tcp_offset = 0; transport->recv.offset = 0;
/* Sanity check of the record length */ /* Sanity check of the record length */
if (unlikely(transport->tcp_reclen < 8)) { if (unlikely(transport->recv.len < 8)) {
dprintk("RPC: invalid TCP record fragment length\n"); dprintk("RPC: invalid TCP record fragment length\n");
xs_tcp_force_close(xprt); xs_tcp_force_close(xprt);
return; return;
} }
dprintk("RPC: reading TCP record fragment of length %d\n", dprintk("RPC: reading TCP record fragment of length %d\n",
transport->tcp_reclen); transport->recv.len);
} }
static void xs_tcp_check_fraghdr(struct sock_xprt *transport) static void xs_tcp_check_fraghdr(struct sock_xprt *transport)
{ {
if (transport->tcp_offset == transport->tcp_reclen) { if (transport->recv.offset == transport->recv.len) {
transport->tcp_flags |= TCP_RCV_COPY_FRAGHDR; transport->recv.flags |= TCP_RCV_COPY_FRAGHDR;
transport->tcp_offset = 0; transport->recv.offset = 0;
if (transport->tcp_flags & TCP_RCV_LAST_FRAG) { if (transport->recv.flags & TCP_RCV_LAST_FRAG) {
transport->tcp_flags &= ~TCP_RCV_COPY_DATA; transport->recv.flags &= ~TCP_RCV_COPY_DATA;
transport->tcp_flags |= TCP_RCV_COPY_XID; transport->recv.flags |= TCP_RCV_COPY_XID;
transport->tcp_copied = 0; transport->recv.copied = 0;
} }
} }
} }
...@@ -1214,20 +1214,20 @@ static inline void xs_tcp_read_xid(struct sock_xprt *transport, struct xdr_skb_r ...@@ -1214,20 +1214,20 @@ static inline void xs_tcp_read_xid(struct sock_xprt *transport, struct xdr_skb_r
size_t len, used; size_t len, used;
char *p; char *p;
len = sizeof(transport->tcp_xid) - transport->tcp_offset; len = sizeof(transport->recv.xid) - transport->recv.offset;
dprintk("RPC: reading XID (%zu bytes)\n", len); dprintk("RPC: reading XID (%zu bytes)\n", len);
p = ((char *) &transport->tcp_xid) + transport->tcp_offset; p = ((char *) &transport->recv.xid) + transport->recv.offset;
used = xdr_skb_read_bits(desc, p, len); used = xdr_skb_read_bits(desc, p, len);
transport->tcp_offset += used; transport->recv.offset += used;
if (used != len) if (used != len)
return; return;
transport->tcp_flags &= ~TCP_RCV_COPY_XID; transport->recv.flags &= ~TCP_RCV_COPY_XID;
transport->tcp_flags |= TCP_RCV_READ_CALLDIR; transport->recv.flags |= TCP_RCV_READ_CALLDIR;
transport->tcp_copied = 4; transport->recv.copied = 4;
dprintk("RPC: reading %s XID %08x\n", dprintk("RPC: reading %s XID %08x\n",
(transport->tcp_flags & TCP_RPC_REPLY) ? "reply for" (transport->recv.flags & TCP_RPC_REPLY) ? "reply for"
: "request with", : "request with",
ntohl(transport->tcp_xid)); ntohl(transport->recv.xid));
xs_tcp_check_fraghdr(transport); xs_tcp_check_fraghdr(transport);
} }
...@@ -1239,34 +1239,34 @@ static inline void xs_tcp_read_calldir(struct sock_xprt *transport, ...@@ -1239,34 +1239,34 @@ static inline void xs_tcp_read_calldir(struct sock_xprt *transport,
char *p; char *p;
/* /*
* We want transport->tcp_offset to be 8 at the end of this routine * We want transport->recv.offset to be 8 at the end of this routine
* (4 bytes for the xid and 4 bytes for the call/reply flag). * (4 bytes for the xid and 4 bytes for the call/reply flag).
* When this function is called for the first time, * When this function is called for the first time,
* transport->tcp_offset is 4 (after having already read the xid). * transport->recv.offset is 4 (after having already read the xid).
*/ */
offset = transport->tcp_offset - sizeof(transport->tcp_xid); offset = transport->recv.offset - sizeof(transport->recv.xid);
len = sizeof(transport->tcp_calldir) - offset; len = sizeof(transport->recv.calldir) - offset;
dprintk("RPC: reading CALL/REPLY flag (%zu bytes)\n", len); dprintk("RPC: reading CALL/REPLY flag (%zu bytes)\n", len);
p = ((char *) &transport->tcp_calldir) + offset; p = ((char *) &transport->recv.calldir) + offset;
used = xdr_skb_read_bits(desc, p, len); used = xdr_skb_read_bits(desc, p, len);
transport->tcp_offset += used; transport->recv.offset += used;
if (used != len) if (used != len)
return; return;
transport->tcp_flags &= ~TCP_RCV_READ_CALLDIR; transport->recv.flags &= ~TCP_RCV_READ_CALLDIR;
/* /*
* We don't yet have the XDR buffer, so we will write the calldir * We don't yet have the XDR buffer, so we will write the calldir
* out after we get the buffer from the 'struct rpc_rqst' * out after we get the buffer from the 'struct rpc_rqst'
*/ */
switch (ntohl(transport->tcp_calldir)) { switch (ntohl(transport->recv.calldir)) {
case RPC_REPLY: case RPC_REPLY:
transport->tcp_flags |= TCP_RCV_COPY_CALLDIR; transport->recv.flags |= TCP_RCV_COPY_CALLDIR;
transport->tcp_flags |= TCP_RCV_COPY_DATA; transport->recv.flags |= TCP_RCV_COPY_DATA;
transport->tcp_flags |= TCP_RPC_REPLY; transport->recv.flags |= TCP_RPC_REPLY;
break; break;
case RPC_CALL: case RPC_CALL:
transport->tcp_flags |= TCP_RCV_COPY_CALLDIR; transport->recv.flags |= TCP_RCV_COPY_CALLDIR;
transport->tcp_flags |= TCP_RCV_COPY_DATA; transport->recv.flags |= TCP_RCV_COPY_DATA;
transport->tcp_flags &= ~TCP_RPC_REPLY; transport->recv.flags &= ~TCP_RPC_REPLY;
break; break;
default: default:
dprintk("RPC: invalid request message type\n"); dprintk("RPC: invalid request message type\n");
...@@ -1287,21 +1287,21 @@ static inline void xs_tcp_read_common(struct rpc_xprt *xprt, ...@@ -1287,21 +1287,21 @@ static inline void xs_tcp_read_common(struct rpc_xprt *xprt,
rcvbuf = &req->rq_private_buf; rcvbuf = &req->rq_private_buf;
if (transport->tcp_flags & TCP_RCV_COPY_CALLDIR) { if (transport->recv.flags & TCP_RCV_COPY_CALLDIR) {
/* /*
* Save the RPC direction in the XDR buffer * Save the RPC direction in the XDR buffer
*/ */
memcpy(rcvbuf->head[0].iov_base + transport->tcp_copied, memcpy(rcvbuf->head[0].iov_base + transport->recv.copied,
&transport->tcp_calldir, &transport->recv.calldir,
sizeof(transport->tcp_calldir)); sizeof(transport->recv.calldir));
transport->tcp_copied += sizeof(transport->tcp_calldir); transport->recv.copied += sizeof(transport->recv.calldir);
transport->tcp_flags &= ~TCP_RCV_COPY_CALLDIR; transport->recv.flags &= ~TCP_RCV_COPY_CALLDIR;
} }
len = desc->count; len = desc->count;
if (len > transport->tcp_reclen - transport->tcp_offset) if (len > transport->recv.len - transport->recv.offset)
desc->count = transport->tcp_reclen - transport->tcp_offset; desc->count = transport->recv.len - transport->recv.offset;
r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied, r = xdr_partial_copy_from_skb(rcvbuf, transport->recv.copied,
desc, xdr_skb_read_bits); desc, xdr_skb_read_bits);
if (desc->count) { if (desc->count) {
...@@ -1314,31 +1314,31 @@ static inline void xs_tcp_read_common(struct rpc_xprt *xprt, ...@@ -1314,31 +1314,31 @@ static inline void xs_tcp_read_common(struct rpc_xprt *xprt,
* Any remaining data from this record will * Any remaining data from this record will
* be discarded. * be discarded.
*/ */
transport->tcp_flags &= ~TCP_RCV_COPY_DATA; transport->recv.flags &= ~TCP_RCV_COPY_DATA;
dprintk("RPC: XID %08x truncated request\n", dprintk("RPC: XID %08x truncated request\n",
ntohl(transport->tcp_xid)); ntohl(transport->recv.xid));
dprintk("RPC: xprt = %p, tcp_copied = %lu, " dprintk("RPC: xprt = %p, recv.copied = %lu, "
"tcp_offset = %u, tcp_reclen = %u\n", "recv.offset = %u, recv.len = %u\n",
xprt, transport->tcp_copied, xprt, transport->recv.copied,
transport->tcp_offset, transport->tcp_reclen); transport->recv.offset, transport->recv.len);
return; return;
} }
transport->tcp_copied += r; transport->recv.copied += r;
transport->tcp_offset += r; transport->recv.offset += r;
desc->count = len - r; desc->count = len - r;
dprintk("RPC: XID %08x read %zd bytes\n", dprintk("RPC: XID %08x read %zd bytes\n",
ntohl(transport->tcp_xid), r); ntohl(transport->recv.xid), r);
dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, " dprintk("RPC: xprt = %p, recv.copied = %lu, recv.offset = %u, "
"tcp_reclen = %u\n", xprt, transport->tcp_copied, "recv.len = %u\n", xprt, transport->recv.copied,
transport->tcp_offset, transport->tcp_reclen); transport->recv.offset, transport->recv.len);
if (transport->tcp_copied == req->rq_private_buf.buflen) if (transport->recv.copied == req->rq_private_buf.buflen)
transport->tcp_flags &= ~TCP_RCV_COPY_DATA; transport->recv.flags &= ~TCP_RCV_COPY_DATA;
else if (transport->tcp_offset == transport->tcp_reclen) { else if (transport->recv.offset == transport->recv.len) {
if (transport->tcp_flags & TCP_RCV_LAST_FRAG) if (transport->recv.flags & TCP_RCV_LAST_FRAG)
transport->tcp_flags &= ~TCP_RCV_COPY_DATA; transport->recv.flags &= ~TCP_RCV_COPY_DATA;
} }
} }
...@@ -1353,14 +1353,14 @@ static inline int xs_tcp_read_reply(struct rpc_xprt *xprt, ...@@ -1353,14 +1353,14 @@ static inline int xs_tcp_read_reply(struct rpc_xprt *xprt,
container_of(xprt, struct sock_xprt, xprt); container_of(xprt, struct sock_xprt, xprt);
struct rpc_rqst *req; struct rpc_rqst *req;
dprintk("RPC: read reply XID %08x\n", ntohl(transport->tcp_xid)); dprintk("RPC: read reply XID %08x\n", ntohl(transport->recv.xid));
/* Find and lock the request corresponding to this xid */ /* Find and lock the request corresponding to this xid */
spin_lock(&xprt->recv_lock); spin_lock(&xprt->recv_lock);
req = xprt_lookup_rqst(xprt, transport->tcp_xid); req = xprt_lookup_rqst(xprt, transport->recv.xid);
if (!req) { if (!req) {
dprintk("RPC: XID %08x request not found!\n", dprintk("RPC: XID %08x request not found!\n",
ntohl(transport->tcp_xid)); ntohl(transport->recv.xid));
spin_unlock(&xprt->recv_lock); spin_unlock(&xprt->recv_lock);
return -1; return -1;
} }
...@@ -1370,8 +1370,8 @@ static inline int xs_tcp_read_reply(struct rpc_xprt *xprt, ...@@ -1370,8 +1370,8 @@ static inline int xs_tcp_read_reply(struct rpc_xprt *xprt,
xs_tcp_read_common(xprt, desc, req); xs_tcp_read_common(xprt, desc, req);
spin_lock(&xprt->recv_lock); spin_lock(&xprt->recv_lock);
if (!(transport->tcp_flags & TCP_RCV_COPY_DATA)) if (!(transport->recv.flags & TCP_RCV_COPY_DATA))
xprt_complete_rqst(req->rq_task, transport->tcp_copied); xprt_complete_rqst(req->rq_task, transport->recv.copied);
xprt_unpin_rqst(req); xprt_unpin_rqst(req);
spin_unlock(&xprt->recv_lock); spin_unlock(&xprt->recv_lock);
return 0; return 0;
...@@ -1393,7 +1393,7 @@ static int xs_tcp_read_callback(struct rpc_xprt *xprt, ...@@ -1393,7 +1393,7 @@ static int xs_tcp_read_callback(struct rpc_xprt *xprt,
struct rpc_rqst *req; struct rpc_rqst *req;
/* Look up the request corresponding to the given XID */ /* Look up the request corresponding to the given XID */
req = xprt_lookup_bc_request(xprt, transport->tcp_xid); req = xprt_lookup_bc_request(xprt, transport->recv.xid);
if (req == NULL) { if (req == NULL) {
printk(KERN_WARNING "Callback slot table overflowed\n"); printk(KERN_WARNING "Callback slot table overflowed\n");
xprt_force_disconnect(xprt); xprt_force_disconnect(xprt);
...@@ -1403,8 +1403,8 @@ static int xs_tcp_read_callback(struct rpc_xprt *xprt, ...@@ -1403,8 +1403,8 @@ static int xs_tcp_read_callback(struct rpc_xprt *xprt,
dprintk("RPC: read callback XID %08x\n", ntohl(req->rq_xid)); dprintk("RPC: read callback XID %08x\n", ntohl(req->rq_xid));
xs_tcp_read_common(xprt, desc, req); xs_tcp_read_common(xprt, desc, req);
if (!(transport->tcp_flags & TCP_RCV_COPY_DATA)) if (!(transport->recv.flags & TCP_RCV_COPY_DATA))
xprt_complete_bc_request(req, transport->tcp_copied); xprt_complete_bc_request(req, transport->recv.copied);
return 0; return 0;
} }
...@@ -1415,7 +1415,7 @@ static inline int _xs_tcp_read_data(struct rpc_xprt *xprt, ...@@ -1415,7 +1415,7 @@ static inline int _xs_tcp_read_data(struct rpc_xprt *xprt,
struct sock_xprt *transport = struct sock_xprt *transport =
container_of(xprt, struct sock_xprt, xprt); container_of(xprt, struct sock_xprt, xprt);
return (transport->tcp_flags & TCP_RPC_REPLY) ? return (transport->recv.flags & TCP_RPC_REPLY) ?
xs_tcp_read_reply(xprt, desc) : xs_tcp_read_reply(xprt, desc) :
xs_tcp_read_callback(xprt, desc); xs_tcp_read_callback(xprt, desc);
} }
...@@ -1458,9 +1458,9 @@ static void xs_tcp_read_data(struct rpc_xprt *xprt, ...@@ -1458,9 +1458,9 @@ static void xs_tcp_read_data(struct rpc_xprt *xprt,
else { else {
/* /*
* The transport_lock protects the request handling. * The transport_lock protects the request handling.
* There's no need to hold it to update the tcp_flags. * There's no need to hold it to update the recv.flags.
*/ */
transport->tcp_flags &= ~TCP_RCV_COPY_DATA; transport->recv.flags &= ~TCP_RCV_COPY_DATA;
} }
} }
...@@ -1468,12 +1468,12 @@ static inline void xs_tcp_read_discard(struct sock_xprt *transport, struct xdr_s ...@@ -1468,12 +1468,12 @@ static inline void xs_tcp_read_discard(struct sock_xprt *transport, struct xdr_s
{ {
size_t len; size_t len;
len = transport->tcp_reclen - transport->tcp_offset; len = transport->recv.len - transport->recv.offset;
if (len > desc->count) if (len > desc->count)
len = desc->count; len = desc->count;
desc->count -= len; desc->count -= len;
desc->offset += len; desc->offset += len;
transport->tcp_offset += len; transport->recv.offset += len;
dprintk("RPC: discarded %zu bytes\n", len); dprintk("RPC: discarded %zu bytes\n", len);
xs_tcp_check_fraghdr(transport); xs_tcp_check_fraghdr(transport);
} }
...@@ -1494,22 +1494,22 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns ...@@ -1494,22 +1494,22 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns
trace_xs_tcp_data_recv(transport); trace_xs_tcp_data_recv(transport);
/* Read in a new fragment marker if necessary */ /* Read in a new fragment marker if necessary */
/* Can we ever really expect to get completely empty fragments? */ /* Can we ever really expect to get completely empty fragments? */
if (transport->tcp_flags & TCP_RCV_COPY_FRAGHDR) { if (transport->recv.flags & TCP_RCV_COPY_FRAGHDR) {
xs_tcp_read_fraghdr(xprt, &desc); xs_tcp_read_fraghdr(xprt, &desc);
continue; continue;
} }
/* Read in the xid if necessary */ /* Read in the xid if necessary */
if (transport->tcp_flags & TCP_RCV_COPY_XID) { if (transport->recv.flags & TCP_RCV_COPY_XID) {
xs_tcp_read_xid(transport, &desc); xs_tcp_read_xid(transport, &desc);
continue; continue;
} }
/* Read in the call/reply flag */ /* Read in the call/reply flag */
if (transport->tcp_flags & TCP_RCV_READ_CALLDIR) { if (transport->recv.flags & TCP_RCV_READ_CALLDIR) {
xs_tcp_read_calldir(transport, &desc); xs_tcp_read_calldir(transport, &desc);
continue; continue;
} }
/* Read in the request data */ /* Read in the request data */
if (transport->tcp_flags & TCP_RCV_COPY_DATA) { if (transport->recv.flags & TCP_RCV_COPY_DATA) {
xs_tcp_read_data(xprt, &desc); xs_tcp_read_data(xprt, &desc);
continue; continue;
} }
...@@ -1602,10 +1602,10 @@ static void xs_tcp_state_change(struct sock *sk) ...@@ -1602,10 +1602,10 @@ static void xs_tcp_state_change(struct sock *sk)
if (!xprt_test_and_set_connected(xprt)) { if (!xprt_test_and_set_connected(xprt)) {
/* Reset TCP record info */ /* Reset TCP record info */
transport->tcp_offset = 0; transport->recv.offset = 0;
transport->tcp_reclen = 0; transport->recv.len = 0;
transport->tcp_copied = 0; transport->recv.copied = 0;
transport->tcp_flags = transport->recv.flags =
TCP_RCV_COPY_FRAGHDR | TCP_RCV_COPY_XID; TCP_RCV_COPY_FRAGHDR | TCP_RCV_COPY_XID;
xprt->connect_cookie++; xprt->connect_cookie++;
clear_bit(XPRT_SOCK_CONNECTING, &transport->sock_state); clear_bit(XPRT_SOCK_CONNECTING, &transport->sock_state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment