aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2006-12-05 16:35:23 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-06 10:46:50 -0500
commite136d0926ef6a048f6e65b35263c0a9faae3abbe (patch)
tree703d73647ce48b5c897af1c8a635db209bd03161
parent51971139b2342fa1005e87bbfcb52305da3fe891 (diff)
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: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--include/linux/sunrpc/xprt.h5
-rw-r--r--net/sunrpc/xprtsock.c49
2 files changed, 29 insertions, 25 deletions
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 0a0ad1ce70e4..3ff8230c7dd9 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -203,11 +203,6 @@ struct rpc_xprt {
203 char * address_strings[RPC_DISPLAY_MAX]; 203 char * address_strings[RPC_DISPLAY_MAX];
204}; 204};
205 205
206#define XPRT_LAST_FRAG (1 << 0)
207#define XPRT_COPY_RECM (1 << 1)
208#define XPRT_COPY_XID (1 << 2)
209#define XPRT_COPY_DATA (1 << 3)
210
211#ifdef __KERNEL__ 206#ifdef __KERNEL__
212 207
213/* 208/*
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 417bd91ea53e..c737acf61c75 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -147,6 +147,14 @@ struct sock_xprt {
147 tcp_flags; 147 tcp_flags;
148}; 148};
149 149
150/*
151 * TCP receive state flags
152 */
153#define TCP_RCV_LAST_FRAG (1UL << 0)
154#define TCP_RCV_COPY_FRAGHDR (1UL << 1)
155#define TCP_RCV_COPY_XID (1UL << 2)
156#define TCP_RCV_COPY_DATA (1UL << 3)
157
150static void xs_format_peer_addresses(struct rpc_xprt *xprt) 158static void xs_format_peer_addresses(struct rpc_xprt *xprt)
151{ 159{
152 struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr; 160 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 661
654 transport->tcp_reclen = ntohl(transport->tcp_fraghdr); 662 transport->tcp_reclen = ntohl(transport->tcp_fraghdr);
655 if (transport->tcp_reclen & RPC_LAST_STREAM_FRAGMENT) 663 if (transport->tcp_reclen & RPC_LAST_STREAM_FRAGMENT)
656 transport->tcp_flags |= XPRT_LAST_FRAG; 664 transport->tcp_flags |= TCP_RCV_LAST_FRAG;
657 else 665 else
658 transport->tcp_flags &= ~XPRT_LAST_FRAG; 666 transport->tcp_flags &= ~TCP_RCV_LAST_FRAG;
659 transport->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK; 667 transport->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK;
660 668
661 transport->tcp_flags &= ~XPRT_COPY_RECM; 669 transport->tcp_flags &= ~TCP_RCV_COPY_FRAGHDR;
662 transport->tcp_offset = 0; 670 transport->tcp_offset = 0;
663 671
664 /* Sanity check of the record length */ 672 /* 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
674static void xs_tcp_check_fraghdr(struct sock_xprt *transport) 682static void xs_tcp_check_fraghdr(struct sock_xprt *transport)
675{ 683{
676 if (transport->tcp_offset == transport->tcp_reclen) { 684 if (transport->tcp_offset == transport->tcp_reclen) {
677 transport->tcp_flags |= XPRT_COPY_RECM; 685 transport->tcp_flags |= TCP_RCV_COPY_FRAGHDR;
678 transport->tcp_offset = 0; 686 transport->tcp_offset = 0;
679 if (transport->tcp_flags & XPRT_LAST_FRAG) { 687 if (transport->tcp_flags & TCP_RCV_LAST_FRAG) {
680 transport->tcp_flags &= ~XPRT_COPY_DATA; 688 transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
681 transport->tcp_flags |= XPRT_COPY_XID; 689 transport->tcp_flags |= TCP_RCV_COPY_XID;
682 transport->tcp_copied = 0; 690 transport->tcp_copied = 0;
683 } 691 }
684 } 692 }
@@ -696,8 +704,8 @@ static inline void xs_tcp_read_xid(struct sock_xprt *transport, skb_reader_t *de
696 transport->tcp_offset += used; 704 transport->tcp_offset += used;
697 if (used != len) 705 if (used != len)
698 return; 706 return;
699 transport->tcp_flags &= ~XPRT_COPY_XID; 707 transport->tcp_flags &= ~TCP_RCV_COPY_XID;
700 transport->tcp_flags |= XPRT_COPY_DATA; 708 transport->tcp_flags |= TCP_RCV_COPY_DATA;
701 transport->tcp_copied = 4; 709 transport->tcp_copied = 4;
702 dprintk("RPC: reading reply for XID %08x\n", 710 dprintk("RPC: reading reply for XID %08x\n",
703 ntohl(transport->tcp_xid)); 711 ntohl(transport->tcp_xid));
@@ -716,7 +724,7 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc
716 spin_lock(&xprt->transport_lock); 724 spin_lock(&xprt->transport_lock);
717 req = xprt_lookup_rqst(xprt, transport->tcp_xid); 725 req = xprt_lookup_rqst(xprt, transport->tcp_xid);
718 if (!req) { 726 if (!req) {
719 transport->tcp_flags &= ~XPRT_COPY_DATA; 727 transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
720 dprintk("RPC: XID %08x request not found!\n", 728 dprintk("RPC: XID %08x request not found!\n",
721 ntohl(transport->tcp_xid)); 729 ntohl(transport->tcp_xid));
722 spin_unlock(&xprt->transport_lock); 730 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 /* Error when copying to the receive buffer, 755 /* Error when copying to the receive buffer,
748 * usually because we weren't able to allocate 756 * usually because we weren't able to allocate
749 * additional buffer pages. All we can do now 757 * additional buffer pages. All we can do now
750 * is turn off XPRT_COPY_DATA, so the request 758 * is turn off TCP_RCV_COPY_DATA, so the request
751 * will not receive any additional updates, 759 * will not receive any additional updates,
752 * and time out. 760 * and time out.
753 * Any remaining data from this record will 761 * Any remaining data from this record will
754 * be discarded. 762 * be discarded.
755 */ 763 */
756 transport->tcp_flags &= ~XPRT_COPY_DATA; 764 transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
757 dprintk("RPC: XID %08x truncated request\n", 765 dprintk("RPC: XID %08x truncated request\n",
758 ntohl(transport->tcp_xid)); 766 ntohl(transport->tcp_xid));
759 dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n", 767 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 transport->tcp_reclen); 777 transport->tcp_reclen);
770 778
771 if (transport->tcp_copied == req->rq_private_buf.buflen) 779 if (transport->tcp_copied == req->rq_private_buf.buflen)
772 transport->tcp_flags &= ~XPRT_COPY_DATA; 780 transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
773 else if (transport->tcp_offset == transport->tcp_reclen) { 781 else if (transport->tcp_offset == transport->tcp_reclen) {
774 if (transport->tcp_flags & XPRT_LAST_FRAG) 782 if (transport->tcp_flags & TCP_RCV_LAST_FRAG)
775 transport->tcp_flags &= ~XPRT_COPY_DATA; 783 transport->tcp_flags &= ~TCP_RCV_COPY_DATA;
776 } 784 }
777 785
778out: 786out:
779 if (!(transport->tcp_flags & XPRT_COPY_DATA)) 787 if (!(transport->tcp_flags & TCP_RCV_COPY_DATA))
780 xprt_complete_rqst(req->rq_task, transport->tcp_copied); 788 xprt_complete_rqst(req->rq_task, transport->tcp_copied);
781 spin_unlock(&xprt->transport_lock); 789 spin_unlock(&xprt->transport_lock);
782 xs_tcp_check_fraghdr(transport); 790 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 do { 818 do {
811 /* Read in a new fragment marker if necessary */ 819 /* Read in a new fragment marker if necessary */
812 /* Can we ever really expect to get completely empty fragments? */ 820 /* Can we ever really expect to get completely empty fragments? */
813 if (transport->tcp_flags & XPRT_COPY_RECM) { 821 if (transport->tcp_flags & TCP_RCV_COPY_FRAGHDR) {
814 xs_tcp_read_fraghdr(xprt, &desc); 822 xs_tcp_read_fraghdr(xprt, &desc);
815 continue; 823 continue;
816 } 824 }
817 /* Read in the xid if necessary */ 825 /* Read in the xid if necessary */
818 if (transport->tcp_flags & XPRT_COPY_XID) { 826 if (transport->tcp_flags & TCP_RCV_COPY_XID) {
819 xs_tcp_read_xid(transport, &desc); 827 xs_tcp_read_xid(transport, &desc);
820 continue; 828 continue;
821 } 829 }
822 /* Read in the request data */ 830 /* Read in the request data */
823 if (transport->tcp_flags & XPRT_COPY_DATA) { 831 if (transport->tcp_flags & TCP_RCV_COPY_DATA) {
824 xs_tcp_read_request(xprt, &desc); 832 xs_tcp_read_request(xprt, &desc);
825 continue; 833 continue;
826 } 834 }
@@ -886,7 +894,8 @@ static void xs_tcp_state_change(struct sock *sk)
886 transport->tcp_offset = 0; 894 transport->tcp_offset = 0;
887 transport->tcp_reclen = 0; 895 transport->tcp_reclen = 0;
888 transport->tcp_copied = 0; 896 transport->tcp_copied = 0;
889 transport->tcp_flags = XPRT_COPY_RECM | XPRT_COPY_XID; 897 transport->tcp_flags =
898 TCP_RCV_COPY_FRAGHDR | TCP_RCV_COPY_XID;
890 899
891 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; 900 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
892 xprt_wake_pending_tasks(xprt, 0); 901 xprt_wake_pending_tasks(xprt, 0);