]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
nfsd: just keep single lockd reference for nfsd
authorJeff Layton <jlayton@redhat.com>
Tue, 20 Jul 2010 18:10:22 +0000 (14:10 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 23 Jul 2010 12:51:26 +0000 (08:51 -0400)
Right now, nfsd keeps a lockd reference for each socket that it has
open. This is unnecessary and complicates the error handling on
startup and shutdown. Change it to just do a lockd_up when starting
the first nfsd thread just do a single lockd_down when taking down the
last nfsd thread. Because of the strange way the sv_count is handled
this requires an extra flag to tell whether the nfsd_serv holds a
reference for lockd or not.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfsctl.c
fs/nfsd/nfssvc.c

index 9e8645a07fcaca396a6a4f30c00cbd71a3963433..b1c5be85bea535e298ba81fd40210a5139b31c8c 100644 (file)
@@ -949,15 +949,8 @@ static ssize_t __write_ports_addfd(char *buf)
        if (err != 0)
                return err;
 
-       err = lockd_up();
-       if (err != 0) {
-               svc_destroy(nfsd_serv);
-               return err;
-       }
-
        err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
        if (err < 0) {
-               lockd_down();
                svc_destroy(nfsd_serv);
                return err;
        }
@@ -982,9 +975,6 @@ static ssize_t __write_ports_delfd(char *buf)
        if (nfsd_serv != NULL)
                len = svc_sock_names(nfsd_serv, buf,
                                        SIMPLE_TRANSACTION_LIMIT, toclose);
-       if (len >= 0)
-               lockd_down();
-
        kfree(toclose);
        return len;
 }
index a631ea61f76aeae97e47b2b0e9b5856ee2876ea4..8a556ff2e10d1aa9fe04c61542e7e7c6ccbcd232 100644 (file)
@@ -186,8 +186,16 @@ static int nfsd_startup(unsigned short port, int nrservs)
 {
        int ret;
 
+       ret = lockd_up();
+       if (ret)
+               return ret;
        ret = nfs4_state_start();
+       if (ret)
+               goto out_lockd;
        nfsd_up = true;
+       return 0;
+out_lockd:
+       lockd_down();
        return ret;
 }
 
@@ -201,6 +209,7 @@ static void nfsd_shutdown(void)
         */
        if (!nfsd_up)
                return;
+       lockd_down();
        nfs4_state_shutdown();
        nfsd_up = false;
 }
@@ -208,9 +217,6 @@ static void nfsd_shutdown(void)
 static void nfsd_last_thread(struct svc_serv *serv)
 {
        /* When last nfsd thread exits we need to do some clean-up */
-       struct svc_xprt *xprt;
-       list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list)
-               lockd_down();
        nfsd_serv = NULL;
        nfsd_racache_shutdown();
        nfsd_shutdown();
@@ -310,19 +316,11 @@ static int nfsd_init_socks(int port)
        if (error < 0)
                return error;
 
-       error = lockd_up();
-       if (error < 0)
-               return error;
-
        error = svc_create_xprt(nfsd_serv, "tcp", PF_INET, port,
                                        SVC_SOCK_DEFAULTS);
        if (error < 0)
                return error;
 
-       error = lockd_up();
-       if (error < 0)
-               return error;
-
        return 0;
 }
 
@@ -400,6 +398,11 @@ int nfsd_set_nrthreads(int n, int *nthreads)
        return err;
 }
 
+/*
+ * Adjust the number of threads and return the new number of threads.
+ * This is also the function that starts the server if necessary, if
+ * this is the first time nrservs is nonzero.
+ */
 int
 nfsd_svc(unsigned short port, int nrservs)
 {