source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/ibm-linux/cxiSharedSeg-plat.h @ 16

Last change on this file since 16 was 16, checked in by rock, 16 years ago
File size: 18.8 KB
Line 
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/* @(#)61 1.97.1.1  src/avs/fs/mmfs/ts/kernext/ibm-linux/cxiSharedSeg-plat.h, mmfs, avs_rgpfs24, rgpfs24s003a 5/25/06 02:08:17 */
34
35#ifndef _h_cxiSharedSeg_plat
36#define _h_cxiSharedSeg_plat
37
38#ifndef _h_cxiSharedSeg
39#error Platform header (XXX-plat.h) should not be included directly
40#endif
41
42#define SHARED_SEGMENT_BASE (UIntPtr(SharedSegmentBase))
43EXTERN char* SharedSegmentBase;
44
45/* Globals for daemon using swizzled pointers with the shared segment */
46#ifdef SSEG_SWIZZLE_PTRS
47EXTERNC int initPtrSwizzling(Boolean initKernel);
48
49EXTERN char * SharedSegmentKernelBase;
50EXTERN char * SharedSegmentKernelMax;
51EXTERN Ptrdiff SharedSegmentOffset;
52EXTERN IntPtr SharedSegmentSwizzledSize;
53EXTERN char * SharedSegmentSwizzledBase;
54EXTERN char * SharedSegmentSwizzledMax;
55#endif
56
57#define SEGMENT_MAX_VMALLOC_PERCENT 50/100
58
59/* ioctl ops */
60enum kxOps
61{
62  RegisterMMFSDaemon                  = 1,
63  WaitCondvar                         = 2,
64  ThreadInitOrTerm                    = 3,
65  SignalOrBroadcastCondvar            = 4,
66  GetCondWaiters                      = 5,
67  AllocEventWords                     = 6,
68  InitKernelMailboxes                 = 7,
69  EnableIO                            = 8,
70  TerminateMailboxes                  = 9,
71  StackAddrToThreadID                 = 10,
72  kernelTrace                         = 11,
73  GetDiskInfo                         = 12,
74  RegisterMMFSSessionId               = 13,
75  kernelRecLockReset                  = 14,
76  SetCommState                        = 15,
77  AcquireMutex                        = 16,
78  ReleaseMutex                        = 17,
79  RegisterNodeAddr                    = 18,
80  InitializeRevokeTab                 = 19,
81  RegisterObjType                     = 20,
82  SetTraceLevel                       = 21,
83  kxtraceit                           = 22,
84  kPoll                               = 23,
85  GetLocalSGIdCounter                 = 24,
86  QueueCompletedIO                    = 25,
87  AwaitIOCompletion                   = 26,
88  StartIO                             = 27,
89  GetSimpleLock                       = 28,
90  MapPrivate                          = 29,
91  SetMountInfoByID                    = 30,
92  FreeMailboxStorage                  = 31,
93  RegisterMMFSSeg                     = 32,
94#ifdef SMB_LOCKS
95  BreakOplock                         = 33,
96#endif
97  GetStructSize                       = 34,
98  GetMapCount                         = 35,
99  DefineShSeg                         = 36,
100  SetPrivLevel                        = 37,
101  kernelSendFlock                     = 38,
102  kernelWaitForFlock                  = 39,
103  kernelCommonReclock                 = 40,
104  kernelDoTraceDump                   = 41,
105  SetNPagesAvailable                  = 42,
106  CoreDump                            = 43,
107  PinKernelIOBuffer                   = 44,
108  UnpinKernelIOBuffer                 = 45,
109  ClearMountInfo                      = 46,
110  RetryRecover                        = 47,
111  UnpinAllKernelIOBuffers             = 48,
112  kernelRLRevokeLock                  = 49,
113  kernelRLRevokeUnLock                = 50,
114  SetPageoutThread                    = 51,
115  ClearPageoutThread                  = 52,
116  Fattr                               = 53,
117  FsAttr                              = 54,
118  Attr                                = 55,
119  GetACL                              = 56,
120  PutACL                              = 57,
121  Fstat                               = 58,
122  Stat                                = 59,
123  AtomvarInit                         = 60,
124  VFSStatCtl                          = 61,
125  kernelMmapControl                   = 62,
126  kernelMmapInfo                      = 63,
127  CatalogGetMounts                    = 64,
128  GetMountInfoByID                    = 65,
129  uvmount                             = 66,
130  saveThreadInfo                      = 67,
131  kernelMmapFlush                     = 68,
132  InvalidateOSNode                    = 69,
133  HasMountHelper                      = 70,
134#ifdef P_NFS4
135  PnfsCtl                             = 71,
136#endif
137  AllocVinfo                          = 72,
138  CleanupVinfo                        = 73,
139  kernelMadvise                       = 74,
140  updateOSNode                        = 75,
141  Quotactl                            = 76,
142  CheckThreadStateCtl                 = 77,
143  // unused 78-80
144#ifdef SSEG_SWIZZLE_PTRS
145  InitPtrSwizzling                    = 81,
146#endif
147  CalcMaxSharedSegment                = 82,
148  AllocSharedMemory                   = 83,
149  FreeSharedMemory                    = 84,
150  FreeAllSharedMemory                 = 85,
151  SetTakeOwnership                    = 86,
152  InitializeNodeHashTab               = 87,
153  ClampLocks                          = 88,
154  UnClampLocks                        = 89,
155  CheckNTAccess                       = 90,
156  noOp                                = 91,
157  InvalidateSnapshot                  = 92,
158  CleanupStaleNFS                     = 93,
159  GetKernelBoundary                   = 94,
160  SetMultiNode                        = 95,
161  BlockingMutexStatsCtl               = 96,
162  FindCloseNFS                        = 97,
163  SetMachineSID                       = 98,
164  GetPrivLevel                        = 99,
165  InvalidateVolatileOSNodes           = 100,
166  ThreadPtrToThreadID                 = 101,
167  DmApiCall                           = 102,
168  DmRemoveSession                     = 103,
169  DmGetSessions                       = 104,
170  DmUpdateSessions                    = 105,
171  AttachSharedMemory                  = 106,
172  DetachSharedMemory                  = 107,
173  XmemXfer                            = 108,
174  ctlDMS                              = 109,
175  QuiesceOperations                   = 110,
176  ResumeOperations                    = 111,
177#ifdef SMB_LOCKS
178  GetShare                            = 112,
179  GetDelegation                       = 113,
180  // unused                           = 114,
181  OplockInit                          = 115,
182  OplockTerm                          = 116,
183  OplockNotify                        = 117,
184#endif
185  SanApiCall                          = 118,
186  GetThreadID                         = 119,
187  GetTimeOfDay            = 120,
188  kernelLockCallback          = 121,
189  CheckBuildTime          = 122,
190  UMount            = 123
191};
192
193#define kxOp_tostring(ent) \
194  (((ent) == 0)? "UNUSED 0"                           : \
195   ((ent) == 1)? "RegisterMMFSDaemon"                 : \
196   ((ent) == 2)? "WaitCondvar"                        : \
197   ((ent) == 3)? "ThreadInitOrTerm"                   : \
198   ((ent) == 4)? "SignalOrBroadcastCondvar"           : \
199   ((ent) == 5)? "GetCondWaiters"                     : \
200   ((ent) == 6)? "AllocEventWords"                    : \
201   ((ent) == 7)? "InitKernelMailboxes"                : \
202   ((ent) == 8)? "EnableIO"                           : \
203   ((ent) == 9)? "TerminateMailboxes"                 : \
204   ((ent) == 10)? "StackAddrToThreadID"               : \
205   ((ent) == 11)? "kernelTrace"                       : \
206  ((ent) == 12)? "GetDiskInfo"                        : \
207  ((ent) == 13)? "RegisterMMFSSessionId "             : \
208  ((ent) == 14)? "kernelRecLockReset"                 : \
209  ((ent) == 15)? "SetCommState"                       : \
210  ((ent) == 16)? "AcquireMutex"                       : \
211  ((ent) == 17)? "ReleaseMutex"                       : \
212  ((ent) == 18)? "RegisterNodeAddr"                   : \
213  ((ent) == 19)? "InitializeRevokeTab"                : \
214  ((ent) == 20)? "RegisterObjType"                    : \
215  ((ent) == 21)? "SetTraceLevel"                      : \
216  ((ent) == 22)? "kxtraceit"                          : \
217  ((ent) == 23)? "kPoll"                              : \
218  ((ent) == 24)? "GetLocalSGIdCounter"                : \
219  ((ent) == 25)? "QueueCompletedIO"                   : \
220  ((ent) == 26)? "AwaitIOCompletion"                  : \
221  ((ent) == 27)? "StartIO"                            : \
222  ((ent) == 28)? "GetSimpleLock"                      : \
223  ((ent) == 29)? "MapPrivate"                         : \
224  ((ent) == 30)? "SetMountInfoByID"                   : \
225  ((ent) == 31)? "FreeMailboxStorage"                 : \
226  ((ent) == 32)? "RegisterMMFSSeg"                    : \
227  ((ent) == 33)? "BreakOplock"                        : \
228  ((ent) == 34)? "GetStructSize"                      : \
229  ((ent) == 35)? "GetMapCount"                        : \
230  ((ent) == 36)? "DefineShSeg"                        : \
231  ((ent) == 37)? "SetPrivLevel"                       : \
232  ((ent) == 38)? "kernelSendFlock"                    : \
233  ((ent) == 39)? "kernelWaitForFlock"                 : \
234  ((ent) == 40)? "kernelCommonReclock"                : \
235  ((ent) == 41)? "kernelDoTraceDump"                  : \
236  ((ent) == 42)? "SetNPagesAvailable"                 : \
237  ((ent) == 43)? "CoreDump"                           : \
238  ((ent) == 44)? "PinKernelIOBuffer"                  : \
239  ((ent) == 45)? "UnpinKernelIOBuffer"                : \
240  ((ent) == 46)? "ClearMountInfo"                     : \
241  ((ent) == 47)? "unused"                             : \
242  ((ent) == 48)? "UnpinAllKernelIOBuffers"            : \
243  ((ent) == 49)? "kernelRLRevokeLock"                 : \
244  ((ent) == 50)? "kernelRLRevokeUnLock"               : \
245  ((ent) == 51)? "SetPageoutThread"                   : \
246  ((ent) == 52)? "ClearPageoutThread"                 : \
247  ((ent) == 53)? "Fattr"                              : \
248  ((ent) == 54)? "FsAttr"                             : \
249  ((ent) == 55)? "Attr"                               : \
250  ((ent) == 56)? "GetACL"                             : \
251  ((ent) == 57)? "PutACL"                             : \
252  ((ent) == 58)? "Fstat"                              : \
253  ((ent) == 59)? "Stat"                               : \
254  ((ent) == 60)? "AtomvarInit"                        : \
255  ((ent) == 61)? "VFSStatCtl"                         : \
256  ((ent) == 62)? "kernelMmapControl"                  : \
257  ((ent) == 63)? "kernelMmapInfo"                     : \
258  ((ent) == 64)? "CatalogGetMounts"                   : \
259  ((ent) == 65)? "GetMountInfoByID"                   : \
260  ((ent) == 66)? "uvmount"                            : \
261  ((ent) == 67)? "saveThreadInfo"                     : \
262  ((ent) == 68)? "kernelMmapFlush"                    : \
263  ((ent) == 69)? "InvalidateOSNode"                   : \
264  ((ent) == 70)? "IsInheritedFD"                      : \
265  ((ent) == 71)? "pNFS"                               : \
266  ((ent) == 72)? "AllocVinfo"                         : \
267  ((ent) == 73)? "CleanupVinfo"                       : \
268  ((ent) == 74)? "kernelMadvise"                      : \
269  ((ent) == 75)? "updateOSNode"                       : \
270  ((ent) == 76)? "Quotactl"                           : \
271  ((ent) == 77)? "SetPAG"                             : \
272  ((ent) == 78)? "GetUserMap"                         : \
273  ((ent) == 79)? "SetUserMap"                         : \
274  ((ent) == 80)? "GetDosAttr"                         : \
275  ((ent) == 81)? "SetDosAttr"                         : \
276  ((ent) == 82)? "CalcMaxSharedSegment"               : \
277  ((ent) == 83)? "AllocSharedMemory"                  : \
278  ((ent) == 84)? "FreeSharedMemory"                   : \
279  ((ent) == 85)? "FreeAllSharedMemory"                : \
280  ((ent) == 86)? "SetTakeOwnership"                   : \
281  ((ent) == 87)? "InitializeNodeHashTab"              : \
282  ((ent) == 88)? "unused"                             : \
283  ((ent) == 89)? "unused"                             : \
284  ((ent) == 90)? "CheckNTAccess"                      : \
285  ((ent) == 91)? "noOp"                               : \
286  ((ent) == 92)? "InvalidateSnapshot"                 : \
287  ((ent) == 93)? "CleanupStaleNFS"                    : \
288  ((ent) == 94)? "GetKernelBoundary"                  : \
289  ((ent) == 95)? "SetMultiNode"                       : \
290  ((ent) == 96)? "BlockingMutexStatsCtl"              : \
291  ((ent) == 97)? "FindCloseNFS"                       : \
292  ((ent) == 98)? "SetMachineSID"                      : \
293  ((ent) == 99)? "GetPrivLevel"                       : \
294  ((ent) == 100)? "InvalidateVolatileOSNodes"         : \
295  ((ent) == 101)? "ThreadPtrToThreadID"               : \
296  ((ent) == 102)? "DmApiCall"                         : \
297  ((ent) == 103)? "DmRemoveSession"                   : \
298  ((ent) == 104)? "DmGetSessions"                     : \
299  ((ent) == 105)? "DmUpdateSessions"                  : \
300  ((ent) == 106)? "AttachSharedMemory"                : \
301  ((ent) == 107)? "DetachSharedMemory"                : \
302  ((ent) == 108)? "XmemXfer"                          : \
303  ((ent) == 109)? "startDMS"            : \
304  ((ent) == 110)? "QuiesceOperations"                 : \
305  ((ent) == 111)? "ResumeOperations"                  : \
306  ((ent) == 112)? "GetShare"                          : \
307  ((ent) == 113)? "GetDelegation"                     : \
308  ((ent) == 114)? "unused"                            : \
309  ((ent) == 115)? "OplockInit"                        : \
310  ((ent) == 116)? "OplockTerm"                        : \
311  ((ent) == 117)? "OplockNotify"                      : \
312  ((ent) == 118)? "SanApiCall"                        : \
313  ((ent) == 119)? "GetThreadID"                       : \
314  ((ent) == 120)? "GetTimeOfDay"                      : \
315  ((ent) == 121)? "kernelLockCallback"                : \
316  ((ent) == 122)? "CheckBuildTime"                    : \
317  ((ent) == 123)? "UMount"                           : \
318   "??")
319
320#define MAX_SS_IOCTL_OPS 123
321
322struct kxArgs
323{
324  long arg1;
325  long arg2;
326  long arg3;
327  long arg4;
328  long arg5;
329};
330
331/* Remapping structure for handling 32-bit API calls in 64-bit GPFS */
332struct kxArgs32
333{
334  UInt32 arg1;
335  UInt32 arg2;
336  UInt32 arg3;
337  UInt32 arg4;
338  UInt32 arg5;
339};
340
341#ifndef GPFS_SUPER_MAGIC
342/* ASCII code for "GPFS" in the struct statfs f_type field */
343/* This value must match same define in gpfs.h */
344#define GPFS_SUPER_MAGIC     0x47504653
345#endif
346
347#ifdef __cplusplus
348extern "C"
349{
350#endif
351  int  ss_init();
352  void gpfs_proc_export_init(void);
353  void gpfs_proc_export_term(void);
354  void InitSharedMemory();
355  void TermSharedMemory();
356  void CleanUpSharedMemory();
357#ifdef API_32BIT
358  void gpfs_reg_ioctl32();
359  void gpfs_unreg_ioctl32();
360#endif /* API_32BIT */
361#ifdef __cplusplus
362}
363#endif
364
365#define ASSERTBASESEG(ADDR, REA, TAG)
366
367#ifdef GPFS_ARCH_IA64
368#define SET_PRIVILEGE_LEVEL()                \
369  int fd_x;                                  \
370  fd_x = open(GPFS_DEVNAME, O_RDWR);         \
371  if (fd_x > 0)                              \
372  {                                          \
373    ioctl(fd_x, SetPrivLevel, 1);            \
374    close(fd_x);                             \
375  }
376#else
377#define SET_PRIVILEGE_LEVEL() (NOOP)
378#endif
379
380#ifdef __cplusplus
381EXTERNC int (*ss_ioctl_op[MAX_SS_IOCTL_OPS+1])(...);
382#else
383EXTERNC int (*ss_ioctl_op[MAX_SS_IOCTL_OPS+1])();
384#endif /* __cplusplus */
385
386struct cxiMemoryMapping_t;
387
388/* Compute how large the total size shared segment
389 * is allowed to grow, based on a desired size.  A value of 0 for
390 * desiredBytes means to compute the default maximum size.
391 */
392EXTERNC int cxiCalcMaxSharedSegment(int desiredBytes, int* actualBytesP);
393
394EXTERNC int cxiAllocSharedMemory(struct cxiMemoryMapping_t *mappingP, 
395                                  Boolean isSharedSegment);
396EXTERNC int cxiFreeSharedMemory(struct cxiMemoryMapping_t *mappingP, 
397                                 Boolean isSharedSegment);
398EXTERNC int cxiAttachSharedMemory(struct cxiMemoryMapping_t *mappingP, 
399                                  Boolean isSharedSegment);
400EXTERNC int cxiDetachSharedMemory(struct cxiMemoryMapping_t *mappingP, 
401                                  Boolean isSharedSegment);
402#ifdef SSEG_SWIZZLE_PTRS
403EXTERNC int cxiRecordSharedMemory(struct cxiMemoryMapping_t *mappingP);
404#endif
405
406/* get a core dump */
407EXTERNC int kxCoreDump(long sig, void *info, struct ucontext *sc,
408                       char *filenameP);
409
410/* Map a section of memory MAP_PRIVATE */
411EXTERNC int kxMapPrivate(char *inAddr, unsigned long len, unsigned long prot,
412                         char **outAddr);
413
414/* Kernel calls implemented in portability layer */
415EXTERNC int kxPoll(void* fdListP, int nFDs, int timeoutMS);
416EXTERNC int kxGetACL(char *pathname, int flags, void *aclP);
417EXTERNC int kxPutACL(char *pathname, int flags, void *aclP);
418EXTERNC int kxMadvise(void* addr, size_t len, int advice);
419#ifdef SMB_LOCKS
420EXTERNC int setSMBOpenLockControl(void *vP, void *infoP, int command, 
421                                  int lockmode);
422EXTERNC int setSMBOplock(void *vP, void *infoP, int accessWant, int oplockWant,
423                         void *breakArgP, int *oplockGrantedP, Boolean isAsync);
424EXTERNC int kxGetShare(int fd, unsigned int share, unsigned int deny);
425EXTERNC int kxGetDelegation(int fd, unsigned int delegate_access,
426                            void *cb_token, void *cookie);
427#endif
428#ifdef GPFS_QUOTACTL
429EXTERNC int kxQuotactl(char *pathname, int cmd, int qid, void *bufferP);
430#endif
431EXTERNC int kxGetTimeOfDay(cxiTimeStruc_t *tP);
432EXTERNC cxiThreadId kxGetThreadID();
433EXTERNC int kxUMount(int flag, char *pathname, int force, int *ret_err);
434
435#if defined(GPFS_GPL)
436#if defined(GPFS_ARCH_IA64) || defined(GPFS_ARCH_X86_64)
437/* stat64 isn't defined in IA64 kernel source */
438/* stat64 only relevant to 32-bit binaries with x86-64 (asm/ia32.h) */
439#define stat64 stat
440#endif /* GPFS_ARCH_IA64 || GPFS_ARCH_X86_64 */
441#endif /* GPFS_GPL*/
442
443struct stat64;
444EXTERNC int tsstat(char *pathname, struct stat64 *statP);
445EXTERNC int tsfstat(int fileDesc, struct stat64 *statP);
446
447#endif /* _h_cxiSharedSeg_plat */
448
449
Note: See TracBrowser for help on using the repository browser.