diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-19 20:15:21 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-19 20:15:21 (GMT) |
commit | 099b37d073e633b0cb4d8c3f41ddf5788e63e6ee (patch) | |
tree | 3316f03ab81dbbab9160aac62fefe3f78b50c1d4 /src/H5Gtest.c | |
parent | 94cf912176257c753eaddde0acabc9a11be2e48d (diff) | |
download | hdf5-099b37d073e633b0cb4d8c3f41ddf5788e63e6ee.zip hdf5-099b37d073e633b0cb4d8c3f41ddf5788e63e6ee.tar.gz hdf5-099b37d073e633b0cb4d8c3f41ddf5788e63e6ee.tar.bz2 |
[svn-r20559] Description:
Bring r20407:20557 from trunk to revise_chunks branch
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/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-ia64 2.6 (ember) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Diffstat (limited to 'src/H5Gtest.c')
-rw-r--r-- | src/H5Gtest.c | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 96ecfda..ec55e47 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -641,3 +641,167 @@ done: FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) } /* end H5G_verify_cached_stab_test() */ + +/*------------------------------------------------------------------------- + * Function: H5G_verify_cached_stabs_test_cb + * + * Purpose: Verify that all entries in this node contain cached symbol + * table information if and only if the entry refers to a + * group with a symbol table, and that that information is + * correct. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Apr 8, 2011 + * + *------------------------------------------------------------------------- + */ +static int +H5G_verify_cached_stabs_test_cb(H5F_t *f, hid_t dxpl_id, + const void UNUSED *_lt_key, haddr_t addr, const void UNUSED *_rt_key, + void UNUSED *udata) +{ + H5G_node_t *sn = NULL; + H5O_loc_t targ_oloc; + H5O_t *targ_oh = NULL; + htri_t stab_exists; + H5O_stab_t stab; + unsigned i; + int ret_value = H5_ITER_CONT; + + FUNC_ENTER_NOAPI(H5G_verify_cached_stabs_test_cb, H5_ITER_ERROR) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* Load the node */ + if(NULL == (sn = (H5G_node_t *)H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, f, H5AC_READ))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node") + + /* Check each target object to see if its stab message (if present) matches + * the cached stab (if present). If one exists, both must exist. */ + /* Initialize constant fields in target oloc */ + targ_oloc.file = f; + targ_oloc.holding_file = FALSE; + + /* Iterate over entries */ + for(i=0; i<sn->nsyms; i++) { + /* Update oloc address */ + targ_oloc.addr = sn->entry[i].header; + + /* Load target object header */ + if(NULL == (targ_oh = H5O_protect(&targ_oloc, dxpl_id, H5AC_READ))) + HGOTO_ERROR(H5E_SYM, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to protect target object header") + + /* Check if a symbol table message exists */ + if((stab_exists = H5O_msg_exists_oh(targ_oh, H5O_STAB_ID)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to check for STAB message") + + if(stab_exists) { + /* Read symbol table message */ + if(NULL == H5O_msg_read_oh(f, dxpl_id, targ_oh, H5O_STAB_ID, &stab)) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to read STAB message") + + /* Check if the stab matches the cached stab info */ + if(sn->entry[i].type != H5G_CACHED_STAB) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "STAB message is not cached in group node") + + if((sn->entry[i].cache.stab.btree_addr != stab.btree_addr) + || (sn->entry[i].cache.stab.heap_addr != stab.heap_addr)) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "cached symbol table information is incorrect") + } /* end if */ + else if(sn->entry[i].type == H5G_CACHED_STAB) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5_ITER_ERROR, "nonexistent STAB message is cached") + + /* Unprotect target object */ + if(H5O_unprotect(&targ_oloc, dxpl_id, targ_oh, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release object header"); + targ_oh = NULL; + } /* end for */ + +done: + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") + + if(targ_oh) { + HDassert(ret_value == H5_ITER_ERROR); + if(H5O_unprotect(&targ_oloc, dxpl_id, targ_oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release object header"); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_verify_cached_stabs_test_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_verify_cached_stabs_test + * + * Purpose: If the provided group contains a symbol table, verifies + * that all links in the group contain cached symbol table + * information if and only if the link points to a group + * with a symbol table, and that that information is correct. + * If the provided group does not contain a symbol table, + * does nothing. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * nfortne2@hdfgroup.org + * April 6 2011 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_verify_cached_stabs_test(hid_t gid) +{ + H5G_t *grp = NULL; /* Group */ + htri_t stab_exists; + H5O_stab_t stab; /* Symbol table message */ + H5G_bt_common_t udata = {NULL, NULL}; /* Dummy udata so H5B_iterate doesn't freak out */ + haddr_t prev_tag = HADDR_UNDEF; /* Previous metadata tag */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_verify_cached_stabs_test, FAIL) + + /* check args */ + HDassert(gid >= 0); + + /* Check args */ + if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + + /* Set up metadata tagging */ + if(H5AC_tag(H5AC_ind_dxpl_id, grp->oloc.addr, &prev_tag) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "unable to apply metadata tag") + + /* Check for group having a symbol table message */ + /* Check for the group having a group info message */ + if((stab_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID, + H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") + + /* No need to check anything if the symbol table doesn't exist */ + if(!stab_exists) + HGOTO_DONE(SUCCEED); + + /* Read the stab */ + if(NULL == H5O_msg_read(&(grp->oloc), H5O_STAB_ID, &stab, H5AC_ind_dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get symbol table info") + + /* Iterate over the b-tree, checking validity of cached information */ + if((ret_value = H5B_iterate(grp->oloc.file, H5AC_ind_dxpl_id, H5B_SNODE, + stab.btree_addr, H5G_verify_cached_stabs_test_cb, &udata)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "iteration operator failed"); + + /* Reset metadata tagging */ + if(H5AC_tag(H5AC_ind_dxpl_id, prev_tag, NULL) < 0) + HDONE_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "unable to apply metadata tag") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_verify_cached_stabs_test() */ + |