diff options
author | Jeff Layton <jlayton@primarydata.com> | 2014-09-12 16:40:20 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-09-17 16:33:11 -0400 |
commit | f7790029655f79cdcee4fa7c7884e0c2795ebebe (patch) | |
tree | 9181503273f1355a506a7658ec0115c20c2047d0 | |
parent | f0c63124a6165792f6e37e4b5983792d009e1ce8 (diff) |
lockd: move lockd's grace period handling into its own module
Currently, all of the grace period handling is part of lockd. Eventually
though we'd like to be able to build v4-only servers, at which point
we'll need to put all of this elsewhere.
Move the code itself into fs/nfs_common and have it build a grace.ko
module. Then, rejigger the Kconfig options so that both nfsd and lockd
enable it automatically.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
-rw-r--r-- | fs/Kconfig | 6 | ||||
-rw-r--r-- | fs/lockd/Makefile | 2 | ||||
-rw-r--r-- | fs/lockd/netns.h | 1 | ||||
-rw-r--r-- | fs/lockd/svc.c | 2 | ||||
-rw-r--r-- | fs/nfs_common/Makefile | 3 | ||||
-rw-r--r-- | fs/nfs_common/grace.c (renamed from fs/lockd/grace.c) | 68 | ||||
-rw-r--r-- | fs/nfsd/Kconfig | 1 | ||||
-rw-r--r-- | include/linux/proc_fs.h | 2 |
8 files changed, 70 insertions, 15 deletions
diff --git a/fs/Kconfig b/fs/Kconfig index 312393f32948..db5dc1598716 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -233,9 +233,13 @@ if NETWORK_FILESYSTEMS | |||
233 | source "fs/nfs/Kconfig" | 233 | source "fs/nfs/Kconfig" |
234 | source "fs/nfsd/Kconfig" | 234 | source "fs/nfsd/Kconfig" |
235 | 235 | ||
236 | config GRACE_PERIOD | ||
237 | tristate | ||
238 | |||
236 | config LOCKD | 239 | config LOCKD |
237 | tristate | 240 | tristate |
238 | depends on FILE_LOCKING | 241 | depends on FILE_LOCKING |
242 | select GRACE_PERIOD | ||
239 | 243 | ||
240 | config LOCKD_V4 | 244 | config LOCKD_V4 |
241 | bool | 245 | bool |
@@ -249,7 +253,7 @@ config NFS_ACL_SUPPORT | |||
249 | 253 | ||
250 | config NFS_COMMON | 254 | config NFS_COMMON |
251 | bool | 255 | bool |
252 | depends on NFSD || NFS_FS | 256 | depends on NFSD || NFS_FS || LOCKD |
253 | default y | 257 | default y |
254 | 258 | ||
255 | source "net/sunrpc/Kconfig" | 259 | source "net/sunrpc/Kconfig" |
diff --git a/fs/lockd/Makefile b/fs/lockd/Makefile index ca58d64374ca..6a0b351ce30e 100644 --- a/fs/lockd/Makefile +++ b/fs/lockd/Makefile | |||
@@ -5,6 +5,6 @@ | |||
5 | obj-$(CONFIG_LOCKD) += lockd.o | 5 | obj-$(CONFIG_LOCKD) += lockd.o |
6 | 6 | ||
7 | lockd-objs-y := clntlock.o clntproc.o clntxdr.o host.o svc.o svclock.o \ | 7 | lockd-objs-y := clntlock.o clntproc.o clntxdr.o host.o svc.o svclock.o \ |
8 | svcshare.o svcproc.o svcsubs.o mon.o xdr.o grace.o | 8 | svcshare.o svcproc.o svcsubs.o mon.o xdr.o |
9 | lockd-objs-$(CONFIG_LOCKD_V4) += clnt4xdr.o xdr4.o svc4proc.o | 9 | lockd-objs-$(CONFIG_LOCKD_V4) += clnt4xdr.o xdr4.o svc4proc.o |
10 | lockd-objs := $(lockd-objs-y) | 10 | lockd-objs := $(lockd-objs-y) |
diff --git a/fs/lockd/netns.h b/fs/lockd/netns.h index 5010b55628b4..097bfa3adb1c 100644 --- a/fs/lockd/netns.h +++ b/fs/lockd/netns.h | |||
@@ -11,7 +11,6 @@ struct lockd_net { | |||
11 | 11 | ||
12 | struct delayed_work grace_period_end; | 12 | struct delayed_work grace_period_end; |
13 | struct lock_manager lockd_manager; | 13 | struct lock_manager lockd_manager; |
14 | struct list_head grace_list; | ||
15 | 14 | ||
16 | spinlock_t nsm_clnt_lock; | 15 | spinlock_t nsm_clnt_lock; |
17 | unsigned int nsm_users; | 16 | unsigned int nsm_users; |
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 09857b48d0c3..266b67972305 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -586,7 +586,7 @@ static int lockd_init_net(struct net *net) | |||
586 | struct lockd_net *ln = net_generic(net, lockd_net_id); | 586 | struct lockd_net *ln = net_generic(net, lockd_net_id); |
587 | 587 | ||
588 | INIT_DELAYED_WORK(&ln->grace_period_end, grace_ender); | 588 | INIT_DELAYED_WORK(&ln->grace_period_end, grace_ender); |
589 | INIT_LIST_HEAD(&ln->grace_list); | 589 | INIT_LIST_HEAD(&ln->lockd_manager.list); |
590 | spin_lock_init(&ln->nsm_clnt_lock); | 590 | spin_lock_init(&ln->nsm_clnt_lock); |
591 | return 0; | 591 | return 0; |
592 | } | 592 | } |
diff --git a/fs/nfs_common/Makefile b/fs/nfs_common/Makefile index f689ed82af3a..d153ca3ea577 100644 --- a/fs/nfs_common/Makefile +++ b/fs/nfs_common/Makefile | |||
@@ -3,5 +3,6 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_NFS_ACL_SUPPORT) += nfs_acl.o | 5 | obj-$(CONFIG_NFS_ACL_SUPPORT) += nfs_acl.o |
6 | |||
7 | nfs_acl-objs := nfsacl.o | 6 | nfs_acl-objs := nfsacl.o |
7 | |||
8 | obj-$(CONFIG_GRACE_PERIOD) += grace.o | ||
diff --git a/fs/lockd/grace.c b/fs/nfs_common/grace.c index 6d1ee7204c88..ae6e58ea4de5 100644 --- a/fs/lockd/grace.c +++ b/fs/nfs_common/grace.c | |||
@@ -1,17 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * Common code for control of lockd and nfsv4 grace periods. | 2 | * Common code for control of lockd and nfsv4 grace periods. |
3 | * | ||
4 | * Transplanted from lockd code | ||
3 | */ | 5 | */ |
4 | 6 | ||
5 | #include <linux/module.h> | 7 | #include <linux/module.h> |
6 | #include <linux/lockd/bind.h> | ||
7 | #include <net/net_namespace.h> | 8 | #include <net/net_namespace.h> |
9 | #include <net/netns/generic.h> | ||
10 | #include <linux/fs.h> | ||
8 | 11 | ||
9 | #include "netns.h" | 12 | static int grace_net_id; |
10 | |||
11 | static DEFINE_SPINLOCK(grace_lock); | 13 | static DEFINE_SPINLOCK(grace_lock); |
12 | 14 | ||
13 | /** | 15 | /** |
14 | * locks_start_grace | 16 | * locks_start_grace |
17 | * @net: net namespace that this lock manager belongs to | ||
15 | * @lm: who this grace period is for | 18 | * @lm: who this grace period is for |
16 | * | 19 | * |
17 | * A grace period is a period during which locks should not be given | 20 | * A grace period is a period during which locks should not be given |
@@ -21,18 +24,20 @@ static DEFINE_SPINLOCK(grace_lock); | |||
21 | * | 24 | * |
22 | * This function is called to start a grace period. | 25 | * This function is called to start a grace period. |
23 | */ | 26 | */ |
24 | void locks_start_grace(struct net *net, struct lock_manager *lm) | 27 | void |
28 | locks_start_grace(struct net *net, struct lock_manager *lm) | ||
25 | { | 29 | { |
26 | struct lockd_net *ln = net_generic(net, lockd_net_id); | 30 | struct list_head *grace_list = net_generic(net, grace_net_id); |
27 | 31 | ||
28 | spin_lock(&grace_lock); | 32 | spin_lock(&grace_lock); |
29 | list_add(&lm->list, &ln->grace_list); | 33 | list_add(&lm->list, grace_list); |
30 | spin_unlock(&grace_lock); | 34 | spin_unlock(&grace_lock); |
31 | } | 35 | } |
32 | EXPORT_SYMBOL_GPL(locks_start_grace); | 36 | EXPORT_SYMBOL_GPL(locks_start_grace); |
33 | 37 | ||
34 | /** | 38 | /** |
35 | * locks_end_grace | 39 | * locks_end_grace |
40 | * @net: net namespace that this lock manager belongs to | ||
36 | * @lm: who this grace period is for | 41 | * @lm: who this grace period is for |
37 | * | 42 | * |
38 | * Call this function to state that the given lock manager is ready to | 43 | * Call this function to state that the given lock manager is ready to |
@@ -41,7 +46,8 @@ EXPORT_SYMBOL_GPL(locks_start_grace); | |||
41 | * Note that callers count on it being safe to call this more than once, | 46 | * Note that callers count on it being safe to call this more than once, |
42 | * and the second call should be a no-op. | 47 | * and the second call should be a no-op. |
43 | */ | 48 | */ |
44 | void locks_end_grace(struct lock_manager *lm) | 49 | void |
50 | locks_end_grace(struct lock_manager *lm) | ||
45 | { | 51 | { |
46 | spin_lock(&grace_lock); | 52 | spin_lock(&grace_lock); |
47 | list_del_init(&lm->list); | 53 | list_del_init(&lm->list); |
@@ -56,10 +62,52 @@ EXPORT_SYMBOL_GPL(locks_end_grace); | |||
56 | * to answer ordinary lock requests, and when they should accept only | 62 | * to answer ordinary lock requests, and when they should accept only |
57 | * lock reclaims. | 63 | * lock reclaims. |
58 | */ | 64 | */ |
59 | int locks_in_grace(struct net *net) | 65 | int |
66 | locks_in_grace(struct net *net) | ||
60 | { | 67 | { |
61 | struct lockd_net *ln = net_generic(net, lockd_net_id); | 68 | struct list_head *grace_list = net_generic(net, grace_net_id); |
62 | 69 | ||
63 | return !list_empty(&ln->grace_list); | 70 | return !list_empty(grace_list); |
64 | } | 71 | } |
65 | EXPORT_SYMBOL_GPL(locks_in_grace); | 72 | EXPORT_SYMBOL_GPL(locks_in_grace); |
73 | |||
74 | static int __net_init | ||
75 | grace_init_net(struct net *net) | ||
76 | { | ||
77 | struct list_head *grace_list = net_generic(net, grace_net_id); | ||
78 | |||
79 | INIT_LIST_HEAD(grace_list); | ||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static void __net_exit | ||
84 | grace_exit_net(struct net *net) | ||
85 | { | ||
86 | struct list_head *grace_list = net_generic(net, grace_net_id); | ||
87 | |||
88 | BUG_ON(!list_empty(grace_list)); | ||
89 | } | ||
90 | |||
91 | static struct pernet_operations grace_net_ops = { | ||
92 | .init = grace_init_net, | ||
93 | .exit = grace_exit_net, | ||
94 | .id = &grace_net_id, | ||
95 | .size = sizeof(struct list_head), | ||
96 | }; | ||
97 | |||
98 | static int __init | ||
99 | init_grace(void) | ||
100 | { | ||
101 | return register_pernet_subsys(&grace_net_ops); | ||
102 | } | ||
103 | |||
104 | static void __exit | ||
105 | exit_grace(void) | ||
106 | { | ||
107 | unregister_pernet_subsys(&grace_net_ops); | ||
108 | } | ||
109 | |||
110 | MODULE_AUTHOR("Jeff Layton <jlayton@primarydata.com>"); | ||
111 | MODULE_LICENSE("GPL"); | ||
112 | module_init(init_grace) | ||
113 | module_exit(exit_grace) | ||
diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig index f3586b645d7d..73395156bdb4 100644 --- a/fs/nfsd/Kconfig +++ b/fs/nfsd/Kconfig | |||
@@ -71,6 +71,7 @@ config NFSD_V4 | |||
71 | select FS_POSIX_ACL | 71 | select FS_POSIX_ACL |
72 | select SUNRPC_GSS | 72 | select SUNRPC_GSS |
73 | select CRYPTO | 73 | select CRYPTO |
74 | select GRACE_PERIOD | ||
74 | help | 75 | help |
75 | This option enables support in your system's NFS server for | 76 | This option enables support in your system's NFS server for |
76 | version 4 of the NFS protocol (RFC 3530). | 77 | version 4 of the NFS protocol (RFC 3530). |
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 9d117f61d976..b97bf2ef996e 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -74,6 +74,8 @@ static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *p | |||
74 | 74 | ||
75 | #endif /* CONFIG_PROC_FS */ | 75 | #endif /* CONFIG_PROC_FS */ |
76 | 76 | ||
77 | struct net; | ||
78 | |||
77 | static inline struct proc_dir_entry *proc_net_mkdir( | 79 | static inline struct proc_dir_entry *proc_net_mkdir( |
78 | struct net *net, const char *name, struct proc_dir_entry *parent) | 80 | struct net *net, const char *name, struct proc_dir_entry *parent) |
79 | { | 81 | { |