00001
00002
00003
00004
00005
00006
00007 #include "adio.h"
00008 #include "adio_extern.h"
00009 #include "ad_zoidfs.h"
00010
00011 #include "ad_zoidfs_common.h"
00012
00013 #define ZOIDFS_READ 0
00014 #define ZOIDFS_WRITE 1
00015
00016 static void ZOIDFS_IOContig(ADIO_File fd, void * buf, int count,
00017 MPI_Datatype datatype, int file_ptr_type,
00018 ADIO_Offset offset, ADIO_Status *status,
00019 int flag, int *error_code)
00020 {
00021 int ret, datatype_size;
00022 uint64_t file_len;
00023 size_t mem_len;
00024 ADIOI_ZOIDFS_object *zoidfs_obj_ptr;
00025 uint64_t file_offset = offset;
00026 static char myname[] = "ADIOI_ZOIDFS_IOCONTIG";
00027
00028 zoidfs_obj_ptr = (ADIOI_ZOIDFS_object*)fd->fs_ptr;
00029
00030 MPI_Type_size(datatype, &datatype_size);
00031 file_len = mem_len = datatype_size * count;
00032
00033 if (file_ptr_type == ADIO_INDIVIDUAL) {
00034 file_offset = fd->fp_ind;
00035 }
00036
00037 if (flag == ZOIDFS_READ) {
00038 NO_STALE(ret, fd, zoidfs_obj_ptr,
00039 zoidfs_read(zoidfs_obj_ptr,
00040 1, &buf, &mem_len,
00041 1, &file_offset, &file_len, ZOIDFS_NO_OP_HINT));
00042 } else {
00043 NO_STALE(ret, fd, zoidfs_obj_ptr,
00044 zoidfs_write(zoidfs_obj_ptr,
00045 1, (const void **)&buf, &mem_len,
00046 1, &file_offset, &file_len, ZOIDFS_NO_OP_HINT));
00047 }
00048
00049 if (ret != ZFS_OK ) {
00050 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00051 MPIR_ERR_RECOVERABLE,
00052 myname, __LINE__,
00053 ADIOI_ZOIDFS_error_convert(ret),
00054 "Error in ZOIDFS I/O", 0);
00055 goto fn_exit;
00056 }
00057
00058
00059 if (file_ptr_type == ADIO_INDIVIDUAL) {
00060 fd->fp_ind += file_len;
00061 }
00062 fd->fp_sys_posn = file_offset + file_len;
00063
00064 #ifdef HAVE_STATUS_SET_BYTES
00065 MPIR_Status_set_bytes(status, datatype, file_len);
00066 #endif
00067
00068 *error_code = MPI_SUCCESS;
00069
00070 fn_exit:
00071 return;
00072 }
00073
00074 void ADIOI_ZOIDFS_ReadContig(ADIO_File fd, void *buf, int count,
00075 MPI_Datatype datatype, int file_ptr_type,
00076 ADIO_Offset offset, ADIO_Status *status,
00077 int *error_code)
00078 {
00079 ZOIDFS_IOContig(fd, buf, count, datatype, file_ptr_type,
00080 offset, status, ZOIDFS_READ, error_code);
00081 }
00082
00083 void ADIOI_ZOIDFS_WriteContig(ADIO_File fd, void *buf, int count,
00084 MPI_Datatype datatype, int file_ptr_type,
00085 ADIO_Offset offset, ADIO_Status *status,
00086 int *error_code)
00087 {
00088 ZOIDFS_IOContig(fd, buf, count, datatype, file_ptr_type,
00089 offset, status, ZOIDFS_WRITE, error_code);
00090 }
00091
00092
00093
00094
00095