aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorChuck Lever <cel@netapp.com>2005-08-25 19:25:49 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2005-09-23 12:38:33 -0400
commit808012fbb23a52ec59352445d2076d175ad4ab26 (patch)
tree7175edb3917bc35f7f5484f567e91d7303a17663 /net/sunrpc/xprtsock.c
parent262965f53defd312a294b45366ea17907b6a616b (diff)
[PATCH] RPC: skip over transport-specific heads automatically
Add a generic mechanism for skipping over transport-specific headers when constructing an RPC request. This removes another "xprt->stream" dependency. Test-plan: Write-intensive workload on a single mount point (try both UDP and TCP). Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 57988300640a..aaf053b1a0c4 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -282,6 +282,13 @@ static int xs_udp_send_request(struct rpc_task *task)
282 return status; 282 return status;
283} 283}
284 284
285static inline void xs_encode_tcp_record_marker(struct xdr_buf *buf)
286{
287 u32 reclen = buf->len - sizeof(rpc_fraghdr);
288 rpc_fraghdr *base = buf->head[0].iov_base;
289 *base = htonl(RPC_LAST_STREAM_FRAGMENT | reclen);
290}
291
285/** 292/**
286 * xs_tcp_send_request - write an RPC request to a TCP socket 293 * xs_tcp_send_request - write an RPC request to a TCP socket
287 * @task: address of RPC task that manages the state of an RPC request 294 * @task: address of RPC task that manages the state of an RPC request
@@ -301,11 +308,9 @@ static int xs_tcp_send_request(struct rpc_task *task)
301 struct rpc_rqst *req = task->tk_rqstp; 308 struct rpc_rqst *req = task->tk_rqstp;
302 struct rpc_xprt *xprt = req->rq_xprt; 309 struct rpc_xprt *xprt = req->rq_xprt;
303 struct xdr_buf *xdr = &req->rq_snd_buf; 310 struct xdr_buf *xdr = &req->rq_snd_buf;
304 u32 *marker = req->rq_svec[0].iov_base;
305 int status, retry = 0; 311 int status, retry = 0;
306 312
307 /* Write the record marker */ 313 xs_encode_tcp_record_marker(&req->rq_snd_buf);
308 *marker = htonl(0x80000000|(req->rq_slen-sizeof(*marker)));
309 314
310 xs_pktdump("packet data:", 315 xs_pktdump("packet data:",
311 req->rq_svec->iov_base, 316 req->rq_svec->iov_base,
@@ -503,16 +508,19 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc
503 xprt->tcp_offset += used; 508 xprt->tcp_offset += used;
504 if (used != len) 509 if (used != len)
505 return; 510 return;
511
506 xprt->tcp_reclen = ntohl(xprt->tcp_recm); 512 xprt->tcp_reclen = ntohl(xprt->tcp_recm);
507 if (xprt->tcp_reclen & 0x80000000) 513 if (xprt->tcp_reclen & RPC_LAST_STREAM_FRAGMENT)
508 xprt->tcp_flags |= XPRT_LAST_FRAG; 514 xprt->tcp_flags |= XPRT_LAST_FRAG;
509 else 515 else
510 xprt->tcp_flags &= ~XPRT_LAST_FRAG; 516 xprt->tcp_flags &= ~XPRT_LAST_FRAG;
511 xprt->tcp_reclen &= 0x7fffffff; 517 xprt->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK;
518
512 xprt->tcp_flags &= ~XPRT_COPY_RECM; 519 xprt->tcp_flags &= ~XPRT_COPY_RECM;
513 xprt->tcp_offset = 0; 520 xprt->tcp_offset = 0;
521
514 /* Sanity check of the record length */ 522 /* Sanity check of the record length */
515 if (xprt->tcp_reclen < 4) { 523 if (unlikely(xprt->tcp_reclen < 4)) {
516 dprintk("RPC: invalid TCP record fragment length\n"); 524 dprintk("RPC: invalid TCP record fragment length\n");
517 xprt_disconnect(xprt); 525 xprt_disconnect(xprt);
518 return; 526 return;
@@ -1065,6 +1073,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1065 1073
1066 xprt->prot = IPPROTO_UDP; 1074 xprt->prot = IPPROTO_UDP;
1067 xprt->port = XS_MAX_RESVPORT; 1075 xprt->port = XS_MAX_RESVPORT;
1076 xprt->tsh_size = 0;
1068 xprt->stream = 0; 1077 xprt->stream = 0;
1069 xprt->nocong = 0; 1078 xprt->nocong = 0;
1070 xprt->cwnd = RPC_INITCWND; 1079 xprt->cwnd = RPC_INITCWND;
@@ -1105,11 +1114,12 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1105 1114
1106 xprt->prot = IPPROTO_TCP; 1115 xprt->prot = IPPROTO_TCP;
1107 xprt->port = XS_MAX_RESVPORT; 1116 xprt->port = XS_MAX_RESVPORT;
1117 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32);
1108 xprt->stream = 1; 1118 xprt->stream = 1;
1109 xprt->nocong = 1; 1119 xprt->nocong = 1;
1110 xprt->cwnd = RPC_MAXCWND(xprt); 1120 xprt->cwnd = RPC_MAXCWND(xprt);
1111 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; 1121 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0;
1112 xprt->max_payload = (1U << 31) - 1; 1122 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
1113 1123
1114 INIT_WORK(&xprt->connect_worker, xs_tcp_connect_worker, xprt); 1124 INIT_WORK(&xprt->connect_worker, xs_tcp_connect_worker, xprt);
1115 1125