openmpi  3.1.6
About: Open MPI is a high performance Message Passing Interface (MPI) library project combining technologies and resources from several other projects (FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) in order to build the best MPI library available. 3.x series.
  Fossies Dox: openmpi-3.1.6.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ad_hfs_fcntl.c
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  * Copyright (C) 1997 University of Chicago.
5  * See COPYRIGHT notice in top-level directory.
6  */
7 
8 #include "ad_hfs.h"
9 #include "adio_extern.h"
10 
11 #ifndef HAVE_LSEEK64
12 #define lseek64 lseek
13 #endif
14 void ADIOI_HFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
15 {
16  int i, ntimes, err;
17  ADIO_Offset curr_fsize, alloc_size, size, len, done;
18  ADIO_Status status;
19  char *buf;
20 #ifndef PRINT_ERR_MSG
21  static char myname[] = "ADIOI_HFS_FCNTL";
22 #endif
23 
24  switch(flag) {
26  fcntl_struct->fsize = lseek64(fd->fd_sys, 0, SEEK_END);
27 #ifdef HPUX
28  if (fd->fp_sys_posn != -1)
29  lseek64(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
30 /* not required in SPPUX since there we use pread/pwrite */
31 #endif
32  if (fcntl_struct->fsize == -1) {
33 #ifdef MPICH
34  *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
35  "**io %s", strerror(errno));
36 #elif defined(PRINT_ERR_MSG)
37  *error_code = MPI_ERR_UNKNOWN;
38 #else /* MPICH-1 */
40  myname, "I/O Error", "%s", strerror(errno));
41  ADIOI_Error(fd, *error_code, myname);
42 #endif
43  }
44  else *error_code = MPI_SUCCESS;
45  break;
46 
48  /* will be called by one process only */
49 
50 #ifdef HPUX
51  err = prealloc64(fd->fd_sys, fcntl_struct->diskspace);
52  /* prealloc64 works only if file is of zero length */
53  if (err && (errno != ENOTEMPTY)) {
54 #ifdef MPICH
55  *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
56  "**io %s", strerror(errno));
57 #elif defined(PRINT_ERR_MSG)
58  *error_code = MPI_ERR_UNKNOWN;
59 #else
61  myname, "I/O Error", "%s", strerror(errno));
62  ADIOI_Error(fd, *error_code, myname);
63 #endif
64  return;
65  }
66  if (err && (errno == ENOTEMPTY)) {
67 #endif
68 
69 #ifdef SPPUX
70  /* SPPUX has no prealloc64. therefore, use prealloc
71  if size < (2GB - 1), otherwise use long method. */
72  if (fcntl_struct->diskspace <= 2147483647) {
73  err = prealloc(fd->fd_sys, (off_t) fcntl_struct->diskspace);
74  if (err && (errno != ENOTEMPTY)) {
75 #ifdef MPICH
76  *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
77  "**io %s", strerror(errno));
78 #elif defined(PRINT_ERR_MSG)
79  *error_code = MPI_ERR_UNKNOWN;
80 #else
82  myname, "I/O Error", "%s", strerror(errno));
83  ADIOI_Error(fd, *error_code, myname);
84 #endif
85  return;
86  }
87  }
88 
89  if ((fcntl_struct->diskspace > 2147483647) ||
90  (err && (errno == ENOTEMPTY))) {
91 #endif
92  ADIOI_GEN_Prealloc(fd,fcntl_struct->diskspace, error_code);
93  }
94  ADIOI_Free(buf);
95 #ifdef HPUX
96  if (fd->fp_sys_posn != -1)
97  lseek64(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
98  /* not required in SPPUX since there we use pread/pwrite */
99 #endif
100  }
101  *error_code = MPI_SUCCESS;
102  break;
103 
105  fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
106  *error_code = MPI_SUCCESS;
107  break;
108 
109  default:
110  FPRINTF(stderr, "Unknown flag passed to ADIOI_HFS_Fcntl\n");
111  MPI_Abort(MPI_COMM_WORLD, 1);
112  }
113 }
lseek64
#define lseek64
Definition: ad_hfs_fcntl.c:12
error_code
* error_code
Definition: ad_hfs_fcntl.c:101
ADIO_Fcntl_t
Definition: adio.h:249
ad_hfs.h
MPI_Abort
#define MPI_Abort
Definition: mpipr.h:14
ADIOI_Free
#define ADIOI_Free(a)
Definition: adioi.h:762
MPIR_ERR_RECOVERABLE
#define MPIR_ERR_RECOVERABLE
Definition: adio.h:446
FPRINTF
#define FPRINTF
Definition: malloc.c:33
ADIOI_Error
int ADIOI_Error(ADIO_File fd, int error_code, char *string)
Definition: error.c:14
err
err
Definition: sharedfp_sm_file_open.c:245
MPIR_Err_setmsg
int MPIR_Err_setmsg(int, int, const char *, const char *, const char *,...)
ADIOI_HFS_Fcntl
void ADIOI_HFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
Definition: ad_hfs_fcntl.c:14
ADIO_Offset
long ADIO_Offset
Definition: adio.h:111
ADIO_Fcntl_t::diskspace
ADIO_Offset diskspace
Definition: adio.h:256
ADIO_FCNTL_GET_FSIZE
#define ADIO_FCNTL_GET_FSIZE
Definition: adio.h:308
MPIR_ADIO_ERROR
#define MPIR_ADIO_ERROR
Definition: mpio_error.h:45
ADIOI_FileD::atomicity
int atomicity
Definition: adio.h:229
ADIOI_FileD
Definition: adio.h:187
flag
*f90 Inc All rights reserved LLC All rights ! reserved & flag
Definition: attr-fn-int-callback-interfaces.h:26
ADIO_Fcntl_t::fsize
ADIO_Offset fsize
Definition: adio.h:255
ADIOI_GEN_Prealloc
void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset diskspace, int *error_code)
Definition: ad_prealloc.c:16
adio_extern.h
ADIOI_FileD::fd_sys
int fd_sys
Definition: adio.h:189
ADIO_Status
#define ADIO_Status
Definition: adio.h:115
ADIOI_FileD::fp_sys_posn
ADIO_Offset fp_sys_posn
Definition: adio.h:202
ADIO_Fcntl_t::atomicity
int atomicity
Definition: adio.h:254
ADIO_FCNTL_SET_DISKSPACE
#define ADIO_FCNTL_SET_DISKSPACE
Definition: adio.h:307
ADIO_FCNTL_SET_ATOMICITY
#define ADIO_FCNTL_SET_ATOMICITY
Definition: adio.h:306