diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-05-18 17:47:56 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-04-07 14:36:39 -0400 |
commit | 5ee78d483c5812228e971e145b912e0a7e35e571 (patch) | |
tree | 0d4003ba3802f8e26d44c45a3fc0cdcb95f68999 | |
parent | 0601f793921157603831d00a9541d92e8f5763f6 (diff) |
SUNRPC: svc_tcp_recvfrom cleanup
Minor cleanup in preparation for later patches.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | net/sunrpc/svcsock.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 7a3e4bfd895d..733c2f6a1858 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -893,6 +893,7 @@ failed: | |||
893 | static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp) | 893 | static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp) |
894 | { | 894 | { |
895 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; | 895 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; |
896 | unsigned int want; | ||
896 | int len; | 897 | int len; |
897 | 898 | ||
898 | if (test_and_clear_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags)) | 899 | if (test_and_clear_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags)) |
@@ -915,9 +916,9 @@ static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp) | |||
915 | clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); | 916 | clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); |
916 | 917 | ||
917 | if (svsk->sk_tcplen < sizeof(rpc_fraghdr)) { | 918 | if (svsk->sk_tcplen < sizeof(rpc_fraghdr)) { |
918 | int want = sizeof(rpc_fraghdr) - svsk->sk_tcplen; | ||
919 | struct kvec iov; | 919 | struct kvec iov; |
920 | 920 | ||
921 | want = sizeof(rpc_fraghdr) - svsk->sk_tcplen; | ||
921 | iov.iov_base = ((char *) &svsk->sk_reclen) + svsk->sk_tcplen; | 922 | iov.iov_base = ((char *) &svsk->sk_reclen) + svsk->sk_tcplen; |
922 | iov.iov_len = want; | 923 | iov.iov_len = want; |
923 | if ((len = svc_recvfrom(rqstp, &iov, 1, want)) < 0) | 924 | if ((len = svc_recvfrom(rqstp, &iov, 1, want)) < 0) |
@@ -1040,8 +1041,9 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) | |||
1040 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; | 1041 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; |
1041 | int len; | 1042 | int len; |
1042 | struct kvec *vec; | 1043 | struct kvec *vec; |
1043 | int pnum, vlen; | ||
1044 | struct rpc_rqst *req = NULL; | 1044 | struct rpc_rqst *req = NULL; |
1045 | unsigned int vlen; | ||
1046 | int pnum; | ||
1045 | 1047 | ||
1046 | dprintk("svc: tcp_recv %p data %d conn %d close %d\n", | 1048 | dprintk("svc: tcp_recv %p data %d conn %d close %d\n", |
1047 | svsk, test_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags), | 1049 | svsk, test_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags), |
@@ -1072,7 +1074,7 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) | |||
1072 | } | 1074 | } |
1073 | 1075 | ||
1074 | pnum = 1; | 1076 | pnum = 1; |
1075 | while (vlen < len) { | 1077 | while (vlen < svsk->sk_reclen - 8) { |
1076 | vec[pnum].iov_base = (req) ? | 1078 | vec[pnum].iov_base = (req) ? |
1077 | page_address(req->rq_private_buf.pages[pnum - 1]) : | 1079 | page_address(req->rq_private_buf.pages[pnum - 1]) : |
1078 | page_address(rqstp->rq_pages[pnum]); | 1080 | page_address(rqstp->rq_pages[pnum]); |
@@ -1083,29 +1085,23 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) | |||
1083 | rqstp->rq_respages = &rqstp->rq_pages[pnum]; | 1085 | rqstp->rq_respages = &rqstp->rq_pages[pnum]; |
1084 | 1086 | ||
1085 | /* Now receive data */ | 1087 | /* Now receive data */ |
1086 | len = svc_recvfrom(rqstp, vec, pnum, len); | 1088 | len = svc_recvfrom(rqstp, vec, pnum, svsk->sk_reclen - 8); |
1087 | if (len < 0) | 1089 | if (len < 0) |
1088 | goto err_again; | 1090 | goto err_again; |
1089 | 1091 | ||
1090 | /* | ||
1091 | * Account for the 8 bytes we read earlier | ||
1092 | */ | ||
1093 | len += 8; | ||
1094 | |||
1095 | if (req) { | 1092 | if (req) { |
1096 | xprt_complete_rqst(req->rq_task, len); | 1093 | xprt_complete_rqst(req->rq_task, svsk->sk_reclen); |
1097 | len = 0; | 1094 | rqstp->rq_arg.len = 0; |
1098 | goto out; | 1095 | goto out; |
1099 | } | 1096 | } |
1100 | dprintk("svc: TCP complete record (%d bytes)\n", len); | 1097 | dprintk("svc: TCP complete record (%d bytes)\n", svsk->sk_reclen); |
1101 | rqstp->rq_arg.len = len; | 1098 | rqstp->rq_arg.len = svsk->sk_reclen; |
1102 | rqstp->rq_arg.page_base = 0; | 1099 | rqstp->rq_arg.page_base = 0; |
1103 | if (len <= rqstp->rq_arg.head[0].iov_len) { | 1100 | if (rqstp->rq_arg.len <= rqstp->rq_arg.head[0].iov_len) { |
1104 | rqstp->rq_arg.head[0].iov_len = len; | 1101 | rqstp->rq_arg.head[0].iov_len = rqstp->rq_arg.len; |
1105 | rqstp->rq_arg.page_len = 0; | 1102 | rqstp->rq_arg.page_len = 0; |
1106 | } else { | 1103 | } else |
1107 | rqstp->rq_arg.page_len = len - rqstp->rq_arg.head[0].iov_len; | 1104 | rqstp->rq_arg.page_len = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len; |
1108 | } | ||
1109 | 1105 | ||
1110 | rqstp->rq_xprt_ctxt = NULL; | 1106 | rqstp->rq_xprt_ctxt = NULL; |
1111 | rqstp->rq_prot = IPPROTO_TCP; | 1107 | rqstp->rq_prot = IPPROTO_TCP; |
@@ -1123,7 +1119,7 @@ out: | |||
1123 | if (serv->sv_stats) | 1119 | if (serv->sv_stats) |
1124 | serv->sv_stats->nettcpcnt++; | 1120 | serv->sv_stats->nettcpcnt++; |
1125 | 1121 | ||
1126 | return len; | 1122 | return rqstp->rq_arg.len; |
1127 | 1123 | ||
1128 | err_again: | 1124 | err_again: |
1129 | if (len == -EAGAIN) { | 1125 | if (len == -EAGAIN) { |