mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-12 17:31:09 +08:00
[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)
This commit is contained in:
parent
4b7fe91126
commit
700e339e10
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user