]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfs/callback.c
[ARM] 4982/1: [AT91] Drop old-style UART initialization (Part 1)
[linux-2.6-omap-h63xx.git] / fs / nfs / callback.c
index a070109fa6c702d101841d44da7d372c87dac318..66648dd92d9731c2aa016cd82219d67268383958 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/sunrpc/svcsock.h>
 #include <linux/nfs_fs.h>
 #include <linux/mutex.h>
+#include <linux/freezer.h>
 
 #include <net/inet_sock.h>
 
@@ -67,6 +68,7 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
        daemonize("nfsv4-svc");
        /* Process request with signals blocked, but allow SIGKILL.  */
        allow_signal(SIGKILL);
+       set_freezable();
 
        complete(&nfs_callback_info.started);
 
@@ -88,11 +90,10 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
                                        __FUNCTION__, -err);
                        break;
                }
-               dprintk("%s: request from %u.%u.%u.%u\n", __FUNCTION__,
-                               NIPQUAD(rqstp->rq_addr.sin_addr.s_addr));
                svc_process(rqstp);
        }
 
+       flush_signals(current);
        svc_exit_thread(rqstp);
        nfs_callback_info.pid = 0;
        complete(&nfs_callback_info.stopped);
@@ -105,7 +106,7 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
  */
 int nfs_callback_up(void)
 {
-       struct svc_serv *serv;
+       struct svc_serv *serv = NULL;
        int ret = 0;
 
        lock_kernel();
@@ -119,27 +120,33 @@ int nfs_callback_up(void)
        if (!serv)
                goto out_err;
 
-       ret = svc_makesock(serv, IPPROTO_TCP, nfs_callback_set_tcpport,
-                                                       SVC_SOCK_ANONYMOUS);
+       ret = svc_create_xprt(serv, "tcp", nfs_callback_set_tcpport,
+                             SVC_SOCK_ANONYMOUS);
        if (ret <= 0)
-               goto out_destroy;
+               goto out_err;
        nfs_callback_tcpport = ret;
        dprintk("Callback port = 0x%x\n", nfs_callback_tcpport);
 
        ret = svc_create_thread(nfs_callback_svc, serv);
        if (ret < 0)
-               goto out_destroy;
+               goto out_err;
        nfs_callback_info.serv = serv;
        wait_for_completion(&nfs_callback_info.started);
 out:
+       /*
+        * svc_create creates the svc_serv with sv_nrthreads == 1, and then
+        * svc_create_thread increments that. So we need to call svc_destroy
+        * on both success and failure so that the refcount is 1 when the
+        * thread exits.
+        */
+       if (serv)
+               svc_destroy(serv);
        mutex_unlock(&nfs_callback_mutex);
        unlock_kernel();
        return ret;
-out_destroy:
+out_err:
        dprintk("Couldn't create callback socket or server thread; err = %d\n",
                ret);
-       svc_destroy(serv);
-out_err:
        nfs_callback_info.users--;
        goto out;
 }
@@ -164,15 +171,18 @@ void nfs_callback_down(void)
 
 static int nfs_callback_authenticate(struct svc_rqst *rqstp)
 {
-       struct sockaddr_in *addr = &rqstp->rq_addr;
        struct nfs_client *clp;
+       RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
 
        /* Don't talk to strangers */
-       clp = nfs_find_client(addr, 4);
+       clp = nfs_find_client(svc_addr(rqstp), 4);
        if (clp == NULL)
                return SVC_DROP;
-       dprintk("%s: %u.%u.%u.%u NFSv4 callback!\n", __FUNCTION__, NIPQUAD(addr->sin_addr));
+
+       dprintk("%s: %s NFSv4 callback!\n", __FUNCTION__,
+                       svc_print_addr(rqstp, buf, sizeof(buf)));
        nfs_put_client(clp);
+
        switch (rqstp->rq_authop->flavour) {
                case RPC_AUTH_NULL:
                        if (rqstp->rq_proc != CB_NULL)