Skip to content

Commit b26411f

Browse files
Stanislav KinsburskyJ. Bruce Fields
authored andcommitted
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>
1 parent 99dbb8f commit b26411f

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎fs/lockd/host.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,14 @@ nlm_gc_hosts(void)
628628
struct hlist_head *chain;
629629
struct hlist_node *pos, *next;
630630
struct nlm_host *host;
631+
struct net *net = &init_net;
631632

632633
dprintk("lockd: host garbage collection\n");
633634
for_each_host(host, pos, chain, nlm_server_hosts)
634635
host->h_inuse = 0;
635636

636637
/* Mark all hosts that hold locks, blocks or shares */
637-
nlmsvc_mark_resources();
638+
nlmsvc_mark_resources(net);
638639

639640
for_each_host_safe(host, pos, next, chain, nlm_server_hosts) {
640641
if (atomic_read(&host->h_count) || host->h_inuse

‎fs/lockd/svcsubs.c‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ nlm_release_file(struct nlm_file *file)
309309
* Helpers function for resource traversal
310310
*
311311
* 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.
313314
* Always returns 0.
314315
*
315316
* nlmsvc_same_host:
@@ -320,12 +321,15 @@ nlm_release_file(struct nlm_file *file)
320321
* returns 1 iff the host is a client.
321322
* Used by nlmsvc_invalidate_all
322323
*/
324+
323325
static int
324-
nlmsvc_mark_host(void *data, struct nlm_host *dummy)
326+
nlmsvc_mark_host(void *data, struct nlm_host *hint)
325327
{
326328
struct nlm_host *host = data;
327329

328-
host->h_inuse = 1;
330+
if ((hint->net == NULL) ||
331+
(host->net == hint->net))
332+
host->h_inuse = 1;
329333
return 0;
330334
}
331335

@@ -358,10 +362,13 @@ nlmsvc_is_client(void *data, struct nlm_host *dummy)
358362
* Mark all hosts that still hold resources
359363
*/
360364
void
361-
nlmsvc_mark_resources(void)
365+
nlmsvc_mark_resources(struct net *net)
362366
{
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);
365372
}
366373

367374
/*

‎include/linux/lockd/lockd.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void nlmsvc_release_call(struct nlm_rqst *);
279279
__be32 nlm_lookup_file(struct svc_rqst *, struct nlm_file **,
280280
struct nfs_fh *);
281281
void nlm_release_file(struct nlm_file *);
282-
void nlmsvc_mark_resources(void);
282+
void nlmsvc_mark_resources(struct net *);
283283
void nlmsvc_free_host_resources(struct nlm_host *);
284284
void nlmsvc_invalidate_all(void);
285285

0 commit comments

Comments
 (0)