Lines Matching refs:host

37 #define for_each_host(host, chain, table) \  argument
40 hlist_for_each_entry((host), (chain), h_hash)
42 #define for_each_host_safe(host, next, chain, table) \ argument
45 hlist_for_each_entry_safe((host), (next), \
113 struct nlm_host *host = NULL; in nlm_alloc_host() local
119 host = NULL; in nlm_alloc_host()
129 host = kmalloc(sizeof(*host), GFP_KERNEL); in nlm_alloc_host()
130 if (unlikely(host == NULL)) { in nlm_alloc_host()
136 memcpy(nlm_addr(host), ni->sap, ni->salen); in nlm_alloc_host()
137 host->h_addrlen = ni->salen; in nlm_alloc_host()
138 rpc_set_port(nlm_addr(host), 0); in nlm_alloc_host()
139 host->h_srcaddrlen = 0; in nlm_alloc_host()
141 host->h_rpcclnt = NULL; in nlm_alloc_host()
142 host->h_name = nsm->sm_name; in nlm_alloc_host()
143 host->h_version = ni->version; in nlm_alloc_host()
144 host->h_proto = ni->protocol; in nlm_alloc_host()
145 host->h_reclaiming = 0; in nlm_alloc_host()
146 host->h_server = ni->server; in nlm_alloc_host()
147 host->h_noresvport = ni->noresvport; in nlm_alloc_host()
148 host->h_inuse = 0; in nlm_alloc_host()
149 init_waitqueue_head(&host->h_gracewait); in nlm_alloc_host()
150 init_rwsem(&host->h_rwsem); in nlm_alloc_host()
151 host->h_state = 0; in nlm_alloc_host()
152 host->h_nsmstate = 0; in nlm_alloc_host()
153 host->h_pidcount = 0; in nlm_alloc_host()
154 refcount_set(&host->h_count, 1); in nlm_alloc_host()
155 mutex_init(&host->h_mutex); in nlm_alloc_host()
156 host->h_nextrebind = now + NLM_HOST_REBIND; in nlm_alloc_host()
157 host->h_expires = now + NLM_HOST_EXPIRE; in nlm_alloc_host()
158 INIT_LIST_HEAD(&host->h_lockowners); in nlm_alloc_host()
159 spin_lock_init(&host->h_lock); in nlm_alloc_host()
160 INIT_LIST_HEAD(&host->h_granted); in nlm_alloc_host()
161 INIT_LIST_HEAD(&host->h_reclaim); in nlm_alloc_host()
162 host->h_nsmhandle = nsm; in nlm_alloc_host()
163 host->h_addrbuf = nsm->sm_addrbuf; in nlm_alloc_host()
164 host->net = ni->net; in nlm_alloc_host()
165 strlcpy(host->nodename, utsname()->nodename, sizeof(host->nodename)); in nlm_alloc_host()
168 return host; in nlm_alloc_host()
176 static void nlm_destroy_host_locked(struct nlm_host *host) in nlm_destroy_host_locked() argument
179 struct lockd_net *ln = net_generic(host->net, lockd_net_id); in nlm_destroy_host_locked()
181 dprintk("lockd: destroy host %s\n", host->h_name); in nlm_destroy_host_locked()
183 hlist_del_init(&host->h_hash); in nlm_destroy_host_locked()
185 nsm_unmonitor(host); in nlm_destroy_host_locked()
186 nsm_release(host->h_nsmhandle); in nlm_destroy_host_locked()
188 clnt = host->h_rpcclnt; in nlm_destroy_host_locked()
191 kfree(host); in nlm_destroy_host_locked()
231 struct nlm_host *host; in nlmclnt_lookup_host() local
242 hlist_for_each_entry(host, chain, h_hash) { in nlmclnt_lookup_host()
243 if (host->net != net) in nlmclnt_lookup_host()
245 if (!rpc_cmp_addr(nlm_addr(host), sap)) in nlmclnt_lookup_host()
250 nsm = host->h_nsmhandle; in nlmclnt_lookup_host()
252 if (host->h_proto != protocol) in nlmclnt_lookup_host()
254 if (host->h_version != version) in nlmclnt_lookup_host()
257 nlm_get_host(host); in nlmclnt_lookup_host()
259 host->h_name, host->h_addrbuf); in nlmclnt_lookup_host()
263 host = nlm_alloc_host(&ni, nsm); in nlmclnt_lookup_host()
264 if (unlikely(host == NULL)) in nlmclnt_lookup_host()
267 hlist_add_head(&host->h_hash, chain); in nlmclnt_lookup_host()
272 host->h_name, host->h_addrbuf); in nlmclnt_lookup_host()
276 return host; in nlmclnt_lookup_host()
284 void nlmclnt_release_host(struct nlm_host *host) in nlmclnt_release_host() argument
286 if (host == NULL) in nlmclnt_release_host()
289 dprintk("lockd: release client host %s\n", host->h_name); in nlmclnt_release_host()
291 WARN_ON_ONCE(host->h_server); in nlmclnt_release_host()
293 if (refcount_dec_and_test(&host->h_count)) { in nlmclnt_release_host()
294 WARN_ON_ONCE(!list_empty(&host->h_lockowners)); in nlmclnt_release_host()
295 WARN_ON_ONCE(!list_empty(&host->h_granted)); in nlmclnt_release_host()
296 WARN_ON_ONCE(!list_empty(&host->h_reclaim)); in nlmclnt_release_host()
299 nlm_destroy_host_locked(host); in nlmclnt_release_host()
327 struct nlm_host *host = NULL; in nlmsvc_lookup_host() local
354 hlist_for_each_entry(host, chain, h_hash) { in nlmsvc_lookup_host()
355 if (host->net != net) in nlmsvc_lookup_host()
357 if (!rpc_cmp_addr(nlm_addr(host), ni.sap)) in nlmsvc_lookup_host()
362 nsm = host->h_nsmhandle; in nlmsvc_lookup_host()
364 if (host->h_proto != ni.protocol) in nlmsvc_lookup_host()
366 if (host->h_version != ni.version) in nlmsvc_lookup_host()
368 if (!rpc_cmp_addr(nlm_srcaddr(host), src_sap)) in nlmsvc_lookup_host()
372 hlist_del(&host->h_hash); in nlmsvc_lookup_host()
373 hlist_add_head(&host->h_hash, chain); in nlmsvc_lookup_host()
375 nlm_get_host(host); in nlmsvc_lookup_host()
377 __func__, host->h_name, host->h_addrbuf); in nlmsvc_lookup_host()
381 host = nlm_alloc_host(&ni, nsm); in nlmsvc_lookup_host()
382 if (unlikely(host == NULL)) in nlmsvc_lookup_host()
385 memcpy(nlm_srcaddr(host), src_sap, src_len); in nlmsvc_lookup_host()
386 host->h_srcaddrlen = src_len; in nlmsvc_lookup_host()
387 hlist_add_head(&host->h_hash, chain); in nlmsvc_lookup_host()
391 refcount_inc(&host->h_count); in nlmsvc_lookup_host()
394 __func__, host->h_name, host->h_addrbuf); in nlmsvc_lookup_host()
398 return host; in nlmsvc_lookup_host()
407 void nlmsvc_release_host(struct nlm_host *host) in nlmsvc_release_host() argument
409 if (host == NULL) in nlmsvc_release_host()
412 dprintk("lockd: release server host %s\n", host->h_name); in nlmsvc_release_host()
414 WARN_ON_ONCE(!host->h_server); in nlmsvc_release_host()
415 refcount_dec(&host->h_count); in nlmsvc_release_host()
422 nlm_bind_host(struct nlm_host *host) in nlm_bind_host() argument
427 host->h_name, host->h_addrbuf); in nlm_bind_host()
430 mutex_lock(&host->h_mutex); in nlm_bind_host()
435 if ((clnt = host->h_rpcclnt) != NULL) { in nlm_bind_host()
436 if (time_after_eq(jiffies, host->h_nextrebind)) { in nlm_bind_host()
438 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_bind_host()
440 host->h_nextrebind - jiffies); in nlm_bind_host()
451 .net = host->net, in nlm_bind_host()
452 .protocol = host->h_proto, in nlm_bind_host()
453 .address = nlm_addr(host), in nlm_bind_host()
454 .addrsize = host->h_addrlen, in nlm_bind_host()
456 .servername = host->h_name, in nlm_bind_host()
458 .version = host->h_version, in nlm_bind_host()
469 if (!host->h_server) in nlm_bind_host()
471 if (host->h_noresvport) in nlm_bind_host()
473 if (host->h_srcaddrlen) in nlm_bind_host()
474 args.saddress = nlm_srcaddr(host); in nlm_bind_host()
478 host->h_rpcclnt = clnt; in nlm_bind_host()
480 printk("lockd: couldn't create RPC handle for %s\n", host->h_name); in nlm_bind_host()
485 mutex_unlock(&host->h_mutex); in nlm_bind_host()
493 nlm_rebind_host(struct nlm_host *host) in nlm_rebind_host() argument
495 dprintk("lockd: rebind host %s\n", host->h_name); in nlm_rebind_host()
496 if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) { in nlm_rebind_host()
497 rpc_force_rebind(host->h_rpcclnt); in nlm_rebind_host()
498 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_rebind_host()
505 struct nlm_host * nlm_get_host(struct nlm_host *host) in nlm_get_host() argument
507 if (host) { in nlm_get_host()
508 dprintk("lockd: get host %s\n", host->h_name); in nlm_get_host()
509 refcount_inc(&host->h_count); in nlm_get_host()
510 host->h_expires = jiffies + NLM_HOST_EXPIRE; in nlm_get_host()
512 return host; in nlm_get_host()
519 struct nlm_host *host; in next_host_state() local
523 for_each_host(host, chain, cache) { in next_host_state()
524 if (host->h_nsmhandle == nsm in next_host_state()
525 && host->h_nsmstate != info->state) { in next_host_state()
526 host->h_nsmstate = info->state; in next_host_state()
527 host->h_state++; in next_host_state()
529 nlm_get_host(host); in next_host_state()
531 return host; in next_host_state()
550 struct nlm_host *host; in nlm_host_rebooted() local
561 while ((host = next_host_state(nlm_server_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
562 nlmsvc_free_host_resources(host); in nlm_host_rebooted()
563 nlmsvc_release_host(host); in nlm_host_rebooted()
565 while ((host = next_host_state(nlm_client_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
566 nlmclnt_recovery(host); in nlm_host_rebooted()
567 nlmclnt_release_host(host); in nlm_host_rebooted()
576 struct nlm_host *host; in nlm_complain_hosts() local
594 for_each_host(host, chain, nlm_server_hosts) { in nlm_complain_hosts()
595 if (net && host->net != net) in nlm_complain_hosts()
598 host->h_name, refcount_read(&host->h_count), in nlm_complain_hosts()
599 host->h_inuse, host->h_expires, host->net->ns.inum); in nlm_complain_hosts()
607 struct nlm_host *host; in nlm_shutdown_hosts_net() local
614 for_each_host(host, chain, nlm_server_hosts) { in nlm_shutdown_hosts_net()
615 if (net && host->net != net) in nlm_shutdown_hosts_net()
617 host->h_expires = jiffies - 1; in nlm_shutdown_hosts_net()
618 if (host->h_rpcclnt) { in nlm_shutdown_hosts_net()
619 rpc_shutdown_client(host->h_rpcclnt); in nlm_shutdown_hosts_net()
620 host->h_rpcclnt = NULL; in nlm_shutdown_hosts_net()
651 struct nlm_host *host; in nlm_gc_hosts() local
655 for_each_host(host, chain, nlm_server_hosts) { in nlm_gc_hosts()
656 if (net && host->net != net) in nlm_gc_hosts()
658 host->h_inuse = 0; in nlm_gc_hosts()
664 for_each_host_safe(host, next, chain, nlm_server_hosts) { in nlm_gc_hosts()
665 if (net && host->net != net) in nlm_gc_hosts()
667 if (host->h_inuse || time_before(jiffies, host->h_expires)) { in nlm_gc_hosts()
670 host->h_name, refcount_read(&host->h_count), in nlm_gc_hosts()
671 host->h_inuse, host->h_expires, in nlm_gc_hosts()
672 host->net->ns.inum); in nlm_gc_hosts()
675 if (refcount_dec_if_one(&host->h_count)) in nlm_gc_hosts()
676 nlm_destroy_host_locked(host); in nlm_gc_hosts()