diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-01 19:01:14 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-01 19:01:14 (GMT) |
commit | edaab1caeee93de076b89f1deacb0fa57665a83a (patch) | |
tree | 640feb6eff1f5f7eb90d63d13c9c4180e7380826 /src | |
parent | 001307e4e801fbad883276f5abb008eb48536e21 (diff) | |
download | hdf5-edaab1caeee93de076b89f1deacb0fa57665a83a.zip hdf5-edaab1caeee93de076b89f1deacb0fa57665a83a.tar.gz hdf5-edaab1caeee93de076b89f1deacb0fa57665a83a.tar.bz2 |
[svn-r18491] Description:
Extract data structure 'destroy' routines from metadata cache client
'destroy' callbacks.
Tested on:
Mac OS X/32 10.6.3 (amazon) w/debug, production & parallel
(h5committest not required on this branch)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 35 | ||||
-rw-r--r-- | src/H5B2.c | 3 | ||||
-rw-r--r-- | src/H5B2cache.c | 119 | ||||
-rw-r--r-- | src/H5B2int.c | 132 | ||||
-rw-r--r-- | src/H5B2pkg.h | 8 | ||||
-rw-r--r-- | src/H5Bcache.c | 27 | ||||
-rw-r--r-- | src/H5Bpkg.h | 2 | ||||
-rw-r--r-- | src/H5FS.c | 174 | ||||
-rw-r--r-- | src/H5FScache.c | 157 | ||||
-rw-r--r-- | src/H5FSpkg.h | 6 |
10 files changed, 440 insertions, 223 deletions
@@ -261,7 +261,8 @@ done: (void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)shared->sizeof_rnode); } /* end if */ if(bt) - (void)H5B_dest(f, bt); + if(H5B_node_dest(bt) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1966,6 +1967,38 @@ done: /*------------------------------------------------------------------------- + * Function: H5B_node_dest + * + * Purpose: Destroy/release a B-tree node + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 26, 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B_node_dest(H5B_t *bt) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_node_dest) + + /* check arguments */ + HDassert(bt); + HDassert(bt->rc_shared); + + bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); + bt->native = H5FL_BLK_FREE(native_block, bt->native); + H5RC_DEC(bt->rc_shared); + bt = H5FL_FREE(H5B_t, bt); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B_node_dest() */ + + +/*------------------------------------------------------------------------- * Function: H5B_debug * * Purpose: Prints debugging info about a B-tree. @@ -143,7 +143,8 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, done: if(ret_value < 0) { if(bt2) - (void)H5B2_cache_hdr_dest(f, bt2); + if(H5B2_hdr_dest(bt2) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2cache.c b/src/H5B2cache.c index bdb9b26..5b168ba 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -69,14 +69,17 @@ /* Metadata cache callbacks */ static H5B2_t *H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); static herr_t H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_t *b, unsigned UNUSED * flags_ptr); +static herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *bt2); static herr_t H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *b, hbool_t destroy); static herr_t H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t *bt, size_t *size_ptr); static H5B2_internal_t *H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_shared); static herr_t H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_internal_t *i, unsigned UNUSED * flags_ptr); +static herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal); static herr_t H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *i, hbool_t destroy); static herr_t H5B2_cache_internal_size(const H5F_t *f, const H5B2_internal_t *i, size_t *size_ptr); static H5B2_leaf_t *H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_shared); static herr_t H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_leaf_t *l, unsigned UNUSED * flags_ptr); +static herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf); static herr_t H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *l, hbool_t destroy); static herr_t H5B2_cache_leaf_size(const H5F_t *f, const H5B2_leaf_t *l, size_t *size_ptr); @@ -243,7 +246,8 @@ done: if(wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_BTREE, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") if(!ret_value && bt2) - (void)H5B2_cache_hdr_dest(f, bt2); + if(H5B2_hdr_dest(bt2) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree header node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -346,7 +350,7 @@ H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B } /* end if */ if(destroy) - if(H5B2_cache_hdr_dest(f, bt2) < 0) + if(H5B2_hdr_dest(bt2) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header") done: @@ -372,24 +376,22 @@ done: *------------------------------------------------------------------------- */ /* ARGSUSED */ -herr_t +static herr_t H5B2_cache_hdr_dest(H5F_t UNUSED *f, H5B2_t *bt2) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_hdr_dest) + herr_t ret_value = SUCCEED; /* Return value */ - /* - * Check arguments. - */ - HDassert(bt2); + FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_hdr_dest) - /* Decrement reference count on shared B-tree info */ - if(bt2->shared) - H5RC_DEC(bt2->shared); + /* Check arguments */ + HDassert(bt2); - /* Free B-tree header info */ - H5FL_FREE(H5B2_t, bt2); + /* Destroy v2 b-tree header */ + if(H5B2_hdr_dest(bt2) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header node") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_cache_hdr_dest() */ @@ -406,8 +408,9 @@ H5B2_cache_hdr_dest(H5F_t UNUSED *f, H5B2_t *bt2) * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t -H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *bt2, hbool_t destroy) +H5B2_cache_hdr_clear(H5F_t UNUSED *f, H5B2_t *bt2, hbool_t destroy) { herr_t ret_value = SUCCEED; /* Return value */ @@ -422,7 +425,7 @@ H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *bt2, hbool_t destroy) bt2->cache_info.is_dirty = FALSE; if(destroy) - if(H5B2_cache_hdr_dest(f, bt2) < 0) + if(H5B2_hdr_dest(bt2) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header") done: @@ -585,7 +588,8 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda done: if(!ret_value && internal) - (void)H5B2_cache_internal_dest(f, internal); + if(H5B2_internal_dest(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_internal_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -681,7 +685,7 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr } /* end if */ if(destroy) - if(H5B2_cache_internal_dest(f, internal) < 0) + if(H5B2_internal_dest(internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node") done: @@ -703,38 +707,22 @@ done: *------------------------------------------------------------------------- */ /* ARGSUSED */ -herr_t +static herr_t H5B2_cache_internal_dest(H5F_t UNUSED *f, H5B2_internal_t *internal) { - H5B2_shared_t *shared; /* Shared B-tree information */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_internal_dest) + FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_internal_dest) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(internal); - /* Get the pointer to the shared B-tree info */ - shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); - HDassert(shared); - - /* Release internal node's native key buffer */ - if(internal->int_native) - H5FL_FAC_FREE(shared->node_info[internal->depth].nat_rec_fac, internal->int_native); - - /* Release internal node's node pointer buffer */ - if(internal->node_ptrs) - H5FL_FAC_FREE(shared->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); + /* Destroy v2 b-tree internal node */ + if(H5B2_internal_dest(internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node") - /* Decrement reference count on shared B-tree info */ - if(internal->shared) - H5RC_DEC(internal->shared); - - /* Free B-tree internal node info */ - H5FL_FREE(H5B2_internal_t, internal); - - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_cache_internal_dest() */ @@ -751,8 +739,9 @@ H5B2_cache_internal_dest(H5F_t UNUSED *f, H5B2_internal_t *internal) * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t -H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *internal, hbool_t destroy) +H5B2_cache_internal_clear(H5F_t UNUSED *f, H5B2_internal_t *internal, hbool_t destroy) { herr_t ret_value = SUCCEED; @@ -767,7 +756,7 @@ H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *internal, hbool_t destroy) internal->cache_info.is_dirty = FALSE; if(destroy) - if(H5B2_cache_internal_dest(f, internal) < 0) + if(H5B2_internal_dest(internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node") done: @@ -915,7 +904,8 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v done: if(!ret_value && leaf) - (void)H5B2_cache_leaf_dest(f, leaf); + if(H5B2_leaf_dest(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_leaf_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -997,7 +987,7 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5 } /* end if */ if(destroy) - if(H5B2_cache_leaf_dest(f, leaf) < 0) + if(H5B2_leaf_dest(leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") done: @@ -1019,34 +1009,22 @@ done: *------------------------------------------------------------------------- */ /* ARGSUSED */ -herr_t +static herr_t H5B2_cache_leaf_dest(H5F_t UNUSED *f, H5B2_leaf_t *leaf) { - H5B2_shared_t *shared; /* Shared B-tree information */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_leaf_dest) + FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_leaf_dest) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(leaf); - /* Get the pointer to the shared B-tree info */ - shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared); - HDassert(shared); - - /* Release leaf's native key buffer */ - if(leaf->leaf_native) - H5FL_FAC_FREE(shared->node_info[0].nat_rec_fac, leaf->leaf_native); - - /* Decrement reference count on shared B-tree info */ - if(leaf->shared) - H5RC_DEC(leaf->shared); + /* Destroy v2 b-tree leaf node */ + if(H5B2_leaf_dest(leaf) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") - /* Free B-tree leaf node info */ - H5FL_FREE(H5B2_leaf_t,leaf); - - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_cache_leaf_dest() */ @@ -1063,8 +1041,9 @@ H5B2_cache_leaf_dest(H5F_t UNUSED *f, H5B2_leaf_t *leaf) * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t -H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *leaf, hbool_t destroy) +H5B2_cache_leaf_clear(H5F_t UNUSED *f, H5B2_leaf_t *leaf, hbool_t destroy) { herr_t ret_value = SUCCEED; @@ -1079,7 +1058,7 @@ H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *leaf, hbool_t destroy) leaf->cache_info.is_dirty = FALSE; if(destroy) - if(H5B2_cache_leaf_dest(f, leaf) < 0) + if(H5B2_leaf_dest(leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") done: diff --git a/src/H5B2int.c b/src/H5B2int.c index 21d6527..71e522e 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1974,7 +1974,8 @@ HDmemset(leaf->leaf_native, 0, shared->type->nrec_size * shared->node_info[0].ma done: if(ret_value < 0) { if(leaf) - (void)H5B2_cache_leaf_dest(f, leaf); + if(H5B2_leaf_dest(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2055,7 +2056,8 @@ HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (shared->node_info[de done: if(ret_value < 0) { if(internal) - (void)H5B2_cache_internal_dest(f, internal); + if(H5B2_internal_dest(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -3218,6 +3220,132 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_iterate_size_node() */ + +/*------------------------------------------------------------------------- + * Function: H5B2_hdr_dest + * + * Purpose: Destroys a B-tree header in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 1 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_hdr_dest(H5B2_t *bt2) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_hdr_dest) + + /* + * Check arguments. + */ + HDassert(bt2); + + /* Decrement reference count on shared B-tree info */ + if(bt2->shared) + H5RC_DEC(bt2->shared); + + /* Free B-tree header info */ + bt2 = H5FL_FREE(H5B2_t, bt2); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B2_hdr_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_internal_dest + * + * Purpose: Destroys a B-tree internal node in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 2 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_internal_dest(H5B2_internal_t *internal) +{ + H5B2_shared_t *shared; /* Shared B-tree information */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_internal_dest) + + /* + * Check arguments. + */ + HDassert(internal); + + /* Get the pointer to the shared B-tree info */ + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + HDassert(shared); + + /* Release internal node's native key buffer */ + if(internal->int_native) + H5FL_FAC_FREE(shared->node_info[internal->depth].nat_rec_fac, internal->int_native); + + /* Release internal node's node pointer buffer */ + if(internal->node_ptrs) + H5FL_FAC_FREE(shared->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); + + /* Decrement reference count on shared B-tree info */ + if(internal->shared) + H5RC_DEC(internal->shared); + + /* Free B-tree internal node info */ + internal = H5FL_FREE(H5B2_internal_t, internal); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B2_internal_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_leaf_dest + * + * Purpose: Destroys a B-tree leaf node in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 2 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_leaf_dest(H5B2_leaf_t *leaf) +{ + H5B2_shared_t *shared; /* Shared B-tree information */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_leaf_dest) + + /* + * Check arguments. + */ + HDassert(leaf); + + /* Get the pointer to the shared B-tree info */ + shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared); + HDassert(shared); + + /* Release leaf's native key buffer */ + if(leaf->leaf_native) + H5FL_FAC_FREE(shared->node_info[0].nat_rec_fac, leaf->leaf_native); + + /* Decrement reference count on shared B-tree info */ + if(leaf->shared) + H5RC_DEC(leaf->shared); + + /* Free B-tree leaf node info */ + leaf = H5FL_FREE(H5B2_leaf_t, leaf); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B2_leaf_dest() */ + #ifdef H5B2_DEBUG /*------------------------------------------------------------------------- diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 43fab1f..270cdfd 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -303,10 +303,10 @@ H5_DLL herr_t H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data); -/* Metadata cache callbacks */ -H5_DLL herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *b); -H5_DLL herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *l); -H5_DLL herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *i); +/* Routines for destroying structures */ +H5_DLL herr_t H5B2_hdr_dest(H5B2_t *b); +H5_DLL herr_t H5B2_leaf_dest(H5B2_leaf_t *l); +H5_DLL herr_t H5B2_internal_dest(H5B2_internal_t *i); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, diff --git a/src/H5Bcache.c b/src/H5Bcache.c index f3351f3..110f6e2 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -56,6 +56,7 @@ /* Metadata cache callbacks */ static H5B_t *H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *b, unsigned UNUSED * flags_ptr); +static herr_t H5B_dest(H5F_t *f, H5B_t *bt); static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy); static herr_t H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr); @@ -181,7 +182,8 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) done: if(!ret_value && bt) - (void)H5B_dest(f, bt); + if(H5B_node_dest(bt) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -270,7 +272,7 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns } /* end if */ if(destroy) - if(H5B_dest(f, bt) < 0) + if(H5B_node_dest(bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: @@ -292,10 +294,12 @@ done: *------------------------------------------------------------------------- */ /* ARGSUSED */ -herr_t +static herr_t H5B_dest(H5F_t UNUSED *f, H5B_t *bt) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_dest) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B_dest) /* * Check arguments. @@ -303,12 +307,12 @@ H5B_dest(H5F_t UNUSED *f, H5B_t *bt) HDassert(bt); HDassert(bt->rc_shared); - bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); - bt->native = H5FL_BLK_FREE(native_block, bt->native); - H5RC_DEC(bt->rc_shared); - bt = H5FL_FREE(H5B_t, bt); + /* Destroy B-tree node */ + if(H5B_node_dest(bt) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_dest() */ @@ -325,8 +329,9 @@ H5B_dest(H5F_t UNUSED *f, H5B_t *bt) * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t -H5B_clear(H5F_t *f, H5B_t *bt, hbool_t destroy) +H5B_clear(H5F_t UNUSED *f, H5B_t *bt, hbool_t destroy) { herr_t ret_value = SUCCEED; @@ -341,7 +346,7 @@ H5B_clear(H5F_t *f, H5B_t *bt, hbool_t destroy) bt->cache_info.is_dirty = FALSE; if(destroy) - if(H5B_dest(f, bt) < 0) + if(H5B_node_dest(bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index ed343fb..05f9f30 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -79,7 +79,7 @@ H5FL_EXTERN(H5B_t); /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5B_dest(H5F_t *f, H5B_t *b); +H5_DLL herr_t H5B_node_dest(H5B_t *b); #endif /*_H5Bpkg_H*/ @@ -55,6 +55,8 @@ /********************/ /* Local Prototypes */ /********************/ +static herr_t H5FS_sinfo_free_sect_cb(void *item, void *key, void *op_data); +static herr_t H5FS_sinfo_free_node_cb(void *item, void *key, void *op_data); /*********************/ @@ -139,7 +141,8 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl done: if(!ret_value && fspace) - (void)H5FS_cache_hdr_dest(f, fspace); + if(H5FS_hdr_dest(fspace) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_create() */ @@ -499,6 +502,175 @@ H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FS_size() */ + +/*------------------------------------------------------------------------- + * Function: H5FS_hdr_dest + * + * Purpose: Destroys a free space header in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * May 2 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FS_hdr_dest(H5FS_t *fspace) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5FS_hdr_dest) + + /* + * Check arguments. + */ + HDassert(fspace); + + /* Terminate the section classes for this free space list */ + for(u = 0; u < fspace->nclasses ; u++) { + /* Call the class termination routine, if there is one */ + if(fspace->sect_cls[u].term_cls) + if((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "unable to finalize section class") + } /* end for */ + + /* Release the memory for the free space section classes */ + if(fspace->sect_cls) + fspace->sect_cls = H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); + + /* Free free space info */ + fspace = H5FL_FREE(H5FS_t, fspace); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FS_hdr_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5FS_sinfo_free_sect_cb + * + * Purpose: Free a size-tracking node for a bin + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Saturday, March 11, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FS_sinfo_free_sect_cb(void *_sect, void UNUSED *key, void *op_data) +{ + H5FS_section_info_t *sect = (H5FS_section_info_t *)_sect; /* Section to free */ + const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)op_data; /* Free space manager for section */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_sinfo_free_sect_cb) + + HDassert(sect); + HDassert(sinfo); + + /* Call the section's class 'free' method on the section */ + (*sinfo->fspace->sect_cls[sect->type].free)(sect); + + FUNC_LEAVE_NOAPI(0) +} /* H5FS_sinfo_free_sect_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5FS_sinfo_free_node_cb + * + * Purpose: Free a size-tracking node for a bin + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Quincey Koziol + * Saturday, March 11, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FS_sinfo_free_node_cb(void *item, void UNUSED *key, void *op_data) +{ + H5FS_node_t *fspace_node = (H5FS_node_t *)item; /* Temporary pointer to free space list node */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_sinfo_free_node_cb) + + HDassert(fspace_node); + HDassert(op_data); + + /* Release the skip list for sections of this size */ + H5SL_destroy(fspace_node->sect_list, H5FS_sinfo_free_sect_cb, op_data); + + /* Release free space list node */ + fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); + + FUNC_LEAVE_NOAPI(0) +} /* H5FS_sinfo_free_node_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5FS_sinfo_dest + * + * Purpose: Destroys a free space section info in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * July 31 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FS_sinfo_dest(H5FS_sinfo_t *sinfo) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5FS_sinfo_dest) + + /* + * Check arguments. + */ + HDassert(sinfo); + HDassert(sinfo->fspace); + HDassert(sinfo->bins); + + /* Clear out lists of nodes */ + for(u = 0; u < sinfo->nbins; u++) + if(sinfo->bins[u].bin_list) { + H5SL_destroy(sinfo->bins[u].bin_list, H5FS_sinfo_free_node_cb, sinfo); + sinfo->bins[u].bin_list = NULL; + } /* end if */ + + /* Release bins for skip lists */ + sinfo->bins = H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins); + + /* Release skip list for merging sections */ + if(sinfo->merge_list) + if(H5SL_close(sinfo->merge_list) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy section merging skip list") + + /* Unpin the free space header in the cache */ + /* (make certain this is last action with section info, to allow for header + * disappearing immediately) + */ + if(H5AC_unpin_entry(sinfo->fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin free space header") + + /* Release free space section info */ + sinfo = H5FL_FREE(H5FS_sinfo_t, sinfo); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FS_sinfo_dest() */ + #ifdef H5FS_DEBUG /*------------------------------------------------------------------------- diff --git a/src/H5FScache.c b/src/H5FScache.c index af92762..9032050 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -73,18 +73,18 @@ typedef struct { /********************/ /* Section info routines */ -static herr_t H5FS_sinfo_free_sect_cb(void *item, void *key, void *op_data); -static herr_t H5FS_sinfo_free_node_cb(void *item, void *key, void *op_data); static herr_t H5FS_sinfo_serialize_sect_cb(void *_item, void UNUSED *key, void *_udata); static herr_t H5FS_sinfo_serialize_node_cb(void *_item, void UNUSED *key, void *_udata); /* Metadata cache callbacks */ static H5FS_t *H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5FS_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FS_t *fspace, unsigned UNUSED * flags_ptr); +static herr_t H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *fspace); static herr_t H5FS_cache_hdr_clear(H5F_t *f, H5FS_t *fspace, hbool_t destroy); static herr_t H5FS_cache_hdr_size(const H5F_t *f, const H5FS_t *fspace, size_t *size_ptr); static H5FS_sinfo_t *H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5FS_cache_sinfo_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FS_sinfo_t *sinfo, unsigned UNUSED * flags_ptr); +static herr_t H5FS_cache_sinfo_dest(H5F_t *f, H5FS_sinfo_t *sinfo); static herr_t H5FS_cache_sinfo_clear(H5F_t *f, H5FS_sinfo_t *sinfo, hbool_t destroy); static herr_t H5FS_cache_sinfo_size(const H5F_t *f, const H5FS_sinfo_t *sinfo, size_t *size_ptr); @@ -251,7 +251,7 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_fs_prot, /* Verify checksum */ if(stored_chksum != computed_chksum) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") + HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") /* Set return value */ ret_value = fspace; @@ -261,7 +261,8 @@ done: if(wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") if(!ret_value && fspace) - (void)H5FS_cache_hdr_dest(f, fspace); + if(H5FS_hdr_dest(fspace) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -375,7 +376,7 @@ H5FS_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5F } /* end if */ if(destroy) - if(H5FS_cache_hdr_dest(f, fspace) < 0) + if(H5FS_hdr_dest(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header") done: @@ -401,33 +402,19 @@ done: *------------------------------------------------------------------------- */ /* ARGSUSED */ -herr_t +static herr_t H5FS_cache_hdr_dest(H5F_t UNUSED *f, H5FS_t *fspace) { - unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_hdr_dest) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fspace); - /* Terminate the section classes for this free space list */ - for(u = 0; u < fspace->nclasses ; u++) { - /* Call the class termination routine, if there is one */ - if(fspace->sect_cls[u].term_cls) - if((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "unable to finalize section class") - } /* end for */ - - /* Release the memory for the free space section classes */ - if(fspace->sect_cls) - fspace->sect_cls = H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); - - /* Free free space info */ - H5FL_FREE(H5FS_t, fspace); + /* Destroy free space header */ + if(H5FS_hdr_dest(fspace) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header") done: FUNC_LEAVE_NOAPI(ret_value) @@ -447,8 +434,9 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t -H5FS_cache_hdr_clear(H5F_t *f, H5FS_t *fspace, hbool_t destroy) +H5FS_cache_hdr_clear(H5F_t UNUSED *f, H5FS_t *fspace, hbool_t destroy) { herr_t ret_value = SUCCEED; /* Return value */ @@ -463,7 +451,7 @@ H5FS_cache_hdr_clear(H5F_t *f, H5FS_t *fspace, hbool_t destroy) fspace->cache_info.is_dirty = FALSE; if(destroy) - if(H5FS_cache_hdr_dest(f, fspace) < 0) + if(H5FS_hdr_dest(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header") done: @@ -657,7 +645,7 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * /* Verify checksum */ if(stored_chksum != computed_chksum) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") + HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") /* Sanity check */ HDassert((size_t)(p - (const uint8_t *)buf) == old_sect_size); @@ -667,9 +655,10 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * done: if(buf) - H5FL_BLK_FREE(sect_block, buf); + buf = H5FL_BLK_FREE(sect_block, buf); if(!ret_value && sinfo) - (void)H5FS_cache_sinfo_dest(f, sinfo); + if(H5FS_sinfo_dest(sinfo) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space section info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_cache_sinfo_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -860,13 +849,13 @@ H5FS_cache_sinfo_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H if(H5F_block_write(f, H5FD_MEM_FSPACE_SINFO, sinfo->fspace->sect_addr, (size_t)sinfo->fspace->sect_size, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFLUSH, FAIL, "unable to save free space sections to disk") - H5FL_BLK_FREE(sect_block, buf); + buf = H5FL_BLK_FREE(sect_block, buf); sinfo->cache_info.is_dirty = FALSE; } /* end if */ if(destroy) - if(H5FS_cache_sinfo_dest(f, sinfo) < 0) + if(H5FS_sinfo_dest(sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space section info") done: @@ -875,71 +864,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5FS_sinfo_free_sect_cb - * - * Purpose: Free a size-tracking node for a bin - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Saturday, March 11, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FS_sinfo_free_sect_cb(void *_sect, void UNUSED *key, void *op_data) -{ - H5FS_section_info_t *sect = (H5FS_section_info_t *)_sect; /* Section to free */ - const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)op_data; /* Free space manager for section */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_sinfo_free_sect_cb) - - HDassert(sect); - HDassert(sinfo); - - /* Call the section's class 'free' method on the section */ - (*sinfo->fspace->sect_cls[sect->type].free)(sect); - - FUNC_LEAVE_NOAPI(0) -} /* H5FS_sinfo_free_sect_cb() */ - - -/*------------------------------------------------------------------------- - * Function: H5FS_sinfo_free_node_cb - * - * Purpose: Free a size-tracking node for a bin - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Saturday, March 11, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FS_sinfo_free_node_cb(void *item, void UNUSED *key, void *op_data) -{ - H5FS_node_t *fspace_node = (H5FS_node_t *)item; /* Temporary pointer to free space list node */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_sinfo_free_node_cb) - - HDassert(fspace_node); - HDassert(op_data); - - /* Release the skip list for sections of this size */ - H5SL_destroy(fspace_node->sect_list, H5FS_sinfo_free_sect_cb, op_data); - - /* Release free space list node */ - H5FL_FREE(H5FS_node_t, fspace_node); - - FUNC_LEAVE_NOAPI(0) -} /* H5FS_sinfo_free_node_cb() */ - - -/*------------------------------------------------------------------------- * Function: H5FS_cache_sinfo_dest * * Purpose: Destroys a free space section info in memory. @@ -953,45 +877,19 @@ H5FS_sinfo_free_node_cb(void *item, void UNUSED *key, void *op_data) *------------------------------------------------------------------------- */ /* ARGSUSED */ -herr_t +static herr_t H5FS_cache_sinfo_dest(H5F_t UNUSED *f, H5FS_sinfo_t *sinfo) { - unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_sinfo_dest) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(sinfo); - HDassert(sinfo->fspace); - HDassert(sinfo->bins); - /* Clear out lists of nodes */ - for(u = 0; u < sinfo->nbins; u++) - if(sinfo->bins[u].bin_list) { - H5SL_destroy(sinfo->bins[u].bin_list, H5FS_sinfo_free_node_cb, sinfo); - sinfo->bins[u].bin_list = NULL; - } /* end if */ - - /* Release bins for skip lists */ - sinfo->bins = H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins); - - /* Release skip list for merging sections */ - if(sinfo->merge_list) - if(H5SL_close(sinfo->merge_list) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy section merging skip list") - - /* Unpin the free space header in the cache */ - /* (make certain this is last action with section info, to allow for header - * disappearing immediately) - */ - if(H5AC_unpin_entry(sinfo->fspace) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin free space header") - - /* Release free space section info */ - H5FL_FREE(H5FS_sinfo_t, sinfo); + /* Destroy free space info */ + if(H5FS_sinfo_dest(sinfo) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space info") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1011,8 +909,9 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t -H5FS_cache_sinfo_clear(H5F_t *f, H5FS_sinfo_t *sinfo, hbool_t destroy) +H5FS_cache_sinfo_clear(H5F_t UNUSED *f, H5FS_sinfo_t *sinfo, hbool_t destroy) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1027,7 +926,7 @@ H5FS_cache_sinfo_clear(H5F_t *f, H5FS_sinfo_t *sinfo, hbool_t destroy) sinfo->cache_info.is_dirty = FALSE; if(destroy) - if(H5FS_cache_sinfo_dest(f, sinfo) < 0) + if(H5FS_sinfo_dest(sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space section info") done: diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 9119902..d900b59 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -214,9 +214,9 @@ H5_DLL herr_t H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5_DLL herr_t H5FS_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t fs_addr, haddr_t client_addr); -/* Metadata cache callbacks */ -H5_DLL herr_t H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *hdr); -H5_DLL herr_t H5FS_cache_sinfo_dest(H5F_t *f, H5FS_sinfo_t *sinfo); +/* Routines for destroying structures */ +H5_DLL herr_t H5FS_hdr_dest(H5FS_t *hdr); +H5_DLL herr_t H5FS_sinfo_dest(H5FS_sinfo_t *sinfo); /* Sanity check routines */ #ifdef H5FS_DEBUG |