Lines Matching +full:host +full:- +full:wake
1 // SPDX-License-Identifier: GPL-2.0-only
48 * nlmclnt_init - Set up per-NFS mount point lockd data structures
56 struct nlm_host *host; in nlmclnt_init() local
57 u32 nlm_version = (nlm_init->nfs_version == 2) ? 1 : 4; in nlmclnt_init()
60 status = lockd_up(nlm_init->net, nlm_init->cred); in nlmclnt_init()
64 host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen, in nlmclnt_init()
65 nlm_init->protocol, nlm_version, in nlmclnt_init()
66 nlm_init->hostname, nlm_init->noresvport, in nlmclnt_init()
67 nlm_init->net, nlm_init->cred); in nlmclnt_init()
68 if (host == NULL) in nlmclnt_init()
70 if (host->h_rpcclnt == NULL && nlm_bind_host(host) == NULL) in nlmclnt_init()
73 host->h_nlmclnt_ops = nlm_init->nlmclnt_ops; in nlmclnt_init()
74 return host; in nlmclnt_init()
76 nlmclnt_release_host(host); in nlmclnt_init()
78 lockd_down(nlm_init->net); in nlmclnt_init()
79 return ERR_PTR(-ENOLCK); in nlmclnt_init()
84 * nlmclnt_done - Release resources allocated by nlmclnt_init()
85 * @host: nlm_host structure reserved by nlmclnt_init()
88 void nlmclnt_done(struct nlm_host *host) in nlmclnt_done() argument
90 struct net *net = host->net; in nlmclnt_done()
92 nlmclnt_release_host(host); in nlmclnt_done()
100 struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *fl) in nlmclnt_prepare_block() argument
106 block->b_host = host; in nlmclnt_prepare_block()
107 block->b_lock = fl; in nlmclnt_prepare_block()
108 init_waitqueue_head(&block->b_wait); in nlmclnt_prepare_block()
109 block->b_status = nlm_lck_blocked; in nlmclnt_prepare_block()
112 list_add(&block->b_list, &nlm_blocked); in nlmclnt_prepare_block()
123 list_del(&block->b_list); in nlmclnt_finish_block()
139 return -EAGAIN; in nlmclnt_block()
149 ret = wait_event_interruptible_timeout(block->b_wait, in nlmclnt_block()
150 block->b_status != nlm_lck_blocked, in nlmclnt_block()
153 return -ERESTARTSYS; in nlmclnt_block()
155 if (block->b_status == nlm_lck_denied_grace_period) in nlmclnt_block()
156 block->b_status = nlm_lck_blocked; in nlmclnt_block()
157 req->a_res.status = block->b_status; in nlmclnt_block()
166 const struct file_lock *fl = &lock->fl; in nlmclnt_grant()
167 const struct nfs_fh *fh = &lock->fh; in nlmclnt_grant()
177 struct file_lock *fl_blocked = block->b_lock; in nlmclnt_grant()
179 if (fl_blocked->fl_start != fl->fl_start) in nlmclnt_grant()
181 if (fl_blocked->fl_end != fl->fl_end) in nlmclnt_grant()
184 * Careful! The NLM server will return the 32-bit "pid" that in nlmclnt_grant()
187 if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid) in nlmclnt_grant()
189 if (!rpc_cmp_addr(nlm_addr(block->b_host), addr)) in nlmclnt_grant()
191 if (nfs_compare_fh(NFS_FH(locks_inode(fl_blocked->fl_file)), fh) != 0) in nlmclnt_grant()
194 * and wake up the caller in nlmclnt_grant()
196 block->b_status = nlm_granted; in nlmclnt_grant()
197 wake_up(&block->b_wait); in nlmclnt_grant()
210 * Reclaim all locks on server host. We do this by spawning a separate
214 nlmclnt_recovery(struct nlm_host *host) in nlmclnt_recovery() argument
218 if (!host->h_reclaiming++) { in nlmclnt_recovery()
219 nlm_get_host(host); in nlmclnt_recovery()
220 task = kthread_run(reclaimer, host, "%s-reclaim", host->h_name); in nlmclnt_recovery()
224 "(%ld)\n", host->h_name, PTR_ERR(task)); in nlmclnt_recovery()
231 struct nlm_host *host = (struct nlm_host *) ptr; in reclaimer() local
236 struct net *net = host->net; in reclaimer()
244 down_write(&host->h_rwsem); in reclaimer()
247 dprintk("lockd: reclaiming locks for host %s\n", host->h_name); in reclaimer()
250 nsmstate = host->h_nsmstate; in reclaimer()
252 /* Force a portmap getport - the peer's lockd will in reclaimer()
255 host->h_nextrebind = jiffies; in reclaimer()
256 nlm_rebind_host(host); in reclaimer()
259 list_splice_init(&host->h_granted, &host->h_reclaim); in reclaimer()
260 list_for_each_entry_safe(fl, next, &host->h_reclaim, fl_u.nfs_fl.list) { in reclaimer()
261 list_del_init(&fl->fl_u.nfs_fl.list); in reclaimer()
267 * reclaimer thread is spawned for this host. in reclaimer()
271 if (nlmclnt_reclaim(host, fl, req) != 0) in reclaimer()
273 list_add_tail(&fl->fl_u.nfs_fl.list, &host->h_granted); in reclaimer()
274 if (host->h_nsmstate != nsmstate) { in reclaimer()
280 host->h_reclaiming = 0; in reclaimer()
281 up_write(&host->h_rwsem); in reclaimer()
282 dprintk("NLM: done reclaiming locks for host %s\n", host->h_name); in reclaimer()
284 /* Now, wake up all processes that sleep on a blocked lock */ in reclaimer()
287 if (block->b_host == host) { in reclaimer()
288 block->b_status = nlm_lck_denied_grace_period; in reclaimer()
289 wake_up(&block->b_wait); in reclaimer()
294 /* Release host handle after use */ in reclaimer()
295 nlmclnt_release_host(host); in reclaimer()