/*************************************************************************** * * Copyright (C) 2001 International Business Machines * All rights reserved. * * This file is part of the GPFS mmfslinux kernel module. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *************************************************************************** */ /* @(#)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 */ #ifndef _h_cxiSharedSeg_plat #define _h_cxiSharedSeg_plat #ifndef _h_cxiSharedSeg #error Platform header (XXX-plat.h) should not be included directly #endif #define SHARED_SEGMENT_BASE (UIntPtr(SharedSegmentBase)) EXTERN char* SharedSegmentBase; /* Globals for daemon using swizzled pointers with the shared segment */ #ifdef SSEG_SWIZZLE_PTRS EXTERNC int initPtrSwizzling(Boolean initKernel); EXTERN char * SharedSegmentKernelBase; EXTERN char * SharedSegmentKernelMax; EXTERN Ptrdiff SharedSegmentOffset; EXTERN IntPtr SharedSegmentSwizzledSize; EXTERN char * SharedSegmentSwizzledBase; EXTERN char * SharedSegmentSwizzledMax; #endif #define SEGMENT_MAX_VMALLOC_PERCENT 50/100 /* ioctl ops */ enum kxOps { RegisterMMFSDaemon = 1, WaitCondvar = 2, ThreadInitOrTerm = 3, SignalOrBroadcastCondvar = 4, GetCondWaiters = 5, AllocEventWords = 6, InitKernelMailboxes = 7, EnableIO = 8, TerminateMailboxes = 9, StackAddrToThreadID = 10, kernelTrace = 11, GetDiskInfo = 12, RegisterMMFSSessionId = 13, kernelRecLockReset = 14, SetCommState = 15, AcquireMutex = 16, ReleaseMutex = 17, RegisterNodeAddr = 18, InitializeRevokeTab = 19, RegisterObjType = 20, SetTraceLevel = 21, kxtraceit = 22, kPoll = 23, GetLocalSGIdCounter = 24, QueueCompletedIO = 25, AwaitIOCompletion = 26, StartIO = 27, GetSimpleLock = 28, MapPrivate = 29, SetMountInfoByID = 30, FreeMailboxStorage = 31, RegisterMMFSSeg = 32, #ifdef SMB_LOCKS BreakOplock = 33, #endif GetStructSize = 34, GetMapCount = 35, DefineShSeg = 36, SetPrivLevel = 37, kernelSendFlock = 38, kernelWaitForFlock = 39, kernelCommonReclock = 40, kernelDoTraceDump = 41, SetNPagesAvailable = 42, CoreDump = 43, PinKernelIOBuffer = 44, UnpinKernelIOBuffer = 45, ClearMountInfo = 46, RetryRecover = 47, UnpinAllKernelIOBuffers = 48, kernelRLRevokeLock = 49, kernelRLRevokeUnLock = 50, SetPageoutThread = 51, ClearPageoutThread = 52, Fattr = 53, FsAttr = 54, Attr = 55, GetACL = 56, PutACL = 57, Fstat = 58, Stat = 59, AtomvarInit = 60, VFSStatCtl = 61, kernelMmapControl = 62, kernelMmapInfo = 63, CatalogGetMounts = 64, GetMountInfoByID = 65, uvmount = 66, saveThreadInfo = 67, kernelMmapFlush = 68, InvalidateOSNode = 69, HasMountHelper = 70, #ifdef P_NFS4 PnfsCtl = 71, #endif AllocVinfo = 72, CleanupVinfo = 73, kernelMadvise = 74, updateOSNode = 75, Quotactl = 76, CheckThreadStateCtl = 77, // unused 78-80 #ifdef SSEG_SWIZZLE_PTRS InitPtrSwizzling = 81, #endif CalcMaxSharedSegment = 82, AllocSharedMemory = 83, FreeSharedMemory = 84, FreeAllSharedMemory = 85, SetTakeOwnership = 86, InitializeNodeHashTab = 87, ClampLocks = 88, UnClampLocks = 89, CheckNTAccess = 90, noOp = 91, InvalidateSnapshot = 92, CleanupStaleNFS = 93, GetKernelBoundary = 94, SetMultiNode = 95, BlockingMutexStatsCtl = 96, FindCloseNFS = 97, SetMachineSID = 98, GetPrivLevel = 99, InvalidateVolatileOSNodes = 100, ThreadPtrToThreadID = 101, DmApiCall = 102, DmRemoveSession = 103, DmGetSessions = 104, DmUpdateSessions = 105, AttachSharedMemory = 106, DetachSharedMemory = 107, XmemXfer = 108, ctlDMS = 109, QuiesceOperations = 110, ResumeOperations = 111, #ifdef SMB_LOCKS GetShare = 112, GetDelegation = 113, // unused = 114, OplockInit = 115, OplockTerm = 116, OplockNotify = 117, #endif SanApiCall = 118, GetThreadID = 119, GetTimeOfDay = 120, kernelLockCallback = 121, CheckBuildTime = 122, UMount = 123 }; #define kxOp_tostring(ent) \ (((ent) == 0)? "UNUSED 0" : \ ((ent) == 1)? "RegisterMMFSDaemon" : \ ((ent) == 2)? "WaitCondvar" : \ ((ent) == 3)? "ThreadInitOrTerm" : \ ((ent) == 4)? "SignalOrBroadcastCondvar" : \ ((ent) == 5)? "GetCondWaiters" : \ ((ent) == 6)? "AllocEventWords" : \ ((ent) == 7)? "InitKernelMailboxes" : \ ((ent) == 8)? "EnableIO" : \ ((ent) == 9)? "TerminateMailboxes" : \ ((ent) == 10)? "StackAddrToThreadID" : \ ((ent) == 11)? "kernelTrace" : \ ((ent) == 12)? "GetDiskInfo" : \ ((ent) == 13)? "RegisterMMFSSessionId " : \ ((ent) == 14)? "kernelRecLockReset" : \ ((ent) == 15)? "SetCommState" : \ ((ent) == 16)? "AcquireMutex" : \ ((ent) == 17)? "ReleaseMutex" : \ ((ent) == 18)? "RegisterNodeAddr" : \ ((ent) == 19)? "InitializeRevokeTab" : \ ((ent) == 20)? "RegisterObjType" : \ ((ent) == 21)? "SetTraceLevel" : \ ((ent) == 22)? "kxtraceit" : \ ((ent) == 23)? "kPoll" : \ ((ent) == 24)? "GetLocalSGIdCounter" : \ ((ent) == 25)? "QueueCompletedIO" : \ ((ent) == 26)? "AwaitIOCompletion" : \ ((ent) == 27)? "StartIO" : \ ((ent) == 28)? "GetSimpleLock" : \ ((ent) == 29)? "MapPrivate" : \ ((ent) == 30)? "SetMountInfoByID" : \ ((ent) == 31)? "FreeMailboxStorage" : \ ((ent) == 32)? "RegisterMMFSSeg" : \ ((ent) == 33)? "BreakOplock" : \ ((ent) == 34)? "GetStructSize" : \ ((ent) == 35)? "GetMapCount" : \ ((ent) == 36)? "DefineShSeg" : \ ((ent) == 37)? "SetPrivLevel" : \ ((ent) == 38)? "kernelSendFlock" : \ ((ent) == 39)? "kernelWaitForFlock" : \ ((ent) == 40)? "kernelCommonReclock" : \ ((ent) == 41)? "kernelDoTraceDump" : \ ((ent) == 42)? "SetNPagesAvailable" : \ ((ent) == 43)? "CoreDump" : \ ((ent) == 44)? "PinKernelIOBuffer" : \ ((ent) == 45)? "UnpinKernelIOBuffer" : \ ((ent) == 46)? "ClearMountInfo" : \ ((ent) == 47)? "unused" : \ ((ent) == 48)? "UnpinAllKernelIOBuffers" : \ ((ent) == 49)? "kernelRLRevokeLock" : \ ((ent) == 50)? "kernelRLRevokeUnLock" : \ ((ent) == 51)? "SetPageoutThread" : \ ((ent) == 52)? "ClearPageoutThread" : \ ((ent) == 53)? "Fattr" : \ ((ent) == 54)? "FsAttr" : \ ((ent) == 55)? "Attr" : \ ((ent) == 56)? "GetACL" : \ ((ent) == 57)? "PutACL" : \ ((ent) == 58)? "Fstat" : \ ((ent) == 59)? "Stat" : \ ((ent) == 60)? "AtomvarInit" : \ ((ent) == 61)? "VFSStatCtl" : \ ((ent) == 62)? "kernelMmapControl" : \ ((ent) == 63)? "kernelMmapInfo" : \ ((ent) == 64)? "CatalogGetMounts" : \ ((ent) == 65)? "GetMountInfoByID" : \ ((ent) == 66)? "uvmount" : \ ((ent) == 67)? "saveThreadInfo" : \ ((ent) == 68)? "kernelMmapFlush" : \ ((ent) == 69)? "InvalidateOSNode" : \ ((ent) == 70)? "IsInheritedFD" : \ ((ent) == 71)? "pNFS" : \ ((ent) == 72)? "AllocVinfo" : \ ((ent) == 73)? "CleanupVinfo" : \ ((ent) == 74)? "kernelMadvise" : \ ((ent) == 75)? "updateOSNode" : \ ((ent) == 76)? "Quotactl" : \ ((ent) == 77)? "SetPAG" : \ ((ent) == 78)? "GetUserMap" : \ ((ent) == 79)? "SetUserMap" : \ ((ent) == 80)? "GetDosAttr" : \ ((ent) == 81)? "SetDosAttr" : \ ((ent) == 82)? "CalcMaxSharedSegment" : \ ((ent) == 83)? "AllocSharedMemory" : \ ((ent) == 84)? "FreeSharedMemory" : \ ((ent) == 85)? "FreeAllSharedMemory" : \ ((ent) == 86)? "SetTakeOwnership" : \ ((ent) == 87)? "InitializeNodeHashTab" : \ ((ent) == 88)? "unused" : \ ((ent) == 89)? "unused" : \ ((ent) == 90)? "CheckNTAccess" : \ ((ent) == 91)? "noOp" : \ ((ent) == 92)? "InvalidateSnapshot" : \ ((ent) == 93)? "CleanupStaleNFS" : \ ((ent) == 94)? "GetKernelBoundary" : \ ((ent) == 95)? "SetMultiNode" : \ ((ent) == 96)? "BlockingMutexStatsCtl" : \ ((ent) == 97)? "FindCloseNFS" : \ ((ent) == 98)? "SetMachineSID" : \ ((ent) == 99)? "GetPrivLevel" : \ ((ent) == 100)? "InvalidateVolatileOSNodes" : \ ((ent) == 101)? "ThreadPtrToThreadID" : \ ((ent) == 102)? "DmApiCall" : \ ((ent) == 103)? "DmRemoveSession" : \ ((ent) == 104)? "DmGetSessions" : \ ((ent) == 105)? "DmUpdateSessions" : \ ((ent) == 106)? "AttachSharedMemory" : \ ((ent) == 107)? "DetachSharedMemory" : \ ((ent) == 108)? "XmemXfer" : \ ((ent) == 109)? "startDMS" : \ ((ent) == 110)? "QuiesceOperations" : \ ((ent) == 111)? "ResumeOperations" : \ ((ent) == 112)? "GetShare" : \ ((ent) == 113)? "GetDelegation" : \ ((ent) == 114)? "unused" : \ ((ent) == 115)? "OplockInit" : \ ((ent) == 116)? "OplockTerm" : \ ((ent) == 117)? "OplockNotify" : \ ((ent) == 118)? "SanApiCall" : \ ((ent) == 119)? "GetThreadID" : \ ((ent) == 120)? "GetTimeOfDay" : \ ((ent) == 121)? "kernelLockCallback" : \ ((ent) == 122)? "CheckBuildTime" : \ ((ent) == 123)? "UMount" : \ "??") #define MAX_SS_IOCTL_OPS 123 struct kxArgs { long arg1; long arg2; long arg3; long arg4; long arg5; }; /* Remapping structure for handling 32-bit API calls in 64-bit GPFS */ struct kxArgs32 { UInt32 arg1; UInt32 arg2; UInt32 arg3; UInt32 arg4; UInt32 arg5; }; #ifndef GPFS_SUPER_MAGIC /* ASCII code for "GPFS" in the struct statfs f_type field */ /* This value must match same define in gpfs.h */ #define GPFS_SUPER_MAGIC 0x47504653 #endif #ifdef __cplusplus extern "C" { #endif int ss_init(); void gpfs_proc_export_init(void); void gpfs_proc_export_term(void); void InitSharedMemory(); void TermSharedMemory(); void CleanUpSharedMemory(); #ifdef API_32BIT void gpfs_reg_ioctl32(); void gpfs_unreg_ioctl32(); #endif /* API_32BIT */ #ifdef __cplusplus } #endif #define ASSERTBASESEG(ADDR, REA, TAG) #ifdef GPFS_ARCH_IA64 #define SET_PRIVILEGE_LEVEL() \ int fd_x; \ fd_x = open(GPFS_DEVNAME, O_RDWR); \ if (fd_x > 0) \ { \ ioctl(fd_x, SetPrivLevel, 1); \ close(fd_x); \ } #else #define SET_PRIVILEGE_LEVEL() (NOOP) #endif #ifdef __cplusplus EXTERNC int (*ss_ioctl_op[MAX_SS_IOCTL_OPS+1])(...); #else EXTERNC int (*ss_ioctl_op[MAX_SS_IOCTL_OPS+1])(); #endif /* __cplusplus */ struct cxiMemoryMapping_t; /* Compute how large the total size shared segment * is allowed to grow, based on a desired size. A value of 0 for * desiredBytes means to compute the default maximum size. */ EXTERNC int cxiCalcMaxSharedSegment(int desiredBytes, int* actualBytesP); EXTERNC int cxiAllocSharedMemory(struct cxiMemoryMapping_t *mappingP, Boolean isSharedSegment); EXTERNC int cxiFreeSharedMemory(struct cxiMemoryMapping_t *mappingP, Boolean isSharedSegment); EXTERNC int cxiAttachSharedMemory(struct cxiMemoryMapping_t *mappingP, Boolean isSharedSegment); EXTERNC int cxiDetachSharedMemory(struct cxiMemoryMapping_t *mappingP, Boolean isSharedSegment); #ifdef SSEG_SWIZZLE_PTRS EXTERNC int cxiRecordSharedMemory(struct cxiMemoryMapping_t *mappingP); #endif /* get a core dump */ EXTERNC int kxCoreDump(long sig, void *info, struct ucontext *sc, char *filenameP); /* Map a section of memory MAP_PRIVATE */ EXTERNC int kxMapPrivate(char *inAddr, unsigned long len, unsigned long prot, char **outAddr); /* Kernel calls implemented in portability layer */ EXTERNC int kxPoll(void* fdListP, int nFDs, int timeoutMS); EXTERNC int kxGetACL(char *pathname, int flags, void *aclP); EXTERNC int kxPutACL(char *pathname, int flags, void *aclP); EXTERNC int kxMadvise(void* addr, size_t len, int advice); #ifdef SMB_LOCKS EXTERNC int setSMBOpenLockControl(void *vP, void *infoP, int command, int lockmode); EXTERNC int setSMBOplock(void *vP, void *infoP, int accessWant, int oplockWant, void *breakArgP, int *oplockGrantedP, Boolean isAsync); EXTERNC int kxGetShare(int fd, unsigned int share, unsigned int deny); EXTERNC int kxGetDelegation(int fd, unsigned int delegate_access, void *cb_token, void *cookie); #endif #ifdef GPFS_QUOTACTL EXTERNC int kxQuotactl(char *pathname, int cmd, int qid, void *bufferP); #endif EXTERNC int kxGetTimeOfDay(cxiTimeStruc_t *tP); EXTERNC cxiThreadId kxGetThreadID(); EXTERNC int kxUMount(int flag, char *pathname, int force, int *ret_err); #if defined(GPFS_GPL) #if defined(GPFS_ARCH_IA64) || defined(GPFS_ARCH_X86_64) /* stat64 isn't defined in IA64 kernel source */ /* stat64 only relevant to 32-bit binaries with x86-64 (asm/ia32.h) */ #define stat64 stat #endif /* GPFS_ARCH_IA64 || GPFS_ARCH_X86_64 */ #endif /* GPFS_GPL*/ struct stat64; EXTERNC int tsstat(char *pathname, struct stat64 *statP); EXTERNC int tsfstat(int fileDesc, struct stat64 *statP); #endif /* _h_cxiSharedSeg_plat */