knfsd: Replace lock_kernel with a mutex in nfsd pool stats.
authorRyusei Yamaguchi <mandel59@gmail.com>
Sat, 15 Aug 2009 15:54:41 +0000 (00:54 +0900)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Tue, 25 Aug 2009 16:39:37 +0000 (12:39 -0400)
lock_kernel() in knfsd was replaced with a mutex. The later
commit 03cf6c9f49a8fea953d38648d016e3f46e814991 ("knfsd:
add file to export stats about nfsd pools") did not follow
that change. This patch fixes the issue.

Also move the get and put of nfsd_serv to the open and close methods
(instead of start and stop methods) to allow atomic check and increment
of reference count in the open method (where we can still return an
error).

Signed-off-by: Ryusei Yamaguchi <mandel59@gmail.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: Greg Banks <gnb@fmeh.org>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
fs/nfsd/nfsctl.c
fs/nfsd/nfssvc.c
net/sunrpc/svc_xprt.c

index b764d7d898e9bb4035e12c9ed4ea3f6dd9069b8d..00388d2a3c9970a3fdfccec1c4dda85904b6fd4e 100644 (file)
@@ -174,12 +174,13 @@ static const struct file_operations exports_operations = {
 };
 
 extern int nfsd_pool_stats_open(struct inode *inode, struct file *file);
+extern int nfsd_pool_stats_release(struct inode *inode, struct file *file);
 
 static struct file_operations pool_stats_operations = {
        .open           = nfsd_pool_stats_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
-       .release        = seq_release,
+       .release        = nfsd_pool_stats_release,
        .owner          = THIS_MODULE,
 };
 
index d68cd056b281b4ecde7830e2641168cca63d52b0..675d395c4ab6ddaa903d3a415b73c8c235b3eac3 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/nfsd/syscall.h>
 #include <linux/lockd/bind.h>
 #include <linux/nfsacl.h>
+#include <linux/seq_file.h>
 
 #define NFSDDBG_FACILITY       NFSDDBG_SVC
 
@@ -614,7 +615,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;
 }
index 27d44332f0175968c0729646ae4641321104bbd6..dcd2d1ee2e3ca94fa57b58f6e3e3a74e8956d21f 100644 (file)
@@ -1166,11 +1166,6 @@ static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos)
 
        dprintk("svc_pool_stats_start, *pidx=%u\n", pidx);
 
-       lock_kernel();
-       /* bump up the pseudo refcount while traversing */
-       svc_get(serv);
-       unlock_kernel();
-
        if (!pidx)
                return SEQ_START_TOKEN;
        return (pidx > serv->sv_nrpools ? NULL : &serv->sv_pools[pidx-1]);
@@ -1198,12 +1193,6 @@ static void *svc_pool_stats_next(struct seq_file *m, void *p, loff_t *pos)
 
 static void svc_pool_stats_stop(struct seq_file *m, void *p)
 {
-       struct svc_serv *serv = m->private;
-
-       lock_kernel();
-       /* this function really, really should have been called svc_put() */
-       svc_destroy(serv);
-       unlock_kernel();
 }
 
 static int svc_pool_stats_show(struct seq_file *m, void *p)
This page took 0.031674 seconds and 5 git commands to generate.