summaryrefslogtreecommitdiffstats
path: root/Help/dev
ModeNameSize
-rw-r--r--README.rst1666logstatsplain
-rw-r--r--documentation.rst25529logstatsplain
-rw-r--r--experimental.rst5453logstatsplain
-rw-r--r--maint.rst11763logstatsplain
-rw-r--r--review.rst24649logstatsplain
-rw-r--r--source.rst9339logstatsplain
-rw-r--r--testing.rst1751logstatsplain
y'>inactive/trunk_merge_coverity Mirror from: https://github.com/HDFGroup/hdf5.git
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-07-17 19:35:09 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-07-17 19:35:09 (GMT)
commit4be636f4f00271f85802fbb6ef079146f2dbf7fb (patch)
tree0a3d45b3e72f36a0b71087b194b328edd88d12cc /src
parenta926dc97d531c87ca098cfaac0b500e808ddbd7b (diff)
downloadhdf5-4be636f4f00271f85802fbb6ef079146f2dbf7fb.zip
hdf5-4be636f4f00271f85802fbb6ef079146f2dbf7fb.tar.gz
hdf5-4be636f4f00271f85802fbb6ef079146f2dbf7fb.tar.bz2
[svn-r13984] Description:
Various code cleanups and refactor recent changes for h5stat to fit into the existing library data structures better. Tested on: Mac OS X/32 10.4.10 (amazon) FreeBSD/32 6.2 (duty) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src')
-rw-r--r--src/H5Abtree2.c2
-rw-r--r--src/H5B.c190
-rw-r--r--src/H5B2.c31
-rw-r--r--src/H5B2int.c120
-rw-r--r--src/H5B2pkg.h5
-rw-r--r--src/H5B2private.h4
-rw-r--r--src/H5Bprivate.h21
-rw-r--r--src/H5D.c1
-rw-r--r--src/H5Distore.c94
-rw-r--r--src/H5Doh.c23
-rw-r--r--src/H5Dpkg.h3
-rw-r--r--src/H5F.c80
-rw-r--r--src/H5FS.c96
-rw-r--r--src/H5FSprivate.h4
-rw-r--r--src/H5Fpkg.h3
-rw-r--r--src/H5Fpublic.h9
-rw-r--r--src/H5Fsuper.c30
-rw-r--r--src/H5Gnode.c101
-rw-r--r--src/H5Gobj.c1
-rw-r--r--src/H5Goh.c66
-rw-r--r--src/H5Gpkg.h11
-rw-r--r--src/H5Gprivate.h1
-rw-r--r--src/H5Gstab.c81
-rw-r--r--src/H5HF.c85
-rw-r--r--src/H5HFiblock.c54
-rw-r--r--src/H5HFpkg.h4
-rw-r--r--src/H5HFprivate.h7
-rw-r--r--src/H5HFstat.c79
-rw-r--r--src/H5HL.c27
-rw-r--r--src/H5O.c68
-rw-r--r--src/H5Oattribute.c63
-rw-r--r--src/H5Opkg.h14
-rw-r--r--src/H5Oprivate.h4
-rw-r--r--src/H5Opublic.h7
-rw-r--r--src/H5Oshared.h4
-rwxr-xr-xsrc/H5SM.c51
-rwxr-xr-xsrc/H5SMprivate.h2
37 files changed, 707 insertions, 739 deletions
diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c
index 97a5a40..b685af7 100644
--- a/src/H5Abtree2.c
+++ b/src/H5Abtree2.c
@@ -273,7 +273,7 @@ H5A_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec)
const H5A_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec;
herr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5A_dense_btree2_name_compare)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_name_compare)
/* Sanity check */
HDassert(bt2_udata);
diff --git a/src/H5B.c b/src/H5B.c
index 23d5eff..9847b7a 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -1827,6 +1827,94 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B_iterate_size
+ *
+ * Purpose: Return the amount of storage used for the btree.
+ * Keep following the left-most child until reaching the leaf node.
+ * For each level, gather storage for all the nodes on that level.
+ * For 0 level, also gather storage for the SNODs.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * June 19, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
+ H5B_operator_t op, haddr_t addr, H5B_info_ud_t *bh_udata)
+{
+ H5B_t *bt = NULL; /* Pointer to current B-tree node */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B_iterate_size, FAIL)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(type);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(bh_udata);
+
+ /* Protect the initial/current node */
+ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, bh_udata->udata, H5AC_READ)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
+ shared = H5RC_GET_OBJ(bt->rc_shared);
+ HDassert(shared);
+
+ /* Keep following the left-most child until we reach a leaf node. */
+ if(bt->level > 0)
+ if(H5B_iterate_size(f, dxpl_id, type, op, bt->child[0], bh_udata) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node")
+
+ /* Iterate through all nodes at this level of the tree */
+ while(bt) {
+ haddr_t next_addr; /* Address of next node to iterate over */
+
+ /* for leaf node with callback, add in the space pointed to by each key */
+ /* (currently only used for symbol table nodes) */
+ if(bt->level == 0 && op) {
+ haddr_t *child; /* Pointer to node's child addresses */
+ uint8_t *key; /* Pointer to node's native keys */
+ unsigned u; /* Local index variable */
+
+ for(u = 0, child = bt->child, key = bt->native; u < bt->nchildren; u++, child++, key += type->sizeof_nkey)
+ if((*op)(f, dxpl_id, key, *child, key + type->sizeof_nkey, bh_udata->btree_size) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "iterator function failed")
+ } /* end if */
+
+ /* count the size of this node */
+ *(bh_udata->btree_size) += H5B_nodesize(f, shared, NULL);
+
+ /* Get the address of the next node to the right */
+ next_addr = bt->right;
+
+ /* Unprotect current node */
+ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+
+ /* Protect bt's next node to the right, if there is one */
+ if(H5F_addr_defined(next_addr)) {
+ addr = next_addr;
+ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, bh_udata->udata, H5AC_READ)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node")
+ } /* end if */
+ else
+ bt = NULL;
+ } /* end while */
+
+done:
+ if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5B_iterate_size() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B_debug
*
* Purpose: Prints debugging info about a B-tree.
@@ -2069,106 +2157,4 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
#endif /* H5B_DEBUG */
-
-/*-------------------------------------------------------------------------
- * Function: H5B_iterate_btree_size
- *
- * Purpose: Return the amount of storage used for the btree.
- * Keep following the left-most child until reaching the leaf node.
- * For each level, gather storage for all the nodes on that level.
- * For 0 level, also gather storage for the SNODs.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Vailin Choi
- * June 19, 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5B_iterate_btree_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op, haddr_t addr, H5B_info_ud_t *bh_udata)
-{
- H5B_t *bt = NULL; /* Pointer to current B-tree node */
- herr_t ret_value; /* Return value */
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
- H5B_t *start_bt; /* Pointer to next B-tree node */
- haddr_t start_addr; /* Address of next node to iterate over */
-
- haddr_t *child; /* Pointer to node's child addresses */
- uint8_t *key; /* Pointer to node's native keys */
- unsigned u; /* Local index variable */
-
- FUNC_ENTER_NOAPI(H5B_iterate_btree_size, FAIL)
- /*
- * Check arguments.
- */
- HDassert(f);
- HDassert(type);
- HDassert(H5F_addr_defined(addr));
- HDassert(bh_udata);
-
- /* Protect the initial/current node */
- if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, bh_udata->udata, H5AC_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
- shared = H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
-
- if (bt->level > 0) {
- /* Keep following the left-most child until we reach a leaf node. */
- if((ret_value = H5B_iterate_btree_size(f, dxpl_id, type, op, bt->child[0], bh_udata)) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node")
- }
- ret_value = H5_ITER_CONT;
- while(bt && ret_value == H5_ITER_CONT) {
- /* count the SNOD sizes for leaf nodes */
- if (bt->level == 0) { /* for leaf node only */
- for(u = 0, child = bt->child, key = bt->native; u < bt->nchildren && ret_value == H5_ITER_CONT; u++, child++, key += type->sizeof_nkey) {
- if (op != NULL) { /* only for symbol table nodes */
- ret_value = (*op)(f, dxpl_id, key, *child, key + type->sizeof_nkey, bh_udata->btree_size);
- }
- if(ret_value < 0)
- HERROR(H5E_BTREE, H5E_CANTLIST, "iterator function failed");
- } /* end for */
- } /* end if */
-
- /* Check for continuing iteration */
- if(ret_value == H5_ITER_CONT) {
- H5B_t *next_bt; /* Pointer to next B-tree node */
- haddr_t next_addr; /* Address of next node to iterate over */
-
- /* count the size of bt */
- *(bh_udata->btree_size) += H5B_nodesize(f, shared, NULL);
-
- /* Protect bt's next node to the right, if there is one */
- if(H5F_addr_defined(bt->right)) {
- next_addr = bt->right;
- if(NULL == (next_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, next_addr, type, bh_udata->udata, H5AC_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node")
- } else {
- next_addr = HADDR_UNDEF;
- next_bt = NULL;
- } /* end if */
-
- /* Unprotect bt */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) {
- if(next_bt) {
- HDassert(H5F_addr_defined(next_addr));
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, next_addr, next_bt, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
- } /* end if */
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
- } /* end if */
-
- /* Advance to the next node */
- bt = next_bt;
- addr = next_addr;
- } /* end if */
- } /* end while */
-
-done:
- if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B_iterate_btree_size() */
diff --git a/src/H5B2.c b/src/H5B2.c
index 281408e..4b7d67c 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -1187,9 +1187,10 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5B2_modify() */
+
/*-------------------------------------------------------------------------
- * Function: H5B2_info_iterate
+ * Function: H5B2_iterate_size
*
* Purpose: Iterate over all the records in the B-tree, collecting
* storage info.
@@ -1202,18 +1203,17 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hsize_t *btree_size)
+H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hsize_t *btree_size)
{
- H5B2_t *bt2=NULL; /* Pointer to the B-tree header */
+ H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
- H5RC_t *bt2_shared=NULL; /* Pointer to ref-counter for shared B-tree info */
- hbool_t incr_rc=FALSE; /* Flag to indicate that we've incremented the B-tree's shared info reference count */
+ H5RC_t *bt2_shared = NULL; /* Pointer to ref-counter for shared B-tree info */
+ hbool_t incr_rc = FALSE; /* Flag to indicate that we've incremented the B-tree's shared info reference count */
H5B2_node_ptr_t root_ptr; /* Node pointer info for root node */
unsigned depth; /* Current depth of the tree */
- herr_t ret_value=SUCCEED;
-
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5B2_info_iterate, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_iterate_size, FAIL)
/* Check arguments. */
HDassert(f);
@@ -1225,6 +1225,7 @@ H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add
if(NULL == (bt2 = H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
+ /* Safely grab pointer to reference counted shared B-tree info, so we can release the B-tree header if necessary */
bt2_shared = bt2->shared;
H5RC_INC(bt2_shared);
incr_rc = TRUE;
@@ -1233,6 +1234,7 @@ H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add
shared = H5RC_GET_OBJ(bt2->shared);
HDassert(shared);
+ /* Add size of header to B-tree metadata total */
*btree_size += H5B2_HEADER_SIZE(f);
/* Make copy of the root node pointer */
@@ -1248,9 +1250,13 @@ H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add
/* Iterate through records */
if(root_ptr.node_nrec > 0) {
- /* Iterate through nodes */
- if((ret_value = H5B2_info_iterate_node(f, dxpl_id, bt2_shared, depth, &root_ptr, btree_size)) < 0)
- HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed");
+ /* Check for root node being a leaf */
+ if(depth == 0)
+ *btree_size += shared->node_size;
+ else
+ /* Iterate through nodes */
+ if(H5B2_iterate_size_node(f, dxpl_id, bt2_shared, depth, &root_ptr, btree_size) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed");
} /* end if */
done:
@@ -1259,4 +1265,5 @@ done:
H5RC_DEC(bt2_shared);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_info_iterate() */
+} /* H5B2_iterate_size() */
+
diff --git a/src/H5B2int.c b/src/H5B2int.c
index 20e4300..2625c63 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -3147,6 +3147,67 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5B2_delete_node() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_iterate_size_node
+ *
+ * Purpose: Iterate over all the records from a B-tree node, collecting
+ * btree storage info.
+ *
+ * Return: non-negative on success, negative on error
+ *
+ * Programmer: Vailin Choi
+ * July 12 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
+ const H5B2_node_ptr_t *curr_node, hsize_t *btree_size)
+{
+ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
+ H5B2_internal_t *internal = NULL; /* Pointer to internal node */
+ herr_t ret_value = SUCCEED; /* Iterator return value */
+
+ FUNC_ENTER_NOAPI(H5B2_iterate_size_node, FAIL)
+
+ /* Check arguments. */
+ HDassert(f);
+ HDassert(bt2_shared);
+ HDassert(curr_node);
+ HDassert(btree_size);
+ HDassert(depth > 0);
+
+ /* Get the pointer to the shared B-tree info */
+ shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared);
+ HDassert(shared);
+
+ /* Lock the current B-tree node */
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
+
+ /* Recursively descend into child nodes, if we are above the "twig" level in the B-tree */
+ if(depth > 1) {
+ unsigned u; /* Local index */
+
+ /* Descend into children */
+ for(u = 0; u < internal->nrec + 1; u++)
+ if(H5B2_iterate_size_node(f, dxpl_id, bt2_shared, (depth - 1), &(internal->node_ptrs[u]), btree_size) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed")
+ } /* end if */
+ else /* depth is 1: count all the leaf nodes from this node */
+ *btree_size += (internal->nrec + 1) * shared->node_size;
+
+ /* Count this node */
+ *btree_size += shared->node_size;
+
+done:
+ if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5B2_iterate_size_node() */
+
#ifdef H5B2_DEBUG
/*-------------------------------------------------------------------------
@@ -3304,63 +3365,4 @@ H5B2_assert_internal2(hsize_t parent_all_nrec, H5B2_shared_t *shared, H5B2_inter
return(0);
} /* end H5B2_assert_internal2() */
#endif /* H5B2_DEBUG */
-
-/*-------------------------------------------------------------------------
- * Function: H5B2_info_iterate_node
- *
- * Purpose: Iterate over all the records from a B-tree node, collecting
- * btree storage info.
- *
- * Return: non-negative on success, negative on error
- *
- * Programmer: Vailin Choi
- * July 12 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5B2_info_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
-const H5B2_node_ptr_t *curr_node, hsize_t *btree_size)
-{
- H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
- herr_t ret_value = SUCCEED; /* Iterator return value */
- H5B2_internal_t *internal = NULL; /* Pointer to internal node */
- unsigned u; /* Local index */
-
- FUNC_ENTER_NOAPI(H5B2_info_iterate_node, FAIL)
-
- /* Check arguments. */
- HDassert(f);
- HDassert(bt2_shared);
- HDassert(curr_node);
- HDassert(btree_size);
-
- /* Get the pointer to the shared B-tree info */
- shared=(H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared);
- HDassert(shared);
-
- if(depth > 0) {
- /* Lock the current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
-
- if(depth>1) {
- /* Descend into children */
- for(u=0; u<internal->nrec+1; u++)
- if(H5B2_info_iterate_node(f, dxpl_id, bt2_shared, (depth-1), &(internal->node_ptrs[u]), btree_size) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed")
- } /* end if */
- else /* depth is 1: count all the leaf nodes from this node */
- *btree_size += (internal->nrec + 1) * shared->node_size;
- } /* end if */
-
- /* Count this node */
- *btree_size += shared->node_size;
-
-done:
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_info_iterate_node() */
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h
index 956abb1..3dfbe41 100644
--- a/src/H5B2pkg.h
+++ b/src/H5B2pkg.h
@@ -269,12 +269,9 @@ H5_DLL herr_t H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
H5_DLL herr_t H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_operator_t op,
void *op_data);
-
-H5_DLL herr_t H5B2_info_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
+H5_DLL herr_t H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
unsigned depth, const H5B2_node_ptr_t *curr_node, hsize_t *op_data);
-
-
/* Routines for locating records */
H5_DLL int H5B2_locate_record(const H5B2_class_t *type, unsigned nrec,
size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx);
diff --git a/src/H5B2private.h b/src/H5B2private.h
index 064743f..6d8172c 100644
--- a/src/H5B2private.h
+++ b/src/H5B2private.h
@@ -122,10 +122,8 @@ H5_DLL herr_t H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, void *udata);
H5_DLL herr_t H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, H5B2_operator_t op, void *op_data);
-
-H5_DLL herr_t H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
+H5_DLL herr_t H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, hsize_t *op_data);
-
H5_DLL herr_t H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
haddr_t addr, void *udata, H5B2_found_t op, void *op_data);
H5_DLL herr_t H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h
index 4d726be..4dfea84 100644
--- a/src/H5Bprivate.h
+++ b/src/H5Bprivate.h
@@ -124,11 +124,13 @@ typedef struct H5B_class_t {
herr_t (*debug_key)(FILE*, H5F_t*, hid_t, int, int, const void*, const void*);
} H5B_class_t;
+/* "user data" for iterating over B-tree when collecting B-tree metadata size */
typedef struct H5B_info_ud_t {
- void *udata;
- hsize_t *btree_size;
+ void *udata; /* Node type's 'udata' for loading */
+ hsize_t *btree_size; /* Accumulated size for B-tree metadata */
} H5B_info_ud_t;
+
/*****************************/
/* Library-private Variables */
/*****************************/
@@ -142,21 +144,22 @@ H5FL_EXTERN(H5B_shared_t);
/***************************************/
H5_DLL size_t H5B_nodesize(const H5F_t *f, const H5B_shared_t *shared,
size_t *total_nkey_size);
-H5_DLL herr_t H5B_create (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
+H5_DLL herr_t H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
haddr_t *addr_p/*out*/);
-H5_DLL herr_t H5B_find (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
+H5_DLL herr_t H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
void *udata);
-H5_DLL herr_t H5B_insert (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
+H5_DLL herr_t H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
void *udata);
-H5_DLL herr_t H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t
+H5_DLL herr_t H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t
op, haddr_t addr, void *udata);
-H5_DLL herr_t H5B_iterate_btree_size (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t
+H5_DLL herr_t H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t
op, haddr_t addr, H5B_info_ud_t *bh_udata);
H5_DLL herr_t H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
void *udata);
H5_DLL herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
void *udata);
-H5_DLL herr_t H5B_debug (H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
+H5_DLL herr_t H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
int indent, int fwidth, const H5B_class_t *type,
void *udata);
-#endif
+#endif /* _H5Bprivate_H */
+
diff --git a/src/H5D.c b/src/H5D.c
index 59bd515..526ee27 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -3288,3 +3288,4 @@ H5Ddebug(hid_t dset_id)
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Ddebug() */
+
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 297a480..5d744e5 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -3883,6 +3883,57 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5D_istore_bh_size
+ *
+ * Purpose: Retrieve the amount of B-tree storage for chunked dataset
+ *
+ * Return: Success: Non-negative
+ * Failure: negative
+ *
+ * Programmer: Vailin Choi
+ * June 8, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_istore_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout, hsize_t *btree_size)
+{
+ H5D_istore_it_ud1_t udata; /* User-data for loading istore nodes */
+ H5B_info_ud_t bh_udata; /* User-data for B-tree size iteration */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5D_istore_bh_info, FAIL)
+
+ /* Check args */
+ HDassert(f);
+ HDassert(layout);
+ HDassert(btree_size);
+
+ /* Initialize the shared info for the B-tree traversal */
+ if(H5D_istore_shared_create(f, layout) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info")
+
+ /* Initialize istore node user-data */
+ HDmemset(&udata, 0, sizeof udata);
+ udata.common.mesg = layout;
+
+ /* Iterate over B-tree, accumulating metadata size */
+ bh_udata.udata = &udata;
+ bh_udata.btree_size = btree_size;
+ if(H5B_iterate_size(f, dxpl_id, H5B_ISTORE, NULL, layout->u.chunk.addr, &bh_udata) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to iterate over chunk B-tree")
+
+done:
+ if(layout->u.chunk.btree_shared == NULL)
+ HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil")
+ if(H5RC_DEC(layout->u.chunk.btree_shared) < 0)
+ HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_istore_bh_info() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D_istore_dump_btree
*
* Purpose: Prints information about the storage B-tree to the specified
@@ -4027,47 +4078,4 @@ H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int inden
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_istore_debug() */
-
-/*-------------------------------------------------------------------------
- * Function: H5D_istore_btree_size
- *
- * Purpose: Retrieve the amount of B-tree storage for chunked dataset
- *
- * Return: Success: Non-negative
- * Failure: negative
- *
- * Programmer: Vailin Choi
- * June 8, 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5D_obj_istore_bh_info(H5O_loc_t *oloc, H5O_layout_t *layout, hid_t dxpl_id, hsize_t *btree_size)
-{
- H5D_istore_it_ud1_t udata;
- herr_t ret_value=SUCCEED;
- H5B_info_ud_t bh_udata;
-
- FUNC_ENTER_NOAPI(H5D_obj_istore_bh_info, FAIL)
-
- HDassert(oloc);
- HDassert(layout);
- HDassert(btree_size);
-
- if(H5D_istore_shared_create(oloc->file, layout)<0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info")
-
- HDmemset(&udata, 0, sizeof udata);
- udata.common.mesg = layout;
- bh_udata.udata = &udata;
- bh_udata.btree_size = btree_size;
- if ((ret_value = H5B_iterate_btree_size(oloc->file, dxpl_id, H5B_ISTORE, NULL, layout->u.chunk.addr, &bh_udata)) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to iterate over chunk B-tree")
-done:
- if(layout->u.chunk.btree_shared==NULL)
- HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil")
- if(H5RC_DEC(layout->u.chunk.btree_shared)<0)
- HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page")
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_obj_istore_bh_info() */
diff --git a/src/H5Doh.c b/src/H5Doh.c
index 620554e0..01447a3 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -327,6 +327,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dset_get_oloc() */
+
/*-------------------------------------------------------------------------
* Function: H5O_dset_bh_info
*
@@ -342,28 +343,28 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_dset_bh_info(H5O_loc_t *oloc, H5O_t *oh, hid_t dxpl_id, H5_ih_info_t *bh_info)
+H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info)
{
H5O_layout_t layout; /* Data storage layout message */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_dset_bh_info, FAIL)
/* Sanity check */
- HDassert(oloc);
+ HDassert(f);
HDassert(oh);
HDassert(bh_info);
- if (NULL==H5O_msg_read_real(oloc->file, dxpl_id, oh, H5O_LAYOUT_ID, &layout))
+ /* Get the layout message from the object header */
+ if(NULL == H5O_msg_read_real(f, dxpl_id, oh, H5O_LAYOUT_ID, &layout))
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find LAYOUT message")
- else {
- if ((layout.type == H5D_CHUNKED) && (layout.u.chunk.addr != HADDR_UNDEF)) {
- ret_value = H5D_obj_istore_bh_info(oloc, &layout, dxpl_id, &(bh_info->index_size));
- if (ret_value < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine chunked dataset btree info")
- }
- }
+
+ /* Check for chunked dataset storage */
+ if((layout.type == H5D_CHUNKED) && H5F_addr_defined(layout.u.chunk.addr))
+ if(H5D_istore_bh_info(f, dxpl_id, &layout, &(bh_info->index_size)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine chunked dataset btree info")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dset_bh_info() */
+
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index b1db412..f28a5db 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h