aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/clntlock.c54
-rw-r--r--fs/lockd/clntproc.c11
-rw-r--r--fs/lockd/host.c2
3 files changed, 17 insertions, 50 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 8ae79ae4b998..0fc0ee267b04 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -155,34 +155,6 @@ u32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock)
155 */ 155 */
156 156
157/* 157/*
158 * Mark the locks for reclaiming.
159 * FIXME: In 2.5 we don't want to iterate through any global file_lock_list.
160 * Maintain NLM lock reclaiming lists in the nlm_host instead.
161 */
162static
163void nlmclnt_mark_reclaim(struct nlm_host *host)
164{
165 struct file_lock *fl;
166 struct inode *inode;
167 struct list_head *tmp;
168
169 list_for_each(tmp, &file_lock_list) {
170 fl = list_entry(tmp, struct file_lock, fl_link);
171
172 inode = fl->fl_file->f_dentry->d_inode;
173 if (inode->i_sb->s_magic != NFS_SUPER_MAGIC)
174 continue;
175 if (fl->fl_u.nfs_fl.owner == NULL)
176 continue;
177 if (fl->fl_u.nfs_fl.owner->host != host)
178 continue;
179 if (!(fl->fl_u.nfs_fl.flags & NFS_LCK_GRANTED))
180 continue;
181 fl->fl_u.nfs_fl.flags |= NFS_LCK_RECLAIM;
182 }
183}
184
185/*
186 * Someone has sent us an SM_NOTIFY. Ensure we bind to the new port number, 158 * Someone has sent us an SM_NOTIFY. Ensure we bind to the new port number,
187 * that we mark locks for reclaiming, and that we bump the pseudo NSM state. 159 * that we mark locks for reclaiming, and that we bump the pseudo NSM state.
188 */ 160 */
@@ -194,7 +166,12 @@ void nlmclnt_prepare_reclaim(struct nlm_host *host, u32 newstate)
194 host->h_state++; 166 host->h_state++;
195 host->h_nextrebind = 0; 167 host->h_nextrebind = 0;
196 nlm_rebind_host(host); 168 nlm_rebind_host(host);
197 nlmclnt_mark_reclaim(host); 169
170 /*
171 * Mark the locks for reclaiming.
172 */
173 list_splice_init(&host->h_granted, &host->h_reclaim);
174
198 dprintk("NLM: reclaiming locks for host %s", host->h_name); 175 dprintk("NLM: reclaiming locks for host %s", host->h_name);
199} 176}
200 177
@@ -223,9 +200,7 @@ reclaimer(void *ptr)
223{ 200{
224 struct nlm_host *host = (struct nlm_host *) ptr; 201 struct nlm_host *host = (struct nlm_host *) ptr;
225 struct nlm_wait *block; 202 struct nlm_wait *block;
226 struct list_head *tmp; 203 struct file_lock *fl, *next;
227 struct file_lock *fl;
228 struct inode *inode;
229 204
230 daemonize("%s-reclaim", host->h_name); 205 daemonize("%s-reclaim", host->h_name);
231 allow_signal(SIGKILL); 206 allow_signal(SIGKILL);
@@ -237,20 +212,9 @@ reclaimer(void *ptr)
237 212
238 /* First, reclaim all locks that have been marked. */ 213 /* First, reclaim all locks that have been marked. */
239restart: 214restart:
240 list_for_each(tmp, &file_lock_list) { 215 list_for_each_entry_safe(fl, next, &host->h_reclaim, fl_u.nfs_fl.list) {
241 fl = list_entry(tmp, struct file_lock, fl_link); 216 list_del(&fl->fl_u.nfs_fl.list);
242
243 inode = fl->fl_file->f_dentry->d_inode;
244 if (inode->i_sb->s_magic != NFS_SUPER_MAGIC)
245 continue;
246 if (fl->fl_u.nfs_fl.owner == NULL)
247 continue;
248 if (fl->fl_u.nfs_fl.owner->host != host)
249 continue;
250 if (!(fl->fl_u.nfs_fl.flags & NFS_LCK_RECLAIM))
251 continue;
252 217
253 fl->fl_u.nfs_fl.flags &= ~NFS_LCK_RECLAIM;
254 nlmclnt_reclaim(host, fl); 218 nlmclnt_reclaim(host, fl);
255 if (signalled()) 219 if (signalled())
256 break; 220 break;
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 80ae3127699f..cb469431bd1d 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -465,7 +465,6 @@ static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *ho
465{ 465{
466 BUG_ON(fl->fl_ops != NULL); 466 BUG_ON(fl->fl_ops != NULL);
467 fl->fl_u.nfs_fl.state = 0; 467 fl->fl_u.nfs_fl.state = 0;
468 fl->fl_u.nfs_fl.flags = 0;
469 fl->fl_u.nfs_fl.owner = nlm_find_lockowner(host, fl->fl_owner); 468 fl->fl_u.nfs_fl.owner = nlm_find_lockowner(host, fl->fl_owner);
470 fl->fl_ops = &nlmclnt_lock_ops; 469 fl->fl_ops = &nlmclnt_lock_ops;
471} 470}
@@ -552,8 +551,8 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
552 551
553 if (resp->status == NLM_LCK_GRANTED) { 552 if (resp->status == NLM_LCK_GRANTED) {
554 fl->fl_u.nfs_fl.state = host->h_state; 553 fl->fl_u.nfs_fl.state = host->h_state;
555 fl->fl_u.nfs_fl.flags |= NFS_LCK_GRANTED;
556 fl->fl_flags |= FL_SLEEP; 554 fl->fl_flags |= FL_SLEEP;
555 list_add_tail(&fl->fl_u.nfs_fl.list, &host->h_granted);
557 do_vfs_lock(fl); 556 do_vfs_lock(fl);
558 } 557 }
559 status = nlm_stat_to_errno(resp->status); 558 status = nlm_stat_to_errno(resp->status);
@@ -619,9 +618,11 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
619 struct nlm_res *resp = &req->a_res; 618 struct nlm_res *resp = &req->a_res;
620 int status; 619 int status;
621 620
622 /* Clean the GRANTED flag now so the lock doesn't get 621 /*
623 * reclaimed while we're stuck in the unlock call. */ 622 * Remove from the granted list now so the lock doesn't get
624 fl->fl_u.nfs_fl.flags &= ~NFS_LCK_GRANTED; 623 * reclaimed while we're stuck in the unlock call.
624 */
625 list_del(&fl->fl_u.nfs_fl.list);
625 626
626 /* 627 /*
627 * Note: the server is supposed to either grant us the unlock 628 * Note: the server is supposed to either grant us the unlock
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 100e78229700..f456f8ed9acd 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -123,6 +123,8 @@ nlm_lookup_host(int server, struct sockaddr_in *sin,
123 nlm_hosts[hash] = host; 123 nlm_hosts[hash] = host;
124 INIT_LIST_HEAD(&host->h_lockowners); 124 INIT_LIST_HEAD(&host->h_lockowners);
125 spin_lock_init(&host->h_lock); 125 spin_lock_init(&host->h_lock);
126 INIT_LIST_HEAD(&host->h_granted);
127 INIT_LIST_HEAD(&host->h_reclaim);
126 128
127 if (++nrhosts > NLM_HOST_MAX) 129 if (++nrhosts > NLM_HOST_MAX)
128 next_gc = 0; 130 next_gc = 0;