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()
166 return host; in nlm_alloc_host()
174 static void nlm_destroy_host_locked(struct nlm_host *host) in nlm_destroy_host_locked() argument
177 struct lockd_net *ln = net_generic(host->net, lockd_net_id); in nlm_destroy_host_locked()
179 dprintk("lockd: destroy host %s\n", host->h_name); in nlm_destroy_host_locked()
181 hlist_del_init(&host->h_hash); in nlm_destroy_host_locked()
183 nsm_unmonitor(host); in nlm_destroy_host_locked()
184 nsm_release(host->h_nsmhandle); in nlm_destroy_host_locked()
186 clnt = host->h_rpcclnt; in nlm_destroy_host_locked()
189 kfree(host); in nlm_destroy_host_locked()
229 struct nlm_host *host; in nlmclnt_lookup_host() local
240 hlist_for_each_entry(host, chain, h_hash) { in nlmclnt_lookup_host()
241 if (host->net != net) in nlmclnt_lookup_host()
243 if (!rpc_cmp_addr(nlm_addr(host), sap)) in nlmclnt_lookup_host()
248 nsm = host->h_nsmhandle; in nlmclnt_lookup_host()
250 if (host->h_proto != protocol) in nlmclnt_lookup_host()
252 if (host->h_version != version) in nlmclnt_lookup_host()
255 nlm_get_host(host); in nlmclnt_lookup_host()
257 host->h_name, host->h_addrbuf); in nlmclnt_lookup_host()
261 host = nlm_alloc_host(&ni, nsm); in nlmclnt_lookup_host()
262 if (unlikely(host == NULL)) in nlmclnt_lookup_host()
265 hlist_add_head(&host->h_hash, chain); in nlmclnt_lookup_host()
270 host->h_name, host->h_addrbuf); in nlmclnt_lookup_host()
274 return host; in nlmclnt_lookup_host()
282 void nlmclnt_release_host(struct nlm_host *host) in nlmclnt_release_host() argument
284 if (host == NULL) in nlmclnt_release_host()
287 dprintk("lockd: release client host %s\n", host->h_name); in nlmclnt_release_host()
289 WARN_ON_ONCE(host->h_server); in nlmclnt_release_host()
291 if (atomic_dec_and_test(&host->h_count)) { in nlmclnt_release_host()
292 WARN_ON_ONCE(!list_empty(&host->h_lockowners)); in nlmclnt_release_host()
293 WARN_ON_ONCE(!list_empty(&host->h_granted)); in nlmclnt_release_host()
294 WARN_ON_ONCE(!list_empty(&host->h_reclaim)); in nlmclnt_release_host()
297 nlm_destroy_host_locked(host); in nlmclnt_release_host()
325 struct nlm_host *host = NULL; in nlmsvc_lookup_host() local
352 hlist_for_each_entry(host, chain, h_hash) { in nlmsvc_lookup_host()
353 if (host->net != net) in nlmsvc_lookup_host()
355 if (!rpc_cmp_addr(nlm_addr(host), ni.sap)) in nlmsvc_lookup_host()
360 nsm = host->h_nsmhandle; in nlmsvc_lookup_host()
362 if (host->h_proto != ni.protocol) in nlmsvc_lookup_host()
364 if (host->h_version != ni.version) in nlmsvc_lookup_host()
366 if (!rpc_cmp_addr(nlm_srcaddr(host), src_sap)) in nlmsvc_lookup_host()
370 hlist_del(&host->h_hash); in nlmsvc_lookup_host()
371 hlist_add_head(&host->h_hash, chain); in nlmsvc_lookup_host()
373 nlm_get_host(host); in nlmsvc_lookup_host()
375 __func__, host->h_name, host->h_addrbuf); in nlmsvc_lookup_host()
379 host = nlm_alloc_host(&ni, nsm); in nlmsvc_lookup_host()
380 if (unlikely(host == NULL)) in nlmsvc_lookup_host()
383 memcpy(nlm_srcaddr(host), src_sap, src_len); in nlmsvc_lookup_host()
384 host->h_srcaddrlen = src_len; in nlmsvc_lookup_host()
385 hlist_add_head(&host->h_hash, chain); in nlmsvc_lookup_host()
390 __func__, host->h_name, host->h_addrbuf); in nlmsvc_lookup_host()
394 return host; in nlmsvc_lookup_host()
403 void nlmsvc_release_host(struct nlm_host *host) in nlmsvc_release_host() argument
405 if (host == NULL) in nlmsvc_release_host()
408 dprintk("lockd: release server host %s\n", host->h_name); in nlmsvc_release_host()
410 WARN_ON_ONCE(!host->h_server); in nlmsvc_release_host()
411 atomic_dec(&host->h_count); in nlmsvc_release_host()
418 nlm_bind_host(struct nlm_host *host) in nlm_bind_host() argument
423 host->h_name, host->h_addrbuf); in nlm_bind_host()
426 mutex_lock(&host->h_mutex); in nlm_bind_host()
431 if ((clnt = host->h_rpcclnt) != NULL) { in nlm_bind_host()
432 if (time_after_eq(jiffies, host->h_nextrebind)) { in nlm_bind_host()
434 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_bind_host()
436 host->h_nextrebind - jiffies); in nlm_bind_host()
447 .net = host->net, in nlm_bind_host()
448 .protocol = host->h_proto, in nlm_bind_host()
449 .address = nlm_addr(host), in nlm_bind_host()
450 .addrsize = host->h_addrlen, in nlm_bind_host()
452 .servername = host->h_name, in nlm_bind_host()
454 .version = host->h_version, in nlm_bind_host()
465 if (!host->h_server) in nlm_bind_host()
467 if (host->h_noresvport) in nlm_bind_host()
469 if (host->h_srcaddrlen) in nlm_bind_host()
470 args.saddress = nlm_srcaddr(host); in nlm_bind_host()
474 host->h_rpcclnt = clnt; in nlm_bind_host()
476 printk("lockd: couldn't create RPC handle for %s\n", host->h_name); in nlm_bind_host()
481 mutex_unlock(&host->h_mutex); in nlm_bind_host()
489 nlm_rebind_host(struct nlm_host *host) in nlm_rebind_host() argument
491 dprintk("lockd: rebind host %s\n", host->h_name); in nlm_rebind_host()
492 if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) { in nlm_rebind_host()
493 rpc_force_rebind(host->h_rpcclnt); in nlm_rebind_host()
494 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_rebind_host()
501 struct nlm_host * nlm_get_host(struct nlm_host *host) in nlm_get_host() argument
503 if (host) { in nlm_get_host()
504 dprintk("lockd: get host %s\n", host->h_name); in nlm_get_host()
505 atomic_inc(&host->h_count); in nlm_get_host()
506 host->h_expires = jiffies + NLM_HOST_EXPIRE; in nlm_get_host()
508 return host; in nlm_get_host()
515 struct nlm_host *host; in next_host_state() local
519 for_each_host(host, chain, cache) { in next_host_state()
520 if (host->h_nsmhandle == nsm in next_host_state()
521 && host->h_nsmstate != info->state) { in next_host_state()
522 host->h_nsmstate = info->state; in next_host_state()
523 host->h_state++; in next_host_state()
525 nlm_get_host(host); in next_host_state()
527 return host; in next_host_state()
545 struct nlm_host *host; in nlm_host_rebooted() local
556 while ((host = next_host_state(nlm_server_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
557 nlmsvc_free_host_resources(host); in nlm_host_rebooted()
558 nlmsvc_release_host(host); in nlm_host_rebooted()
560 while ((host = next_host_state(nlm_client_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
561 nlmclnt_recovery(host); in nlm_host_rebooted()
562 nlmclnt_release_host(host); in nlm_host_rebooted()
571 struct nlm_host *host; in nlm_complain_hosts() local
587 for_each_host(host, chain, nlm_server_hosts) { in nlm_complain_hosts()
588 if (net && host->net != net) in nlm_complain_hosts()
591 host->h_name, atomic_read(&host->h_count), in nlm_complain_hosts()
592 host->h_inuse, host->h_expires, host->net); in nlm_complain_hosts()
600 struct nlm_host *host; in nlm_shutdown_hosts_net() local
606 for_each_host(host, chain, nlm_server_hosts) { in nlm_shutdown_hosts_net()
607 if (net && host->net != net) in nlm_shutdown_hosts_net()
609 host->h_expires = jiffies - 1; in nlm_shutdown_hosts_net()
610 if (host->h_rpcclnt) { in nlm_shutdown_hosts_net()
611 rpc_shutdown_client(host->h_rpcclnt); in nlm_shutdown_hosts_net()
612 host->h_rpcclnt = NULL; in nlm_shutdown_hosts_net()
644 struct nlm_host *host; in nlm_gc_hosts() local
647 for_each_host(host, chain, nlm_server_hosts) { in nlm_gc_hosts()
648 if (net && host->net != net) in nlm_gc_hosts()
650 host->h_inuse = 0; in nlm_gc_hosts()
656 for_each_host_safe(host, next, chain, nlm_server_hosts) { in nlm_gc_hosts()
657 if (net && host->net != net) in nlm_gc_hosts()
659 if (atomic_read(&host->h_count) || host->h_inuse in nlm_gc_hosts()
660 || time_before(jiffies, host->h_expires)) { in nlm_gc_hosts()
663 host->h_name, atomic_read(&host->h_count), in nlm_gc_hosts()
664 host->h_inuse, host->h_expires, host->net); in nlm_gc_hosts()
667 nlm_destroy_host_locked(host); in nlm_gc_hosts()