nfsd: make fs/nfsd/vfs.h for common includes
[safe/jmp/linux-2.6] / fs / nfsd / nfssvc.c
index d68cd05..2944b31 100644 (file)
@@ -34,6 +34,8 @@
 #include <linux/nfsd/syscall.h>
 #include <linux/lockd/bind.h>
 #include <linux/nfsacl.h>
+#include <linux/seq_file.h>
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY       NFSDDBG_SVC
 
@@ -410,7 +412,9 @@ nfsd_svc(unsigned short port, int nrservs)
        error = nfsd_racache_init(2*nrservs);
        if (error<0)
                goto out;
-       nfs4_state_start();
+       error = nfs4_state_start();
+       if (error)
+               goto out;
 
        nfsd_reset_versions();
 
@@ -505,7 +509,9 @@ nfsd(void *vrqstp)
                /* Lock the export hash tables for reading. */
                exp_readlock();
 
+               validate_process_creds();
                svc_process(rqstp);
+               validate_process_creds();
 
                /* Unlock export hash tables */
                exp_readunlock();
@@ -576,10 +582,6 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
                + rqstp->rq_res.head[0].iov_len;
        rqstp->rq_res.head[0].iov_len += sizeof(__be32);
 
-       /* NFSv4.1 DRC requires statp */
-       if (rqstp->rq_vers == 4)
-               nfsd4_set_statp(rqstp, statp);
-
        /* Now call the procedure handler, and encode NFS status. */
        nfserr = proc->pc_func(rqstp, rqstp->rq_argp, rqstp->rq_resp);
        nfserr = map_new_errors(rqstp->rq_vers, nfserr);
@@ -614,7 +616,25 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
 
 int nfsd_pool_stats_open(struct inode *inode, struct file *file)
 {
-       if (nfsd_serv == NULL)
+       int ret;
+       mutex_lock(&nfsd_mutex);
+       if (nfsd_serv == NULL) {
+               mutex_unlock(&nfsd_mutex);
                return -ENODEV;
-       return svc_pool_stats_open(nfsd_serv, file);
+       }
+       /* bump up the psudo refcount while traversing */
+       svc_get(nfsd_serv);
+       ret = svc_pool_stats_open(nfsd_serv, file);
+       mutex_unlock(&nfsd_mutex);
+       return ret;
+}
+
+int nfsd_pool_stats_release(struct inode *inode, struct file *file)
+{
+       int ret = seq_release(inode, file);
+       mutex_lock(&nfsd_mutex);
+       /* this function really, really should have been called svc_put() */
+       svc_destroy(nfsd_serv);
+       mutex_unlock(&nfsd_mutex);
+       return ret;
 }