17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*bbaa8b60SDan Kruchinin /* 28*bbaa8b60SDan Kruchinin * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 29*bbaa8b60SDan Kruchinin */ 30*bbaa8b60SDan Kruchinin 317c478bd9Sstevel@tonic-gate #ifndef _NFS_LM_H 327c478bd9Sstevel@tonic-gate #define _NFS_LM_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate * Interface definitions for the NFSv2/v3 lock manager. 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #include <sys/cred.h> 437c478bd9Sstevel@tonic-gate #include <sys/fcntl.h> 447c478bd9Sstevel@tonic-gate #include <sys/types.h> 457c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 467c478bd9Sstevel@tonic-gate #include <rpc/rpc.h> 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #ifdef _KERNEL 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * Common interfaces. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate 54*bbaa8b60SDan Kruchinin struct exportinfo; 55*bbaa8b60SDan Kruchinin 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * The numeric sysid is used to identify a host and transport. 587c478bd9Sstevel@tonic-gate * 597c478bd9Sstevel@tonic-gate * The local locking code uses (pid, sysid) to uniquely identify a process. 607c478bd9Sstevel@tonic-gate * This means that the client-side code must doctor up the sysid before 617c478bd9Sstevel@tonic-gate * registering a lock, so that the local locking code doesn't confuse a 627c478bd9Sstevel@tonic-gate * remote process with a local process just because they have the same pid. 637c478bd9Sstevel@tonic-gate * We currently do this by ORing LM_SYSID_CLIENT into the sysid before 647c478bd9Sstevel@tonic-gate * registering a lock. 657c478bd9Sstevel@tonic-gate * 667c478bd9Sstevel@tonic-gate * If you change LM_SYSID and LM_SYSID_MAX, be sure to pick values so that 677c478bd9Sstevel@tonic-gate * LM_SYSID_MAX > LM_SYSID using signed arithmetic, and don't use zero. 687c478bd9Sstevel@tonic-gate * You may also need a different way to tag lock manager locks that are 697c478bd9Sstevel@tonic-gate * registered locally. 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate #define LM_SYSID ((sysid_t)0x0001) 727c478bd9Sstevel@tonic-gate #define LM_SYSID_MAX ((sysid_t)0x3FFF) 737c478bd9Sstevel@tonic-gate #define LM_SYSID_CLIENT ((sysid_t)0x4000) 747c478bd9Sstevel@tonic-gate #define LM_NOSYSID ((sysid_t)-1) 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* 777c478bd9Sstevel@tonic-gate * Struct used to represent a host. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate struct lm_sysid; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * Given a knetconfig and network address, returns a reference to the 837c478bd9Sstevel@tonic-gate * associated lm_sysid. The 3rd argument is the hostname to assign to the 847c478bd9Sstevel@tonic-gate * lm_sysid. The 4th argument is an output parameter. It is set non-zero 857c478bd9Sstevel@tonic-gate * if the returned lm_sysid has a different protocol 867c478bd9Sstevel@tonic-gate * (knetconfig::knc_proto) than what was requested. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate extern struct lm_sysid *lm_get_sysid(struct knetconfig *, struct netbuf *, 897c478bd9Sstevel@tonic-gate char *, bool_t *); 907c478bd9Sstevel@tonic-gate extern void lm_rel_sysid(struct lm_sysid *); 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * Return the integer sysid for the given lm_sysid. 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate extern sysid_t lm_sysidt(struct lm_sysid *); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate extern void lm_free_config(struct knetconfig *); 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate extern void lm_cprsuspend(void); 1007c478bd9Sstevel@tonic-gate extern void lm_cprresume(void); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * Client-side interfaces. 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate extern int lm_frlock(struct vnode *vp, int cmd, 1077c478bd9Sstevel@tonic-gate struct flock64 *flk, int flag, 1087c478bd9Sstevel@tonic-gate u_offset_t offset, struct cred *cr, 1097c478bd9Sstevel@tonic-gate netobj *fh, struct flk_callback *); 1107c478bd9Sstevel@tonic-gate extern int lm_has_sleep(const struct vnode *); 1117c478bd9Sstevel@tonic-gate extern void lm_register_lock_locally(vnode_t *, 1127c478bd9Sstevel@tonic-gate struct lm_sysid *, struct flock64 *, int, 1137c478bd9Sstevel@tonic-gate u_offset_t); 1147c478bd9Sstevel@tonic-gate extern int lm_safelock(vnode_t *, const struct flock64 *, 1157c478bd9Sstevel@tonic-gate cred_t *); 1167c478bd9Sstevel@tonic-gate extern int lm_safemap(const vnode_t *); 1177c478bd9Sstevel@tonic-gate extern int lm_shrlock(struct vnode *vp, int cmd, 1187c478bd9Sstevel@tonic-gate struct shrlock *shr, int flag, netobj *fh); 1197c478bd9Sstevel@tonic-gate extern int lm4_frlock(struct vnode *vp, int cmd, 1207c478bd9Sstevel@tonic-gate struct flock64 *flk, int flag, 1217c478bd9Sstevel@tonic-gate u_offset_t offset, struct cred *cr, 1227c478bd9Sstevel@tonic-gate netobj *fh, struct flk_callback *); 1237c478bd9Sstevel@tonic-gate extern int lm4_shrlock(struct vnode *vp, int cmd, 1247c478bd9Sstevel@tonic-gate struct shrlock *shr, int flag, netobj *fh); 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * Server-side interfaces. 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate extern void lm_unexport(struct exportinfo *); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate /* 1337c478bd9Sstevel@tonic-gate * Clustering: functions to encode the nlmid of the node where this NLM 1347c478bd9Sstevel@tonic-gate * server is running in the l_sysid of the flock struct or the s_sysid 1357c478bd9Sstevel@tonic-gate * field of the shrlock struct (respectively). 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate extern void lm_set_nlmid_flk(int *); 1387c478bd9Sstevel@tonic-gate extern void lm_set_nlmid_shr(int32_t *); 1397c478bd9Sstevel@tonic-gate /* Hook for deleting all mandatory NFSv4 file locks held by a remote client */ 1407c478bd9Sstevel@tonic-gate extern void (*lm_remove_file_locks)(int); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * The following global variable is the node id of the node where this 1447c478bd9Sstevel@tonic-gate * NLM server is running. 1457c478bd9Sstevel@tonic-gate */ 1467c478bd9Sstevel@tonic-gate extern int lm_global_nlmid; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* 1497c478bd9Sstevel@tonic-gate * End of clustering hooks. 1507c478bd9Sstevel@tonic-gate */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Return non-zero if the given local vnode is in use. 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate extern int lm_vp_active(const struct vnode *); 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate extern sysid_t lm_alloc_sysidt(void); 1587c478bd9Sstevel@tonic-gate extern void lm_free_sysidt(sysid_t); 1597c478bd9Sstevel@tonic-gate 160*bbaa8b60SDan Kruchinin #endif /* _KERNEL */ 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #ifdef __STDC__ 1637c478bd9Sstevel@tonic-gate extern int lm_shutdown(void); 1647c478bd9Sstevel@tonic-gate #else 1657c478bd9Sstevel@tonic-gate extern int lm_shutdown(); 1667c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1697c478bd9Sstevel@tonic-gate } 1707c478bd9Sstevel@tonic-gate #endif 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate #endif /* _NFS_LM_H */ 173