Commit 9e474152 authored by David Goodell's avatar David Goodell
Browse files

[svn-r10641] only one task should actually delete in ADIO_Close

Contributed by IBM.  Based on patch 0013 from code discussions.
parent 1afe0227
......@@ -14,7 +14,8 @@
void ADIO_Close(ADIO_File fd, int *error_code)
{
int i, j, k, combiner, myrank, err, is_contig;
int err = MPI_SUCCESS;
int i, j, k, combiner, myrank, is_contig;
static char myname[] = "ADIO_CLOSE";
if (fd->async_count) {
......@@ -47,14 +48,21 @@ void ADIO_Close(ADIO_File fd, int *error_code)
}
if (fd->access_mode & ADIO_DELETE_ON_CLOSE) {
int is_agg_ldr = 0;
ADIOI_IS_AGG_LEADER(fd, &is_agg_ldr);
/* if we are doing aggregation and deferred open, then it's possible
* that rank 0 does not have access to the file. make sure only an
* aggregator deletes the file.*/
MPI_Comm_rank(fd->comm, &myrank);
if (myrank == fd->hints->ranklist[0]) {
ADIO_Delete(fd->filename, &err);
if (is_agg_ldr) {
ADIO_Delete(fd->filename, &err);
}
MPI_Barrier(fd->comm);
MPI_Bcast(&err, 1, MPI_INT, fd->hints->ranklist[0], fd->comm);
if (err != MPI_SUCCESS) {
*error_code = err;
return;
}
}
if (fd->fortran_handle != -1) {
......
......@@ -18,9 +18,7 @@ void ADIOI_GEN_Delete(const char *filename, int *error_code)
err = unlink(filename);
if (err == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_IO, "**io",
"**io %s", strerror(errno));
*error_code = ADIOI_Err_create_code(myname, filename, errno);
return;
}
else *error_code = MPI_SUCCESS;
......
......@@ -78,6 +78,13 @@ struct ADIOI_Hints_struct {
};
#define ADIOI_IS_AGG_LEADER(fh_, is_agg_p_) \
do { \
int rank_; \
MPI_Comm_rank((fh_)->comm, &rank_); \
*(is_agg_p_) = ((fh_)->hints->ranklist[0] == 0); \
} while (0)
typedef struct ADIOI_Datarep {
char *name;
void *state;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment