5917 User-mode SMB server
[unleashed.git] / usr / src / uts / common / nfs / lm.h
blob0328a9686ca8f4189700eb6841ca9141e9ade05b
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
30 #ifndef _NFS_LM_H
31 #define _NFS_LM_H
34 * Interface definitions for the NFSv2/v3 lock manager.
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
41 #include <sys/cred.h>
42 #include <sys/fcntl.h>
43 #include <sys/types.h>
44 #include <sys/vnode.h>
45 #include <rpc/xdr.h>
47 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
50 * Common interfaces.
53 struct exportinfo;
56 * The numeric sysid is used to identify a host and transport.
58 * The local locking code uses (pid, sysid) to uniquely identify a process.
59 * This means that the client-side code must doctor up the sysid before
60 * registering a lock, so that the local locking code doesn't confuse a
61 * remote process with a local process just because they have the same pid.
62 * We currently do this by ORing LM_SYSID_CLIENT into the sysid before
63 * registering a lock.
65 * If you change LM_SYSID and LM_SYSID_MAX, be sure to pick values so that
66 * LM_SYSID_MAX > LM_SYSID using signed arithmetic, and don't use zero.
67 * You may also need a different way to tag lock manager locks that are
68 * registered locally.
70 #define LM_SYSID ((sysid_t)0x0001)
71 #define LM_SYSID_MAX ((sysid_t)0x3FFF)
72 #define LM_SYSID_CLIENT ((sysid_t)0x4000)
73 #define LM_NOSYSID ((sysid_t)-1)
76 * Struct used to represent a host.
78 struct lm_sysid;
79 struct knetconfig;
80 struct netbuf;
83 * Given a knetconfig and network address, returns a reference to the
84 * associated lm_sysid. The 3rd argument is the hostname to assign to the
85 * lm_sysid. The 4th argument is an output parameter. It is set non-zero
86 * if the returned lm_sysid has a different protocol
87 * (knetconfig::knc_proto) than what was requested.
89 extern struct lm_sysid *lm_get_sysid(struct knetconfig *, struct netbuf *,
90 char *, bool_t *);
91 extern void lm_rel_sysid(struct lm_sysid *);
94 * Return the integer sysid for the given lm_sysid.
96 extern sysid_t lm_sysidt(struct lm_sysid *);
98 extern void lm_free_config(struct knetconfig *);
100 extern void lm_cprsuspend(void);
101 extern void lm_cprresume(void);
104 * Client-side interfaces.
107 extern int lm_frlock(struct vnode *vp, int cmd,
108 struct flock64 *flk, int flag,
109 u_offset_t offset, struct cred *cr,
110 netobj *fh, struct flk_callback *);
111 extern int lm_has_sleep(const struct vnode *);
112 extern void lm_register_lock_locally(vnode_t *,
113 struct lm_sysid *, struct flock64 *, int,
114 u_offset_t);
115 extern int lm_safelock(vnode_t *, const struct flock64 *,
116 cred_t *);
117 extern int lm_safemap(const vnode_t *);
118 extern int lm_shrlock(struct vnode *vp, int cmd,
119 struct shrlock *shr, int flag, netobj *fh);
120 extern int lm4_frlock(struct vnode *vp, int cmd,
121 struct flock64 *flk, int flag,
122 u_offset_t offset, struct cred *cr,
123 netobj *fh, struct flk_callback *);
124 extern int lm4_shrlock(struct vnode *vp, int cmd,
125 struct shrlock *shr, int flag, netobj *fh);
128 * Server-side interfaces.
131 extern void lm_unexport(struct exportinfo *);
134 * Clustering: functions to encode the nlmid of the node where this NLM
135 * server is running in the l_sysid of the flock struct or the s_sysid
136 * field of the shrlock struct (respectively).
138 extern void lm_set_nlmid_flk(int *);
139 extern void lm_set_nlmid_shr(int32_t *);
140 /* Hook for deleting all mandatory NFSv4 file locks held by a remote client */
141 extern void (*lm_remove_file_locks)(int);
144 * The following global variable is the node id of the node where this
145 * NLM server is running.
147 extern int lm_global_nlmid;
150 * End of clustering hooks.
154 * Return non-zero if the given local vnode is in use.
156 extern int lm_vp_active(const struct vnode *);
158 extern sysid_t lm_alloc_sysidt(void);
159 extern void lm_free_sysidt(sysid_t);
161 #endif /* _KERNEL */
163 #ifdef __STDC__
164 extern int lm_shutdown(void);
165 #else
166 extern int lm_shutdown();
167 #endif /* __STDC__ */
169 #ifdef __cplusplus
171 #endif
173 #endif /* _NFS_LM_H */