Lines Matching refs:host
36 #define for_each_host(host, chain, table) \ argument
39 hlist_for_each_entry((host), (chain), h_hash)
41 #define for_each_host_safe(host, next, chain, table) \ argument
44 hlist_for_each_entry_safe((host), (next), \
112 struct nlm_host *host = NULL; in nlm_alloc_host() local
118 host = NULL; in nlm_alloc_host()
128 host = kmalloc(sizeof(*host), GFP_KERNEL); in nlm_alloc_host()
129 if (unlikely(host == NULL)) { in nlm_alloc_host()
135 memcpy(nlm_addr(host), ni->sap, ni->salen); in nlm_alloc_host()
136 host->h_addrlen = ni->salen; in nlm_alloc_host()
137 rpc_set_port(nlm_addr(host), 0); in nlm_alloc_host()
138 host->h_srcaddrlen = 0; in nlm_alloc_host()
140 host->h_rpcclnt = NULL; in nlm_alloc_host()
141 host->h_name = nsm->sm_name; in nlm_alloc_host()
142 host->h_version = ni->version; in nlm_alloc_host()
143 host->h_proto = ni->protocol; in nlm_alloc_host()
144 host->h_reclaiming = 0; in nlm_alloc_host()
145 host->h_server = ni->server; in nlm_alloc_host()
146 host->h_noresvport = ni->noresvport; in nlm_alloc_host()
147 host->h_inuse = 0; in nlm_alloc_host()
148 init_waitqueue_head(&host->h_gracewait); in nlm_alloc_host()
149 init_rwsem(&host->h_rwsem); in nlm_alloc_host()
150 host->h_state = 0; in nlm_alloc_host()
151 host->h_nsmstate = 0; in nlm_alloc_host()
152 host->h_pidcount = 0; in nlm_alloc_host()
153 atomic_set(&host->h_count, 1); in nlm_alloc_host()
154 mutex_init(&host->h_mutex); in nlm_alloc_host()
155 host->h_nextrebind = now + NLM_HOST_REBIND; in nlm_alloc_host()
156 host->h_expires = now + NLM_HOST_EXPIRE; in nlm_alloc_host()
157 INIT_LIST_HEAD(&host->h_lockowners); in nlm_alloc_host()
158 spin_lock_init(&host->h_lock); in nlm_alloc_host()
159 INIT_LIST_HEAD(&host->h_granted); in nlm_alloc_host()
160 INIT_LIST_HEAD(&host->h_reclaim); in nlm_alloc_host()
161 host->h_nsmhandle = nsm; in nlm_alloc_host()
162 host->h_addrbuf = nsm->sm_addrbuf; in nlm_alloc_host()
163 host->net = ni->net; in nlm_alloc_host()
164 strlcpy(host->nodename, utsname()->nodename, sizeof(host->nodename)); in nlm_alloc_host()
167 return host; in nlm_alloc_host()
175 static void nlm_destroy_host_locked(struct nlm_host *host) in nlm_destroy_host_locked() argument
178 struct lockd_net *ln = net_generic(host->net, lockd_net_id); in nlm_destroy_host_locked()
180 dprintk("lockd: destroy host %s\n", host->h_name); in nlm_destroy_host_locked()
182 hlist_del_init(&host->h_hash); in nlm_destroy_host_locked()
184 nsm_unmonitor(host); in nlm_destroy_host_locked()
185 nsm_release(host->h_nsmhandle); in nlm_destroy_host_locked()
187 clnt = host->h_rpcclnt; in nlm_destroy_host_locked()
190 kfree(host); in nlm_destroy_host_locked()
230 struct nlm_host *host; in nlmclnt_lookup_host() local
241 hlist_for_each_entry(host, chain, h_hash) { in nlmclnt_lookup_host()
242 if (host->net != net) in nlmclnt_lookup_host()
244 if (!rpc_cmp_addr(nlm_addr(host), sap)) in nlmclnt_lookup_host()
249 nsm = host->h_nsmhandle; in nlmclnt_lookup_host()
251 if (host->h_proto != protocol) in nlmclnt_lookup_host()
253 if (host->h_version != version) in nlmclnt_lookup_host()
256 nlm_get_host(host); in nlmclnt_lookup_host()
258 host->h_name, host->h_addrbuf); in nlmclnt_lookup_host()
262 host = nlm_alloc_host(&ni, nsm); in nlmclnt_lookup_host()
263 if (unlikely(host == NULL)) in nlmclnt_lookup_host()
266 hlist_add_head(&host->h_hash, chain); in nlmclnt_lookup_host()
271 host->h_name, host->h_addrbuf); in nlmclnt_lookup_host()
275 return host; in nlmclnt_lookup_host()
283 void nlmclnt_release_host(struct nlm_host *host) in nlmclnt_release_host() argument
285 if (host == NULL) in nlmclnt_release_host()
288 dprintk("lockd: release client host %s\n", host->h_name); in nlmclnt_release_host()
290 WARN_ON_ONCE(host->h_server); in nlmclnt_release_host()
292 if (atomic_dec_and_test(&host->h_count)) { in nlmclnt_release_host()
293 WARN_ON_ONCE(!list_empty(&host->h_lockowners)); in nlmclnt_release_host()
294 WARN_ON_ONCE(!list_empty(&host->h_granted)); in nlmclnt_release_host()
295 WARN_ON_ONCE(!list_empty(&host->h_reclaim)); in nlmclnt_release_host()
298 nlm_destroy_host_locked(host); in nlmclnt_release_host()
326 struct nlm_host *host = NULL; in nlmsvc_lookup_host() local
353 hlist_for_each_entry(host, chain, h_hash) { in nlmsvc_lookup_host()
354 if (host->net != net) in nlmsvc_lookup_host()
356 if (!rpc_cmp_addr(nlm_addr(host), ni.sap)) in nlmsvc_lookup_host()
361 nsm = host->h_nsmhandle; in nlmsvc_lookup_host()
363 if (host->h_proto != ni.protocol) in nlmsvc_lookup_host()
365 if (host->h_version != ni.version) in nlmsvc_lookup_host()
367 if (!rpc_cmp_addr(nlm_srcaddr(host), src_sap)) in nlmsvc_lookup_host()
371 hlist_del(&host->h_hash); in nlmsvc_lookup_host()
372 hlist_add_head(&host->h_hash, chain); in nlmsvc_lookup_host()
374 nlm_get_host(host); in nlmsvc_lookup_host()
376 __func__, host->h_name, host->h_addrbuf); in nlmsvc_lookup_host()
380 host = nlm_alloc_host(&ni, nsm); in nlmsvc_lookup_host()
381 if (unlikely(host == NULL)) in nlmsvc_lookup_host()
384 memcpy(nlm_srcaddr(host), src_sap, src_len); in nlmsvc_lookup_host()
385 host->h_srcaddrlen = src_len; in nlmsvc_lookup_host()
386 hlist_add_head(&host->h_hash, chain); in nlmsvc_lookup_host()
391 __func__, host->h_name, host->h_addrbuf); in nlmsvc_lookup_host()
395 return host; in nlmsvc_lookup_host()
404 void nlmsvc_release_host(struct nlm_host *host) in nlmsvc_release_host() argument
406 if (host == NULL) in nlmsvc_release_host()
409 dprintk("lockd: release server host %s\n", host->h_name); in nlmsvc_release_host()
411 WARN_ON_ONCE(!host->h_server); in nlmsvc_release_host()
412 atomic_dec(&host->h_count); in nlmsvc_release_host()
419 nlm_bind_host(struct nlm_host *host) in nlm_bind_host() argument
424 host->h_name, host->h_addrbuf); in nlm_bind_host()
427 mutex_lock(&host->h_mutex); in nlm_bind_host()
432 if ((clnt = host->h_rpcclnt) != NULL) { in nlm_bind_host()
433 if (time_after_eq(jiffies, host->h_nextrebind)) { in nlm_bind_host()
435 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_bind_host()
437 host->h_nextrebind - jiffies); in nlm_bind_host()
448 .net = host->net, in nlm_bind_host()
449 .protocol = host->h_proto, in nlm_bind_host()
450 .address = nlm_addr(host), in nlm_bind_host()
451 .addrsize = host->h_addrlen, in nlm_bind_host()
453 .servername = host->h_name, in nlm_bind_host()
455 .version = host->h_version, in nlm_bind_host()
466 if (!host->h_server) in nlm_bind_host()
468 if (host->h_noresvport) in nlm_bind_host()
470 if (host->h_srcaddrlen) in nlm_bind_host()
471 args.saddress = nlm_srcaddr(host); in nlm_bind_host()
475 host->h_rpcclnt = clnt; in nlm_bind_host()
477 printk("lockd: couldn't create RPC handle for %s\n", host->h_name); in nlm_bind_host()
482 mutex_unlock(&host->h_mutex); in nlm_bind_host()
490 nlm_rebind_host(struct nlm_host *host) in nlm_rebind_host() argument
492 dprintk("lockd: rebind host %s\n", host->h_name); in nlm_rebind_host()
493 if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) { in nlm_rebind_host()
494 rpc_force_rebind(host->h_rpcclnt); in nlm_rebind_host()
495 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_rebind_host()
502 struct nlm_host * nlm_get_host(struct nlm_host *host) in nlm_get_host() argument
504 if (host) { in nlm_get_host()
505 dprintk("lockd: get host %s\n", host->h_name); in nlm_get_host()
506 atomic_inc(&host->h_count); in nlm_get_host()
507 host->h_expires = jiffies + NLM_HOST_EXPIRE; in nlm_get_host()
509 return host; in nlm_get_host()
516 struct nlm_host *host; in next_host_state() local
520 for_each_host(host, chain, cache) { in next_host_state()
521 if (host->h_nsmhandle == nsm in next_host_state()
522 && host->h_nsmstate != info->state) { in next_host_state()
523 host->h_nsmstate = info->state; in next_host_state()
524 host->h_state++; in next_host_state()
526 nlm_get_host(host); in next_host_state()
528 return host; in next_host_state()
547 struct nlm_host *host; in nlm_host_rebooted() local
558 while ((host = next_host_state(nlm_server_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
559 nlmsvc_free_host_resources(host); in nlm_host_rebooted()
560 nlmsvc_release_host(host); in nlm_host_rebooted()
562 while ((host = next_host_state(nlm_client_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
563 nlmclnt_recovery(host); in nlm_host_rebooted()
564 nlmclnt_release_host(host); in nlm_host_rebooted()
573 struct nlm_host *host; in nlm_complain_hosts() local
589 for_each_host(host, chain, nlm_server_hosts) { in nlm_complain_hosts()
590 if (net && host->net != net) in nlm_complain_hosts()
593 host->h_name, atomic_read(&host->h_count), in nlm_complain_hosts()
594 host->h_inuse, host->h_expires, host->net); in nlm_complain_hosts()
602 struct nlm_host *host; in nlm_shutdown_hosts_net() local
608 for_each_host(host, chain, nlm_server_hosts) { in nlm_shutdown_hosts_net()
609 if (net && host->net != net) in nlm_shutdown_hosts_net()
611 host->h_expires = jiffies - 1; in nlm_shutdown_hosts_net()
612 if (host->h_rpcclnt) { in nlm_shutdown_hosts_net()
613 rpc_shutdown_client(host->h_rpcclnt); in nlm_shutdown_hosts_net()
614 host->h_rpcclnt = NULL; in nlm_shutdown_hosts_net()
646 struct nlm_host *host; in nlm_gc_hosts() local
649 for_each_host(host, chain, nlm_server_hosts) { in nlm_gc_hosts()
650 if (net && host->net != net) in nlm_gc_hosts()
652 host->h_inuse = 0; in nlm_gc_hosts()
658 for_each_host_safe(host, next, chain, nlm_server_hosts) { in nlm_gc_hosts()
659 if (net && host->net != net) in nlm_gc_hosts()
661 if (atomic_read(&host->h_count) || host->h_inuse in nlm_gc_hosts()
662 || time_before(jiffies, host->h_expires)) { in nlm_gc_hosts()
665 host->h_name, atomic_read(&host->h_count), in nlm_gc_hosts()
666 host->h_inuse, host->h_expires, host->net); in nlm_gc_hosts()
669 nlm_destroy_host_locked(host); in nlm_gc_hosts()