1 | /*************************************************************************** |
---|
2 | * |
---|
3 | * Copyright (C) 2001 International Business Machines |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * This file is part of the GPFS mmfslinux kernel module. |
---|
7 | * |
---|
8 | * Redistribution and use in source and binary forms, with or without |
---|
9 | * modification, are permitted provided that the following conditions |
---|
10 | * are met: |
---|
11 | * |
---|
12 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
15 | * notice, this list of conditions and the following disclaimer in the |
---|
16 | * documentation and/or other materials provided with the distribution. |
---|
17 | * 3. The name of the author may not be used to endorse or promote products |
---|
18 | * derived from this software without specific prior written |
---|
19 | * permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
---|
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
---|
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
---|
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
30 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
31 | * |
---|
32 | *************************************************************************** */ |
---|
33 | /* @(#)02 1.16 src/avs/fs/mmfs/ts/kernext/gpl-linux/oplock.h, mmfs, avs_rgpfs24, rgpfs240610b 11/3/05 11:00:29 */ |
---|
34 | |
---|
35 | #define TEST_LOCK_MOVE_CLAMP |
---|
36 | /* |
---|
37 | * for kernel oplocks used by Samba |
---|
38 | */ |
---|
39 | #ifndef _OPLOCK_H |
---|
40 | #define _OPLOCK_H |
---|
41 | |
---|
42 | #ifdef __KERNEL__ |
---|
43 | #include <linux/types.h> |
---|
44 | #include <linux/file.h> |
---|
45 | #else |
---|
46 | /* Header file is also used in user space by Samba */ |
---|
47 | #include <sys/types.h> |
---|
48 | #endif |
---|
49 | |
---|
50 | /* |
---|
51 | * Additional fcntl commands to support integration with Samba/NFS |
---|
52 | * for oplocks, share modes and NLM locks. |
---|
53 | */ |
---|
54 | |
---|
55 | /* |
---|
56 | * Commands 20-26 are deprecated and may be removed anytime (once Samba |
---|
57 | * moves over). Use the following instead |
---|
58 | */ |
---|
59 | #define F_OPLKREG 20 /* register exclusive oplock */ |
---|
60 | #define F_OPLKREG_LVL2 21 /* register level 2 oplock */ |
---|
61 | #define F_OPLKACK 22 /* action on oplock */ |
---|
62 | #define F_OPLKSTAT 23 /* stat file for oplock */ |
---|
63 | #define F_SET_SHMODE 24 /* Request a share mode (opening a file) */ |
---|
64 | #define F_DEL_SHMODE 25 /* Drop a share mode (closing a file) */ |
---|
65 | #define F_OPENMODE 26 /* register open mode only */ |
---|
66 | |
---|
67 | #define F_SET_NLM_MODE 27 /* Set share mode for NLM */ |
---|
68 | #define F_DEL_NLM_MODE 28 /* Remove NLM share mode */ |
---|
69 | #define F_SET_NLM_MOVE 29 /* Move a lock for the NLM */ |
---|
70 | |
---|
71 | #define F_SHARE_MODE 30 /* share mode without oplocks */ |
---|
72 | #define F_EXCL_OPEN 31 /* share mode with exclusive oplock */ |
---|
73 | #define F_SHARED_OPEN 32 /* share mode with level 2 oplock */ |
---|
74 | |
---|
75 | #ifdef TEST_LOCK_MOVE_CLAMP |
---|
76 | #define F_TEST_MOVE_OPEN_LOCK 50 |
---|
77 | #define F_TEST_MOVE_REC_LOCK 51 |
---|
78 | #define F_TEST_CLAMP_LOCKS 52 |
---|
79 | #define F_TEST_UNCLAMP_LOCKS 53 |
---|
80 | #endif |
---|
81 | |
---|
82 | /* Deny mode values passed from CIFS */ |
---|
83 | #define DENY_DOS 0 |
---|
84 | #define DENY_ALL 1 |
---|
85 | #define DENY_WRITE 2 |
---|
86 | #define DENY_READ 3 |
---|
87 | #define DENY_NONE 4 |
---|
88 | #define DENY_FCB 7 |
---|
89 | /* The following prevents duplicate definition in Samba */ |
---|
90 | #ifndef _INCLUDES_H |
---|
91 | #define ALLOW_SHARE_DELETE 1<<15 |
---|
92 | #endif |
---|
93 | |
---|
94 | /* Access / deny modes passed from NLM */ |
---|
95 | #define NLM_READ 1 |
---|
96 | #define NLM_WRITE 2 |
---|
97 | #define NLM_REACQUIRE 4 |
---|
98 | |
---|
99 | /* Operands for the OPLKACK function */ |
---|
100 | #define OP_REVOKE 1 |
---|
101 | #define OP_DOWNGRADE 2 |
---|
102 | |
---|
103 | /* Values for the access parameter of the check_cifs_locks function */ |
---|
104 | #define LOCKS_ALL 1 |
---|
105 | #define OPLOCK_ONLY 2 |
---|
106 | #define SHMODE_ONLY 3 |
---|
107 | |
---|
108 | /* Parameter values for F_SET_SHMODE, F_DEL_SHMODE */ |
---|
109 | /* The following constants may be "OR"ed into the standard */ |
---|
110 | /* DENY_MODE specifications */ |
---|
111 | |
---|
112 | #define DENY_MASK 0x000000FF /* DENY bits */ |
---|
113 | |
---|
114 | typedef struct { |
---|
115 | unsigned long long os_dev; /* Samba needs u64 for dev_t; this *cannot* be dev_t */ |
---|
116 | ino_t os_ino; |
---|
117 | int os_state; |
---|
118 | } oplock_stat_t; |
---|
119 | |
---|
120 | #ifdef __KERNEL__ |
---|
121 | |
---|
122 | /* Share mode counter categories */ |
---|
123 | |
---|
124 | #define SM_DENYWA 0 /* Deny write advisory */ |
---|
125 | #define SM_DENYWM 1 /* Deny write mandatory */ |
---|
126 | #define SM_DENYR 2 /* Deny read */ |
---|
127 | #define AM_WRITEA 3 /* Write access, check advisory locks */ |
---|
128 | #define AM_WRITEM 4 /* Write access, check mandatory locks */ |
---|
129 | #define AM_READ 5 /* Read access */ |
---|
130 | #define NUM_SM 6 /* Count of the above fields */ |
---|
131 | |
---|
132 | /* Lock Bits for CIFS Open locks tokens */ |
---|
133 | /* These locks are used as follows: |
---|
134 | * coSMBOpen is always on to distinguish these lock modes from the standard ones. |
---|
135 | * coRead is turned on by Samba requesting read access to the file. An NFS open |
---|
136 | * for read will not use these locks and is always allowed. |
---|
137 | * coWriteA requests write access and asks that advisory write locks be |
---|
138 | * checked. Samba will turn this bit on for write access. |
---|
139 | * If this bit is on, COWriteM will be defaulted on also. |
---|
140 | * coWriteM requests write access and asks that mandatory write locks be checked. |
---|
141 | * Both Samba and NFS will turn this bit on. |
---|
142 | * NOTE: One of CORead and coWriteM will always be on. |
---|
143 | * coDenyR requests that read access be denied to others (except NFS users who don't lock) |
---|
144 | * coDenyWA is advisory denial of writes. It will block users who request COWriteA. |
---|
145 | * coDenyWM is mandatory denial of writes. It will block users who request COWriteM. |
---|
146 | */ |
---|
147 | |
---|
148 | /* Initially, coNFS4Share is not set indicating that no share operation has been |
---|
149 | * done by the NFS version 4 daemon (therefore any open locks held were done |
---|
150 | * implicitly and can be replaced by those specified on a share operation). |
---|
151 | * This is set when gpfs_f_share is first called for a file and means that |
---|
152 | * subsequent share operations will add additional open locks (instead of |
---|
153 | * replacing the current ones). */ |
---|
154 | #define coNFS4Share 0x80 |
---|
155 | |
---|
156 | #define coSMBOpen 0x40 |
---|
157 | #define coSMBShift 3 |
---|
158 | #define coRead 0x20 |
---|
159 | #define coWriteM 0x10 |
---|
160 | #define coWriteA 0x08 |
---|
161 | #define coDenyR 0x04 |
---|
162 | #define coDenyWM 0x02 |
---|
163 | #define coDenyWA 0x01 |
---|
164 | #define coDenyAll 0x07 |
---|
165 | #define coMask 0x3f |
---|
166 | |
---|
167 | /* Command parameter of the tkn_control() function. |
---|
168 | */ |
---|
169 | #define TOKENOP_ACQUIRE 0x1 /* Acquire (Samba) */ |
---|
170 | #define TOKENOP_RELEASE 0x2 /* Release (Samba) */ |
---|
171 | #define TOKENOP_ACQUIRE_NLM 0x3 /* Acquire (NLM) */ |
---|
172 | #define TOKENOP_RELEASE_NLM 0x4 /* Release (NLM) */ |
---|
173 | #define TOKENOP_MOVE_NLM 0x5 /* Move a lock for NLM */ |
---|
174 | |
---|
175 | /* Flags for gpfsReserveShare and gpfsReserveDelegation */ |
---|
176 | #define RESERVE_NONE 0x00000000 |
---|
177 | #define RESERVE_HAVELOCK 0x00000001 /* caller holds vinfoLock */ |
---|
178 | #define RESERVE_DOWNGRADE 0x00000002 /* calling to return share */ |
---|
179 | #define RESERVE_NOWAIT 0x00000004 /* asynchronous */ |
---|
180 | |
---|
181 | int setSMBOpenLockControl(void *fP, void *infoP, int command, int lockmode); |
---|
182 | |
---|
183 | #endif |
---|
184 | |
---|
185 | #endif /* _OPLOCK_H */ |
---|
186 | |
---|
187 | |
---|