00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_pfs.h"
00009 #include "adio_extern.h"
00010
00011 void ADIOI_PFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct,
00012 int *error_code)
00013 {
00014 int i, err;
00015 int iomod, np_total, np_comm;
00016 static char myname[] = "ADIOI_PFS_FCNTL";
00017
00018 switch(flag) {
00019 case ADIO_FCNTL_GET_FSIZE:
00020 if (!(fd->atomicity)) {
00021
00022
00023
00024
00025 MPI_Comm_size(MPI_COMM_WORLD, &np_total);
00026 MPI_Comm_size(fd->comm, &np_comm);
00027 if (np_total == np_comm) {
00028 err = _setiomode(fd->fd_sys, M_UNIX);
00029 err = _setiomode(fd->fd_sys, M_ASYNC);
00030 }
00031
00032 }
00033 fcntl_struct->fsize = lseek(fd->fd_sys, 0, SEEK_END);
00034 if (fd->fp_sys_posn != -1)
00035 lseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
00036 *error_code = MPI_SUCCESS;
00037 break;
00038
00039 case ADIO_FCNTL_SET_DISKSPACE:
00040 err = _lsize(fd->fd_sys, fcntl_struct->diskspace, SEEK_SET);
00041 if (err == -1) {
00042 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00043 MPIR_ERR_RECOVERABLE, myname,
00044 __LINE__, MPI_ERR_IO, "**io",
00045 "**io %s", strerror(errno));
00046 }
00047 else *error_code = MPI_SUCCESS;
00048 break;
00049
00050 case ADIO_FCNTL_SET_ATOMICITY:
00051 MPI_Comm_size(MPI_COMM_WORLD, &np_total);
00052 MPI_Comm_size(fd->comm, &np_comm);
00053 if (np_total == np_comm) {
00054 iomod = (fcntl_struct->atomicity == 0) ? M_ASYNC : M_UNIX;
00055 err = _setiomode(fd->fd_sys, iomod);
00056 }
00057
00058
00059
00060
00061 fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
00062 if (err == -1) {
00063
00064 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00065 MPIR_ERR_RECOVERABLE, myname,
00066 __LINE__, MPI_ERR_IO, "**io",
00067 "**io %s", strerror(errno));
00068
00069 }
00070 else *error_code = MPI_SUCCESS;
00071 break;
00072
00073 default:
00074
00075 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPI_ERR_RECOVERABLE,
00076 myname, __LINE__, MPI_ERR_ARG,
00077 "**flag", "**flag %d", flag);
00078 return;
00079
00080 }
00081 }