void ADIOI_SFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { int i, ntimes, len; ADIO_Offset curr_fsize, alloc_size, size, done; ADIO_Status status; char *buf; #ifndef PRINT_ERR_MSG static char myname[] = "ADIOI_SFS_FCNTL"; #endif switch(flag) { case ADIO_FCNTL_GET_FSIZE: /* On SFS, I find that a write from one process, which changes the file size, does not automatically make the new file size visible to other processes. Therefore, a sync-barrier-sync is needed. (Other processes are able to read the data written though; only file size is returned incorrectly.) */ fsync(fd->fd_sys); MPI_Barrier(fd->comm); fsync(fd->fd_sys); fcntl_struct->fsize = llseek(fd->fd_sys, 0, SEEK_END); if (fd->fp_sys_posn != -1) llseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET); if (fcntl_struct->fsize == -1) { #ifdef MPICH2 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); #elif defined(PRINT_ERR_MSG) *error_code = MPI_ERR_UNKNOWN; #else /* MPICH-1 */ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR, myname, "I/O Error", "%s", strerror(errno)); ADIOI_Error(fd, *error_code, myname); #endif } else *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; case ADIO_FCNTL_SET_ATOMICITY: fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1; *error_code = MPI_SUCCESS; break; default: FPRINTF(stderr, "Unknown flag passed to ADIOI_SFS_Fcntl\n"); MPI_Abort(MPI_COMM_WORLD, 1); } }
void ADIOI_GEN_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t * fcntl_struct, int *error_code) { static char myname[] = "ADIOI_GEN_FCNTL"; switch (flag) { case ADIO_FCNTL_GET_FSIZE: #ifdef ADIOI_MPE_LOGGING MPE_Log_event(ADIOI_MPE_lseek_a, 0, NULL); #endif fcntl_struct->fsize = lseek(fd->fd_sys, 0, SEEK_END); #ifdef ADIOI_MPE_LOGGING MPE_Log_event(ADIOI_MPE_lseek_b, 0, NULL); #endif if (fd->fp_sys_posn != -1) { #ifdef ADIOI_MPE_LOGGING MPE_Log_event(ADIOI_MPE_lseek_a, 0, NULL); #endif lseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET); #ifdef ADIOI_MPE_LOGGING MPE_Log_event(ADIOI_MPE_lseek_b, 0, NULL); #endif } if (fcntl_struct->fsize == -1) { *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); } else *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; case ADIO_FCNTL_SET_ATOMICITY: fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1; *error_code = MPI_SUCCESS; break; /* --BEGIN ERROR HANDLING-- */ default: *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**flag", "**flag %d", flag); /* --END ERROR HANDLING-- */ } }
void ADIOI_PVFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { static char myname[] = "ADIOI_PVFS_FCNTL"; switch(flag) { case ADIO_FCNTL_GET_FSIZE: fcntl_struct->fsize = pvfs_lseek64(fd->fd_sys, 0, SEEK_END); if (fd->fp_sys_posn != -1) pvfs_lseek64(fd->fd_sys, fd->fp_sys_posn, SEEK_SET); if (fcntl_struct->fsize == -1) { *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); } else *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; case ADIO_FCNTL_SET_ATOMICITY: fd->atomicity = 0; /* --BEGIN ERROR HANDLING-- */ if (fcntl_struct->atomicity != 0) { *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_UNSUPPORTED_OPERATION, "PVFS does not support atomic mode", 0); return; } /* --END ERROR HANDLING-- */ break; default: /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**flag", "**flag %d", flag); return; /* --END ERROR HANDLING-- */ } }
void ADIOI_ZOIDFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { int ret; zoidfs_attr_t attr; ADIOI_ZOIDFS_object *zoidfs_obj_ptr; static char myname[] = "ADIOI_ZOIDFS_FCNTL"; zoidfs_obj_ptr = (ADIOI_ZOIDFS_object*)fd->fs_ptr; switch(flag) { case ADIO_FCNTL_GET_FSIZE: attr.mask = ZOIDFS_ATTR_SIZE; NO_STALE(ret, fd, zoidfs_obj_ptr, zoidfs_getattr(zoidfs_obj_ptr, &attr, ZOIDFS_NO_OP_HINT)); if ( !(attr.mask & ZOIDFS_ATTR_SIZE) || (ret != ZFS_OK ) ) { /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, ADIOI_ZOIDFS_error_convert(ret), "Error in zoidfs_getattr", 0); /* --END ERROR HANDLING-- */ } else { *error_code = MPI_SUCCESS; } fcntl_struct->fsize = attr.size; return; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; /* --BEGIN ERROR HANDLING-- */ case ADIO_FCNTL_SET_ATOMICITY: default: *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**flag", "**flag %d", flag); /* --END ERROR HANDLING-- */ } }
void ADIOI_PVFS2_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { int ret; ADIOI_PVFS2_fs *pvfs_fs; PVFS_sysresp_getattr resp_getattr; static char myname[] = "ADIOI_PVFS2_FCNTL"; pvfs_fs = (ADIOI_PVFS2_fs*)fd->fs_ptr; switch(flag) { case ADIO_FCNTL_GET_FSIZE: ret = PVFS_sys_getattr(pvfs_fs->object_ref, PVFS_ATTR_SYS_SIZE, &(pvfs_fs->credentials), &resp_getattr); if (ret != 0 ) { /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, ADIOI_PVFS2_error_convert(ret), "Error in PVFS_sys_getattr", 0); /* --END ERROR HANDLING-- */ } else { *error_code = MPI_SUCCESS; } fcntl_struct->fsize = resp_getattr.attr.size; return; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; /* --BEGIN ERROR HANDLING-- */ case ADIO_FCNTL_SET_ATOMICITY: default: *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**flag", "**flag %d", flag); /* --END ERROR HANDLING-- */ } }
void ADIOI_PIOFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { MPI_Datatype copy_etype, copy_filetype; int i, ntimes, err; ADIO_Offset curr_fsize, alloc_size, size, len, done; ADIO_Status status; char *buf; piofs_change_view_t *piofs_change_view; #ifndef PRINT_ERR_MSG static char myname[] = "ADIOI_PIOFS_FCNTL"; #endif switch(flag) { case ADIO_FCNTL_GET_FSIZE: fcntl_struct->fsize = llseek(fd->fd_sys, 0, SEEK_END); if (fd->fp_sys_posn != -1) llseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET); if (fcntl_struct->fsize == -1) { #ifdef MPICH *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); #elif defined(PRINT_ERR_MSG) *error_code = MPI_ERR_UNKNOWN; #else /* MPICH-1 */ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR, myname, "I/O Error", "%s", strerror(errno)); ADIOI_Error(fd, *error_code, myname); #endif } else *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; case ADIO_FCNTL_SET_ATOMICITY: piofs_change_view = (piofs_change_view_t *) ADIOI_Malloc(sizeof(piofs_change_view_t)); piofs_change_view->Vbs = piofs_change_view->Vn = piofs_change_view->Hbs = piofs_change_view->Hn = 1; piofs_change_view->subfile = 0; piofs_change_view->flags = (fcntl_struct->atomicity == 0) ? (ACTIVE | NORMAL) : (ACTIVE | CAUTIOUS); err = piofsioctl(fd->fd_sys, PIOFS_CHANGE_VIEW, piofs_change_view); ADIOI_Free(piofs_change_view); fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1; if (err == -1) { #ifdef MPICH *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); #elif defined(PRINT_ERR_MSG) *error_code = MPI_ERR_UNKNOWN; #else /* MPICH-1 */ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR, myname, "I/O Error", "%s", strerror(errno)); ADIOI_Error(fd, *error_code, myname); #endif } else *error_code = MPI_SUCCESS; break; default: FPRINTF(stderr, "Unknown flag passed to ADIOI_PIOFS_Fcntl\n"); MPI_Abort(MPI_COMM_WORLD, 1); } }
void ADIOI_NTFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { DWORD err; LONG dwTemp; static char myname[] = "ADIOI_NTFS_FCNTL"; switch(flag) { case ADIO_FCNTL_GET_FSIZE: fcntl_struct->fsize = SetFilePointer(fd->fd_sys, 0, 0, FILE_END); if (fd->fp_sys_posn != -1) { dwTemp = DWORDHIGH(fd->fp_sys_posn); if (SetFilePointer(fd->fd_sys, DWORDLOW(fd->fp_sys_posn), &dwTemp, FILE_BEGIN) == INVALID_SET_FILE_POINTER) { char errMsg[ADIOI_NTFS_ERR_MSG_MAX]; err = GetLastError(); ADIOI_NTFS_Strerror(err, errMsg, ADIOI_NTFS_ERR_MSG_MAX); if (err != NO_ERROR) { *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", errMsg); return; } } } /* --BEGIN ERROR HANDLING-- */ if (fcntl_struct->fsize == INVALID_SET_FILE_POINTER) { char errMsg[ADIOI_NTFS_ERR_MSG_MAX]; dwTemp = GetLastError(); ADIOI_NTFS_Strerror(dwTemp, errMsg, ADIOI_NTFS_ERR_MSG_MAX); *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", errMsg); return; } /* --END ERROR HANDLING-- */ *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; case ADIO_FCNTL_SET_ATOMICITY: fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1; *error_code = MPI_SUCCESS; /* fd->atomicity = 0; *error_code = MPI_ERR_UNSUPPORTED_OPERATION; */ break; default: /* --BEGIN ERROR HANDLING-- */ *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**flag", "**flag %d", flag); return; /* --END ERROR HANDLING-- */ } }
void ADIOI_GRIDFTP_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { MPI_Datatype copy_etype, copy_filetype; int combiner, i, j, k, filetype_is_contig, err; ADIOI_Flatlist_node *flat_file; char myname[]="ADIOI_GRIDFTP_Fcntl"; int myrank, nprocs; *error_code = MPI_SUCCESS; MPI_Comm_size(fd->comm, &nprocs); MPI_Comm_rank(fd->comm, &myrank); switch(flag) { case ADIO_FCNTL_GET_FSIZE: { globus_result_t result; globus_off_t fsize=0; globus_mutex_init(&fcntl_size_lock,GLOBUS_NULL); globus_cond_init(&fcntl_size_cond,GLOBUS_NULL); fcntl_size_done=GLOBUS_FALSE; if ( (result=globus_ftp_client_size(&(gridftp_fh[fd->fd_sys]), fd->filename, &(oattr[fd->fd_sys]), &(fsize), fcntl_size_cb, GLOBUS_NULL))!=GLOBUS_SUCCESS ) { globus_err_handler("globus_ftp_client_size",myname,result); *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", globus_object_printable_to_string(globus_error_get(result))); return; } globus_mutex_lock(&fcntl_size_lock); while ( fcntl_size_done!=GLOBUS_TRUE ) globus_cond_wait(&fcntl_size_lock,&fcntl_size_cond); globus_mutex_unlock(&fcntl_size_lock); globus_mutex_destroy(&fcntl_size_lock); globus_cond_destroy(&fcntl_size_cond); fcntl_struct->fsize=fsize; } *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_DISKSPACE: ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code); break; case ADIO_FCNTL_SET_ATOMICITY: default: *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_ARG, "**flag", "**flag %d", flag); } }
void ADIOI_HFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code) { int i, ntimes, err; ADIO_Offset curr_fsize, alloc_size, size, len, done; ADIO_Status status; char *buf; #ifndef PRINT_ERR_MSG static char myname[] = "ADIOI_HFS_FCNTL"; #endif switch(flag) { case ADIO_FCNTL_GET_FSIZE: fcntl_struct->fsize = lseek64(fd->fd_sys, 0, SEEK_END); #ifdef HPUX if (fd->fp_sys_posn != -1) lseek64(fd->fd_sys, fd->fp_sys_posn, SEEK_SET); /* not required in SPPUX since there we use pread/pwrite */ #endif if (fcntl_struct->fsize == -1) { #ifdef MPICH2 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); #elif defined(PRINT_ERR_MSG) *error_code = MPI_ERR_UNKNOWN; #else /* MPICH-1 */ *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR, myname, "I/O Error", "%s", strerror(errno)); ADIOI_Error(fd, *error_code, myname); #endif } else *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_DISKSPACE: /* will be called by one process only */ #ifdef HPUX err = prealloc64(fd->fd_sys, fcntl_struct->diskspace); /* prealloc64 works only if file is of zero length */ if (err && (errno != ENOTEMPTY)) { #ifdef MPICH2 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); #elif defined(PRINT_ERR_MSG) *error_code = MPI_ERR_UNKNOWN; #else *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR, myname, "I/O Error", "%s", strerror(errno)); ADIOI_Error(fd, *error_code, myname); #endif return; } if (err && (errno == ENOTEMPTY)) { #endif #ifdef SPPUX /* SPPUX has no prealloc64. therefore, use prealloc if size < (2GB - 1), otherwise use long method. */ if (fcntl_struct->diskspace <= 2147483647) { err = prealloc(fd->fd_sys, (off_t) fcntl_struct->diskspace); if (err && (errno != ENOTEMPTY)) { #ifdef MPICH2 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", strerror(errno)); #elif defined(PRINT_ERR_MSG) *error_code = MPI_ERR_UNKNOWN; #else *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR, myname, "I/O Error", "%s", strerror(errno)); ADIOI_Error(fd, *error_code, myname); #endif return; } } if ((fcntl_struct->diskspace > 2147483647) || (err && (errno == ENOTEMPTY))) { #endif ADIOI_GEN_Prealloc(fd,fcntl_struct->diskspace, error_code); } ADIOI_Free(buf); #ifdef HPUX if (fd->fp_sys_posn != -1) lseek64(fd->fd_sys, fd->fp_sys_posn, SEEK_SET); /* not required in SPPUX since there we use pread/pwrite */ #endif } *error_code = MPI_SUCCESS; break; case ADIO_FCNTL_SET_ATOMICITY: fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1; *error_code = MPI_SUCCESS; break; default: FPRINTF(stderr, "Unknown flag passed to ADIOI_HFS_Fcntl\n"); MPI_Abort(MPI_COMM_WORLD, 1); } }