From 2e2a1d8e31df6e924eecb19691feeee974e32d71 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 14 May 2002 15:28:37 -0500 Subject: [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) --- src/H5FDmpio.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 */ -- cgit v0.12