summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Fmpio.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/H5Fmpio.c b/src/H5Fmpio.c
index a9ac303..cbe10ed 100644
--- a/src/H5Fmpio.c
+++ b/src/H5Fmpio.c
@@ -295,6 +295,10 @@ H5F_mpio_access(const char *name, const H5F_access_t *access_parms, int mode,
* Added H5F_mpio_Debug debug flags controlled by MPI_Info.
*
* rky 980828 Init flag controlling redundant metadata writes to disk.
+ *
+ * rky 19981207 Added barrier after MPI_File_set_size to prevent
+ * race condition: subsequent writes were being truncated,
+ * causing holes in file.
*-------------------------------------------------------------------------
*/
static H5F_low_t *
@@ -354,6 +358,12 @@ H5F_mpio_open(const char *name, const H5F_access_t *access_parms, uintn flags,
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
"MPI_File_set_size failed trying to truncate file" );
}
+ /* Don't let any proc return until all have truncated the file. */
+ mpierr = MPI_Barrier( access_parms->u.mpio.comm );
+ if (MPI_SUCCESS!=mpierr) {
+ MPI_File_close( &fh );
+ HRETURN_ERROR( H5E_IO, H5E_MPI, NULL, "MPI_Barrier failed" );
+ }
}
/* Build the return value */