summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-09-10 19:02:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-09-10 19:02:40 (GMT)
commitf4d4d427b2f8bae72a12d4cdbee6acfc233b4c44 (patch)
tree37f5eb0424b03707bf38eb5608bd4bb8926e14e2 /src
parenteaf4ee3eb992809394f74e607b932482126a5b57 (diff)
downloadhdf5-f4d4d427b2f8bae72a12d4cdbee6acfc233b4c44.zip
hdf5-f4d4d427b2f8bae72a12d4cdbee6acfc233b4c44.tar.gz
hdf5-f4d4d427b2f8bae72a12d4cdbee6acfc233b4c44.tar.bz2
[svn-r17461] Description:
Fix a few more problems when the user block is not aligned properly. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5C.c8
-rw-r--r--src/H5F.c1
-rw-r--r--src/H5FD.c30
-rw-r--r--src/H5FDprivate.h1
-rw-r--r--src/H5Fdbg.c1
-rw-r--r--src/H5Fpkg.h1
-rw-r--r--src/H5Fsuper.c24
-rw-r--r--src/H5Fsuper_cache.c70
8 files changed, 90 insertions, 46 deletions
diff --git a/src/H5C.c b/src/H5C.c
index b90f963..7fc651b 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -6211,7 +6211,7 @@ H5C_protect(H5F_t * f,
/* Check for trying to load the wrong type of entry from an address */
if(entry_ptr->type != type)
- HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "not a dataset creation property list")
+ HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type")
hit = TRUE;
thing = (void *)entry_ptr;
@@ -10716,7 +10716,7 @@ end_of_inner_loop:
*/
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \
- "Can't unpin all pinned entries 1.")
+ "Pinned entry count not decreasing.")
} else if ( ( cur_pel_len == 0 ) && ( old_pel_len == 0 ) ) {
@@ -10759,7 +10759,7 @@ end_of_inner_loop:
} else if ( cur_pel_len > 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \
- "Can't unpin all pinned entries 2.")
+ "Can't unpin all pinned entries.")
}
@@ -10994,7 +10994,7 @@ H5C_flush_single_entry(H5F_t * f,
if ( NULL == (dxpl = H5I_object(primary_dxpl_id)) ) {
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, \
- "not a dataset creation property list")
+ "not a dataset transfer property list")
}
/* Get the transfer mode property */
diff --git a/src/H5F.c b/src/H5F.c
index e74b047..830cdd7 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -867,7 +867,6 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t)))
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure")
- f->shared->super_addr = HADDR_UNDEF;
f->shared->sohm_addr = HADDR_UNDEF;
f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION;
for(u = 0; u < NELMTS(f->shared->fs_addr); u++)
diff --git a/src/H5FD.c b/src/H5FD.c
index 8de2a1a..8a0e230 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -2088,3 +2088,33 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_set_base_addr() */
+
+/*--------------------------------------------------------------------------
+ * Function: H5FD_get_base_addr
+ *
+ * Purpose: Get the base address for the file
+ *
+ * Return: Success: The absolute base address of the file
+ * Failure: The undefined address (HADDR_UNDEF)
+ *
+ * Programmer: Quincey Koziol
+ * Sept. 10, 2009
+ *
+ *--------------------------------------------------------------------------
+ */
+haddr_t
+H5FD_get_base_addr(const H5FD_t *file)
+{
+ haddr_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FD_get_base_addr, HADDR_UNDEF)
+
+ HDassert(file);
+
+ /* Return the file's base address */
+ ret_value = file->base_addr;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_get_base_addr() */
+
diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h
index fc38566..cb40e5c 100644
--- a/src/H5FDprivate.h
+++ b/src/H5FDprivate.h
@@ -77,6 +77,7 @@ H5_DLL herr_t H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
H5_DLL herr_t H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum);
H5_DLL herr_t H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void** file_handle);
H5_DLL herr_t H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr);
+H5_DLL haddr_t H5FD_get_base_addr(const H5FD_t *file);
#endif /* !_H5FDprivate_H */
diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c
index 5f14357..2b13f11 100644
--- a/src/H5Fdbg.c
+++ b/src/H5Fdbg.c
@@ -60,7 +60,6 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth)
HDassert(stream);
HDassert(indent >= 0);
HDassert(fwidth >= 0);
- HDassert(f->shared->super_addr != HADDR_UNDEF);
/* Get property list */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 88ec8d9..cf40a86 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -192,7 +192,6 @@ typedef struct H5F_super_t {
typedef struct H5F_file_t {
H5FD_t *lf; /* Lower level file handle for I/O */
H5F_super_t *sblock; /* Pointer to (pinned) superblock for file */
- haddr_t super_addr; /* Address of superblock signature */
unsigned nrefs; /* Ref count for times file is opened */
unsigned flags; /* Access Permissions for file */
H5F_mtab_t mtab; /* File mount table */
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index f26d93f..e85c980 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -293,6 +293,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
{
H5F_super_t * sblock = NULL; /* superblock structure */
unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */
+ haddr_t super_addr; /* Absolute address of superblock */
H5AC_protect_t rw; /* read/write permissions for file */
hbool_t dirtied = FALSE; /* Bool for sblock protect call */
herr_t ret_value = SUCCEED; /* return value */
@@ -300,9 +301,16 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
FUNC_ENTER_NOAPI(H5F_super_read, FAIL)
/* Find the superblock */
- if(HADDR_UNDEF == (f->shared->super_addr = H5F_locate_signature(f->shared->lf, dxpl_id)))
+ if(HADDR_UNDEF == (super_addr = H5F_locate_signature(f->shared->lf, dxpl_id)))
HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to find file signature")
+ /* Check for userblock present */
+ if(H5F_addr_gt(super_addr, 0)) {
+ /* Set the base address for the file in the VFD now */
+ if(H5FD_set_base_addr(f->shared->lf, super_addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "failed to set base address for file driver")
+ } /* end if */
+
/* Determine file intent for superblock protect */
if(H5F_INTENT(f) & H5F_ACC_RDWR)
rw = H5AC_WRITE;
@@ -310,7 +318,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
rw = H5AC_READ;
/* Look up the superblock */
- if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, f->shared->super_addr, NULL, &dirtied, rw)))
+ if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, NULL, &dirtied, rw)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load superblock")
/* Mark the superblock dirty if it was modified during loading or VFD indicated to do so */
@@ -326,7 +334,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
done:
/* Release the superblock */
- if(sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, f->shared->super_addr, sblock, sblock_flags) < 0)
+ if(sblock && H5AC_unprotect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0)
HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock")
FUNC_LEAVE_NOAPI(ret_value)
@@ -359,7 +367,6 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
hsize_t superblock_size; /* Size of superblock, in bytes */
size_t driver_size; /* Size of driver info block (bytes) */
unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */
- haddr_t super_addr; /* Address of superblock */
hbool_t need_ext; /* Whether the superblock extension is needed */
herr_t ret_value = SUCCEED; /* Return Value */
@@ -471,17 +478,13 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_SUPER, superblock_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to set EOA value for superblock")
- /* Set the superblock's address, it must be immediately after any userblock */
- super_addr = (haddr_t)0;
-
/* Insert superblock into cache, pinned */
- if(H5AC_set(f, dxpl_id, H5AC_SUPERBLOCK, super_addr, sblock, H5AC__PIN_ENTRY_FLAG) < 0)
+ if(H5AC_set(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, sblock, H5AC__PIN_ENTRY_FLAG) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "can't add superblock to cache")
sblock_in_cache = TRUE;
/* Keep a copy of the superblock info */
f->shared->sblock = sblock;
- f->shared->super_addr = super_addr;
/*
* Determine if we will need a superblock extension
@@ -585,7 +588,7 @@ done:
HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock")
/* Evict the superblock from the cache */
- if(H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, super_addr, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_expunge_entry(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock")
} /* end if */
else
@@ -594,7 +597,6 @@ done:
/* Reset variables in file structure */
f->shared->sblock = NULL;
- f->shared->super_addr = HADDR_UNDEF;
} /* end if */
} /* end if */
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index 240ac9f..14454ef 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -111,9 +111,10 @@ H5FL_EXTERN(H5F_super_t);
*-------------------------------------------------------------------------
*/
static H5F_super_t *
-H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED *udata1, void *udata2/*out*/)
+H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void *udata2/*out*/)
{
H5F_super_t *sblock = NULL; /* File's superblock */
+ haddr_t base_addr = HADDR_UNDEF; /* Base address of file */
uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Buffer for superblock */
H5P_genplist_t *c_plist; /* File creation property list */
H5F_file_t *shared; /* shared part of `file' */
@@ -131,6 +132,10 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED
FUNC_ENTER_NOAPI_NOINIT(H5F_sblock_load)
+ /* check arguments */
+ HDassert(f);
+ HDassert(H5F_addr_eq(addr, 0));
+
/* Short cuts */
shared = f->shared;
lf = shared->lf;
@@ -139,15 +144,19 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED
if(NULL == (c_plist = (H5P_genplist_t *)H5I_object(shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get property list")
+ /* Get the base address for the file in the VFD */
+ if(HADDR_UNDEF == (base_addr = H5FD_get_base_addr(lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "failed to get base address for file driver")
+
/* Allocate space for the superblock */
if(NULL == (sblock = H5FL_CALLOC(H5F_super_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Read fixed-size portion of the superblock */
p = sbuf;
- if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size) < 0)
+ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, fixed_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed")
- if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, f->shared->super_addr, fixed_size, p) < 0)
+ if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, fixed_size, p) < 0)
HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock")
/* Skip over signature (already checked when locating the superblock) */
@@ -172,10 +181,11 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED
HDassert(fixed_size + variable_size <= sizeof(sbuf));
/* Read in variable-sized portion of superblock */
- if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size + variable_size) < 0)
+ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, fixed_size + variable_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed")
- if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, f->shared->super_addr + fixed_size, variable_size, p) < 0)
+ if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)fixed_size, variable_size, p) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read superblock")
+
/* Check for older version of superblock format */
if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
uint32_t status_flags; /* File status flags */
@@ -284,22 +294,24 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED
* Check if superblock address is different from base address and
* adjust base address and "end of address" address if so.
*/
- if(!H5F_addr_eq(f->shared->super_addr, sblock->base_addr)) {
+ if(!H5F_addr_eq(base_addr, sblock->base_addr)) {
/* Check if the superblock moved earlier in the file */
- if(H5F_addr_lt(f->shared->super_addr, sblock->base_addr))
- stored_eoa -= (sblock->base_addr - f->shared->super_addr);
+ if(H5F_addr_lt(base_addr, sblock->base_addr))
+ stored_eoa -= (sblock->base_addr - base_addr);
else
/* The superblock moved later in the file */
- stored_eoa += (f->shared->super_addr - sblock->base_addr);
+ stored_eoa += (base_addr - sblock->base_addr);
- sblock->base_addr = f->shared->super_addr;
- } /* end if */
+ /* Adjust base address for offsets of the HDF5 data in the file */
+ sblock->base_addr = base_addr;
- /* Set the base address for the file in the VFD now, after adjusting
- * space for possible offsets of the HDF5 data in the file.
- */
- if(H5FD_set_base_addr(lf, sblock->base_addr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "failed to set base address for file driver")
+ /* Set the base address for the file in the VFD now */
+ if(H5FD_set_base_addr(lf, sblock->base_addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "failed to set base address for file driver")
+
+ /* Indicate that the superblock should be marked dirty */
+ *dirtied = TRUE;
+ } /* end if */
/* This step is for h5repart tool only. If user wants to change file driver
* from family to sec2 while using h5repart, set the driver address to
@@ -412,22 +424,24 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED
* Check if superblock address is different from base address and
* adjust base address and "end of address" address if so.
*/
- if(!H5F_addr_eq(f->shared->super_addr, sblock->base_addr)) {
+ if(!H5F_addr_eq(base_addr, sblock->base_addr)) {
/* Check if the superblock moved earlier in the file */
- if(H5F_addr_lt(f->shared->super_addr, sblock->base_addr))
- stored_eoa -= (sblock->base_addr - f->shared->super_addr);
+ if(H5F_addr_lt(base_addr, sblock->base_addr))
+ stored_eoa -= (sblock->base_addr - base_addr);
else
/* The superblock moved later in the file */
- stored_eoa += (f->shared->super_addr - sblock->base_addr);
+ stored_eoa += (base_addr - sblock->base_addr);
- sblock->base_addr = f->shared->super_addr;
- } /* end if */
+ /* Adjust base address for offsets of the HDF5 data in the file */
+ sblock->base_addr = base_addr;
- /* Set the base address for the file in the VFD now, after adjusting
- * space for possible offsets of the HDF5 data in the file.
- */
- if(H5FD_set_base_addr(lf, sblock->base_addr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "failed to set base address for file driver")
+ /* Set the base address for the file in the VFD now */
+ if(H5FD_set_base_addr(lf, sblock->base_addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "failed to set base address for file driver")
+
+ /* Indicate that the superblock should be marked dirty */
+ *dirtied = TRUE;
+ } /* end if */
/* Get the B-tree internal node values, etc */
if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0)
@@ -587,6 +601,7 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_sup
/* check arguments */
HDassert(f);
+ HDassert(H5F_addr_eq(addr, 0));
HDassert(sblock);
if(sblock->cache_info.is_dirty) {
@@ -729,7 +744,6 @@ H5F_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F_sup
H5O_drvinfo_t drvinfo; /* Driver info */
H5O_loc_t ext_loc; /* "Object location" for superblock extension */
uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */
- htri_t status; /* Indicate whether the message exists or not */
/* Sanity check */
HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE);