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