| 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 | /* @(#)68 1.51 src/avs/fs/mmfs/ts/kernext/ibm-kxi/cxiTSFattr.h, mmfs, avs_rgpfs24, rgpfs24s003a 5/8/06 15:23:39 */ |
|---|
| 34 | |
|---|
| 35 | #ifndef _h_cxitsfattr |
|---|
| 36 | #define _h_cxitsfattr |
|---|
| 37 | |
|---|
| 38 | #include <cxiTypes.h> |
|---|
| 39 | |
|---|
| 40 | /* defines for command parameter in tsfattr() */ |
|---|
| 41 | #define SET_BUFFERING 10 |
|---|
| 42 | #define GET_BUFFERING 11 |
|---|
| 43 | #define LIST_XATTR 12 |
|---|
| 44 | #define GET_XATTR 13 |
|---|
| 45 | #define SET_XATTR 14 |
|---|
| 46 | #define GPFS_STATFSPOOL 15 |
|---|
| 47 | #define GPFS_GETPOOLNAME 16 |
|---|
| 48 | /* #define GET_REPL_FACTORS 20 deprecated -- use gpfs_fcntl */ |
|---|
| 49 | /* #define SET_REPL_FACTORS 21 deprecated -- use gpfs_fcntl */ |
|---|
| 50 | #define REMOTE_STAT 22 |
|---|
| 51 | #define IO_HINTS 24 |
|---|
| 52 | #define PREALLOCATE_FILE 25 |
|---|
| 53 | #define GET_ALL_ATTRS 27 |
|---|
| 54 | #define PUT_ALL_ATTRS 28 |
|---|
| 55 | #define PUT_ALL_ATTRS_WITH_NAME 29 |
|---|
| 56 | |
|---|
| 57 | #define PRIVILEGED_OPERATIONS 31 /* must be privileged user for operations |
|---|
| 58 | bigger than PRIVILEGED_OPERATIONS */ |
|---|
| 59 | |
|---|
| 60 | #define GET_INODE_BLOCK 32 |
|---|
| 61 | #define GET_DIR_BLOCK 33 |
|---|
| 62 | #define SET_DIR_ENTRY 34 |
|---|
| 63 | #define GPFS_IOPEN 35 |
|---|
| 64 | #define GPFS_ICLOSE 36 |
|---|
| 65 | #define GPFS_IREAD 37 |
|---|
| 66 | #define GPFS_IWRITE 38 |
|---|
| 67 | #define GPFS_IREAD_SYMLINK 39 |
|---|
| 68 | #define GPFS_IGET_ATTRS 40 |
|---|
| 69 | #define GPFS_IPUT_ATTRS 41 |
|---|
| 70 | /* #define UNUSED 42 */ |
|---|
| 71 | #define GPFS_SYNC_FS 43 |
|---|
| 72 | #define GPFS_START_RESTORE 44 |
|---|
| 73 | #define GPFS_END_RESTORE 45 |
|---|
| 74 | #define GPFS_FS_RESTORABLE 46 |
|---|
| 75 | #define GPFS_IGET_FILESET 47 |
|---|
| 76 | #define GPFS_IGET_STORAGEPOOL 48 |
|---|
| 77 | #define GPFS_IREADX 49 |
|---|
| 78 | #define GPFS_IWRITEX 50 |
|---|
| 79 | #define GPFS_OPEN_FSSNAPHANDLE 51 |
|---|
| 80 | |
|---|
| 81 | /* define KERNEL_LOGGENERIC 97 Defined in tsfattrx.h */ |
|---|
| 82 | /* define KERNEL_LOGSPECIFIC 98 Defined in tsfattrx.h */ |
|---|
| 83 | /* define TEST_LOCK_PERF 99 Defined in tsfattrx.h */ |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | /* If you add a new tsfattr command, also update trcfmt.common */ |
|---|
| 87 | #define tsfattrcmd_id2name(s) ((int)(s)) |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | /* defines for command parameter in tsfsattr() */ |
|---|
| 91 | /*define PRIVILEGED_OPERATIONS 30 must be privileged user for operations |
|---|
| 92 | bigger than PRIVILEGED_OPERATIONS */ |
|---|
| 93 | #define GPFS_FSATTR_HANDLE_VIA_NAME 30 |
|---|
| 94 | #define GPFS_FSATTR_HANDLE_VIA_ID 31 |
|---|
| 95 | #define GPFS_FSATTR_PATH_VIA_HANDLE 32 |
|---|
| 96 | #define GPFS_FSATTR_FSNAME_VIA_HANDLE 33 |
|---|
| 97 | #define GPFS_FSATTR_SNAPNAME_VIA_HANDLE 34 |
|---|
| 98 | #define GPFS_FSATTR_RESTORE_FSSNAPID_VIA_HANDLE 35 |
|---|
| 99 | #define GPFS_FSATTR_GET_SNAPDIRNAME 36 |
|---|
| 100 | |
|---|
| 101 | /* If you add a new tsfsattr command, also update trcfmt.common */ |
|---|
| 102 | #define tsfsattrcmd_id2name(s) ((int)(s)) |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | /* Structure used to receive additional information regarding |
|---|
| 107 | operation failures. */ |
|---|
| 108 | typedef struct |
|---|
| 109 | { |
|---|
| 110 | int reason; /* reason request failed */ |
|---|
| 111 | int value1; /* optional value depending upon reason */ |
|---|
| 112 | int value2; /* optional value depending upon reason */ |
|---|
| 113 | } tsfattrReasonCodeInfo; |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | /* Structure used to pass FILE_PREALLOCATION information */ |
|---|
| 118 | struct filePreallocation |
|---|
| 119 | { |
|---|
| 120 | long long offset; /* in - offset to start preallocation from */ |
|---|
| 121 | long long size; /* in - size of preallocation */ |
|---|
| 122 | int flags; /* in - write flags */ |
|---|
| 123 | }; |
|---|
| 124 | |
|---|
| 125 | /* Structure used to pass parameters for GET_ALL_ATTRS and PUT_ALL_ATTRS |
|---|
| 126 | functions. For PUT_ALL_ATTRS_WITH_NAME, the attrSizeP points to the |
|---|
| 127 | pathName or NULL. */ |
|---|
| 128 | struct xattrsparms |
|---|
| 129 | { |
|---|
| 130 | int flags; /* in - flags (must be zero, reserved for future use) */ |
|---|
| 131 | void *bufferP; /* in - address of buffer containing or receiving |
|---|
| 132 | attribute data */ |
|---|
| 133 | int bufferSize; /* in - size of the buffer (not used by PUT_ALL_ATTRS) */ |
|---|
| 134 | int *attrSizeP; /* in - address where to return actual size of the data |
|---|
| 135 | (not used by PUT_ALL_ATTRS) */ |
|---|
| 136 | }; |
|---|
| 137 | |
|---|
| 138 | /* Interface structures for gpfsStatFsPool() */ |
|---|
| 139 | typedef struct |
|---|
| 140 | { |
|---|
| 141 | UInt64 f_blocks; /* total data blocks in pool */ |
|---|
| 142 | UInt64 f_bfree; /* free blocks in pool */ |
|---|
| 143 | UInt64 f_bavail; /* free blocks avail to non-superuser */ |
|---|
| 144 | UInt64 f_mblocks; /* total metadata blocks in pool */ |
|---|
| 145 | UInt64 f_mfree; /* free blocks avail for system metadata */ |
|---|
| 146 | int f_bsize; /* optimal storage pool block size */ |
|---|
| 147 | int f_files; /* total file nodes assigned to pool */ |
|---|
| 148 | UInt32 f_poolid; /* storage pool id */ |
|---|
| 149 | int f_fsize; /* fundamental file system block size */ |
|---|
| 150 | unsigned int f_usage; /* data and/or metadata stored in pool */ |
|---|
| 151 | int f_reserved[7];/* currently unused and set to zero */ |
|---|
| 152 | } cxiStatFsPool_t; |
|---|
| 153 | |
|---|
| 154 | typedef struct |
|---|
| 155 | { |
|---|
| 156 | UInt32 poolId; |
|---|
| 157 | UInt32 options; |
|---|
| 158 | int nPools; |
|---|
| 159 | int bufferSize; |
|---|
| 160 | char *bufferP; |
|---|
| 161 | } cxiStatFsPoolArgs_t; |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | /* Definitions for GPFS file attribute function */ |
|---|
| 167 | |
|---|
| 168 | #ifdef __cplusplus |
|---|
| 169 | extern "C" |
|---|
| 170 | { |
|---|
| 171 | #endif |
|---|
| 172 | |
|---|
| 173 | extern int tsfattr(int fileDesc, /* Open file descriptor */ |
|---|
| 174 | int command, /* Control function to be performed */ |
|---|
| 175 | void *argP, /* Additional info required by function */ |
|---|
| 176 | tsfattrReasonCodeInfo *rCodeP); /* More returned info*/ |
|---|
| 177 | |
|---|
| 178 | extern int tsfsattr(int command, /* Control function to be performed */ |
|---|
| 179 | void *argP); /* Additional info required by function */ |
|---|
| 180 | |
|---|
| 181 | /* The tsattr call only supports the following commands: |
|---|
| 182 | GET_REPL_FACTORS |
|---|
| 183 | */ |
|---|
| 184 | extern int tsattr(char *pathname, /* File pathname */ |
|---|
| 185 | int command, /* Control function to be performed */ |
|---|
| 186 | void *argP, /* Additional info required by function */ |
|---|
| 187 | tsfattrReasonCodeInfo *rCodeP); /* More returned info*/ |
|---|
| 188 | |
|---|
| 189 | /* Define type used to identify a file system. Internally, this is |
|---|
| 190 | actually a DiskUID. Assignments to and from this id must be cast |
|---|
| 191 | as DiskUIDs to generate the correct byte-swapping code. */ |
|---|
| 192 | typedef struct _gpfs_fs_id |
|---|
| 193 | { |
|---|
| 194 | BigEndUInt32 word0; |
|---|
| 195 | BigEndUInt32 word1; |
|---|
| 196 | } _gpfs_fs_id_t; |
|---|
| 197 | |
|---|
| 198 | /* Structure used to hold snapshot id max size is 48 see gpfs_snap_id_t in |
|---|
| 199 | gpfs.h. Note that the "_gpfs" prefix is used for an internal definition |
|---|
| 200 | of an externally defined structure. */ |
|---|
| 201 | #define FSSNAPID_MAGIC 0xD00FF009 |
|---|
| 202 | #define ISCAN_VERSION 1 |
|---|
| 203 | |
|---|
| 204 | typedef struct _gpfs_fssnap_id |
|---|
| 205 | { |
|---|
| 206 | BigEndInt32 magic; /* magic number */ |
|---|
| 207 | BigEndInt32 fmtVersion; /* version from curFmtVersion */ |
|---|
| 208 | BigEndInt64 snapId; /* snapshot id */ |
|---|
| 209 | BigEndInt64 baseSnapId; /* base id for snapshot */ |
|---|
| 210 | _gpfs_fs_id_t stripeId; /* FS id assigned at format time */ |
|---|
| 211 | _gpfs_fs_id_t baseStripeId; /* base FS id for snapshot */ |
|---|
| 212 | BigEndInt64 time; /* time stamp (just second) */ |
|---|
| 213 | } _gpfs_fssnap_id_t; |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | /* Structure used to identify file system and snapshot |
|---|
| 217 | Note "_gpfs" is used for the internal version of an externally |
|---|
| 218 | defined type. */ |
|---|
| 219 | #define FSSNAPHANDLE_MAGIC 0xD00FF013 |
|---|
| 220 | typedef struct _gpfs_fssnap_handle |
|---|
| 221 | { |
|---|
| 222 | int magic; /* magic number */ |
|---|
| 223 | int fd; /* file descriptor */ |
|---|
| 224 | _gpfs_fssnap_id_t fssnapId; /* unique fs/snapshot id */ |
|---|
| 225 | cxiIno_t maxIno; /* maximum inode number */ |
|---|
| 226 | int blockSize; /* block size used by fs */ |
|---|
| 227 | int pathNameSize; /* size of path buffer */ |
|---|
| 228 | char *pathNameP; /* path buffer */ |
|---|
| 229 | int fsNameSize; /* size of fsName buffer */ |
|---|
| 230 | char *fsNameP; /* fsName buffer */ |
|---|
| 231 | int snapNameSize; /* size of snapName buffer */ |
|---|
| 232 | char *snapNameP; /* snapName buffer */ |
|---|
| 233 | } _gpfs_fssnap_handle_t; |
|---|
| 234 | |
|---|
| 235 | /* Structure used to keep restore session information. */ |
|---|
| 236 | #define RESTORE_MAGIC 0xD00FF015 |
|---|
| 237 | typedef struct _gpfs_restore |
|---|
| 238 | { |
|---|
| 239 | int magic; /* magic number */ |
|---|
| 240 | int fd; /* file descriptor */ |
|---|
| 241 | _gpfs_fssnap_id_t old_fssnapId; /* id for last snapshot */ |
|---|
| 242 | _gpfs_fssnap_id_t new_fssnapId; /* id for new snapshot */ |
|---|
| 243 | } _gpfs_restore_t; |
|---|
| 244 | |
|---|
| 245 | /* Define a structure used to pass control information |
|---|
| 246 | for the restore start/end code. This structure is |
|---|
| 247 | internal to gpfs and not returned to the users. */ |
|---|
| 248 | typedef struct gpfs_rcontrol |
|---|
| 249 | { |
|---|
| 250 | int flags; /* restore flags */ |
|---|
| 251 | #define RESTORE_START 0x00000001 |
|---|
| 252 | #define RESTORE_END 0x00000002 |
|---|
| 253 | #define RESTORE_ENABLE 0x00000010 |
|---|
| 254 | #define RESTORE_DISABLE 0x10000000 |
|---|
| 255 | |
|---|
| 256 | Int32 fmtVersion; /* version from curFmtVersion */ |
|---|
| 257 | Int64 snapId; /* snapshot id */ |
|---|
| 258 | _gpfs_fs_id_t stripeId;/* FS id assigned at format time */ |
|---|
| 259 | Int64 time; /* time stamp (just second) */ |
|---|
| 260 | } gpfs_rcontrol_t; |
|---|
| 261 | |
|---|
| 262 | /* Structure used to read a block of gpfs_iattr_t with the tsfattr commmand |
|---|
| 263 | GET_INODE_BLOCK */ |
|---|
| 264 | #define ISCAN_MAGIC 0xD00FF005 |
|---|
| 265 | typedef struct _gpfs_iscan |
|---|
| 266 | { |
|---|
| 267 | int magic; /* magic number */ |
|---|
| 268 | int fd; /* file descriptor */ |
|---|
| 269 | Int64 instanceID; /* instance identifier */ |
|---|
| 270 | long nextInode; /* next Inode to read */ |
|---|
| 271 | long termInode; /* terminate before this ino */ |
|---|
| 272 | long bufferSize; /* size of buffer */ |
|---|
| 273 | char *bufferP; /* block of gpfs_iattr_t */ |
|---|
| 274 | long lastOffset; /* offset of last item */ |
|---|
| 275 | long offset; /* used by caller only */ |
|---|
| 276 | _gpfs_fssnap_id_t old_fssnapId; /* snapId for last snapshot */ |
|---|
| 277 | _gpfs_fssnap_id_t new_fssnapId; /* snapId for new snapshot */ |
|---|
| 278 | UInt32 cachedFilesetId; /* id of cached fileset name */ |
|---|
| 279 | int cachedFilesetNameLen; /* length of cached fileset name */ |
|---|
| 280 | char *cachedFilesetNameP; /* pointer to cached fileset name */ |
|---|
| 281 | UInt32 cachedDataPoolId; /* id of cached storage pool name */ |
|---|
| 282 | int cachedDataPoolNameLen; /* length of cached storage pool name */ |
|---|
| 283 | char *cachedDataPoolNameP; /* pointer to cached storage pool name */ |
|---|
| 284 | } _gpfs_iscan_t; |
|---|
| 285 | |
|---|
| 286 | #define CXI_INVALID_FILESET_ID ((UInt32) -1) /* cached value */ |
|---|
| 287 | #define CXI_INVALID_STORAGEPOOL_ID ((UInt32) -1) /* is invalid */ |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | /* Define internal structure used for block level incremental reads. |
|---|
| 291 | Each call to gpfs_ireadx() returns an array of changes between |
|---|
| 292 | the scanned file and its previous snapshot version. */ |
|---|
| 293 | typedef struct gpfs_idelta |
|---|
| 294 | { |
|---|
| 295 | int hole; /* =0 if data changed in the following range |
|---|
| 296 | =1 if a hole was created in that range */ |
|---|
| 297 | Int64 startOffset; /* byte offset to start of change */ |
|---|
| 298 | Int64 endOffset; /* offset at end of changed region */ |
|---|
| 299 | } gpfs_idelta_t; |
|---|
| 300 | |
|---|
| 301 | /* Structure used to pass extended attribute information |
|---|
| 302 | for GET_XATTR and SET_XATTR */ |
|---|
| 303 | struct tsxattrs |
|---|
| 304 | { |
|---|
| 305 | int appId; /* application id */ |
|---|
| 306 | int nattrs; /* no of attributes to get or set */ |
|---|
| 307 | struct tsxattr *attrs; /* attributes to get or set */ |
|---|
| 308 | }; |
|---|
| 309 | |
|---|
| 310 | /* If this is modified, also make corresponding changes to |
|---|
| 311 | tsxattrMB, which is used in mailbox communication */ |
|---|
| 312 | struct tsxattr |
|---|
| 313 | { |
|---|
| 314 | char *keyP; /* attribute key */ |
|---|
| 315 | int keyLen; /* key length */ |
|---|
| 316 | char *valueP; /* attribute value */ |
|---|
| 317 | int valueLen; /* length of attribute value */ |
|---|
| 318 | }; |
|---|
| 319 | |
|---|
| 320 | /* Structure used to read/write by inode number. */ |
|---|
| 321 | #define IFILE_MAGIC 0xD00FF011 |
|---|
| 322 | #define DIRX_BUFFER_SIZE (16*1024) |
|---|
| 323 | #define DELTA_BUFFER_SIZE (sizeof(gpfs_idelta_t) * 128) |
|---|
| 324 | #define MAX_FILE_OFFSET MAX_INT64 |
|---|
| 325 | |
|---|
| 326 | typedef struct _gpfs_ifile |
|---|
| 327 | { |
|---|
| 328 | int magic; /* magic number */ |
|---|
| 329 | int fd; /* file descriptor for root */ |
|---|
| 330 | long ino; /* inode number */ |
|---|
| 331 | int genNo; /* inode generation number */ |
|---|
| 332 | Int64 snapId; /* snapshot ID */ |
|---|
| 333 | int open_flags; /* open flags */ |
|---|
| 334 | cxiMode_t mode; /* mode of file being read */ |
|---|
| 335 | const char *symlinkP; /* optional symlink */ |
|---|
| 336 | char *bufferP; /* buffer for read/write */ |
|---|
| 337 | long bufferSize; /* size of buffer */ |
|---|
| 338 | Int64 offset; /* offset to read/write from */ |
|---|
| 339 | Int64 count; /* length to read/write */ |
|---|
| 340 | int dirCount; /* number of directory entries*/ |
|---|
| 341 | char *dirBufferP; /* buffer for directory read */ |
|---|
| 342 | long dirBufferSize; /* size of dir buffer */ |
|---|
| 343 | offset_t dirOffset; /* offset in directory buffer */ |
|---|
| 344 | offset_t lastOffset; /* offset of last item */ |
|---|
| 345 | struct gpfs_iattr *statxP; /* optional for open/create */ |
|---|
| 346 | void *vP; /* inode/vnode (OS dependent) |
|---|
| 347 | NOTE: This value cannot be trusted |
|---|
| 348 | between calls to the kernel. */ |
|---|
| 349 | int *attrSizeP; /* ptr to rtnd value for iget_attrs */ |
|---|
| 350 | |
|---|
| 351 | /* Define fields for block-level incremental read/write */ |
|---|
| 352 | Int64 prevSnapId; /* prev snapId */ |
|---|
| 353 | _gpfs_fs_id_t prevStripeId; /* prev stripeId */ |
|---|
| 354 | int hole; /* read/write a hole */ |
|---|
| 355 | int callBlockLevel; /* if >=0 then call ireadx |
|---|
| 356 | if < 0 then call iread */ |
|---|
| 357 | Int64 fileSize; /* size of file when reading deltas */ |
|---|
| 358 | Int64 firstOffset; /* start of range covered by deltas */ |
|---|
| 359 | Int64 nextOffset; /* in: limit on single ireadx |
|---|
| 360 | out: next offset to read */ |
|---|
| 361 | } _gpfs_ifile_t; |
|---|
| 362 | |
|---|
| 363 | #ifdef __cplusplus |
|---|
| 364 | } |
|---|
| 365 | #endif |
|---|
| 366 | |
|---|
| 367 | int myFillDir(void *fillDirArgP, const char *nameP, int namlen, |
|---|
| 368 | offset_t offset, ino_t ino, cxiMode_t mode, int generation); |
|---|
| 369 | |
|---|
| 370 | #endif /* _h_cxitsfattr */ |
|---|