This source file includes following definitions.
- ADIOI_LUSTRE_Fcntl
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 #include "ad_lustre.h"
  10 #include "adio_extern.h"
  11 
  12 void ADIOI_LUSTRE_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
  13 {
  14     int i, ntimes;
  15     ADIO_Offset curr_fsize, alloc_size, size, len, done;
  16     ADIO_Status status;
  17     char *buf;
  18 #if defined(MPICH) || !defined(PRINT_ERR_MSG)
  19     static char myname[] = "ADIOI_LUSTRE_FCNTL";
  20 #endif
  21 
  22     switch(flag) {
  23     case ADIO_FCNTL_GET_FSIZE:
  24         fcntl_struct->fsize = lseek(fd->fd_sys, 0, SEEK_END);
  25         if (fd->fp_sys_posn != -1) 
  26              lseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
  27         if (fcntl_struct->fsize == -1) {
  28             *error_code = MPIO_Err_create_code(MPI_SUCCESS, 
  29                     MPIR_ERR_RECOVERABLE, myname, __LINE__, 
  30                     MPI_ERR_IO, "**io", "**io %s", strerror(errno));
  31         }
  32         else *error_code = MPI_SUCCESS;
  33         break;
  34 
  35     case ADIO_FCNTL_SET_DISKSPACE:
  36         
  37         
  38 
  39 
  40 
  41 
  42 
  43 
  44 
  45         curr_fsize = lseek(fd->fd_sys, 0, SEEK_END);
  46         alloc_size = fcntl_struct->diskspace;
  47 
  48         size = ADIOI_MIN(curr_fsize, alloc_size);
  49         
  50         ntimes = (size + ADIOI_PREALLOC_BUFSZ - 1)/ADIOI_PREALLOC_BUFSZ;
  51         buf = (char *) ADIOI_Malloc(ADIOI_PREALLOC_BUFSZ);
  52         done = 0;
  53 
  54         for (i=0; i<ntimes; i++) {
  55             len = ADIOI_MIN(size-done, ADIOI_PREALLOC_BUFSZ);
  56             ADIO_ReadContig(fd, buf, len, MPI_BYTE, ADIO_EXPLICIT_OFFSET, done,
  57                             &status, error_code);
  58             if (*error_code != MPI_SUCCESS) {
  59                 *error_code = MPIO_Err_create_code(MPI_SUCCESS, 
  60                         MPIR_ERR_RECOVERABLE, myname, __LINE__, 
  61                         MPI_ERR_IO, "**io", "**io %s", strerror(errno));
  62                 return;  
  63             }
  64             ADIO_WriteContig(fd, buf, len, MPI_BYTE, ADIO_EXPLICIT_OFFSET, 
  65                              done, &status, error_code);
  66             if (*error_code != MPI_SUCCESS) return;
  67             done += len;
  68         }
  69 
  70         if (alloc_size > curr_fsize) {
  71             memset(buf, 0, ADIOI_PREALLOC_BUFSZ); 
  72             size = alloc_size - curr_fsize;
  73             ntimes = (size + ADIOI_PREALLOC_BUFSZ - 1)/ADIOI_PREALLOC_BUFSZ;
  74             for (i=0; i<ntimes; i++) {
  75                 len = ADIOI_MIN(alloc_size-done, ADIOI_PREALLOC_BUFSZ);
  76                 ADIO_WriteContig(fd, buf, len, MPI_BYTE, ADIO_EXPLICIT_OFFSET, 
  77                                  done, &status, error_code);
  78                 if (*error_code != MPI_SUCCESS) return;
  79                 done += len;  
  80             }
  81         }
  82         ADIOI_Free(buf);
  83         if (fd->fp_sys_posn != -1) 
  84             lseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
  85         *error_code = MPI_SUCCESS;
  86         break;
  87 
  88     case ADIO_FCNTL_SET_ATOMICITY:
  89         fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
  90         *error_code = MPI_SUCCESS;
  91         break;
  92 
  93     default:
  94         FPRINTF(stderr, "Unknown flag passed to ADIOI_LUSTRE_Fcntl\n");
  95         MPI_Abort(MPI_COMM_WORLD, 1);
  96     }
  97 }