]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
SUNRPC: Optimise away svc_recv_available
authorTrond Myklebust <trond.myklebust@primarydata.com>
Sun, 3 Aug 2014 17:03:13 +0000 (13:03 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Sun, 17 Aug 2014 16:00:11 +0000 (12:00 -0400)
We really do not want to do ioctls in the server's fast path. Instead, let's
use the fact that we managed to read a full record as the indicator that
we should try to read the socket again.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/svcsock.c

index c24a8ff33f8fa1f5a66da0b4f2a57f775c86cb51..0e8b667337a2e1f8df76476cc0cb842ca491346f 100644 (file)
@@ -311,19 +311,6 @@ static int svc_one_sock_name(struct svc_sock *svsk, char *buf, int remaining)
        return len;
 }
 
-/*
- * Check input queue length
- */
-static int svc_recv_available(struct svc_sock *svsk)
-{
-       struct socket   *sock = svsk->sk_sock;
-       int             avail, err;
-
-       err = kernel_sock_ioctl(sock, TIOCINQ, (unsigned long) &avail);
-
-       return (err >= 0)? avail : err;
-}
-
 /*
  * Generic recvfrom routine.
  */
@@ -339,8 +326,14 @@ static int svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr,
 
        rqstp->rq_xprt_hlen = 0;
 
+       clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
        len = kernel_recvmsg(svsk->sk_sock, &msg, iov, nr, buflen,
                                msg.msg_flags);
+       /* If we read a full record, then assume there may be more
+        * data to read (stream based sockets only!)
+        */
+       if (len == buflen)
+               set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
 
        dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
                svsk, iov[0].iov_base, iov[0].iov_len, len);
@@ -980,8 +973,6 @@ static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp)
        unsigned int want;
        int len;
 
-       clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
-
        if (svsk->sk_tcplen < sizeof(rpc_fraghdr)) {
                struct kvec     iov;
 
@@ -1073,8 +1064,6 @@ static int copy_pages_to_kvecs(struct kvec *vec, struct page **pages, int len)
 static void svc_tcp_fragment_received(struct svc_sock *svsk)
 {
        /* If we have more data, signal svc_xprt_enqueue() to try again */
-       if (svc_recv_available(svsk) > sizeof(rpc_fraghdr))
-               set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
        dprintk("svc: TCP %s record (%d bytes)\n",
                svc_sock_final_rec(svsk) ? "final" : "nonfinal",
                svc_sock_reclen(svsk));