Commit 7d44307f authored by Rob Latham's avatar Rob Latham
Browse files

partial fix for tt 1742

It would appear that we can get more than two gigs worth of data down to
the write(2) and read(2) system call, but those syscalls fail to process
all of it.  Perfectly valid behavior for unix to return less than
requested, but until now, ROMIO never dealt with it.

Still to do: update Blue Gene drivers

closes ticket #1742  , since that ticket is only asking about I/O to
less than two gigs.  Lots and Lots more work needed for larger than two
gigs.
parent 2de997d9
......@@ -22,15 +22,16 @@ void ADIOI_GEN_ReadContig(ADIO_File fd, void *buf, int count,
off_t err_lseek = -1;
ssize_t err = -1;
int datatype_size;
ADIO_Offset len;
ADIO_Offset len, bytes_xfered=0;
size_t rd_count;
static char myname[] = "ADIOI_GEN_READCONTIG";
char *p;
#ifdef AGGREGATION_PROFILE
MPE_Log_event (5034, 0, NULL);
#endif
MPI_Type_size(datatype, &datatype_size);
len = (ADIO_Offset)datatype_size * (ADIO_Offset)count;
ADIOI_Assert(len == (unsigned int) len); /* read takes an unsigned int parm */
if (file_ptr_type == ADIO_INDIVIDUAL) {
offset = fd->fp_ind;
......@@ -57,33 +58,46 @@ void ADIOI_GEN_ReadContig(ADIO_File fd, void *buf, int count,
/* --END ERROR HANDLING-- */
}
p=buf;
while (bytes_xfered < len) {
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
#endif
err = read(fd->fd_sys, buf, (unsigned int)len);
rd_count = len - bytes_xfered;
err = read(fd->fd_sys, p, rd_count);
/* --BEGIN ERROR HANDLING-- */
if (err == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE,
myname, __LINE__,
MPI_ERR_IO, "**io",
"**io %s", strerror(errno));
fd->fp_sys_posn = -1;
return;
}
/* --END ERROR HANDLING-- */
if (err == 0) {
/* end of file */
break;
}
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
#endif
/* --BEGIN ERROR HANDLING-- */
if (err == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE,
myname, __LINE__,
MPI_ERR_IO, "**io",
"**io %s", strerror(errno));
fd->fp_sys_posn = -1;
return;
bytes_xfered += err;
p += err;
}
/* --END ERROR HANDLING-- */
fd->fp_sys_posn = offset + err;
fd->fp_sys_posn = offset + bytes_xfered;
if (file_ptr_type == ADIO_INDIVIDUAL) {
fd->fp_ind += err;
fd->fp_ind += bytes_xfered;
}
#ifdef HAVE_STATUS_SET_BYTES
if (err != -1) MPIR_Status_set_bytes(status, datatype, err);
/* what if we only read half a datatype? */
/* bytes_xfered could be larger than int */
if (err != -1) MPIR_Status_set_bytes(status, datatype, bytes_xfered);
#endif
*error_code = MPI_SUCCESS;
......
......@@ -22,8 +22,10 @@ void ADIOI_GEN_WriteContig(ADIO_File fd, const void *buf, int count,
off_t err_lseek = -1;
ssize_t err = -1;
int datatype_size;
ADIO_Offset len;
ADIO_Offset len, bytes_xfered=0;
size_t wr_count;
static char myname[] = "ADIOI_GEN_WRITECONTIG";
char * p;
#ifdef AGGREGATION_PROFILE
MPE_Log_event (5036, 0, NULL);
......@@ -31,7 +33,6 @@ void ADIOI_GEN_WriteContig(ADIO_File fd, const void *buf, int count,
MPI_Type_size(datatype, &datatype_size);
len = (ADIO_Offset)datatype_size * (ADIO_Offset)count;
ADIOI_Assert(len == (unsigned int) len); /* read takes an unsigned int parm */
if (file_ptr_type == ADIO_INDIVIDUAL) {
offset = fd->fp_ind;
......@@ -58,33 +59,40 @@ void ADIOI_GEN_WriteContig(ADIO_File fd, const void *buf, int count,
/* --END ERROR HANDLING-- */
}
p = (char *)buf;
while (bytes_xfered < len) {
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
#endif
err = write(fd->fd_sys, buf, (unsigned int)len);
wr_count = len - bytes_xfered;
err = write(fd->fd_sys, p, wr_count);
/* --BEGIN ERROR HANDLING-- */
if (err == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE,
myname, __LINE__,
MPI_ERR_IO, "**io",
"**io %s", strerror(errno));
fd->fp_sys_posn = -1;
return;
}
/* --END ERROR HANDLING-- */
#ifdef ADIOI_MPE_LOGGING
MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
#endif
/* --BEGIN ERROR HANDLING-- */
if (err == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE,
myname, __LINE__,
MPI_ERR_IO, "**io",
"**io %s", strerror(errno));
fd->fp_sys_posn = -1;
return;
bytes_xfered += err;
p += err;
}
/* --END ERROR HANDLING-- */
fd->fp_sys_posn = offset + err;
fd->fp_sys_posn = offset + bytes_xfered;
if (file_ptr_type == ADIO_INDIVIDUAL) {
fd->fp_ind += err;
fd->fp_ind += bytes_xfered;
}
#ifdef HAVE_STATUS_SET_BYTES
if (err != -1 && status) MPIR_Status_set_bytes(status, datatype, err);
/* bytes_xfered could be larger than int */
if (err != -1 && status) MPIR_Status_set_bytes(status, datatype, bytes_xfered);
#endif
*error_code = MPI_SUCCESS;
......
......@@ -706,6 +706,10 @@ fi
#
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_OFF_T
# Header files
# Find the CPP before the header check
AC_PROG_CPP
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment