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