SIONlib  1.6.2
Scalable I/O library for parallel access to task-local files
sion_hints_gpfs.c
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2016 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include <time.h>
13 #include <assert.h>
14 
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <fcntl.h>
18 #include <unistd.h>
19 
20 #include "sion.h"
21 #include "sion_debug.h"
22 #include "sion_internal.h"
23 #include "sion_hints_gpfs.h"
24 
25 #ifdef SION_HINTS_GPFS
26 #include <gpfs_fcntl.h>
27 #endif
28 
29 
30 
40 int _sion_apply_hint_gpfs_access_range(int fd, long long start, long long length, int iswrite ) {
41  int rc=SION_SUCCESS;
42 
43  /* #NODIST# */
44 #ifdef SION_HINTS_GPFS
45  int grc;
46  struct
47  {
48  gpfsFcntlHeader_t hdr;
49  gpfsAccessRange_t acc;
50  } accHint;
51 #endif
52 
53  DPRINTFP((2, "_sion_apply_hint_gpfs_access_range", -1, "start fd=%d start=%lld length=%lld\n",
54  fd, start, length));
55 
56 
57 #ifdef SION_HINTS_GPFS
58  DPRINTFP((2, "_sion_apply_hint_gpfs_access_range", -1, "do apply\n"));
59 
60  /* Issue the access range hint */
61  accHint.hdr.totalLength = sizeof(accHint);
62  accHint.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
63  accHint.hdr.fcntlReserved = 0;
64  accHint.acc.structLen = sizeof(accHint.acc);
65  accHint.acc.structType = GPFS_ACCESS_RANGE;
66  accHint.acc.start = start;
67  accHint.acc.length = length;
68  accHint.acc.isWrite = iswrite;
69  grc = gpfs_fcntl(fd, &accHint);
70  if (grc != 0) {
71  return(_sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"cannot set GPFS hint (access) for file fd=%d start=%lld length=%lld ... rc=%d\n",
72  fd, start, length, rc));
73  }
74  DPRINTFP((2, "_sion_apply_hint_gpfs_access_range", -1, "apply done rc=%d\n",rc));
75 
76 #endif
77  /* #NODIST# */
78 
79  return (rc);
80 }
81 
82 
92 int _sion_apply_hint_gpfs_free_range(int fd, long long start, long long length, int iswrite ) {
93  int rc=SION_SUCCESS;
94 
95  /* #NODIST# */
96 #ifdef SION_HINTS_GPFS
97  int grc;
98  struct
99  {
100  gpfsFcntlHeader_t hdr;
101  gpfsFreeRange_t free;
102  } freeHint;
103 #endif
104 
105  DPRINTFP((2, "_sion_apply_hint_gpfs_free_range", -1, "start fd=%d start=%lld length=%lld\n",
106  fd, start, length));
107 
108 
109 #ifdef SION_HINTS_GPFS
110  DPRINTFP((2, "_sion_apply_hint_gpfs_free_range", -1, "do apply\n"));
111 
112  /* Issue the free range hint */
113  freeHint.hdr.totalLength = sizeof(freeHint);
114  freeHint.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
115  freeHint.hdr.fcntlReserved = 0;
116  freeHint.free.structLen = sizeof(freeHint.free);
117  freeHint.free.structType = GPFS_FREE_RANGE;
118  freeHint.free.start = start;
119  freeHint.free.length = length;
120  grc = gpfs_fcntl(fd, &freeHint);
121  if (grc != 0) {
122  _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"cannot set GPFS hint (free) for file fd=%d start=%lld length=%lld ... rc=%d\n",
123  fd, start, length, rc);
124  return(rc);
125  }
126  DPRINTFP((2, "_sion_apply_hint_gpfs_free_range", -1, "apply done rc=%d\n",rc));
127 
128 #endif
129  /* #NODIST# */
130 
131  return (rc);
132 }
133 
134 
int _sion_errorprint(int rc, int level, const char *format,...)
Internal SION error.