From 4be636f4f00271f85802fbb6ef079146f2dbf7fb Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 17 Jul 2007 14:35:09 -0500 Subject: [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) --- src/H5Abtree2.c | 2 +- src/H5B.c | 190 +++---- src/H5B2.c | 31 +- src/H5B2int.c | 120 ++-- src/H5B2pkg.h | 5 +- src/H5B2private.h | 4 +- src/H5Bprivate.h | 21 +- src/H5D.c | 1 + src/H5Distore.c | 94 ++-- src/H5Doh.c | 23 +- src/H5Dpkg.h | 3 +- src/H5F.c | 80 +-- src/H5FS.c | 96 ++-- src/H5FSprivate.h | 4 +- src/H5Fpkg.h | 3 +- src/H5Fpublic.h | 9 +- src/H5Fsuper.c | 30 +- src/H5Gnode.c | 101 ++-- src/H5Gobj.c | 1 + src/H5Goh.c | 66 +-- src/H5Gpkg.h | 11 +- src/H5Gprivate.h | 1 - src/H5Gstab.c | 81 +-- src/H5HF.c | 85 --- src/H5HFiblock.c | 54 +- src/H5HFpkg.h | 4 +- src/H5HFprivate.h | 7 +- src/H5HFstat.c | 79 +++ src/H5HL.c | 27 +- src/H5O.c | 68 +-- src/H5Oattribute.c | 63 +-- src/H5Opkg.h | 14 +- src/H5Oprivate.h | 4 - src/H5Opublic.h | 7 +- src/H5Oshared.h | 4 +- src/H5SM.c | 51 +- src/H5SMprivate.h | 2 +- tools/misc/h5stat.c | 860 +++++++++++++---------------- tools/misc/testfiles/h5stat_filters-d.ddl | 18 +- tools/misc/testfiles/h5stat_filters-dT.ddl | 18 +- tools/misc/testfiles/h5stat_filters.ddl | 18 +- tools/misc/testfiles/h5stat_newgrat.ddl | 18 +- tools/misc/testfiles/h5stat_tsohm.ddl | 18 +- 43 files changed, 1130 insertions(+), 1266 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; unrec+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 @@ -329,7 +329,8 @@ H5_DLL herr_t H5D_istore_dest (H5D_t *dset, hid_t dxpl_id); H5_DLL herr_t H5D_istore_allocate (H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite); H5_DLL hsize_t H5D_istore_allocated(H5D_t *dset, hid_t dxpl_id); -H5_DLL herr_t H5D_obj_istore_bh_info(H5O_loc_t *oloc, H5O_layout_t *layout, hid_t dxpl_id, hsize_t *btree_size); +H5_DLL herr_t H5D_istore_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout, + hsize_t *btree_size); H5_DLL herr_t H5D_istore_prune_by_extent(const H5D_io_info_t *io_info, const hsize_t *old_dims); H5_DLL herr_t H5D_istore_initialize_by_extent(H5D_io_info_t *io_info); diff --git a/src/H5F.c b/src/H5F.c index ebbc3f2..f478813 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -31,6 +31,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ /* Predefined file drivers */ @@ -3488,37 +3489,25 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id) { - H5F_t *file=NULL; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ - herr_t result; + H5F_t *file; /* File object for file ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Freset_mdc_hit_rate_stats, FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if ( NULL == (file = H5I_object_verify(file_id, H5I_FILE)) ) { - + if(NULL == (file = H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - } /* Reset the hit rate statistic */ - result = H5AC_reset_cache_hit_rate_stats(file->shared->cache); - - if ( result != SUCCEED ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "H5AC_reset_cache_hit_rate_stats() failed."); - } - + if(H5AC_reset_cache_hit_rate_stats(file->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") done: - FUNC_LEAVE_API(ret_value) - } /* H5Freset_mdc_hit_rate_stats() */ @@ -3539,8 +3528,6 @@ done: * Programmer: Raymond Lu * June 29, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ ssize_t @@ -3579,11 +3566,12 @@ H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) } /* end if */ /* Set return value */ - ret_value=(ssize_t)len; + ret_value = (ssize_t)len; done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_name() */ + /*------------------------------------------------------------------------- * Function: H5Fget_info @@ -3602,31 +3590,47 @@ done: herr_t H5Fget_info(hid_t obj_id, H5F_info_t *finfo) { - H5F_t *f; - herr_t ret_value=SUCCEED; + H5F_t *f; /* Top file in mount hierarchy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Fget_info, FAIL) - HDassert(finfo); + /* Check args */ + if(!finfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - HDmemset(finfo, 0, sizeof(H5F_info_t)); + /* For file IDs, get the file object directly */ + /* (This prevents the H5G_loc() call from returning the file pointer for + * the top file in a mount hierarchy) + */ if(H5I_get_type(obj_id) == H5I_FILE ) { if(NULL == (f = H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file") - else { - HDassert(f->shared); - if (H5F_addr_defined(f->shared->extension_addr)) { - if (H5F_super_ext_info(f, finfo, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock extension size") - } - if(H5F_addr_defined(f->shared->sohm_addr)) { - if (H5SM_ih_info(f, finfo, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve SOHM btree & heap storage info") - } - } - } else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid object ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + } /* end if */ + else { + H5G_loc_t loc; /* Object location */ + + /* Get symbol table entry */ + if(H5G_loc(obj_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") + f = loc.oloc->file; + } /* end else */ + HDassert(f->shared); + + /* Reset file info struct */ + HDmemset(finfo, 0, sizeof(H5F_info_t)); + + /* Check for superblock extension info */ + if(H5F_addr_defined(f->shared->extension_addr)) + if(H5F_super_ext_size(f, H5AC_ind_dxpl_id, &finfo->super_ext_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock extension size") + + /* Check for SOHM info */ + if(H5F_addr_defined(f->shared->sohm_addr)) + if(H5SM_ih_size(f, H5AC_ind_dxpl_id, finfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve SOHM btree & heap storage info") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info() */ + diff --git a/src/H5FS.c b/src/H5FS.c index 1417713..e34f176 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -452,50 +452,9 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_new() */ -#ifdef H5FS_DEBUG /*------------------------------------------------------------------------- - * Function: H5FS_assert - * - * Purpose: Verify that the free space manager is mostly sane - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jul 17 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5FS_assert(const H5FS_t *fspace) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_assert) -#ifdef QAK -HDfprintf(stderr, "%s: fspace->hdr->tot_sect_count = %Hu\n", "H5FS_assert", fspace->hdr->tot_sect_count); -#endif /* QAK */ - - /* Sanity check sections */ - H5FS_sect_assert(fspace); - - /* General assumptions about the section size counts */ - HDassert(fspace->sinfo->tot_size_count >= fspace->sinfo->serial_size_count); - HDassert(fspace->sinfo->tot_size_count >= fspace->sinfo->ghost_size_count); - - /* General assumptions about the section counts */ - HDassert(fspace->tot_sect_count >= fspace->serial_sect_count); - HDassert(fspace->tot_sect_count >= fspace->ghost_sect_count); - HDassert(fspace->tot_sect_count == (fspace->serial_sect_count + fspace->ghost_sect_count)); -#ifdef QAK - HDassert(fspace->serial_sect_count > 0 || fspace->ghost_sect_count == 0); -#endif /* QAK */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5FS_assert() */ -#endif /* H5FS_DEBUG */ - -/*------------------------------------------------------------------------- - * Function: H5FS_meta_info + * Function: H5FS_size * * Purpose: Collect meta storage info used by the free space manager * @@ -508,13 +467,14 @@ HDfprintf(stderr, "%s: fspace->hdr->tot_sect_count = %Hu\n", "H5FS_assert", fspa *------------------------------------------------------------------------- */ herr_t -H5FS_meta_info(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, hsize_t *meta_size) +H5FS_size(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, hsize_t *meta_size) { H5FS_t *fspace = NULL; /* Free space header info */ H5FS_prot_t fs_prot; /* Information for protecting free space manager */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FS_meta_info, FAIL) + FUNC_ENTER_NOAPI(H5FS_size, FAIL) + /* * Check arguments. */ @@ -533,11 +493,55 @@ H5FS_meta_info(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, hsize_t *meta_size) if(NULL == (fspace = H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, &fs_prot, NULL, H5AC_READ))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, FAIL, "unable to load free space header") - *meta_size = H5FS_HEADER_SIZE(f) + fspace->alloc_sect_size; + /* Get the free space size info */ + *meta_size += H5FS_HEADER_SIZE(f) + fspace->alloc_sect_size; done: if(fspace && H5AC_unprotect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FS_size() */ + +#ifdef H5FS_DEBUG + +/*------------------------------------------------------------------------- + * Function: H5FS_assert + * + * Purpose: Verify that the free space manager is mostly sane + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Jul 17 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FS_assert(const H5FS_t *fspace) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_assert) +#ifdef QAK +HDfprintf(stderr, "%s: fspace->hdr->tot_sect_count = %Hu\n", "H5FS_assert", fspace->hdr->tot_sect_count); +#endif /* QAK */ + + /* Sanity check sections */ + H5FS_sect_assert(fspace); + + /* General assumptions about the section size counts */ + HDassert(fspace->sinfo->tot_size_count >= fspace->sinfo->serial_size_count); + HDassert(fspace->sinfo->tot_size_count >= fspace->sinfo->ghost_size_count); + + /* General assumptions about the section counts */ + HDassert(fspace->tot_sect_count >= fspace->serial_sect_count); + HDassert(fspace->tot_sect_count >= fspace->ghost_sect_count); + HDassert(fspace->tot_sect_count == (fspace->serial_sect_count + fspace->ghost_sect_count)); +#ifdef QAK + HDassert(fspace->serial_sect_count > 0 || fspace->ghost_sect_count == 0); +#endif /* QAK */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FS_assert() */ +#endif /* H5FS_DEBUG */ + diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index e6a3ce4..16f2df6 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -158,11 +158,11 @@ H5_DLL H5FS_t *H5FS_create(H5F_t *f, hid_t dxpl_id, haddr_t *fs_addr, const H5FS_section_class_t *classes[], void *cls_init_udata); H5_DLL H5FS_t *H5FS_open(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, size_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata); +H5_DLL herr_t H5FS_size(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, + hsize_t *meta_size); H5_DLL herr_t H5FS_delete(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr); H5_DLL herr_t H5FS_close(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace); -H5_DLL herr_t H5FS_meta_info(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, hsize_t *meta_size); - /* Free space section routines */ H5_DLL herr_t H5FS_sect_add(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_section_info_t *node, unsigned flags, void *op_data); diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 60a81a9..a104e61 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -177,8 +177,7 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop H5_DLL herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_write(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc); - -H5_DLL herr_t H5F_super_ext_info(H5F_t *f, H5F_info_t *finfo, hid_t dxpl_id); +H5_DLL herr_t H5F_super_ext_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_ext_info); /* Shared file list related routines */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index db86101..1d98330 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -97,11 +97,13 @@ typedef enum H5F_close_degree_t { H5F_CLOSE_STRONG = 3 } H5F_close_degree_t; +/* Current "global" information about file */ +/* (just size info currently) */ typedef struct H5F_info_t { - hsize_t super_ext_size; /* superblock extension size */ + hsize_t super_ext_size; /* Superblock extension size */ struct { - hsize_t hdr_size; - H5_ih_info_t msgs_info; + hsize_t hdr_size; /* Shared object header message header size */ + H5_ih_info_t msgs_info; /* Shared object header message index & heap size */ } sohm; } H5F_info_t; @@ -142,7 +144,6 @@ H5_DLL herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id); H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size); H5_DLL herr_t H5Fget_info(hid_t obj_id, H5F_info_t *bh_info); - #ifdef __cplusplus } #endif diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 4a516af..7d1a8ad 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -965,8 +965,9 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_super_write() */ + /*------------------------------------------------------------------------- - * Function: H5F_super_ext_info + * Function: H5F_super_ext_size * Get storage size of the superblock extension * * Return: Success: non-negative on success @@ -977,18 +978,31 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_super_ext_info(H5F_t *f, H5F_info_t *finfo, hid_t dxpl_id) +H5F_super_ext_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_ext_size) { - herr_t ret_value=SUCCEED; + H5O_loc_t ext_loc; /* "Object location" for superblock extension */ + H5O_info_t oinfo; /* Object info for superblock extension */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5F_super_ext_info, FAIL) + FUNC_ENTER_NOAPI(H5F_super_ext_size, FAIL) + /* Sanity check */ HDassert(f); - HDassert(finfo); + HDassert(super_ext_size); + + /* Set up "fake" object location for superblock extension */ + H5O_loc_reset(&ext_loc); + ext_loc.file = f; + ext_loc.addr = f->shared->extension_addr; - if (H5O_super_ext_size(f, &(finfo->super_ext_size), dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock extension size") + /* Get object header info for superblock extension */ + if(H5O_get_info(&ext_loc, &oinfo, dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info") + + /* Set the superblock extension size */ + *super_ext_size = oinfo.hdr.space.total; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5F_super_ext_info() */ +} /* H5F_super_ext_size() */ + diff --git a/src/H5Gnode.c b/src/H5Gnode.c index cf49c8b..5aa64c5 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -73,7 +73,7 @@ typedef struct H5G_node_t { /* PRIVATE PROTOTYPES */ static herr_t H5G_node_serialize(H5F_t *f, H5G_node_t *sym, size_t size, uint8_t *buf); -static size_t H5G_node_size(const H5F_t *f); +static size_t H5G_node_size_real(const H5F_t *f); static herr_t H5G_node_shared_free(void *shared); /* Metadata cache callbacks */ @@ -83,7 +83,7 @@ static herr_t H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t a H5G_node_t *sym, unsigned UNUSED * flags_ptr); static herr_t H5G_node_dest(H5F_t *f, H5G_node_t *sym); static herr_t H5G_node_clear(H5F_t *f, H5G_node_t *sym, hbool_t destroy); -static herr_t H5G_compute_size(const H5F_t *f, const H5G_node_t *sym, size_t *size_ptr); +static herr_t H5G_node_size(const H5F_t *f, const H5G_node_t *sym, size_t *size_ptr); /* B-tree callbacks */ static H5RC_t *H5G_node_get_shared(const H5F_t *f, const void *_udata); @@ -119,7 +119,7 @@ const H5AC_class_t H5AC_SNODE[1] = {{ (H5AC_flush_func_t)H5G_node_flush, (H5AC_dest_func_t)H5G_node_dest, (H5AC_clear_func_t)H5G_node_clear, - (H5AC_size_func_t)H5G_compute_size, + (H5AC_size_func_t)H5G_node_size, }}; /* H5G inherits B-tree like properties from H5B */ @@ -294,7 +294,7 @@ H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t UNUSED dxpl_id, int indent, /*------------------------------------------------------------------------- - * Function: H5G_node_size + * Function: H5G_node_size_real * * Purpose: Returns the total size of a symbol table node. * @@ -311,9 +311,9 @@ H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t UNUSED dxpl_id, int indent, *------------------------------------------------------------------------- */ static size_t -H5G_node_size(const H5F_t *f) +H5G_node_size_real(const H5F_t *f) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_size); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_size_real); FUNC_LEAVE_NOAPI(H5G_NODE_SIZEOF_HDR(f) + (2 * H5F_SYM_LEAF_K(f)) * H5G_SIZEOF_ENTRY(f)); @@ -373,7 +373,7 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_udata1 HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't wrap buffer") /* Compute the size of the serialized symbol table node on disk */ - size = H5G_node_size(f); + size = H5G_node_size_real(f); /* Get a pointer to a buffer that's large enough for node */ if(NULL == (node = H5WB_actual(wb, size))) @@ -500,7 +500,7 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Compute the size of the serialized symbol table node on disk */ - size = H5G_node_size(f); + size = H5G_node_size_real(f); /* Get a pointer to a buffer that's large enough for node */ if(NULL == (node = H5WB_actual(wb, size))) @@ -671,7 +671,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_compute_size + * Function: H5G_node_size * * Purpose: Compute the size in bytes of the specified instance of * H5G_node_t on disk, and return it in *size_ptr. On failure @@ -687,20 +687,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_compute_size(const H5F_t *f, const H5G_node_t UNUSED *sym, size_t *size_ptr) +H5G_node_size(const H5F_t *f, const H5G_node_t UNUSED *sym, size_t *size_ptr) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_compute_size); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_size); /* * Check arguments. */ - assert(f); - assert(size_ptr); + HDassert(f); + HDassert(size_ptr); - *size_ptr = H5G_node_size(f); + *size_ptr = H5G_node_size_real(f); FUNC_LEAVE_NOAPI(SUCCEED); -} /* H5G_compute_size() */ +} /* H5G_node_size() */ /*------------------------------------------------------------------------- @@ -742,7 +742,7 @@ H5G_node_create(H5F_t *f, hid_t dxpl_id, H5B_ins_t UNUSED op, void *_lt_key, if(NULL == (sym = H5FL_CALLOC(H5G_node_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - size = H5G_node_size(f); + size = H5G_node_size_real(f); if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, size))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to allocate file space"); @@ -1297,7 +1297,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, *rt_key = *lt_key; *rt_key_changed = TRUE; sn->nsyms = 0; - if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f)) < 0 + if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size_real(f)) < 0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__DIRTIED_FLAG | H5C__DELETED_FLAG) < 0) { sn = NULL; HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node") @@ -1369,7 +1369,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, *rt_key = *lt_key; *rt_key_changed = TRUE; sn->nsyms = 0; - if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f)) < 0 + if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size_real(f)) < 0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__DIRTIED_FLAG | H5C__DELETED_FLAG) < 0) { sn = NULL; HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node") @@ -1928,6 +1928,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5G_node_iterate_size + * + * Purpose: This function gets called by H5B_iterate_btree_size() + * to gather storage info for SNODs. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi + * Jun 19 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_node_iterate_size(H5F_t *f, hid_t UNUSED dxpl_id, const void UNUSED *_lt_key, haddr_t UNUSED addr, + const void UNUSED *_rt_key, void *_udata) +{ + hsize_t *stab_size = (hsize_t *)_udata; /* User data */ + + FUNC_ENTER_NOAPI_NOFUNC(H5G_node_iterate_size) + + /* Check arguments */ + HDassert(f); + HDassert(stab_size); + + *stab_size += H5G_node_size_real(f); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5G_btree_node_iterate() */ + + +/*------------------------------------------------------------------------- * Function: H5G_node_debug * * Purpose: Prints debugging information about a symbol table node @@ -1984,7 +2015,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, "Dirty:", sn->cache_info.is_dirty ? "Yes" : "No"); fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Size of Node (in bytes):", (unsigned)H5G_node_size(f)); + "Size of Node (in bytes):", (unsigned)H5G_node_size_real(f)); fprintf(stream, "%*s%-*s %u of %u\n", indent, "", fwidth, "Number of Symbols:", sn->nsyms, (unsigned)(2 * H5F_SYM_LEAF_K(f))); @@ -2015,36 +2046,4 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_debug() */ - -/*------------------------------------------------------------------------- - * Function: H5G_btree_node_iterate - * - * Purpose: This function gets called by H5B_iterate_btree_size() - * to gather storage info for SNODs. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi - * Jun 19 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_btree_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t UNUSED addr, - const void UNUSED *_rt_key, void *_udata) -{ - herr_t ret_value=SUCCEED; - hsize_t *stab_size=(hsize_t *)_udata; - - FUNC_ENTER_NOAPI(H5G_btree_node_iterate, FAIL) - - /* - * Check arguments. - */ - HDassert(f); - HDassert(stab_size); - *stab_size += H5G_node_size(f); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_btree_node_iterate() */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 09eb3b1..a3166ba 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -1247,3 +1247,4 @@ H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5_index_t idx_type, done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_obj_lookup_by_idx() */ + diff --git a/src/H5Goh.c b/src/H5Goh.c index 9b070a6..4f7dbc6 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -242,6 +242,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_group_get_oloc() */ + /*------------------------------------------------------------------------- * Function: H5O_group_bh_info * @@ -256,50 +257,51 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_group_bh_info(H5O_loc_t *oloc, H5O_t *oh, hid_t dxpl_id, H5_ih_info_t *bh_info) +H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) { - herr_t ret_value=SUCCEED; /* Return value */ - hsize_t huge_bt_size=0; H5O_linfo_t linfo; /* Link info message */ - H5O_stab_t stabinfo; /* Info about symbol table */ - - + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_group_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_LINFO_ID, &linfo)) { + /* Check for "new style" group info */ + if(NULL == H5O_msg_read_real(f, dxpl_id, oh, H5O_LINFO_ID, &linfo)) { + H5O_stab_t stab; /* Info about symbol table */ + + /* Must be "old style" group, clear error stack */ H5E_clear_stack(NULL); - if(NULL==H5O_msg_read_real(oloc->file, dxpl_id, oh, H5O_STAB_ID, &stabinfo)) { + + /* Get symbol table message */ + if(NULL == H5O_msg_read_real(f, dxpl_id, oh, H5O_STAB_ID, &stab)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't find LINFO nor STAB messages") - } else { /* STAB */ - if (H5G_stab_bh_info(oloc, &stabinfo, dxpl_id, bh_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve pre-1.8 group btree & heap info") - } - } else { /* LINFO */ - if (H5F_addr_defined(linfo.corder_bt2_addr)) { - if (H5B2_info_iterate(oloc->file, dxpl_id, H5G_BT2_CORDER, - linfo.corder_bt2_addr, &bh_info->index_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } - if (H5F_addr_defined(linfo.name_bt2_addr)) { - if (H5B2_info_iterate(oloc->file, dxpl_id, H5G_BT2_NAME, - linfo.name_bt2_addr, &bh_info->index_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } - huge_bt_size = 0; - if (H5F_addr_defined(linfo.fheap_addr)) { - if (H5HF_fheap_info(oloc->file, dxpl_id, linfo.fheap_addr, - &bh_info->heap_size, &huge_bt_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve fractal heap storage info") - } - bh_info->index_size += huge_bt_size; - } + + /* Get symbol table size info */ + if(H5G_stab_bh_size(f, dxpl_id, &stab, bh_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve symbol table size info") + } /* end if */ + else { /* LINFO */ + /* Get creation order B-tree size, if available */ + if(H5F_addr_defined(linfo.corder_bt2_addr)) + if(H5B2_iterate_size(f, dxpl_id, H5G_BT2_CORDER, linfo.corder_bt2_addr, &bh_info->index_size) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") + + /* Get name order B-tree size, if available */ + if(H5F_addr_defined(linfo.name_bt2_addr)) + if(H5B2_iterate_size(f, dxpl_id, H5G_BT2_NAME, linfo.name_bt2_addr, &bh_info->index_size) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") + + /* Get fractal heap size, if available */ + if(H5F_addr_defined(linfo.fheap_addr)) + if(H5HF_size(f, dxpl_id, linfo.fheap_addr, &bh_info->heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve fractal heap storage info") + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_group_bh_info() */ + diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index cb36a0f..5567782 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -372,6 +372,8 @@ H5_DLL herr_t H5G_stab_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data); H5_DLL herr_t H5G_stab_count(struct H5O_loc_t *oloc, hsize_t *num_objs, hid_t dxpl_id); +H5_DLL herr_t H5G_stab_bh_size(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab, + H5_ih_info_t *bh_info); H5_DLL ssize_t H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id); H5_DLL H5G_obj_t H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, @@ -385,9 +387,6 @@ H5_DLL herr_t H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5_DLL herr_t H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk, hid_t dxpl_id); -H5_DLL herr_t H5G_stab_bh_info(struct H5O_loc_t *grp_oloc, H5O_stab_t *stabinfo, - hid_t dxpl_id, H5_ih_info_t *bh_info); - /* * Functions that understand symbol table entries. @@ -408,10 +407,6 @@ H5_DLL herr_t H5G_ent_debug(H5F_t *f, const H5G_entry_t *ent, H5_DLL herr_t H5G_node_init(H5F_t *f); H5_DLL int H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); - -H5_DLL herr_t H5G_btree_node_iterate(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, - const void *_rt_key, void *_udata); - H5_DLL int H5G_node_sumup(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); H5_DLL int H5G_node_by_idx(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, @@ -420,6 +415,8 @@ H5_DLL int H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t a const void *_rt_key, void *_udata); H5_DLL int H5G_node_build_table(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL herr_t H5G_node_iterate_size(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, + const void *_rt_key, void *_udata); /* Functions that understand links in groups */ H5_DLL int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 665b597..40d2df8 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -175,7 +175,6 @@ H5_DLL herr_t H5G_obj_ent_decode(H5F_t *f, const uint8_t **pp, H5_DLL herr_t H5G_obj_ent_encode(const H5F_t *f, uint8_t **pp, const struct H5O_loc_t *oloc); - /* * These functions operate on group hierarchy names. */ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 9e9f91b..2bc525c 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -604,6 +604,48 @@ done: /*------------------------------------------------------------------------- + * Function: H5G_stab_bh_size + * + * Purpose: Retrieve storage for btree and heap (1.6) + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Vailin Choi + * June 25 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_stab_bh_size(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab, H5_ih_info_t *bh_info) +{ + H5B_info_ud_t bh_udata; /* User-data for B-tree callbacks */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(H5G_stab_bh_size, FAIL) + + /* Sanity check */ + HDassert(f); + HDassert(stab); + HDassert(bh_info); + + /* Set up user data for B-tree callback */ + bh_udata.udata = NULL; + bh_udata.btree_size = &(bh_info->index_size); + + /* Get the B-tree & symbol table node size info */ + if(H5B_iterate_size(f, dxpl_id, H5B_SNODE, H5G_node_iterate_size, stab->btree_addr, &bh_udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iteration operator failed") + + /* Get the size of the local heap for the group */ + if(H5HL_heapsize(f, dxpl_id, stab->heap_addr, &(bh_info->heap_size)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "iteration operator failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_stab_bh_size() */ + + +/*------------------------------------------------------------------------- * Function: H5G_stab_get_name_by_idx_cb * * Purpose: Callback for B-tree iteration 'by index' info query to @@ -1046,43 +1088,4 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_lookup_by_idx() */ - -/*------------------------------------------------------------------------- - * Function: H5G_stab_bh_info - * - * Purpose: Retrieve storage for btree and heap (1.6) - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi - * June 25 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_stab_bh_info(H5O_loc_t *oloc, H5O_stab_t *stab, hid_t dxpl_id, H5_ih_info_t *bh_info) -{ - hsize_t stab_size=0; /* storage used for symbol table nodes */ - herr_t ret_value = SUCCEED; - - H5B_info_ud_t bh_udata; - FUNC_ENTER_NOAPI(H5G_stab_bh_info, FAIL) - - /* Sanity check */ - HDassert(oloc); - HDassert(stab); - HDassert(bh_info); - - bh_udata.udata = NULL; - bh_udata.btree_size = &(bh_info->index_size); - - if (H5B_iterate_btree_size(oloc->file, dxpl_id, H5B_SNODE, H5G_btree_node_iterate, stab->btree_addr, &bh_udata) <0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iteration operator failed") - - if (H5HL_heapsize(oloc->file, dxpl_id, stab->heap_addr, &(bh_info->heap_size)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "iteration operator failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_stab_bh_info() */ diff --git a/src/H5HF.c b/src/H5HF.c index 8d65604..768b7e7 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -926,88 +926,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_delete() */ - -/*------------------------------------------------------------------------- - * Function: H5HF_fheap_info - * - * Purpose: Retrieve storage info for: - * 1. fractal heap - * 2. btree storage used by huge objects in fractal heap - * 3. free space storage info - * - * Return: non-negative on success, negative on error - * - * Programmer: Vailin Choi - * July 12 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5HF_fheap_info(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, hsize_t *heap_size, hsize_t *huge_bt_size) -{ - H5HF_hdr_t *hdr = NULL; - herr_t ret_value = SUCCEED; - hsize_t meta_size = 0; - int reterr; - - FUNC_ENTER_NOAPI(H5HF_fheap_info, FAIL) - - /* - * Check arguments. - */ - HDassert(f); - HDassert(H5F_addr_defined(fh_addr)); - HDassert(heap_size); - HDassert(huge_bt_size); - - - /* Lock the heap header into memory */ - if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header") - - *heap_size += hdr->heap_size; - *heap_size += hdr->man_alloc_size; - *heap_size += hdr->huge_size; - - if(H5F_addr_defined(hdr->man_dtable.table_addr)) { - if (hdr->man_dtable.curr_root_rows != 0) { - reterr = H5HF_indirect_info(f, dxpl_id, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, heap_size); - if (reterr < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get fractal heap storage info for indirect block") - } - } - - /* get B-tree storage for huge objects in fractal heap */ - if (H5F_addr_defined(hdr->huge_bt2_addr)) { - if (hdr->huge_ids_direct) { - if (hdr->filter_len > 0) { - if (H5B2_info_iterate(f, dxpl_id, H5HF_BT2_FILT_DIR, hdr->huge_bt2_addr, huge_bt_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } else { - if (H5B2_info_iterate(f, dxpl_id, H5HF_BT2_DIR, hdr->huge_bt2_addr, huge_bt_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } - } else { - if (hdr->filter_len > 0) { - if (H5B2_info_iterate(f, dxpl_id, H5HF_BT2_FILT_INDIR, hdr->huge_bt2_addr, huge_bt_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } else { - if (H5B2_info_iterate(f, dxpl_id, H5HF_BT2_INDIR, hdr->huge_bt2_addr, huge_bt_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } - } - } - if (H5F_addr_defined(hdr->fs_addr)) { - meta_size = 0; - if (H5FS_meta_info(f, dxpl_id, hdr->fs_addr, &meta_size) < 0) - HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") - *heap_size += meta_size; - } - -done: - /* Unprotect the header, if an error occurred */ - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_fheap_info() */ diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 15c998c..70133aa 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -1575,10 +1575,11 @@ HDfprintf(stderr, "%s: iblock_addr = %a, iblock_nrows = %u\n", FUNC, iblock_addr done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_delete() */ + /*------------------------------------------------------------------------- * - * Function: H5HF_indirect_info + * Function: H5HF_man_iblock_size * * Purpose: Gather storage used for the indirect block in fractal heap * @@ -1589,15 +1590,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_indirect_info(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned nrows, hsize_t *heap_size) +H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_addr, + unsigned nrows, hsize_t *heap_size) { - hbool_t did_protect; - H5HF_indirect_t *iblock; /* Pointer to indirect block */ - size_t u, v; - int reterr; - int ret_value=SUCCEED; + H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ + hbool_t did_protect; /* Whether we protected the indirect block or not */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5HF_man_iblock_size, FAIL) - FUNC_ENTER_NOAPI(H5HF_indirect_info, FAIL) /* * Check arguments. */ @@ -1606,34 +1607,39 @@ H5HF_indirect_info(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_addr HDassert(H5F_addr_defined(iblock_addr)); HDassert(heap_size); - if (NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, nrows, NULL, 0, FALSE, H5AC_READ, &did_protect))) + /* Protect the indirect block */ + if(NULL == (iblock = H5HF_man_iblock_protect(hdr, dxpl_id, iblock_addr, nrows, NULL, 0, FALSE, H5AC_READ, &did_protect))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap indirect block") + /* Accumulate size of this indirect block */ *heap_size += iblock->size; /* Indirect entries in this indirect block */ if(iblock->nrows > hdr->man_dtable.max_direct_rows) { - unsigned first_row_bits; /* Number of bits used bit addresses in first row */ - unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ + unsigned first_row_bits; /* Number of bits used bit addresses in first row */ + unsigned num_indirect_rows; /* Number of rows of blocks in each indirect block */ + unsigned entry; /* Current entry in row */ + size_t u; /* Local index variable */ + entry = hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width; first_row_bits = H5V_log2_of2((uint32_t)hdr->man_dtable.cparam.start_block_size) + H5V_log2_of2(hdr->man_dtable.cparam.width); - for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++) { - num_indirect_rows = (H5V_log2_gen(hdr->man_dtable.row_block_size[u]) - first_row_bits) + 1; - for(v = 0; v < hdr->man_dtable.cparam.width; v++) { - size_t off = (u * hdr->man_dtable.cparam.width) + v; - - if (H5F_addr_defined(iblock->ents[off].addr)) { - reterr = H5HF_indirect_info(f, dxpl_id, hdr, iblock->ents[off].addr, num_indirect_rows, heap_size); - if (reterr < 0) + num_indirect_rows = (H5V_log2_gen(hdr->man_dtable.row_block_size[u]) - first_row_bits) + 1; + for(u = hdr->man_dtable.max_direct_rows; u < iblock->nrows; u++, num_indirect_rows++) { + size_t v; /* Local index variable */ + + for(v = 0; v < hdr->man_dtable.cparam.width; v++, entry++) + if(H5F_addr_defined(iblock->ents[entry].addr)) + if(H5HF_man_iblock_size(f, dxpl_id, hdr, iblock->ents[entry].addr, num_indirect_rows, heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to get fractal heap storage info for indirect block") - } /* end if */ - } /* end for v */ - } /* end for u */ + } /* end for */ } /* end if */ done: - if(H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0) + /* Release the indirect block */ + if(iblock && H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5HF_man_iblock_size() */ + diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index bd3c4ec..5bc1f14 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -600,6 +600,8 @@ H5_DLL herr_t H5HF_man_iblock_entry_addr(H5HF_indirect_t *iblock, unsigned entry H5_DLL herr_t H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t iblock_addr, unsigned iblock_nrows, H5HF_indirect_t *par_iblock, unsigned par_entry); +H5_DLL herr_t H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, + haddr_t iblock_addr, unsigned nrows, hsize_t *heap_size/*out*/); /* Direct block routines */ H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request, @@ -722,8 +724,6 @@ H5_DLL herr_t H5HF_sect_indirect_add(H5HF_hdr_t *hdr, hid_t dxpl_id, /* Internal operator callbacks */ H5_DLL herr_t H5HF_op_read(const void *obj, size_t obj_len, void *op_data); H5_DLL herr_t H5HF_op_write(const void *obj, size_t obj_len, void *op_data); -H5_DLL herr_t H5HF_indirect_info(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, - haddr_t iblock_addr, unsigned nrows, hsize_t *heap_size/*out*/); /* Testing routines */ #ifdef H5HF_TESTING diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h index a8855de..208ab57 100644 --- a/src/H5HFprivate.h +++ b/src/H5HFprivate.h @@ -126,13 +126,10 @@ H5_DLL herr_t H5HF_remove(H5HF_t *fh, hid_t dxpl_id, const void *id); H5_DLL herr_t H5HF_close(H5HF_t *fh, hid_t dxpl_id); H5_DLL herr_t H5HF_delete(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr); -/* Routines to gather storage info for fractal heap */ -H5_DLL herr_t H5HF_fheap_info(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, - hsize_t *heap_size/*out*/, hsize_t *huge_bt_size/*out*/); - - /* Statistics routines */ H5_DLL herr_t H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats); +H5_DLL herr_t H5HF_size(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, + hsize_t *heap_size/*out*/); /* Debugging routines */ #ifdef H5HF_DEBUGGING diff --git a/src/H5HFstat.c b/src/H5HFstat.c index 4846cd0..4971394 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -107,3 +107,82 @@ H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF_stat_info() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_size + * + * Purpose: Retrieve storage info for: + * 1. fractal heap + * 2. btree storage used by huge objects in fractal heap + * 3. free space storage info + * + * Return: non-negative on success, negative on error + * + * Programmer: Vailin Choi + * July 12 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_size(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr, hsize_t *heap_size) +{ + H5HF_hdr_t *hdr = NULL; /* Fractal heap header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5HF_size, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(H5F_addr_defined(fh_addr)); + HDassert(heap_size); + + /* Lock the heap header into memory */ + if(NULL == (hdr = H5AC_protect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load fractal heap header") + + /* Add in values already known */ + *heap_size += hdr->heap_size; /* Heap header */ + *heap_size += hdr->man_alloc_size; /* Direct block storage for "managed" objects */ + *heap_size += hdr->huge_size; /* "huge" object storage */ + + /* Check for indirect blocks for managed objects */ + if(H5F_addr_defined(hdr->man_dtable.table_addr) && hdr->man_dtable.curr_root_rows != 0) + if(H5HF_man_iblock_size(f, dxpl_id, hdr, hdr->man_dtable.table_addr, hdr->man_dtable.curr_root_rows, heap_size) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to get fractal heap storage info for indirect block") + + /* Get B-tree storage for huge objects in fractal heap */ + if(H5F_addr_defined(hdr->huge_bt2_addr)) { + const H5B2_class_t *huge_bt2_class; /* Class for huge v2 B-tree */ + + /* Determine the class of the huge v2 B-tree */ + if(hdr->huge_ids_direct) + if(hdr->filter_len > 0) + huge_bt2_class = H5HF_BT2_FILT_DIR; + else + huge_bt2_class = H5HF_BT2_DIR; + else + if(hdr->filter_len > 0) + huge_bt2_class = H5HF_BT2_FILT_INDIR; + else + huge_bt2_class = H5HF_BT2_INDIR; + + /* Get the B-tree storage for the appropriate class */ + if(H5B2_iterate_size(f, dxpl_id, huge_bt2_class, hdr->huge_bt2_addr, heap_size) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") + } /* end if */ + + /* Get storage for free-space tracking info */ + if(H5F_addr_defined(hdr->fs_addr)) + if(H5FS_size(f, dxpl_id, hdr->fs_addr, heap_size) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info") + +done: + /* Release resources */ + if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_size() */ + diff --git a/src/H5HL.c b/src/H5HL.c index a50512d..c861978 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -63,7 +63,7 @@ static H5HL_t *H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udat static herr_t H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr, H5HL_t *heap, unsigned UNUSED * flags_ptr); static herr_t H5HL_dest(H5F_t *f, H5HL_t *heap); static herr_t H5HL_clear(H5F_t *f, H5HL_t *heap, hbool_t destroy); -static herr_t H5HL_compute_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr); +static herr_t H5HL_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr); /* * H5HL inherits cache-like properties from H5AC @@ -74,7 +74,7 @@ const H5AC_class_t H5AC_LHEAP[1] = {{ (H5AC_flush_func_t)H5HL_flush, (H5AC_dest_func_t)H5HL_dest, (H5AC_clear_func_t)H5HL_clear, - (H5AC_size_func_t)H5HL_compute_size, + (H5AC_size_func_t)H5HL_size, }}; /* Declare a free list to manage the H5HL_free_t struct */ @@ -682,7 +682,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HL_compute_size + * Function: H5HL_size * * Purpose: Compute the size in bytes of the specified instance of * H5HL_t on disk, and return it in *len_ptr. On failure, @@ -697,9 +697,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HL_compute_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr) +H5HL_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_compute_size); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HL_size); /* check arguments */ HDassert(f); @@ -709,7 +709,7 @@ H5HL_compute_size(const H5F_t *f, const H5HL_t *heap, size_t *size_ptr) *size_ptr = H5HL_SIZEOF_HDR(f) + heap->heap_alloc; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5HL_compute_size() */ +} /* H5HL_size() */ /*------------------------------------------------------------------------- @@ -1346,12 +1346,13 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_get_size() */ + /*------------------------------------------------------------------------- * Function: H5HL_heapsize * * Purpose: Compute the size in bytes of the specified instance of - * H5HL_t via H5HL_compute_size() + * H5HL_t via H5HL_size() * * Return: Non-negative on success/Negative on failure * @@ -1364,8 +1365,8 @@ herr_t H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size) { H5HL_t *heap = NULL; /* Heap to query */ - herr_t ret_value = SUCCEED; /* Return value */ size_t local_heap_size = 0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_heapsize, FAIL) @@ -1378,13 +1379,17 @@ H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size) if(NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") - if (H5HL_compute_size(f, heap, &local_heap_size)<0) + /* Get the total size of the local heap */ + if(H5HL_size(f, heap, &local_heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to compute size of local heap") - *heap_size = (hsize_t)local_heap_size; + + /* Accumulate the size of the local heap */ + *heap_size += (hsize_t)local_heap_size; done: if(heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HL_get_size() */ +} /* end H5HL_heapsize() */ + diff --git a/src/H5O.c b/src/H5O.c index b721352..1b5add7 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1824,13 +1824,6 @@ done: * Programmer: Quincey Koziol * November 21 2006 * - * Modifications: - * 12 July 2007 by Vailin Choi - * Modified to retrieve the following information: - * 1. GROUP: storage for btree and heap (1.6 and 1.8) - * 2. DATASET: btree storage for chunked dataset - * 3. ATTRIBUTE: storage for 1.8 btree and fractal heap - * *------------------------------------------------------------------------- */ herr_t @@ -1852,6 +1845,9 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) if(NULL == (oh = H5AC_protect(oloc->file, dxpl_id, H5AC_OHDR, oloc->addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + /* Reset the object info structure */ + HDmemset(oinfo, 0, sizeof(*oinfo)); + /* Retrieve the file's fileno */ if(H5F_get_fileno(oloc->file, &oinfo->fileno) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to read fileno") @@ -1864,12 +1860,11 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") /* Retrieve btree and heap storage info */ - HDmemset(&oinfo->meta_size.obj, 0, sizeof(H5_ih_info_t)); - if (oinfo->type == H5O_TYPE_GROUP) { - if (H5O_group_bh_info(oloc, oh, dxpl_id, &(oinfo->meta_size.obj)/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve 1.8 group btree & heap info") - } else if (oinfo->type == H5O_TYPE_DATASET) { - if (H5O_dset_bh_info(oloc, oh, dxpl_id, &(oinfo->meta_size.obj)/*out*/) < 0) + if(oinfo->type == H5O_TYPE_GROUP) { + if(H5O_group_bh_info(oloc->file, dxpl_id, oh, &(oinfo->meta_size.obj)/*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve group btree & heap info") + } else if(oinfo->type == H5O_TYPE_DATASET) { + if(H5O_dset_bh_info(oloc->file, dxpl_id, oh, &(oinfo->meta_size.obj)/*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve chunked dataset btree info") } @@ -1943,8 +1938,7 @@ H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id) /* Retrieve # of attributes */ oinfo->num_attrs = H5O_attr_count_real(oloc->file, dxpl_id, oh); - HDmemset(&oinfo->meta_size.attr, 0, sizeof(H5_ih_info_t)); - if ((oinfo->num_attrs > 0) && (H5O_attr_bh_info(oloc, oh, dxpl_id, &oinfo->meta_size.attr/*out*/) < 0)) + if((oinfo->num_attrs > 0) && (H5O_attr_bh_info(oloc->file, dxpl_id, oh, &oinfo->meta_size.attr/*out*/) < 0)) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info") /* Iterate over all the chunks, adding any gaps to the free space */ @@ -2140,47 +2134,3 @@ H5O_get_oh_addr(const H5O_t *oh) FUNC_LEAVE_NOAPI(oh->chunk[0].addr) } /* end H5O_get_oh_addr() */ -/*------------------------------------------------------------------------- - * Function: H5O_super_ext_size - * - * Purpose: Collect size of the superblock extension - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Vailin Choi - * July 12, 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_super_ext_size(H5F_t *f, hsize_t *ext_size, hid_t dxpl_id) -{ - H5O_t *oh = NULL; /* Object header */ - H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5O_super_ext_size, FAIL) - - /* Check args */ - HDassert(f); - HDassert(ext_size); - HDassert(H5F_addr_defined(f->shared->extension_addr)); - - /* Get the object header */ - if(NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, f->shared->extension_addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") - - *ext_size = 0; - for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) { - /* Accumulate the size of the header on disk */ - *ext_size += curr_chunk->size; - } - -done: - if(oh && H5AC_unprotect(f, dxpl_id, H5AC_OHDR, f->shared->extension_addr, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5O_super_ext_size() */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index f0bafc9..b328f5b 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1687,6 +1687,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_attr_exists */ + /*------------------------------------------------------------------------- * Function: H5O_attr_bh_info @@ -1701,49 +1702,43 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_attr_bh_info(H5O_loc_t *oloc, H5O_t *oh, hid_t dxpl_id, H5_ih_info_t *bh_info) +H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) { - H5O_ainfo_t ainfo; /* Attribute information for object */ - herr_t ret_value=SUCCEED; /* Return value */ - hsize_t huge_bt_size=0; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_attr_bh_info, FAIL) - HDassert(oloc); + HDassert(f); HDassert(oh); HDassert(bh_info); - /* Check for attribute info stored */ - ainfo.nattrs = 0; - ainfo.fheap_addr = HADDR_UNDEF; - ainfo.corder_bt2_addr = HADDR_UNDEF; - ainfo.name_bt2_addr = HADDR_UNDEF; - if(oh->version > H5O_VERSION_1 && NULL == H5A_get_ainfo(oloc->file, dxpl_id, oh, &ainfo)) - /* Clear error stack from not finding attribute info */ - H5E_clear_stack(NULL); - + /* Attributes are only stored in fractal heap & indexed w/v2 B-tree in later versions */ if(oh->version > H5O_VERSION_1) { - if (H5F_addr_defined(ainfo.corder_bt2_addr)) { - if (H5B2_info_iterate(oloc->file, dxpl_id, H5A_BT2_CORDER, - ainfo.corder_bt2_addr, &(bh_info->index_size)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } - - if (H5F_addr_defined(ainfo.name_bt2_addr)) { - if (H5B2_info_iterate(oloc->file, dxpl_id, H5A_BT2_NAME, - ainfo.name_bt2_addr, &(bh_info->index_size)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } - - huge_bt_size = 0; - if (H5F_addr_defined(ainfo.fheap_addr)) { - HDassert(H5O_msg_count_real(oh, H5O_MSG_ATTR) == 0); - if (H5HF_fheap_info(oloc->file, dxpl_id, ainfo.fheap_addr, &(bh_info->heap_size), &huge_bt_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - bh_info->index_size += huge_bt_size; - } - } + H5O_ainfo_t ainfo; /* Attribute information for object */ + + /* Check for attribute info stored */ + if(NULL == H5A_get_ainfo(f, dxpl_id, oh, &ainfo)) + /* Clear error stack from not finding attribute info */ + H5E_clear_stack(NULL); + else { + /* Get storage size of creation order index, if it's used */ + if(H5F_addr_defined(ainfo.corder_bt2_addr)) + if(H5B2_iterate_size(f, dxpl_id, H5A_BT2_CORDER, ainfo.corder_bt2_addr, &(bh_info->index_size)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") + + /* Get storage size of name index, if it's used */ + if(H5F_addr_defined(ainfo.name_bt2_addr)) + if(H5B2_iterate_size(f, dxpl_id, H5A_BT2_NAME, ainfo.name_bt2_addr, &(bh_info->index_size)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") + + /* Get storage size of fractal heap, if it's used */ + if(H5F_addr_defined(ainfo.fheap_addr)) + if(H5HF_size(f, dxpl_id, ainfo.fheap_addr, &(bh_info->heap_size)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") + } /* end else */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O_attr_bh_info() */ + diff --git a/src/H5Opkg.h b/src/H5Opkg.h index afde15a..ce60ce4 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -479,13 +479,13 @@ H5_DLL void *H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src, H5_DLL herr_t H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, const H5O_mesg_operator_t *op, void *op_data, hid_t dxpl_id); -/* collect storage info for btree and heap */ -H5_DLL herr_t H5O_group_bh_info(H5O_loc_t *oloc, H5O_t *oh, hid_t dxpl_id, H5_ih_info_t *bh_info); -H5_DLL herr_t H5O_dset_bh_info(H5O_loc_t *oloc, H5O_t *oh, hid_t dxpl_id, H5_ih_info_t *bh_info); -H5_DLL herr_t H5O_attr_bh_info(H5O_loc_t *oloc, H5O_t *oh, hid_t dxpl_id, H5_ih_info_t *bh_info); - - - +/* Collect storage info for btree and heap */ +H5_DLL herr_t H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + H5_ih_info_t *bh_info); +H5_DLL herr_t H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + H5_ih_info_t *bh_info); +H5_DLL herr_t H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + H5_ih_info_t *bh_info); /* Object header allocation routines */ H5_DLL herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 584d9d5..2376113 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -532,9 +532,6 @@ H5_DLL herr_t H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, unsigned m #endif /* H5O_ENABLE_BOGUS */ H5_DLL herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL herr_t H5O_get_info(H5O_loc_t *oloc, H5O_info_t *oinfo, hid_t dxpl_id); - -H5_DLL herr_t H5O_super_ext_size(H5F_t *f, hsize_t *ext_size, hid_t dxpl_id); - H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id); H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, struct H5P_genplist_t *oc_plist); H5_DLL hid_t H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id); @@ -621,6 +618,5 @@ H5_DLL herr_t H5O_set_shared(H5O_shared_t *dst, const H5O_shared_t *src); /* Attribute operators */ H5_DLL hsize_t H5O_attr_count_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh); - #endif /* _H5Oprivate_H */ diff --git a/src/H5Opublic.h b/src/H5Opublic.h index c5f1b21..b10a4e4 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -120,11 +120,10 @@ typedef struct H5O_info_t { uint64_t shared; /* Flags to indicate message type is shared in header */ } mesg; } hdr; - /* btree and heap storage info for obj & attributes */ - /* (B-tree & heap for groups, B-tree for chunked dataset, 1.8 B-tree & heap for attributes) */ + /* Extra metadata storage for obj & attributes */ struct { - H5_ih_info_t obj; - H5_ih_info_t attr; + H5_ih_info_t obj; /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ + H5_ih_info_t attr; /* v2 B-tree & heap for attributes */ } meta_size; } H5O_info_t; diff --git a/src/H5Oshared.h b/src/H5Oshared.h index 539577f..582d29b 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -373,8 +373,8 @@ done: *------------------------------------------------------------------------- */ static H5_inline herr_t -H5O_SHARED_POST_COPY_FILE(H5O_loc_t *oloc_src, void *mesg_src, H5O_loc_t *oloc_dst, - void *mesg_dst, hid_t dxpl_id, H5O_copy_t *cpy_info) +H5O_SHARED_POST_COPY_FILE(const H5O_loc_t *oloc_src, const void *mesg_src, + H5O_loc_t *oloc_dst, void *mesg_dst, hid_t dxpl_id, H5O_copy_t *cpy_info) { const H5O_shared_t *shared_dst = (const H5O_shared_t *)mesg_dst; /* Alias to shared info in native source */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5SM.c b/src/H5SM.c index 1ca4652..1e3ced3 100755 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -2474,8 +2474,9 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_list_debug() */ + /*------------------------------------------------------------------------- - * Function: H5SM_ih_info + * Function: H5SM_ih_size * * Purpose: Loop through the master SOHM table (if there is one) to: * 1. collect storage used for header @@ -2491,15 +2492,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5SM_ih_info(H5F_t *f, H5F_info_t *finfo, hid_t dxpl_id) +H5SM_ih_size(H5F_t *f, hid_t dxpl_id, H5F_info_t *finfo) { - H5SM_master_table_t *table=NULL; /* SOHM master table */ - herr_t ret_value=SUCCEED; /* Return value */ - unsigned x; - hsize_t huge_bt_size=0; - + H5SM_master_table_t *table = NULL; /* SOHM master table */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5SM_ih_info, FAIL) + FUNC_ENTER_NOAPI(H5SM_ih_size, FAIL) /* Sanity check */ HDassert(f); @@ -2510,32 +2509,32 @@ H5SM_ih_info(H5F_t *f, H5F_info_t *finfo, hid_t dxpl_id) if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") + /* Get SOHM header size */ finfo->sohm.hdr_size = (hsize_t) H5SM_TABLE_SIZE(f) + (hsize_t)(table->num_indexes * H5SM_INDEX_HEADER_SIZE(f)); - for(x = 0; x < table->num_indexes; x++) { - if (table->indexes[x].index_type==H5SM_BTREE) { - if (H5F_addr_defined(table->indexes[x].index_addr)) { - if (H5B2_info_iterate(f, dxpl_id, H5SM_INDEX, - table->indexes[x].index_addr, &(finfo->sohm.msgs_info.index_size)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") - } - } - if (table->indexes[x].index_type==H5SM_LIST) - finfo->sohm.msgs_info.index_size += H5SM_LIST_SIZE(f, table->indexes[x].list_max); - - huge_bt_size = 0; - if (H5F_addr_defined(table->indexes[x].heap_addr)) { - if (H5HF_fheap_info(f, dxpl_id, table->indexes[x].heap_addr, &(finfo->sohm.msgs_info.heap_size), &huge_bt_size) < 0) + /* Loop over all the indices for shared messages */ + for(u = 0; u < table->num_indexes; u++) { + /* Get index storage size (for either B-tree or list) */ + if(table->indexes[u].index_type == H5SM_BTREE) { + if(H5F_addr_defined(table->indexes[u].index_addr)) + if(H5B2_iterate_size(f, dxpl_id, H5SM_INDEX, table->indexes[u].index_addr, &(finfo->sohm.msgs_info.index_size)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree storage info") + } /* end if */ + else if(table->indexes[u].index_type == H5SM_LIST) + finfo->sohm.msgs_info.index_size += H5SM_LIST_SIZE(f, table->indexes[u].list_max); + + /* Get heap storage size */ + if(H5F_addr_defined(table->indexes[u].heap_addr)) + if(H5HF_size(f, dxpl_id, table->indexes[u].heap_addr, &(finfo->sohm.msgs_info.heap_size)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve fractal heap storage info") - } - finfo->sohm.msgs_info.index_size += huge_bt_size; } /* end for */ +done: /* Release resources */ if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, f->shared->sohm_addr, table, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "unable to close SOHM master table") -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SM_ih_info() */ +} /* end H5SM_ih_size() */ + diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h index 763c117..1465357 100755 --- a/src/H5SMprivate.h +++ b/src/H5SMprivate.h @@ -56,7 +56,7 @@ H5_DLL herr_t H5SM_reconstitute(H5O_shared_t *sh_mesg, H5F_t *f, unsigned msg_type_id, H5O_fheap_id_t heap_id); H5_DLL herr_t H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id, const H5O_shared_t *sh_mesg, hsize_t *ref_count); -H5_DLL herr_t H5SM_ih_info(H5F_t *f, H5F_info_t *bh_info, hid_t dxpl_id); +H5_DLL herr_t H5SM_ih_size(H5F_t *f, hid_t dxpl_id, H5F_info_t *bh_info); /* Debugging routines */ diff --git a/tools/misc/h5stat.c b/tools/misc/h5stat.c index d10e2d1..8f29519 100644 --- a/tools/misc/h5stat.c +++ b/tools/misc/h5stat.c @@ -274,33 +274,28 @@ ceil_log10(unsigned long x) * Programmer: Robb Matzke * Thursday, January 21, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ static void -sym_insert(H5G_stat_t *sb, const char *name) +sym_insert(H5O_info_t *oi, const char *name) { - haddr_t objno; /* Compact form of object's location */ - int n; - /* Don't add it if the link count is 1 because such an object can only * have one name. */ - if (sb->nlink<2) return; + if(oi->rc > 1) { + int n; - /* Extend the table */ - if (idtab_g.nobjs>=idtab_g.nalloc) { - idtab_g.nalloc = MAX(256, 2*idtab_g.nalloc); - idtab_g.obj = realloc(idtab_g.obj, - idtab_g.nalloc*sizeof(idtab_g.obj[0])); - } + /* Extend the table */ + if(idtab_g.nobjs >= idtab_g.nalloc) { + idtab_g.nalloc = MAX(256, 2 * idtab_g.nalloc); + idtab_g.obj = realloc(idtab_g.obj, idtab_g.nalloc * sizeof(idtab_g.obj[0])); + } /* end if */ - /* Insert the entry */ - n = idtab_g.nobjs++; - objno = (haddr_t)sb->objno[0] | ((haddr_t)sb->objno[1] << (8 * sizeof(long))); - idtab_g.obj[n].id = objno; - idtab_g.obj[n].name = strdup(name); -} + /* Insert the entry */ + n = idtab_g.nobjs++; + idtab_g.obj[n].id = oi->addr; + idtab_g.obj[n].name = strdup(name); + } /* end if */ +} /* end sym_insert() */ /*------------------------------------------------------------------------- @@ -320,20 +315,20 @@ sym_insert(H5G_stat_t *sb, const char *name) *------------------------------------------------------------------------- */ static char * -sym_lookup(H5G_stat_t *sb) +sym_lookup(H5O_info_t *oi) { - haddr_t objno; /* Compact form of object's location */ int n; - if (sb->nlink<2) - return NULL; /*only one name possible*/ - objno = (haddr_t)sb->objno[0] | ((haddr_t)sb->objno[1] << (8 * sizeof(long))); - for (n=0; nrc < 2) + return NULL; + + for(n = 0; n < idtab_g.nobjs; n++) + if(idtab_g.obj[n].id == oi->addr) return idtab_g.obj[n].name; - } + return NULL; -} +} /* end sym_lookup() */ /*------------------------------------------------------------------------- @@ -384,6 +379,57 @@ fix_name(const char *path, const char *base) s[len] = '\0'; return s; } + + +/*------------------------------------------------------------------------- + * Function: attribute_stats + * + * Purpose: Gather statistics about attributes on an object + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Quincey Koziol + * Tuesday, July 17, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +attribute_stats(iter_t *iter, const H5O_info_t *oi) +{ + unsigned bin; /* "bin" the number of objects falls in */ + + /* Update dataset & attribute metadata info */ + iter->attrs_btree_storage_size += oi->meta_size.attr.index_size; + iter->attrs_heap_storage_size += oi->meta_size.attr.heap_size; + + /* Update small # of attribute count & limits */ + if(oi->num_attrs < SIZE_SMALL_ATTRS) + (iter->num_small_attrs[(size_t)oi->num_attrs])++; + if(oi->num_attrs > iter->max_attrs) + iter->max_attrs = oi->num_attrs; + + /* Add attribute count to proper bin */ + bin = ceil_log10((unsigned long)oi->num_attrs); + if((bin + 1) > iter->attr_nbins) { + iter->attr_bins = realloc(iter->attr_bins, (bin + 1) * sizeof(unsigned long)); + assert(iter->attr_bins); + + /* Initialize counts for intermediate bins */ + while(iter->attr_nbins < bin) + iter->attr_bins[iter->attr_nbins++] = 0; + iter->attr_nbins++; + + /* Initialize count for new bin */ + iter->attr_bins[bin] = 1; + } /* end if */ + else + (iter->attr_bins[bin])++; + + return 0; +} /* end attribute_stats() */ + /*------------------------------------------------------------------------- * Function: group_stats @@ -412,19 +458,14 @@ fix_name(const char *path, const char *base) *------------------------------------------------------------------------- */ static herr_t -group_stats (hid_t group, const char *name, const char * fullname, H5G_stat_t * _sb, H5G_iterate_t _walk, iter_t *_iter) +group_stats(hid_t group, const char *name, const char *fullname, + const H5O_info_t *oi, H5G_iterate_t walk, iter_t *iter) { hid_t gid; /* Group ID */ const char *last_container; hsize_t num_objs; unsigned bin; /* "bin" the number of objects falls in */ - iter_t *iter = (iter_t*)_iter; - H5G_stat_t *sb = _sb; - H5G_iterate_t walk = _walk; herr_t ret; - hsize_t num_attrs=0; - unsigned attr_bin; - H5O_info_t oinfo; /* Gather statistics about this type of object */ iter->uniq_groups++; @@ -432,23 +473,26 @@ group_stats (hid_t group, const char *name, const char * fullname, H5G_stat_t * iter->max_depth = iter->curr_depth; /* Get object header information */ - iter->group_ohdr_info.total_size += sb->ohdr.size; - iter->group_ohdr_info.free_size += sb->ohdr.free; + iter->group_ohdr_info.total_size += oi->hdr.space.total; + iter->group_ohdr_info.free_size += oi->hdr.space.free; gid = H5Gopen(group, name); assert(gid > 0); - H5Gget_num_objs(gid, &num_objs); + /* Get number of links in this group */ + ret = H5Gget_num_objs(gid, &num_objs); + assert(ret >= 0); + /* Update link stats */ if(num_objs < SIZE_SMALL_GROUPS) (iter->num_small_groups[(size_t)num_objs])++; if(num_objs > iter->max_fanout) iter->max_fanout = num_objs; /* Add group count to proper bin */ - bin = ceil_log10((unsigned long)num_objs); - if((bin + 1) > iter->group_nbins) { - /* Allocate more storage for info about dataset's datatype */ + bin = ceil_log10((unsigned long)num_objs); + if((bin + 1) > iter->group_nbins) { + /* Allocate more storage for info about dataset's datatype */ iter->group_bins = realloc(iter->group_bins, (bin + 1) * sizeof(unsigned long)); assert(iter->group_bins); @@ -459,64 +503,42 @@ group_stats (hid_t group, const char *name, const char * fullname, H5G_stat_t * /* Initialize count for new bin */ iter->group_bins[bin] = 1; - } /* end if */ - else { - (iter->group_bins[bin])++; - } /* end else */ - - ret = H5Oget_info(gid, ".", &oinfo, H5P_DEFAULT); - if (ret < 0) { - warn_msg(progname, "Unable to retrieve object info for \"%s\"\n", name); - } else { - num_attrs = oinfo.num_attrs; - iter->groups_btree_storage_size += oinfo.meta_size.obj.index_size; - iter->groups_heap_storage_size += oinfo.meta_size.obj.heap_size; - iter->attrs_btree_storage_size += oinfo.meta_size.attr.index_size; - iter->attrs_heap_storage_size += oinfo.meta_size.attr.heap_size; - } - - if(num_attrs < SIZE_SMALL_ATTRS) - (iter->num_small_attrs[(size_t)num_attrs])++; - if(num_attrs > iter->max_attrs) - iter->max_attrs = num_attrs; - - /* Add attribute count to proper bin */ - attr_bin = ceil_log10((unsigned long)num_attrs); - if((attr_bin + 1) > iter->attr_nbins) { - iter->attr_bins = realloc(iter->attr_bins, (attr_bin + 1) * sizeof(unsigned long)); - assert(iter->attr_bins); + } /* end if */ + else + (iter->group_bins[bin])++; - /* Initialize counts for intermediate bins */ - while(iter->attr_nbins < attr_bin) - iter->attr_bins[iter->attr_nbins++] = 0; - iter->attr_nbins++; + /* Update group metadata info */ + iter->groups_btree_storage_size += oi->meta_size.obj.index_size; + iter->groups_heap_storage_size += oi->meta_size.obj.heap_size; - /* Initialize count for new bin */ - iter->attr_bins[attr_bin] = 1; - } /* end if */ - else { - (iter->attr_bins[attr_bin])++; - } /* end else */ + /* Update attribute metadata info */ + ret = attribute_stats(iter, oi); + assert(ret >= 0); + /* Close current group */ ret = H5Gclose(gid); assert(ret >= 0); + /* Update current container info */ last_container = iter->container; iter->container = fullname; iter->curr_depth++; + /* Recursively descend into current group's objects */ H5Giterate(group, name, NULL, walk, iter); + /* Revert current container info */ iter->container = last_container; iter->curr_depth--; return 0; -} +} /* end group_stats() */ + /*------------------------------------------------------------------------- * Function: dataset_stats * - * Purpose: Gather statistics about the datset + * Purpose: Gather statistics about the dataset * * Return: Success: 0 * @@ -540,12 +562,9 @@ group_stats (hid_t group, const char *name, const char * fullname, H5G_stat_t * *------------------------------------------------------------------------- */ static herr_t -dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) +dataset_stats(hid_t group, const char *name, const H5O_info_t *oi, iter_t *iter) { unsigned bin; /* "bin" the number of objects falls in */ - iter_t *iter = (iter_t*)_iter; - H5G_stat_t *sb = _sb; - herr_t ret; hid_t did; /* Dataset ID */ hid_t sid; /* Dataspace ID */ hid_t tid; /* Datatype ID */ @@ -560,53 +579,24 @@ dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) int num_ext; /* Number of external files for a dataset */ int nfltr; /* Number of filters for a dataset */ H5Z_filter_t fltr; /* Filter identifier */ - - hsize_t num_attrs = 0; - unsigned attr_bin; - H5O_info_t oinfo; + herr_t ret; /* Gather statistics about this type of object */ iter->uniq_dsets++; /* Get object header information */ - iter->dset_ohdr_info.total_size += sb->ohdr.size; - iter->dset_ohdr_info.free_size += sb->ohdr.free; + iter->dset_ohdr_info.total_size += oi->hdr.space.total; + iter->dset_ohdr_info.free_size += oi->hdr.space.free; did = H5Dopen(group, name); assert(did > 0); - ret = H5Oget_info(did, ".", &oinfo, H5P_DEFAULT); - if (ret < 0) { - warn_msg(progname, "Unable to retrieve object info for \"%s\"\n", name); - } else { - num_attrs = oinfo.num_attrs; - iter->datasets_btree_storage_size += oinfo.meta_size.obj.index_size; - iter->attrs_btree_storage_size += oinfo.meta_size.attr.index_size; - iter->attrs_heap_storage_size += oinfo.meta_size.attr.heap_size; - } - - if(num_attrs < SIZE_SMALL_ATTRS) - (iter->num_small_attrs[(size_t)num_attrs])++; - if(num_attrs > iter->max_attrs) - iter->max_attrs = num_attrs; - - /* Add attribute count to proper bin */ - attr_bin = ceil_log10((unsigned long)num_attrs); - if((attr_bin + 1) > iter->attr_nbins) { - iter->attr_bins = realloc(iter->attr_bins, (attr_bin + 1) * sizeof(unsigned long)); - assert(iter->attr_bins); - - /* Initialize counts for intermediate bins */ - while(iter->attr_nbins < attr_bin) - iter->attr_bins[iter->attr_nbins++] = 0; - iter->attr_nbins++; + /* Update dataset metadata info */ + iter->datasets_btree_storage_size += oi->meta_size.obj.index_size; - /* Initialize count for new bin */ - iter->attr_bins[attr_bin] = 1; - } /* end if */ - else { - (iter->attr_bins[attr_bin])++; - } /* end else */ + /* Update attribute metadata info */ + ret = attribute_stats(iter, oi); + assert(ret >= 0); /* Get storage info */ storage = H5Dget_storage_size(did); @@ -628,7 +618,7 @@ dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) /* Only gather dim size statistics on 1-D datasets */ if(ndims == 1) { - iter->max_dset_dims = dims[0]; + iter->max_dset_dims = dims[0]; if(dims[0] < SIZE_SMALL_DSETS) (iter->small_dset_dims[(size_t)dims[0]])++; @@ -647,9 +637,8 @@ dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) /* Initialize count for this bin */ iter->dset_dim_bins[bin] = 1; } /* end if */ - else { + else (iter->dset_dim_bins[bin])++; - } /* end else */ } /* end if */ ret = H5Sclose(sid); @@ -665,9 +654,8 @@ dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) type_found = TRUE; break; } /* end for */ - if(type_found) { + if(type_found) (iter->dset_type_info[u].count)++; - } /* end if */ else { unsigned curr_ntype = iter->dset_ntypes; @@ -686,48 +674,47 @@ dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) /* Set index for later */ u = curr_ntype; - } /* end else */ + } /* end else */ - /* Check if the datatype is a named datatype */ - if(H5Tcommitted(tid) > 0) - (iter->dset_type_info[u].named)++; + /* Check if the datatype is a named datatype */ + if(H5Tcommitted(tid) > 0) + (iter->dset_type_info[u].named)++; - ret = H5Tclose(tid); - assert(ret >= 0); + ret = H5Tclose(tid); + assert(ret >= 0); - /* Gather layout statistics */ - dcpl = H5Dget_create_plist(did); - assert(dcpl > 0); + /* Gather layout statistics */ + dcpl = H5Dget_create_plist(did); + assert(dcpl > 0); - lout = H5Pget_layout(dcpl); - assert(lout >= 0); + lout = H5Pget_layout(dcpl); + assert(lout >= 0); - /* Track the layout type for dataset */ - (iter->dset_layouts[lout])++; + /* Track the layout type for dataset */ + (iter->dset_layouts[lout])++; - num_ext = H5Pget_external_count(dcpl); - assert (num_ext >= 0); + num_ext = H5Pget_external_count(dcpl); + assert (num_ext >= 0); - if(num_ext) iter->nexternal = iter->nexternal + num_ext; + if(num_ext) + iter->nexternal = iter->nexternal + num_ext; /* Track different filters */ - - if ((nfltr=H5Pget_nfilters(dcpl)) >= 0) { - - if (nfltr == 0) iter->dset_comptype[0]++; - for (u=0; u < (unsigned) nfltr; u++) { + if((nfltr = H5Pget_nfilters(dcpl)) >= 0) { + if(nfltr == 0) + iter->dset_comptype[0]++; + for(u = 0; u < (unsigned)nfltr; u++) { #ifdef H5_WANT_H5_V1_6_COMPAT - fltr = H5Pget_filter(dcpl, u, 0, 0, 0, 0, 0); + fltr = H5Pget_filter(dcpl, u, 0, 0, 0, 0, 0); #else /* H5_WANT_H5_V1_6_COMPAT */ - fltr = H5Pget_filter(dcpl, u, 0, 0, 0, 0, 0, NULL); + fltr = H5Pget_filter(dcpl, u, 0, 0, 0, 0, 0, NULL); #endif /* H5_WANT_H5_V1_6_COMPAT */ - if (fltr < (H5_NFILTERS_IMPL-1)) - iter->dset_comptype[fltr]++; - else - iter->dset_comptype[H5_NFILTERS_IMPL-1]++; /*other filters*/ - } - - } /*endif nfltr */ + if(fltr < (H5_NFILTERS_IMPL - 1)) + iter->dset_comptype[fltr]++; + else + iter->dset_comptype[H5_NFILTERS_IMPL - 1]++; /*other filters*/ + } /* end for */ + } /* endif nfltr */ ret = H5Pclose(dcpl); assert(ret >= 0); @@ -736,7 +723,7 @@ dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) assert(ret >= 0); return 0; -} +} /* end dataset_stats() */ /*------------------------------------------------------------------------- @@ -755,38 +742,39 @@ dataset_stats (hid_t group, const char *name, H5G_stat_t * _sb, iter_t *_iter) *------------------------------------------------------------------------- */ static herr_t -walk (hid_t group, const char *name, void *_iter) +walk(hid_t group, const char *name, void *_iter) { + iter_t *iter = (iter_t *)_iter; + H5O_info_t oi; char *fullname = NULL; char *s; - H5G_stat_t sb; - iter_t *iter = (iter_t*)_iter; herr_t ret; /* Generic return value */ /* Get the full object name */ fullname = fix_name(iter->container, name); + /* Get object information */ - ret = H5Gget_objinfo(group, name, FALSE, &sb); + ret = H5Oget_info(group, name, &oi, H5P_DEFAULT); assert(ret >= 0); /* If the object has already been printed then just show the object ID * and return. */ - if ((s=sym_lookup(&sb))) { + if((s = sym_lookup(&oi))) { printf("%s same as %s\n", name, s); } else { - sym_insert(&sb, fullname); + sym_insert(&oi, fullname); /* Gather some statistics about the object */ - if(sb.nlink > iter->max_links) - iter->max_links = sb.nlink; + if(oi.rc > iter->max_links) + iter->max_links = oi.rc; - switch(sb.type) { + switch(oi.type) { case H5G_GROUP: - group_stats(group, name, fullname, &sb, walk, iter); + group_stats(group, name, fullname, &oi, walk, iter); break; case H5G_DATASET: - dataset_stats(group, name, &sb, iter); + dataset_stats(group, name, &oi, iter); break; case H5G_TYPE: @@ -806,7 +794,7 @@ walk (hid_t group, const char *name, void *_iter) } /* end switch */ } - if (fullname) + if(fullname) free(fullname); return 0; @@ -840,7 +828,6 @@ parse_command_line(int argc, const char *argv[]) /* Allocate space to hold the command line info */ hand = calloc((size_t)argc, sizeof(struct handler_t)); - /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { @@ -920,87 +907,20 @@ parse_command_line(int argc, const char *argv[]) * Programmer: Elena Pourmal * Saturday, August 12, 2006 * - * Modifications: - * Vailin Choi 12 July 2007 - * Initialized storage info for: - * 1. btree/heap storage for groups and attributes - * 2. btree storage for chunked dataset - * 3. hdr/btree/list/heap storage for SOHM table - * 4. superblock extension size - * *------------------------------------------------------------------------- */ static herr_t -iter_init(iter_t * _iter) +iter_init(iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - herr_t ret =0; /* Generic return value */ - - unsigned u; /* Local index variable */ - - /* Initilaize file' metadata information */ - iter->container = "/"; - iter->uniq_groups = 0; - iter->uniq_dsets = 0; - iter->uniq_types = 0; - iter->uniq_links = 0; - iter->uniq_others = 0; - iter->curr_depth = 0; - iter->max_depth = 0; - iter->max_links = 0; - iter->max_fanout = 0; - for(u = 0; u < SIZE_SMALL_GROUPS; u++) - iter->num_small_groups[u] = 0; - - /* Initilaize groups' metadata information */ - iter->group_nbins = 0; - iter->group_bins = NULL; - iter->group_ohdr_info.total_size = 0; - iter->group_ohdr_info.free_size = 0; - - /* initialize attributes' information for groups and datasets */ - iter->max_attrs = 0; - for(u = 0; u < SIZE_SMALL_ATTRS; u++) - iter->num_small_attrs[u] = 0; - iter->attr_nbins = 0; - iter->attr_bins = NULL; - - /* Initilaize datasets' metadata information */ - iter->max_dset_rank = 0; - for(u = 0; u < H5S_MAX_RANK; u++) - iter->dset_rank_count[u] = 0; - iter->max_dset_dims = 0; - for(u = 0; u < SIZE_SMALL_DSETS; u++) - iter->small_dset_dims[u] = 0; - for(u = 0; u < H5D_NLAYOUTS; u++) - iter->dset_layouts[u] = 0; - for(u = 0; u < H5_NFILTERS_IMPL; u++) - iter->dset_comptype[u] = 0; - - iter->dset_ntypes = 0; - iter->dset_type_info = NULL; - iter->dset_dim_nbins = 0; - iter->dset_dim_bins = NULL; - iter->dset_ohdr_info.total_size = 0; - iter->dset_ohdr_info.free_size = 0; - iter->dset_storage_size = 0; - - /* Initialize storage info */ - iter->groups_btree_storage_size = 0; - iter->groups_heap_storage_size = 0; - iter->attrs_btree_storage_size = 0; - iter->attrs_heap_storage_size = 0; - iter->SM_hdr_storage_size = 0; - iter->SM_index_storage_size = 0; - iter->SM_heap_storage_size = 0; - iter->super_ext_size = 0; - iter->datasets_btree_storage_size = 0; - - iter->nexternal = 0; - iter->local = 0; - - return ret; + /* Clear everything to zeros */ + memset(iter, 0, sizeof(*iter)); + + /* Initialize non-zero information */ + iter->container = "/"; + + return 0; } + /*------------------------------------------------------------------------- * Function: print_file_info @@ -1019,22 +939,19 @@ iter_init(iter_t * _iter) *------------------------------------------------------------------------- */ static herr_t -print_file_info(iter_t * _iter) +print_file_info(const iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - herr_t ret =0; /* Generic return value */ - - printf("File information\n"); - printf("\t# of unique groups: %lu\n", iter->uniq_groups); - printf("\t# of unique datasets: %lu\n", iter->uniq_dsets); - printf("\t# of unique named dataypes: %lu\n", iter->uniq_types); - printf("\t# of unique links: %lu\n", iter->uniq_links); - printf("\t# of unique other: %lu\n", iter->uniq_others); - printf("\tMax. # of links to object: %lu\n", iter->max_links); - printf("\tMax. depth of hierarchy: %lu\n", iter->max_depth); - HDfprintf(stdout, "\tMax. # of objects in group: %Hu\n", iter->max_fanout); - - return ret; + printf("File information\n"); + printf("\t# of unique groups: %lu\n", iter->uniq_groups); + printf("\t# of unique datasets: %lu\n", iter->uniq_dsets); + printf("\t# of unique named dataypes: %lu\n", iter->uniq_types); + printf("\t# of unique links: %lu\n", iter->uniq_links); + printf("\t# of unique other: %lu\n", iter->uniq_others); + printf("\tMax. # of links to object: %lu\n", iter->max_links); + printf("\tMax. depth of hierarchy: %lu\n", iter->max_depth); + HDfprintf(stdout, "\tMax. # of objects in group: %Hu\n", iter->max_fanout); + + return 0; } @@ -1061,37 +978,36 @@ print_file_info(iter_t * _iter) *------------------------------------------------------------------------- */ static herr_t -print_file_metadata(iter_t * _iter) +print_file_metadata(const iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - herr_t ret =0; /* Generic return value */ - - printf("Object header size: (total/unused)\n"); - HDfprintf(stdout, "\tGroups: %Hu/%Hu\n", iter->group_ohdr_info.total_size, - iter->group_ohdr_info.free_size); - HDfprintf(stdout, "\tDatasets: %Hu/%Hu\n", iter->dset_ohdr_info.total_size, - iter->dset_ohdr_info.free_size); - - printf("Storage information:\n"); - HDfprintf(stdout, "\tGroups:\n"); - HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->groups_btree_storage_size); - HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->groups_heap_storage_size); - - HDfprintf(stdout, "\tAttributes:\n"); - HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->attrs_btree_storage_size); - HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->attrs_heap_storage_size); - - HDfprintf(stdout, "\tChunked datasets:\n"); - HDfprintf(stdout, "\t\tB-tree: %Hu\n", iter->datasets_btree_storage_size); - - HDfprintf(stdout, "\tShared Messages:\n"); - HDfprintf(stdout, "\t\tHeader: %Hu\n", iter->SM_hdr_storage_size); - HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->SM_index_storage_size); - HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->SM_heap_storage_size); - - HDfprintf(stdout, "\tSuperblock extension: %Hu\n", iter->super_ext_size); - return ret; + printf("Object header size: (total/unused)\n"); + HDfprintf(stdout, "\tGroups: %Hu/%Hu\n", iter->group_ohdr_info.total_size, + iter->group_ohdr_info.free_size); + HDfprintf(stdout, "\tDatasets: %Hu/%Hu\n", iter->dset_ohdr_info.total_size, + iter->dset_ohdr_info.free_size); + + printf("Storage information:\n"); + HDfprintf(stdout, "\tGroups:\n"); + HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->groups_btree_storage_size); + HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->groups_heap_storage_size); + + HDfprintf(stdout, "\tAttributes:\n"); + HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->attrs_btree_storage_size); + HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->attrs_heap_storage_size); + + HDfprintf(stdout, "\tChunked datasets:\n"); + HDfprintf(stdout, "\t\tB-tree: %Hu\n", iter->datasets_btree_storage_size); + + HDfprintf(stdout, "\tShared Messages:\n"); + HDfprintf(stdout, "\t\tHeader: %Hu\n", iter->SM_hdr_storage_size); + HDfprintf(stdout, "\t\tB-tree/List: %Hu\n", iter->SM_index_storage_size); + HDfprintf(stdout, "\t\tHeap: %Hu\n", iter->SM_heap_storage_size); + + HDfprintf(stdout, "\tSuperblock extension: %Hu\n", iter->super_ext_size); + + return 0; } + /*------------------------------------------------------------------------- * Function: print_group_info @@ -1110,43 +1026,42 @@ print_file_metadata(iter_t * _iter) *------------------------------------------------------------------------- */ static herr_t -print_group_info(iter_t * _iter) +print_group_info(const iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - herr_t ret =0; /* Generic return value */ - unsigned u; /* Local index variable */ - unsigned long power; /* Temporary "power" for bins */ - unsigned long total; /* Total count for various statistics */ - - printf("Small groups:\n"); - total = 0; - for(u = 0; u < SIZE_SMALL_GROUPS; u++) { - if(iter->num_small_groups[u] > 0) { - printf("\t# of groups of size %u: %lu\n", u, iter->num_small_groups[u]); - total += iter->num_small_groups[u]; - } /* end if */ - } /* end for */ - printf("\tTotal # of small groups: %lu\n", total); - - printf("Group bins:\n"); - total = 0; - if(iter->group_bins[0] > 0) { - printf("\t# of groups of size 0: %lu\n", iter->group_bins[0]); - total = iter->group_bins[0]; + unsigned long power; /* Temporary "power" for bins */ + unsigned long total; /* Total count for various statistics */ + unsigned u; /* Local index variable */ + + printf("Small groups:\n"); + total = 0; + for(u = 0; u < SIZE_SMALL_GROUPS; u++) { + if(iter->num_small_groups[u] > 0) { + printf("\t# of groups of size %u: %lu\n", u, iter->num_small_groups[u]); + total += iter->num_small_groups[u]; } /* end if */ - power = 1; - for(u = 1; u < iter->group_nbins; u++) { - if(iter->group_bins[u] > 0) { - printf("\t# of groups of size %lu - %lu: %lu\n", power, (power * 10) - 1, - iter->group_bins[u]); - total += iter->group_bins[u]; - } /* end if */ - power *= 10; - } /* end for */ - printf("\tTotal # of groups: %lu\n", total); + } /* end for */ + printf("\tTotal # of small groups: %lu\n", total); + + printf("Group bins:\n"); + total = 0; + if(iter->group_bins[0] > 0) { + printf("\t# of groups of size 0: %lu\n", iter->group_bins[0]); + total = iter->group_bins[0]; + } /* end if */ + power = 1; + for(u = 1; u < iter->group_nbins; u++) { + if(iter->group_bins[u] > 0) { + printf("\t# of groups of size %lu - %lu: %lu\n", power, (power * 10) - 1, + iter->group_bins[u]); + total += iter->group_bins[u]; + } /* end if */ + power *= 10; + } /* end for */ + printf("\tTotal # of groups: %lu\n", total); - return ret; + return 0; } + /*------------------------------------------------------------------------- * Function: print_attr_info @@ -1165,39 +1080,39 @@ print_group_info(iter_t * _iter) *------------------------------------------------------------------------- */ static herr_t -print_attr_info(iter_t * _iter) +print_attr_info(const iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - herr_t ret =0; /* Generic return value */ - unsigned u; /* Local index variable */ - unsigned long power; /* Temporary "power" for bins */ - unsigned long total; /* Total count for various statistics */ - - printf("Small # of attributes:\n"); - total = 0; - for(u = 1; u < SIZE_SMALL_ATTRS; u++) { - if(iter->num_small_attrs[u] > 0) { - printf("\t# of objects with %u attributes: %lu\n", u, iter->num_small_attrs[u]); - total += iter->num_small_attrs[u]; - } /* end if */ - } /* end for */ - printf("\tTotal # of objects with small # of attributes: %lu\n", total); + unsigned long power; /* Temporary "power" for bins */ + unsigned long total; /* Total count for various statistics */ + unsigned u; /* Local index variable */ + + printf("Small # of attributes:\n"); + total = 0; + for(u = 1; u < SIZE_SMALL_ATTRS; u++) { + if(iter->num_small_attrs[u] > 0) { + printf("\t# of objects with %u attributes: %lu\n", u, iter->num_small_attrs[u]); + total += iter->num_small_attrs[u]; + } /* end if */ + } /* end for */ + printf("\tTotal # of objects with small # of attributes: %lu\n", total); + + printf("Attribute bins:\n"); + total = 0; + power = 1; + for(u = 1; u < iter->attr_nbins; u++) { + if(iter->attr_bins[u] > 0) { + printf("\t# of objects with %lu - %lu attributes: %lu\n", power, (power * 10) - 1, + iter->attr_bins[u]); + total += iter->attr_bins[u]; + } /* end if */ + power *= 10; + } /* end for */ + printf("\tTotal # of objects with attributes: %lu\n", total); + printf("\tMax. # of attributes to objects: %lu\n", (unsigned long)iter->max_attrs); - printf("Attribute bins:\n"); - total = 0; - power = 1; - for(u = 1; u < iter->attr_nbins; u++) { - if(iter->attr_bins[u] > 0) { - printf("\t# of objects with %lu - %lu attributes: %lu\n", power, (power * 10) - 1, - iter->attr_bins[u]); - total += iter->attr_bins[u]; - } /* end if */ - power *= 10; - } /* end for */ - printf("\tTotal # of objects with attributes: %lu\n", total); - printf("\tMax. # of attributes to objects: %lu\n", (unsigned long)iter->max_attrs); - return ret; + return 0; } + /*------------------------------------------------------------------------- * Function: print_dataset_info @@ -1216,101 +1131,94 @@ print_attr_info(iter_t * _iter) *------------------------------------------------------------------------- */ static herr_t -print_dataset_info(iter_t * _iter) +print_dataset_info(const iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - herr_t ret =0; /* Generic return value */ - unsigned u; /* Local index variable */ - unsigned long power; /* Temporary "power" for bins */ - unsigned long total; /* Total count for various statistics */ - size_t dtype_size; /* Size of encoded datatype */ - - if(iter->uniq_dsets > 0) { - printf("Dataset dimension information:\n"); - printf("\tMax. rank of datasets: %lu\n", iter->max_dset_rank); - printf("\tDataset ranks:\n"); - for(u = 0; u < H5S_MAX_RANK; u++) - if(iter->dset_rank_count[u] > 0) - printf("\t\t# of dataset with rank %u: %lu\n", u, iter->dset_rank_count[u]); - - printf("1-D Dataset information:\n"); - HDfprintf(stdout, "\tMax. dimension size of 1-D datasets: %Hu\n", iter->max_dset_dims); - printf("\tSmall 1-D datasets:\n"); + unsigned long power; /* Temporary "power" for bins */ + unsigned long total; /* Total count for various statistics */ + size_t dtype_size; /* Size of encoded datatype */ + unsigned u; /* Local index variable */ + + if(iter->uniq_dsets > 0) { + printf("Dataset dimension information:\n"); + printf("\tMax. rank of datasets: %lu\n", iter->max_dset_rank); + printf("\tDataset ranks:\n"); + for(u = 0; u < H5S_MAX_RANK; u++) + if(iter->dset_rank_count[u] > 0) + printf("\t\t# of dataset with rank %u: %lu\n", u, iter->dset_rank_count[u]); + + printf("1-D Dataset information:\n"); + HDfprintf(stdout, "\tMax. dimension size of 1-D datasets: %Hu\n", iter->max_dset_dims); + printf("\tSmall 1-D datasets:\n"); + total = 0; + for(u = 0; u < SIZE_SMALL_DSETS; u++) { + if(iter->small_dset_dims[u] > 0) { + printf("\t\t# of dataset dimensions of size %u: %lu\n", u, + iter->small_dset_dims[u]); + total += iter->small_dset_dims[u]; + } /* end if */ + } /* end for */ + printf("\t\tTotal small datasets: %lu\n", total); + + /* Protect against no datasets in file */ + if(iter->dset_dim_nbins > 0) { + printf("\t1-D Dataset dimension bins:\n"); total = 0; - for(u = 0; u < SIZE_SMALL_DSETS; u++) { - if(iter->small_dset_dims[u] > 0) { - printf("\t\t# of dataset dimensions of size %u: %lu\n", u, - iter->small_dset_dims[u]); - total += iter->small_dset_dims[u]; + if(iter->dset_dim_bins[0] > 0) { + printf("\t\t# of datasets of size 0: %lu\n", iter->dset_dim_bins[0]); + total = iter->dset_dim_bins[0]; + } /* end if */ + power = 1; + for(u = 1; u < iter->dset_dim_nbins; u++) { + if(iter->dset_dim_bins[u] > 0) { + printf("\t\t# of datasets of size %lu - %lu: %lu\n", power, (power * 10) - 1, + iter->dset_dim_bins[u]); + total += iter->dset_dim_bins[u]; } /* end if */ + power *= 10; } /* end for */ - printf("\t\tTotal small datasets: %lu\n", total); - - /* Protect against no datasets in file */ - if(iter->dset_dim_nbins > 0) { - printf("\t1-D Dataset dimension bins:\n"); - total = 0; - if(iter->dset_dim_bins[0] > 0) { - printf("\t\t# of datasets of size 0: %lu\n", iter->dset_dim_bins[0]); - total = iter->dset_dim_bins[0]; - } /* end if */ - power = 1; - for(u = 1; u < iter->dset_dim_nbins; u++) { - if(iter->dset_dim_bins[u] > 0) { - printf("\t\t# of datasets of size %lu - %lu: %lu\n", power, (power * 10) - 1, - iter->dset_dim_bins[u]); - total += iter->dset_dim_bins[u]; - } /* end if */ - power *= 10; - } /* end for */ - printf("\t\tTotal # of datasets: %lu\n", total); - } /* end if */ - - printf("Dataset storage information:\n"); - HDfprintf(stdout, "\tTotal raw data size: %Hu\n", iter->dset_storage_size); - - printf("Dataset layout information:\n"); - for(u = 0; u < H5D_NLAYOUTS; u++) - printf("\tDataset layout counts[%s]: %lu\n", (u == 0 ? "COMPACT" : - (u == 1 ? "CONTIG" : "CHUNKED")), iter->dset_layouts[u]); - printf("\tNumber of external files : %lu\n", iter->nexternal); - printf("Dataset filters information:\n"); - printf("\tNumber of datasets with \n"); - - printf("\t NO filter: %lu\n", iter->dset_comptype[H5Z_FILTER_ERROR+1]); - - printf("\t GZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_DEFLATE]); - - printf("\t SHUFFLE filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SHUFFLE]); - - printf("\t FLETCHER32 filter: %lu\n", iter->dset_comptype[H5Z_FILTER_FLETCHER32]); - - printf("\t SZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SZIP]); - - printf("\t NBIT filter: %lu\n", iter->dset_comptype[H5Z_FILTER_NBIT]); + printf("\t\tTotal # of datasets: %lu\n", total); + } /* end if */ - printf("\t SCALEOFFSET filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SCALEOFFSET]); + printf("Dataset storage information:\n"); + HDfprintf(stdout, "\tTotal raw data size: %Hu\n", iter->dset_storage_size); - printf("\t USER-DEFINED filter: %lu\n", iter->dset_comptype[H5_NFILTERS_IMPL-1]); - if(display_dtype_metadata) { - printf("Dataset datatype information:\n"); - printf("\t# of unique datatypes used by datasets: %lu\n", iter->dset_ntypes); - total = 0; - for(u = 0; u < iter->dset_ntypes; u++) { - H5Tencode(iter->dset_type_info[u].tid, NULL, &dtype_size); - printf("\tDataset datatype #%u:\n", u); - printf("\t\tCount (total/named) = (%lu/%lu)\n", iter->dset_type_info[u].count, iter->dset_type_info[u].named); - printf("\t\tSize (desc./elmt) = (%lu/%lu)\n", (unsigned long)dtype_size, - (unsigned long)H5Tget_size(iter->dset_type_info[u].tid)); - H5Tclose(iter->dset_type_info[u].tid); - total += iter->dset_type_info[u].count; - } /* end for */ - printf("\tTotal dataset datatype count: %lu\n", total); - } - } /* end if */ + printf("Dataset layout information:\n"); + for(u = 0; u < H5D_NLAYOUTS; u++) + printf("\tDataset layout counts[%s]: %lu\n", (u == 0 ? "COMPACT" : + (u == 1 ? "CONTIG" : "CHUNKED")), iter->dset_layouts[u]); + printf("\tNumber of external files : %lu\n", iter->nexternal); + + printf("Dataset filters information:\n"); + printf("\tNumber of datasets with:\n"); + printf("\t\tNO filter: %lu\n", iter->dset_comptype[H5Z_FILTER_ERROR+1]); + printf("\t\tGZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_DEFLATE]); + printf("\t\tSHUFFLE filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SHUFFLE]); + printf("\t\tFLETCHER32 filter: %lu\n", iter->dset_comptype[H5Z_FILTER_FLETCHER32]); + printf("\t\tSZIP filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SZIP]); + printf("\t\tNBIT filter: %lu\n", iter->dset_comptype[H5Z_FILTER_NBIT]); + printf("\t\tSCALEOFFSET filter: %lu\n", iter->dset_comptype[H5Z_FILTER_SCALEOFFSET]); + printf("\t\tUSER-DEFINED filter: %lu\n", iter->dset_comptype[H5_NFILTERS_IMPL-1]); + + if(display_dtype_metadata) { + printf("Dataset datatype information:\n"); + printf("\t# of unique datatypes used by datasets: %lu\n", iter->dset_ntypes); + total = 0; + for(u = 0; u < iter->dset_ntypes; u++) { + H5Tencode(iter->dset_type_info[u].tid, NULL, &dtype_size); + printf("\tDataset datatype #%u:\n", u); + printf("\t\tCount (total/named) = (%lu/%lu)\n", iter->dset_type_info[u].count, iter->dset_type_info[u].named); + printf("\t\tSize (desc./elmt) = (%lu/%lu)\n", (unsigned long)dtype_size, + (unsigned long)H5Tget_size(iter->dset_type_info[u].tid)); + H5Tclose(iter->dset_type_info[u].tid); + total += iter->dset_type_info[u].count; + } /* end for */ + printf("\tTotal dataset datatype count: %lu\n", total); + } + } /* end if */ - return ret; + return 0; } + /*------------------------------------------------------------------------- * Function: print_file_statistics @@ -1329,28 +1237,25 @@ print_dataset_info(iter_t * _iter) *------------------------------------------------------------------------- */ static void -print_file_statistics(iter_t * _iter) +print_file_statistics(const iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - - if(display_all) { - display_file = TRUE; - display_file_metadata = TRUE; - display_group = TRUE; - display_group_metadata = TRUE; - display_dset = TRUE; - display_dtype_metadata = TRUE; - display_attr = TRUE; - } - - - if(display_file) print_file_info(iter); - if(display_file_metadata) print_file_metadata(iter); - if(display_group) print_group_info(iter); - if(display_dset) print_dataset_info(iter); - if(display_attr) print_attr_info(iter); + if(display_all) { + display_file = TRUE; + display_file_metadata = TRUE; + display_group = TRUE; + display_group_metadata = TRUE; + display_dset = TRUE; + display_dtype_metadata = TRUE; + display_attr = TRUE; + } + if(display_file) print_file_info(iter); + if(display_file_metadata) print_file_metadata(iter); + if(display_group) print_group_info(iter); + if(display_dset) print_dataset_info(iter); + if(display_attr) print_attr_info(iter); } + /*------------------------------------------------------------------------- * Function: print_object_statistics @@ -1369,15 +1274,11 @@ print_file_statistics(iter_t * _iter) *------------------------------------------------------------------------- */ static void -print_object_statistics(char *name, iter_t UNUSED * _iter) +print_object_statistics(const char *name) { -/* Comment out for now to eliminate warnings since variable is not used - iter_t *iter = (iter_t*)_iter; - EIP 11/17/06 -*/ - - printf("Object name %s\n", name); + printf("Object name %s\n", name); } + /*------------------------------------------------------------------------- * Function: print_statistics @@ -1396,13 +1297,12 @@ print_object_statistics(char *name, iter_t UNUSED * _iter) *------------------------------------------------------------------------- */ static void -print_statistics(char *name, iter_t * _iter) +print_statistics(const char *name, const iter_t *iter) { - iter_t *iter = (iter_t*)_iter; - if(display_object) - print_object_statistics(name, iter); - else - print_file_statistics(iter); + if(display_object) + print_object_statistics(name); + else + print_file_statistics(iter); } @@ -1413,7 +1313,6 @@ main(int argc, const char *argv[]) const char *fname = NULL; hid_t fid; struct handler_t *hand; - herr_t status, reterr; char root[] = "/"; int i; H5F_info_t finfo; @@ -1443,13 +1342,11 @@ main(int argc, const char *argv[]) leave(EXIT_FAILURE); } - /* Initialize iter structure */ - status = iter_init(&iter); + iter_init(&iter); /* Get storge info for SOHM's btree/list/heap and superblock extension */ - reterr = H5Fget_info(fid, &finfo); - if (reterr < 0) + if(H5Fget_info(fid, &finfo) < 0) warn_msg(progname, "Unable to retrieve SOHM info\n"); else { iter.super_ext_size = finfo.super_ext_size; @@ -1458,20 +1355,19 @@ main(int argc, const char *argv[]) iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; } - /* Walk the objects or all file */ - for (i = 0; i < argc; i++) { - if (hand[i].obj) { + for(i = 0; i < argc; i++) { + if(hand[i].obj) { if(hand[i].flag) { walk(fid, hand[i].obj, &iter); print_statistics(hand[i].obj, &iter); } } - } + free(hand); - H5Fclose(fid); - if (fid < 0) { + + if(H5Fclose(fid) < 0) { error_msg(progname, "unable to close file \"%s\"\n", fname); leave(EXIT_FAILURE); } diff --git a/tools/misc/testfiles/h5stat_filters-d.ddl b/tools/misc/testfiles/h5stat_filters-d.ddl index ba34ae8..e83c6c4 100644 --- a/tools/misc/testfiles/h5stat_filters-d.ddl +++ b/tools/misc/testfiles/h5stat_filters-d.ddl @@ -22,12 +22,12 @@ Dataset layout information: Dataset layout counts[CHUNKED]: 12 Number of external files : 2 Dataset filters information: - Number of datasets with - NO filter: 7 - GZIP filter: 2 - SHUFFLE filter: 2 - FLETCHER32 filter: 2 - SZIP filter: 2 - NBIT filter: 2 - SCALEOFFSET filter: 1 - USER-DEFINED filter: 1 + Number of datasets with: + NO filter: 7 + GZIP filter: 2 + SHUFFLE filter: 2 + FLETCHER32 filter: 2 + SZIP filter: 2 + NBIT filter: 2 + SCALEOFFSET filter: 1 + USER-DEFINED filter: 1 diff --git a/tools/misc/testfiles/h5stat_filters-dT.ddl b/tools/misc/testfiles/h5stat_filters-dT.ddl index 5e91577..62735f0 100644 --- a/tools/misc/testfiles/h5stat_filters-dT.ddl +++ b/tools/misc/testfiles/h5stat_filters-dT.ddl @@ -22,15 +22,15 @@ Dataset layout information: Dataset layout counts[CHUNKED]: 12 Number of external files : 2 Dataset filters information: - Number of datasets with - NO filter: 7 - GZIP filter: 2 - SHUFFLE filter: 2 - FLETCHER32 filter: 2 - SZIP filter: 2 - NBIT filter: 2 - SCALEOFFSET filter: 1 - USER-DEFINED filter: 1 + Number of datasets with: + NO filter: 7 + GZIP filter: 2 + SHUFFLE filter: 2 + FLETCHER32 filter: 2 + SZIP filter: 2 + NBIT filter: 2 + SCALEOFFSET filter: 1 + USER-DEFINED filter: 1 Dataset datatype information: # of unique datatypes used by datasets: 2 Dataset datatype #0: diff --git a/tools/misc/testfiles/h5stat_filters.ddl b/tools/misc/testfiles/h5stat_filters.ddl index 11eb76a..4dd6aee 100644 --- a/tools/misc/testfiles/h5stat_filters.ddl +++ b/tools/misc/testfiles/h5stat_filters.ddl @@ -53,15 +53,15 @@ Dataset layout information: Dataset layout counts[CHUNKED]: 12 Number of external files : 2 Dataset filters information: - Number of datasets with - NO filter: 7 - GZIP filter: 2 - SHUFFLE filter: 2 - FLETCHER32 filter: 2 - SZIP filter: 2 - NBIT filter: 2 - SCALEOFFSET filter: 1 - USER-DEFINED filter: 1 + Number of datasets with: + NO filter: 7 + GZIP filter: 2 + SHUFFLE filter: 2 + FLETCHER32 filter: 2 + SZIP filter: 2 + NBIT filter: 2 + SCALEOFFSET filter: 1 + USER-DEFINED filter: 1 Dataset datatype information: # of unique datatypes used by datasets: 2 Dataset datatype #0: diff --git a/tools/misc/testfiles/h5stat_newgrat.ddl b/tools/misc/testfiles/h5stat_newgrat.ddl index 0cf8367..228d565 100644 --- a/tools/misc/testfiles/h5stat_newgrat.ddl +++ b/tools/misc/testfiles/h5stat_newgrat.ddl @@ -51,15 +51,15 @@ Dataset layout information: Dataset layout counts[CHUNKED]: 0 Number of external files : 0 Dataset filters information: - Number of datasets with - NO filter: 1 - GZIP filter: 0 - SHUFFLE filter: 0 - FLETCHER32 filter: 0 - SZIP filter: 0 - NBIT filter: 0 - SCALEOFFSET filter: 0 - USER-DEFINED filter: 0 + Number of datasets with: + NO filter: 1 + GZIP filter: 0 + SHUFFLE filter: 0 + FLETCHER32 filter: 0 + SZIP filter: 0 + NBIT filter: 0 + SCALEOFFSET filter: 0 + USER-DEFINED filter: 0 Dataset datatype information: # of unique datatypes used by datasets: 1 Dataset datatype #0: diff --git a/tools/misc/testfiles/h5stat_tsohm.ddl b/tools/misc/testfiles/h5stat_tsohm.ddl index cdca49a..572965e 100644 --- a/tools/misc/testfiles/h5stat_tsohm.ddl +++ b/tools/misc/testfiles/h5stat_tsohm.ddl @@ -50,15 +50,15 @@ Dataset layout information: Dataset layout counts[CHUNKED]: 2 Number of external files : 0 Dataset filters information: - Number of datasets with - NO filter: 2 - GZIP filter: 0 - SHUFFLE filter: 0 - FLETCHER32 filter: 0 - SZIP filter: 0 - NBIT filter: 0 - SCALEOFFSET filter: 0 - USER-DEFINED filter: 0 + Number of datasets with: + NO filter: 2 + GZIP filter: 0 + SHUFFLE filter: 0 + FLETCHER32 filter: 0 + SZIP filter: 0 + NBIT filter: 0 + SCALEOFFSET filter: 0 + USER-DEFINED filter: 0 Dataset datatype information: # of unique datatypes used by datasets: 1 Dataset datatype #0: -- cgit v0.12