From d2f3c1b991b1990fe70afa64b3ca1941165a94c4 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 11 Oct 2012 14:10:26 -0500 Subject: [svn-r22885] Purpose: Adds some additional flush dependency plumbing and fixes some minor issues with the v2 B-tree code. Tested on: local Ubuntu VM --- src/H5B2.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++-------- src/H5B2cache.c | 63 ++++++++++++++------------- src/H5B2hdr.c | 40 ++++++++--------- src/H5B2int.c | 112 +++++++++++++++++++++++++++++++++++++---------- src/H5B2pkg.h | 16 ++++--- src/H5B2private.h | 9 ++-- src/H5B2stat.c | 27 ++++++------ src/H5B2test.c | 2 +- src/H5Bcache.c | 16 +++---- 9 files changed, 288 insertions(+), 125 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index 5a77c30..4364eb3 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -133,11 +133,11 @@ H5B2_t * H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udata, void *parent) { - H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ - H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ + H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ + H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ haddr_t hdr_addr; /* B-tree header address */ - H5B2_t *ret_value; /* Return value */ + H5B2_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -152,7 +152,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, /* Create shared v2 B-tree header */ if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam, ctx_udata, parent))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't create v2 B-tree header") /* Create v2 B-tree wrapper */ if(NULL == (bt2 = H5FL_MALLOC(H5B2_t))) @@ -163,7 +163,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, cache_udata.parent = parent; cache_udata.ctx_udata = ctx_udata; if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ bt2->hdr = hdr; @@ -172,7 +172,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, /* Increment # of files using this v2 B-tree header */ if(H5B2_hdr_fuse_incr(bt2->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment file reference count on shared v2 B-tree header") /* Set file pointer for this v2 B-tree open context */ bt2->f = f; @@ -427,15 +427,15 @@ htri_t H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, void *op_data) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ void *parent = NULL; /* Parent of current node */ unsigned depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(FALSE) /* Check arguments. */ HDassert(bt2); @@ -1403,7 +1403,7 @@ done: *------------------------------------------------------------------------- */ htri_t -H5B2_support(H5B2_t *bt2, hid_t dxpl_id, void *udata, void *child) +H5B2_support(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5AC_info_t *child) { H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ @@ -1476,7 +1476,7 @@ H5B2_support(H5B2_t *bt2, hid_t dxpl_id, void *udata, void *child) } /* end if */ else { /* Add flush dependency on child */ - if(H5AC_create_flush_dependency(internal, child) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)internal, child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") /* Unlock current node */ @@ -1508,7 +1508,7 @@ H5B2_support(H5B2_t *bt2, hid_t dxpl_id, void *udata, void *child) if(cmp == 0) { /* Add flush dependency on child */ - if(H5AC_create_flush_dependency(leaf, child) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)leaf, child) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") /* Indicate child was supported */ @@ -1548,7 +1548,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, void *child) +H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5AC_info_t *child) { H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ @@ -1556,7 +1556,7 @@ H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, void *child) unsigned depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ - htri_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1621,8 +1621,8 @@ H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, void *child) } /* end if */ else { /* Remove flush dependency on child */ - if(H5AC_destroy_flush_dependency(internal, child) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + if(H5B2__destroy_flush_depend((H5AC_info_t *)internal, child) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to destroy flush dependency") /* Unlock current node */ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) @@ -1652,9 +1652,9 @@ H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, void *child) cmp = H5B2_locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx); if(cmp == 0) { - /* Add flush dependency on child */ - if(H5AC_destroy_flush_dependency(leaf, child) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + /* Remove flush dependency on child */ + if(H5B2__destroy_flush_depend((H5AC_info_t *)leaf, child) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to destroy flush dependency") } /* end if */ else HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "node not found in B-tree") @@ -1674,3 +1674,93 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_unsupport() */ + +/*------------------------------------------------------------------------- + * Function: H5B2_depend + * + * Purpose: Make a child flush dependency between the v2 B-tree's + * header and another piece of metadata in the file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_depend(H5AC_info_t *parent_entry, H5B2_t *bt2) +{ + /* Local variables */ + H5B2_hdr_t *hdr = bt2->hdr; /* Header for B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(SUCCEED) + +#ifdef QAK +HDfprintf(stderr, "%s: Called\n", FUNC); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(bt2); + HDassert(hdr); + + /* Set the shared v2 B-tree header's file context for this operation */ + bt2->hdr->f = bt2->f; + + /* Set up flush dependency between parent entry and B-tree header */ + if(H5B2__create_flush_depend(parent_entry, (H5AC_info_t *)hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency on file metadata") + +done: + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2_depend() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_undepend + * + * Purpose: Remove a child flush dependency between the v2 B-tree's + * header and another piece of metadata in the file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_undepend(H5AC_info_t *parent_entry, H5B2_t *bt2) +{ + /* Local variables */ + H5B2_hdr_t *hdr = bt2->hdr; /* Header for B-tree */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(SUCCEED) + +#ifdef QAK +HDfprintf(stderr, "%s: Called\n", FUNC); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(bt2); + HDassert(hdr); + + /* Set the shared v2 B-tree header's file context for this operation */ + bt2->hdr->f = bt2->f; + + /* Remove flush dependency between parent entry and B-tree header */ + if(H5B2__destroy_flush_depend(parent_entry, (H5AC_info_t *)hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency on file metadata") + +done: + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2_undepend() */ + diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 31277a7..be53058 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -15,11 +15,11 @@ /*------------------------------------------------------------------------- * - * Created: H5B2cache.c - * Jan 31 2005 - * Quincey Koziol + * Created: H5B2cache.c + * Jan 31 2005 + * Quincey Koziol * - * Purpose: Implement v2 B-tree metadata cache methods. + * Purpose: Implement v2 B-tree metadata cache methods. * *------------------------------------------------------------------------- */ @@ -499,13 +499,13 @@ H5B2_cache_hdr_notify(H5AC_notify_action_t action, H5B2_hdr_t *hdr) switch(action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: /* Create flush dependency on parent */ - if(H5AC_create_flush_dependency(hdr->parent, hdr) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)hdr->parent, (H5AC_info_t *)hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ - if(H5AC_destroy_flush_dependency(hdr->parent, hdr) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)hdr->parent, (H5AC_info_t *)hdr) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") break; @@ -524,27 +524,28 @@ done: /*------------------------------------------------------------------------- - * Function: H5B2_cache_hdr_size + * Function: H5B2_cache_hdr_size * - * Purpose: Compute the size in bytes of a B-tree header - * on disk, and return it in *size_ptr. On failure, - * the value of *size_ptr is undefined. + * Purpose: Compute the size in bytes of a B-tree header + * on disk, and return it in *size_ptr. On failure, + * the value of *size_ptr is undefined. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED (Can't fail) * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Feb 1 2005 + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Feb 1 2005 * *------------------------------------------------------------------------- */ static herr_t H5B2_cache_hdr_size(const H5F_t UNUSED *f, const H5B2_hdr_t *hdr, size_t *size_ptr) { - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR /* check arguments */ HDassert(f); + HDassert(hdr); HDassert(size_ptr); /* Set size value */ @@ -598,7 +599,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Increment ref. count on B-tree header */ if(H5B2_hdr_incr(udata->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree information */ internal->hdr = udata->hdr; @@ -608,7 +609,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Read header from disk */ if(H5F_block_read(f, H5FD_MEM_BTREE, addr, udata->hdr->node_size, dxpl_id, udata->hdr->page) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree internal node") + HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree internal node") p = udata->hdr->page; @@ -619,11 +620,11 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Version */ if(*p++ != H5B2_INT_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree internal node version") + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree internal node version") /* B-tree type */ if(*p++ != (uint8_t)udata->hdr->cls->id) - HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") + HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac))) @@ -675,7 +676,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Verify checksum */ if(stored_chksum != computed_chksum) - HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 internal node") + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 internal node") /* Set return value */ ret_value = internal; @@ -923,13 +924,13 @@ H5B2_cache_internal_notify(H5AC_notify_action_t action, H5B2_internal_t *interna switch(action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: /* Create flush dependency on parent */ - if(H5AC_create_flush_dependency(internal->parent, internal) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ - if(H5AC_destroy_flush_dependency(internal->parent, internal) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)internal->parent, (H5AC_info_t *)internal) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") break; @@ -1014,7 +1015,7 @@ H5B2_cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Allocate new leaf node and reset cache info */ if(NULL == (leaf = H5FL_MALLOC(H5B2_leaf_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&leaf->cache_info, 0, sizeof(H5AC_info_t)); /* Set the B-tree header's file context for this operation */ @@ -1022,7 +1023,7 @@ H5B2_cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Increment ref. count on B-tree header */ if(H5B2_hdr_incr(udata->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header") /* Share B-tree header information */ leaf->hdr = udata->hdr; @@ -1032,26 +1033,26 @@ H5B2_cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Read header from disk */ if(H5F_block_read(udata->f, H5FD_MEM_BTREE, addr, udata->hdr->node_size, dxpl_id, udata->hdr->page) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree leaf node") + HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree leaf node") p = udata->hdr->page; /* Magic number */ if(HDmemcmp(p, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node signature") + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node signature") p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5B2_LEAF_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node version") + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node version") /* B-tree type */ if(*p++ != (uint8_t)udata->hdr->cls->id) - HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") + HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type") /* Allocate space for the native keys in memory */ if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[0].nat_rec_fac))) - HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys") + HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys") /* Set the number of records in the leaf */ leaf->nrec = udata->nrec; @@ -1313,13 +1314,13 @@ H5B2_cache_leaf_notify(H5AC_notify_action_t action, H5B2_leaf_t *leaf) switch(action) { case H5AC_NOTIFY_ACTION_AFTER_INSERT: /* Create flush dependency on parent */ - if(H5AC_create_flush_dependency(leaf->parent, leaf) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ - if(H5AC_destroy_flush_dependency(leaf->parent, leaf) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)leaf->parent, (H5AC_info_t *)leaf) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") break; diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index d0ea61b..589325c 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -167,7 +167,7 @@ HDmemset(hdr->page, 0, hdr->node_size); hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; hdr->node_info[0].cum_max_nrec_size = 0; if(NULL == (hdr->node_info[0].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[0].max_nrec))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create node native key block factory") hdr->node_info[0].node_ptr_fac = NULL; /* Allocate array of pointers to internal node native keys */ @@ -261,7 +261,7 @@ H5B2_hdr_alloc(H5F_t *f) /* Allocate space for the shared information */ if(NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree header") /* Assign non-zero information */ hdr->f = f; @@ -309,19 +309,19 @@ H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, /* Allocate v2 B-tree header */ if(NULL == (hdr = H5B2_hdr_alloc(f))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header") /* Initialize shared B-tree info */ if(H5B2_hdr_init(hdr, cparam, ctx_udata, parent, (uint16_t)0) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info") /* Allocate space for the header on disk */ if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)hdr->hdr_size))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for B-tree header") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for B-tree header") /* Cache the new B-tree node */ if(H5AC_insert_entry(f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, HADDR_UNDEF, "can't add B-tree header to cache") + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, HADDR_UNDEF, "can't add B-tree header to cache") /* Set address of v2 B-tree header to return */ ret_value = hdr->addr; @@ -409,22 +409,22 @@ done: /*------------------------------------------------------------------------- - * Function: H5B2_hdr_fuse_incr + * Function: H5B2_hdr_fuse_incr * - * Purpose: Increment file reference count on shared v2 B-tree header + * Purpose: Increment file reference count on shared v2 B-tree header * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED (Can't fail) * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Oct 27 2009 + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 27 2009 * *------------------------------------------------------------------------- */ herr_t H5B2_hdr_fuse_incr(H5B2_hdr_t *hdr) { - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ HDassert(hdr); @@ -437,22 +437,22 @@ H5B2_hdr_fuse_incr(H5B2_hdr_t *hdr) /*------------------------------------------------------------------------- - * Function: H5B2_hdr_fuse_decr + * Function: H5B2_hdr_fuse_decr * - * Purpose: Decrement file reference count on shared v2 B-tree header + * Purpose: Decrement file reference count on shared v2 B-tree header * - * Return: Non-negative on success/Negative on failure + * Return: The file's reference count after the decrement. (Can't fail) * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Oct 27 2009 + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 27 2009 * *------------------------------------------------------------------------- */ size_t H5B2_hdr_fuse_decr(H5B2_hdr_t *hdr) { - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ HDassert(hdr); diff --git a/src/H5B2int.c b/src/H5B2int.c index 3d6ac14..7f56352 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -403,9 +403,9 @@ H5B2_split1(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(left_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)left_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(right_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)right_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -746,9 +746,9 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(right_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)right_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(left_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)left_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -868,9 +868,9 @@ H5B2_redistribute2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(left_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)left_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(right_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)right_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -1189,9 +1189,9 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(middle_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)middle_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(left_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)left_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -1305,9 +1305,9 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(middle_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)middle_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(right_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)right_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -1421,9 +1421,9 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(left_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)left_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(middle_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)middle_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end else */ @@ -1536,9 +1536,9 @@ H5B2_redistribute3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(right_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)right_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(middle_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)middle_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -1830,9 +1830,9 @@ H5B2_merge2(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(right_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)right_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(left_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)left_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -2135,9 +2135,9 @@ H5B2_merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(middle_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)middle_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(left_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)left_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -2227,9 +2227,9 @@ H5B2_merge3(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, /* Update flush dependencies if necessary */ if(update_deps) { - if(H5AC_destroy_flush_dependency(right_child, grandchild) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)right_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(middle_child, grandchild) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)middle_child, (H5AC_info_t *)grandchild) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -3196,9 +3196,9 @@ H5B2_remove_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, hbool_t *depth_decreased, /* Update flush dependency if necessary */ if(update_dep) { - if(H5AC_destroy_flush_dependency(internal, new_root) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)internal, (H5AC_info_t *)new_root) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(hdr, new_root) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)new_root) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -3565,9 +3565,9 @@ H5B2_remove_internal_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, /* Update flush dependency if necessary */ if(update_dep) { - if(H5AC_destroy_flush_dependency(internal, new_root) < 0) + if(H5B2__destroy_flush_depend((H5AC_info_t *)internal, (H5AC_info_t *)new_root) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") - if(H5AC_create_flush_dependency(hdr, new_root) < 0) + if(H5B2__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)new_root) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") } /* end if */ @@ -4505,3 +4505,67 @@ H5B2_assert_internal2(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2 } /* end H5B2_assert_internal2() */ #endif /* H5B2_DEBUG */ + +/*------------------------------------------------------------------------- + * Function: H5B2__create_flush_depend + * + * Purpose: Create a flush dependency between two data structure components + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(parent_entry); + HDassert(child_entry); + + /* Create a flush dependency between parent and child entry */ + if(H5AC_create_flush_dependency(parent_entry, child_entry) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__create_flush_depend() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__destroy_flush_depend + * + * Purpose: Destroy a flush dependency between two data structure components + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(parent_entry); + HDassert(child_entry); + + /* Destroy a flush dependency between parent and child entry */ + if(H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__destroy_flush_depend() */ + diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index eb7d833..50cd153 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -230,8 +230,8 @@ typedef struct H5B2_internal_cache_ud_t { H5F_t *f; /* File that v2 b-tree header is within */ H5B2_hdr_t *hdr; /* v2 B-tree header */ void *parent; /* Flush dependency parent */ - unsigned nrec; /* Number of records in node to load */ - unsigned depth; /* Depth of node to load */ + uint16_t nrec; /* Number of records in node to load */ + uint16_t depth; /* Depth of node to load */ } H5B2_internal_cache_ud_t; /* Callback info for loading a free space leaf node into the cache */ @@ -239,14 +239,14 @@ typedef struct H5B2_leaf_cache_ud_t { H5F_t *f; /* File that v2 b-tree header is within */ H5B2_hdr_t *hdr; /* v2 B-tree header */ void *parent; /* Flush dependency parent */ - unsigned nrec; /* Number of records in node to load */ + uint16_t nrec; /* Number of records in node to load */ } H5B2_leaf_cache_ud_t; #ifdef H5B2_TESTING /* Node information for testing */ typedef struct { - unsigned depth; /* Depth of node */ - unsigned nrec; /* Number of records in node */ + uint16_t depth; /* Depth of node */ + uint16_t nrec; /* Number of records in node */ } H5B2_node_info_test_t; #endif /* H5B2_TESTING */ @@ -283,6 +283,12 @@ extern const H5B2_class_t *const H5B2_client_class_g[H5B2_NUM_BTREE_ID]; /* Package Private Prototypes */ /******************************/ +/* Generic routines */ +H5_DLL herr_t H5B2__create_flush_depend(H5AC_info_t *parent_entry, + H5AC_info_t *child_entry); +H5_DLL herr_t H5B2__destroy_flush_depend(H5AC_info_t *parent_entry, + H5AC_info_t *child_entry); + /* Routines for managing B-tree header info */ H5_DLL H5B2_hdr_t *H5B2_hdr_alloc(H5F_t *f); H5_DLL haddr_t H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, diff --git a/src/H5B2private.h b/src/H5B2private.h index 7ec0019..1f547bd 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -31,7 +31,8 @@ #include "H5B2public.h" /* Private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Fprivate.h" /* File access */ /**************************/ /* Library Private Macros */ @@ -157,9 +158,11 @@ H5_DLL herr_t H5B2_close(H5B2_t *bt2, hid_t dxpl_id); H5_DLL herr_t H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, void *parent, H5B2_remove_t op, void *op_data); H5_DLL htri_t H5B2_support(H5B2_t *bt2, hid_t dxpl_id, void *udata, - void *child); + H5AC_info_t *child); H5_DLL herr_t H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, - void *child); + H5AC_info_t *child); +H5_DLL herr_t H5B2_depend(H5AC_info_t *parent_entry, H5B2_t *bt2); +H5_DLL herr_t H5B2_undepend(H5AC_info_t *parent_entry, H5B2_t *bt2); /* Statistics routines */ H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); diff --git a/src/H5B2stat.c b/src/H5B2stat.c index 05e81ed..d536456 100644 --- a/src/H5B2stat.c +++ b/src/H5B2stat.c @@ -13,10 +13,10 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Monday, March 6, 2006 * - * Purpose: v2 B-tree metadata statistics functions. + * Purpose: v2 B-tree metadata statistics functions. * */ @@ -24,15 +24,15 @@ /* Module Setup */ /****************/ -#define H5B2_PACKAGE /*suppress error about including H5B2pkg */ +#define H5B2_PACKAGE /* Suppress error about including H5B2pkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5B2pkg.h" /* v2 B-trees */ +#include "H5Eprivate.h" /* Error handling */ /****************/ @@ -71,14 +71,13 @@ /*------------------------------------------------------------------------- - * Function: H5B2_stat_info + * Function: H5B2_stat_info * - * Purpose: Retrieve metadata statistics for a v2 B-tree + * Purpose: Retrieve metadata statistics for a v2 B-tree * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED (Can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, March 6, 2006 * *------------------------------------------------------------------------- @@ -86,7 +85,7 @@ herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) { - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOERR /* Check arguments. */ HDassert(info); @@ -105,7 +104,7 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) * Purpose: Iterate over all the records in the B-tree, collecting * storage info. * - * Return: non-negative on success, negative on error + * Return: SUCCEED/FAIL * * Programmer: Vailin Choi * June 19 2007 @@ -115,7 +114,7 @@ H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info) herr_t H5B2_size(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size) { - H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5B2test.c b/src/H5B2test.c index 06736e7..29e378a 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -400,7 +400,7 @@ H5B2_get_node_info_test(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ void *parent = NULL; /* Parent of current node */ - unsigned depth; /* Current depth of the tree */ + uint16_t depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 8022743..00715e0 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -440,16 +440,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5B_compute_size + * Function: H5B_compute_size * - * Purpose: Compute the size in bytes of the specified instance of - * H5B_t on disk, and return it in *len_ptr. On failure, - * the value of *len_ptr is undefined. + * Purpose: Compute the size in bytes of the specified instance of + * H5B_t on disk, and return it in *len_ptr. On failure, + * the value of *len_ptr is undefined. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED (Can't fail) * - * Programmer: John Mainzer - * 5/13/04 + * Programmer: John Mainzer + * 5/13/04 * *------------------------------------------------------------------------- */ @@ -458,7 +458,7 @@ H5B_compute_size(const H5F_t UNUSED *f, const H5B_t *bt, size_t *size_ptr) { H5B_shared_t *shared; /* Pointer to shared B-tree info */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR /* check arguments */ HDassert(f); -- cgit v0.12