summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--test/testhdf5.h14
-rw-r--r--test/tfile.c137
10 files changed, 222 insertions, 65 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);
diff --git a/test/testhdf5.h b/test/testhdf5.h
index 86333d3..f2a820f 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -81,6 +81,20 @@
} \
} while(0)
+/* Used to make certain a (non-'long' type's) return value _is_ a value */
+#define VERIFY_TYPE(_x, _val, _type, _format, where) do { \
+ _type __x = (_type)_x, __val = (_type)_val; \
+ if(GetTestVerbosity() >= VERBO_HI) { \
+ print_func(" Call to routine: %15s at line %4d in %s had value " \
+ _format " \n", (where), (int)__LINE__, __FILE__, __x); \
+ } \
+ if((__x) != (__val)) { \
+ TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format " at line %4d " \
+ "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__); \
+ H5Eprint2(H5E_DEFAULT, stdout); \
+ } \
+} while(0)
+
/* Used to make certain a string return value _is_ a value */
#define VERIFY_STR(x, val, where) do { \
if (GetTestVerbosity()>=VERBO_HI) { \
diff --git a/test/tfile.c b/test/tfile.c
index 84dcb73..b291154 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -1987,7 +1987,7 @@ test_userblock_file_size(void)
CHECK(ret, FAIL, "H5Fget_filesize");
/* Verify that the file sizes differ exactly by the userblock size */
- VERIFY(filesize2, filesize1 + USERBLOCK_SIZE, "H5Fget_filesize");
+ VERIFY_TYPE((unsigned long long)filesize2, (unsigned long long)(filesize1 + USERBLOCK_SIZE), unsigned long long, "%llu", "H5Fget_filesize");
/* Close files */
ret = H5Fclose(file1_id);
@@ -2117,6 +2117,113 @@ test_rw_noupdate(void)
/****************************************************************
**
+** test_userblock_alignment_helper(): helper routine for
+** test_userblock_alignment() test, to handle common testing
+**
+** Programmer: Quincey Koziol
+** koziol@hdfgroup.org
+** Septmber 10, 2009
+**
+*****************************************************************/
+static int
+test_userblock_alignment_helper(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ int curr_num_errs = GetTestNumErrs(); /* Retrieve the current # of errors */
+ herr_t ret; /* Generic return value */
+
+ /* Create a file with FAPL & FCPL */
+ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Only proceed further if file ID is OK */
+ if(fid > 0) {
+ hid_t gid; /* Group ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t did; /* Dataset ID */
+ int val = 2; /* Dataset value */
+
+ /* Create a group */
+ gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Create a dataset */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+ did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(did, FAIL, "H5Dcreate2");
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Write value to dataset */
+ ret = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &val);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close dataset */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close group */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end if */
+
+
+ /* Re-open file */
+ fid = H5Fopen(FILE1, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Only proceed further if file ID is OK */
+ if(fid > 0) {
+ hid_t gid, gid2; /* Group IDs */
+ hid_t did; /* Dataset ID */
+ int val = 2; /* Dataset value */
+
+ /* Open group */
+ gid = H5Gopen2(fid, "group1", H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen2");
+
+ /* Open dataset */
+ did = H5Dopen2(gid, "dataset", H5P_DEFAULT);
+ CHECK(did, FAIL, "H5Dopen2");
+
+ /* Read value from dataset */
+ ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &val);
+ CHECK(ret, FAIL, "H5Dread");
+ VERIFY(val, 2, "H5Dread");
+
+ /* Close dataset */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Create a new group */
+ gid2 = H5Gcreate2(gid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Close new group */
+ ret = H5Gclose(gid2);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Close group */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end if */
+
+ return((GetTestNumErrs() == curr_num_errs) ? 0 : -1);
+} /* end test_userblock_alignment_helper() */
+
+/****************************************************************
+**
** test_userblock_alignment(): low-level file test routine.
** This test checks to ensure that files with both a userblock and a
** object [allocation] alignment size set interact properly.
@@ -2154,9 +2261,9 @@ test_userblock_alignment(void)
ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)3);
CHECK(ret, FAIL, "H5Pset_alignment");
- /* Create a file with FAPL & FCPL */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
+ /* Call helper routine to perform file manipulations */
+ ret = test_userblock_alignment_helper(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper");
/* Release property lists */
ret = H5Pclose(fcpl);
@@ -2164,9 +2271,6 @@ test_userblock_alignment(void)
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
/* Case 2:
* Userblock size = 512, alignment = 16
@@ -2186,9 +2290,9 @@ test_userblock_alignment(void)
ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)16);
CHECK(ret, FAIL, "H5Pset_alignment");
- /* Create a file with FAPL & FCPL */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
+ /* Call helper routine to perform file manipulations */
+ ret = test_userblock_alignment_helper(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper");
/* Release property lists */
ret = H5Pclose(fcpl);
@@ -2196,9 +2300,6 @@ test_userblock_alignment(void)
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
/* Case 3:
* Userblock size = 512, alignment = 512
@@ -2218,9 +2319,9 @@ test_userblock_alignment(void)
ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)512);
CHECK(ret, FAIL, "H5Pset_alignment");
- /* Create a file with FAPL & FCPL */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
+ /* Call helper routine to perform file manipulations */
+ ret = test_userblock_alignment_helper(fcpl, fapl);
+ CHECK(ret, FAIL, "test_userblock_alignment_helper");
/* Release property lists */
ret = H5Pclose(fcpl);
@@ -2228,9 +2329,6 @@ test_userblock_alignment(void)
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
/* Case 4:
* Userblock size = 512, alignment = 3
@@ -2263,6 +2361,7 @@ test_userblock_alignment(void)
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
+
/* Case 5:
* Userblock size = 512, alignment = 1024
* (userblock & alignment each individually valid, but userblock is