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