SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
sion_dup.c
Go to the documentation of this file.
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 
16 #define _XOPEN_SOURCE 700
17 
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <stdarg.h>
21 #include <string.h>
22 #include <time.h>
23 
24 #include <sys/time.h>
25 
26 #include "sion.h"
27 #include "sion_debug.h"
28 #include "sion_error_handler.h"
29 #include "sion_internal.h"
30 #include "sion_metadata.h"
31 #include "sion_filedesc.h"
32 #include "sion_fd.h"
33 #include "sion_file.h"
34 #include "sion_printts.h"
35 #include "sion_keyvalue.h"
36 
37 #include "sion_dup.h"
38 #include "sion_buffer.h"
39 
40 
41 #define DFUNCTION "_sion_dup"
52 int _sion_dup( int sid, int mode, int rank, uint64_t key ) {
53  int rc = SION_NOT_SUCCESS, new_sid = SION_ID_NOT_VALID;
54  _sion_filedesc *sion_filedesc;
55  _sion_filedesc *new_filedesc;
56 
57  /* */ DPRINTFTS(-1, "enter sion_dup");
58  DPRINTFP((2, DFUNCTION, -1, "enter dup sid=%d\n",sid));
59 
60  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
61  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
62  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN, DFUNCTION ": invalid sion_filedesc, returning %d ...\n", sid));
63  }
64 
65  if (sion_filedesc->mode != SION_FILEMODE_READ) {
66  DPRINTFP((8, DFUNCTION, -1, "invalid opened\n"));
67  return(_sion_errorprint_on_rank(SION_ID_NOT_VALID,_SION_ERROR_RETURN,sion_filedesc->rank,
68  DFUNCTION "[%2d]: file is not opened in read mode, returning ...", sion_filedesc->rank));
69  }
70 
71  _sion_print_filedesc(sion_filedesc, 512, "_sion_dup_orig ", _SION_DEBUG_PRINT_ALL|_SION_DEBUG_PRINT_RECURSIVE);
72 
73 
74  new_filedesc = _sion_dup_filedesc(sion_filedesc);
75  if (!new_filedesc) {
76  return(_sion_errorprint_on_rank(SION_ID_NOT_VALID,_SION_ERROR_RETURN,sion_filedesc->rank, DFUNCTION"[%2d]: could not duplicate internal data structure, returning ...", sion_filedesc->rank));
77  }
78  /* reset dup_state if only one rank/key is selected */
79  if(mode==SION_DUP_RANK) {
80  new_filedesc->dup_mode = SION_DESCSTATE_DUP_SEL_RANK;
81  new_filedesc->dup_sel_rank = (sion_int32) rank;
82  }
83  if(mode==SION_DUP_RANK_KEY) {
85  new_filedesc->dup_sel_rank = (sion_int32) rank;
86  new_filedesc->dup_sel_key = (sion_uint64) key;
87  }
88 
89  /* New sion file handle */
90  new_sid = _sion_newvcd(new_filedesc, SION_FILEDESCRIPTOR);
91  new_filedesc->sid=new_sid;
92 
93 
94  /* mode PAROPEN: in this mode is only one filedesc structure defined; if a
95  multifile was opened each task is only taking part on one of these
96  files, therefore we have not to duplicate recursive */
97  if (sion_filedesc->state == SION_FILESTATE_PAROPEN) {
98  DPRINTFP((8, DFUNCTION, -1, "file is in state SION_FILESTATE_PAROPEN\n"));
99  rc=_sion_dup_paropen(sion_filedesc, new_filedesc);
100  }
101 
102  /* mode seropen: in this mode a sion file could have multiple filedesc structure when opening a SION multi-file */
103  if (sion_filedesc->state == SION_FILESTATE_SEROPEN) {
104  DPRINTFP((8, DFUNCTION, -1, "file is in state SION_FILESTATE_SEROPEN\n"));
105  /* TODO WF implement */
106  return(_sion_errorprint_on_rank(SION_ID_NOT_VALID,_SION_ERROR_RETURN,sion_filedesc->rank,
107  DFUNCTION "[%2d]: mode not implemented, aborting ...", sion_filedesc->rank));
108  }
109 
110  /* mode seropenrank: in this mode only a simple filedesc structure is used one file, one task */
111  if (sion_filedesc->state == SION_FILESTATE_SEROPENRANK) {
112  DPRINTFP((8, DFUNCTION, -1, "file is in state SION_FILESTATE_SEROPENRANK\n"));
113  /* TODO WF implement */
114  return(_sion_errorprint_on_rank(SION_ID_NOT_VALID,_SION_ERROR_RETURN,sion_filedesc->rank,
115  DFUNCTION "[%2d]: mode not implemented, aborting ...", sion_filedesc->rank));
116  }
117 
118  /* mode PAROPEN_MAPPED_MASTER: in this mode the whole structure including sub-datastructures for multifiles have to be duplicated */
119  if (sion_filedesc->state == SION_FILESTATE_PAROPENMAPPEDMASTER) {
120  DPRINTFP((8, DFUNCTION, -1, "file is in state SION_FILESTATE_PAROPENMAPPEDMASTER\n"));
121  rc=_sion_dup_paropenmappedmaster(sion_filedesc, new_filedesc);
122  }
123 
124 
125  if (rc!=SION_SUCCESS) {
126  return(_sion_errorprint_on_rank(SION_ID_NOT_VALID,_SION_ERROR_RETURN,sion_filedesc->rank,
127  DFUNCTION "[%2d]: could not duplicate, returning ...", sion_filedesc->rank));
128  }
129 
130 
131  /* set position on selected rank if multiple ranks are available
132  Hints: in the optimized version (to be impl.)
133  this is not needed: only the selected rank is copied */
134  if ( (sion_filedesc->state == SION_FILESTATE_SEROPEN) ||
135  (sion_filedesc->state == SION_FILESTATE_PAROPENMAPPEDMASTER)
136  ){
137  /* _sion_print_filedesc(new_filedesc, 512, "_sion_dup_clone_before_seek", _SION_DEBUG_PRINT_ALL|_SION_DEBUG_PRINT_RECURSIVE); */
138  sion_seek(new_filedesc->sid,rank,SION_CURRENT_CHUNK,SION_CURRENT_POS);
139  }
140 
141  _sion_print_filedesc(new_filedesc, 512, "_sion_dup_clone", _SION_DEBUG_PRINT_ALL|_SION_DEBUG_PRINT_RECURSIVE);
142 
143  DPRINTFP((2, DFUNCTION, -1, "leave dup sid=%d new_sid=%d\n",sid,new_sid));
144  /* */ DPRINTFTS(-1, "leave sion_dup");
145 
146  return(new_sid);
147 
148 }
149 #undef DFUNCTION
150 
151 #define DFUNCTION "_sion_dedup"
157 int _sion_dedup( int sid ) {
158  int rc = SION_SUCCESS;
159  int filenr, lfile, lrank;
160  _sion_filedesc *sion_filedesc;
161  _sion_filedesc *sion_filedesc_sub;
162 
163  /* */ DPRINTFTS(-1, "enter sion_dedup");
164  DPRINTFP((2, DFUNCTION, -1, "enter dedup sid=%d\n",sid));
165 
166  if ((sid<0) || (_sion_vcdtype(sid) != SION_FILEDESCRIPTOR)
167  || !(sion_filedesc = _sion_vcdtovcon(sid))) {
168  return(_sion_errorprint(SION_ID_NOT_VALID,_SION_ERROR_RETURN, DFUNCTION ": invalid sion_filedesc, returning %d ...\n", sid));
169  }
170 
171  if (sion_filedesc->dup_mode == SION_DESCSTATE_ORIG) {
172  return(_sion_errorprint_on_rank(SION_NOT_SUCCESS,_SION_ERROR_RETURN,sion_filedesc->rank, DFUNCTION "[%2d]: descriptor is not a duplicate, returning ...", sion_filedesc->rank));
173  }
174 
175 #ifdef SION_DEBUG
176  {
177  int numbytes, numfds;
178  sion_get_sizeof(sid, &numbytes, &numfds);
179  DPRINTFP((2, DFUNCTION, -1, "internal data size of sid %2d (%d bytes, %d fds) \n", sid,numbytes, numfds));
180  }
181 #endif
182 
183 
184  /* close all files if multi file */
185  if ( (sion_filedesc->state == SION_FILESTATE_SEROPENMASTER)
186  || (sion_filedesc->state == SION_FILESTATE_PAROPENMAPPEDMASTER) ) {
187 
188  /* pointer to keyval structure -> all_keyvalptr */
189  if(sion_filedesc->keyvalmode!=SION_KEYVAL_NONE) {
190  lfile=sion_filedesc->filenumber;
191  lrank=sion_filedesc->rank; /* index to local list */
192  sion_filedesc_sub=sion_filedesc->multifiles[lfile];
193  if( (lrank>=0) && (lfile>=0)
194  && (sion_filedesc->keyvalptr!=NULL)
195  && (sion_filedesc_sub->all_keyvalptr!=NULL) ) {
196 
197  DPRINTFP((2, DFUNCTION, -1, "keyvalptr all_keyvalptr[%d] = %x\n",lrank,sion_filedesc->keyvalptr));
198  if(sion_filedesc_sub->all_keyvalptr[lrank]!=NULL) {
199  DPRINTFP((2, DFUNCTION, -1, "WARNING keyvalptr already set all_keyvalptr[%d] = %x new =%x \n",lrank,
200  sion_filedesc_sub->all_keyvalptr[lrank],sion_filedesc->keyvalptr));
201  sion_filedesc_sub->all_keyvalptr[lrank] = sion_filedesc->keyvalptr;
202  }
203  sion_filedesc_sub->all_keyvalptr[lrank] = sion_filedesc->keyvalptr;
204  }
205  }
206 
207  /* close file and free data structure for each sub-file */
208  for(filenr=0;filenr<sion_filedesc->nfiles;filenr++) {
209  sion_filedesc_sub=sion_filedesc->multifiles[filenr];
210 
211  if(sion_filedesc_sub->keyvalmode!=SION_KEYVAL_NONE) {
212  sion_filedesc_sub->keyvalptr = NULL;
213  }
214  if (sion_filedesc_sub->usebuffer) _sion_buffer_flush(sion_filedesc_sub);
215  if (sion_filedesc_sub->fileptr!=NULL) {
216  _sion_file_close(sion_filedesc_sub->fileptr);
217  sion_filedesc_sub->fileptr=NULL;
218  }
219  _sion_free_filedesc(sion_filedesc_sub);
220  sion_filedesc->multifiles[filenr] = NULL;
221  }
222 
223  free(sion_filedesc->multifiles);
224 
225  /* the top-level keyvalptr is a pointer to one of the all_keyvalptr of the subfiles, which are already freed */
226  if(sion_filedesc->keyvalmode!=SION_KEYVAL_NONE) sion_filedesc->keyvalptr = NULL;
227 
228  _sion_freevcd(sid);
229  _sion_free_filedesc(sion_filedesc);
230  sion_filedesc = NULL;
231 
232  } else {
233  /* close file and free data structure */
234  if (sion_filedesc->usebuffer) {
235  _sion_buffer_flush(sion_filedesc);
236  }
237  _sion_file_close(sion_filedesc->fileptr);
238  sion_filedesc->fileptr=NULL;
239  _sion_freevcd(sid);
240  _sion_free_filedesc(sion_filedesc);
241  sion_filedesc = NULL;
242  }
243 
244  DPRINTFP((2, DFUNCTION, -1, "leave dedup sid=%d rc=%d\n",sid,rc));
245  /* */ DPRINTFTS(-1, "leave sion_dedup");
246 
247  return(rc);
248 
249 }
250 #undef DFUNCTION
251 
252 
253 #define DFUNCTION "_sion_dup_paropen"
259 int _sion_dup_paropen( _sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc ) {
260  int rc = SION_SUCCESS;
261 
262  DPRINTFP((2, DFUNCTION, -1, "enter \n"));
263 
264  _sion_dup_blocksizes(sion_filedesc, new_filedesc);
265 
266  /* open again the file */
267  new_filedesc->fileptr=_sion_file_open(new_filedesc->fname,sion_filedesc->fileptr->flags,0);
268  if (!new_filedesc->fileptr) {
269  return(_sion_errorprint_on_rank(SION_ID_NOT_VALID,_SION_ERROR_RETURN,sion_filedesc->rank,
270  DFUNCTION "[%2d]: could not duplicate fileptr, returning ...", sion_filedesc->rank));
271  }
272 
273  /* set filepointer to position in original descriptor */
274  _sion_file_set_position(new_filedesc->fileptr, new_filedesc->currentpos);
275 
276 
277  /* duplicate keyval structures */
278  if(new_filedesc->keyvalmode!=SION_KEYVAL_NONE) {
279  _sion_dup_keyvalptr(sion_filedesc, new_filedesc);
280  }
281 
282  DPRINTFP((2, DFUNCTION, -1, "leave rc=%d\n",rc));
283 
284  return(rc);
285 
286 }
287 #undef DFUNCTION
288 
289 #define DFUNCTION "_sion_dup_paropenmappedmaster"
295 int _sion_dup_paropenmappedmaster( _sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc ) {
296  int rc = SION_SUCCESS;
297  _sion_filedesc *sion_filedesc_sub;
298  int filenr, lfile, lrank;
299 
300  DPRINTFP((2, DFUNCTION, -1, "enter \n"));
301 
302  /* transfer meta data to corresponding sub datastructure, changes maybe caused by seeks before dup */
303  lfile=sion_filedesc->filenumber;
304  lrank=sion_filedesc->rank; /* index to local list */
305  sion_filedesc_sub=sion_filedesc->multifiles[lfile];
306 
307  sion_filedesc_sub->currentpos = sion_filedesc->currentpos;
308  sion_filedesc_sub->currentblocknr = sion_filedesc->currentblocknr;
309 
310  /* pointer to keyval structure */
311  if(sion_filedesc_sub->keyvalmode!=SION_KEYVAL_NONE) sion_filedesc_sub->keyvalptr = sion_filedesc->keyvalptr;
312 
313  /* store data of current rank on sub datastructure */
314  DPRINTFP((4, DFUNCTION, -1, "store current information lrank=%d lastchunknr=%d\n", lrank,sion_filedesc_sub->lastchunknr));
315  sion_filedesc_sub->all_currentpos[lrank] = sion_filedesc_sub->currentpos;
316  sion_filedesc_sub->all_currentblocknr[lrank] = sion_filedesc_sub->currentblocknr;
317 
318  /* pointer to keyval structure */
319  if(sion_filedesc_sub->keyvalmode!=SION_KEYVAL_NONE) {
320  DPRINTFP((2, DFUNCTION, -1, "keyvalptr all_keyvalptr[%d] = %x\n",lrank,sion_filedesc_sub->keyvalptr));
321  sion_filedesc_sub->all_keyvalptr[lrank] = sion_filedesc_sub->keyvalptr;
322  }
323 
324  _sion_dup_blocksizes(sion_filedesc, new_filedesc);
325 
326  /* allocate vector for all datastructures */
327  new_filedesc->multifiles = (_sion_filedesc **) malloc(sion_filedesc->nfiles * sizeof(_sion_filedesc*));
328  if (new_filedesc->multifiles == NULL) {
329  return(_sion_errorprint(SION_ID_UNDEF,_SION_ERROR_RETURN,"cannot allocate filedescriptor structure vector of size %lu (sion_filedesc), aborting ...\n",
330  (unsigned long) sion_filedesc->nfiles * sizeof(_sion_filedesc*)));
331  }
332 
333  /* create data structure for every multifile */
334  for(filenr=0;filenr<sion_filedesc->nfiles;filenr++) {
335  new_filedesc->multifiles[filenr] = _sion_dup_filedesc(sion_filedesc->multifiles[filenr]);
336 
337  new_filedesc->multifiles[filenr]->dup_mode=new_filedesc->dup_mode;
338  new_filedesc->multifiles[filenr]->dup_sel_rank=new_filedesc->dup_sel_rank;
339  new_filedesc->multifiles[filenr]->dup_sel_key=new_filedesc->dup_sel_key;
340 
341  /* open again the file */
342  if(sion_filedesc->multifiles[filenr]->fileptr!=NULL) { /* only if needed */
343  DPRINTFP((2, DFUNCTION, -1, " open file for multifiles[%d]\n",filenr));
344  new_filedesc->multifiles[filenr]->fileptr=_sion_file_open(sion_filedesc->multifiles[filenr]->fname,
345  sion_filedesc->multifiles[filenr]->fileptr->flags,0);
346  if (!new_filedesc->multifiles[filenr]->fileptr) {
347  return(_sion_errorprint_on_rank(SION_ID_NOT_VALID,_SION_ERROR_RETURN,sion_filedesc->rank, DFUNCTION
348  "[%2d]: could not duplicate fileptr, returning ...", sion_filedesc->rank));
349  }
350 
351  /* set filepointer to position in original descriptor */
352  _sion_file_set_position(new_filedesc->multifiles[filenr]->fileptr, new_filedesc->multifiles[filenr]->currentpos);
353 
354  /* copy further data structures */
355  _sion_dup_blocksizes(sion_filedesc->multifiles[filenr], new_filedesc->multifiles[filenr]);
356 
357  /* copy further all_* structures */
358  _sion_dup_all_ds(sion_filedesc->multifiles[filenr], new_filedesc->multifiles[filenr]);
359 
360  /* duplicate keyval structures */
361  if(new_filedesc->multifiles[filenr]->keyvalmode!=SION_KEYVAL_NONE) {
362  _sion_dup_all_keyvalptr(sion_filedesc->multifiles[filenr], new_filedesc->multifiles[filenr]);
363  }
364 
365  }
366 
367 
368  }
369 
370  /* set file pointer of master, position is already set */
371  lfile=sion_filedesc->filenumber;
372  lrank=sion_filedesc->rank;
373  new_filedesc->fileptr=new_filedesc->multifiles[lfile]->fileptr;
374 
375  if(new_filedesc->keyvalmode!=SION_KEYVAL_NONE) {
376  DPRINTFP((2, DFUNCTION, -1, "set keyvalptr on lfile=%d,lrank=%d to %x\n",lfile,lrank,new_filedesc->keyvalptr));
377  new_filedesc->keyvalptr=new_filedesc->multifiles[lfile]->all_keyvalptr[lrank];
378  }
379  DPRINTFP((2, DFUNCTION, -1, "leave rc=%d\n",rc));
380 
381  return(rc);
382 
383 }
384 #undef DFUNCTION
385 
386 
387 #define DFUNCTION "_sion_dup_blocksizes"
393 int _sion_dup_blocksizes( _sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc ) {
394  int rc = SION_SUCCESS;
395  int i;
396 
397  DPRINTFP((32, DFUNCTION, sion_filedesc->rank, "maxusedchunks=%d maxchunks=%d (%d)\n", sion_filedesc->maxusedchunks,sion_filedesc->maxchunks, MAXCHUNKS));
398 
399  /* realloc array */
400  _sion_realloc_filedesc_blocklist(new_filedesc, new_filedesc->maxusedchunks);
401 
402  /* copy data fields */
403  if(sion_filedesc->blocksizes !=NULL) {
404  for (i = 0; i <= sion_filedesc->lastchunknr; i++) {
405  new_filedesc->blocksizes[i] = sion_filedesc->blocksizes[i];
406  }
407  }
408 
409 
410  return(rc);
411 }
412 #undef DFUNCTION
413 
414 
415 
416 #define DFUNCTION "_sion_dup_all_ds"
422 int _sion_dup_all_ds( _sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc ) {
423  int rc = SION_SUCCESS;
424  int i,ltask;
425 
426  DPRINTFP((32, DFUNCTION, sion_filedesc->rank, "ntasks=%d\n", sion_filedesc->ntasks));
427 
428  /* alloc arrays */
429  _sion_alloc_filedesc_all_chunksizes(new_filedesc);
430  _sion_alloc_filedesc_all_globalranks(new_filedesc);
431  _sion_alloc_filedesc_all_localranks(new_filedesc);
432  _sion_alloc_filedesc_all_startpointers(new_filedesc);
433 
434  _sion_alloc_filedesc_block_arrays(new_filedesc); /* all_blockcount, all_currentpos, all_currentblocknr, all_blocksizes */
435 
436  /* copy data fields */
437  for(ltask=0;ltask<new_filedesc->ntasks;ltask++) {
438  new_filedesc->all_chunksizes[ltask]=sion_filedesc->all_chunksizes[ltask];
439  new_filedesc->all_globalranks[ltask]=sion_filedesc->all_globalranks[ltask];
440  new_filedesc->all_localranks[ltask]=sion_filedesc->all_localranks[ltask];
441  new_filedesc->all_startpointers[ltask]=sion_filedesc->all_startpointers[ltask];
442  new_filedesc->all_currentpos[ltask]=sion_filedesc->all_currentpos[ltask];
443  new_filedesc->all_currentblocknr[ltask]=sion_filedesc->all_currentblocknr[ltask];
444  new_filedesc->all_blockcount[ltask]=sion_filedesc->all_blockcount[ltask];
445  DPRINTFP((32, DFUNCTION, sion_filedesc->rank, " sel all_*[%d]\n", ltask));
446  }
447 
448  DPRINTFP((32, DFUNCTION, sion_filedesc->rank, " sel all_blocksizes[0..%d]\n", new_filedesc->maxchunks * new_filedesc->ntasks));
449  for (i = 0; i < new_filedesc->maxchunks * new_filedesc->ntasks; i++) {
450  /* DPRINTFP((32, DFUNCTION, sion_filedesc->rank, " all_blocksizes[%d] = %ld <- %ld\n", i, (long) new_filedesc->all_blocksizes[i], (long) sion_filedesc->all_blocksizes[i])); */
451  new_filedesc->all_blocksizes[i] = sion_filedesc->all_blocksizes[i];
452  }
453 
454  return(rc);
455 }
456 #undef DFUNCTION
457 
458 #define DFUNCTION "_sion_dup_keyvalptr"
464 int _sion_dup_keyvalptr( _sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc ) {
465  int rc = 0;
466 
467  DPRINTFP((2, DFUNCTION, -1, "enter\n"));
468 
469  rc=_sion_keyval_dup_dataptr(sion_filedesc,new_filedesc);
470 
471  DPRINTFP((2, DFUNCTION, -1, "leave rc=%d\n",rc));
472 
473  return(rc);
474 }
475 #undef DFUNCTION
476 
477 
478 #define DFUNCTION "_sion_dup_all_keyvalptr"
484 int _sion_dup_all_keyvalptr( _sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc ) {
485  int rc = SION_SUCCESS;
486  int ltask;
487  void *savep;
488 
489  DPRINTFP((32, DFUNCTION, sion_filedesc->rank, "ntasks=%d\n", sion_filedesc->ntasks));
490 
491  /* alloc arrays */
492  _sion_alloc_filedesc_all_keyvalptr(new_filedesc);
493 
494  /* dup keyvalptr */
495  savep=sion_filedesc->keyvalptr;
496  for(ltask=0;ltask<new_filedesc->ntasks;ltask++) {
497  if(sion_filedesc->all_keyvalptr[ltask]!=NULL) {
498  sion_filedesc->keyvalptr=sion_filedesc->all_keyvalptr[ltask];
499 
500  _sion_keyval_dup_dataptr(sion_filedesc,new_filedesc);
501 
502  DPRINTFP((2, DFUNCTION, -1, "keyvalptr all_keyvalptr[%d] = %x\n",ltask,new_filedesc->keyvalptr));
503  new_filedesc->all_keyvalptr[ltask]=new_filedesc->keyvalptr;
504 
505  DPRINTFP((32, DFUNCTION, sion_filedesc->rank, " duplicated keyvalptr[%d]\n", ltask));
506 
507  }
508 
509  }
510  sion_filedesc->keyvalptr=savep;
511 
512  return(rc);
513 }
514 #undef DFUNCTION
int _sion_buffer_flush(_sion_filedesc *sion_filedesc)
Flush buffer.
Definition: sion_buffer.c:177
int sion_seek(int sid, int rank, int currentblocknr, sion_int64 posinblk)
Function to set the file pointer to a new position.
Definition: sion_common.c:698
int sion_get_sizeof(int sid, int *numbytes, int *numfds)
Function returns size of internal data structure for sid.
Definition: sion_common.c:1123
#define MAXCHUNKS
Definition: sion_common.h:35
#define SION_DUP_RANK
Definition: sion_const.h:76
#define SION_CURRENT_CHUNK
Definition: sion_const.h:68
#define SION_CURRENT_POS
Definition: sion_const.h:70
#define SION_KEYVAL_NONE
Definition: sion_const.h:80
#define SION_DUP_RANK_KEY
Definition: sion_const.h:77
int _sion_dup_paropenmappedmaster(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc)
Duplicate sion_filedesc if the file is opened in paropen_mapped_master.
Definition: sion_dup.c:295
int _sion_dup_paropen(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc)
Duplicate sion_filedesc if the file is opened in paropen_mapped_master.
Definition: sion_dup.c:259
int _sion_dup_all_keyvalptr(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc)
Duplicate the keyvalue data structures of sion_filedesc.
Definition: sion_dup.c:484
int _sion_dup_blocksizes(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc)
Duplicate the blocksizes array of sion_filedesc.
Definition: sion_dup.c:393
int _sion_dup(int sid, int mode, int rank, uint64_t key)
Create a duplicated sion file descriptor.
Definition: sion_dup.c:52
int _sion_dup_all_ds(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc)
Duplicate the all* array of sion_filedesc.
Definition: sion_dup.c:422
int _sion_dup_keyvalptr(_sion_filedesc *sion_filedesc, _sion_filedesc *new_filedesc)
Duplicate the keyvalue data structure of sion_filedesc.
Definition: sion_dup.c:464
int _sion_dedup(int sid)
Destroy a duplicated sion file descriptor.
Definition: sion_dup.c:157
void * _sion_vcdtovcon(int sid)
Definition: sion_fd.c:53
int _sion_vcdtype(int sid)
Definition: sion_fd.c:58
int _sion_newvcd(void *data, int type)
Definition: sion_fd.c:43
int _sion_freevcd(int sid)
Definition: sion_fd.c:48
#define SION_FILEDESCRIPTOR
Definition: sion_fd.h:17
int _sion_file_close(_sion_fileptr *sion_fileptr)
Close file and destroys fileptr structure.
Definition: sion_file.c:178
sion_int64 _sion_file_set_position(_sion_fileptr *sion_fileptr, sion_int64 startpointer)
Set new position in file.
Definition: sion_file.c:367
_sion_fileptr * _sion_file_open(const char *fname, unsigned int flags, unsigned int addflags)
Create and open a new file for writing.
Definition: sion_file.c:53
int _sion_realloc_filedesc_blocklist(_sion_filedesc *sion_filedesc, sion_int32 maxchunks)
Increase the memory used by the internal sion structure for the blocklist.
int _sion_print_filedesc(_sion_filedesc *sion_filedesc, int level, char *desc, int flag)
Print the initialized sion file description.
_sion_filedesc * _sion_dup_filedesc(_sion_filedesc *sion_filedesc)
duplicates a filedesc data structure, not copying/reopen active file pointers
int _sion_alloc_filedesc_block_arrays(_sion_filedesc *sion_filedesc)
Allocate memory for the internal sion structure, fields for all chunksizes of all tasks.
#define SION_DESCSTATE_ORIG
Definition: sion_filedesc.h:45
#define SION_DESCSTATE_DUP_SEL_RANK
Definition: sion_filedesc.h:47
#define SION_FILEMODE_READ
Definition: sion_filedesc.h:37
#define SION_FILESTATE_SEROPENRANK
Definition: sion_filedesc.h:30
#define SION_FILESTATE_PAROPEN
Definition: sion_filedesc.h:28
#define SION_FILESTATE_SEROPENMASTER
Definition: sion_filedesc.h:31
#define SION_DESCSTATE_DUP_SEL_RANK_KEY
Definition: sion_filedesc.h:48
#define SION_FILESTATE_SEROPEN
Definition: sion_filedesc.h:29
#define SION_FILESTATE_PAROPENMAPPEDMASTER
Definition: sion_filedesc.h:32
Sion Time Stamp Header.
Sion File Descriptor Structure.
Definition: sion_filedesc.h:79
sion_int64 * all_localranks
sion_int64 * all_blocksizes
sion_int64 * all_chunksizes
sion_int64 * all_currentpos
sion_int64 * blocksizes
sion_int64 * all_currentblocknr
_sion_filedesc ** multifiles
sion_int64 * all_globalranks
sion_int32 currentblocknr
Definition: sion_filedesc.h:97
_sion_fileptr * fileptr
Definition: sion_filedesc.h:82
sion_int64 * all_startpointers
sion_int64 * all_blockcount