diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Abtree2.c | 2 | ||||
-rw-r--r-- | src/H5B.c | 190 | ||||
-rw-r--r-- | src/H5B2.c | 31 | ||||
-rw-r--r-- | src/H5B2int.c | 120 | ||||
-rw-r--r-- | src/H5B2pkg.h | 5 | ||||
-rw-r--r-- | src/H5B2private.h | 4 | ||||
-rw-r--r-- | src/H5Bprivate.h | 21 | ||||
-rw-r--r-- | src/H5D.c | 1 | ||||
-rw-r--r-- | src/H5Distore.c | 94 | ||||
-rw-r--r-- | src/H5Doh.c | 23 | ||||
-rw-r--r-- | src/H5Dpkg.h | 3 | ||||
-rw-r--r-- | src/H5F.c | 80 | ||||
-rw-r--r-- | src/H5FS.c | 96 | ||||
-rw-r--r-- | src/H5FSprivate.h | 4 | ||||
-rw-r--r-- | src/H5Fpkg.h | 3 | ||||
-rw-r--r-- | src/H5Fpublic.h | 9 | ||||
-rw-r--r-- | src/H5Fsuper.c | 30 | ||||
-rw-r--r-- | src/H5Gnode.c | 101 | ||||
-rw-r--r-- | src/H5Gobj.c | 1 | ||||
-rw-r--r-- | src/H5Goh.c | 66 | ||||
-rw-r--r-- | src/H5Gpkg.h | 11 | ||||
-rw-r--r-- | src/H5Gprivate.h | 1 | ||||
-rw-r--r-- | src/H5Gstab.c | 81 | ||||
-rw-r--r-- | src/H5HF.c | 85 | ||||
-rw-r--r-- | src/H5HFiblock.c | 54 | ||||
-rw-r--r-- | src/H5HFpkg.h | 4 | ||||
-rw-r--r-- | src/H5HFprivate.h | 7 | ||||
-rw-r--r-- | src/H5HFstat.c | 79 | ||||
-rw-r--r-- | src/H5HL.c | 27 | ||||
-rw-r--r-- | src/H5O.c | 68 | ||||
-rw-r--r-- | src/H5Oattribute.c | 63 | ||||
-rw-r--r-- | src/H5Opkg.h | 14 | ||||
-rw-r--r-- | src/H5Oprivate.h | 4 | ||||
-rw-r--r-- | src/H5Opublic.h | 7 | ||||
-rw-r--r-- | src/H5Oshared.h | 4 | ||||
-rwxr-xr-x | src/H5SM.c | 51 | ||||
-rwxr-xr-x | src/H5SMprivate.h | 2 |
37 files changed, 707 insertions, 739 deletions
diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 97a5a40..b685af7 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -273,7 +273,7 @@ H5A_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec) const H5A_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec; herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5A_dense_btree2_name_compare) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_dense_btree2_name_compare) /* Sanity check */ HDassert(bt2_udata); @@ -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() */ @@ -1187,9 +1187,10 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_modify() */ + /*------------------------------------------------------------------------- - * Function: H5B2_info_iterate + * Function: H5B2_iterate_size * * Purpose: Iterate over all the records in the B-tree, collecting * storage info. @@ -1202,18 +1203,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hsize_t *btree_size) +H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hsize_t *btree_size) { - H5B2_t *bt2=NULL; /* Pointer to the B-tree header */ + H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ - H5RC_t *bt2_shared=NULL; /* Pointer to ref-counter for shared B-tree info */ - hbool_t incr_rc=FALSE; /* Flag to indicate that we've incremented the B-tree's shared info reference count */ + H5RC_t *bt2_shared = NULL; /* Pointer to ref-counter for shared B-tree info */ + hbool_t incr_rc = FALSE; /* Flag to indicate that we've incremented the B-tree's shared info reference count */ H5B2_node_ptr_t root_ptr; /* Node pointer info for root node */ unsigned depth; /* Current depth of the tree */ - herr_t ret_value=SUCCEED; - + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5B2_info_iterate, FAIL) + FUNC_ENTER_NOAPI(H5B2_iterate_size, FAIL) /* Check arguments. */ HDassert(f); @@ -1225,6 +1225,7 @@ H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add if(NULL == (bt2 = H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") + /* Safely grab pointer to reference counted shared B-tree info, so we can release the B-tree header if necessary */ bt2_shared = bt2->shared; H5RC_INC(bt2_shared); incr_rc = TRUE; @@ -1233,6 +1234,7 @@ H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add shared = H5RC_GET_OBJ(bt2->shared); HDassert(shared); + /* Add size of header to B-tree metadata total */ *btree_size += H5B2_HEADER_SIZE(f); /* Make copy of the root node pointer */ @@ -1248,9 +1250,13 @@ H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add /* Iterate through records */ if(root_ptr.node_nrec > 0) { - /* Iterate through nodes */ - if((ret_value = H5B2_info_iterate_node(f, dxpl_id, bt2_shared, depth, &root_ptr, btree_size)) < 0) - HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); + /* Check for root node being a leaf */ + if(depth == 0) + *btree_size += shared->node_size; + else + /* Iterate through nodes */ + if(H5B2_iterate_size_node(f, dxpl_id, bt2_shared, depth, &root_ptr, btree_size) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed"); } /* end if */ done: @@ -1259,4 +1265,5 @@ done: H5RC_DEC(bt2_shared); FUNC_LEAVE_NOAPI(ret_value) -} /* H5B2_info_iterate() */ +} /* H5B2_iterate_size() */ + diff --git a/src/H5B2int.c b/src/H5B2int.c index 20e4300..2625c63 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -3147,6 +3147,67 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_delete_node() */ + +/*------------------------------------------------------------------------- + * Function: H5B2_iterate_size_node + * + * Purpose: Iterate over all the records from a B-tree node, collecting + * btree storage info. + * + * Return: non-negative on success, negative on error + * + * Programmer: Vailin Choi + * July 12 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, + const H5B2_node_ptr_t *curr_node, hsize_t *btree_size) +{ + H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + herr_t ret_value = SUCCEED; /* Iterator return value */ + + FUNC_ENTER_NOAPI(H5B2_iterate_size_node, FAIL) + + /* Check arguments. */ + HDassert(f); + HDassert(bt2_shared); + HDassert(curr_node); + HDassert(btree_size); + HDassert(depth > 0); + + /* Get the pointer to the shared B-tree info */ + shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); + HDassert(shared); + + /* Lock the current B-tree node */ + if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") + + /* Recursively descend into child nodes, if we are above the "twig" level in the B-tree */ + if(depth > 1) { + unsigned u; /* Local index */ + + /* Descend into children */ + for(u = 0; u < internal->nrec + 1; u++) + if(H5B2_iterate_size_node(f, dxpl_id, bt2_shared, (depth - 1), &(internal->node_ptrs[u]), btree_size) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") + } /* end if */ + else /* depth is 1: count all the leaf nodes from this node */ + *btree_size += (internal->nrec + 1) * shared->node_size; + + /* Count this node */ + *btree_size += shared->node_size; + +done: + if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2_iterate_size_node() */ + #ifdef H5B2_DEBUG /*------------------------------------------------------------------------- @@ -3304,63 +3365,4 @@ H5B2_assert_internal2(hsize_t parent_all_nrec, H5B2_shared_t *shared, H5B2_inter return(0); } /* end H5B2_assert_internal2() */ #endif /* H5B2_DEBUG */ - -/*------------------------------------------------------------------------- - * Function: H5B2_info_iterate_node - * - * Purpose: Iterate over all the records from a B-tree node, collecting - * btree storage info. - * - * Return: non-negative on success, negative on error - * - * Programmer: Vailin Choi - * July 12 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5B2_info_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, -const H5B2_node_ptr_t *curr_node, hsize_t *btree_size) -{ - H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ - herr_t ret_value = SUCCEED; /* Iterator return value */ - H5B2_internal_t *internal = NULL; /* Pointer to internal node */ - unsigned u; /* Local index */ - - FUNC_ENTER_NOAPI(H5B2_info_iterate_node, FAIL) - - /* Check arguments. */ - HDassert(f); - HDassert(bt2_shared); - HDassert(curr_node); - HDassert(btree_size); - - /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); - HDassert(shared); - - if(depth > 0) { - /* Lock the current B-tree node */ - if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") - - if(depth>1) { - /* Descend into children */ - for(u=0; u<internal->nrec+1; u++) - if(H5B2_info_iterate_node(f, dxpl_id, bt2_shared, (depth-1), &(internal->node_ptrs[u]), btree_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") - } /* end if */ - else /* depth is 1: count all the leaf nodes from this node */ - *btree_size += (internal->nrec + 1) * shared->node_size; - } /* end if */ - - /* Count this node */ - *btree_size += shared->node_size; - -done: - if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5B2_info_iterate_node() */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 956abb1..3dfbe41 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -269,12 +269,9 @@ H5_DLL herr_t H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, H5_DLL herr_t H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data); - -H5_DLL herr_t H5B2_info_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, +H5_DLL herr_t H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, const H5B2_node_ptr_t *curr_node, hsize_t *op_data); - - /* Routines for locating records */ H5_DLL int H5B2_locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, const uint8_t *native, const void *udata, unsigned *idx); diff --git a/src/H5B2private.h b/src/H5B2private.h index 064743f..6d8172c 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -122,10 +122,8 @@ H5_DLL herr_t H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, void *udata); H5_DLL herr_t H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, H5B2_operator_t op, void *op_data); - -H5_DLL herr_t H5B2_info_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, +H5_DLL herr_t H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hsize_t *op_data); - H5_DLL herr_t H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, void *udata, H5B2_found_t op, void *op_data); H5_DLL herr_t H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 4d726be..4dfea84 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -124,11 +124,13 @@ typedef struct H5B_class_t { herr_t (*debug_key)(FILE*, H5F_t*, hid_t, int, int, const void*, const void*); } H5B_class_t; +/* "user data" for iterating over B-tree when collecting B-tree metadata size */ typedef struct H5B_info_ud_t { - void *udata; - hsize_t *btree_size; + void *udata; /* Node type's 'udata' for loading */ + hsize_t *btree_size; /* Accumulated size for B-tree metadata */ } H5B_info_ud_t; + /*****************************/ /* Library-private Variables */ /*****************************/ @@ -142,21 +144,22 @@ H5FL_EXTERN(H5B_shared_t); /***************************************/ H5_DLL size_t H5B_nodesize(const H5F_t *f, const H5B_shared_t *shared, size_t *total_nkey_size); -H5_DLL herr_t H5B_create (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, +H5_DLL herr_t H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, haddr_t *addr_p/*out*/); -H5_DLL herr_t H5B_find (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, +H5_DLL herr_t H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); -H5_DLL herr_t H5B_insert (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, +H5_DLL herr_t H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); -H5_DLL herr_t H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t +H5_DLL herr_t H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op, haddr_t addr, void *udata); -H5_DLL herr_t H5B_iterate_btree_size (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t +H5_DLL herr_t H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op, haddr_t addr, H5B_info_ud_t *bh_udata); H5_DLL herr_t H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); H5_DLL herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata); -H5_DLL herr_t H5B_debug (H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, +H5_DLL herr_t H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, const H5B_class_t *type, void *udata); -#endif +#endif /* _H5Bprivate_H */ + @@ -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); @@ -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() */ + @@ -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() */ @@ -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() */ + @@ -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() */ + @@ -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 */ @@ -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 */ |