aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/clntlock.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/lockd/clntlock.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'fs/lockd/clntlock.c')
-rw-r--r--fs/lockd/clntlock.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 64fd427c993c..8d4ea8351e3d 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -14,7 +14,6 @@
14#include <linux/sunrpc/clnt.h> 14#include <linux/sunrpc/clnt.h>
15#include <linux/sunrpc/svc.h> 15#include <linux/sunrpc/svc.h>
16#include <linux/lockd/lockd.h> 16#include <linux/lockd/lockd.h>
17#include <linux/smp_lock.h>
18#include <linux/kthread.h> 17#include <linux/kthread.h>
19 18
20#define NLMDBG_FACILITY NLMDBG_CLIENT 19#define NLMDBG_FACILITY NLMDBG_CLIENT
@@ -42,6 +41,7 @@ struct nlm_wait {
42}; 41};
43 42
44static LIST_HEAD(nlm_blocked); 43static LIST_HEAD(nlm_blocked);
44static DEFINE_SPINLOCK(nlm_blocked_lock);
45 45
46/** 46/**
47 * nlmclnt_init - Set up per-NFS mount point lockd data structures 47 * nlmclnt_init - Set up per-NFS mount point lockd data structures
@@ -79,7 +79,7 @@ EXPORT_SYMBOL_GPL(nlmclnt_init);
79 */ 79 */
80void nlmclnt_done(struct nlm_host *host) 80void nlmclnt_done(struct nlm_host *host)
81{ 81{
82 nlm_release_host(host); 82 nlmclnt_release_host(host);
83 lockd_down(); 83 lockd_down();
84} 84}
85EXPORT_SYMBOL_GPL(nlmclnt_done); 85EXPORT_SYMBOL_GPL(nlmclnt_done);
@@ -97,7 +97,10 @@ struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *
97 block->b_lock = fl; 97 block->b_lock = fl;
98 init_waitqueue_head(&block->b_wait); 98 init_waitqueue_head(&block->b_wait);
99 block->b_status = nlm_lck_blocked; 99 block->b_status = nlm_lck_blocked;
100
101 spin_lock(&nlm_blocked_lock);
100 list_add(&block->b_list, &nlm_blocked); 102 list_add(&block->b_list, &nlm_blocked);
103 spin_unlock(&nlm_blocked_lock);
101 } 104 }
102 return block; 105 return block;
103} 106}
@@ -106,7 +109,9 @@ void nlmclnt_finish_block(struct nlm_wait *block)
106{ 109{
107 if (block == NULL) 110 if (block == NULL)
108 return; 111 return;
112 spin_lock(&nlm_blocked_lock);
109 list_del(&block->b_list); 113 list_del(&block->b_list);
114 spin_unlock(&nlm_blocked_lock);
110 kfree(block); 115 kfree(block);
111} 116}
112 117
@@ -154,6 +159,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
154 * Look up blocked request based on arguments. 159 * Look up blocked request based on arguments.
155 * Warning: must not use cookie to match it! 160 * Warning: must not use cookie to match it!
156 */ 161 */
162 spin_lock(&nlm_blocked_lock);
157 list_for_each_entry(block, &nlm_blocked, b_list) { 163 list_for_each_entry(block, &nlm_blocked, b_list) {
158 struct file_lock *fl_blocked = block->b_lock; 164 struct file_lock *fl_blocked = block->b_lock;
159 165
@@ -178,6 +184,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
178 wake_up(&block->b_wait); 184 wake_up(&block->b_wait);
179 res = nlm_granted; 185 res = nlm_granted;
180 } 186 }
187 spin_unlock(&nlm_blocked_lock);
181 return res; 188 return res;
182} 189}
183 190
@@ -216,10 +223,6 @@ reclaimer(void *ptr)
216 allow_signal(SIGKILL); 223 allow_signal(SIGKILL);
217 224
218 down_write(&host->h_rwsem); 225 down_write(&host->h_rwsem);
219
220 /* This one ensures that our parent doesn't terminate while the
221 * reclaim is in progress */
222 lock_kernel();
223 lockd_up(); /* note: this cannot fail as lockd is already running */ 226 lockd_up(); /* note: this cannot fail as lockd is already running */
224 227
225 dprintk("lockd: reclaiming locks for host %s\n", host->h_name); 228 dprintk("lockd: reclaiming locks for host %s\n", host->h_name);
@@ -260,16 +263,17 @@ restart:
260 dprintk("NLM: done reclaiming locks for host %s\n", host->h_name); 263 dprintk("NLM: done reclaiming locks for host %s\n", host->h_name);
261 264
262 /* Now, wake up all processes that sleep on a blocked lock */ 265 /* Now, wake up all processes that sleep on a blocked lock */
266 spin_lock(&nlm_blocked_lock);
263 list_for_each_entry(block, &nlm_blocked, b_list) { 267 list_for_each_entry(block, &nlm_blocked, b_list) {
264 if (block->b_host == host) { 268 if (block->b_host == host) {
265 block->b_status = nlm_lck_denied_grace_period; 269 block->b_status = nlm_lck_denied_grace_period;
266 wake_up(&block->b_wait); 270 wake_up(&block->b_wait);
267 } 271 }
268 } 272 }
273 spin_unlock(&nlm_blocked_lock);
269 274
270 /* Release host handle after use */ 275 /* Release host handle after use */
271 nlm_release_host(host); 276 nlmclnt_release_host(host);
272 lockd_down(); 277 lockd_down();
273 unlock_kernel();
274 return 0; 278 return 0;
275} 279}