]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sunrpc/svcsock.c
svc: Add a max payload value to the transport
[linux-2.6-omap-h63xx.git] / net / sunrpc / svcsock.c
index 036ab520df21ec5ecea04342e979fc58762aa059..c507f6f8ee545c116be598cd673d71420296bcf0 100644 (file)
@@ -19,6 +19,7 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
+#include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/fcntl.h>
@@ -74,7 +75,7 @@
  *
  */
 
-#define RPCDBG_FACILITY        RPCDBG_SVCSOCK
+#define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
 
 static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
@@ -103,7 +104,7 @@ static struct lock_class_key svc_slock_key[2];
 static inline void svc_reclassify_socket(struct socket *sock)
 {
        struct sock *sk = sock->sk;
-       BUG_ON(sk->sk_lock.owner != NULL);
+       BUG_ON(sock_owned_by_user(sk));
        switch (sk->sk_family) {
        case AF_INET:
                sock_lock_init_class_and_name(sk, "slock-AF_INET-NFSD",
@@ -877,7 +878,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
        } else {
                rqstp->rq_arg.page_len = len - rqstp->rq_arg.head[0].iov_len;
                rqstp->rq_respages = rqstp->rq_pages + 1 +
-                       (rqstp->rq_arg.page_len + PAGE_SIZE - 1)/ PAGE_SIZE;
+                       DIV_ROUND_UP(rqstp->rq_arg.page_len, PAGE_SIZE);
        }
 
        if (serv->sv_stats)
@@ -899,12 +900,22 @@ svc_udp_sendto(struct svc_rqst *rqstp)
        return error;
 }
 
+static struct svc_xprt_ops svc_udp_ops = {
+};
+
+static struct svc_xprt_class svc_udp_class = {
+       .xcl_name = "udp",
+       .xcl_ops = &svc_udp_ops,
+       .xcl_max_payload = RPCSVC_MAXPAYLOAD_UDP,
+};
+
 static void
 svc_udp_init(struct svc_sock *svsk)
 {
        int one = 1;
        mm_segment_t oldfs;
 
+       svc_xprt_init(&svc_udp_class, &svsk->sk_xprt);
        svsk->sk_sk->sk_data_ready = svc_udp_data_ready;
        svsk->sk_sk->sk_write_space = svc_write_space;
        svsk->sk_recvfrom = svc_udp_recvfrom;
@@ -1343,12 +1354,34 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
        return sent;
 }
 
+static struct svc_xprt_ops svc_tcp_ops = {
+};
+
+static struct svc_xprt_class svc_tcp_class = {
+       .xcl_name = "tcp",
+       .xcl_ops = &svc_tcp_ops,
+       .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP,
+};
+
+void svc_init_xprt_sock(void)
+{
+       svc_reg_xprt_class(&svc_tcp_class);
+       svc_reg_xprt_class(&svc_udp_class);
+}
+
+void svc_cleanup_xprt_sock(void)
+{
+       svc_unreg_xprt_class(&svc_tcp_class);
+       svc_unreg_xprt_class(&svc_udp_class);
+}
+
 static void
 svc_tcp_init(struct svc_sock *svsk)
 {
        struct sock     *sk = svsk->sk_sk;
        struct tcp_sock *tp = tcp_sk(sk);
 
+       svc_xprt_init(&svc_tcp_class, &svsk->sk_xprt);
        svsk->sk_recvfrom = svc_tcp_recvfrom;
        svsk->sk_sendto = svc_tcp_sendto;