root/ompi/mca/io/romio321/romio/adio/ad_panfs/ad_panfs_resize.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PANFS_Resize

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 2004 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "ad_panfs.h"
   9 
  10 #ifdef HAVE_UNISTD_H
  11 #include <unistd.h>
  12 #endif
  13 
  14 void ADIOI_PANFS_Resize(ADIO_File fd, ADIO_Offset size, int *error_code)
  15 {
  16     int err;
  17     int myrank;
  18     struct stat stat_buf;
  19     static char myname[] = "ADIOI_PANFS_RESIZE";
  20 
  21     MPI_Comm_rank(fd->comm, &myrank);
  22     if (!myrank)
  23     {
  24         AD_PANFS_RETRY(ftruncate(fd->fd_sys,size),err);
  25         MPI_Barrier(fd->comm);
  26     }
  27     else
  28     {
  29         MPI_Barrier(fd->comm);
  30         AD_PANFS_RETRY(fstat(fd->fd_sys,&stat_buf),err);
  31         if(((ADIO_Offset)stat_buf.st_size) != size)
  32         {
  33             /* This should never happen otherwise there is a coherency problem. */
  34             FPRINTF(stderr, "%s: Rank %d: Resize failed: requested=%llu actual=%llu.\n",myname,myrank,size,(unsigned long long)stat_buf.st_size);
  35             MPI_Abort(MPI_COMM_WORLD, 1);
  36         }
  37     }
  38 
  39     /* --BEGIN ERROR HANDLING-- */
  40     if (err == -1) {
  41         *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  42                                            myname, __LINE__, MPI_ERR_IO,
  43                                            "**io", "**io %s", strerror(errno));
  44         return;
  45     }
  46     /* --END ERROR HANDLING-- */
  47 
  48     *error_code = MPI_SUCCESS;
  49 }

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