summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-05-14 20:28:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-05-14 20:28:37 (GMT)
commit2e2a1d8e31df6e924eecb19691feeee974e32d71 (patch)
tree89f05eb7552494ce79a600d81e02c09ad13c2093
parent390209e72e2a7e87c776be7acfc545ca29b795b4 (diff)
downloadhdf5-2e2a1d8e31df6e924eecb19691feeee974e32d71.zip
hdf5-2e2a1d8e31df6e924eecb19691feeee974e32d71.tar.gz
hdf5-2e2a1d8e31df6e924eecb19691feeee974e32d71.tar.bz2
[svn-r5419] Purpose:
Bug fix. Description: Added barrier to flush routine to prevent race condition where file could be truncated. Platforms tested: IRIX64 6.5 (modi4)
-rw-r--r--src/H5FDmpio.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index cca989b..f4ba335 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -1617,8 +1617,19 @@ H5FD_mpio_flush(H5FD_t *_file)
#else /* OLD_WAY */
if (haddr_to_MPIOff(file->eoa, &mpi_off)<0)
HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset");
+
+ /* Extend the file's size */
if (MPI_SUCCESS != MPI_File_set_size(file->f, mpi_off))
HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_size failed");
+
+ /* Don't let any proc return until all have extended the file.
+ * (Prevents race condition where some processes go ahead and write
+ * more data to the file before all the processes have finished making
+ * it the shorter length, potentially truncating the file and dropping
+ * the new data written)
+ */
+ if (MPI_SUCCESS!= MPI_Barrier(file->comm))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed");
#endif /* OLD_WAY */
/* Update the 'last' eoa value */