root/ompi/mca/io/romio321/romio/adio/ad_sfs/ad_sfs_fcntl.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_SFS_Fcntl

   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_sfs.h"
   9 #include "adio_extern.h"
  10 
  11 void ADIOI_SFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
  12 {
  13     int  i, ntimes, len;
  14     ADIO_Offset curr_fsize, alloc_size, size, done;
  15     ADIO_Status status;
  16     char *buf;
  17 #ifndef PRINT_ERR_MSG
  18     static char myname[] = "ADIOI_SFS_FCNTL";
  19 #endif
  20 
  21     switch(flag) {
  22     case ADIO_FCNTL_GET_FSIZE:
  23         /* On SFS, I find that a write from one process, which changes
  24            the file size, does not automatically make the new file size 
  25            visible to other processes. Therefore, a sync-barrier-sync is 
  26            needed. (Other processes are able to read the data written 
  27            though; only file size is returned incorrectly.) */
  28 
  29         fsync(fd->fd_sys);
  30         MPI_Barrier(fd->comm);
  31         fsync(fd->fd_sys);
  32         
  33         fcntl_struct->fsize = llseek(fd->fd_sys, 0, SEEK_END);
  34         if (fd->fp_sys_posn != -1) 
  35              llseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
  36         if (fcntl_struct->fsize == -1) {
  37 #ifdef MPICH
  38             *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
  39                 "**io %s", strerror(errno));
  40 #elif defined(PRINT_ERR_MSG)
  41             *error_code = MPI_ERR_UNKNOWN;
  42 #else /* MPICH-1 */
  43             *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  44                               myname, "I/O Error", "%s", strerror(errno));
  45             ADIOI_Error(fd, *error_code, myname);           
  46 #endif
  47         }
  48         else *error_code = MPI_SUCCESS;
  49         break;
  50 
  51     case ADIO_FCNTL_SET_DISKSPACE:
  52         ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
  53         break;
  54 
  55     case ADIO_FCNTL_SET_ATOMICITY:
  56         fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
  57         *error_code = MPI_SUCCESS;
  58         break;
  59 
  60     default:
  61         FPRINTF(stderr, "Unknown flag passed to ADIOI_SFS_Fcntl\n");
  62         MPI_Abort(MPI_COMM_WORLD, 1);
  63     }
  64 }

/* [<][>][^][v][top][bottom][index][help] */