nlm.h revision 1.1.1.1.10.3 1 1.1.1.1.10.2 tls /* $NetBSD: nlm.h,v 1.1.1.1.10.3 2017/12/03 11:38:42 jdolecek Exp $ */
2 1.1.1.1.10.2 tls /*-
3 1.1.1.1.10.2 tls * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
4 1.1.1.1.10.2 tls * Authors: Doug Rabson <dfr (at) rabson.org>
5 1.1.1.1.10.2 tls * Developed with Red Inc: Alfred Perlstein <alfred (at) freebsd.org>
6 1.1.1.1.10.2 tls *
7 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
8 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
9 1.1.1.1.10.2 tls * are met:
10 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
11 1.1.1.1.10.2 tls * notice, this list of conditions and the following disclaimer.
12 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.1.1.10.2 tls * notice, this list of conditions and the following disclaimer in the
14 1.1.1.1.10.2 tls * documentation and/or other materials provided with the distribution.
15 1.1.1.1.10.2 tls *
16 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.1.1.1.10.2 tls * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1.1.1.10.2 tls * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1.1.1.10.2 tls * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.1.1.1.10.2 tls * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1.1.1.10.2 tls * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1.1.1.10.2 tls * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1.1.1.10.2 tls * SUCH DAMAGE.
27 1.1.1.1.10.2 tls *
28 1.1.1.1.10.2 tls * FreeBSD: head/sys/nlm/nlm.h 197840 2009-10-07 19:50:14Z zml
29 1.1.1.1.10.2 tls * $NetBSD: nlm.h,v 1.1.1.1.10.3 2017/12/03 11:38:42 jdolecek Exp $
30 1.1.1.1.10.2 tls */
31 1.1.1.1.10.2 tls
32 1.1.1.1.10.2 tls #ifndef _NLM_NLM_H_
33 1.1.1.1.10.2 tls #define _NLM_NLM_H_
34 1.1.1.1.10.2 tls
35 1.1.1.1.10.2 tls #ifdef _KERNEL
36 1.1.1.1.10.2 tls
37 1.1.1.1.10.2 tls #ifdef _SYS_MALLOC_H_
38 1.1.1.1.10.2 tls MALLOC_DECLARE(M_NLM);
39 1.1.1.1.10.2 tls #endif
40 1.1.1.1.10.2 tls
41 1.1.1.1.10.2 tls /*
42 1.1.1.1.10.2 tls * This value is added to host system IDs when recording NFS client
43 1.1.1.1.10.2 tls * locks in the local lock manager.
44 1.1.1.1.10.2 tls */
45 1.1.1.1.10.2 tls #define NLM_SYSID_CLIENT 0x1000000
46 1.1.1.1.10.2 tls
47 1.1.1.1.10.2 tls struct nlm_host;
48 1.1.1.1.10.2 tls struct vnode;
49 1.1.1.1.10.2 tls
50 1.1.1.1.10.2 tls extern struct timeval nlm_zero_tv;
51 1.1.1.1.10.2 tls extern int nlm_nsm_state;
52 1.1.1.1.10.2 tls
53 1.1.1.1.10.2 tls /*
54 1.1.1.1.10.2 tls * Make a struct netobj.
55 1.1.1.1.10.2 tls */
56 1.1.1.1.10.2 tls extern void nlm_make_netobj(struct netobj *dst, caddr_t srt,
57 1.1.1.1.10.2 tls size_t srcsize, struct malloc_type *type);
58 1.1.1.1.10.2 tls
59 1.1.1.1.10.2 tls /*
60 1.1.1.1.10.2 tls * Copy a struct netobj.
61 1.1.1.1.10.2 tls */
62 1.1.1.1.10.2 tls extern void nlm_copy_netobj(struct netobj *dst, struct netobj *src,
63 1.1.1.1.10.2 tls struct malloc_type *type);
64 1.1.1.1.10.2 tls
65 1.1.1.1.10.2 tls /*
66 1.1.1.1.10.2 tls * Search for an existing NLM host that matches the given name
67 1.1.1.1.10.2 tls * (typically the caller_name element of an nlm4_lock). If none is
68 1.1.1.1.10.2 tls * found, create a new host. If 'addr' is non-NULL, record the remote
69 1.1.1.1.10.2 tls * address of the host so that we can call it back for async
70 1.1.1.1.10.2 tls * responses. If 'vers' is greater than zero then record the NLM
71 1.1.1.1.10.2 tls * program version to use to communicate with this client. The host
72 1.1.1.1.10.2 tls * reference count is incremented - the caller must call
73 1.1.1.1.10.2 tls * nlm_host_release when it has finished using it.
74 1.1.1.1.10.2 tls */
75 1.1.1.1.10.2 tls extern struct nlm_host *nlm_find_host_by_name(const char *name,
76 1.1.1.1.10.2 tls const struct sockaddr *addr, rpcvers_t vers);
77 1.1.1.1.10.2 tls
78 1.1.1.1.10.2 tls /*
79 1.1.1.1.10.2 tls * Search for an existing NLM host that matches the given remote
80 1.1.1.1.10.2 tls * address. If none is found, create a new host with the requested
81 1.1.1.1.10.2 tls * address and remember 'vers' as the NLM protocol version to use for
82 1.1.1.1.10.2 tls * that host. The host reference count is incremented - the caller
83 1.1.1.1.10.2 tls * must call nlm_host_release when it has finished using it.
84 1.1.1.1.10.2 tls */
85 1.1.1.1.10.2 tls extern struct nlm_host *nlm_find_host_by_addr(const struct sockaddr *addr,
86 1.1.1.1.10.2 tls int vers);
87 1.1.1.1.10.2 tls
88 1.1.1.1.10.2 tls /*
89 1.1.1.1.10.2 tls * Register this NLM host with the local NSM so that we can be
90 1.1.1.1.10.2 tls * notified if it reboots.
91 1.1.1.1.10.2 tls */
92 1.1.1.1.10.2 tls extern void nlm_host_monitor(struct nlm_host *host, int state);
93 1.1.1.1.10.2 tls
94 1.1.1.1.10.2 tls /*
95 1.1.1.1.10.2 tls * Decrement the host reference count, freeing resources if the
96 1.1.1.1.10.2 tls * reference count reaches zero.
97 1.1.1.1.10.2 tls */
98 1.1.1.1.10.2 tls extern void nlm_host_release(struct nlm_host *host);
99 1.1.1.1.10.2 tls
100 1.1.1.1.10.2 tls /*
101 1.1.1.1.10.2 tls * Return an RPC client handle that can be used to talk to the NLM
102 1.1.1.1.10.2 tls * running on the given host.
103 1.1.1.1.10.2 tls */
104 1.1.1.1.10.2 tls extern CLIENT *nlm_host_get_rpc(struct nlm_host *host, bool_t isserver);
105 1.1.1.1.10.2 tls
106 1.1.1.1.10.2 tls /*
107 1.1.1.1.10.2 tls * Return the system ID for a host.
108 1.1.1.1.10.2 tls */
109 1.1.1.1.10.2 tls extern int nlm_host_get_sysid(struct nlm_host *host);
110 1.1.1.1.10.2 tls
111 1.1.1.1.10.2 tls /*
112 1.1.1.1.10.2 tls * Return the remote NSM state value for a host.
113 1.1.1.1.10.2 tls */
114 1.1.1.1.10.2 tls extern int nlm_host_get_state(struct nlm_host *host);
115 1.1.1.1.10.2 tls
116 1.1.1.1.10.2 tls /*
117 1.1.1.1.10.2 tls * When sending a blocking lock request, we need to track the request
118 1.1.1.1.10.2 tls * in our waiting lock list. We add an entry to the waiting list
119 1.1.1.1.10.2 tls * before we send the lock RPC so that we can cope with a granted
120 1.1.1.1.10.2 tls * message arriving at any time. Call this function before sending the
121 1.1.1.1.10.2 tls * lock rpc. If the lock succeeds, call nlm_deregister_wait_lock with
122 1.1.1.1.10.2 tls * the handle this function returns, otherwise nlm_wait_lock. Both
123 1.1.1.1.10.2 tls * will remove the entry from the waiting list.
124 1.1.1.1.10.2 tls */
125 1.1.1.1.10.2 tls extern void *nlm_register_wait_lock(struct nlm4_lock *lock, struct vnode *vp);
126 1.1.1.1.10.2 tls
127 1.1.1.1.10.2 tls /*
128 1.1.1.1.10.2 tls * Deregister a blocking lock request. Call this if the lock succeeded
129 1.1.1.1.10.2 tls * without blocking.
130 1.1.1.1.10.2 tls */
131 1.1.1.1.10.2 tls extern void nlm_deregister_wait_lock(void *handle);
132 1.1.1.1.10.2 tls
133 1.1.1.1.10.2 tls /*
134 1.1.1.1.10.2 tls * Wait for a granted callback for a blocked lock request, waiting at
135 1.1.1.1.10.2 tls * most timo ticks. If no granted message is received within the
136 1.1.1.1.10.2 tls * timeout, return EWOULDBLOCK. If a signal interrupted the wait,
137 1.1.1.1.10.2 tls * return EINTR - the caller must arrange to send a cancellation to
138 1.1.1.1.10.2 tls * the server. In both cases, the request is removed from the waiting
139 1.1.1.1.10.2 tls * list.
140 1.1.1.1.10.2 tls */
141 1.1.1.1.10.2 tls extern int nlm_wait_lock(void *handle, int timo);
142 1.1.1.1.10.2 tls
143 1.1.1.1.10.2 tls /*
144 1.1.1.1.10.2 tls * Cancel any pending waits for this vnode - called on forcible unmounts.
145 1.1.1.1.10.2 tls */
146 1.1.1.1.10.2 tls extern void nlm_cancel_wait(struct vnode *vp);
147 1.1.1.1.10.2 tls
148 1.1.1.1.10.2 tls /*
149 1.1.1.1.10.2 tls * Called when a host restarts.
150 1.1.1.1.10.2 tls */
151 1.1.1.1.10.2 tls extern void nlm_sm_notify(nlm_sm_status *argp);
152 1.1.1.1.10.2 tls
153 1.1.1.1.10.2 tls /*
154 1.1.1.1.10.2 tls * Implementation for lock testing RPCs. If the request was handled
155 1.1.1.1.10.2 tls * successfully and rpcp is non-NULL, *rpcp is set to an RPC client
156 1.1.1.1.10.2 tls * handle which can be used to send an async rpc reply. Returns zero
157 1.1.1.1.10.2 tls * if the request was handled, or a suitable unix error code
158 1.1.1.1.10.2 tls * otherwise.
159 1.1.1.1.10.2 tls */
160 1.1.1.1.10.2 tls extern int nlm_do_test(nlm4_testargs *argp, nlm4_testres *result,
161 1.1.1.1.10.2 tls struct svc_req *rqstp, CLIENT **rpcp);
162 1.1.1.1.10.2 tls
163 1.1.1.1.10.2 tls /*
164 1.1.1.1.10.2 tls * Implementation for lock setting RPCs. If the request was handled
165 1.1.1.1.10.2 tls * successfully and rpcp is non-NULL, *rpcp is set to an RPC client
166 1.1.1.1.10.2 tls * handle which can be used to send an async rpc reply. Returns zero
167 1.1.1.1.10.2 tls * if the request was handled, or a suitable unix error code
168 1.1.1.1.10.2 tls * otherwise.
169 1.1.1.1.10.2 tls */
170 1.1.1.1.10.2 tls extern int nlm_do_lock(nlm4_lockargs *argp, nlm4_res *result,
171 1.1.1.1.10.3 jdolecek struct svc_req *rqstp, bool_t monitor, CLIENT **rpcp);
172 1.1.1.1.10.2 tls
173 1.1.1.1.10.2 tls /*
174 1.1.1.1.10.2 tls * Implementation for cancelling a pending lock request. If the
175 1.1.1.1.10.2 tls * request was handled successfully and rpcp is non-NULL, *rpcp is set
176 1.1.1.1.10.2 tls * to an RPC client handle which can be used to send an async rpc
177 1.1.1.1.10.2 tls * reply. Returns zero if the request was handled, or a suitable unix
178 1.1.1.1.10.2 tls * error code otherwise.
179 1.1.1.1.10.2 tls */
180 1.1.1.1.10.2 tls extern int nlm_do_cancel(nlm4_cancargs *argp, nlm4_res *result,
181 1.1.1.1.10.2 tls struct svc_req *rqstp, CLIENT **rpcp);
182 1.1.1.1.10.2 tls
183 1.1.1.1.10.2 tls /*
184 1.1.1.1.10.2 tls * Implementation for unlocking RPCs. If the request was handled
185 1.1.1.1.10.2 tls * successfully and rpcp is non-NULL, *rpcp is set to an RPC client
186 1.1.1.1.10.2 tls * handle which can be used to send an async rpc reply. Returns zero
187 1.1.1.1.10.2 tls * if the request was handled, or a suitable unix error code
188 1.1.1.1.10.2 tls * otherwise.
189 1.1.1.1.10.2 tls */
190 1.1.1.1.10.2 tls extern int nlm_do_unlock(nlm4_unlockargs *argp, nlm4_res *result,
191 1.1.1.1.10.2 tls struct svc_req *rqstp, CLIENT **rpcp);
192 1.1.1.1.10.2 tls
193 1.1.1.1.10.2 tls /*
194 1.1.1.1.10.2 tls * Implementation for granted RPCs. If the request was handled
195 1.1.1.1.10.2 tls * successfully and rpcp is non-NULL, *rpcp is set to an RPC client
196 1.1.1.1.10.2 tls * handle which can be used to send an async rpc reply. Returns zero
197 1.1.1.1.10.2 tls * if the request was handled, or a suitable unix error code
198 1.1.1.1.10.2 tls * otherwise.
199 1.1.1.1.10.2 tls */
200 1.1.1.1.10.2 tls extern int nlm_do_granted(nlm4_testargs *argp, nlm4_res *result,
201 1.1.1.1.10.2 tls struct svc_req *rqstp, CLIENT **rpcp);
202 1.1.1.1.10.2 tls
203 1.1.1.1.10.2 tls /*
204 1.1.1.1.10.2 tls * Implementation for the granted result RPC. The client may reject the granted
205 1.1.1.1.10.2 tls * message, in which case we need to handle it appropriately.
206 1.1.1.1.10.2 tls */
207 1.1.1.1.10.2 tls extern void nlm_do_granted_res(nlm4_res *argp, struct svc_req *rqstp);
208 1.1.1.1.10.2 tls
209 1.1.1.1.10.2 tls /*
210 1.1.1.1.10.2 tls * Free all locks associated with the hostname argp->name.
211 1.1.1.1.10.2 tls */
212 1.1.1.1.10.2 tls extern void nlm_do_free_all(nlm4_notify *argp);
213 1.1.1.1.10.2 tls
214 1.1.1.1.10.2 tls /*
215 1.1.1.1.10.2 tls * Recover client lock state after a server reboot.
216 1.1.1.1.10.2 tls */
217 1.1.1.1.10.2 tls extern void nlm_client_recovery(struct nlm_host *);
218 1.1.1.1.10.2 tls
219 1.1.1.1.10.2 tls /*
220 1.1.1.1.10.2 tls * Interface from NFS client code to the NLM.
221 1.1.1.1.10.2 tls */
222 1.1.1.1.10.2 tls struct vop_advlock_args;
223 1.1.1.1.10.2 tls struct vop_reclaim_args;
224 1.1.1.1.10.2 tls extern int nlm_advlock(struct vop_advlock_args *ap);
225 1.1.1.1.10.2 tls extern int nlm_reclaim(struct vop_reclaim_args *ap);
226 1.1.1.1.10.2 tls
227 1.1.1.1.10.2 tls /*
228 1.1.1.1.10.2 tls * Acquire the next sysid for remote locks not handled by the NLM.
229 1.1.1.1.10.2 tls */
230 1.1.1.1.10.2 tls extern uint32_t nlm_acquire_next_sysid(void);
231 1.1.1.1.10.2 tls
232 1.1.1.1.10.2 tls #endif
233 1.1.1.1.10.2 tls
234 1.1.1.1.10.2 tls #endif
235