summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/suff.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-01-17 08:48:39 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-01-17 08:48:39 (GMT)
commit70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7 (patch)
treecf47b67db3753288cfd9fa2adc45e7c5cd2f8741 /Tools/scripts/suff.py
parenta88854059309667092000da55d4d5a5804267e9f (diff)
downloadcpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.zip
cpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.tar.gz
cpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.tar.bz2
Whitespace normalization.
Diffstat (limited to 'Tools/scripts/suff.py')
-rwxr-xr-xTools/scripts/suff.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/Tools/scripts/suff.py b/Tools/scripts/suff.py
index 826e236..e085cd0 100755
--- a/Tools/scripts/suff.py
+++ b/Tools/scripts/suff.py
@@ -7,23 +7,23 @@
import sys
def main():
- files = sys.argv[1:]
- suffixes = {}
- for file in files:
- suff = getsuffix(file)
- if not suffixes.has_key(suff):
- suffixes[suff] = []
- suffixes[suff].append(file)
- keys = suffixes.keys()
- keys.sort()
- for suff in keys:
- print `suff`, len(suffixes[suff])
+ files = sys.argv[1:]
+ suffixes = {}
+ for file in files:
+ suff = getsuffix(file)
+ if not suffixes.has_key(suff):
+ suffixes[suff] = []
+ suffixes[suff].append(file)
+ keys = suffixes.keys()
+ keys.sort()
+ for suff in keys:
+ print `suff`, len(suffixes[suff])
def getsuffix(file):
- suff = ''
- for i in range(len(file)):
- if file[i] == '.':
- suff = file[i:]
- return suff
+ suff = ''
+ for i in range(len(file)):
+ if file[i] == '.':
+ suff = file[i:]
+ return suff
main()
bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, child, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new node") if(!rt_key_changed) @@ -631,7 +658,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root") /* update the new child's left pointer */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_WRITE))) + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, child, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new child") bt->left = old_root; @@ -645,7 +672,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, * at the new location -QAK */ /* Bring the old root into the cache if it's not already */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new child") /* Make certain the old root info is marked as dirty before moving it, */ @@ -810,7 +837,9 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type { unsigned bt_flags = H5AC__NO_FLAGS_SET, twin_flags = H5AC__NO_FLAGS_SET; H5B_t *bt = NULL, *twin = NULL; + H5RC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */ int cmp = -1; /* Key comparison value */ haddr_t child_addr = HADDR_UNDEF; @@ -837,15 +866,22 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type *lt_key_changed = FALSE; *rt_key_changed = FALSE; + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); + HDassert(shared); + /* * Use a binary search to find the child that will receive the new * data. When the search completes IDX points to the child that * should get the new data. */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); - HDassert(shared); rt = bt->nchildren; while(lt < rt && cmp) { @@ -1007,7 +1043,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if(bt->nchildren == shared->two_k) { if(H5B_split(f, dxpl_id, bt, &bt_flags, addr, idx, udata, new_node_p/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") - if(NULL == (twin = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE))) + if(NULL == (twin = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") if(idx < bt->nchildren) { tmp_bt = bt; @@ -1079,6 +1115,9 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add H5B_operator_t op, void *udata) { H5B_t *bt = NULL; /* Pointer to current B-tree node */ + H5RC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ uint8_t *native = NULL; /* Array of keys in native format */ haddr_t *child = NULL; /* Array of child pointers */ herr_t ret_value; /* Return value */ @@ -1094,8 +1133,17 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add HDassert(op); HDassert(udata); + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); + HDassert(shared); + /* Protect the initial/current node */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load B-tree node") if(bt->level > 0) { @@ -1111,14 +1159,9 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, H5_ITER_ERROR, "unable to list B-tree node") } /* end if */ else { - H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned nchildren; /* Number of child pointers */ haddr_t next_addr; /* Address of next node to the right */ - /* Get the shared B-tree information */ - shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); - HDassert(shared); - /* Allocate space for a copy of the native records & child pointers */ if(NULL == (native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed for shared B-tree native records") @@ -1164,7 +1207,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add if(H5F_addr_defined(next_addr)) { /* Protect the next node to the right */ addr = next_addr; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "B-tree node") /* Cache information from this node */ @@ -1270,7 +1313,9 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type { H5B_t *bt = NULL, *sibling = NULL; unsigned bt_flags = H5AC__NO_FLAGS_SET; + H5RC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned idx = 0, lt = 0, rt; /* Final, left & right indices */ int cmp = 1; /* Key comparison value */ H5B_ins_t ret_value = H5B_INS_ERROR; @@ -1286,14 +1331,21 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type HDassert(udata); HDassert(rt_key && rt_key_changed); + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); + HDassert(shared); + /* * Perform a binary search to locate the child which contains the thing * for which we're searching. */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load B-tree node") - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); - HDassert(shared); rt = bt->nchildren; while(lt < rt && cmp) { @@ -1371,7 +1423,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ if(ret_value != H5B_INS_REMOVE && level > 0) { if(H5F_addr_defined(bt->right)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) + if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") /* Make certain the native key for the right sibling is set up */ @@ -1399,7 +1451,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type bt->nchildren = 0; if(level > 0) { if(H5F_addr_defined(bt->left)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata, H5AC_WRITE))) + if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node from tree") sibling->right = bt->right; @@ -1409,7 +1461,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type sibling = NULL; /* Make certain future references will be caught */ } /* end if */ if(H5F_addr_defined(bt->right)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) + if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") /* Copy left-most key from deleted node to left-most key in it's right neighbor */ @@ -1425,7 +1477,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type bt->right = HADDR_UNDEF; H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode) < 0 - || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags | H5C__DELETED_FLAG) < 0) { + || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags | H5AC__DELETED_FLAG) < 0) { bt = NULL; bt_flags = H5AC__NO_FLAGS_SET; HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to free B-tree node") @@ -1471,7 +1523,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ if(level > 0) { if(H5F_addr_defined(bt->right)) { - if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) + if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") HDmemcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); @@ -1539,6 +1591,9 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void hbool_t rt_key_changed = FALSE; /*right key changed?*/ unsigned bt_flags = H5AC__NO_FLAGS_SET; H5B_t *bt = NULL; /*btree node */ + H5RC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_remove, FAIL) @@ -1554,11 +1609,20 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void udata, rt_key, &rt_key_changed) == H5B_INS_ERROR) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); + HDassert(shared); + /* * If the B-tree is now empty then make sure we mark the root node as * being at level zero */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree root node") if(0 == bt->nchildren && 0 != bt->level) { @@ -1595,7 +1659,9 @@ herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt = NULL; /* B-tree node being operated on */ + H5RC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1606,11 +1672,18 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void HDassert(type); HDassert(H5F_addr_defined(addr)); + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); + HDassert(shared); + /* Lock this B-tree node into memory for now */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); - HDassert(shared); /* Iterate over all children in tree, deleting them */ if(bt->level > 0) { @@ -1832,7 +1905,9 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad const H5B_info_ud_t *info_udata) { H5B_t *bt = NULL; /* Pointer to current B-tree node */ + H5RC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned level; /* Node level */ size_t sizeof_rnode; /* Size of raw (disk) node */ haddr_t next_addr; /* Address of next node to the right */ @@ -1851,17 +1926,22 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad HDassert(info_udata->bt_info); HDassert(info_udata->udata); - /* Protect the initial/current node */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, info_udata->udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") - - /* Get the shared B-tree information */ - shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, info_udata->udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); HDassert(shared); /* Get the raw node size for iteration */ sizeof_rnode = shared->sizeof_rnode; + /* Protect the initial/current node */ + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") + /* Cache information from this node */ left_child = bt->child[0]; next_addr = bt->right; @@ -1883,7 +1963,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad while(H5F_addr_defined(next_addr)) { /* Protect the next node to the right */ addr = next_addr; - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, info_udata->udata, H5AC_READ))) + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "B-tree node") /* Cache information from this node */ @@ -2016,7 +2096,9 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; + H5RC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ @@ -2032,13 +2114,20 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f HDassert(fwidth >= 0); HDassert(type); + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); + HDassert(shared); + /* * Load the tree node. */ - if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") - shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); - HDassert(shared); /* * Print the values. @@ -2125,7 +2214,9 @@ static herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; + H5RC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ int i, ncell, cmp; static int ncalls = 0; herr_t status; @@ -2144,8 +2235,18 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void if(H5DEBUG(B)) fprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n"); } /* end if */ + + /* Get shared info for B-tree */ + if(NULL == (rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object") + shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared); + HDassert(shared); + /* Initialize the queue */ - bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ); + cache_udata.f = f; + cache_udata.type = type; + cache_udata.rc_shared = rc_shared; + bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, &cache_udata, H5AC_READ); HDassert(bt); shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -2166,7 +2267,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void * test. */ for(ncell = 0; cur; ncell++) { - bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, cur->addr, type, udata, H5AC_READ); + bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, cur->addr, &cache_udata, H5AC_READ); HDassert(bt); /* Check node header */ diff --git a/src/H5B2.c b/src/H5B2.c index c583f32..9c329fe 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -171,6 +171,7 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ unsigned bt2_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for B-tree header */ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_insert, FAIL) @@ -181,7 +182,9 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(H5F_addr_defined(addr)); /* Look up the b-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -253,6 +256,7 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, 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 */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_iterate, FAIL) @@ -264,7 +268,9 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(op); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, 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 */ @@ -338,6 +344,8 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, unsigned depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_find, FAIL) @@ -348,7 +356,9 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, 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 */ @@ -405,7 +415,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, /* Make callback for current record */ if(op && (op)(H5B2_INT_NREC(internal, shared, idx), op_data) < 0) { /* Unlock current node */ - if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") @@ -426,7 +436,10 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), bt2_shared, H5AC_READ))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr.node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &cache_leaf_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Locate record */ @@ -500,6 +513,8 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hbool_t incr_rc=FALSE; /* Flag to indicate that we've incremented the B-tree's shared info reference count */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ unsigned depth; /* Current depth of the tree */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_index, FAIL) @@ -511,7 +526,9 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(op); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, 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 */ @@ -625,7 +642,10 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ /* Lock B-tree leaf node */ - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), bt2_shared, H5AC_READ))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr.node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &cache_leaf_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Sanity check index */ @@ -674,6 +694,7 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ unsigned bt2_flags = H5AC__NO_FLAGS_SET; H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_remove, FAIL) @@ -684,7 +705,9 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(H5F_addr_defined(addr)); /* Look up the b-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -729,7 +752,7 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, done: /* Release the B-tree header info */ - if (bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, bt2_flags) < 0) + if(bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, bt2_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info") FUNC_LEAVE_NOAPI(ret_value) @@ -757,6 +780,7 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ unsigned bt2_flags = H5AC__NO_FLAGS_SET; H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_remove_by_idx, FAIL) @@ -767,7 +791,9 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, HDassert(H5F_addr_defined(addr)); /* Look up the b-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -820,7 +846,7 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, done: /* Release the B-tree header info */ - if (bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, bt2_flags) < 0) + if(bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, bt2_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info") FUNC_LEAVE_NOAPI(ret_value) @@ -844,8 +870,9 @@ herr_t H5B2_get_nrec(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hsize_t *nrec) { - H5B2_t *bt2=NULL; /* Pointer to the B-tree header */ - herr_t ret_value = SUCCEED; + H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B2_get_nrec, FAIL) @@ -856,7 +883,9 @@ H5B2_get_nrec(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(nrec); /* Look up the B-tree header */ - if (NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get B-tree number of records */ @@ -864,7 +893,7 @@ H5B2_get_nrec(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, done: /* Release B-tree header node */ - if (bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0) + if(bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info") FUNC_LEAVE_NOAPI(ret_value) @@ -902,6 +931,7 @@ H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, { H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_neighbor, FAIL) @@ -913,7 +943,9 @@ H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(op); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -936,7 +968,7 @@ H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, done: /* Release the B-tree header info */ - if (bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0) + if(bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info") FUNC_LEAVE_NOAPI(ret_value) @@ -971,6 +1003,7 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, { H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_delete, FAIL) @@ -981,7 +1014,9 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -1038,6 +1073,8 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, unsigned depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_modify, FAIL) @@ -1049,7 +1086,9 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, HDassert(op); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, 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 */ @@ -1098,7 +1137,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, next_node_ptr=internal->node_ptrs[idx]; /* Unlock current node */ - if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Set pointer to next node to load */ @@ -1108,12 +1147,12 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hbool_t changed; /* Whether the 'modify' callback changed the record */ /* Make callback for current record */ - if ( (op)(H5B2_INT_NREC(internal,shared,idx), op_data, &changed) <0) { + if((op)(H5B2_INT_NREC(internal,shared,idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed==FALSE); /* Unlock current node */ - if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation") @@ -1123,7 +1162,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, internal_flags |= changed ? H5AC__DIRTIED_FLAG : 0; /* Unlock current node */ - if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_DONE(SUCCEED); @@ -1139,7 +1178,10 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, hbool_t changed = FALSE;/* Whether the 'modify' callback changed the record */ /* Lock B-tree leaf node */ - if (NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), bt2_shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr.node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Locate record */ @@ -1147,7 +1189,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, if(cmp != 0) { /* Unlock leaf node */ - if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") /* Note: don't push error on stack, leave that to next higher level, @@ -1162,12 +1204,12 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, } /* end if */ else { /* Make callback for current record */ - if ((op)(H5B2_LEAF_NREC(leaf,shared,idx), op_data, &changed) <0) { + if((op)(H5B2_LEAF_NREC(leaf,shared,idx), op_data, &changed) < 0) { /* Make certain that the callback didn't modify the value if it failed */ HDassert(changed==FALSE); /* Unlock current node */ - if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree find operation") @@ -1178,7 +1220,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, leaf_flags |= (changed ? H5AC__DIRTIED_FLAG : 0); /* Unlock current node */ - if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } @@ -1213,6 +1255,7 @@ H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add 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 */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5B2_iterate_size, FAIL) @@ -1224,7 +1267,9 @@ H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add HDassert(btree_size); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, 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 */ diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 5b168ba..387c153 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -67,17 +67,17 @@ /********************/ /* Metadata cache callbacks */ -static H5B2_t *H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); +static H5B2_t *H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata); static herr_t H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_t *b, unsigned UNUSED * flags_ptr); static herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *bt2); static herr_t H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *b, hbool_t destroy); static herr_t H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t *bt, size_t *size_ptr); -static H5B2_internal_t *H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_shared); +static H5B2_internal_t *H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata); static herr_t H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_internal_t *i, unsigned UNUSED * flags_ptr); static herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal); static herr_t H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *i, hbool_t destroy); static herr_t H5B2_cache_internal_size(const H5F_t *f, const H5B2_internal_t *i, size_t *size_ptr); -static H5B2_leaf_t *H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_shared); +static H5B2_leaf_t *H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata); static herr_t H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_leaf_t *l, unsigned UNUSED * flags_ptr); static herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf); static herr_t H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *l, hbool_t destroy); @@ -144,9 +144,9 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{ *------------------------------------------------------------------------- */ static H5B2_t * -H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void UNUSED *udata) +H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) { - const H5B2_class_t *type = (const H5B2_class_t *) _type; /* Type of B-tree */ + H5B2_hdr_cache_ud_t *udata = (H5B2_hdr_cache_ud_t *)_udata; unsigned depth; /* Depth of B-tree */ size_t node_size, rrec_size; /* Size info for B-tree */ uint8_t split_percent, merge_percent; /* Split & merge %s for B-tree */ @@ -165,7 +165,7 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(type); + HDassert(udata); /* Allocate space for the B-tree data structure */ if(NULL == (bt2 = H5FL_MALLOC(H5B2_t))) @@ -177,7 +177,7 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't wrap buffer") /* Compute the size of the serialized B-tree header on disk */ - size = H5B2_HEADER_SIZE(f); + size = H5B2_HEADER_SIZE(udata->f); /* Get a pointer to a buffer that's large enough for header */ if(NULL == (hdr = (uint8_t *)H5WB_actual(wb, size))) @@ -200,7 +200,7 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree header version") /* B-tree type */ - if(*p++ != (uint8_t)type->id) + if(*p++ != (uint8_t)udata->type->id) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree type") /* Node size (in bytes) */ @@ -217,9 +217,9 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo merge_percent = *p++; /* Root node pointer */ - H5F_addr_decode(f, (const uint8_t **)&p, &(bt2->root.addr)); + H5F_addr_decode(udata->f, (const uint8_t **)&p, &(bt2->root.addr)); UINT16DECODE(p, bt2->root.node_nrec); - H5F_DECODE_LENGTH(f, p, bt2->root.all_nrec); + H5F_DECODE_LENGTH(udata->f, p, bt2->root.all_nrec); /* Metadata checksum */ UINT32DECODE(p, stored_chksum); @@ -235,7 +235,7 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 B-tree header") /* Initialize shared B-tree info */ - if(H5B2_shared_init(f, bt2, type, depth, node_size, rrec_size, split_percent, merge_percent) < 0) + if(H5B2_shared_init(udata->f, bt2, udata->type, depth, node_size, rrec_size, split_percent, merge_percent) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't create shared B-tree info") /* Set return value */ @@ -479,9 +479,9 @@ H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t UNUSED *bt2, size_t *size_ptr) *------------------------------------------------------------------------- */ static H5B2_internal_t * -H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata, void UNUSED *udata2) +H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) { - const H5B2_int_load_ud1_t *udata = (const H5B2_int_load_ud1_t *)_udata; /* Pointer to user data */ + H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ H5B2_shared_t *shared; /* Shared B-tree information */ H5B2_internal_t *internal = NULL; /* Internal node read */ const uint8_t *p; /* Pointer into raw data buffer */ @@ -547,7 +547,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda native = internal->int_native; for(u = 0; u < internal->nrec; u++) { /* Decode record */ - if((shared->type->decode)(f, p, native) < 0) + if((shared->type->decode)(udata->f, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode B-tree record") /* Move to next record */ @@ -559,7 +559,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda int_node_ptr = internal->node_ptrs; for(u = 0; u < internal->nrec + 1; u++) { /* Decode node pointer */ - H5F_addr_decode(f, (const uint8_t **)&p, &(int_node_ptr->addr)); + H5F_addr_decode(udata->f, (const uint8_t **)&p, &(int_node_ptr->addr)); UINT64DECODE_VAR(p, int_node_ptr->node_nrec, shared->max_nrec_size); if(udata->depth > 1) UINT64DECODE_VAR(p, int_node_ptr->all_nrec, shared->node_info[udata->depth - 1].cum_max_nrec_size) @@ -816,10 +816,9 @@ H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal, *------------------------------------------------------------------------- */ static H5B2_leaf_t * -H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_bt2_shared) +H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) { - const unsigned *nrec = (const unsigned *)_nrec; - H5RC_t *bt2_shared = (H5RC_t *)_bt2_shared; /* Shared B-tree information */ + H5B2_leaf_cache_ud_t *udata = (H5B2_leaf_cache_ud_t *)_udata; H5B2_shared_t *shared; /* Shared B-tree information */ H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */ const uint8_t *p; /* Pointer into raw data buffer */ @@ -834,14 +833,14 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(bt2_shared); + HDassert(udata); if(NULL == (leaf = H5FL_MALLOC(H5B2_leaf_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemset(&leaf->cache_info, 0, sizeof(H5AC_info_t)); /* Share common B-tree information */ - leaf->shared = bt2_shared; + leaf->shared = udata->bt2_shared; H5RC_INC(leaf->shared); /* Get the pointer to the shared B-tree info */ @@ -872,13 +871,13 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys") /* Set the number of records in the leaf */ - leaf->nrec = *nrec; + leaf->nrec = *udata->nrec; /* Deserialize records for leaf node */ native = leaf->leaf_native; for(u = 0; u < leaf->nrec; u++) { /* Decode record */ - if((shared->type->decode)(f, p, native) < 0) + if((shared->type->decode)(udata->f, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record") /* Move to next record */ diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 836486e..56e3c4d 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -94,6 +94,7 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, H5B2_shared_t *shared; /* Shared B-tree information */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B2_hdr_debug, FAIL) @@ -111,7 +112,9 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, /* * Load the B-tree header. */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -204,6 +207,7 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, H5B2_shared_t *shared; /* Shared B-tree information */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B2_int_debug, FAIL) @@ -223,7 +227,9 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, /* * Load the B-tree header. */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -333,6 +339,8 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, H5B2_shared_t *shared; /* Shared B-tree information */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B2_leaf_debug, FAIL) @@ -352,7 +360,9 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, /* * Load the B-tree header. */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Get the pointer to the shared B-tree info */ @@ -362,7 +372,10 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, /* * Load the B-tree leaf node */ - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, addr, &nrec, bt2->shared, H5AC_READ))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &nrec; + cache_leaf_udata.bt2_shared = bt2->shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, addr, &cache_leaf_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree leaf node") /* Release the B-tree header */ diff --git a/src/H5B2int.c b/src/H5B2int.c index 71e522e..ecf9bae 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -377,6 +377,7 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_ H5B2_shared_t *shared; /* B-tree's shared info */ unsigned mid_record; /* Index of "middle" record in current node */ unsigned old_node_nrec; /* Number of records in internal node split */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_split1) @@ -440,9 +441,14 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_ right_addr = internal->node_ptrs[idx + 1].addr; /* Protect both leafs */ - if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), internal->shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec); + cache_leaf_udata.bt2_shared = internal->shared; + if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx + 1].node_nrec), internal->shared, H5AC_WRITE))) + + cache_leaf_udata.nrec = &(internal->node_ptrs[idx + 1].node_nrec); + if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* More setup for child nodes */ @@ -646,6 +652,7 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int H5B2_node_ptr_t *left_node_ptrs=NULL, *right_node_ptrs=NULL;/* Pointers to childs' node pointer info */ H5B2_shared_t *shared; /* B-tree's shared info */ hssize_t left_moved_nrec=0, right_moved_nrec=0; /* Number of records moved, for internal redistrib */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_redistribute2) @@ -654,7 +661,7 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int HDassert(internal); /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); HDassert(shared); /* Check for the kind of B-tree node to redistribute */ @@ -668,9 +675,9 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int right_addr = internal->node_ptrs[idx+1].addr; /* Lock left & right B-tree child nodes */ - if (NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if (NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx+1].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx+1].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* More setup for child nodes */ @@ -693,9 +700,14 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int right_addr = internal->node_ptrs[idx+1].addr; /* Lock left & right B-tree child nodes */ - if (NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), internal->shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec); + cache_leaf_udata.bt2_shared = internal->shared; + if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if (NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx+1].node_nrec), internal->shared, H5AC_WRITE))) + + cache_leaf_udata.nrec = &(internal->node_ptrs[idx + 1].node_nrec); + if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* More setup for child nodes */ @@ -832,9 +844,9 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int #endif /* H5B2_DEBUG */ /* Release child nodes (marked as dirty) */ - if (H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if (H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") done: @@ -875,6 +887,7 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *middle_node_ptrs=NULL;/* Pointers to childs' node pointer info */ hssize_t left_moved_nrec=0, right_moved_nrec=0; /* Number of records moved, for internal split */ hssize_t middle_moved_nrec=0; /* Number of records moved, for internal split */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_redistribute3) @@ -884,7 +897,7 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth, HDassert(internal_flags_ptr); /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); HDassert(shared); /* Check for the kind of B-tree node to redistribute */ @@ -900,11 +913,11 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth, right_addr = internal->node_ptrs[idx+1].addr; /* Lock B-tree child nodes */ - if (NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx-1].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx-1].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") - if (NULL == (middle_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (middle_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") - if (NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx+1].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx+1].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* More setup for child nodes */ @@ -933,11 +946,18 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth, right_addr = internal->node_ptrs[idx+1].addr; /* Lock B-tree child nodes */ - if (NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx-1].node_nrec), internal->shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(internal->node_ptrs[idx-1].node_nrec); + cache_leaf_udata.bt2_shared = internal->shared; + if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if (NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, middle_addr, &(internal->node_ptrs[idx].node_nrec), internal->shared, H5AC_WRITE))) + + cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec); + if(NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, middle_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if (NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx+1].node_nrec), internal->shared, H5AC_WRITE))) + + cache_leaf_udata.nrec = &(internal->node_ptrs[idx+1].node_nrec); + if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* More setup for child nodes */ @@ -1204,11 +1224,11 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth, #endif /* H5B2_DEBUG */ /* Unlock child nodes (marked as dirty) */ - if (H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if (H5AC_unprotect(f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if (H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") done: @@ -1243,6 +1263,7 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth, uint8_t *left_native, *right_native; /* Pointers to left & right children's native records */ H5B2_node_ptr_t *left_node_ptrs=NULL, *right_node_ptrs=NULL;/* Pointers to childs' node pointer info */ H5B2_shared_t *shared; /* B-tree's shared info */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_merge2) @@ -1254,7 +1275,7 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth, HDassert(internal_flags_ptr); /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); HDassert(shared); /* Check for the kind of B-tree node to split */ @@ -1293,9 +1314,14 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth, right_addr = internal->node_ptrs[idx+1].addr; /* Lock left & right B-tree child nodes */ - if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx].node_nrec), internal->shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec); + cache_leaf_udata.bt2_shared = internal->shared; + if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx+1].node_nrec), internal->shared, H5AC_WRITE))) + + cache_leaf_udata.nrec = &(internal->node_ptrs[idx+1].node_nrec); + if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* More setup for accessing child node information */ @@ -1403,6 +1429,7 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *middle_node_ptrs=NULL;/* Pointer to child's node pointer info */ H5B2_shared_t *shared; /* B-tree's shared info */ hsize_t middle_moved_nrec; /* Number of records moved, for internal split */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_merge3) @@ -1414,7 +1441,7 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth, HDassert(internal_flags_ptr); /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); HDassert(shared); /* Check for the kind of B-tree node to split */ @@ -1430,11 +1457,11 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth, right_addr = internal->node_ptrs[idx+1].addr; /* Lock B-tree child nodes */ - if (NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx-1].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (left_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx-1].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") - if (NULL == (middle_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (middle_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, middle_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") - if (NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx+1].node_nrec, (depth - 1), H5AC_WRITE))) + if(NULL == (right_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx+1].node_nrec, (depth - 1), H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* More setup for accessing child node information */ @@ -1463,11 +1490,18 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth, right_addr = internal->node_ptrs[idx+1].addr; /* Lock B-tree child nodes */ - if (NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &(internal->node_ptrs[idx-1].node_nrec), internal->shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(internal->node_ptrs[idx-1].node_nrec); + cache_leaf_udata.bt2_shared = internal->shared; + if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, left_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if (NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, middle_addr, &(internal->node_ptrs[idx].node_nrec), internal->shared, H5AC_WRITE))) + + cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec); + if(NULL == (middle_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, middle_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - if (NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &(internal->node_ptrs[idx+1].node_nrec), internal->shared, H5AC_WRITE))) + + cache_leaf_udata.nrec = &(internal->node_ptrs[idx+1].node_nrec); + if(NULL == (right_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, right_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* More setup for accessing child node information */ @@ -1578,15 +1612,15 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth, #endif /* H5B2_DEBUG */ /* Unlock left & middle nodes (marked as dirty) */ - if (H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") - if (H5AC_unprotect(f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, middle_addr, middle_child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") /* Delete right node & remove from cache (marked as dirty) */ - if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, right_addr, (hsize_t)shared->node_size) < 0) + if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, right_addr, (hsize_t)shared->node_size) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree leaf node") - if (H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG|H5AC__DELETED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG|H5AC__DELETED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") done: @@ -1619,6 +1653,7 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth, void *child; /* Pointer to child node */ uint8_t *child_native; /* Pointer to child's native records */ H5B2_shared_t *shared; /* B-tree's shared info */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_swap_leaf) @@ -1629,7 +1664,7 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth, HDassert(idx <= internal->nrec); /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); HDassert(shared); /* Check for the kind of B-tree node to swap */ @@ -1656,7 +1691,10 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth, child_addr = internal->node_ptrs[idx].addr; /* Lock B-tree child node */ - if (NULL == (child_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, child_addr, &(internal->node_ptrs[idx].node_nrec), internal->shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec); + cache_leaf_udata.bt2_shared = internal->shared; + if(NULL == (child_leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, child_class, child_addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* More setup for accessing child node information */ @@ -1681,7 +1719,7 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth, #endif /* H5B2_DEBUG */ /* Unlock child node */ - if (H5AC_unprotect(f, dxpl_id, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0) + if(H5AC_unprotect(f, dxpl_id, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") done: @@ -1710,6 +1748,7 @@ H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5B2_insert_leaf) @@ -1720,14 +1759,17 @@ H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, HDassert(curr_node_ptr); HDassert(H5F_addr_defined(curr_node_ptr->addr)); - /* Lock current B-tree node */ - if (NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &(curr_node_ptr->node_nrec), bt2_shared, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); HDassert(shared); + /* Lock current B-tree node */ + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &cache_leaf_udata, H5AC_WRITE))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") + /* Must have a leaf node with enough space to insert a record now */ HDassert(curr_node_ptr->node_nrec < shared->node_info[0].max_nrec); @@ -1809,7 +1851,7 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); HDassert(shared); /* Split or redistribute child node pointers, if necessary */ @@ -1903,7 +1945,7 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, done: /* Release the B-tree internal node */ - if (internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) @@ -2081,7 +2123,7 @@ H5B2_internal_t * H5B2_protect_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, haddr_t addr, unsigned nrec, unsigned depth, H5AC_protect_t rw) { - H5B2_int_load_ud1_t udata; /* User data to pass through to cache 'load' callback */ + H5B2_internal_cache_ud_t udata; /* User data to pass through to cache 'deserialize' callback */ H5B2_internal_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_protect_internal) @@ -2096,9 +2138,10 @@ H5B2_protect_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, haddr_t addr, udata.bt2_shared = bt2_shared; udata.nrec = nrec; udata.depth = depth; + udata.f = f; /* Protect the internal node */ - if(NULL == (ret_value = (H5B2_internal_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_INT, addr, &udata, NULL, rw))) + if(NULL == (ret_value = (H5B2_internal_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_INT, addr, &udata, rw))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree internal node") done: @@ -2134,6 +2177,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, uint8_t *native = NULL; /* Pointers to copy of node's native records */ H5B2_node_ptr_t *node_ptrs = NULL; /* Pointers to node's node pointers */ unsigned u; /* Local index */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = H5_ITER_CONT; /* Iterator return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_iterate_node) @@ -2172,7 +2216,10 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, H5B2_leaf_t *leaf; /* Pointer to leaf node */ /* Lock the current B-tree node */ - if (NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &(curr_node->node_nrec), bt2_shared, H5AC_READ))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node->node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &cache_leaf_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* Set up information about current node */ @@ -2248,6 +2295,7 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ unsigned idx; /* Location of record which matches key */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_leaf) @@ -2258,15 +2306,18 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, HDassert(curr_node_ptr); HDassert(H5F_addr_defined(curr_node_ptr->addr)); - /* Lock current B-tree node */ - leaf_addr = curr_node_ptr->addr; - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &(curr_node_ptr->node_nrec), bt2_shared, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - /* Get the pointer to the shared B-tree info */ shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); HDassert(shared); + /* Lock current B-tree node */ + leaf_addr = curr_node_ptr->addr; + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &cache_leaf_udata, H5AC_WRITE))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") + /* Sanity check number of records */ HDassert(curr_node_ptr->all_nrec == curr_node_ptr->node_nrec); HDassert(leaf->nrec == curr_node_ptr->node_nrec); @@ -2551,6 +2602,7 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */ unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_leaf_by_idx) @@ -2561,15 +2613,18 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, HDassert(curr_node_ptr); HDassert(H5F_addr_defined(curr_node_ptr->addr)); - /* Lock B-tree leaf node */ - leaf_addr = curr_node_ptr->addr; - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &(curr_node_ptr->node_nrec), bt2_shared, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - /* Get the pointer to the shared B-tree info */ shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); HDassert(shared); + /* Lock B-tree leaf node */ + leaf_addr = curr_node_ptr->addr; + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, &cache_leaf_udata, H5AC_WRITE))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") + /* Sanity check number of records */ HDassert(curr_node_ptr->all_nrec == curr_node_ptr->node_nrec); HDassert(leaf->nrec == curr_node_ptr->node_nrec); @@ -2919,6 +2974,7 @@ H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ unsigned idx; /* Location of record which matches key */ int cmp=0; /* Comparison value of records */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5B2_neighbor_leaf) @@ -2930,14 +2986,16 @@ H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, HDassert(H5F_addr_defined(curr_node_ptr->addr)); HDassert(op); - /* Lock current B-tree node */ - if (NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &(curr_node_ptr->node_nrec), bt2_shared, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") - /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); HDassert(shared); + /* Lock current B-tree node */ + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, &cache_leaf_udata, H5AC_READ))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* Locate node pointer for child */ cmp = H5B2_locate_record(shared->type, leaf->nrec, shared->nat_off, leaf->leaf_native, udata, &idx); @@ -2962,7 +3020,7 @@ H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, /* Make callback if neighbor record has been found */ if(neighbor_loc) { /* Make callback for current record */ - if ((op)(neighbor_loc, op_data) < 0) + if((op)(neighbor_loc, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree neighbor operation") } /* end if */ else @@ -2970,7 +3028,7 @@ H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, done: /* Release the B-tree internal node */ - if (leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) + if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) @@ -3061,7 +3119,7 @@ H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, done: /* Release the B-tree internal node */ - if (internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) + if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") FUNC_LEAVE_NOAPI(ret_value) @@ -3090,6 +3148,7 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, const H5AC_class_t *curr_node_class=NULL; /* Pointer to current node's class info */ void *node=NULL; /* Pointers to current node */ uint8_t *native; /* Pointers to node's native records */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5B2_delete_node) @@ -3100,7 +3159,7 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, HDassert(curr_node); /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); HDassert(shared); if(depth>0) { @@ -3108,7 +3167,7 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, unsigned u; /* Local index */ /* 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_WRITE))) + if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Set up information about current node */ @@ -3117,15 +3176,18 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, native = internal->int_native; /* Descend into children */ - for(u=0; unrec+1; u++) - if(H5B2_delete_node(f, dxpl_id, bt2_shared, depth-1, &(internal->node_ptrs[u]), op, op_data) < 0) + for(u = 0; u < internal->nrec + 1; u++) + if(H5B2_delete_node(f, dxpl_id, bt2_shared, (depth - 1), &(internal->node_ptrs[u]), op, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node descent failed") } /* end if */ else { H5B2_leaf_t *leaf; /* Pointer to leaf node */ /* Lock the current B-tree node */ - if (NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &(curr_node->node_nrec), bt2_shared, H5AC_WRITE))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node->node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node->addr, &cache_leaf_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node") /* Set up information about current node */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 270cdfd..21b6eee 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -126,6 +126,27 @@ typedef struct { hsize_t all_nrec; /* Number of records in node pointed to and all it's children */ } H5B2_node_ptr_t; +/* Callback info for loading a free space header into the cache */ +typedef struct H5B2_hdr_cache_ud_t { + H5F_t *f; /* File that v2 b-tree header is within */ + const H5B2_class_t *type; /* User-data for protecting */ +} H5B2_hdr_cache_ud_t; + +/* Callback info for loading a free space internal node into the cache */ +typedef struct H5B2_internal_cache_ud_t { + H5F_t *f; /* File that v2 b-tree header is within */ + H5RC_t *bt2_shared; /* Ref counter for shared B-tree info */ + unsigned nrec; /* Number of records in node to load */ + unsigned depth; /* Depth of node to load */ +} H5B2_internal_cache_ud_t; + +/* Callback info for loading a free space leaf node into the cache */ +typedef struct H5B2_leaf_cache_ud_t { + H5F_t *f; /* File that v2 b-tree header is within */ + const unsigned *nrec; /* Number of records in node to load */ + H5RC_t *bt2_shared; /* Ref counter for shared B-tree info */ +} H5B2_leaf_cache_ud_t; + /* Information about a node at a given depth */ typedef struct { unsigned max_nrec; /* Max. number of records in node */ @@ -194,13 +215,6 @@ typedef struct H5B2_internal_t { unsigned depth; /* Depth of this node in the B-tree */ } H5B2_internal_t; -/* User data for metadata cache 'load' callback */ -typedef struct { - H5RC_t *bt2_shared; /* Ref counter for shared B-tree info */ - unsigned nrec; /* Number of records in node to load */ - unsigned depth; /* Depth of node to load */ -} H5B2_int_load_ud1_t; - #ifdef H5B2_TESTING /* Node information for testing */ typedef struct { diff --git a/src/H5B2stat.c b/src/H5B2stat.c index 899bb8a..8aaa248 100644 --- a/src/H5B2stat.c +++ b/src/H5B2stat.c @@ -88,6 +88,7 @@ H5B2_stat_info(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, { H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ H5B2_shared_t *shared; /* Pointer to B-tree's shared information */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_stat_info) @@ -99,7 +100,9 @@ H5B2_stat_info(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, HDassert(info); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get pointer to reference counted shared B-tree info */ diff --git a/src/H5B2test.c b/src/H5B2test.c index f2cf79d..deb1748 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -258,6 +258,7 @@ H5B2_get_root_addr_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, haddr_t *root_addr) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_get_root_addr_test) @@ -269,7 +270,9 @@ H5B2_get_root_addr_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, HDassert(root_addr); /* Look up the B-tree header */ - if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header") /* Get B-tree root addr */ @@ -309,6 +312,7 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr unsigned depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ + H5B2_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B2_get_node_info_test, FAIL) @@ -319,13 +323,15 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - if (NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ))) + cache_udata.f = f; + cache_udata.type = type; + if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, 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; + bt2_shared = bt2->shared; H5RC_INC(bt2_shared); - incr_rc=TRUE; + incr_rc = TRUE; /* Get the pointer to the shared B-tree info */ shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared); @@ -391,9 +397,13 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr { H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */ + H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */ /* Lock B-tree leaf node */ - if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &(curr_node_ptr.node_nrec), bt2_shared, H5AC_READ))) + cache_leaf_udata.f = f; + cache_leaf_udata.nrec = &(curr_node_ptr.node_nrec); + cache_leaf_udata.bt2_shared = bt2_shared; + if(NULL == (leaf = (H5B2_leaf_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node") /* Locate record */ diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 110f6e2..0537502 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -54,7 +54,7 @@ /********************/ /* Metadata cache callbacks */ -static H5B_t *H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); +static H5B_t *H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata); static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *b, unsigned UNUSED * flags_ptr); static herr_t H5B_dest(H5F_t *f, H5B_t *bt); static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy); @@ -96,10 +96,10 @@ const H5AC_class_t H5AC_BT[1] = {{ *------------------------------------------------------------------------- */ static H5B_t * -H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) +H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) { - const H5B_class_t *type = (const H5B_class_t *) _type; - H5B_t *bt = NULL; + H5B_t *bt = NULL; /* Pointer to the deserialized B-tree node */ + H5B_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ const uint8_t *p; /* Pointer into raw data buffer */ uint8_t *native; /* Pointer to native keys */ @@ -111,8 +111,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(type); - HDassert(type->get_shared); + HDassert(udata); /* Allocate the B-tree node in memory */ if(NULL == (bt = H5FL_MALLOC(H5B_t))) @@ -120,8 +119,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t)); /* Set & increment the ref-counted "shared" B-tree information for the node */ - if(NULL == (bt->rc_shared=(type->get_shared)(f, udata))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer") + bt->rc_shared = udata->rc_shared; H5RC_INC(bt->rc_shared); /* Get a pointer to the shared info, for convenience */ @@ -146,7 +144,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) p += 4; /* node type and level */ - if(*p++ != (uint8_t)type->id) + if(*p++ != (uint8_t)udata->type->id) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") bt->level = *p++; @@ -154,26 +152,26 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) UINT16DECODE(p, bt->nchildren); /* sibling pointers */ - H5F_addr_decode(f, (const uint8_t **)&p, &(bt->left)); - H5F_addr_decode(f, (const uint8_t **)&p, &(bt->right)); + H5F_addr_decode(udata->f, (const uint8_t **)&p, &(bt->left)); + H5F_addr_decode(udata->f, (const uint8_t **)&p, &(bt->right)); /* the child/key pairs */ native = bt->native; for(u = 0; u < bt->nchildren; u++) { /* Decode native key value */ - if((type->decode)(shared, p, native) < 0) + if((udata->type->decode)(shared, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") p += shared->sizeof_rkey; - native += type->sizeof_nkey; + native += udata->type->sizeof_nkey; /* Decode address value */ - H5F_addr_decode(f, (const uint8_t **)&p, bt->child + u); + H5F_addr_decode(udata->f, (const uint8_t **)&p, bt->child + u); } /* end for */ /* Decode final key */ if(bt->nchildren > 0) { /* Decode native key value */ - if((type->decode)(shared, p, native) < 0) + if((udata->type->decode)(shared, p, native) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key") } /* end if */ diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 05f9f30..e48ec23 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -33,8 +33,7 @@ /* Other private headers needed by this file */ #include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5RCprivate.h" /* Reference counted objects */ +#include "H5FLprivate.h" /* Free Lists */ /**************************/ @@ -59,6 +58,13 @@ typedef struct H5B_t { haddr_t *child; /*2k child pointers */ } H5B_t; +/* Callback info for loading a B-tree node into the cache */ +typedef struct H5B_cache_ud_t { + H5F_t *f; /* File that B-tree node is within */ + const struct H5B_class_t *type; /* Type of tree */ + H5RC_t *rc_shared; /* Ref-counted shared info */ +} H5B_cache_ud_t; + /*****************************/ /* Package Private Variables */ /*****************************/ @@ -79,7 +85,7 @@ H5FL_EXTERN(H5B_t); /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5B_node_dest(H5B_t *b); +H5_DLL herr_t H5B_node_dest(H5B_t *bt); #endif /*_H5Bpkg_H*/ diff --git a/src/H5C.c b/src/H5C.c index 850194c..a2386e2 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -175,8 +175,7 @@ static void * H5C_load_entry(H5F_t * f, hid_t dxpl_id, const H5C_class_t * type, haddr_t addr, - const void * udata1, - void * udata2, + void * udata, hbool_t skip_file_checks); static herr_t H5C_make_space_in_cache(H5F_t * f, @@ -210,7 +209,7 @@ static herr_t H5C_verify_not_in_index(H5C_t * cache_ptr, #define H5C__EPOCH_MARKER_TYPE H5C__MAX_NUM_TYPE_IDS static void *H5C_epoch_marker_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void *udata1, void *udata2); + void *udata); static herr_t H5C_epoch_marker_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr, void *thing, unsigned *flags_ptr); @@ -241,8 +240,7 @@ static void * H5C_epoch_marker_load(H5F_t UNUSED * f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr, - const void UNUSED * udata1, - void UNUSED * udata2) + void UNUSED * udata) { void * ret_value = NULL; /* Return value */ @@ -321,6 +319,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } + /*------------------------------------------------------------------------- * Function: H5C_create @@ -2175,7 +2174,7 @@ H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr, *------------------------------------------------------------------------- */ herr_t -H5C_insert_entry(H5F_t * f, +H5C_insert_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, const H5C_class_t * type, @@ -2475,7 +2474,7 @@ done: */ #ifdef H5_HAVE_PARALLEL herr_t -H5C_mark_entries_as_clean(H5F_t * f, +H5C_mark_entries_as_clean(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, int32_t ce_array_len, @@ -3332,13 +3331,12 @@ done: *------------------------------------------------------------------------- */ void * -H5C_protect(H5F_t * f, +H5C_protect(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, const H5C_class_t * type, haddr_t addr, - const void * udata1, - void * udata2, + void * udata, unsigned flags) { H5C_t * cache_ptr; @@ -3396,8 +3394,7 @@ H5C_protect(H5F_t * f, hit = FALSE; - thing = H5C_load_entry(f, primary_dxpl_id, type, addr, udata1, udata2, - cache_ptr->skip_file_checks); + thing = H5C_load_entry(f, primary_dxpl_id, type, addr, udata, cache_ptr->skip_file_checks); if ( thing == NULL ) { @@ -7472,7 +7469,7 @@ H5C_flush_single_entry(const H5F_t * f, hid_t secondary_dxpl_id, const H5C_class_t * type_ptr, haddr_t addr, - unsigned flags, + unsigned flags, hbool_t * first_flush_ptr, hbool_t del_entry_from_slist_on_destroy) { @@ -7879,7 +7876,7 @@ H5C_flush_single_entry(const H5F_t * f, if ( cache_ptr->aux_ptr != NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Flush operation occured in the parallel case.") + "resize/rename in serialize occured in parallel case.") } } @@ -8030,8 +8027,7 @@ H5C_load_entry(H5F_t * f, hid_t dxpl_id, const H5C_class_t * type, haddr_t addr, - const void * udata1, - void * udata2, + void * udata, #ifndef NDEBUG hbool_t skip_file_checks) #else /* NDEBUG */ @@ -8053,7 +8049,7 @@ H5C_load_entry(H5F_t * f, HDassert( type->size ); HDassert( H5F_addr_defined(addr) ); - if ( NULL == (thing = (type->load)(f, dxpl_id, addr, udata1, udata2)) ) { + if ( NULL == (thing = (type->load)(f, dxpl_id, addr, udata)) ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load entry") diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 2c2de6d..da22c8a 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -124,8 +124,7 @@ typedef struct H5C_t H5C_t; typedef void *(*H5C_load_func_t)(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void *udata1, - void *udata2); + void *udata); typedef herr_t (*H5C_flush_func_t)(H5F_t *f, hid_t dxpl_id, hbool_t dest, @@ -443,6 +442,37 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t * cache_ptr, * there is no previous item, it should be NULL. * * + * Fields supporting metadata journaling: + * + * last_trans: unit64_t containing the ID of the last transaction in + * which this entry was dirtied. If journaling is disabled, + * or if the entry has never been dirtied in a transaction, + * this field should be set to zero. Once we notice that + * the specified transaction has made it to disk, we will + * reset this field to zero as well. + * + * We must maintain this field, as to avoid messages from + * the future, we must not flush a dirty entry to disk + * until the last transaction in which it was dirtied + * has made it to disk in the journal file. + * + * trans_next: Next pointer in the entries modified in the current + * transaction list. This field should always be null + * unless journaling is enabled, the entry is dirty, + * and last_trans field contains the current transaction + * number. Even if all these conditions are fulfilled, + * the field will still be NULL if this is the last + * entry on the list. + * + * trans_prev: Previous pointer in the entries modified in the current + * transaction list. This field should always be null + * unless journaling is enabled, the entry is dirty, + * and last_trans field contains the current transaction + * number. Even if all these conditions are fulfilled, + * the field will still be NULL if this is the first + * entry on the list. + * + * * Cache entry stats collection fields: * * These fields should only be compiled in when both H5C_COLLECT_CACHE_STATS @@ -1022,11 +1052,10 @@ H5_DLL herr_t H5C_pin_protected_entry(void *thing); H5_DLL void * H5C_protect(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - const H5C_class_t * type, + const H5C_class_t * type, haddr_t addr, - const void * udata1, - void * udata2, - unsigned flags); + void * udata, + unsigned flags); H5_DLL herr_t H5C_reset_cache_hit_rate_stats(H5C_t * cache_ptr); diff --git a/src/H5Distore.c b/src/H5Distore.c index 4da3db8..e824c26 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -52,7 +52,6 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5Bprivate.h" /* B-link trees */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ diff --git a/src/H5F.c b/src/H5F.c index c27194e..b7825bd 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -22,7 +22,7 @@ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ @@ -1956,7 +1956,7 @@ H5F_try_close(H5F_t *f) */ if(f->intent&H5F_ACC_RDWR) { /* Flush and destroy all caches */ - if(H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, H5C__NO_FLAGS_SET) < 0) + if(H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, H5F_FLUSH_NONE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 5853d05..be7d921 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -26,7 +26,6 @@ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ diff --git a/src/H5FS.c b/src/H5FS.c index b2e127d..cb390f0 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -33,6 +33,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5FSpkg.h" /* File free space */ #include "H5MFprivate.h" /* File memory management */ @@ -55,6 +56,8 @@ /********************/ /* Local Prototypes */ /********************/ + +/* Section info routines */ static herr_t H5FS_sinfo_free_sect_cb(void *item, void *key, void *op_data); static herr_t H5FS_sinfo_free_node_cb(void *item, void *key, void *op_data); @@ -169,6 +172,7 @@ H5FS_open(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, size_t nclasses, H5FS_t *fspace = NULL; /* New free space structure */ H5FS_prot_t fs_prot; /* Information for protecting free space manager */ unsigned fspace_status = 0; /* Free space header's status in the metadata cache */ + H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ H5FS_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FS_open, NULL) @@ -185,9 +189,11 @@ HDfprintf(stderr, "%s: Opening free space manager, nclasses = %Zu\n", FUNC, ncla fs_prot.nclasses = nclasses; fs_prot.classes = classes; fs_prot.cls_init_udata = cls_init_udata; + cache_udata.fs_prot = &fs_prot; + cache_udata.f = f; /* Protect the free space header */ - if(NULL == (fspace = H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, &fs_prot, NULL, H5AC_READ))) + if(NULL == (fspace = H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC_READ))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, NULL, "unable to load free space header") #ifdef QAK HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); @@ -239,6 +245,7 @@ H5FS_delete(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr) { H5FS_t *fspace = NULL; /* Free space header loaded from file */ H5FS_prot_t fs_prot; /* Temporary information for protecting free space header */ + H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FS_delete, FAIL) @@ -255,9 +262,11 @@ HDfprintf(stderr, "%s: Deleting free space manager\n", FUNC); fs_prot.nclasses = 0; fs_prot.classes = NULL; fs_prot.cls_init_udata = NULL; + cache_udata.fs_prot = &fs_prot; + cache_udata.f = f; /* Protect the free space header */ - if(NULL == (fspace = H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, &fs_prot, NULL, H5AC_WRITE))) + if(NULL == (fspace = H5AC_protect(f, dxpl_id, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC_WRITE))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, FAIL, "unable to protect free space header") /* Delete serialized section storage, if there are any */ diff --git a/src/H5FScache.c b/src/H5FScache.c index 9032050..5d9f5c6 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -34,6 +34,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5FSpkg.h" /* File free space */ #include "H5Vprivate.h" /* Vectors and arrays */ @@ -77,12 +78,12 @@ static herr_t H5FS_sinfo_serialize_sect_cb(void *_item, void UNUSED *key, void * static herr_t H5FS_sinfo_serialize_node_cb(void *_item, void UNUSED *key, void *_udata); /* Metadata cache callbacks */ -static H5FS_t *H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); +static H5FS_t *H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata); static herr_t H5FS_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FS_t *fspace, unsigned UNUSED * flags_ptr); static herr_t H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *fspace); static herr_t H5FS_cache_hdr_clear(H5F_t *f, H5FS_t *fspace, hbool_t destroy); static herr_t H5FS_cache_hdr_size(const H5F_t *f, const H5FS_t *fspace, size_t *size_ptr); -static H5FS_sinfo_t *H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); +static H5FS_sinfo_t *H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata); static herr_t H5FS_cache_sinfo_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FS_sinfo_t *sinfo, unsigned UNUSED * flags_ptr); static herr_t H5FS_cache_sinfo_dest(H5F_t *f, H5FS_sinfo_t *sinfo); static herr_t H5FS_cache_sinfo_clear(H5F_t *f, H5FS_sinfo_t *sinfo, hbool_t destroy); @@ -143,10 +144,10 @@ H5FL_BLK_DEFINE_STATIC(sect_block); *------------------------------------------------------------------------- */ static H5FS_t * -H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_fs_prot, void UNUSED *udata2) +H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) { H5FS_t *fspace = NULL; /* Free space header info */ - const H5FS_prot_t *fs_prot = (const H5FS_prot_t *)_fs_prot; /* User data for protecting */ + H5FS_hdr_cache_ud_t *udata = (H5FS_hdr_cache_ud_t *)_udata; /* user data for callback */ size_t size; /* Header size */ H5WB_t *wb = NULL; /* Wrapped buffer for header data */ uint8_t hdr_buf[H5FS_HDR_BUF_SIZE]; /* Buffer for header */ @@ -162,10 +163,10 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_fs_prot, /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(fs_prot); + HDassert(udata); /* Allocate a new free space manager */ - if(NULL == (fspace = H5FS_new(fs_prot->nclasses, fs_prot->classes, fs_prot->cls_init_udata))) + if(NULL == (fspace = H5FS_new(udata->fs_prot->nclasses, udata->fs_prot->classes, udata->fs_prot->cls_init_udata))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set free space manager's internal information */ @@ -176,7 +177,7 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_fs_prot, HGOTO_ERROR(H5E_FSPACE, H5E_CANTINIT, NULL, "can't wrap buffer") /* Compute the size of the free space header on disk */ - size = H5FS_HEADER_SIZE(f); + size = H5FS_HEADER_SIZE(udata->f); /* Get a pointer to a buffer that's large enough for header */ if(NULL == (hdr = H5WB_actual(wb, size))) @@ -203,16 +204,16 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_fs_prot, HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "unknown client ID in free space header") /* Total space tracked */ - H5F_DECODE_LENGTH(f, p, fspace->tot_space); + H5F_DECODE_LENGTH(udata->f, p, fspace->tot_space); /* Total # of free space sections tracked */ - H5F_DECODE_LENGTH(f, p, fspace->tot_sect_count); + H5F_DECODE_LENGTH(udata->f, p, fspace->tot_sect_count); /* # of serializable free space sections tracked */ - H5F_DECODE_LENGTH(f, p, fspace->serial_sect_count); + H5F_DECODE_LENGTH(udata->f, p, fspace->serial_sect_count); /* # of ghost free space sections tracked */ - H5F_DECODE_LENGTH(f, p, fspace->ghost_sect_count); + H5F_DECODE_LENGTH(udata->f, p, fspace->ghost_sect_count); /* # of section classes */ /* (only check if we actually have some classes) */ @@ -230,16 +231,16 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_fs_prot, UINT16DECODE(p, fspace->max_sect_addr); /* Max. size of section to track */ - H5F_DECODE_LENGTH(f, p, fspace->max_sect_size); + H5F_DECODE_LENGTH(udata->f, p, fspace->max_sect_size); /* Address of serialized free space sections */ - H5F_addr_decode(f, &p, &fspace->sect_addr); + H5F_addr_decode(udata->f, &p, &fspace->sect_addr); /* Size of serialized free space sections */ - H5F_DECODE_LENGTH(f, p, fspace->sect_size); + H5F_DECODE_LENGTH(udata->f, p, fspace->sect_size); /* Allocated size of serialized free space sections */ - H5F_DECODE_LENGTH(f, p, fspace->alloc_sect_size); + H5F_DECODE_LENGTH(udata->f, p, fspace->alloc_sect_size); /* Compute checksum on indirect block */ computed_chksum = H5_checksum_metadata(hdr, (size_t)(p - (const uint8_t *)hdr), 0); @@ -506,10 +507,10 @@ H5FS_cache_hdr_size(const H5F_t *f, const H5FS_t UNUSED *fspace, size_t *size_pt *------------------------------------------------------------------------- */ static H5FS_sinfo_t * -H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void *_fspace) +H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) { H5FS_sinfo_t *sinfo = NULL; /* Free space section info */ - H5FS_t *fspace = (H5FS_t *)_fspace; /* User data for protecting */ + H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* user data for callback */ haddr_t fs_addr; /* Free space header address */ size_t old_sect_size; /* Old section size */ uint8_t *buf = NULL; /* Temporary buffer */ @@ -523,28 +524,28 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(fspace); + HDassert(udata); /* Allocate a new free space section info */ - if(NULL == (sinfo = H5FS_sinfo_new(f, fspace))) + if(NULL == (sinfo = H5FS_sinfo_new(udata->f, udata->fspace))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Link free space manager to section info */ /* (for deserializing sections) */ - HDassert(fspace->sinfo == NULL); - fspace->sinfo = sinfo; + HDassert(udata->fspace->sinfo == NULL); + udata->fspace->sinfo = sinfo; /* Sanity check address */ - if(H5F_addr_ne(addr, fspace->sect_addr)) + if(H5F_addr_ne(addr, udata->fspace->sect_addr)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "incorrect address for free space sections") /* Allocate space for the buffer to serialize the sections into */ - H5_ASSIGN_OVERFLOW(/* To: */ old_sect_size, /* From: */ fspace->sect_size, /* From: */ hsize_t, /* To: */ size_t); - if(NULL == (buf = H5FL_BLK_MALLOC(sect_block, (size_t)fspace->sect_size))) + H5_ASSIGN_OVERFLOW(/* To: */ old_sect_size, /* From: */ udata->fspace->sect_size, /* From: */ hsize_t, /* To: */ size_t); + if(NULL == (buf = H5FL_BLK_MALLOC(sect_block, (size_t)udata->fspace->sect_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Read buffer from disk */ - if(H5F_block_read(f, H5FD_MEM_FSPACE_SINFO, fspace->sect_addr, (size_t)fspace->sect_size, dxpl_id, buf) < 0) + if(H5F_block_read(f, H5FD_MEM_FSPACE_SINFO, udata->fspace->sect_addr, (size_t)udata->fspace->sect_size, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_READERROR, NULL, "can't read free space sections") /* Deserialize free sections from buffer available */ @@ -560,12 +561,12 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections version") /* Address of free space header for these sections */ - H5F_addr_decode(f, &p, &fs_addr); - if(H5F_addr_ne(fs_addr, fspace->addr)) + H5F_addr_decode(udata->f, &p, &fs_addr); + if(H5F_addr_ne(fs_addr, udata->fspace->addr)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "incorrect header address for free space sections") /* Check for any serialized sections */ - if(fspace->serial_sect_count > 0) { + if(udata->fspace->serial_sect_count > 0) { hsize_t old_tot_sect_count; /* Total section count from header */ hsize_t old_serial_sect_count; /* Total serializable section count from header */ hsize_t old_ghost_sect_count; /* Total ghost section count from header */ @@ -573,17 +574,17 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * unsigned sect_cnt_size; /* The size of the section size counts */ /* Compute the size of the section counts */ - sect_cnt_size = H5V_limit_enc_size((uint64_t)fspace->serial_sect_count); + sect_cnt_size = H5V_limit_enc_size((uint64_t)udata->fspace->serial_sect_count); /* Reset the section count, the "add" routine will update it */ - old_tot_sect_count = fspace->tot_sect_count; - old_serial_sect_count = fspace->serial_sect_count; - old_ghost_sect_count = fspace->ghost_sect_count; - old_tot_space = fspace->tot_space; - fspace->tot_sect_count = 0; - fspace->serial_sect_count = 0; - fspace->ghost_sect_count = 0; - fspace->tot_space = 0; + old_tot_sect_count = udata->fspace->tot_sect_count; + old_serial_sect_count = udata->fspace->serial_sect_count; + old_ghost_sect_count = udata->fspace->ghost_sect_count; + old_tot_space = udata->fspace->tot_space; + udata->fspace->tot_sect_count = 0; + udata->fspace->serial_sect_count = 0; + udata->fspace->ghost_sect_count = 0; + udata->fspace->tot_space = 0; /* Walk through the buffer, deserializing sections */ do { @@ -614,27 +615,27 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * /* Call 'deserialize' callback for this section */ des_flags = 0; - HDassert(fspace->sect_cls[sect_type].deserialize); - if(NULL == (new_sect = (*fspace->sect_cls[sect_type].deserialize)(&fspace->sect_cls[sect_type], dxpl_id, p, sect_addr, sect_size, &des_flags))) + HDassert(udata->fspace->sect_cls[sect_type].deserialize); + if(NULL == (new_sect = (*udata->fspace->sect_cls[sect_type].deserialize)(&udata->fspace->sect_cls[sect_type], udata->dxpl_id, p, sect_addr, sect_size, &des_flags))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDECODE