nfs-ganesha 1.4
|
00001 /* Copyright (C) 2001 International Business Machines 00002 * All rights reserved. 00003 * 00004 * This file is part of the GPFS user library. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 3. The name of the author may not be used to endorse or promote products 00016 * derived from this software without specific prior written 00017 * permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00020 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00021 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00022 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00023 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00025 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00026 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00027 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00028 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 * 00030 */ 00031 /* @(#)51 1.38 src/avs/fs/mmfs/ts/kernext/gpfs_fcntl.h, mmfs, avs_rhrz 1/27/12 09:58:58 */ 00032 00033 /* 00034 * GPFS interface definitions for supporting I/O hints and directives. 00035 * 00036 * Usage: The argument to gpfs_fcntl is composed of the concatenation of 00037 * structures defined in this file. The first structure must be of type 00038 * gpfsFcntlHeader_t. This is immediately followed by additional 00039 * structures, one for each hint or directive supplied. The totalLength 00040 * field of the header contains the length of all of the structures, 00041 * including the header itself. Each structure is defined to be a multiple 00042 * of 8 bytes in length, and the highest alignment requirement of any of the 00043 * data types is also 8 bytes, so the compiler will not insert padding when 00044 * several structures are declared within an outer structure. This makes 00045 * it easier to build up the necessary area before calling gpfs_fcntl. 00046 * 00047 * For example, the following code fragment first releases all cached data 00048 * held on behalf of a file, then tells GPFS that this node will write 00049 * the portion of the file with file offsets between 2G and 3G-1: 00050 * struct 00051 * { 00052 * gpfsFcntlHeader_t hdr; 00053 * gpfsClearFileCache_t rel; 00054 * gpfsAccessRange_t acc; 00055 * } arg; 00056 * 00057 * arg.hdr.totalLength = sizeof(arg); 00058 * arg.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION; 00059 * arg.hdr.fcntlReserved = 0; 00060 * arg.rel.structLen = sizeof(arg.rel); 00061 * arg.rel.structType = GPFS_CLEAR_FILE_CACHE; 00062 * arg.acc.structLen = sizeof(arg.acc); 00063 * arg.acc.structType = GPFS_ACCESS_RANGE; 00064 * arg.acc.start = 2LL * 1024LL * 1024LL * 1024LL; 00065 * arg.acc.length = 1024 * 1024 * 1024; 00066 * arg.acc.isWrite = 1; 00067 * rc = gpfs_fcntl(handle, &arg); 00068 * 00069 * If gpfs_fcntl returns an error (rc -1), errno will contain the error 00070 * reason, and the errorOffset field of the header will contain the offset 00071 * of the offending structure within the argument area. 00072 * 00073 * In general, the structures within the argument are processed in order, 00074 * except that data shipping directives are performed after all other hints 00075 * and directives. 00076 */ 00077 00078 #ifndef _h_gpfs_fcntl 00079 #define _h_gpfs_fcntl 00080 00081 /* open source interfaces */ 00082 #include <gpfs.h> 00083 00084 #ifdef __cplusplus 00085 extern "C" 00086 { 00087 #endif 00088 00089 /* Header of the parameter area passed to gpfs_fcntl */ 00090 typedef struct 00091 { 00092 int totalLength; /* length of this structure plus the sum of 00093 the lengths of all structures in this 00094 gpfs_fcntl argument */ 00095 int fcntlVersion; /* version number: GPFS_FCNTL_CURRENT_VERSION */ 00096 int errorOffset; /* Returned value giving offset into parameter 00097 area of the structure to which errno 00098 pertains. Only set if errno is set. */ 00099 int fcntlReserved; /* not used, should be set to 0 */ 00100 } gpfsFcntlHeader_t; 00101 00102 /* Moved it here from tshints.C, since function tschattr also uses it while 00103 * filling in errReason into argument structure. */ 00104 typedef struct 00105 { 00106 int structLen; /* length of the entire argument */ 00107 int structType; /* identifier of the hint */ 00108 } genericStruct_t; 00109 00110 00111 /* Interface version number (fcntlVersion field of gpfsFcntlHeader_t) */ 00112 #define GPFS_FCNTL_CURRENT_VERSION 1 00113 00114 /* Maximum length of argument to gpfs_fcntl */ 00115 #define GPFS_MAX_FCNTL_LENGTH 65536 00116 00117 /* Maximum length of a name arguement passed to or returned from gpfs_fcntl. 00118 Length of buffer must be a multiple of 8. */ 00119 #define GPFS_FCNTL_MAX_NAME_BUFFER 1024 00120 #define GPFS_FCNTL_MIN_NAME_BUFFER 8 00121 00122 00123 /* Definitions of structType fields for GPFS hints. Hints can be ignored 00124 by GPFS without affecting correct operation, although performance might 00125 suffer. */ 00126 #define GPFS_ACCESS_RANGE 1001 00127 #define GPFS_FREE_RANGE 1002 00128 #define GPFS_MULTIPLE_ACCESS_RANGE 1003 00129 #define GPFS_CLEAR_FILE_CACHE 1004 00130 00131 /* Definitions of structType fields for GPFS directives. GPFS must honor 00132 directives, or return an error saying why a directive could not be 00133 honored. */ 00134 #define GPFS_CANCEL_HINTS 2001 00135 #define GPFS_DATA_SHIP_START 2002 00136 #define GPFS_DATA_SHIP_MAP 2003 00137 #define GPFS_DATA_SHIP_STOP 2004 00138 #define GPFS_FCNTL_SET_REPLICATION 2005 00139 #define GPFS_FCNTL_SET_STORAGEPOOL 2006 00140 #define GPFS_FCNTL_RESTRIPE_DATA 2007 00141 #define GPFS_FCNTL_RESTRIPE_RANGE 2008 00142 00143 00144 /* Definitions of structType fileds for GPFS inquiries. Inquiries merely 00145 return GPFS attributes of existing files. */ 00146 #define GPFS_FCNTL_GET_REPLICATION 3001 00147 #define GPFS_FCNTL_GET_STORAGEPOOL 3002 00148 #define GPFS_FCNTL_GET_FILESETNAME 3003 00149 #define GPFS_FCNTL_GET_SNAPSHOTNAME 3004 00150 #define GPFS_FCNTL_GET_DATABLKDISKIDX 3005 00151 00152 00153 /* Structures for specifying the various gpfs_fnctl hints */ 00154 00155 /* Access range hint: The application will soon access file offsets within 00156 the given range, and will not access offsets outside the range. Violating 00157 this hint may produce worse performance than if no hint was specified. */ 00158 typedef struct 00159 { 00160 int structLen; /* length of this structure */ 00161 int structType; /* hint identifier: GPFS_ACCESS_RANGE */ 00162 long long start; /* start offset in bytes from beginning of file */ 00163 long long length; /* length of range; 0 indicates to end of file */ 00164 int isWrite; /* 0 - read access, 1 - write access */ 00165 char padding[4]; 00166 } gpfsAccessRange_t; 00167 00168 00169 /* Free range hint: the application will no longer access file offsets 00170 within the given range, so GPFS is free to flush those file offsets from 00171 its cache. */ 00172 typedef struct 00173 { 00174 int structLen; /* length of this structure */ 00175 int structType; /* hint identifier: GPFS_FREE_RANGE */ 00176 long long start; /* start offset in bytes from beginning of file */ 00177 long long length; /* length of range; 0 indicates to end of file */ 00178 } gpfsFreeRange_t; 00179 00180 00181 /* Format of accRangeArray and relRangeArray entries used by 00182 GPFS_MULTIPLE_ACCESS_RANGE hint */ 00183 typedef struct 00184 { 00185 long long blockNumber; /* data block number to access */ 00186 int start; /* start of range (from beginning of block) */ 00187 int length; /* number of bytes in the range */ 00188 int isWrite; /* 0 - read access, 1 - write access */ 00189 char padding[4]; 00190 } gpfsRangeArray_t; 00191 00192 /* Multiple access range hint: This hint is used to drive application-defined 00193 prefetching and writebehind. The application will soon access the 00194 portions of the blocks specified in accRangeArray, and has finished 00195 accessing the ranges listed in relRangeArray. The size of a block is 00196 returned by stat in the st_blksize field, so offset OFF of a file is in 00197 block OFF/st_blksize. Up to GPFS_MAX_RANGE_COUNT blocks may be given in 00198 one multiple access range hint. Depending on the current load, GPFS may 00199 initiate prefetching of some or all of these. Each range named in 00200 accRangeArray that is accepted for prefetching should eventually be 00201 released via relRangeArray, or else GPFS will stop prefetching blocks 00202 for this file. */ 00203 #define GPFS_MAX_RANGE_COUNT 8 00204 typedef struct 00205 { 00206 int structLen; /* length of this structure */ 00207 int structType; /* hint identifier: GPFS_MULTIPLE_ACCESS_RANGE */ 00208 int accRangeCnt; /* on input, number of ranges in accRangeArray 00209 on output, number of processed ranges (the 00210 first n of the given ranges) */ 00211 int relRangeCnt; /* number of ranges in relRangeArray */ 00212 gpfsRangeArray_t accRangeArray[GPFS_MAX_RANGE_COUNT]; /* requested ranges */ 00213 gpfsRangeArray_t relRangeArray[GPFS_MAX_RANGE_COUNT]; /* ranges to release */ 00214 } gpfsMultipleAccessRange_t; 00215 00216 00217 /* Clear file cache hint: the application expects to no longer access any 00218 portion of the file, so GPFS should flush and invalidate any cached 00219 data belonging to this file. This may avoid synchronous cache invalidations 00220 on later uses of the file by other nodes. */ 00221 typedef struct 00222 { 00223 int structLen; /* length of this structure */ 00224 int structType; /* hint identifier: GPFS_CLEAR_FILE_CACHE */ 00225 } gpfsClearFileCache_t; 00226 00227 00228 00229 /* Structures for specifying the various gpfs_fnctl directives */ 00230 00231 /* Cancel all hints: GPFS removes any hints that may have been issued 00232 against this file. Does not affect the contents of the GPFS file cache. 00233 Note that this directive does not cancel the effect of other directives, 00234 such as GPFS_DATA_SHIP_START. */ 00235 typedef struct /* cancelAccessHints hint */ 00236 { 00237 int structLen; /* length of this structure */ 00238 int structType; /* hint identifier: GPFS_CANCEL_HINTS */ 00239 } gpfsCancelHints_t; 00240 00241 00242 /* Initiate data shipping mode: once all participating threads have issued 00243 this hint for a file, GPFS enters a mode where it partitions the blocks 00244 of the file among a group of agent nodes. In data shipping mode, all 00245 file accesses result in GPFS messages to the appropriate agent(s) to read 00246 or write the requested data. Applications that perform fine-grained 00247 write sharing should benefit most from data shipping, since GPFS cache 00248 invalidations will be avoided. Because an application level read or 00249 write may be split across several agents, Posix read/write file atomicity 00250 is not enforced while in data shipping mode. */ 00251 typedef struct 00252 { 00253 int structLen; /* length of this structure */ 00254 int structType; /* directive identifier: GPFS_DATA_SHIP_START */ 00255 int numInstances; /* number of open file instances collaborating 00256 to operate on the file. These may be on 00257 any number of nodes. */ 00258 int reserved; /* not used, should be set to 0 */ 00259 } gpfsDataShipStart_t; 00260 00261 00262 /* Specify the agent mapping for data shipping: tells GPFS which agent 00263 nodes to use for data shipping. This directive can only appear in a 00264 gpfs_fcntl call that also gives the GPFS_DATA_SHIP_START directive. If 00265 this directive is not used, the agents will be exactly the nodes on which 00266 the GPFS_DATA_SHIP_START directive was given, and the partition will be a 00267 round-robin distribution of the blocks of the file to the agent nodes. 00268 There are two forms of this directive. The gpfsDataShipMap_t structure 00269 contains enough room for up to GPFS_MAX_DS_AGENT_NODES agent nodes. If 00270 this is insufficient, the variable-size structure gpfsDataShipMapVariable_t 00271 may be used instead. GPFS will infer the actual size of the agentNodeNumber 00272 array in the gpfsDataShipMapVariable_t structure from its structLen 00273 field. To build the argument to gpfs_fcntl when gpfsDataShipMapVariable_t 00274 is used, the application needs to dynamically allocate space for all of 00275 the contiguous structures to be passed to gpfs_fcntl. The following code 00276 fragment illustrates how this might be done: 00277 00278 char * p; 00279 gpfsFcntlHeader_t * hdrP; 00280 gpfsDataShipStart_t * startP; 00281 gpfsDataShipMapVariable_t * mapP; 00282 int mapSize = GPFS_DATA_SHIP_MAP_VARIABLE_SIZE(nAgents); 00283 00284 p = malloc(sizeof(gpfsFcntlHeader_t) + sizeof(gpfsDataShipStart_t) + mapSize); 00285 hdrP = (gpfsFcntlHeader_t *) p; 00286 startP = (gpfsDataShipStart_t *) (p + sizeof(gpfsFcntlHeader_t)); 00287 mapP = (gpfsDataShipMapVariable_t *) (p + sizeof(gpfsFcntlHeader_t) + 00288 sizeof(gpfsDataShipStart_t)); 00289 hdrP->totalLength = sizeof(gpfsFcntlHeader_t) + 00290 sizeof(gpfsDataShipStart_t) + mapSize; 00291 ... fill in other fields in *hdrP 00292 startP->structLen = sizeof(gpfsDataShipStart_t); 00293 ... fill in other fields in *startP 00294 mapP->structLen = mapSize; 00295 ... fill in other fields in mapP, including nAgents entries in the 00296 mapP->agentNodeNumber array 00297 rc = gpfs_fcntl(handle, hdrP); 00298 free(p); 00299 00300 As the example code shows, using gpfsDataShipMapVariable_t is more awkward 00301 than using gpfsDataShipMap_t, since the latter can simply be embedded 00302 within a larger structure that contains the necessary gpfsFcntlHeader_t 00303 and gpfsDataShipStart_t structures. */ 00304 #define GPFS_MAX_DS_AGENT_NODES 2048 00305 typedef struct 00306 { 00307 int structLen; /* length of this structure */ 00308 int structType; /* directive identifier: GPFS_DATA_SHIP_MAP */ 00309 int partitionSize; /* number of contiguous bytes per server */ 00310 int agentCount; /* number of entries used in the 00311 agentNodeNumber array */ 00312 int agentNodeNumber[GPFS_MAX_DS_AGENT_NODES]; 00313 /* data ship agent node numbers, using 00314 GPFS configuration data repository 00315 node numbers */ 00316 } gpfsDataShipMap_t; 00317 00318 typedef struct 00319 { 00320 int structLen; /* length of this structure */ 00321 int structType; /* directive identifier: GPFS_DATA_SHIP_MAP */ 00322 int partitionSize; /* number of contiguous bytes per server */ 00323 int agentCount; /* number of entries used in the 00324 agentNodeNumber array */ 00325 int agentNodeNumber[2]; 00326 /* data ship agent node numbers, using 00327 GPFS configuration data repository 00328 node numbers. The actual size of this 00329 array will be inferred from structLen. 00330 The number of elements in the array must 00331 be even, so that the total structure size 00332 is a multiple of 8. The number of 00333 entries used in the array is given by 00334 agentCount, and may be any positive value 00335 less than or equal to the size of the 00336 array. */ 00337 } gpfsDataShipMapVariable_t; 00338 00339 /* Compute the size in bytes of a gpfsDataShipMapVariable_t structure large 00340 enough to hold _nAgents data shipping agent node numbers */ 00341 #define GPFS_DATA_SHIP_MAP_VARIABLE_SIZE(_nAgents) \ 00342 ( sizeof(gpfsDataShipMapVariable_t) - 2*sizeof(int) + \ 00343 ((((_nAgents)+1)/2)*2)*sizeof(int) ) 00344 00345 00346 /* Terminate data shipping: waits for all threads that issued the 00347 GPFS_DATA_SHIP_START directive to issue this directive, then leaves data 00348 shipping mode. */ 00349 typedef struct 00350 { 00351 int structLen; /* length of this structure */ 00352 int structType; /* directive identifier: GPFS_DATA_SHIP_STOP */ 00353 } gpfsDataShipStop_t; 00354 00355 00356 /* This directive is used to set a file's replication factors. 00357 However, the directive does not cause the file data to be restriped 00358 immediately. Instead the caller must append a gpfsRestripeData_t directive 00359 or invoke a mmrestripefs or a mmrestripefile command. */ 00360 typedef struct 00361 { 00362 int structLen; /* length of this structure */ 00363 int structType; /* directive identifier: 00364 GPFS_FCNTL_SET_REPLICATION */ 00365 int metadataReplicas; /* Set the number of copies of the file's 00366 indirect blocks. Valid values are 1 or 2, 00367 but not greater than the value of 00368 maxMetadataReplicas. A value of 0 indicates 00369 not to change the current value. */ 00370 int maxMetadataReplicas; /* Set the maximum number of copies of a file's 00371 indirect blocks. Space in the file's inode 00372 and indirect blocks is reserved for the 00373 maximum number of copies, regardless of the 00374 current value. Valid values are 1 or 2. 00375 A value of 0 indicates not to change the 00376 current value. */ 00377 int dataReplicas; /* Set the number of copies of the file's 00378 data blocks. Valid values are 1 or 2, 00379 but cannot be greater than the value of 00380 maxDataReplicas. A value of 0 indicates 00381 not to change the current value. */ 00382 int maxDataReplicas; /* Set the maximum number of copies of a file's 00383 data blocks. Space in the file's inode 00384 and indirect blocks is reserved for the 00385 maximum number of copues, regardless of the 00386 current value. Valid values are 1 or 2. 00387 A value of 0 indicates not the change the 00388 current value. */ 00389 int errReason; /* returned reason request failed. 00390 Defined below. */ 00391 int errValue1; /* returned value depending upon errReason */ 00392 int errValue2; /* returned value depending upon errReason */ 00393 int reserved; /* unused, but should be set to 0 */ 00394 } gpfsSetReplication_t; 00395 00396 00397 00398 /* Values that may be returned by errReason */ 00399 00400 /* No reason information was returned. */ 00401 #define GPFS_FCNTL_ERR_NONE 0 00402 00403 /* MetadataReplicas is out of range. 00404 errValue1 and errValue2 contain the valid lower and upper range boundaries. */ 00405 #define GPFS_FCNTL_ERR_METADATA_REPLICAS_RANGE 1 00406 00407 /* MaxMetadataReplicas is out of range. 00408 errValue1 and errValue2 contain the valid lower and upper range boundaries. */ 00409 #define GPFS_FCNTL_ERR_MAXMETADATA_REPLICAS_RANGE 2 00410 00411 /* DataReplicas is out of range. 00412 errValue1 and errValue2 contain the valid lower and upper range boundaries. */ 00413 #define GPFS_FCNTL_ERR_DATA_REPLICAS_RANGE 3 00414 00415 /* MaxDataReplicas is out of range. 00416 errValue1 and errValue2 contain the valid lower and upper range boundaries. */ 00417 #define GPFS_FCNTL_ERR_MAXDATA_REPLICAS_RANGE 4 00418 00419 /* An attempt to change maxMetadataReplicas or maxDataReplicas or both 00420 was made on a file that is not empty. */ 00421 #define GPFS_FCNTL_ERR_FILE_NOT_EMPTY 5 00422 00423 /* MetadataReplicas or dataReplicas or both exceed the number of failure groups. 00424 errValue1 contains the maximum number of metadata failure groups. 00425 errValue2 contains the maximum number of data failure groups. */ 00426 #define GPFS_FCNTL_ERR_REPLICAS_EXCEED_FGMAX 6 00427 00428 00429 /* This directive is used to set a file's assigned storage pool. 00430 However, the directive does not cause the file data to be migrated 00431 immediately. Instead the caller must append a gpfsRestripeData_t 00432 directive or invoke a mmrestripefs or mmrestripefile command. 00433 The caller must have root privileges to change a file's storage pool. */ 00434 typedef struct 00435 { 00436 int structLen; /* length of this structure */ 00437 int structType; /* directive identifier: 00438 GPFS_FCNTL_SET_STORAGEPOOL */ 00439 int errReason; /* returned reason request failed. 00440 Defined below. */ 00441 int errValue1; /* returned value depending upon errReason */ 00442 int errValue2; /* returned value depending upon errReason */ 00443 int reserved; /* unused, but should be set to 0 */ 00444 char buffer[GPFS_FCNTL_MAX_NAME_BUFFER]; /* Null-terminated name of 00445 storage pool to be assigned */ 00446 } gpfsSetStoragePool_t; 00447 00448 00449 /* Values that may be returned by errReason */ 00450 00451 /* Invalid storage pool name was given. */ 00452 #define GPFS_FCNTL_ERR_INVALID_STORAGE_POOL 7 00453 00454 /* Invalid storage pool. File cannot be assigned to given pool. */ 00455 #define GPFS_FCNTL_ERR_INVALID_STORAGE_POOL_TYPE 8 00456 00457 /* Invalid storage pool. Directories cannot be assigned to given pool. */ 00458 #define GPFS_FCNTL_ERR_INVALID_STORAGE_POOL_ISDIR 9 00459 00460 /* Invalid storage pool. System files cannot be assigned to given pool. */ 00461 #define GPFS_FCNTL_ERR_INVALID_STORAGE_POOL_ISLNK 10 00462 00463 /* Invalid storage pool. System files cannot be assigned to given pool. */ 00464 #define GPFS_FCNTL_ERR_INVALID_STORAGE_POOL_ISSYS 11 00465 00466 /* File system has not been upgraded to support storage pools */ 00467 #define GPFS_FCNTL_ERR_STORAGE_POOL_NOTENABLED 12 00468 00469 /* User does not have permission to perform the requested operation */ 00470 #define GPFS_FCNTL_ERR_NOPERM 13 00471 00472 00473 00474 00475 /* This directive is used to restripe a file's data blocks to update 00476 its replication and/or migrate its data. The data movement is always 00477 done immediately. */ 00478 00479 typedef struct 00480 { 00481 long long startOffset; 00482 long long numOfBlks; 00483 } gpfsByteRange_t; 00484 00485 typedef struct 00486 { 00487 int structLen; /* length of this structure */ 00488 int structType; /* directive identifier: 00489 GPFS_FCNTL_RESTRIPE_FILE */ 00490 int options; /* options for restripe command. Defined below. 00491 See mmrestripefs command for details. */ 00492 int errReason; /* returned reason request failed. 00493 Defined below. */ 00494 int errValue1; /* returned value depending upon errReason */ 00495 int errValue2; /* returned value depending upon errReason */ 00496 int reserved1; /* unused, but should be set to 0 */ 00497 int reserved2; /* unused, but should be set to 0 */ 00498 } gpfsRestripeData_t; 00499 00500 typedef struct 00501 { 00502 int structLen; /* length of this structure */ 00503 int structType; /* directive identifier: 00504 GPFS_FCNTL_RESTRIPE_FILE */ 00505 int options; /* options for restripe command. Defined below. 00506 See mmrestripefs command for details. */ 00507 int errReason; /* returned reason request failed. 00508 Defined below. */ 00509 int errValue1; /* returned value depending upon errReason */ 00510 int errValue2; /* returned value depending upon errReason */ 00511 gpfsByteRange_t range; /* Should be zero when GPFS_FCNTL_RESTRIPE_RANGE 00512 is not set */ 00513 int reserved1; /* unused, but should be set to 0 */ 00514 int reserved2; /* unused, but should be set to 0 */ 00515 } gpfsRestripeRange_t; 00516 00517 00518 /* Define values for restripe options. 00519 See mmrestripefs command for complete definitions. */ 00520 00521 /* Migrate critical data off of suspended disks. */ 00522 #define GPFS_FCNTL_RESTRIPE_M 0x0001 00523 00524 /* Replicate data against subsequent failure. */ 00525 #define GPFS_FCNTL_RESTRIPE_R 0x0002 00526 00527 /* Place file data in assigned storage pool. */ 00528 #define GPFS_FCNTL_RESTRIPE_P 0x0004 00529 00530 /* Rebalance file data */ 00531 #define GPFS_FCNTL_RESTRIPE_B 0x0008 00532 00533 /* Restripe a range if file data */ 00534 #define GPFS_FCNTL_RESTRIPE_RANGE_R 0x0010 00535 00536 /* Values that may be returned by errReason */ 00537 00538 /* Not enough replicas could be created because the desired degree 00539 of replication is larger than the number of failure groups. */ 00540 #define GPFS_FCNTL_ERR_NO_REPLICA_GROUP 14 00541 00542 /* Not enough replicas could be created because there was not 00543 enough space left in one of the failure groups. */ 00544 #define GPFS_FCNTL_ERR_NO_REPLICA_SPACE 15 00545 00546 /* There was not enough space left on one of the disks to properly 00547 balance the file according to the current stripe method. */ 00548 #define GPFS_FCNTL_ERR_NO_BALANCE_SPACE 16 00549 00550 /* The file could not be properly balanced because one or more 00551 disks are unavailable. */ 00552 #define GPFS_FCNTL_ERR_NO_BALANCE_AVAILABLE 17 00553 00554 /* All replicas were on disks that have since been deleted 00555 from the stripe group. */ 00556 #define GPFS_FCNTL_ERR_ADDR_BROKEN 18 00557 00558 /* No immutable attribute on directorys */ 00559 #define GPFS_FCNTL_ERR_NO_IMMUTABLE_DIR 19 00560 00561 /* No immutable attribute on system files */ 00562 #define GPFS_FCNTL_ERR_NO_IMMUTABLE_SYSFILE 20 00563 00564 /* Immutable and indefinite retension flag wrong */ 00565 #define GPFS_FCNTL_ERR_IMMUTABLE_FLAG 21 00566 00567 /* Immutable and indefinite retension flag wrong */ 00568 #define GPFS_FCNTL_ERR_IMMUTABLE_PERM 22 00569 00570 /* AppendOnly flag should be set separetly */ 00571 #define GPFS_FCNTL_ERR_APPENDONLY_CONFLICT 23 00572 00573 /* Should not set immutable or appendOnly on snapshots */ 00574 #define GPFS_FCNTL_ERR_NOIMMUTABLE_ONSNAP 24 00575 00576 /* An attempt to change maxDataReplicas or maxMetadataReplicas 00577 was made on a file that has extended attributes. */ 00578 #define GPFS_FCNTL_ERR_FILE_HAS_XATTRS 25 00579 00580 /* Give reason that it's not GPFS file*/ 00581 #define GPFS_FCNTL_ERR_NOT_GPFS_FILE 26 00582 00583 00584 00585 00586 00587 00588 /* Values that may be returned by errValue1 */ 00589 00590 /* Strict replica allocation option set to be yes */ 00591 #define GPFS_FCNTL_STATUS_STRICT_REPLICA_YES 0x0010 00592 00593 /* Strict replica allocation option set to be no */ 00594 #define GPFS_FCNTL_STATUS_STRICT_REPLICA_NO 0x0020 00595 00596 /* Strict replica allocation option set to be whenpossible */ 00597 #define GPFS_FCNTL_STATUS_STRICT_REPLICA_WHENPOSSIBLE 0x0040 00598 00599 /* Structures for specifying the various gpfs_fnctl inquiries. 00600 The inquiry directives may be used to obtain attributes of a files 00601 such as the file's replication factors, storage pool name, 00602 fileset name or snapshot name. */ 00603 00604 /* This inquiry is used to obtain a file's replication factors. */ 00605 typedef struct 00606 { 00607 int structLen; /* length of this structure */ 00608 int structType; /* inquiry identifier: 00609 GPFS_FCNTL_GET_REPLICATION */ 00610 int metadataReplicas; /* returns the current number of copies 00611 of indirect blocks for the file. */ 00612 int maxMetadataReplicas; /* returns the maximum number of copies 00613 of indirect blocks for the file. */ 00614 int dataReplicas; /* returns the current number of copies 00615 of data blocks for the file. */ 00616 int maxDataReplicas; /* returns the maximum number of copies 00617 of data blocks for the file. */ 00618 int status; /* returns the status of the file. 00619 Status values defined below. */ 00620 int reserved; /* unused, but should be set to 0 */ 00621 } gpfsGetReplication_t; 00622 00623 00624 /* Flag definitions */ 00625 00626 /* If set this file may have some data where the only replicas are 00627 on suspended disks; implies some data may be lost if suspended 00628 disks are removed. */ 00629 #define GPFS_FCNTL_STATUS_EXPOSED 0x40000000 00630 00631 /* If set this file may not be properly replicated, i.e. some data 00632 may have fewer or more than the desired number of replicas, 00633 or some replicas may be on suspended disks. */ 00634 #define GPFS_FCNTL_STATUS_ILLREPLICATED 0x20000000 00635 00636 /* If set this file may not be properly balanced. */ 00637 #define GPFS_FCNTL_STATUS_UNBALANCED 0x10000000 00638 00639 /* If set this file has stale data blocks on at least one of the disks 00640 that are marked as unavailable or recovering in the stripe group 00641 descriptor. */ 00642 #define GPFS_FCNTL_STATUS_DATAUPDATEMISS 0x08000000 00643 00644 /* If set this file has stale indirect blocks on at least one 00645 unavailable or recovering disk. */ 00646 #define GPFS_FCNTL_STATUS_METAUPDATEMISS 0x04000000 00647 00648 /* If set this file may not be properly placed, i.e. some data may 00649 be stored in an incorrect storage pool */ 00650 #define GPFS_FCNTL_STATUS_ILLPLACED 0x02000000 00651 00652 00653 00654 /* This inquiry is used to obtain the name of the storage assigned 00655 for the file's data. The size of the buffer may vary, but it must be 00656 a multiple of 8. Upon successful completion of the call, the buffer 00657 will contain a null-terminated character string for the name of the 00658 file's storage pool. */ 00659 typedef struct 00660 { 00661 int structLen; /* length of this structure */ 00662 int structType; /* inquiry identifier: 00663 GPFS_FCNTL_GET_STORAGEPOOL */ 00664 char buffer[GPFS_FCNTL_MAX_NAME_BUFFER]; /* returns with the file's 00665 storage pool name */ 00666 } gpfsGetStoragePool_t; 00667 00668 00669 /* This inquiry is used to obtain the name of the fileset to which this 00670 file has been assigned. The size of the buffer may vary, but it must be 00671 a multiple of 8. Upon successful completion of the call, the buffer 00672 will contain a null-terminated character string for the name of the 00673 file's fileset. */ 00674 typedef struct 00675 { 00676 int structLen; /* length of this structure */ 00677 int structType; /* inquiry identifier: 00678 GPFS_FCNTL_GET_FILESETNAME */ 00679 char buffer[GPFS_FCNTL_MAX_NAME_BUFFER]; /* returns with the file's 00680 fileset name */ 00681 } gpfsGetFilesetName_t; 00682 00683 00684 /* This inquiry is used to obtain the name of the snapshot that includes 00685 this file. If the file is not part of a snapshot, then a zero-length 00686 string will be returned. The size of the buffer may vary, but it must be 00687 a multiple of 8. Upon successful completion of the call, the buffer 00688 will contain a null-terminated character string for the name of the 00689 snapshot that includes this file. */ 00690 typedef struct { 00691 int structLen; /* length of this structure */ 00692 int structType; /* inquiry identifier: 00693 GPFS_FCNTL_GET_SNAPSHOTNAME */ 00694 char buffer[GPFS_FCNTL_MAX_NAME_BUFFER]; /* returns with the file's 00695 snapshot name */ 00696 } gpfsGetSnapshotName_t; 00697 00698 /* Allow tschattr to change file immutable attribute */ 00699 #define GPFS_FCNTL_SET_IMMUTABLE 5000 00700 00701 typedef struct { 00702 int structLen; /* length of this structure */ 00703 int structType; /* function identifier: 00704 GPFS_FCNTL_SET_IMMUTABLE */ 00705 int setImmutable; /* value to set the immutable flag */ 00706 int setIndefiniteRetention; /* value to set IndefiniteRetention */ 00707 int errReasonCode; /* Reason code */ 00708 int reserved; /* reserved field */ 00709 } gpfsSetImmutable_t; 00710 00711 #define GPFS_FCNTL_GET_IMMUTABLE 5001 00712 00713 typedef struct { 00714 int structLen; /* length of this structure */ 00715 int structType; /* function identifier: 00716 GPFS_FCNTL_SET_IMMUTABLE */ 00717 int immutable; /* value of the immutable flag */ 00718 int indefiniteRetention; /* value of the indeiniteRetention flag */ 00719 int errReasonCode; /* Reason code */ 00720 int reserved; 00721 } gpfsGetImmutable_t; 00722 00723 #define GPFS_FCNTL_SET_EXPIRATION_TIME 5002 00724 00725 typedef struct { 00726 int structLen; /* length of this structure */ 00727 int structType; /* function identifier: 00728 GPFS_FCNTL_SET_IMMUTABLE */ 00729 long long expTime; /* expiration Time */ 00730 int errReasonCode; /* Reason code */ 00731 int reserved; /* reserved field */ 00732 } gpfsSetExpTime_t; 00733 00734 #define GPFS_FCNTL_GET_EXPIRATION_TIME 5003 00735 00736 typedef struct { 00737 int structLen; /* length of this structure */ 00738 int structType; /* function identifier: 00739 GPFS_FCNTL_SET_IMMUTABLE */ 00740 long long expTime; /* expiration Time */ 00741 int errReasonCode; /* Reason code */ 00742 int reserved; /* reserved field */ 00743 } gpfsGetExpTime_t; 00744 00745 00746 #define GPFS_FCNTL_SET_APPENDONLY 5004 00747 00748 typedef struct { 00749 int structLen; /* length of this structure */ 00750 int structType; /* function identifier: 00751 GPFS_FCNTL_SET_IMMUTABLE */ 00752 int setAppendOnly; /* value to set the appendOnly flag */ 00753 int setIndefiniteRetention; /* value to set IndefiniteRetention */ 00754 int errReasonCode; /* Reason code */ 00755 int reserved; /* reserved field */ 00756 } gpfsSetAppendOnly_t; 00757 00758 #define GPFS_FCNTL_GET_APPENDONLY 5005 00759 00760 typedef struct { 00761 int structLen; /* length of this structure */ 00762 int structType; /* function identifier: 00763 GPFS_FCNTL_SET_IMMUTABLE */ 00764 int appendOnly; /* value of the appendOnly flag */ 00765 int indefiniteRetention; /* value of the indeiniteRetention flag */ 00766 int errReasonCode; /* Reason code */ 00767 int reserved; /* reserved field */ 00768 } gpfsGetAppendOnly_t; 00769 00770 00771 00772 /* 00773 * Provide access to a file's extended attributes 00774 * 00775 * Extended attributes are persistent name,value pairs assigned to files or 00776 * directories. The name is typically a character string which is terminated 00777 * by a null ('\0') character which is included in the name length. 00778 * Attributes set internally or for dmapi may follow other conventions. 00779 * The attributes's value is a binary string which is not interpretted 00780 * by this api. 00781 * 00782 * Attribute names are typically divided into namespaces, both to avoid 00783 * collisions and to enforce access controls. The namespaces currently 00784 * defined are: 00785 * 00786 * "user." -- requires permission to access file data 00787 * "system." -- used by kernel for access control lists 00788 * "trusted." -- requires admin/root privilege 00789 * "security." -- used by Security Enhanced Linux 00790 * "archive." -- reserved for GPFS 00791 * "dmapi." -- reserved for the X/Open Data Storage Management API (XDSM) 00792 * "gpfs." -- reserved for GPFS 00793 * 00794 * For example, "user.name1" or "system.posix_acl_default". 00795 * Additional namespaces may be defined in future releases. Users should 00796 * restrict the names used to a predefined namespace. 00797 * 00798 * Setting or resetting attributes reserved by GPFS or other middleware 00799 * services may have unintended consequences and is not recommended. 00800 * 00801 * Attributes are creating via the SET_XATTR call with a value length of 00802 * zero or more bytes. By default, setting an extended attribute will create 00803 * the attribute if it does not exist or will replace the current value if 00804 * it does. Using the CREATE flag causes a pure create which fails if the 00805 * attribute already exists. Likewise using the REPLACE flag causes a pure 00806 * replace which fails if the attribute does not exist. 00807 * 00808 * Attributes are deleted by calling SET_XATTR with a negative length. Using 00809 * the DELETE flag causes a pure delete which fails if the attribute does 00810 * not exist. 00811 * 00812 * By default, setting or deleting an extended attribute is done 00813 * asynchronously. That is to say, the update is not written to disk until 00814 * some time after the call completes. Using the SYNC option causes the 00815 * update to be committed to disk before the call completes. The update 00816 * to a single attribute is always done atomically, either the original value 00817 * is retained or the complete new value will be set. 00818 * 00819 * More than one attribute may be set or deleted within a single fcntl call. 00820 * The updates are applied in the order specified in the fcntl vector. 00821 * If the file system fails, there is no guarantee that all updates will 00822 * be applied, even if using the SYNC options. If sync is specified on the 00823 * last update in the vector, then all prior attributes updates will also 00824 * be written with the final update. 00825 * 00826 * In order to see an attribute via the GET_XATTR or LIST_XATTR call 00827 * the caller must have sufficient privilege to set the attribute. 00828 * 00829 * Errors are returned in the errReturnCode field. 00830 * 00831 * 00832 * Note: Extended attributes are stored as character or binary strings. 00833 * Care should be taken when used on mixed architectures with different 00834 * byte orders or word sizes to insure the attribute values are in an 00835 * architecture independent format. 00836 * 00837 */ 00838 #define GPFS_FCNTL_GET_XATTR 6001 00839 #define GPFS_FCNTL_SET_XATTR 6002 00840 #define GPFS_FCNTL_LIST_XATTR 6003 00841 00842 #define GPFS_FCNTL_XATTR_MAX_NAMELEN 256 /* includes trailing null char */ 00843 #define GPFS_FCNTL_XATTR_MAX_VALUELEN (16 * 1024) 00844 00845 #define GPFS_FCNTL_XATTRFLAG_NONE 0x0000 00846 #define GPFS_FCNTL_XATTRFLAG_SYNC 0x0001 /* synchronous update 00847 All updates are committed 00848 before the call returns */ 00849 #define GPFS_FCNTL_XATTRFLAG_CREATE 0x0002 /* pure create 00850 will fail if already exists */ 00851 #define GPFS_FCNTL_XATTRFLAG_REPLACE 0x0004 /* pure replace 00852 will fail if does not exist */ 00853 #define GPFS_FCNTL_XATTRFLAG_DELETE 0x0008 /* pure delete 00854 will fail if does not exist */ 00855 #define GPFS_FCNTL_XATTRFLAG_NO_CTIME 0x0010 /* Update will not set ctime. 00856 Must have admin authority. */ 00857 00858 /* Define error reason codes for extended attributes */ 00859 #define GPFS_FCNTL_ERR_NO_ATTR 27 00860 #define GPFS_FCNTL_ERR_ATTR_EXISTS 28 00861 #define GPFS_FCNTL_ERR_BUFFER_TOO_SMALL 29 00862 #define GPFS_FCNTL_ERR_NO_ATTR_SPACE 30 00863 #define GPFS_FCNTL_ERR_INVAL_VALUE 31 00864 00865 00866 00867 typedef struct { 00868 int structLen; /* length of this structure */ 00869 int structType; /* function identifier: 00870 GPFS_FCNTL_GET_XATTR 00871 or GPFS_FCNTL_SET_XATTR */ 00872 int nameLen; /* length of attribute name 00873 may include trailing '\0' character */ 00874 int bufferLen; /* 00875 for GPFS_FCNTL_GET_XATTR 00876 INPUT: length of buffer 00877 OUTPUT: length of attribute value 00878 00879 for GPFS_FCNTL_SET_XATTR 00880 INPUT: length of attribute value 00881 length = -1 to delete attribute */ 00882 unsigned int flags; /* defined above. */ 00883 int errReasonCode; /* Reason code */ 00884 char buffer[0]; /* buffer for name and value. 00885 00886 for GPFS_FCNTL_GET_XATTR 00887 00888 INPUT: name begins at offset 0 00889 and must be null terminated. 00890 OUTPUT: name is returned unchanged 00891 value begins at nameLen rounded up 00892 to a multiple of 8. 00893 00894 for GPFS_FCNTL_SET_XATTR 00895 00896 INPUT: name begins at offset 0 00897 and must be null terminated. 00898 value begins at nameLen rounded up 00899 to a multiple of 8. 00900 00901 actual length of buffer should be 00902 nameLen rounded up to a multiple of 8 00903 + valueLen rounded up to a multiple of 8 00904 00905 Buffer size set by caller. Maximum 00906 size is (GPFS_FCNTL_XATTR_MAX_NAMELEN + 00907 GPFS_FCNTL_XATTR_MAX_VALUELEN) */ 00908 } gpfsGetSetXAttr_t; 00909 00910 typedef struct { 00911 int structLen; /* length of this structure */ 00912 int structType; /* function identifier: 00913 GPFS_FCNTL_LIST_XATTR */ 00914 int bufferLen; /* INPUT: length of buffer 00915 OUTPUT: length of returned list of names */ 00916 int errReasonCode; /* Reason code */ 00917 char buffer[0]; 00918 /* buffer for returned list of names 00919 Each attribute name is prefixed with 00920 a 1-byte name length that includes the 00921 trailing null. The next attribute name 00922 follows immediately in the buffer (and is 00923 prefixed with its own length). Following 00924 the last name a '\0' is appended to 00925 terminate the list. The returned bufferLen 00926 includes the final '\0'. 00927 00928 \7abcdef\0\4ABC\0\10user.name\0\0 00929 00930 The actual length of the buffer required 00931 depends on the number of attributes set on 00932 the file and the length of each attribute name. 00933 If the buffer provided is too small for all 00934 of the returned names, the errReasonCode 00935 will be set to GPFS_FCNTL_ERR_BUFFER_TOO_SMALL 00936 and bufferLen will be set to the minimum 00937 size buffer required to list all attributes. 00938 An initial buffer length of 0 may be used to 00939 query the attributes and determine the 00940 correct buffer size for this file. */ 00941 00942 } gpfsListXAttr_t; 00943 00944 00945 00946 00947 00948 00949 #ifdef GPFS_SNC_FILEMAP 00950 00951 typedef struct OffsetLoc { 00952 long long offset; 00953 int diskNum[3]; /* array of locations based on number of replicas returned */ 00954 } OffsetLoc; 00955 00956 typedef struct FilemapIn { 00957 long long startOffset; /* start offset in bytes */ 00958 long long skipfactor; /* number of bytes to skip before next offset read */ 00959 long long length; /* number of bytes (start offset + length / skipfactor = numblks returned */ 00960 int mreplicas; /* number of replicas user wants, 0 is all, 00961 1 primary, 2, primary and 1st replica 3 all */ 00962 int reserved; /* for now to align it to the 8byte boundary */ 00963 } FilemapIn; 00964 00965 typedef struct FilemapOut { 00966 int numReplicasReturned; 00967 int numBlksReturned; 00968 int blockSize; 00969 int reserved; 00970 char buffer [GPFS_MAX_FCNTL_LENGTH-1024]; /* packs offset, disklocation1, disklocation2.... */ 00971 } FilemapOut; 00972 00973 00974 typedef struct GetDataBlkDiskIdx { 00975 int structLen; /* length of this structure */ 00976 int structType; /* function identifier: 00977 GPFS_FCNTL_GET_DATABLKDISKIDX */ 00978 FilemapIn filemapIn; /* Input parameters specified by the user */ 00979 FilemapOut filemapOut; /* Output data */ 00980 } GetDataBlkDiskIdx; 00981 00982 #endif /* GPFS_SNC_FILEMAP */ 00983 00984 00985 /* NAME: gpfs_fcntl() 00986 * 00987 * FUNCTION: Pass hints and directives to GPFS on behalf of an open file 00988 * 00989 * Returns: 0 Successful 00990 * -1 Failure 00991 * 00992 * Errno: ENOSYS Function not available 00993 * EBADF Bad file handle 00994 * EINVAL Not a GPFS file 00995 * EINVAL Not a regular file 00996 * EINVAL Ill-formed hint or directive 00997 * E2BIG Argument longer than GPFS_MAX_FCNTL_LENGTH 00998 */ 00999 01000 int GPFS_API 01001 gpfs_fcntl(gpfs_file_t fileDesc, /* Open file descriptor */ 01002 void* fcntlArgP); /* argument list */ 01003 01004 /* 01005 * NAME: gpfs_restripe_file() 01006 * 01007 * FUNCTION: Restripes a file by calling gpfs_fcntl for noBlocks 01008 * from start offset. If noBlocks 0 ==> use default increment size 01009 * 01010 * Returns: 0 Successful 01011 * -1 Failure 01012 * 01013 * Errno: ENOSYS No quality of service function available 01014 * ENOENT File not found 01015 * EINVAL Not a GPFS file 01016 * ESTALE cached fs information was invalid 01017 */ 01018 01019 int GPFS_API 01020 gpfs_restripe_file(gpfs_file_t fileDesc, /* Open file descriptor */ 01021 void* fcntlArgP, /* argument list */ 01022 int noBlocks); /* number of blocks used for each 01023 iteration when restriping a 01024 file */ 01025 01026 #ifdef __cplusplus 01027 } 01028 #endif 01029 01030 #endif /* _h_gpfs_fcntl */