aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/svclock.c
diff options
context:
space:
mode:
authorOlaf Kirch <okir@suse.de>2006-10-04 05:15:59 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-04 10:55:17 -0400
commitf2af793db02d2c2f677bdb5bf8e0efdcbf9c0256 (patch)
tree2daa40a1a128905ff514df995903d8ef8d692b04 /fs/lockd/svclock.c
parent07ba80635117c136714084e019375aa508365375 (diff)
[PATCH] knfsd: lockd: make nlm_traverse_* more flexible
This patch makes nlm_traverse{locks,blocks,shares} and friends use a function pointer rather than a "action" enum. This function pointer is given two nlm_hosts (one given by the caller, the other taken from the lock/block/share currently visited), and is free to do with them as it wants. If it returns a non-zero value, the lockd/block/share is released. Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/lockd/svclock.c')
-rw-r--r--fs/lockd/svclock.c33
1 files changed, 8 insertions, 25 deletions
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 7209712f3832..1f91567a1b88 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -265,24 +265,20 @@ static void nlmsvc_release_block(struct nlm_block *block)
265 kref_put(&block->b_count, nlmsvc_free_block); 265 kref_put(&block->b_count, nlmsvc_free_block);
266} 266}
267 267
268static void nlmsvc_act_mark(struct nlm_host *host, struct nlm_file *file) 268/*
269{ 269 * Loop over all blocks and delete blocks held by
270 struct nlm_block *block; 270 * a matching host.
271 271 */
272 down(&file->f_sema); 272void nlmsvc_traverse_blocks(struct nlm_host *host,
273 list_for_each_entry(block, &file->f_blocks, b_flist) 273 struct nlm_file *file,
274 block->b_host->h_inuse = 1; 274 nlm_host_match_fn_t match)
275 up(&file->f_sema);
276}
277
278static void nlmsvc_act_unlock(struct nlm_host *host, struct nlm_file *file)
279{ 275{
280 struct nlm_block *block, *next; 276 struct nlm_block *block, *next;
281 277
282restart: 278restart:
283 down(&file->f_sema); 279 down(&file->f_sema);
284 list_for_each_entry_safe(block, next, &file->f_blocks, b_flist) { 280 list_for_each_entry_safe(block, next, &file->f_blocks, b_flist) {
285 if (host != NULL && host != block->b_host) 281 if (!match(block->b_host, host))
286 continue; 282 continue;
287 /* Do not destroy blocks that are not on 283 /* Do not destroy blocks that are not on
288 * the global retry list - why? */ 284 * the global retry list - why? */
@@ -298,19 +294,6 @@ restart:
298} 294}
299 295
300/* 296/*
301 * Loop over all blocks and perform the action specified.
302 * (NLM_ACT_CHECK handled by nlmsvc_inspect_file).
303 */
304void
305nlmsvc_traverse_blocks(struct nlm_host *host, struct nlm_file *file, int action)
306{
307 if (action == NLM_ACT_MARK)
308 nlmsvc_act_mark(host, file);
309 else
310 nlmsvc_act_unlock(host, file);
311}
312
313/*
314 * Initialize arguments for GRANTED call. The nlm_rqst structure 297 * Initialize arguments for GRANTED call. The nlm_rqst structure
315 * has been cleared already. 298 * has been cleared already.
316 */ 299 */