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 | |
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>
-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 | ||||
-rw-r--r-- | fs/nfsd/nfs4proc.c | 18 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 29 | ||||
-rw-r--r-- | fs/nfsd/state.h | 3 | ||||
-rw-r--r-- | include/linux/fs.h | 5 | ||||
-rw-r--r-- | include/linux/lockd/lockd.h | 4 |
10 files changed, 67 insertions, 58 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 | } |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 987e719fbae8..c9c1c0a25417 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -354,10 +354,10 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
354 | /* Openowner is now set, so sequence id will get bumped. Now we need | 354 | /* Openowner is now set, so sequence id will get bumped. Now we need |
355 | * these checks before we do any creates: */ | 355 | * these checks before we do any creates: */ |
356 | status = nfserr_grace; | 356 | status = nfserr_grace; |
357 | if (locks_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) | 357 | if (locks_in_grace(SVC_NET(rqstp)) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) |
358 | goto out; | 358 | goto out; |
359 | status = nfserr_no_grace; | 359 | status = nfserr_no_grace; |
360 | if (!locks_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) | 360 | if (!locks_in_grace(SVC_NET(rqstp)) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) |
361 | goto out; | 361 | goto out; |
362 | 362 | ||
363 | switch (open->op_claim_type) { | 363 | switch (open->op_claim_type) { |
@@ -686,7 +686,8 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
686 | 686 | ||
687 | nfs4_lock_state(); | 687 | nfs4_lock_state(); |
688 | /* check stateid */ | 688 | /* check stateid */ |
689 | if ((status = nfs4_preprocess_stateid_op(cstate, &read->rd_stateid, | 689 | if ((status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), |
690 | cstate, &read->rd_stateid, | ||
690 | RD_STATE, &read->rd_filp))) { | 691 | RD_STATE, &read->rd_filp))) { |
691 | dprintk("NFSD: nfsd4_read: couldn't process stateid!\n"); | 692 | dprintk("NFSD: nfsd4_read: couldn't process stateid!\n"); |
692 | goto out; | 693 | goto out; |
@@ -741,7 +742,7 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
741 | { | 742 | { |
742 | __be32 status; | 743 | __be32 status; |
743 | 744 | ||
744 | if (locks_in_grace()) | 745 | if (locks_in_grace(SVC_NET(rqstp))) |
745 | return nfserr_grace; | 746 | return nfserr_grace; |
746 | status = nfsd_unlink(rqstp, &cstate->current_fh, 0, | 747 | status = nfsd_unlink(rqstp, &cstate->current_fh, 0, |
747 | remove->rm_name, remove->rm_namelen); | 748 | remove->rm_name, remove->rm_namelen); |
@@ -760,8 +761,8 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
760 | 761 | ||
761 | if (!cstate->save_fh.fh_dentry) | 762 | if (!cstate->save_fh.fh_dentry) |
762 | return status; | 763 | return status; |
763 | if (locks_in_grace() && !(cstate->save_fh.fh_export->ex_flags | 764 | if (locks_in_grace(SVC_NET(rqstp)) && |
764 | & NFSEXP_NOSUBTREECHECK)) | 765 | !(cstate->save_fh.fh_export->ex_flags & NFSEXP_NOSUBTREECHECK)) |
765 | return nfserr_grace; | 766 | return nfserr_grace; |
766 | status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, | 767 | status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, |
767 | rename->rn_snamelen, &cstate->current_fh, | 768 | rename->rn_snamelen, &cstate->current_fh, |
@@ -845,7 +846,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
845 | 846 | ||
846 | if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { | 847 | if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { |
847 | nfs4_lock_state(); | 848 | nfs4_lock_state(); |
848 | status = nfs4_preprocess_stateid_op(cstate, | 849 | status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), cstate, |
849 | &setattr->sa_stateid, WR_STATE, NULL); | 850 | &setattr->sa_stateid, WR_STATE, NULL); |
850 | nfs4_unlock_state(); | 851 | nfs4_unlock_state(); |
851 | if (status) { | 852 | if (status) { |
@@ -890,7 +891,8 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
890 | return nfserr_inval; | 891 | return nfserr_inval; |
891 | 892 | ||
892 | nfs4_lock_state(); | 893 | nfs4_lock_state(); |
893 | status = nfs4_preprocess_stateid_op(cstate, stateid, WR_STATE, &filp); | 894 | status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), |
895 | cstate, stateid, WR_STATE, &filp); | ||
894 | if (filp) | 896 | if (filp) |
895 | get_file(filp); | 897 | get_file(filp); |
896 | nfs4_unlock_state(); | 898 | nfs4_unlock_state(); |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 4a44b50c2f58..34f65f10fa43 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -2885,7 +2885,8 @@ static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status) | |||
2885 | * Attempt to hand out a delegation. | 2885 | * Attempt to hand out a delegation. |
2886 | */ | 2886 | */ |
2887 | static void | 2887 | static void |
2888 | nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_ol_stateid *stp) | 2888 | nfs4_open_delegation(struct net *net, struct svc_fh *fh, |
2889 | struct nfsd4_open *open, struct nfs4_ol_stateid *stp) | ||
2889 | { | 2890 | { |
2890 | struct nfs4_delegation *dp; | 2891 | struct nfs4_delegation *dp; |
2891 | struct nfs4_openowner *oo = container_of(stp->st_stateowner, struct nfs4_openowner, oo_owner); | 2892 | struct nfs4_openowner *oo = container_of(stp->st_stateowner, struct nfs4_openowner, oo_owner); |
@@ -2906,7 +2907,7 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_ol_ | |||
2906 | case NFS4_OPEN_CLAIM_NULL: | 2907 | case NFS4_OPEN_CLAIM_NULL: |
2907 | /* Let's not give out any delegations till everyone's | 2908 | /* Let's not give out any delegations till everyone's |
2908 | * had the chance to reclaim theirs.... */ | 2909 | * had the chance to reclaim theirs.... */ |
2909 | if (locks_in_grace()) | 2910 | if (locks_in_grace(net)) |
2910 | goto out; | 2911 | goto out; |
2911 | if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED)) | 2912 | if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED)) |
2912 | goto out; | 2913 | goto out; |
@@ -3040,7 +3041,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf | |||
3040 | * Attempt to hand out a delegation. No error return, because the | 3041 | * Attempt to hand out a delegation. No error return, because the |
3041 | * OPEN succeeds even if we fail. | 3042 | * OPEN succeeds even if we fail. |
3042 | */ | 3043 | */ |
3043 | nfs4_open_delegation(current_fh, open, stp); | 3044 | nfs4_open_delegation(SVC_NET(rqstp), current_fh, open, stp); |
3044 | nodeleg: | 3045 | nodeleg: |
3045 | status = nfs_ok; | 3046 | status = nfs_ok; |
3046 | 3047 | ||
@@ -3279,11 +3280,11 @@ out: | |||
3279 | } | 3280 | } |
3280 | 3281 | ||
3281 | static inline __be32 | 3282 | static inline __be32 |
3282 | check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags) | 3283 | check_special_stateids(struct net *net, svc_fh *current_fh, stateid_t *stateid, int flags) |
3283 | { | 3284 | { |
3284 | if (ONE_STATEID(stateid) && (flags & RD_STATE)) | 3285 | if (ONE_STATEID(stateid) && (flags & RD_STATE)) |
3285 | return nfs_ok; | 3286 | return nfs_ok; |
3286 | else if (locks_in_grace()) { | 3287 | else if (locks_in_grace(net)) { |
3287 | /* Answer in remaining cases depends on existence of | 3288 | /* Answer in remaining cases depends on existence of |
3288 | * conflicting state; so we must wait out the grace period. */ | 3289 | * conflicting state; so we must wait out the grace period. */ |
3289 | return nfserr_grace; | 3290 | return nfserr_grace; |
@@ -3300,9 +3301,9 @@ check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags) | |||
3300 | * that are not able to provide mandatory locking. | 3301 | * that are not able to provide mandatory locking. |
3301 | */ | 3302 | */ |
3302 | static inline int | 3303 | static inline int |
3303 | grace_disallows_io(struct inode *inode) | 3304 | grace_disallows_io(struct net *net, struct inode *inode) |
3304 | { | 3305 | { |
3305 | return locks_in_grace() && mandatory_lock(inode); | 3306 | return locks_in_grace(net) && mandatory_lock(inode); |
3306 | } | 3307 | } |
3307 | 3308 | ||
3308 | /* Returns true iff a is later than b: */ | 3309 | /* Returns true iff a is later than b: */ |
@@ -3393,7 +3394,7 @@ static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, s | |||
3393 | * Checks for stateid operations | 3394 | * Checks for stateid operations |
3394 | */ | 3395 | */ |
3395 | __be32 | 3396 | __be32 |
3396 | nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | 3397 | nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate, |
3397 | stateid_t *stateid, int flags, struct file **filpp) | 3398 | stateid_t *stateid, int flags, struct file **filpp) |
3398 | { | 3399 | { |
3399 | struct nfs4_stid *s; | 3400 | struct nfs4_stid *s; |
@@ -3406,11 +3407,11 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | |||
3406 | if (filpp) | 3407 | if (filpp) |
3407 | *filpp = NULL; | 3408 | *filpp = NULL; |
3408 | 3409 | ||
3409 | if (grace_disallows_io(ino)) | 3410 | if (grace_disallows_io(net, ino)) |
3410 | return nfserr_grace; | 3411 | return nfserr_grace; |
3411 | 3412 | ||
3412 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) | 3413 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) |
3413 | return check_special_stateids(current_fh, stateid, flags); | 3414 | return check_special_stateids(net, current_fh, stateid, flags); |
3414 | 3415 | ||
3415 | status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, &s); | 3416 | status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, &s); |
3416 | if (status) | 3417 | if (status) |
@@ -4107,10 +4108,10 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4107 | goto out; | 4108 | goto out; |
4108 | 4109 | ||
4109 | status = nfserr_grace; | 4110 | status = nfserr_grace; |
4110 | if (locks_in_grace() && !lock->lk_reclaim) | 4111 | if (locks_in_grace(SVC_NET(rqstp)) && !lock->lk_reclaim) |
4111 | goto out; | 4112 | goto out; |
4112 | status = nfserr_no_grace; | 4113 | status = nfserr_no_grace; |
4113 | if (!locks_in_grace() && lock->lk_reclaim) | 4114 | if (!locks_in_grace(SVC_NET(rqstp)) && lock->lk_reclaim) |
4114 | goto out; | 4115 | goto out; |
4115 | 4116 | ||
4116 | locks_init_lock(&file_lock); | 4117 | locks_init_lock(&file_lock); |
@@ -4210,7 +4211,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
4210 | struct nfs4_lockowner *lo; | 4211 | struct nfs4_lockowner *lo; |
4211 | __be32 status; | 4212 | __be32 status; |
4212 | 4213 | ||
4213 | if (locks_in_grace()) | 4214 | if (locks_in_grace(SVC_NET(rqstp))) |
4214 | return nfserr_grace; | 4215 | return nfserr_grace; |
4215 | 4216 | ||
4216 | if (check_lock_length(lockt->lt_offset, lockt->lt_length)) | 4217 | if (check_lock_length(lockt->lt_offset, lockt->lt_length)) |
@@ -4703,7 +4704,7 @@ nfs4_state_start(void) | |||
4703 | get_net(net); | 4704 | get_net(net); |
4704 | nfsd4_client_tracking_init(net); | 4705 | nfsd4_client_tracking_init(net); |
4705 | boot_time = get_seconds(); | 4706 | boot_time = get_seconds(); |
4706 | locks_start_grace(&nn->nfsd4_manager); | 4707 | locks_start_grace(net, &nn->nfsd4_manager); |
4707 | grace_ended = false; | 4708 | grace_ended = false; |
4708 | printk(KERN_INFO "NFSD: starting %ld-second grace period\n", | 4709 | printk(KERN_INFO "NFSD: starting %ld-second grace period\n", |
4709 | nfsd4_grace); | 4710 | nfsd4_grace); |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 495df4e3aa67..981ef10141b3 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -451,7 +451,8 @@ static inline struct nfs4_ol_stateid *openlockstateid(struct nfs4_stid *s) | |||
451 | 451 | ||
452 | struct nfsd4_compound_state; | 452 | struct nfsd4_compound_state; |
453 | 453 | ||
454 | extern __be32 nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | 454 | extern __be32 nfs4_preprocess_stateid_op(struct net *net, |
455 | struct nfsd4_compound_state *cstate, | ||
455 | stateid_t *stateid, int flags, struct file **filp); | 456 | stateid_t *stateid, int flags, struct file **filp); |
456 | extern void nfs4_lock_state(void); | 457 | extern void nfs4_lock_state(void); |
457 | extern void nfs4_unlock_state(void); | 458 | extern void nfs4_unlock_state(void); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 17fd887c798f..a1e77270f5a5 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1163,9 +1163,10 @@ struct lock_manager { | |||
1163 | struct list_head list; | 1163 | struct list_head list; |
1164 | }; | 1164 | }; |
1165 | 1165 | ||
1166 | void locks_start_grace(struct lock_manager *); | 1166 | struct net; |
1167 | void locks_start_grace(struct net *, struct lock_manager *); | ||
1167 | void locks_end_grace(struct lock_manager *); | 1168 | void locks_end_grace(struct lock_manager *); |
1168 | int locks_in_grace(void); | 1169 | int locks_in_grace(struct net *); |
1169 | 1170 | ||
1170 | /* that will die - we need it for nfs_lock_info */ | 1171 | /* that will die - we need it for nfs_lock_info */ |
1171 | #include <linux/nfs_fs_i.h> | 1172 | #include <linux/nfs_fs_i.h> |
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 50e31a2c1a97..f5a051a79273 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h | |||
@@ -262,11 +262,11 @@ typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref); | |||
262 | __be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, | 262 | __be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, |
263 | struct nlm_host *, struct nlm_lock *, int, | 263 | struct nlm_host *, struct nlm_lock *, int, |
264 | struct nlm_cookie *, int); | 264 | struct nlm_cookie *, int); |
265 | __be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *); | 265 | __be32 nlmsvc_unlock(struct net *net, struct nlm_file *, struct nlm_lock *); |
266 | __be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *, | 266 | __be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *, |
267 | struct nlm_host *, struct nlm_lock *, | 267 | struct nlm_host *, struct nlm_lock *, |
268 | struct nlm_lock *, struct nlm_cookie *); | 268 | struct nlm_lock *, struct nlm_cookie *); |
269 | __be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *); | 269 | __be32 nlmsvc_cancel_blocked(struct net *net, struct nlm_file *, struct nlm_lock *); |
270 | unsigned long nlmsvc_retry_blocked(void); | 270 | unsigned long nlmsvc_retry_blocked(void); |
271 | void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, | 271 | void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, |
272 | nlm_host_match_fn_t match); | 272 | nlm_host_match_fn_t match); |