Commit b26411f85d3763ec5fc553854d9c3c0966072090
Committed by
J. Bruce Fields
1 parent
99dbb8fe09
Exists in
master
and in
20 other branches
LockD: mark host per network namespace on garbage collect
This is required for per-network NLM shutdown and cleanup. This patch passes init_net for a while. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Showing 3 changed files with 16 additions and 8 deletions Side-by-side Diff
fs/lockd/host.c
... | ... | @@ -628,13 +628,14 @@ |
628 | 628 | struct hlist_head *chain; |
629 | 629 | struct hlist_node *pos, *next; |
630 | 630 | struct nlm_host *host; |
631 | + struct net *net = &init_net; | |
631 | 632 | |
632 | 633 | dprintk("lockd: host garbage collection\n"); |
633 | 634 | for_each_host(host, pos, chain, nlm_server_hosts) |
634 | 635 | host->h_inuse = 0; |
635 | 636 | |
636 | 637 | /* Mark all hosts that hold locks, blocks or shares */ |
637 | - nlmsvc_mark_resources(); | |
638 | + nlmsvc_mark_resources(net); | |
638 | 639 | |
639 | 640 | for_each_host_safe(host, pos, next, chain, nlm_server_hosts) { |
640 | 641 | if (atomic_read(&host->h_count) || host->h_inuse |
fs/lockd/svcsubs.c
... | ... | @@ -309,7 +309,8 @@ |
309 | 309 | * Helpers function for resource traversal |
310 | 310 | * |
311 | 311 | * nlmsvc_mark_host: |
312 | - * used by the garbage collector; simply sets h_inuse. | |
312 | + * used by the garbage collector; simply sets h_inuse only for those | |
313 | + * hosts, which passed network check. | |
313 | 314 | * Always returns 0. |
314 | 315 | * |
315 | 316 | * nlmsvc_same_host: |
316 | 317 | |
317 | 318 | |
... | ... | @@ -320,12 +321,15 @@ |
320 | 321 | * returns 1 iff the host is a client. |
321 | 322 | * Used by nlmsvc_invalidate_all |
322 | 323 | */ |
324 | + | |
323 | 325 | static int |
324 | -nlmsvc_mark_host(void *data, struct nlm_host *dummy) | |
326 | +nlmsvc_mark_host(void *data, struct nlm_host *hint) | |
325 | 327 | { |
326 | 328 | struct nlm_host *host = data; |
327 | 329 | |
328 | - host->h_inuse = 1; | |
330 | + if ((hint->net == NULL) || | |
331 | + (host->net == hint->net)) | |
332 | + host->h_inuse = 1; | |
329 | 333 | return 0; |
330 | 334 | } |
331 | 335 | |
332 | 336 | |
... | ... | @@ -358,10 +362,13 @@ |
358 | 362 | * Mark all hosts that still hold resources |
359 | 363 | */ |
360 | 364 | void |
361 | -nlmsvc_mark_resources(void) | |
365 | +nlmsvc_mark_resources(struct net *net) | |
362 | 366 | { |
363 | - dprintk("lockd: nlmsvc_mark_resources\n"); | |
364 | - nlm_traverse_files(NULL, nlmsvc_mark_host, NULL); | |
367 | + struct nlm_host hint; | |
368 | + | |
369 | + dprintk("lockd: nlmsvc_mark_resources for net %p\n", net); | |
370 | + hint.net = net; | |
371 | + nlm_traverse_files(&hint, nlmsvc_mark_host, NULL); | |
365 | 372 | } |
366 | 373 | |
367 | 374 | /* |
include/linux/lockd/lockd.h
... | ... | @@ -279,7 +279,7 @@ |
279 | 279 | __be32 nlm_lookup_file(struct svc_rqst *, struct nlm_file **, |
280 | 280 | struct nfs_fh *); |
281 | 281 | void nlm_release_file(struct nlm_file *); |
282 | -void nlmsvc_mark_resources(void); | |
282 | +void nlmsvc_mark_resources(struct net *); | |
283 | 283 | void nlmsvc_free_host_resources(struct nlm_host *); |
284 | 284 | void nlmsvc_invalidate_all(void); |
285 | 285 |