• Home
  • Raw
  • Download

Lines Matching full:host

3  * linux/fs/lockd/host.c
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()
198 * nlmclnt_lookup_host - Find an NLM host handle matching a remote server
208 * If one doesn't already exist in the host cache, a new handle is
231 struct nlm_host *host; in nlmclnt_lookup_host() local
235 dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__, in nlmclnt_lookup_host()
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()
258 dprintk("lockd: %s found host %s (%s)\n", __func__, 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()
271 dprintk("lockd: %s created host %s (%s)\n", __func__, in nlmclnt_lookup_host()
272 host->h_name, host->h_addrbuf); in nlmclnt_lookup_host()
276 return host; in nlmclnt_lookup_host()
281 * @host: nlm_host to release
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_mutex_lock(&host->h_count, &nlm_host_mutex)) { 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()
298 nlm_destroy_host_locked(host); in nlmclnt_release_host()
304 * nlmsvc_lookup_host - Find an NLM host handle matching a remote client
306 * @hostname: name of client host
311 * NLM request. If one doesn't already exist in the host cache, a
326 struct nlm_host *host = NULL; in nlmsvc_lookup_host() local
343 dprintk("lockd: %s(host='%.*s', vers=%u, proto=%s)\n", __func__, in nlmsvc_lookup_host()
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()
375 dprintk("lockd: %s found host %s (%s)\n", 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()
390 refcount_inc(&host->h_count); in nlmsvc_lookup_host()
392 dprintk("lockd: %s created host %s (%s)\n", in nlmsvc_lookup_host()
393 __func__, host->h_name, host->h_addrbuf); in nlmsvc_lookup_host()
397 return host; in nlmsvc_lookup_host()
402 * @host: nlm_host to release
404 * Host is destroyed later in nlm_gc_host().
406 void nlmsvc_release_host(struct nlm_host *host) in nlmsvc_release_host() argument
408 if (host == NULL) in nlmsvc_release_host()
411 dprintk("lockd: release server host %s\n", host->h_name); in nlmsvc_release_host()
413 WARN_ON_ONCE(!host->h_server); in nlmsvc_release_host()
414 refcount_dec(&host->h_count); in nlmsvc_release_host()
421 nlm_bind_host(struct nlm_host *host) in nlm_bind_host() argument
426 host->h_name, host->h_addrbuf); in nlm_bind_host()
428 /* Lock host handle */ in nlm_bind_host()
429 mutex_lock(&host->h_mutex); in nlm_bind_host()
434 if ((clnt = host->h_rpcclnt) != NULL) { in nlm_bind_host()
435 if (time_after_eq(jiffies, host->h_nextrebind)) { in nlm_bind_host()
437 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_bind_host()
439 host->h_nextrebind - jiffies); in nlm_bind_host()
450 .net = host->net, in nlm_bind_host()
451 .protocol = host->h_proto, in nlm_bind_host()
452 .address = nlm_addr(host), in nlm_bind_host()
453 .addrsize = host->h_addrlen, in nlm_bind_host()
455 .servername = host->h_name, in nlm_bind_host()
457 .version = host->h_version, in nlm_bind_host()
468 if (!host->h_server) in nlm_bind_host()
470 if (host->h_noresvport) in nlm_bind_host()
472 if (host->h_srcaddrlen) in nlm_bind_host()
473 args.saddress = nlm_srcaddr(host); in nlm_bind_host()
477 host->h_rpcclnt = clnt; in nlm_bind_host()
479 printk("lockd: couldn't create RPC handle for %s\n", host->h_name); in nlm_bind_host()
484 mutex_unlock(&host->h_mutex); in nlm_bind_host()
492 nlm_rebind_host(struct nlm_host *host) in nlm_rebind_host() argument
494 dprintk("lockd: rebind host %s\n", host->h_name); in nlm_rebind_host()
495 if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) { in nlm_rebind_host()
496 rpc_force_rebind(host->h_rpcclnt); in nlm_rebind_host()
497 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_rebind_host()
502 * Increment NLM host count
504 struct nlm_host * nlm_get_host(struct nlm_host *host) in nlm_get_host() argument
506 if (host) { in nlm_get_host()
507 dprintk("lockd: get host %s\n", host->h_name); in nlm_get_host()
508 refcount_inc(&host->h_count); in nlm_get_host()
509 host->h_expires = jiffies + NLM_HOST_EXPIRE; in nlm_get_host()
511 return host; in nlm_get_host()
518 struct nlm_host *host; in next_host_state() local
522 for_each_host(host, chain, cache) { in next_host_state()
523 if (host->h_nsmhandle == nsm in next_host_state()
524 && host->h_nsmstate != info->state) { in next_host_state()
525 host->h_nsmstate = info->state; in next_host_state()
526 host->h_state++; in next_host_state()
528 nlm_get_host(host); in next_host_state()
530 return host; in next_host_state()
539 * nlm_host_rebooted - Release all resources held by rebooted host
543 * We were notified that the specified host has rebooted. Release
549 struct nlm_host *host; in nlm_host_rebooted() local
556 * We run the loop repeatedly, because we drop the host table in nlm_host_rebooted()
558 * To avoid processing a host several times, we match the nsmstate. in nlm_host_rebooted()
560 while ((host = next_host_state(nlm_server_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
561 nlmsvc_free_host_resources(host); in nlm_host_rebooted()
562 nlmsvc_release_host(host); in nlm_host_rebooted()
564 while ((host = next_host_state(nlm_client_hosts, nsm, info)) != NULL) { in nlm_host_rebooted()
565 nlmclnt_recovery(host); in nlm_host_rebooted()
566 nlmclnt_release_host(host); in nlm_host_rebooted()
575 struct nlm_host *host; in nlm_complain_hosts() local
582 pr_warn("lockd: couldn't shutdown host module for net %x!\n", in nlm_complain_hosts()
589 printk(KERN_WARNING "lockd: couldn't shutdown host module!\n"); in nlm_complain_hosts()
593 for_each_host(host, chain, nlm_server_hosts) { in nlm_complain_hosts()
594 if (net && host->net != net) in nlm_complain_hosts()
597 host->h_name, refcount_read(&host->h_count), in nlm_complain_hosts()
598 host->h_inuse, host->h_expires, host->net->ns.inum); in nlm_complain_hosts()
606 struct nlm_host *host; in nlm_shutdown_hosts_net() local
613 for_each_host(host, chain, nlm_server_hosts) { in nlm_shutdown_hosts_net()
614 if (net && host->net != net) in nlm_shutdown_hosts_net()
616 host->h_expires = jiffies - 1; in nlm_shutdown_hosts_net()
617 if (host->h_rpcclnt) { in nlm_shutdown_hosts_net()
618 rpc_shutdown_client(host->h_rpcclnt); in nlm_shutdown_hosts_net()
619 host->h_rpcclnt = NULL; in nlm_shutdown_hosts_net()
636 dprintk("lockd: shutting down host module\n"); in nlm_shutdown_hosts()
650 struct nlm_host *host; in nlm_gc_hosts() local
652 dprintk("lockd: host garbage collection for net %x\n", in nlm_gc_hosts()
654 for_each_host(host, chain, nlm_server_hosts) { in nlm_gc_hosts()
655 if (net && host->net != net) in nlm_gc_hosts()
657 host->h_inuse = 0; in nlm_gc_hosts()
663 for_each_host_safe(host, next, chain, nlm_server_hosts) { in nlm_gc_hosts()
664 if (net && host->net != net) in nlm_gc_hosts()
666 if (host->h_inuse || time_before(jiffies, host->h_expires)) { in nlm_gc_hosts()
669 host->h_name, refcount_read(&host->h_count), in nlm_gc_hosts()
670 host->h_inuse, host->h_expires, in nlm_gc_hosts()
671 host->net->ns.inum); in nlm_gc_hosts()
674 if (refcount_dec_if_one(&host->h_count)) in nlm_gc_hosts()
675 nlm_destroy_host_locked(host); in nlm_gc_hosts()