Commit e136d092 authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

SUNRPC: Move TCP state flags into xprtsock.c

Move "XPRT_LAST_FRAG" and friends from xprt.h into xprtsock.c, and rename
them to use the naming scheme in use in xprtsock.c.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 51971139
...@@ -203,11 +203,6 @@ struct rpc_xprt { ...@@ -203,11 +203,6 @@ struct rpc_xprt {
char * address_strings[RPC_DISPLAY_MAX]; char * address_strings[RPC_DISPLAY_MAX];
}; };
#define XPRT_LAST_FRAG (1 << 0)
#define XPRT_COPY_RECM (1 << 1)
#define XPRT_COPY_XID (1 << 2)
#define XPRT_COPY_DATA (1 << 3)
#ifdef __KERNEL__ #ifdef __KERNEL__
/* /*
......
...@@ -147,6 +147,14 @@ struct sock_xprt { ...@@ -147,6 +147,14 @@ struct sock_xprt {
tcp_flags; tcp_flags;
}; };
/*
* TCP receive state flags
*/
#define TCP_RCV_LAST_FRAG (1UL << 0)
#define TCP_RCV_COPY_FRAGHDR (1UL << 1)
#define TCP_RCV_COPY_XID (1UL << 2)
#define TCP_RCV_COPY_DATA (1UL << 3)
static void xs_format_peer_addresses(struct rpc_xprt *xprt) static void xs_format_peer_addresses(struct rpc_xprt *xprt)
{ {
struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr; struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr;
...@@ -653,12 +661,12 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc ...@@ -653,12 +661,12 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc
transport->tcp_reclen = ntohl(transport->tcp_fraghdr); transport->tcp_reclen = ntohl(transport->tcp_fraghdr);
if (transport->tcp_reclen & RPC_LAST_STREAM_FRAGMENT) if (transport->tcp_reclen & RPC_LAST_STREAM_FRAGMENT)
transport->tcp_flags |= XPRT_LAST_FRAG; transport->tcp_flags |= TCP_RCV_LAST_FRAG;
else else
transport->tcp_flags &= ~XPRT_LAST_FRAG; transport->tcp_flags &= ~TCP_RCV_LAST_FRAG;
transport->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK; transport->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK;
transport->tcp_flags &= ~XPRT_COPY_RECM; transport->tcp_flags &= ~TCP_RCV_COPY_FRAGHDR;
transport->tcp_offset = 0; transport->tcp_offset = 0;
/* Sanity check of the record length */ /* Sanity check of the record length */
...@@ -674,11 +682,11 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc ...@@ -674,11 +682,11 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc
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->tcp_offset == transport->tcp_reclen) {
transport->tcp_flags |= XPRT_COPY_RECM; transport->tcp_flags |= TCP_RCV_COPY_FRAGHDR;
transport->tcp_offset = 0; transport->tcp_offset = 0;
if (transport->tcp_flags & XPRT_LAST_FRAG) { if (transport->tcp_flags & TCP_RCV_LAST_FRAG) {
transport->tcp_flags &= ~XPRT_COPY_DATA; transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
transport->tcp_flags |= XPRT_COPY_XID; transport->tcp_flags |= TCP_RCV_COPY_XID;
transport->tcp_copied = 0; transport->tcp_copied = 0;
} }
} }
...@@ -696,8 +704,8 @@ static inline void xs_tcp_read_xid(struct sock_xprt *transport, skb_reader_t *de ...@@ -696,8 +704,8 @@ static inline void xs_tcp_read_xid(struct sock_xprt *transport, skb_reader_t *de
transport->tcp_offset += used; transport->tcp_offset += used;
if (used != len) if (used != len)
return; return;
transport->tcp_flags &= ~XPRT_COPY_XID; transport->tcp_flags &= ~TCP_RCV_COPY_XID;
transport->tcp_flags |= XPRT_COPY_DATA; transport->tcp_flags |= TCP_RCV_COPY_DATA;
transport->tcp_copied = 4; transport->tcp_copied = 4;
dprintk("RPC: reading reply for XID %08x\n", dprintk("RPC: reading reply for XID %08x\n",
ntohl(transport->tcp_xid)); ntohl(transport->tcp_xid));
...@@ -716,7 +724,7 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc ...@@ -716,7 +724,7 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc
spin_lock(&xprt->transport_lock); spin_lock(&xprt->transport_lock);
req = xprt_lookup_rqst(xprt, transport->tcp_xid); req = xprt_lookup_rqst(xprt, transport->tcp_xid);
if (!req) { if (!req) {
transport->tcp_flags &= ~XPRT_COPY_DATA; transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
dprintk("RPC: XID %08x request not found!\n", dprintk("RPC: XID %08x request not found!\n",
ntohl(transport->tcp_xid)); ntohl(transport->tcp_xid));
spin_unlock(&xprt->transport_lock); spin_unlock(&xprt->transport_lock);
...@@ -747,13 +755,13 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc ...@@ -747,13 +755,13 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc
/* Error when copying to the receive buffer, /* Error when copying to the receive buffer,
* usually because we weren't able to allocate * usually because we weren't able to allocate
* additional buffer pages. All we can do now * additional buffer pages. All we can do now
* is turn off XPRT_COPY_DATA, so the request * is turn off TCP_RCV_COPY_DATA, so the request
* will not receive any additional updates, * will not receive any additional updates,
* and time out. * and time out.
* Any remaining data from this record will * Any remaining data from this record will
* be discarded. * be discarded.
*/ */
transport->tcp_flags &= ~XPRT_COPY_DATA; transport->tcp_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->tcp_xid));
dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n", dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n",
...@@ -769,14 +777,14 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc ...@@ -769,14 +777,14 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc
transport->tcp_reclen); transport->tcp_reclen);
if (transport->tcp_copied == req->rq_private_buf.buflen) if (transport->tcp_copied == req->rq_private_buf.buflen)
transport->tcp_flags &= ~XPRT_COPY_DATA; transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
else if (transport->tcp_offset == transport->tcp_reclen) { else if (transport->tcp_offset == transport->tcp_reclen) {
if (transport->tcp_flags & XPRT_LAST_FRAG) if (transport->tcp_flags & TCP_RCV_LAST_FRAG)
transport->tcp_flags &= ~XPRT_COPY_DATA; transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
} }
out: out:
if (!(transport->tcp_flags & XPRT_COPY_DATA)) if (!(transport->tcp_flags & TCP_RCV_COPY_DATA))
xprt_complete_rqst(req->rq_task, transport->tcp_copied); xprt_complete_rqst(req->rq_task, transport->tcp_copied);
spin_unlock(&xprt->transport_lock); spin_unlock(&xprt->transport_lock);
xs_tcp_check_fraghdr(transport); xs_tcp_check_fraghdr(transport);
...@@ -810,17 +818,17 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns ...@@ -810,17 +818,17 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns
do { do {
/* 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 & XPRT_COPY_RECM) { if (transport->tcp_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 & XPRT_COPY_XID) { if (transport->tcp_flags & TCP_RCV_COPY_XID) {
xs_tcp_read_xid(transport, &desc); xs_tcp_read_xid(transport, &desc);
continue; continue;
} }
/* Read in the request data */ /* Read in the request data */
if (transport->tcp_flags & XPRT_COPY_DATA) { if (transport->tcp_flags & TCP_RCV_COPY_DATA) {
xs_tcp_read_request(xprt, &desc); xs_tcp_read_request(xprt, &desc);
continue; continue;
} }
...@@ -886,7 +894,8 @@ static void xs_tcp_state_change(struct sock *sk) ...@@ -886,7 +894,8 @@ static void xs_tcp_state_change(struct sock *sk)
transport->tcp_offset = 0; transport->tcp_offset = 0;
transport->tcp_reclen = 0; transport->tcp_reclen = 0;
transport->tcp_copied = 0; transport->tcp_copied = 0;
transport->tcp_flags = XPRT_COPY_RECM | XPRT_COPY_XID; transport->tcp_flags =
TCP_RCV_COPY_FRAGHDR | TCP_RCV_COPY_XID;
xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
xprt_wake_pending_tasks(xprt, 0); xprt_wake_pending_tasks(xprt, 0);
......
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