xref: /titanic_51/usr/src/uts/common/klm/klmops.c (revision 5cd496e3c5514951ae23bdd897cb29b202e2ff62)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy is of the CDDL is also available via the Internet
9  * at http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
14  */
15 
16 /*
17  * NFS Lock Manager, client-side
18  * Note: depends on (links with) klmmod
19  *
20  * This file contains all the external entry points of klmops.
21  * Basically, this is the "glue" to the BSD nlm code.
22  */
23 
24 #include <sys/types.h>
25 #include <sys/errno.h>
26 #include <sys/modctl.h>
27 #include <sys/flock.h>
28 
29 #include <nfs/lm.h>
30 #include <rpcsvc/nlm_prot.h>
31 #include "nlm_impl.h"
32 
33 
34 static struct modlmisc modlmisc = {
35 	&mod_miscops, "lock mgr calls"
36 };
37 
38 static struct modlinkage modlinkage = {
39 	MODREV_1, &modlmisc, NULL
40 };
41 
42 
43 
44 /*
45  * ****************************************************************
46  * module init, fini, info
47  */
48 int
49 _init()
50 {
51 	return (mod_install(&modlinkage));
52 }
53 
54 int
55 _fini()
56 {
57 	/* Don't unload. */
58 	return (EBUSY);
59 }
60 
61 int
62 _info(struct modinfo *modinfop)
63 {
64 	return (mod_info(&modlinkage, modinfop));
65 }
66 
67 
68 
69 /*
70  * ****************************************************************
71  * Stubs listed in modstubs.s
72  * These are called from fs/nfs
73  */
74 
75 /*
76  * NFSv2 lock/unlock.  Called by nfs_frlock()
77  * Uses NLM version 1 (NLM_VERS)
78  */
79 int
80 lm_frlock(struct vnode *vp, int cmd, struct flock64 *flk, int flags,
81     u_offset_t off, struct cred *cr, struct netobj *fh,
82     struct flk_callback *flcb)
83 {
84 	return (nlm_frlock(vp, cmd, flk, flags, off,
85 	    cr, fh, flcb, NLM_VERS));
86 }
87 
88 /*
89  * NFSv3 lock/unlock.  Called by nfs3_frlock()
90  * Uses NLM version 4 (NLM4_VERS)
91  */
92 int
93 lm4_frlock(struct vnode *vp, int cmd, struct flock64 *flk, int flags,
94 	u_offset_t off, struct cred *cr, struct netobj *fh,
95 	struct flk_callback *flcb)
96 {
97 	int err;
98 	err = nlm_frlock(vp, cmd, flk, flags, off,
99 	    cr, fh, flcb, NLM4_VERS);
100 	return (err);
101 }
102 
103 /*
104  * NFSv2 shrlk/unshrlk.  See nfs_shrlock
105  * Uses NLM version 3 (NLM_VERSX)
106  */
107 int
108 lm_shrlock(struct vnode *vp, int cmd,
109     struct shrlock *shr, int flags, struct netobj *fh)
110 {
111 	return (nlm_shrlock(vp, cmd, shr, flags, fh, NLM_VERSX));
112 }
113 
114 /*
115  * NFSv3 shrlk/unshrlk.  See nfs3_shrlock
116  * Uses NLM version 4 (NLM4_VERS)
117  */
118 int
119 lm4_shrlock(struct vnode *vp, int cmd,
120     struct shrlock *shr, int flags, struct netobj *fh)
121 {
122 	return (nlm_shrlock(vp, cmd, shr, flags, fh, NLM4_VERS));
123 }
124 
125 /*
126  * Helper for nfs_lockrelease.
127  */
128 void
129 lm_register_lock_locally(struct vnode *vp, struct lm_sysid *ls,
130     struct flock64 *flk, int flags, u_offset_t offset)
131 {
132 	nlm_register_lock_locally(vp, (struct nlm_host *)ls,
133 	    flk, flags, offset);
134 }
135 
136 /*
137  * Old RPC service dispatch functions, no longer used.
138  * Here only to satisfy modstubs.s references.
139  */
140 void
141 lm_nlm_dispatch(struct svc_req *req, SVCXPRT *xprt)
142 {
143 	_NOTE(ARGUNUSED(req, xprt))
144 }
145 
146 void
147 lm_nlm4_dispatch(struct svc_req *req, SVCXPRT *xprt)
148 {
149 	_NOTE(ARGUNUSED(req, xprt))
150 }
151 
152 /*
153  * Old internal functions used for reclaiming locks
154  * our NFS client holds after some server restarts.
155  * The new NLM code does this differently, so these
156  * are here only to satisfy modstubs.s references.
157  */
158 void
159 lm_nlm_reclaim(struct vnode *vp, struct flock64 *flkp)
160 {
161 	_NOTE(ARGUNUSED(vp, flkp))
162 }
163 
164 void
165 lm_nlm4_reclaim(struct vnode *vp, struct flock64 *flkp)
166 {
167 	_NOTE(ARGUNUSED(vp, flkp))
168 }
169