Lines Matching +full:host +full:- +full:wake

1 // SPDX-License-Identifier: GPL-2.0-only
39 * nlmclnt_init - Set up per-NFS mount point lockd data structures
47 struct nlm_host *host; in nlmclnt_init() local
48 u32 nlm_version = (nlm_init->nfs_version == 2) ? 1 : 4; in nlmclnt_init()
51 status = lockd_up(nlm_init->net, nlm_init->cred); in nlmclnt_init()
55 host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen, in nlmclnt_init()
56 nlm_init->protocol, nlm_version, in nlmclnt_init()
57 nlm_init->hostname, nlm_init->noresvport, in nlmclnt_init()
58 nlm_init->net, nlm_init->cred); in nlmclnt_init()
59 if (host == NULL) in nlmclnt_init()
61 if (host->h_rpcclnt == NULL && nlm_bind_host(host) == NULL) in nlmclnt_init()
64 host->h_nlmclnt_ops = nlm_init->nlmclnt_ops; in nlmclnt_init()
65 return host; in nlmclnt_init()
67 nlmclnt_release_host(host); in nlmclnt_init()
69 lockd_down(nlm_init->net); in nlmclnt_init()
70 return ERR_PTR(-ENOLCK); in nlmclnt_init()
75 * nlmclnt_done - Release resources allocated by nlmclnt_init()
76 * @host: nlm_host structure reserved by nlmclnt_init()
79 void nlmclnt_done(struct nlm_host *host) in nlmclnt_done() argument
81 struct net *net = host->net; in nlmclnt_done()
83 nlmclnt_release_host(host); in nlmclnt_done()
88 void nlmclnt_prepare_block(struct nlm_wait *block, struct nlm_host *host, struct file_lock *fl) in nlmclnt_prepare_block() argument
90 block->b_host = host; in nlmclnt_prepare_block()
91 block->b_lock = fl; in nlmclnt_prepare_block()
92 init_waitqueue_head(&block->b_wait); in nlmclnt_prepare_block()
93 block->b_status = nlm_lck_blocked; in nlmclnt_prepare_block()
96 struct rpc_clnt *nlmclnt_rpc_clnt(struct nlm_host *host) in nlmclnt_rpc_clnt() argument
98 return host->h_rpcclnt; in nlmclnt_rpc_clnt()
108 list_add(&block->b_list, &nlm_blocked); in nlmclnt_queue_block()
120 list_del(&block->b_list); in nlmclnt_dequeue_block()
121 status = block->b_status; in nlmclnt_dequeue_block()
137 return -EAGAIN; in nlmclnt_wait()
147 ret = wait_event_interruptible_timeout(block->b_wait, in nlmclnt_wait()
148 block->b_status != nlm_lck_blocked, in nlmclnt_wait()
151 return -ERESTARTSYS; in nlmclnt_wait()
153 if (block->b_status == nlm_lck_denied_grace_period) in nlmclnt_wait()
154 block->b_status = nlm_lck_blocked; in nlmclnt_wait()
163 const struct file_lock *fl = &lock->fl; in nlmclnt_grant()
164 const struct nfs_fh *fh = &lock->fh; in nlmclnt_grant()
174 struct file_lock *fl_blocked = block->b_lock; in nlmclnt_grant()
176 if (fl_blocked->fl_start != fl->fl_start) in nlmclnt_grant()
178 if (fl_blocked->fl_end != fl->fl_end) in nlmclnt_grant()
181 * Careful! The NLM server will return the 32-bit "pid" that in nlmclnt_grant()
184 if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid) in nlmclnt_grant()
186 if (!rpc_cmp_addr(nlm_addr(block->b_host), addr)) in nlmclnt_grant()
188 if (nfs_compare_fh(NFS_FH(file_inode(fl_blocked->c.flc_file)), fh) != 0) in nlmclnt_grant()
191 * and wake up the caller in nlmclnt_grant()
193 block->b_status = nlm_granted; in nlmclnt_grant()
194 wake_up(&block->b_wait); in nlmclnt_grant()
208 * Reclaim all locks on server host. We do this by spawning a separate
212 nlmclnt_recovery(struct nlm_host *host) in nlmclnt_recovery() argument
216 if (!host->h_reclaiming++) { in nlmclnt_recovery()
217 nlm_get_host(host); in nlmclnt_recovery()
218 task = kthread_run(reclaimer, host, "%s-reclaim", host->h_name); in nlmclnt_recovery()
222 "(%ld)\n", host->h_name, PTR_ERR(task)); in nlmclnt_recovery()
229 struct nlm_host *host = (struct nlm_host *) ptr; in reclaimer() local
234 struct net *net = host->net; in reclaimer()
242 down_write(&host->h_rwsem); in reclaimer()
245 dprintk("lockd: reclaiming locks for host %s\n", host->h_name); in reclaimer()
248 nsmstate = host->h_nsmstate; in reclaimer()
250 /* Force a portmap getport - the peer's lockd will in reclaimer()
253 host->h_nextrebind = jiffies; in reclaimer()
254 nlm_rebind_host(host); in reclaimer()
257 list_splice_init(&host->h_granted, &host->h_reclaim); in reclaimer()
258 list_for_each_entry_safe(fl, next, &host->h_reclaim, fl_u.nfs_fl.list) { in reclaimer()
259 list_del_init(&fl->fl_u.nfs_fl.list); in reclaimer()
265 * reclaimer thread is spawned for this host. in reclaimer()
269 if (nlmclnt_reclaim(host, fl, req) != 0) in reclaimer()
271 list_add_tail(&fl->fl_u.nfs_fl.list, &host->h_granted); in reclaimer()
272 if (host->h_nsmstate != nsmstate) { in reclaimer()
278 host->h_reclaiming = 0; in reclaimer()
279 up_write(&host->h_rwsem); in reclaimer()
280 dprintk("NLM: done reclaiming locks for host %s\n", host->h_name); in reclaimer()
282 /* Now, wake up all processes that sleep on a blocked lock */ in reclaimer()
285 if (block->b_host == host) { in reclaimer()
286 block->b_status = nlm_lck_denied_grace_period; in reclaimer()
287 wake_up(&block->b_wait); in reclaimer()
292 /* Release host handle after use */ in reclaimer()
293 nlmclnt_release_host(host); in reclaimer()