Lines Matching refs:host

62 nlm_match_host(struct nlm_host *host, struct svc_client *clnt,  in nlm_match_host()  argument
66 return host->h_exportent == clnt; in nlm_match_host()
67 return nlm_cmp_addr(&host->h_addr, sin); in nlm_match_host()
77 struct nlm_host *host, **hp; in nlm_lookup_host() local
100 for (hp = &nlm_hosts[hash]; (host = *hp); hp = &host->h_next) { in nlm_lookup_host()
101 if (proto && host->h_proto != proto) in nlm_lookup_host()
103 if (version && host->h_version != version) in nlm_lookup_host()
106 if (nlm_match_host(host, clnt, sin)) { in nlm_lookup_host()
108 *hp = host->h_next; in nlm_lookup_host()
109 host->h_next = nlm_hosts[hash]; in nlm_lookup_host()
110 nlm_hosts[hash] = host; in nlm_lookup_host()
112 nlm_get_host(host); in nlm_lookup_host()
114 return host; in nlm_lookup_host()
125 if (!(host = (struct nlm_host *) kmalloc(sizeof(*host), GFP_KERNEL))) in nlm_lookup_host()
127 memset(host, 0, sizeof(*host)); in nlm_lookup_host()
130 sprintf(host->h_name, "%d.%d.%d.%d", in nlm_lookup_host()
136 host->h_addr = *sin; in nlm_lookup_host()
137 host->h_addr.sin_port = 0; /* ouch! */ in nlm_lookup_host()
138 host->h_version = version; in nlm_lookup_host()
139 host->h_proto = proto; in nlm_lookup_host()
140 host->h_authflavor = RPC_AUTH_UNIX; in nlm_lookup_host()
141 host->h_rpcclnt = NULL; in nlm_lookup_host()
142 init_MUTEX(&host->h_sema); in nlm_lookup_host()
143 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_lookup_host()
144 host->h_expires = jiffies + NLM_HOST_EXPIRE; in nlm_lookup_host()
145 host->h_count = 1; in nlm_lookup_host()
146 init_waitqueue_head(&host->h_gracewait); in nlm_lookup_host()
147 host->h_state = 0; /* pseudo NSM state */ in nlm_lookup_host()
148 host->h_nsmstate = 0; /* real NSM state */ in nlm_lookup_host()
149 host->h_exportent = clnt; in nlm_lookup_host()
151 host->h_next = nlm_hosts[hash]; in nlm_lookup_host()
152 nlm_hosts[hash] = host; in nlm_lookup_host()
159 return host; in nlm_lookup_host()
166 nlm_bind_host(struct nlm_host *host) in nlm_bind_host() argument
172 (unsigned)ntohl(host->h_addr.sin_addr.s_addr)); in nlm_bind_host()
175 down(&host->h_sema); in nlm_bind_host()
181 if ((clnt = host->h_rpcclnt) != NULL) { in nlm_bind_host()
183 if (!xprt->stream && time_after_eq(jiffies, host->h_nextrebind)) { in nlm_bind_host()
185 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_bind_host()
187 host->h_nextrebind - jiffies); in nlm_bind_host()
190 xprt = xprt_create_proto(host->h_proto, &host->h_addr, NULL); in nlm_bind_host()
196 clnt = rpc_create_client(xprt, host->h_name, &nlm_program, in nlm_bind_host()
197 host->h_version, host->h_authflavor); in nlm_bind_host()
206 host->h_rpcclnt = clnt; in nlm_bind_host()
209 up(&host->h_sema); in nlm_bind_host()
213 printk("lockd: couldn't create RPC handle for %s\n", host->h_name); in nlm_bind_host()
214 up(&host->h_sema); in nlm_bind_host()
222 nlm_rebind_host(struct nlm_host *host) in nlm_rebind_host() argument
224 dprintk("lockd: rebind host %s\n", host->h_name); in nlm_rebind_host()
225 if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) { in nlm_rebind_host()
226 host->h_rpcclnt->cl_port = 0; in nlm_rebind_host()
227 host->h_nextrebind = jiffies + NLM_HOST_REBIND; in nlm_rebind_host()
234 struct nlm_host * nlm_get_host(struct nlm_host *host) in nlm_get_host() argument
236 if (host) { in nlm_get_host()
237 dprintk("lockd: get host %s\n", host->h_name); in nlm_get_host()
238 host->h_count ++; in nlm_get_host()
239 host->h_expires = jiffies + NLM_HOST_EXPIRE; in nlm_get_host()
241 return host; in nlm_get_host()
247 void nlm_release_host(struct nlm_host *host) in nlm_release_host() argument
249 if (host && host->h_count) { in nlm_release_host()
250 dprintk("lockd: release host %s\n", host->h_name); in nlm_release_host()
251 host->h_count --; in nlm_release_host()
262 struct nlm_host *host; in nlm_shutdown_hosts() local
271 for (host = nlm_hosts[i]; host; host = host->h_next) in nlm_shutdown_hosts()
272 host->h_expires = 0; in nlm_shutdown_hosts()
284 for (host = nlm_hosts[i]; host; host = host->h_next) { in nlm_shutdown_hosts()
286 host->h_name, host->h_count, in nlm_shutdown_hosts()
287 host->h_inuse, host->h_expires); in nlm_shutdown_hosts()
301 struct nlm_host **q, *host; in nlm_gc_hosts() local
307 for (host = nlm_hosts[i]; host; host = host->h_next) in nlm_gc_hosts()
308 host->h_inuse = 0; in nlm_gc_hosts()
316 while ((host = *q) != NULL) { in nlm_gc_hosts()
317 if (host->h_count || host->h_inuse in nlm_gc_hosts()
318 || time_before(jiffies, host->h_expires)) { in nlm_gc_hosts()
319 q = &host->h_next; in nlm_gc_hosts()
322 dprintk("lockd: delete host %s\n", host->h_name); in nlm_gc_hosts()
323 *q = host->h_next; in nlm_gc_hosts()
325 if (host->h_monitored && !host->h_killed) in nlm_gc_hosts()
326 nsm_unmonitor(host); in nlm_gc_hosts()
327 if ((clnt = host->h_rpcclnt) != NULL) { in nlm_gc_hosts()
333 rpc_destroy_client(host->h_rpcclnt); in nlm_gc_hosts()
336 kfree(host); in nlm_gc_hosts()