diff options
-rw-r--r-- | src/H5F.c | 20 | ||||
-rw-r--r-- | src/H5Flow.c | 51 | ||||
-rw-r--r-- | src/H5Fmpio.c | 11 | ||||
-rw-r--r-- | src/H5Fprivate.h | 1 |
4 files changed, 39 insertions, 44 deletions
@@ -1609,6 +1609,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate) { uint8_t buf[2048], *p = buf; haddr_t reserved_addr; + uintn firsttime_bootblock=0; uintn nerrors=0, i; FUNC_ENTER(H5F_flush, FAIL); @@ -1677,20 +1678,23 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate) H5F_addr_reset(&(f->shared->hdf5_eof)); H5F_addr_inc(&(f->shared->hdf5_eof), (hsize_t)(p-buf)); H5F_low_seteof(f->shared->lf, &(f->shared->hdf5_eof)); + firsttime_bootblock=1; } /* write the boot block to disk */ + if(!firsttime_bootblock) { #ifdef HAVE_PARALLEL - H5F_mpio_tas_allsame(f->shared->lf, TRUE); /* only p0 will write */ + H5F_mpio_tas_allsame(f->shared->lf, TRUE); /* only p0 will write */ #endif - if (H5F_low_write(f->shared->lf, f->shared->access_parms, &H5F_xfer_dflt, - &(f->shared->boot_addr), (size_t)(p-buf), buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write header"); - } + if (H5F_low_write(f->shared->lf, f->shared->access_parms, &H5F_xfer_dflt, + &(f->shared->boot_addr), (size_t)(p-buf), buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write header"); + } - /* Flush file buffers to disk */ - if (H5F_low_flush(f->shared->lf, f->shared->access_parms) < 0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed"); + /* Flush file buffers to disk */ + if (H5F_low_flush(f->shared->lf, f->shared->access_parms) < 0) { + HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed"); + } } /* Check flush errors for children - errors are already on the stack */ diff --git a/src/H5Flow.c b/src/H5Flow.c index b3c0df1..3ac4cf1 100644 --- a/src/H5Flow.c +++ b/src/H5Flow.c @@ -284,39 +284,14 @@ H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms, assert(buf); /* check for writing past the end of file marker */ -#ifdef HAVE_PARALLEL - if (H5F_LOW_MPIO==access_parms->driver && - access_parms->u.mpio.use_types) { - /* rky 090902 KLUGE - * In the case of fancy use of MPI datatypes, the addr and size - * parameters have a very peculiar interpretation. - * It is logically possible, but quite complex, to calculate - * the physical offset that the last byte to be written will have - * (assuming the write doesn't fail partway thru, which it may). - * I don't yet fully understand the relationship between - * the lf->eof processor-local variable and the file's true eof. - * But presumably lf->eof has the correct value at this point, - * and we should _not_ change it, - * even if the file's true eof differs from the value of lf->eof. - * So for now we DO NOTHING! - * (Eventually, perhaps we should at least calculate the address - * of the last byte of this write, and compare it to lf->eof.) */ - } else { -#endif /* HAVE_PARALLEL */ - /* writing a simple block of bytes; can check for writing beyond eof */ - tmp_addr = *addr; - H5F_addr_inc(&tmp_addr, (hsize_t)size); - if (H5F_addr_gt(&tmp_addr, &(lf->eof))) { -#ifdef H5F_DEBUG - if (H5DEBUG(F)) { - fprintf(H5DEBUG(F), "H5F: extending file w/o allocation\n"); - } -#endif - lf->eof = tmp_addr; - } -#ifdef HAVE_PARALLEL - } /* end else */ -#endif /* HAVE_PARALLEL */ + tmp_addr = *addr; + H5F_addr_inc(&tmp_addr, (hsize_t)size); + if (H5F_addr_gt(&tmp_addr, &(lf->eof))) + HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, ret_value, "write past end of logical file"); + + /* Check if the last byte of the logical file has been written */ + if (!lf->eof_written && H5F_addr_eq(&tmp_addr, &(lf->eof))) + lf->eof_written=1; /* Write the data */ if (lf->type->write) { @@ -366,10 +341,8 @@ H5F_low_flush(H5F_low_t *lf, const H5F_access_t *access_parms) assert(lf && lf->type); /* Make sure the last block of the file has been allocated on disk */ - /* rky 980828 NOTE - * Is this really necessary? Could this be eliminated for MPI-IO files? */ H5F_addr_reset(&last_byte); - if (addr_defined(&(lf->eof)) && H5F_addr_gt(&(lf->eof), &last_byte)) { + if (!lf->eof_written && addr_defined(&(lf->eof)) && H5F_addr_gt(&(lf->eof), &last_byte)) { last_byte = lf->eof; last_byte.offset -= 1; if (H5F_low_read(lf, access_parms, &H5F_xfer_dflt, &last_byte, @@ -380,6 +353,9 @@ H5F_low_flush(H5F_low_t *lf, const H5F_access_t *access_parms) H5F_low_write(lf, access_parms, &H5F_xfer_dflt, &last_byte, 1, buf); } + else + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "low level flush failed"); } /* Invoke the subclass the flush method */ if (lf->type->flush) { @@ -563,6 +539,9 @@ H5F_low_extend(H5F_low_t *lf, const H5F_access_t *access_parms, intn op, assert(size > 0); assert(addr); + /* Reset the EOF written flag */ + lf->eof_written=0; + if (lf->type->extend) { if ((lf->type->extend) (lf, access_parms, op, size, addr/*out*/) < 0) { HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, diff --git a/src/H5Fmpio.c b/src/H5Fmpio.c index 753d6ca..b960741 100644 --- a/src/H5Fmpio.c +++ b/src/H5Fmpio.c @@ -328,6 +328,17 @@ H5F_mpio_open(const char *name, const H5F_access_t *access_parms, uintn flags, if (flags&H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL; #ifdef H5Fmpio_DEBUG + { + /* set debug mask */ + /* Should this be done in H5F global initialization instead of here? */ + const char *s = HDgetenv ("H5F_mpio_Debug"); + if (s) { + while (*s){ + H5F_mpio_Debug[(int)*s]++; + s++; + } + } + } /* Check for debug commands in the info parameter */ { char debug_str[128]; int infoerr, flag, i; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index ad9d86f..c0a111e 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -381,6 +381,7 @@ typedef struct H5F_low_class_t { typedef struct H5F_low_t { const H5F_low_class_t *type;/* What type of file is this? */ haddr_t eof; /* Address of logical end-of-file */ + uint eof_written; /* whether the last byte is written */ union { /* File families */ |