diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-07-25 08:57:22 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-07-27 16:49:22 -0400 |
commit | 5ccb0066f2d561549cc4d73d7f56b4ce3ca7a8a1 (patch) | |
tree | 43ca9eff5c94fc3609d858ce2a430c544fcc5f99 /fs/lockd | |
parent | db9c4553412d72c6a05e0168d1d487f66e0660b3 (diff) |
LockD: pass actual network namespace to grace period management functions
Passed network namespace replaced hard-coded init_net
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/grace.c | 6 | ||||
-rw-r--r-- | fs/lockd/svc.c | 16 | ||||
-rw-r--r-- | fs/lockd/svc4proc.c | 13 | ||||
-rw-r--r-- | fs/lockd/svclock.c | 16 | ||||
-rw-r--r-- | fs/lockd/svcproc.c | 15 |
5 files changed, 35 insertions, 31 deletions
diff --git a/fs/lockd/grace.c b/fs/lockd/grace.c index 8dbaff782098..6d1ee7204c88 100644 --- a/fs/lockd/grace.c +++ b/fs/lockd/grace.c | |||
@@ -21,9 +21,8 @@ static DEFINE_SPINLOCK(grace_lock); | |||
21 | * | 21 | * |
22 | * This function is called to start a grace period. | 22 | * This function is called to start a grace period. |
23 | */ | 23 | */ |
24 | void locks_start_grace(struct lock_manager *lm) | 24 | void locks_start_grace(struct net *net, struct lock_manager *lm) |
25 | { | 25 | { |
26 | struct net *net = &init_net; | ||
27 | struct lockd_net *ln = net_generic(net, lockd_net_id); | 26 | struct lockd_net *ln = net_generic(net, lockd_net_id); |
28 | 27 | ||
29 | spin_lock(&grace_lock); | 28 | spin_lock(&grace_lock); |
@@ -57,9 +56,8 @@ EXPORT_SYMBOL_GPL(locks_end_grace); | |||
57 | * to answer ordinary lock requests, and when they should accept only | 56 | * to answer ordinary lock requests, and when they should accept only |
58 | * lock reclaims. | 57 | * lock reclaims. |
59 | */ | 58 | */ |
60 | int locks_in_grace(void) | 59 | int locks_in_grace(struct net *net) |
61 | { | 60 | { |
62 | struct net *net = &init_net; | ||
63 | struct lockd_net *ln = net_generic(net, lockd_net_id); | 61 | struct lockd_net *ln = net_generic(net, lockd_net_id); |
64 | 62 | ||
65 | return !list_empty(&ln->grace_list); | 63 | return !list_empty(&ln->grace_list); |
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 834dfe2ed2e9..68271c206bdc 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -97,12 +97,12 @@ static void grace_ender(struct work_struct *grace) | |||
97 | locks_end_grace(&ln->lockd_manager); | 97 | locks_end_grace(&ln->lockd_manager); |
98 | } | 98 | } |
99 | 99 | ||
100 | static void set_grace_period(void) | 100 | static void set_grace_period(struct net *net) |
101 | { | 101 | { |
102 | unsigned long grace_period = get_lockd_grace_period(); | 102 | unsigned long grace_period = get_lockd_grace_period(); |
103 | struct lockd_net *ln = net_generic(&init_net, lockd_net_id); | 103 | struct lockd_net *ln = net_generic(net, lockd_net_id); |
104 | 104 | ||
105 | locks_start_grace(&ln->lockd_manager); | 105 | locks_start_grace(net, &ln->lockd_manager); |
106 | cancel_delayed_work_sync(&ln->grace_period_end); | 106 | cancel_delayed_work_sync(&ln->grace_period_end); |
107 | schedule_delayed_work(&ln->grace_period_end, grace_period); | 107 | schedule_delayed_work(&ln->grace_period_end, grace_period); |
108 | } | 108 | } |
@@ -110,12 +110,13 @@ static void set_grace_period(void) | |||
110 | static void restart_grace(void) | 110 | static void restart_grace(void) |
111 | { | 111 | { |
112 | if (nlmsvc_ops) { | 112 | if (nlmsvc_ops) { |
113 | struct lockd_net *ln = net_generic(&init_net, lockd_net_id); | 113 | struct net *net = &init_net; |
114 | struct lockd_net *ln = net_generic(net, lockd_net_id); | ||
114 | 115 | ||
115 | cancel_delayed_work_sync(&ln->grace_period_end); | 116 | cancel_delayed_work_sync(&ln->grace_period_end); |
116 | locks_end_grace(&ln->lockd_manager); | 117 | locks_end_grace(&ln->lockd_manager); |
117 | nlmsvc_invalidate_all(); | 118 | nlmsvc_invalidate_all(); |
118 | set_grace_period(); | 119 | set_grace_period(net); |
119 | } | 120 | } |
120 | } | 121 | } |
121 | 122 | ||
@@ -127,7 +128,8 @@ lockd(void *vrqstp) | |||
127 | { | 128 | { |
128 | int err = 0, preverr = 0; | 129 | int err = 0, preverr = 0; |
129 | struct svc_rqst *rqstp = vrqstp; | 130 | struct svc_rqst *rqstp = vrqstp; |
130 | struct lockd_net *ln = net_generic(&init_net, lockd_net_id); | 131 | struct net *net = &init_net; |
132 | struct lockd_net *ln = net_generic(net, lockd_net_id); | ||
131 | 133 | ||
132 | /* try_to_freeze() is called from svc_recv() */ | 134 | /* try_to_freeze() is called from svc_recv() */ |
133 | set_freezable(); | 135 | set_freezable(); |
@@ -141,7 +143,7 @@ lockd(void *vrqstp) | |||
141 | nlm_timeout = LOCKD_DFLT_TIMEO; | 143 | nlm_timeout = LOCKD_DFLT_TIMEO; |
142 | nlmsvc_timeout = nlm_timeout * HZ; | 144 | nlmsvc_timeout = nlm_timeout * HZ; |
143 | 145 | ||
144 | set_grace_period(); | 146 | set_grace_period(net); |
145 | 147 | ||
146 | /* | 148 | /* |
147 | * The main request loop. We don't terminate until the last | 149 | * The main request loop. We don't terminate until the last |
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 9a41fdc19511..4a43d253c045 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | #include <linux/lockd/lockd.h> | 12 | #include <linux/lockd/lockd.h> |
13 | #include <linux/lockd/share.h> | 13 | #include <linux/lockd/share.h> |
14 | #include <linux/sunrpc/svc_xprt.h> | ||
14 | 15 | ||
15 | #define NLMDBG_FACILITY NLMDBG_CLIENT | 16 | #define NLMDBG_FACILITY NLMDBG_CLIENT |
16 | 17 | ||
@@ -151,7 +152,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
151 | resp->cookie = argp->cookie; | 152 | resp->cookie = argp->cookie; |
152 | 153 | ||
153 | /* Don't accept requests during grace period */ | 154 | /* Don't accept requests during grace period */ |
154 | if (locks_in_grace()) { | 155 | if (locks_in_grace(SVC_NET(rqstp))) { |
155 | resp->status = nlm_lck_denied_grace_period; | 156 | resp->status = nlm_lck_denied_grace_period; |
156 | return rpc_success; | 157 | return rpc_success; |
157 | } | 158 | } |
@@ -161,7 +162,7 @@ nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
161 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; | 162 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
162 | 163 | ||
163 | /* Try to cancel request. */ | 164 | /* Try to cancel request. */ |
164 | resp->status = nlmsvc_cancel_blocked(file, &argp->lock); | 165 | resp->status = nlmsvc_cancel_blocked(SVC_NET(rqstp), file, &argp->lock); |
165 | 166 | ||
166 | dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); | 167 | dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); |
167 | nlmsvc_release_host(host); | 168 | nlmsvc_release_host(host); |
@@ -184,7 +185,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
184 | resp->cookie = argp->cookie; | 185 | resp->cookie = argp->cookie; |
185 | 186 | ||
186 | /* Don't accept new lock requests during grace period */ | 187 | /* Don't accept new lock requests during grace period */ |
187 | if (locks_in_grace()) { | 188 | if (locks_in_grace(SVC_NET(rqstp))) { |
188 | resp->status = nlm_lck_denied_grace_period; | 189 | resp->status = nlm_lck_denied_grace_period; |
189 | return rpc_success; | 190 | return rpc_success; |
190 | } | 191 | } |
@@ -194,7 +195,7 @@ nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
194 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; | 195 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
195 | 196 | ||
196 | /* Now try to remove the lock */ | 197 | /* Now try to remove the lock */ |
197 | resp->status = nlmsvc_unlock(file, &argp->lock); | 198 | resp->status = nlmsvc_unlock(SVC_NET(rqstp), file, &argp->lock); |
198 | 199 | ||
199 | dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); | 200 | dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); |
200 | nlmsvc_release_host(host); | 201 | nlmsvc_release_host(host); |
@@ -321,7 +322,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
321 | resp->cookie = argp->cookie; | 322 | resp->cookie = argp->cookie; |
322 | 323 | ||
323 | /* Don't accept new lock requests during grace period */ | 324 | /* Don't accept new lock requests during grace period */ |
324 | if (locks_in_grace() && !argp->reclaim) { | 325 | if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) { |
325 | resp->status = nlm_lck_denied_grace_period; | 326 | resp->status = nlm_lck_denied_grace_period; |
326 | return rpc_success; | 327 | return rpc_success; |
327 | } | 328 | } |
@@ -354,7 +355,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
354 | resp->cookie = argp->cookie; | 355 | resp->cookie = argp->cookie; |
355 | 356 | ||
356 | /* Don't accept requests during grace period */ | 357 | /* Don't accept requests during grace period */ |
357 | if (locks_in_grace()) { | 358 | if (locks_in_grace(SVC_NET(rqstp))) { |
358 | resp->status = nlm_lck_denied_grace_period; | 359 | resp->status = nlm_lck_denied_grace_period; |
359 | return rpc_success; | 360 | return rpc_success; |
360 | } | 361 | } |
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index e46353f41a42..afe4488c33d8 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/sched.h> | 27 | #include <linux/sched.h> |
28 | #include <linux/sunrpc/clnt.h> | 28 | #include <linux/sunrpc/clnt.h> |
29 | #include <linux/sunrpc/svc.h> | 29 | #include <linux/sunrpc/svc_xprt.h> |
30 | #include <linux/lockd/nlm.h> | 30 | #include <linux/lockd/nlm.h> |
31 | #include <linux/lockd/lockd.h> | 31 | #include <linux/lockd/lockd.h> |
32 | #include <linux/kthread.h> | 32 | #include <linux/kthread.h> |
@@ -447,11 +447,11 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, | |||
447 | goto out; | 447 | goto out; |
448 | } | 448 | } |
449 | 449 | ||
450 | if (locks_in_grace() && !reclaim) { | 450 | if (locks_in_grace(SVC_NET(rqstp)) && !reclaim) { |
451 | ret = nlm_lck_denied_grace_period; | 451 | ret = nlm_lck_denied_grace_period; |
452 | goto out; | 452 | goto out; |
453 | } | 453 | } |
454 | if (reclaim && !locks_in_grace()) { | 454 | if (reclaim && !locks_in_grace(SVC_NET(rqstp))) { |
455 | ret = nlm_lck_denied_grace_period; | 455 | ret = nlm_lck_denied_grace_period; |
456 | goto out; | 456 | goto out; |
457 | } | 457 | } |
@@ -559,7 +559,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, | |||
559 | goto out; | 559 | goto out; |
560 | } | 560 | } |
561 | 561 | ||
562 | if (locks_in_grace()) { | 562 | if (locks_in_grace(SVC_NET(rqstp))) { |
563 | ret = nlm_lck_denied_grace_period; | 563 | ret = nlm_lck_denied_grace_period; |
564 | goto out; | 564 | goto out; |
565 | } | 565 | } |
@@ -603,7 +603,7 @@ out: | |||
603 | * must be removed. | 603 | * must be removed. |
604 | */ | 604 | */ |
605 | __be32 | 605 | __be32 |
606 | nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock) | 606 | nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock) |
607 | { | 607 | { |
608 | int error; | 608 | int error; |
609 | 609 | ||
@@ -615,7 +615,7 @@ nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock) | |||
615 | (long long)lock->fl.fl_end); | 615 | (long long)lock->fl.fl_end); |
616 | 616 | ||
617 | /* First, cancel any lock that might be there */ | 617 | /* First, cancel any lock that might be there */ |
618 | nlmsvc_cancel_blocked(file, lock); | 618 | nlmsvc_cancel_blocked(net, file, lock); |
619 | 619 | ||
620 | lock->fl.fl_type = F_UNLCK; | 620 | lock->fl.fl_type = F_UNLCK; |
621 | error = vfs_lock_file(file->f_file, F_SETLK, &lock->fl, NULL); | 621 | error = vfs_lock_file(file->f_file, F_SETLK, &lock->fl, NULL); |
@@ -631,7 +631,7 @@ nlmsvc_unlock(struct nlm_file *file, struct nlm_lock *lock) | |||
631 | * The calling procedure must check whether the file can be closed. | 631 | * The calling procedure must check whether the file can be closed. |
632 | */ | 632 | */ |
633 | __be32 | 633 | __be32 |
634 | nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock) | 634 | nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *lock) |
635 | { | 635 | { |
636 | struct nlm_block *block; | 636 | struct nlm_block *block; |
637 | int status = 0; | 637 | int status = 0; |
@@ -643,7 +643,7 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock) | |||
643 | (long long)lock->fl.fl_start, | 643 | (long long)lock->fl.fl_start, |
644 | (long long)lock->fl.fl_end); | 644 | (long long)lock->fl.fl_end); |
645 | 645 | ||
646 | if (locks_in_grace()) | 646 | if (locks_in_grace(net)) |
647 | return nlm_lck_denied_grace_period; | 647 | return nlm_lck_denied_grace_period; |
648 | 648 | ||
649 | mutex_lock(&file->f_mutex); | 649 | mutex_lock(&file->f_mutex); |
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index d27aab11f324..de8f2caa2235 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | #include <linux/lockd/lockd.h> | 12 | #include <linux/lockd/lockd.h> |
13 | #include <linux/lockd/share.h> | 13 | #include <linux/lockd/share.h> |
14 | #include <linux/sunrpc/svc_xprt.h> | ||
14 | 15 | ||
15 | #define NLMDBG_FACILITY NLMDBG_CLIENT | 16 | #define NLMDBG_FACILITY NLMDBG_CLIENT |
16 | 17 | ||
@@ -175,13 +176,14 @@ nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
175 | { | 176 | { |
176 | struct nlm_host *host; | 177 | struct nlm_host *host; |
177 | struct nlm_file *file; | 178 | struct nlm_file *file; |
179 | struct net *net = SVC_NET(rqstp); | ||
178 | 180 | ||
179 | dprintk("lockd: CANCEL called\n"); | 181 | dprintk("lockd: CANCEL called\n"); |
180 | 182 | ||
181 | resp->cookie = argp->cookie; | 183 | resp->cookie = argp->cookie; |
182 | 184 | ||
183 | /* Don't accept requests during grace period */ | 185 | /* Don't accept requests during grace period */ |
184 | if (locks_in_grace()) { | 186 | if (locks_in_grace(net)) { |
185 | resp->status = nlm_lck_denied_grace_period; | 187 | resp->status = nlm_lck_denied_grace_period; |
186 | return rpc_success; | 188 | return rpc_success; |
187 | } | 189 | } |
@@ -191,7 +193,7 @@ nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
191 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; | 193 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
192 | 194 | ||
193 | /* Try to cancel request. */ | 195 | /* Try to cancel request. */ |
194 | resp->status = cast_status(nlmsvc_cancel_blocked(file, &argp->lock)); | 196 | resp->status = cast_status(nlmsvc_cancel_blocked(net, file, &argp->lock)); |
195 | 197 | ||
196 | dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); | 198 | dprintk("lockd: CANCEL status %d\n", ntohl(resp->status)); |
197 | nlmsvc_release_host(host); | 199 | nlmsvc_release_host(host); |
@@ -208,13 +210,14 @@ nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
208 | { | 210 | { |
209 | struct nlm_host *host; | 211 | struct nlm_host *host; |
210 | struct nlm_file *file; | 212 | struct nlm_file *file; |
213 | struct net *net = SVC_NET(rqstp); | ||
211 | 214 | ||
212 | dprintk("lockd: UNLOCK called\n"); | 215 | dprintk("lockd: UNLOCK called\n"); |
213 | 216 | ||
214 | resp->cookie = argp->cookie; | 217 | resp->cookie = argp->cookie; |
215 | 218 | ||
216 | /* Don't accept new lock requests during grace period */ | 219 | /* Don't accept new lock requests during grace period */ |
217 | if (locks_in_grace()) { | 220 | if (locks_in_grace(net)) { |
218 | resp->status = nlm_lck_denied_grace_period; | 221 | resp->status = nlm_lck_denied_grace_period; |
219 | return rpc_success; | 222 | return rpc_success; |
220 | } | 223 | } |
@@ -224,7 +227,7 @@ nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
224 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; | 227 | return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; |
225 | 228 | ||
226 | /* Now try to remove the lock */ | 229 | /* Now try to remove the lock */ |
227 | resp->status = cast_status(nlmsvc_unlock(file, &argp->lock)); | 230 | resp->status = cast_status(nlmsvc_unlock(net, file, &argp->lock)); |
228 | 231 | ||
229 | dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); | 232 | dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status)); |
230 | nlmsvc_release_host(host); | 233 | nlmsvc_release_host(host); |
@@ -361,7 +364,7 @@ nlmsvc_proc_share(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
361 | resp->cookie = argp->cookie; | 364 | resp->cookie = argp->cookie; |
362 | 365 | ||
363 | /* Don't accept new lock requests during grace period */ | 366 | /* Don't accept new lock requests during grace period */ |
364 | if (locks_in_grace() && !argp->reclaim) { | 367 | if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) { |
365 | resp->status = nlm_lck_denied_grace_period; | 368 | resp->status = nlm_lck_denied_grace_period; |
366 | return rpc_success; | 369 | return rpc_success; |
367 | } | 370 | } |
@@ -394,7 +397,7 @@ nlmsvc_proc_unshare(struct svc_rqst *rqstp, struct nlm_args *argp, | |||
394 | resp->cookie = argp->cookie; | 397 | resp->cookie = argp->cookie; |
395 | 398 | ||
396 | /* Don't accept requests during grace period */ | 399 | /* Don't accept requests during grace period */ |
397 | if (locks_in_grace()) { | 400 | if (locks_in_grace(SVC_NET(rqstp))) { |
398 | resp->status = nlm_lck_denied_grace_period; | 401 | resp->status = nlm_lck_denied_grace_period; |
399 | return rpc_success; | 402 | return rpc_success; |
400 | } | 403 | } |