root/ompi/mca/io/romio321/romio/adio/ad_nfs/ad_nfs_setsh.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_NFS_Set_shared_fp

   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_nfs.h"
   9 
  10 /* set the shared file pointer to "offset" etypes relative to the current 
  11    view */
  12 
  13 /*
  14 This looks very similar to ADIOI_GEN_Set_shared_fp, except this 
  15 function avoids locking the file twice.  The generic version does
  16 
  17 Write lock
  18 ADIO_WriteContig
  19 Unlock
  20 
  21 For NFS, ADIOI_NFS_WriteContig does a lock before writing to disable
  22 caching. To avoid the lock being called twice, this version for NFS does
  23 
  24 Write lock
  25 Lseek
  26 Write
  27 Unlock 
  28 
  29 */
  30 
  31 void ADIOI_NFS_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code)
  32 {
  33     ssize_t err;
  34     MPI_Comm dupcommself;
  35     static char myname[] = "ADIOI_NFS_SET_SHARED_FP";
  36 
  37     if (fd->shared_fp_fd == ADIO_FILE_NULL) {
  38         MPI_Comm_dup(MPI_COMM_SELF, &dupcommself);
  39         fd->shared_fp_fd = ADIO_Open(MPI_COMM_SELF, dupcommself,
  40                                      fd->shared_fp_fname, 
  41                                      fd->file_system, fd->fns,
  42                                      ADIO_CREATE | ADIO_RDWR | ADIO_DELETE_ON_CLOSE, 
  43                                      0, MPI_BYTE, MPI_BYTE, MPI_INFO_NULL, 
  44                                      ADIO_PERM_NULL, error_code);
  45     }
  46 
  47     if (*error_code != MPI_SUCCESS) return;
  48 
  49     ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
  50 #ifdef ADIOI_MPE_LOGGING
  51     MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
  52 #endif
  53     lseek(fd->shared_fp_fd->fd_sys, 0, SEEK_SET);
  54 #ifdef ADIOI_MPE_LOGGING
  55     MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
  56 #endif
  57 #ifdef ADIOI_MPE_LOGGING
  58     MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
  59 #endif
  60     err = write(fd->shared_fp_fd->fd_sys, &offset, sizeof(ADIO_Offset));
  61 #ifdef ADIOI_MPE_LOGGING
  62     MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
  63 #endif
  64     ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
  65 
  66     if (err == -1) {
  67         *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  68                                            myname, __LINE__, MPI_ERR_IO,
  69                                            "**io",
  70                                            "**io %s", strerror(errno));
  71     }
  72     else *error_code = MPI_SUCCESS;
  73 }
  74 

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