From 5ba9869b4984935f3ee7eddc1337859ef50aa61e Mon Sep 17 00:00:00 2001 From: Robert Kim Yates Date: Mon, 7 Dec 1998 18:21:41 -0500 Subject: [svn-r961] Added barrier after MPI_File_set_size to prevent race condition: subsequent writes were being truncated, causing holes in file. --- src/H5Fmpio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 */ -- cgit v0.12