mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-06 14:56:51 +08:00
[svn-r1276] H5D.c:
H5F.c: H5Flow.c: H5Fprivate.h: Joined work by Quincey, Robb and me to eliminate the initial writes of BOOTBLOCK when the file is first created. Also, eliminate the repeatedly encoding of BOOTBLOCK in the flushing code. Introduced the eof_written flag to indicate when it is not necessary to go do a dumb write at eof. (But something is not right if the userblock is not zero.) H5Fmpio.c: Added code to allow setting the MPIO debug output mask via the environment variable H5F_mpio_Debug.
This commit is contained in:
parent
20811af57b
commit
9282a3e357
20
src/H5F.c
20
src/H5F.c
@ -1609,6 +1609,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate)
|
|||||||
{
|
{
|
||||||
uint8_t buf[2048], *p = buf;
|
uint8_t buf[2048], *p = buf;
|
||||||
haddr_t reserved_addr;
|
haddr_t reserved_addr;
|
||||||
|
uintn firsttime_bootblock=0;
|
||||||
uintn nerrors=0, i;
|
uintn nerrors=0, i;
|
||||||
|
|
||||||
FUNC_ENTER(H5F_flush, FAIL);
|
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_reset(&(f->shared->hdf5_eof));
|
||||||
H5F_addr_inc(&(f->shared->hdf5_eof), (hsize_t)(p-buf));
|
H5F_addr_inc(&(f->shared->hdf5_eof), (hsize_t)(p-buf));
|
||||||
H5F_low_seteof(f->shared->lf, &(f->shared->hdf5_eof));
|
H5F_low_seteof(f->shared->lf, &(f->shared->hdf5_eof));
|
||||||
|
firsttime_bootblock=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write the boot block to disk */
|
/* write the boot block to disk */
|
||||||
|
if(!firsttime_bootblock) {
|
||||||
#ifdef HAVE_PARALLEL
|
#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
|
#endif
|
||||||
if (H5F_low_write(f->shared->lf, f->shared->access_parms, &H5F_xfer_dflt,
|
if (H5F_low_write(f->shared->lf, f->shared->access_parms, &H5F_xfer_dflt,
|
||||||
&(f->shared->boot_addr), (size_t)(p-buf), buf)<0) {
|
&(f->shared->boot_addr), (size_t)(p-buf), buf)<0) {
|
||||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write header");
|
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write header");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush file buffers to disk */
|
/* Flush file buffers to disk */
|
||||||
if (H5F_low_flush(f->shared->lf, f->shared->access_parms) < 0) {
|
if (H5F_low_flush(f->shared->lf, f->shared->access_parms) < 0) {
|
||||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed");
|
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check flush errors for children - errors are already on the stack */
|
/* Check flush errors for children - errors are already on the stack */
|
||||||
|
51
src/H5Flow.c
51
src/H5Flow.c
@ -284,39 +284,14 @@ H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
|||||||
assert(buf);
|
assert(buf);
|
||||||
|
|
||||||
/* check for writing past the end of file marker */
|
/* check for writing past the end of file marker */
|
||||||
#ifdef HAVE_PARALLEL
|
tmp_addr = *addr;
|
||||||
if (H5F_LOW_MPIO==access_parms->driver &&
|
H5F_addr_inc(&tmp_addr, (hsize_t)size);
|
||||||
access_parms->u.mpio.use_types) {
|
if (H5F_addr_gt(&tmp_addr, &(lf->eof)))
|
||||||
/* rky 090902 KLUGE
|
HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, ret_value, "write past end of logical file");
|
||||||
* In the case of fancy use of MPI datatypes, the addr and size
|
|
||||||
* parameters have a very peculiar interpretation.
|
/* Check if the last byte of the logical file has been written */
|
||||||
* It is logically possible, but quite complex, to calculate
|
if (!lf->eof_written && H5F_addr_eq(&tmp_addr, &(lf->eof)))
|
||||||
* the physical offset that the last byte to be written will have
|
lf->eof_written=1;
|
||||||
* (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 */
|
|
||||||
|
|
||||||
/* Write the data */
|
/* Write the data */
|
||||||
if (lf->type->write) {
|
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);
|
assert(lf && lf->type);
|
||||||
|
|
||||||
/* Make sure the last block of the file has been allocated on disk */
|
/* 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);
|
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 = lf->eof;
|
||||||
last_byte.offset -= 1;
|
last_byte.offset -= 1;
|
||||||
if (H5F_low_read(lf, access_parms, &H5F_xfer_dflt, &last_byte,
|
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,
|
H5F_low_write(lf, access_parms, &H5F_xfer_dflt, &last_byte,
|
||||||
1, buf);
|
1, buf);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
|
||||||
|
"low level flush failed");
|
||||||
}
|
}
|
||||||
/* Invoke the subclass the flush method */
|
/* Invoke the subclass the flush method */
|
||||||
if (lf->type->flush) {
|
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(size > 0);
|
||||||
assert(addr);
|
assert(addr);
|
||||||
|
|
||||||
|
/* Reset the EOF written flag */
|
||||||
|
lf->eof_written=0;
|
||||||
|
|
||||||
if (lf->type->extend) {
|
if (lf->type->extend) {
|
||||||
if ((lf->type->extend) (lf, access_parms, op, size, addr/*out*/) < 0) {
|
if ((lf->type->extend) (lf, access_parms, op, size, addr/*out*/) < 0) {
|
||||||
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
|
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
|
||||||
|
@ -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;
|
if (flags&H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL;
|
||||||
|
|
||||||
#ifdef H5Fmpio_DEBUG
|
#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 */
|
/* Check for debug commands in the info parameter */
|
||||||
{ char debug_str[128];
|
{ char debug_str[128];
|
||||||
int infoerr, flag, i;
|
int infoerr, flag, i;
|
||||||
|
@ -381,6 +381,7 @@ typedef struct H5F_low_class_t {
|
|||||||
typedef struct H5F_low_t {
|
typedef struct H5F_low_t {
|
||||||
const H5F_low_class_t *type;/* What type of file is this? */
|
const H5F_low_class_t *type;/* What type of file is this? */
|
||||||
haddr_t eof; /* Address of logical end-of-file */
|
haddr_t eof; /* Address of logical end-of-file */
|
||||||
|
uint eof_written; /* whether the last byte is written */
|
||||||
union {
|
union {
|
||||||
|
|
||||||
/* File families */
|
/* File families */
|
||||||
|
Loading…
Reference in New Issue
Block a user