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
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.
13 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
17 * NFS Lock Manager, client-side
18 * Note: depends on (links with) klmmod
20 * This file contains all the external entry points of klmops.
21 * Basically, this is the "glue" to the BSD nlm code.
24 #include <sys/types.h>
25 #include <sys/errno.h>
26 #include <sys/modctl.h>
27 #include <sys/flock.h>
30 #include <rpcsvc/nlm_prot.h>
34 static struct modlmisc modlmisc
= {
35 &mod_miscops
, "lock mgr calls"
38 static struct modlinkage modlinkage
= {
39 MODREV_1
, &modlmisc
, NULL
45 * ****************************************************************
46 * module init, fini, info
51 return (mod_install(&modlinkage
));
62 _info(struct modinfo
*modinfop
)
64 return (mod_info(&modlinkage
, modinfop
));
70 * ****************************************************************
71 * Stubs listed in modstubs.s
72 * These are called from fs/nfs
76 * NFSv2 lock/unlock. Called by nfs_frlock()
77 * Uses NLM version 1 (NLM_VERS)
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
)
84 return (nlm_frlock(vp
, cmd
, flk
, flags
, off
,
85 cr
, fh
, flcb
, NLM_VERS
));
89 * NFSv3 lock/unlock. Called by nfs3_frlock()
90 * Uses NLM version 4 (NLM4_VERS)
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
)
98 err
= nlm_frlock(vp
, cmd
, flk
, flags
, off
,
99 cr
, fh
, flcb
, NLM4_VERS
);
104 * NFSv2 shrlk/unshrlk. See nfs_shrlock
105 * Uses NLM version 3 (NLM_VERSX)
108 lm_shrlock(struct vnode
*vp
, int cmd
,
109 struct shrlock
*shr
, int flags
, struct netobj
*fh
)
111 return (nlm_shrlock(vp
, cmd
, shr
, flags
, fh
, NLM_VERSX
));
115 * NFSv3 shrlk/unshrlk. See nfs3_shrlock
116 * Uses NLM version 4 (NLM4_VERS)
119 lm4_shrlock(struct vnode
*vp
, int cmd
,
120 struct shrlock
*shr
, int flags
, struct netobj
*fh
)
122 return (nlm_shrlock(vp
, cmd
, shr
, flags
, fh
, NLM4_VERS
));
126 * Helper for nfs_lockrelease.
129 lm_register_lock_locally(struct vnode
*vp
, struct lm_sysid
*ls
,
130 struct flock64
*flk
, int flags
, u_offset_t offset
)
132 nlm_register_lock_locally(vp
, (struct nlm_host
*)ls
,
137 * Old RPC service dispatch functions, no longer used.
138 * Here only to satisfy modstubs.s references.
141 lm_nlm_dispatch(struct svc_req
*req
, SVCXPRT
*xprt
)
143 _NOTE(ARGUNUSED(req
, xprt
))
147 lm_nlm4_dispatch(struct svc_req
*req
, SVCXPRT
*xprt
)
149 _NOTE(ARGUNUSED(req
, xprt
))
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.
159 lm_nlm_reclaim(struct vnode
*vp
, struct flock64
*flkp
)
161 _NOTE(ARGUNUSED(vp
, flkp
))
165 lm_nlm4_reclaim(struct vnode
*vp
, struct flock64
*flkp
)
167 _NOTE(ARGUNUSED(vp
, flkp
))