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