source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/include/cxi/cxiTypes.h @ 16

Last change on this file since 16 was 16, checked in by rock, 16 years ago
File size: 26.4 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/* @(#)93       1.85  src/avs/fs/mmfs/ts/kernext/ibm-kxi/cxiTypes.h, mmfs, avs_rgpfs24, rgpfs24s001a 3/27/06 10:57:53 */
34/*
35 * Basic types used throughout GPFS.  Since GPFS shares data between its
36 * daemon and its kernel pieces, types must be defined consistently, rather
37 * than relying on platform-specific include files.  This file may be
38 * included in either C or C++ code.
39 *
40 */
41
42#ifndef _h_cxiTypes
43#define _h_cxiTypes
44
45/* Types to use when the number of bits in a word is important.  Use these
46   instead of long, short, int, etc. for portability */
47typedef short                  Int16;
48typedef int                    Int32;
49typedef long long              Int64;
50typedef unsigned short         UInt16;
51typedef unsigned int           UInt32;
52typedef unsigned long long     UInt64;
53
54typedef unsigned char          UChar;
55typedef unsigned short         UShort;
56typedef long                   Ptrdiff;
57
58/* Use these instead of Int or UInt for padding in structures that are sent
59   in RPCs.  These types will not be byte-swapped when sent between nodes
60   having different endian value. */
61typedef short                  Pad16;
62typedef int                    Pad32;
63
64/* Use these for fields send in RPCs that should not be byte-swapped */
65typedef int                    Opaque32;
66typedef unsigned long long     Opaque64;
67
68/* Use this as the return value type for functions that return a local
69   system errno value, to make it clear that the function is called from
70   outside of GPFS and does not return a GPFS Errno. */
71typedef int                    IntRC;
72
73#define MAX_UINT64 ((UInt64)(0xFFFFFFFFFFFFFFFFuLL))
74#define MAX_INT64  ((Int64)(0x7FFFFFFFFFFFFFFFuLL))
75#define MAX_UINT32 ((UInt32)0xFFFFFFFF)
76#define MAX_INT32  ((Int32)0x7FFFFFFF)
77#define MIN_INT32  ((Int32)0x80000000)
78#define MAX_UINT16 ((UInt16)0xFFFF)
79#define MAX_INT16  ((Int16)0x7FFF)
80#define MIN_INT16  ((Int16)0x8000)
81
82/* Macros to fetch the high and low 32 bits of an Int64 */
83#define High32(_i) ((Int32) (((UInt64)(_i))>>32))
84#define Low32(_i) ((UInt32) ((_i)&0xFFFFFFFF))
85
86/* Use types to safely allow integer to ptr assignment and vice-versa;
87   defined for maximum portability (instead of using intptr_t/uintptr_t) */
88typedef signed long            IntPtr;
89typedef unsigned long          UIntPtr;
90
91/* Define macros to typecast a pointer in a failsafe manner */
92#define INTPTR(_p)             ((IntPtr)(_p))
93#define UINTPTR(_p)            ((UIntPtr)(_p))
94
95/* Conversion macros for pointers and 32-bit integers */
96/* Use when intentionally converting to/from 32-bit integers
97   and pointers so that useless compiler warnings are suppressed. */
98#define PTR_TO_INT32(_p)         ((Int32)(IntPtr)(_p))
99#define PTR_TO_UINT32(_p)        ((UInt32)(UIntPtr)(_p))
100#define INT32_TO_PTR(_i)         ((void *)(IntPtr)(_i))
101#define UINT32_TO_PTR(_i)        ((void *)(UIntPtr)(_i))
102#define PTR_TO_INT64(_p)         ((Int64)(IntPtr)(_p))
103#define PTR_TO_UINT64(_p)        ((UInt64)(UIntPtr)(_p))
104#define UINT64_TO_PTR(_i)        ((void *)(UIntPtr)(_i))
105
106/* Lockword type for mutexes */
107#ifdef __64BIT__
108typedef unsigned long          lockWord_t;
109#else
110typedef unsigned int           lockWord_t;
111#endif /* 64b */
112
113/* Boolean type */
114typedef unsigned int Boolean;
115typedef char cBoolean;
116#define false 0
117#define FALSE 0
118#define true  1
119#define TRUE  1
120
121#ifndef EXTERNC
122#ifdef __cplusplus
123#define EXTERNC extern "C"
124#else
125#define EXTERNC extern
126#endif
127#endif /* EXTERNC */
128
129/* Command parameters given to gpfsSetattr() */
130#ifndef V_MODE         /* set mode */
131#define V_MODE  0x01
132#endif
133#ifndef V_OWN          /* set owner */
134#define V_OWN 0x02
135#endif
136#ifndef V_UTIME        /* set atime and mtime */
137#define V_UTIME 0x04
138#endif
139#ifndef V_STIME        /* set atime, mtime, and ctime */
140#define V_STIME 0x08
141#endif
142#ifndef V_NTIME        /* set atime, mtime, and ctime to now */
143#define V_NTIME 0x10
144#endif
145#ifndef V_SIZE         /* set file size */
146#define V_SIZE  0x20
147#endif
148
149#define CXIDEVNONE (cxiDev_t)(-1U)
150
151/* AIX SHM_RDONLY sys/shm.h */
152#define CXI_SHM_RDONLY 010000
153
154/* Macros to compute minimum and maximum of two numbers */
155#ifndef MIN
156#define MIN(a,b) (((a)<(b))?(a):(b))
157#endif
158#ifndef MAX
159#define MAX(a,b) (((a)>(b))?(a):(b))
160#endif
161
162/* Make sure null pointer definition is always available */
163#ifndef NULL
164#define NULL 0
165#endif
166
167/* Macro to compute the offset of a field within a structure */
168#if defined(__GNUC__) && (__GNUC__ >= 3)
169/* gcc 3.x: avoid warning msg "invalid offsetof from non-POD type: ..."  */
170#define OFFSET_OF(_field, _struct) \
171  (Int32) ( (char*)&((_struct *)16)->_field - (char*)16 )
172#else
173#define OFFSET_OF(_field, _struct) ( (long) ( &((_struct *)0)->_field ) )
174#endif
175
176/* Identifier of a thread.  Always 32 bits, even if native thread IDs are
177   longer on some platforms.  The value cxiNoThread denotes an invalid
178   thread ID. */
179typedef Int32                  cxiThreadId;
180#define cxiNoThread            0
181
182#if !defined(GPFS_LINUX) && defined(__64BIT__)
183typedef Int64                  cxiPid_t;
184#else
185typedef Int32                  cxiPid_t;
186#endif
187typedef Int64                  cxiPid64_t;
188typedef Int32                  cxiPid32_t;
189typedef Int32                  cxiKey_t;
190
191/* Needed since mode_t is short in linux kernel */
192typedef UInt32                 cxiMode_t;
193typedef UInt32                 cxiUid_t;
194typedef UInt32                 cxiGid_t;
195typedef UInt32                 cxiIno_t;    /* gpfs inode number */
196
197/* Original AIX sizes for dev_t.  Special device files continue to
198 * record their major/minor numbers as 32 bits on disk.
199 */
200typedef UInt32                 cxiDev32_t;
201
202typedef UInt32                 cxiTime32_t; /* seconds time type */
203typedef UInt32                 cxiNSec32_t; /* nanoseconds time type */
204typedef unsigned long          cxiSize_t;
205
206/* File system type within cxiStatfs_t */
207typedef struct cxiFsid_t
208{
209  unsigned long val[2];
210} cxiFsid_t;
211
212/* Interface structure for gpfsStatfs() */
213typedef struct cxiStatfs_t
214{
215  UInt64    f_blocks;     /* total data blocks in file system */
216  UInt64    f_bfree;      /* free block in fs */
217  UInt64    f_bavail;     /* free blocks avail to non-superuser */
218  int       f_bsize;      /* optimal file system block size */
219  int       f_files;      /* total file nodes in file system */
220  int       f_ffree;      /* free file nodes in fs */
221  cxiFsid_t f_fsid;       /* file system id */
222  int       f_fsize;      /* fundamental file system block size */
223  char      f_fname[32];  /* file system name (usually mount pt.) */
224  char      f_fpack[32];  /* file system pack name */
225  int       f_name_max;   /* maximum component name length for posix */
226} cxiStatfs_t;
227
228
229
230
231/* l_caller values */
232#define L_CALLER_NULL 0
233#define L_CALLER_LOCKD 1
234
235/* Advisory record locking interface structure */
236typedef long long cxiOff64_t;
237typedef struct cxiFlock_t
238{
239  short           l_type;
240  short           l_whence;
241  unsigned int    l_sysid;
242  cxiPid_t        l_pid;
243#ifndef GPFS_LINUX
244  int             l_vfs;
245#else
246  int             l_caller;
247#endif
248  cxiOff64_t      l_start;
249  cxiOff64_t      l_len;
250  void *          l_owner;
251  void *          l_file;
252  void *          l_lmops;
253  unsigned char   l_flags;
254/* defines for l_flags */
255#define FL_RECLAIM  64  /* lock reclaim */
256} cxiFlock_t;
257
258/* flock l_type constants are OS dependent.  When sending F_GETLK
259 * results between nodes, they must be mapped to generic constants
260 * and then back to OS-specific values by the receiving node.
261 */
262#define GENERIC_F_RDLCK 1
263#define GENERIC_F_WRLCK 2
264#define GENERIC_F_UNLCK 3
265
266#define L_TYPE_OUT(lt) \
267  ((lt) == F_RDLCK)? GENERIC_F_RDLCK: \
268  ((lt) == F_WRLCK)? GENERIC_F_WRLCK: \
269  ((lt) == F_UNLCK)? GENERIC_F_UNLCK: lt; \
270
271#define L_TYPE_IN(lt) \
272  ((lt) == GENERIC_F_RDLCK)? F_RDLCK: \
273  ((lt) == GENERIC_F_WRLCK)? F_WRLCK: \
274  ((lt) == GENERIC_F_UNLCK)? F_UNLCK: lt; \
275
276#ifndef GPFS_LINUX
277#define cxiFlock2Common( cxiCommonP, cxiP )           \
278{                                                     \
279  (cxiCommonP)->l_type = L_TYPE_OUT((cxiP)->l_type);  \
280  (cxiCommonP)->l_whence = (cxiP)->l_whence;          \
281  (cxiCommonP)->l_sysid = (cxiP)->l_sysid;            \
282  (cxiCommonP)->l_pid = (cxiPid64_t)(cxiP)->l_pid;    \
283  (cxiCommonP)->l_vfs = (cxiP)->l_vfs;                \
284  (cxiCommonP)->l_start = (cxiP)->l_start;            \
285  (cxiCommonP)->l_len = (cxiP)->l_len;                \
286  (cxiCommonP)->l_owner = (UInt64)(cxiP)->l_owner;    \
287};
288#define cxiCommon2Flock( cxiP, cxiCommonP )           \
289{                                                     \
290  (cxiP)->l_type = L_TYPE_IN((cxiCommonP)->l_type);   \
291  (cxiP)->l_whence = (cxiCommonP)->l_whence;          \
292  (cxiP)->l_sysid = (cxiCommonP)->l_sysid;            \
293  (cxiP)->l_pid = (cxiPid_t)(cxiCommonP)->l_pid;      \
294  (cxiP)->l_vfs = (cxiCommonP)->l_vfs;                \
295  (cxiP)->l_start = (cxiCommonP)->l_start;            \
296  (cxiP)->l_len = (cxiCommonP)->l_len;                \
297  (cxiP)->l_owner = (void *)(cxiCommonP)->l_owner;    \
298};
299#else
300#define cxiFlock2Common( cxiCommonP, cxiP )           \
301{                                                     \
302  (cxiCommonP)->l_type = L_TYPE_OUT((cxiP)->l_type);  \
303  (cxiCommonP)->l_whence = (cxiP)->l_whence;          \
304  (cxiCommonP)->l_sysid = (cxiP)->l_sysid;            \
305  (cxiCommonP)->l_pid = (cxiPid64_t)(cxiP)->l_pid;    \
306  (cxiCommonP)->l_caller = (cxiP)->l_caller;          \
307  (cxiCommonP)->l_start = (cxiP)->l_start;            \
308  (cxiCommonP)->l_len = (cxiP)->l_len;                \
309  (cxiCommonP)->l_owner = PTR_TO_UINT64((cxiP)->l_owner);    \
310};
311#define cxiCommon2Flock( cxiP, cxiCommonP )           \
312{                                                     \
313  (cxiP)->l_type = L_TYPE_IN((cxiCommonP)->l_type);   \
314  (cxiP)->l_whence = (cxiCommonP)->l_whence;          \
315  (cxiP)->l_sysid = (cxiCommonP)->l_sysid;            \
316  (cxiP)->l_pid = (cxiPid_t)(cxiCommonP)->l_pid;      \
317  (cxiP)->l_caller = (cxiCommonP)->l_caller;          \
318  (cxiP)->l_start = (cxiCommonP)->l_start;            \
319  (cxiP)->l_len = (cxiCommonP)->l_len;                \
320  (cxiP)->l_owner = (void *)(UIntPtr)(cxiCommonP)->l_owner;    \
321};
322#endif        /* !GPFS_LINUX */
323
324typedef enum cxiTrace_t
325{
326  cxiTraceNFS = 0,     /* trace linux nfs activity via printk */
327  cxiTraceNFSoff = 1   /* stop  tracing of linux nfs activity */
328} cxiTrace_t;
329
330
331/* DMAPI operation context */
332typedef enum cxiContext_t
333{
334  unknownOp = 0,        /* invalid or unknown operation type */
335  vnOp = 1,             /* vnode operation */
336  reservedFileOp = 2,   /* quota operation (quota check, asyncRecovery) */
337  generalOp = 3,        /* general (not vnop) operation */
338
339  /* must place all non-dm contexts above this line */
340  /* must place dmOp context on next line, and all other dm contexts after it */
341  dmOp = 4,             /* non-file-related DM operation */
342  dmOpWithToken = 5,    /* File-related DM operation with a DM token */
343  dmOpWithoutToken = 6, /* File-related DM operation without a token */
344  dmOpInvalidToken = 7, /* File-related DM operation with an invalid token */
345  dmOpAccessControl = 8 /* DM operation that acquires/releases access rights */
346} cxiContext_t;
347
348#define CXI_D_NAME_MAX 255     /* _D_NAME_MAX sys/dir.h */
349#define CXI_DEV_BSIZE  512     /* DEV_BSIZE AIX sys/dir.h */
350#define CXI_MAXNAMLEN  255     /* MAXNAMLEN AIX sys/dir.h */
351#define CXI_MAXPATHLEN 1024    /* MAXPATHLEN AIX sys/param.h */
352#define CXI_PATH_MAX   1023    /* PATH_MAX AIX sys/limits.h */
353
354/* This macro verifies if a given operation context is one of DMAPI contexts */
355#define IS_DM_CONTEXT(opContext) ((opContext < dmOp) ? false : true)
356
357/* Operations supported by gpfsReadWrite */
358typedef enum cxiRdWr_t { CXI_READ, CXI_WRITE, CXI_READ_NO_MOVE,
359                         CXI_WRITE_NO_MOVE } cxiRdWr_t;
360
361/* Forward declarations */
362struct gpfsVfsData_t;
363struct ext_cred_t;
364
365/* Macros to convert integers of various sizes from big endian to little
366   endian or vice versa.  Do not use these directly; use either the ByteSwapxx
367   routines defined in cxiTypes-plat.h or the BigEndToCPUxx/CPUToBigEndxx
368   macros instead. */
369#define _ByteSwap16(d) \
370        ((UInt16)((((UInt16)(d) >> 8) & 0x00FFU) | \
371                  (((UInt16)(d) << 8) & 0xFF00U)))
372
373#define _ByteSwap32(d) \
374        ((UInt32)((((UInt32)(d) >> 24) & 0x000000FFU) | \
375                  (((UInt32)(d) >>  8) & 0x0000FF00U) | \
376                  (((UInt32)(d) <<  8) & 0x00FF0000U) | \
377                  (((UInt32)(d) << 24) & 0xFF000000U)))
378
379#define _ByteSwap64(d) \
380  ((UInt64)((((UInt64)(d) >> 56) & 0x00000000000000FFULL) | \
381      (((UInt64)(d) >> 40) & 0x000000000000FF00ULL) | \
382      (((UInt64)(d) >> 24) & 0x0000000000FF0000ULL) | \
383      (((UInt64)(d) >>  8) & 0x00000000FF000000ULL) | \
384      (((UInt64)(d) <<  8) & 0x000000FF00000000ULL) | \
385      (((UInt64)(d) << 24) & 0x0000FF0000000000ULL) | \
386      (((UInt64)(d) << 40) & 0x00FF000000000000ULL) | \
387      (((UInt64)(d) << 56) & 0xFF00000000000000ULL)))   
388
389
390/* Include platform specific types */
391#include <cxiTypes-plat.h>
392
393/* Macros to be used when switching data from big endian to
394 * the endian-ness of the CPU
395 */
396#ifdef GPFS_LITTLE_ENDIAN
397#define BigEndToCPU16(d)  ByteSwap16(d)
398#define BigEndToCPU32(d)  ByteSwap32(d)
399#define BigEndToCPU64(d)  ByteSwap64(d)
400#define CPUToBigEnd16(d)  ByteSwap16(d)
401#define CPUToBigEnd32(d)  ByteSwap32(d)
402#define CPUToBigEnd64(d)  ByteSwap64(d)
403#else
404#define BigEndToCPU16(d)  (d)
405#define BigEndToCPU32(d)  (d)
406#define BigEndToCPU64(d)  (d)
407#define CPUToBigEnd16(d)  (d)
408#define CPUToBigEnd32(d)  (d)
409#define CPUToBigEnd64(d)  (d)
410#endif
411
412/* Macros to get the endian-ness and word size of this CPU */
413#ifdef GPFS_LITTLE_ENDIAN
414#define NodeBigEndian false
415#else
416#define NodeBigEndian true
417#endif
418
419typedef enum {
420  OSTYPE_AIX,
421  OSTYPE_LINUX
422} OSType;
423
424#define ostypeToStr(T) \
425  (((T) == OSTYPE_AIX)    ? "AIX"    : \
426   ((T) == OSTYPE_LINUX ) ? "Linux"  : \
427                            "unknown")
428
429#ifdef GPFS_LINUX
430#define NodeOperatingSystem OSTYPE_LINUX
431#else
432#define NodeOperatingSystem OSTYPE_AIX
433#endif
434
435#ifdef __64BIT__
436#define NodeWordSize 64
437#else
438#define NodeWordSize 32
439#endif
440
441/* Retrieve the file type from the mode and translate it to cxiNodeType_t */
442#define CXIMODE_TO_NODETYPE(M) (modeToNodeType[((M) & S_IFMT) >> 12])
443
444/* Invariant size time structure. */
445typedef struct cxiTimeStruc32_t
446{
447  cxiTime32_t tv_sec;   /* seconds */
448  cxiNSec32_t tv_nsec;  /* nanoseconds */
449} cxiTimeStruc32_t;
450
451/* May be 32/64 bit specific depending on how OS defines
452 * cxiTime_t (cxiTypes-plat.h).  On AIX cxiTime_t (time_t) is
453 * an int32long64 and cxiNSec_t (suseconds_t) is a signed int.
454 * Nanoseconds can always be represented within 32 bits, however
455 * on linux it's a long int, which would change size for 64bits.
456 */
457typedef struct cxiTimeStruc_t
458{
459  cxiTime_t tv_sec;    /* seconds */
460  cxiNSec_t tv_nsec;   /* nanoseconds */
461} cxiTimeStruc_t;
462
463/* Must match struct vattr on AIX */
464typedef struct cxiVattr_t
465{
466  int            va_type;       /* vnode type */
467  cxiMode_t      va_mode;       /* access mode */
468  cxiUid_t       va_uid;        /* owner uid */
469  cxiGid_t       va_gid;        /* owner gid */
470  union
471  {
472    cxiDev_t    _va_dev;        /* id of device containing file */
473    long        _va_fsid;       /* fs id (dev for now) */
474  } _vattr_union;
475  cxiInoSys_t    va_serialno;   /* file serial (inode) number */
476  short          va_nlink;      /* number of links */
477  short          va_flags;      /* Flags, see below for define */
478  long           va_mask;       /* Initial attribute mask */
479  cxiOff64_t     va_size;       /* file size in bytes */
480  long           va_blocksize;  /* preferred blocksize for io */
481  long           va_blocks;     /* kbytes of disk held by file */
482
483  /* The following three fields use the 32/64 bit dependent
484   * cxiTimeStruc_t since the AIX vattr structure defines these
485   * with timestruc_t which has time_t field.
486   */
487  cxiTimeStruc_t va_atime;      /* time of last access */
488  cxiTimeStruc_t va_mtime;      /* time of last data modification */
489  cxiTimeStruc_t va_ctime;      /* time of last status change */
490  cxiDev_t       va_rdev; /* id of device */
491
492  /* Fields added for compatability with the fullstat structure */
493  long           va_nid;        /* unused (node id on AIX) */
494  int            va_chan;       /* unused (channel on AIX) */
495  char          *va_acl;        /* unused (Access Control List on AIX) */
496  cxiSize_t      va_xinfo;      /* Extended info field (defined below)
497                                   (AIX: cxiSize_t va_aclsiz (size of ACL)) */
498  int            va_gen;        /* inode generation number */
499} cxiVattr_t;
500
501/* Define bit flags for the extended information field */
502#define VA_XPERM 0x0001         // file has extended ACL
503#define VA_XVOL  0x0002         // dir entry was generated and is volatile
504 
505/* Macros to recognize artificial, unique inode numbers for snapshot link
506   direcories and snapshot root directories. */
507#define SNAPROOTDIR_EXT_INO_BASE 0xFFFF0000
508#define IS_SNAPROOTDIR_EXT_INO(ino) ((UInt32)(ino) >  SNAPROOTDIR_EXT_INO_BASE)
509#define IS_SNAPLINKDIR_EXT_INO(ino) ((UInt32)(ino) == SNAPROOTDIR_EXT_INO_BASE)
510#define SNAPROOTDIR_INT_INO (3)
511
512#ifdef va_dev
513#undef va_dev
514#endif
515#ifdef va_fsid
516#undef va_fsid
517#endif
518#define va_dev   _vattr_union._va_dev
519#define va_fsid  _vattr_union._va_fsid
520
521/* Based on the AIX definition */
522typedef struct cxiIovec_t
523{
524  char     *iov_base;
525  cxiSize_t iov_len;
526} cxiIovec_t;
527
528typedef struct cxiErrorLogEntry_t
529{
530  short logErrorType;       /* One of the values #defined below */
531
532  /*   Fields common for all types of errors   */
533  UInt32 logRecTag;         /* Tag to associate related log entries */
534  char *componentName;      /* Name of the malfunctioning component */
535  char *componentID;
536  char *buildBranch;
537
538  /*  Fields used by logMoreInfo, logGenIF, logShutdownIF    */
539  char *strFileName;        /* File in which the error occurred */
540  UInt32 srcLineNumber;     /* Line on which the error occurred */
541  Int32 retCode;            /* return code value */
542  Int32 reasonCode;         /* reason code value */
543  char *dataStr;            /* Data dump string */
544  char *failingExpr;        /* Expression that evaluates to false */
545
546  /*   Fields used by LOGSPECIFIC   */
547  UInt32 logTemplID;        /* Error log template ID (used in AIX only) */
548  char *formatStr;          /* printf-style format string */
549  void *varargPtrPtr;       /* Pointer to the variable argument list
550             (will be casted to va_list *)           */
551
552  char *kernData;           /* Used for copying the logRecData field of the logging
553                               kernel mailbox   */
554  int kernDataLength;       /* = logRecDataLen */
555
556  char *moduleVersion;      /* Used only for logging from external progsams */
557} cxiErrorLogEntry_t;
558
559#ifdef SMB_LOCKS
560/* Enumeration used to specify whether a file will be read or written. */
561enum AccessMode
562{
563  opAccessNone  = 0,
564  opAccessRead  = 1,
565  opAccessWrite = 2
566};
567
568/* types of oplocks granted to Samba */
569enum OplockMode
570{
571  smbOplockNone  = 0,
572  smbOplockShared  = 1,
573  smbOplockExclusive = 2
574};
575
576/* Check whether oplock olm is in conflict with lock access am:
577   A conflict exists if one of the two is for write/exlucisve and the
578   other one is at least for read/shared. */
579#define oplockAccessConflict(olm, am) ((int)(olm) + (int)(am) > 2)
580#endif
581
582#ifdef CCL
583/* Types of dentry operations tables that can be requested. */
584typedef enum DentryOpTableTypes
585{
586  DOpNormal,
587  DOpOnlyValidIfSamba,
588  DOpInvalidIfSamba
589} DentryOpTableTypes;
590#endif
591
592#define LOG_ERR_SPECIFIC    0x1
593#define LOG_ERR_GENERIC     0x2
594#define LOG_ERR_MOREINFO    0x3
595#define LOG_ERR_SHUTDOWN    0x4
596#define LOG_ERR_TRACEBACK   0x5
597#define LOG_ERR_SPECIFIC_KERN  0x6
598
599
600/* Common part of information about an open file */
601typedef struct cxiVinfo_t
602{
603  cBoolean viInUse;      /* True if VInfo is in use by an open file */
604  cBoolean disconnected; /* True if the daemon died or a forced unmount or
605                            SG panic occurred since the file was opened */
606  cBoolean viIsNFS;      /* True if this cxiVinfo_t is embedded inside a
607                            struct NFSData */
608  cBoolean rwPageDone;   /* True if paging requests received */
609} cxiVinfo_t;
610
611
612#ifdef _KERNEL
613#ifdef __cplusplus
614extern "C" {
615#endif
616/* Function pointer for main routine of a kernel process */
617typedef void (*cxiKProcFunc_t)(void *argP);
618#ifdef __cplusplus
619}
620#endif
621
622/* Interface structure to cxiStartKProc() and cxiStopKProc() */
623typedef struct cxiKProcData_t
624{
625  cxiPid_t pid;        /* proc pid (returned) */
626
627  /* protects startStopEvent and kprocEvent transitions */
628  cxiBlockingMutex_t lock;
629
630  /* kproc can sleep here */
631  cxiWaitEvent_t kprocEvent;
632
633  /* start or stop request should sleep here waiting on pid transition */
634  cxiWaitEvent_t startStopEvent; 
635
636  int priority;        /* process priority of kproc */
637  int kprocFlags;      /* flags to pass to kernel thread creation routine */
638  Boolean terminate;   /* terminate proc when true */
639  cxiKProcFunc_t func; /* proc function */
640  void *fargP;         /* proc function arguments */
641  char *nameP;         /* proc name */
642  char *systemP;       /* any system data structure associated with process */
643} cxiKProcData_t;
644
645#define KPROC_FAILED_PID      -1
646#define KPROC_UNASSIGNED_PID  -2
647#define KPROC_RUNNING(KP)     ((KP)->pid > 0)
648#endif /* _KERNEL */
649
650/* Macros to do multiplication, division, and modulo by numbers that
651   are probably powers of two.  Depending on which define is set, the
652   operations can be performed using the built-in operators /, *, and %,
653   or using shifts and masks.  The _shift parameter of the macros should
654   be log base 2 of _divisor or _multiplier, or 0 if _divisor or
655   _multiplier is not a power of 2.  If POW2_COND_SHIFT is defined, the
656   generated code will test _shift for 0, then do either a shift or the
657   general operation.  If POW2_FORCE_SHIFT is defined, the generated
658   code will always use shifts.  This requires that the subblock size of
659   the file system actually be a power of 2.  If neither POW2_COND_SHIFT
660   nor POW2_FORCE_SHIFT are defined, the generated code will use the
661   general operations (/, *, or %). */
662#if defined(POW2_FORCE_SHIFT)
663# define MULT_OR_SHIFT(_multiplicand, _multiplier, _shift)   \
664     ((_multiplicand)<<(_shift))
665# define DIV_OR_SHIFT(_dividend, _divisor, _shift)           \
666     ((_dividend)>>(_shift))
667# define MOD_OR_MASK(_dividend, _divisor, _shift)            \
668     ((_dividend) & ((1<<(_shift)) - 1))
669#elif defined(POW2_COND_SHIFT)
670# define MULT_OR_SHIFT(_multiplicand, _multiplier, _shift)   \
671   ( ((_shift)!=0) ?                                         \
672       (_multiplicand) << (_shift) :                         \
673       ((_multiplicand)*(_multiplier)) )
674# define DIV_OR_SHIFT(_dividend, _divisor, _shift)           \
675   ( ((_shift)!=0) ?                                         \
676       (_dividend) >> (_shift) :                             \
677       ((_dividend)/(_divisor)) )
678# define MOD_OR_MASK(_dividend, _divisor, _shift)            \
679   ( ((_shift)!=0) ?                                         \
680       (_dividend) & ((1<<(_shift)) - 1) :                   \
681       ((_dividend)%(_divisor)) )
682#else
683# define MULT_OR_SHIFT(_multiplicand, _multiplier, _shift)   \
684     ((_multiplicand)*(_multiplier))
685# define DIV_OR_SHIFT(_dividend, _divisor, _shift)           \
686     ((_dividend)/(_divisor))
687# define MOD_OR_MASK(_dividend, _divisor, _shift)            \
688     ((_dividend)%(_divisor))
689#endif
690
691/* Memory copy macros that use memcpy when aligned data accesses
692   are necessary, and standard pointer typecast copying otherwise. */
693#ifdef ALIGNED_DATA_ACCESS
694#define MCPY(DEST, SRC, TYPE)  memcpy((void*) DEST, (void*) SRC, sizeof(TYPE));
695#define MCPY_SRCVAR(DEST, SRCVAR, TYPE)  memcpy((void*) DEST, (void*) &SRCVAR, sizeof(TYPE));
696#define MCPY_DESTVAR(DESTVAR, SRC, TYPE)  memcpy((void*) &DESTVAR, (void*) SRC, sizeof(TYPE));
697#define MCPY_VAR(DEST, SRC, TYPE)  memcpy((void*) &DEST, (void*) &SRC, sizeof(TYPE));
698#else
699#define MCPY(DEST, SRC, TYPE)  *((TYPE *)DEST) = *((TYPE *)SRC);
700#define MCPY_SRCVAR(DEST, SRCVAR, TYPE)  *((TYPE *)DEST) = SRCVAR;
701#define MCPY_DESTVAR(DESTVAR, SRC, TYPE) DESTVAR = *((TYPE *)SRC);
702#define MCPY_VAR(DEST, SRC, TYPE) DEST = SRC;
703#endif /* ALIGNED_DATA_ACCESS */
704
705/* Flag values for cxiNode_t::icValid:
706   Indicates whether inode attributes cached in the osNode (struct inode
707   in Linux) are known to be valid. */
708#define CXI_IC_PERM   0x00000001  /* permission related inode fields (owner,
709                                     mode, acl, etc) are valid */
710#define CXI_IC_ATTR   0x00000002  /* other inode fields are valid */
711
712/* combinations of bits defined above: */
713#define CXI_IC_STAT   0x00000003  /* what needs to be valid for stat() */
714#define CXI_IC_ALL    0x00000003  /* OR of all flags above */
715
716typedef Int32 DiskNum_t;
717typedef Int64 SectorNum_t;
718typedef Int32 SectorNumHigh_t;
719typedef UInt32 SectorNumLow_t;
720typedef Int64 BlkNum_t;
721#define DiskSizeInit MAX_INT64
722
723#ifndef INODENUM_ROOTDIR_FILE
724/* Definition needed in portability layer */
725#define INODENUM_ROOTDIR_FILE 3
726#endif
727
728#ifdef GPFS_LINUX
729#define THROWEMPTY throw()
730#else
731#define THROWEMPTY
732#endif
733
734#endif  /* _h_cxiTypes */
Note: See TracBrowser for help on using the repository browser.