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