aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Dickson <SteveD@redhat.com>2007-11-08 04:05:04 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 02:05:24 -0500
commitef818a28fac9bd214e676986d8301db0582b92a9 (patch)
treeb1825d1ecdfa6b35951a61f6bc54363236c12cd0
parent2f74c0a05612b9c2014b5b67833dba9b9f523948 (diff)
NFS: Stop sillyname renames and unmounts from racing
Added an active/deactive mechanism to the nfs_server structure allowing async operations to hold off umount until the operations are done. Signed-off-by: Steve Dickson <steved@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/client.c3
-rw-r--r--fs/nfs/internal.h2
-rw-r--r--fs/nfs/super.c24
-rw-r--r--fs/nfs/unlink.c4
-rw-r--r--include/linux/nfs_fs_sb.h6
5 files changed, 39 insertions, 0 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index a6f625497612..c3740f5ab978 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -729,6 +729,9 @@ static struct nfs_server *nfs_alloc_server(void)
729 INIT_LIST_HEAD(&server->client_link); 729 INIT_LIST_HEAD(&server->client_link);
730 INIT_LIST_HEAD(&server->master_link); 730 INIT_LIST_HEAD(&server->master_link);
731 731
732 init_waitqueue_head(&server->active_wq);
733 atomic_set(&server->active, 0);
734
732 server->io_stats = nfs_alloc_iostats(); 735 server->io_stats = nfs_alloc_iostats();
733 if (!server->io_stats) { 736 if (!server->io_stats) {
734 kfree(server); 737 kfree(server);
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index f3acf48412be..75793794aefe 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -160,6 +160,8 @@ extern struct rpc_stat nfs_rpcstat;
160 160
161extern int __init register_nfs_fs(void); 161extern int __init register_nfs_fs(void);
162extern void __exit unregister_nfs_fs(void); 162extern void __exit unregister_nfs_fs(void);
163extern void nfs_sb_active(struct nfs_server *server);
164extern void nfs_sb_deactive(struct nfs_server *server);
163 165
164/* namespace.c */ 166/* namespace.c */
165extern char *nfs_path(const char *base, 167extern char *nfs_path(const char *base,
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 0b0c72a072ff..fda1635dd133 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -202,6 +202,7 @@ static int nfs_get_sb(struct file_system_type *, int, const char *, void *, stru
202static int nfs_xdev_get_sb(struct file_system_type *fs_type, 202static int nfs_xdev_get_sb(struct file_system_type *fs_type,
203 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); 203 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
204static void nfs_kill_super(struct super_block *); 204static void nfs_kill_super(struct super_block *);
205static void nfs_put_super(struct super_block *);
205 206
206static struct file_system_type nfs_fs_type = { 207static struct file_system_type nfs_fs_type = {
207 .owner = THIS_MODULE, 208 .owner = THIS_MODULE,
@@ -223,6 +224,7 @@ static const struct super_operations nfs_sops = {
223 .alloc_inode = nfs_alloc_inode, 224 .alloc_inode = nfs_alloc_inode,
224 .destroy_inode = nfs_destroy_inode, 225 .destroy_inode = nfs_destroy_inode,
225 .write_inode = nfs_write_inode, 226 .write_inode = nfs_write_inode,
227 .put_super = nfs_put_super,
226 .statfs = nfs_statfs, 228 .statfs = nfs_statfs,
227 .clear_inode = nfs_clear_inode, 229 .clear_inode = nfs_clear_inode,
228 .umount_begin = nfs_umount_begin, 230 .umount_begin = nfs_umount_begin,
@@ -325,6 +327,28 @@ void __exit unregister_nfs_fs(void)
325 unregister_filesystem(&nfs_fs_type); 327 unregister_filesystem(&nfs_fs_type);
326} 328}
327 329
330void nfs_sb_active(struct nfs_server *server)
331{
332 atomic_inc(&server->active);
333}
334
335void nfs_sb_deactive(struct nfs_server *server)
336{
337 if (atomic_dec_and_test(&server->active))
338 wake_up(&server->active_wq);
339}
340
341static void nfs_put_super(struct super_block *sb)
342{
343 struct nfs_server *server = NFS_SB(sb);
344 /*
345 * Make sure there are no outstanding ops to this server.
346 * If so, wait for them to finish before allowing the
347 * unmount to continue.
348 */
349 wait_event(server->active_wq, atomic_read(&server->active) == 0);
350}
351
328/* 352/*
329 * Deliver file system statistics to userspace 353 * Deliver file system statistics to userspace
330 */ 354 */
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 431981d0265f..8e5428e0b86f 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -14,6 +14,8 @@
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/wait.h> 15#include <linux/wait.h>
16 16
17#include "internal.h"
18
17struct nfs_unlinkdata { 19struct nfs_unlinkdata {
18 struct hlist_node list; 20 struct hlist_node list;
19 struct nfs_removeargs args; 21 struct nfs_removeargs args;
@@ -113,6 +115,7 @@ static void nfs_async_unlink_release(void *calldata)
113 struct nfs_unlinkdata *data = calldata; 115 struct nfs_unlinkdata *data = calldata;
114 116
115 nfs_dec_sillycount(data->dir); 117 nfs_dec_sillycount(data->dir);
118 nfs_sb_deactive(NFS_SERVER(data->dir));
116 nfs_free_unlinkdata(data); 119 nfs_free_unlinkdata(data);
117} 120}
118 121
@@ -153,6 +156,7 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n
153 nfs_dec_sillycount(dir); 156 nfs_dec_sillycount(dir);
154 return 0; 157 return 0;
155 } 158 }
159 nfs_sb_active(NFS_SERVER(dir));
156 data->args.fh = NFS_FH(dir); 160 data->args.fh = NFS_FH(dir);
157 nfs_fattr_init(&data->res.dir_attr); 161 nfs_fattr_init(&data->res.dir_attr);
158 162
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 0cac49bc0955..9f949b587684 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -3,6 +3,9 @@
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/backing-dev.h> 5#include <linux/backing-dev.h>
6#include <linux/wait.h>
7
8#include <asm/atomic.h>
6 9
7struct nfs_iostats; 10struct nfs_iostats;
8 11
@@ -110,6 +113,9 @@ struct nfs_server {
110 filesystem */ 113 filesystem */
111#endif 114#endif
112 void (*destroy)(struct nfs_server *); 115 void (*destroy)(struct nfs_server *);
116
117 atomic_t active; /* Keep trace of any activity to this server */
118 wait_queue_head_t active_wq; /* Wait for any activity to stop */
113}; 119};
114 120
115/* Server capabilities */ 121/* Server capabilities */