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