summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2001-12-13 20:14:32 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2001-12-13 20:14:32 (GMT)
commit700e339e1054ae07c3093126de575be8e304424b (patch)
tree89e736167be15b42e5cc46584717efe9f0e011b4
parent4b7fe911263077521c00f7c2e3a8d651152fdef2 (diff)
downloadhdf5-700e339e1054ae07c3093126de575be8e304424b.zip
hdf5-700e339e1054ae07c3093126de575be8e304424b.tar.gz
hdf5-700e339e1054ae07c3093126de575be8e304424b.tar.bz2
[svn-r4723] Purpose:
Bug fix (or more like feature) Description: MPI_File_open does not truncate the filesize if file already exists. This created confusion during debugging as what the real file size is. It also interfere the real write bandwidth since the times required to allocate new disk-space vanishes for subsequent writes that are for offset shorter than previous file sizes. Added a MPI_File_set_size to reset the file size to 0 for every new file. Another bug is that the 'remove()' call may not work for MPIO/PHDF5 files. (e.g., filename may have some MPI prefix like "pfs:filename"). Replaced "remove" with MPI_File_delete for those cases. Platforms tested: modi4(pp) and eirene (pp)
-rw-r--r--perform/pio_engine.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/perform/pio_engine.c b/perform/pio_engine.c
index 0136a7f..4a41901 100644
--- a/perform/pio_engine.c
+++ b/perform/pio_engine.c
@@ -139,7 +139,7 @@ static herr_t do_read(file_descr *fd, iotype iot, long ndsets,
static herr_t do_fopen(iotype iot, char *fname, file_descr *fd /*out*/,
int flags);
static herr_t do_fclose(iotype iot, file_descr *fd);
-static void do_cleanupfile(char *fname);
+static void do_cleanupfile(iotype iot, char *fname);
/*
* Function: do_pio
@@ -328,7 +328,7 @@ fprintf(stderr, "filename=%s\n", fname);
/* Close file for read */
hrc = do_fclose(iot, &fd);
VRFY((hrc == SUCCESS), "do_fclose failed");
- do_cleanupfile(fname);
+ do_cleanupfile(iot, fname);
}
done:
@@ -950,17 +950,30 @@ do_fopen(iotype iot, char *fname, file_descr *fd /*out*/, int flags)
case MPIO:
if (flags & (PIO_CREATE | PIO_WRITE)) {
+ MPI_File_delete(fname, MPI_INFO_NULL);
mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &(fd->mpifd));
+ MPI_INFO_NULL, &fd->mpifd);
+ if (mrc != MPI_SUCCESS) {
+ fprintf(stderr, "MPI File Open failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+ /*since MPI_File_open with MPI_MODE_CREATE does not truncate */
+ /*filesize , set size to 0 explicitedly. */
+ mrc = MPI_File_set_size(fd->mpifd, 0);
+ if (mrc != MPI_SUCCESS) {
+ fprintf(stderr, "MPI_File_set_size failed\n");
+ GOTOERROR(FAIL);
+ }
+
} else {
mrc = MPI_File_open(pio_comm_g, fname, MPI_MODE_RDONLY,
- MPI_INFO_NULL, &(fd->mpifd));
+ MPI_INFO_NULL, &fd->mpifd);
+ if (mrc != MPI_SUCCESS) {
+ fprintf(stderr, "MPI File Open failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
}
- if (mrc != MPI_SUCCESS) {
- fprintf(stderr, "MPI File Open failed(%s)\n", fname);
- GOTOERROR(FAIL);
- }
break;
@@ -1032,7 +1045,7 @@ do_fclose(iotype iot, file_descr *fd /*out*/)
break;
case MPIO:
- mrc = MPI_File_close(&(fd->mpifd));
+ mrc = MPI_File_close(&fd->mpifd);
if (mrc != MPI_SUCCESS){
fprintf(stderr, "MPI File close failed\n");
@@ -1069,7 +1082,7 @@ done:
* Modifications:
*/
static void
-do_cleanupfile(char *fname)
+do_cleanupfile(iotype iot, char *fname)
{
if (pio_mpi_rank_g != 0)
return;
@@ -1077,7 +1090,16 @@ do_cleanupfile(char *fname)
if (clean_file_g == -1)
clean_file_g = (getenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0;
- if (clean_file_g)
- remove(fname);
+ if (clean_file_g){
+ switch (iot){
+ case RAW:
+ remove(fname);
+ break;
+ case MPIO:
+ case PHDF5:
+ MPI_File_delete(fname, MPI_INFO_NULL);
+ break;
+ }
+ }
}
#endif /* H5_HAVE_PARALLEL */