diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2006-12-05 16:35:41 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-12-06 10:46:52 -0500 |
commit | 9d29231690925915015c21c1fff73c7118099843 (patch) | |
tree | ac1018a80198a7e493296f5fc8e9fbd8dac7d0f0 /net/sunrpc/xprtsock.c | |
parent | 7559c7a28fbcaa0bca028eeebd5f251b09befe6b (diff) |
SUNRPC: skb_read_bits is the same as xs_tcp_copy_data
Clean-up: eliminate xs_tcp_copy_data -- it's exactly the same logic as the
common routine skb_read_bits. The UDP and TCP socket read code now share
the same routine for copying data into an xdr_buf.
Now that skb_read_bits() is exported, rename it to avoid confusing it with
a generic skb_* function. As these functions are XDR-specific, they should
not have names that suggest they are of generic use. Also rename
skb_read_and_csum_bits() to be consistent.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r-- | net/sunrpc/xprtsock.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index a94aff42d08c..450c350a0c62 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -651,22 +651,6 @@ static void xs_udp_data_ready(struct sock *sk, int len) | |||
651 | read_unlock(&sk->sk_callback_lock); | 651 | read_unlock(&sk->sk_callback_lock); |
652 | } | 652 | } |
653 | 653 | ||
654 | static inline size_t xs_tcp_copy_data(skb_reader_t *desc, void *p, size_t len) | ||
655 | { | ||
656 | if (len > desc->count) | ||
657 | len = desc->count; | ||
658 | if (skb_copy_bits(desc->skb, desc->offset, p, len)) { | ||
659 | dprintk("RPC: failed to copy %zu bytes from skb. %zu bytes remain\n", | ||
660 | len, desc->count); | ||
661 | return 0; | ||
662 | } | ||
663 | desc->offset += len; | ||
664 | desc->count -= len; | ||
665 | dprintk("RPC: copied %zu bytes from skb. %zu bytes remain\n", | ||
666 | len, desc->count); | ||
667 | return len; | ||
668 | } | ||
669 | |||
670 | static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc) | 654 | static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc) |
671 | { | 655 | { |
672 | struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); | 656 | struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); |
@@ -675,7 +659,7 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc | |||
675 | 659 | ||
676 | p = ((char *) &transport->tcp_fraghdr) + transport->tcp_offset; | 660 | p = ((char *) &transport->tcp_fraghdr) + transport->tcp_offset; |
677 | len = sizeof(transport->tcp_fraghdr) - transport->tcp_offset; | 661 | len = sizeof(transport->tcp_fraghdr) - transport->tcp_offset; |
678 | used = xs_tcp_copy_data(desc, p, len); | 662 | used = xdr_skb_read_bits(desc, p, len); |
679 | transport->tcp_offset += used; | 663 | transport->tcp_offset += used; |
680 | if (used != len) | 664 | if (used != len) |
681 | return; | 665 | return; |
@@ -721,7 +705,7 @@ static inline void xs_tcp_read_xid(struct sock_xprt *transport, skb_reader_t *de | |||
721 | len = sizeof(transport->tcp_xid) - transport->tcp_offset; | 705 | len = sizeof(transport->tcp_xid) - transport->tcp_offset; |
722 | dprintk("RPC: reading XID (%Zu bytes)\n", len); | 706 | dprintk("RPC: reading XID (%Zu bytes)\n", len); |
723 | p = ((char *) &transport->tcp_xid) + transport->tcp_offset; | 707 | p = ((char *) &transport->tcp_xid) + transport->tcp_offset; |
724 | used = xs_tcp_copy_data(desc, p, len); | 708 | used = xdr_skb_read_bits(desc, p, len); |
725 | transport->tcp_offset += used; | 709 | transport->tcp_offset += used; |
726 | if (used != len) | 710 | if (used != len) |
727 | return; | 711 | return; |
@@ -761,12 +745,12 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc | |||
761 | memcpy(&my_desc, desc, sizeof(my_desc)); | 745 | memcpy(&my_desc, desc, sizeof(my_desc)); |
762 | my_desc.count = len; | 746 | my_desc.count = len; |
763 | r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied, | 747 | r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied, |
764 | &my_desc, xs_tcp_copy_data); | 748 | &my_desc, xdr_skb_read_bits); |
765 | desc->count -= r; | 749 | desc->count -= r; |
766 | desc->offset += r; | 750 | desc->offset += r; |
767 | } else | 751 | } else |
768 | r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied, | 752 | r = xdr_partial_copy_from_skb(rcvbuf, transport->tcp_copied, |
769 | desc, xs_tcp_copy_data); | 753 | desc, xdr_skb_read_bits); |
770 | 754 | ||
771 | if (r > 0) { | 755 | if (r > 0) { |
772 | transport->tcp_copied += r; | 756 | transport->tcp_copied += r; |