summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike McGreevy <mamcgree@hdfgroup.org>2008-06-27 14:18:39 (GMT)
committerMike McGreevy <mamcgree@hdfgroup.org>2008-06-27 14:18:39 (GMT)
commit5b7788f3ececa7efa6b91c4d0806e672ed724d14 (patch)
tree55a8851784231f321268ab8f61fc73177eb869cd /src
parent1bc53871cd54271844b30693aff7a41fa080b365 (diff)
downloadhdf5-5b7788f3ececa7efa6b91c4d0806e672ed724d14.zip
hdf5-5b7788f3ececa7efa6b91c4d0806e672ed724d14.tar.gz
hdf5-5b7788f3ececa7efa6b91c4d0806e672ed724d14.tar.bz2
[svn-r15285] Purpose: metadata cache client conversion
Description: converted the v2 b-tree header, internal node, and leaf node metadata cache clients over to use the new journaling cache callbacks. Tested: kagiso, smirom
Diffstat (limited to 'src')
-rw-r--r--src/H5B2.c309
-rw-r--r--src/H5B2cache.c930
-rw-r--r--src/H5B2dbg.c32
-rw-r--r--src/H5B2int.c356
-rw-r--r--src/H5B2pkg.h47
-rw-r--r--src/H5B2stat.c8
-rw-r--r--src/H5B2test.c26
7 files changed, 881 insertions, 827 deletions
diff --git a/src/H5B2.c b/src/H5B2.c
index 4b7d67c..3bb79ee 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -123,7 +123,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree header")
/* Assign internal information */
- HDmemset(&bt2->cache_info, 0, sizeof(H5AC_info_t));
+ HDmemset(&bt2->cache_info, 0, sizeof(H5AC2_info_t));
bt2->root.addr = HADDR_UNDEF;
bt2->root.node_nrec = 0;
bt2->root.all_nrec = 0;
@@ -137,13 +137,13 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree header")
/* Cache the new B-tree node */
- if(H5AC_set(f, dxpl_id, H5AC_BT2_HDR, *addr_p, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_set(f, dxpl_id, H5AC2_BT2_HDR, *addr_p, (size_t)H5B2_HEADER_SIZE(f), bt2, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree header to cache")
done:
if(ret_value < 0) {
if(bt2)
- (void)H5B2_cache_hdr_dest(f, bt2);
+ (void)H5B2_cache_hdr_dest(bt2);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -168,9 +168,10 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
void *udata)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */
- unsigned bt2_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for B-tree header */
+ unsigned bt2_flags = H5AC2__NO_FLAGS_SET; /* Metadata cache flags for B-tree header */
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_insert, FAIL)
@@ -179,8 +180,11 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(type);
HDassert(H5F_addr_defined(addr));
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the b-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -194,7 +198,7 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node")
/* Mark B-tree header as dirty, since we updated the address of the root node */
- bt2_flags |= H5AC__DIRTIED_FLAG;
+ bt2_flags |= H5AC2__DIRTIED_FLAG;
} /* end if */
/* Check if we need to split the root node (equiv. to a 1->2 node split) */
else if(bt2->root.node_nrec == shared->node_info[shared->depth].split_nrec) {
@@ -214,11 +218,11 @@ H5B2_insert(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
} /* end else */
/* Mark parent node as dirty */
- bt2_flags |= H5AC__DIRTIED_FLAG;
+ bt2_flags |= H5AC2__DIRTIED_FLAG;
done:
/* Release the B-tree header info */
- if(bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, bt2_flags) < 0)
+ if(bt2 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, bt2_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
FUNC_LEAVE_NOAPI(ret_value)
@@ -253,6 +257,7 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
H5B2_node_ptr_t root_ptr; /* Node pointer info for root node */
unsigned depth; /* Current depth of the tree */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_iterate, FAIL)
@@ -262,8 +267,11 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(H5F_addr_defined(addr));
HDassert(op);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_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 */
@@ -282,7 +290,7 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
depth = shared->depth;
/* Release header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
bt2 = NULL;
@@ -338,6 +346,8 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
int cmp; /* Comparison value of records */
unsigned idx; /* Location of record which matches key */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_find, FAIL)
@@ -346,8 +356,11 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(type);
HDassert(H5F_addr_defined(addr));
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_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 */
@@ -366,7 +379,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
depth = shared->depth;
/* Release header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
bt2 = NULL;
@@ -381,7 +394,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate node pointer for child */
@@ -394,7 +407,7 @@ H5B2_find(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(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -404,14 +417,14 @@ 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 (H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__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")
} /* end if */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_DONE(SUCCEED);
@@ -424,8 +437,12 @@ 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 */
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node_ptr.node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
+
/* 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)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate record */
@@ -433,7 +450,7 @@ H5B2_find(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(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__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,
@@ -450,7 +467,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_LEAF_NREC(leaf, shared, idx), op_data) < 0) {
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__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")
@@ -458,7 +475,7 @@ H5B2_find(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
} /* end else */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
} /* end block */
@@ -500,6 +517,8 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */
unsigned depth; /* Current depth of the tree */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_index, FAIL)
@@ -509,8 +528,11 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(H5F_addr_defined(addr));
HDassert(op);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_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 */
@@ -529,7 +551,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
depth = shared->depth;
/* Release header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
bt2 = NULL;
@@ -552,7 +574,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
unsigned u; /* Local index variable */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Search for record with correct index */
@@ -563,7 +585,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
next_node_ptr = internal->node_ptrs[u];
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -578,14 +600,14 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
/* Make callback for current record */
if((op)(H5B2_INT_NREC(internal, shared, u), 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(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__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")
} /* end if */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_DONE(SUCCEED);
@@ -605,7 +627,7 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
next_node_ptr = internal->node_ptrs[u];
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -623,8 +645,12 @@ 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 */
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node_ptr.node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
+
/* 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)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Sanity check index */
@@ -633,14 +659,14 @@ H5B2_index(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
/* Make callback for correct record */
if((op)(H5B2_LEAF_NREC(leaf, shared, idx), op_data) < 0) {
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__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")
} /* end if */
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
} /* end block */
@@ -671,9 +697,10 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
void *udata, H5B2_remove_t op, void *op_data)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */
- unsigned bt2_flags = H5AC__NO_FLAGS_SET;
+ unsigned bt2_flags = H5AC2__NO_FLAGS_SET;
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_remove, FAIL)
@@ -682,8 +709,11 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(type);
HDassert(H5F_addr_defined(addr));
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the b-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -724,11 +754,11 @@ H5B2_remove(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
bt2->root.all_nrec--;
/* Mark parent node as dirty */
- bt2_flags |= H5AC__DIRTIED_FLAG;
+ bt2_flags |= H5AC2__DIRTIED_FLAG;
done:
/* Release the B-tree header info */
- if (bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, bt2_flags) < 0)
+ if (bt2 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, bt2_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
FUNC_LEAVE_NOAPI(ret_value)
@@ -754,9 +784,10 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
void *op_data)
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */
- unsigned bt2_flags = H5AC__NO_FLAGS_SET;
+ unsigned bt2_flags = H5AC2__NO_FLAGS_SET;
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_remove_by_idx, FAIL)
@@ -765,8 +796,11 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
HDassert(type);
HDassert(H5F_addr_defined(addr));
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the b-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -815,11 +849,11 @@ H5B2_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
bt2->root.all_nrec--;
/* Mark parent node as dirty */
- bt2_flags |= H5AC__DIRTIED_FLAG;
+ bt2_flags |= H5AC2__DIRTIED_FLAG;
done:
/* Release the B-tree header info */
- if (bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, bt2_flags) < 0)
+ if (bt2 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, bt2_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
FUNC_LEAVE_NOAPI(ret_value)
@@ -845,6 +879,7 @@ H5B2_get_nrec(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 */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_get_nrec, FAIL)
@@ -854,8 +889,11 @@ H5B2_get_nrec(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(H5F_addr_defined(addr));
HDassert(nrec);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if (NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if (NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get B-tree number of records */
@@ -863,7 +901,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 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__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 +940,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 */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_neighbor, FAIL)
@@ -911,8 +950,11 @@ H5B2_neighbor(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(H5F_addr_defined(addr));
HDassert(op);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -935,7 +977,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 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__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 +1013,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 */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_delete, FAIL)
@@ -979,8 +1022,11 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(type);
HDassert(H5F_addr_defined(addr));
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_WRITE)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -998,7 +1044,7 @@ H5B2_delete(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__DELETED_FLAG) < 0)
+ if(bt2 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__DELETED_FLAG) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to delete B-tree header info")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1038,6 +1084,8 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
int cmp; /* Comparison value of records */
unsigned idx; /* Location of record which matches key */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_modify, FAIL)
@@ -1047,12 +1095,16 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
HDassert(H5F_addr_defined(addr));
HDassert(op);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_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;
+ HDassert(bt2_shared);
H5RC_INC(bt2_shared);
incr_rc = TRUE;
@@ -1067,7 +1119,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
depth = shared->depth;
/* Release header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
bt2 = NULL;
@@ -1078,12 +1130,12 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
/* Walk down B-tree to find record or leaf node where record is located */
cmp = -1;
while(depth > 0 && cmp != 0) {
- unsigned internal_flags = H5AC__NO_FLAGS_SET;
+ unsigned internal_flags = H5AC2__NO_FLAGS_SET;
H5B2_internal_t *internal; /* Pointer to internal node in B-tree */
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate node pointer for child */
@@ -1096,7 +1148,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 (H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -1111,17 +1163,17 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
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 (H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__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")
} /* end if */
/* Mark the node as dirty if it changed */
- internal_flags |= changed ? H5AC__DIRTIED_FLAG : 0;
+ internal_flags |= changed ? H5AC2__DIRTIED_FLAG : 0;
/* Unlock current node */
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, internal_flags) < 0)
+ if (H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr,(size_t)0, internal, internal_flags) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
HGOTO_DONE(SUCCEED);
@@ -1132,12 +1184,16 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
} /* end while */
{
- unsigned leaf_flags = H5AC__NO_FLAGS_SET;
+ unsigned leaf_flags = H5AC2__NO_FLAGS_SET;
H5B2_leaf_t *leaf; /* Pointer to leaf node in B-tree */
hbool_t changed = FALSE;/* Whether the 'modify' callback changed the record */
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node_ptr.node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
+
/* 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)))
+ if (NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate record */
@@ -1145,7 +1201,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 (H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__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,
@@ -1165,7 +1221,7 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
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 (H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__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")
@@ -1173,10 +1229,10 @@ H5B2_modify(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
} /* end else */
/* Mark the node as dirty if it changed */
- leaf_flags |= (changed ? H5AC__DIRTIED_FLAG : 0);
+ leaf_flags |= (changed ? H5AC2__DIRTIED_FLAG : 0);
/* Unlock current node */
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0)
+ if (H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, leaf_flags) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
}
@@ -1212,6 +1268,7 @@ H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add
H5B2_node_ptr_t root_ptr; /* Node pointer info for root node */
unsigned depth; /* Current depth of the tree */
herr_t ret_value = SUCCEED;
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_iterate_size, FAIL)
@@ -1221,8 +1278,11 @@ H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add
HDassert(H5F_addr_defined(addr));
HDassert(btree_size);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_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 */
@@ -1244,7 +1304,7 @@ H5B2_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t add
depth = shared->depth;
/* Release header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
bt2 = NULL;
@@ -1267,3 +1327,132 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5B2_iterate_size() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_cache_hdr_dest
+ *
+ * Purpose: Destroys a B-tree header in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 1 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+herr_t
+H5B2_cache_hdr_dest(H5B2_t *bt2)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_hdr_dest)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(bt2);
+
+ /* Decrement reference count on shared B-tree info */
+ if(bt2->shared)
+ H5RC_DEC(bt2->shared);
+
+ /* Free B-tree header info */
+ H5FL_FREE(H5B2_t, bt2);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5B2_cache_hdr_dest() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_cache_internal_dest
+ *
+ * Purpose: Destroys a B-tree internal node in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 2 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+herr_t
+H5B2_cache_internal_dest(H5B2_internal_t *internal)
+{
+ H5B2_shared_t *shared; /* Shared B-tree information */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_internal_dest)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(internal);
+
+ /* Get the pointer to the shared B-tree info */
+ shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
+ HDassert(shared);
+
+ /* Release internal node's native key buffer */
+ if(internal->int_native)
+ H5FL_FAC_FREE(shared->node_info[internal->depth].nat_rec_fac, internal->int_native);
+
+ /* Release internal node's node pointer buffer */
+ if(internal->node_ptrs)
+ H5FL_FAC_FREE(shared->node_info[internal->depth].node_ptr_fac, internal->node_ptrs);
+
+ /* Decrement reference count on shared B-tree info */
+ if(internal->shared)
+ H5RC_DEC(internal->shared);
+
+ /* Free B-tree internal node info */
+ H5FL_FREE(H5B2_internal_t, internal);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5B2_cache_internal_dest() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5B2_cache_leaf_dest
+ *
+ * Purpose: Destroys a B-tree leaf node in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 2 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+herr_t
+H5B2_cache_leaf_dest(H5B2_leaf_t *leaf)
+{
+ H5B2_shared_t *shared; /* Shared B-tree information */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_leaf_dest)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(leaf);
+
+ /* Get the pointer to the shared B-tree info */
+ shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
+ HDassert(shared);
+
+ /* Release leaf's native key buffer */
+ if(leaf->leaf_native)
+ H5FL_FAC_FREE(shared->node_info[0].nat_rec_fac, leaf->leaf_native);
+
+ /* Decrement reference count on shared B-tree info */
+ if(leaf->shared)
+ H5RC_DEC(leaf->shared);
+
+ /* Free B-tree leaf node info */
+ H5FL_FREE(H5B2_leaf_t,leaf);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5B2_cache_leaf_dest() */
+
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index d8679aa..fc24f00 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -67,51 +67,65 @@
/********************/
/* 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 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_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 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_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 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_clear(H5F_t *f, H5B2_leaf_t *l, hbool_t destroy);
-static herr_t H5B2_cache_leaf_size(const H5F_t *f, const H5B2_leaf_t *l, size_t *size_ptr);
+static void *H5B2_cache_hdr_deserialize(haddr_t addr, size_t len,
+ const void *image, const void *udata, hbool_t *dirty);
+static herr_t H5B2_cache_hdr_serialize(const H5F_t *f, haddr_t addr, size_t len,
+ void *image, void *thing, unsigned *flags, haddr_t *new_addr,
+ size_t *new_len, void **new_image);
+static herr_t H5B2_cache_hdr_free_icr(haddr_t addr, size_t len, void *thing);
+
+static void *H5B2_cache_internal_deserialize(haddr_t addr, size_t len,
+ const void *image, const void *udata, hbool_t *dirty);
+static herr_t H5B2_cache_internal_serialize(const H5F_t *f, haddr_t addr, size_t len,
+ void *image, void *thing, unsigned *flags, haddr_t *new_addr,
+ size_t *new_len, void **new_image);
+static herr_t H5B2_cache_internal_free_icr(haddr_t addr, size_t len, void *thing);
+
+static void *H5B2_cache_leaf_deserialize(haddr_t addr, size_t len,
+ const void *image, const void *udata, hbool_t *dirty);
+static herr_t H5B2_cache_leaf_serialize(const H5F_t *f, haddr_t addr, size_t len,
+ void *image, void *thing, unsigned *flags, haddr_t *new_addr,
+ size_t *new_len, void **new_image);
+static herr_t H5B2_cache_leaf_free_icr(haddr_t addr, size_t len, void *thing);
/*********************/
/* Package Variables */
/*********************/
-/* H5B2 inherits cache-like properties from H5AC */
-const H5AC_class_t H5AC_BT2_HDR[1] = {{
- H5AC_BT2_HDR_ID,
- (H5AC_load_func_t)H5B2_cache_hdr_load,
- (H5AC_flush_func_t)H5B2_cache_hdr_flush,
- (H5AC_dest_func_t)H5B2_cache_hdr_dest,
- (H5AC_clear_func_t)H5B2_cache_hdr_clear,
- (H5AC_size_func_t)H5B2_cache_hdr_size,
+/* H5B2 inherits cache-like properties from H5AC2 */
+const H5AC2_class_t H5AC2_BT2_HDR[1] = {{
+ H5AC2_BT2_HDR_ID,
+ "v2 b-tree header",
+ H5FD_MEM_BTREE,
+ H5B2_cache_hdr_deserialize,
+ NULL,
+ H5B2_cache_hdr_serialize,
+ H5B2_cache_hdr_free_icr,
+ NULL,
}};
-/* H5B2 inherits cache-like properties from H5AC */
-const H5AC_class_t H5AC_BT2_INT[1] = {{
- H5AC_BT2_INT_ID,
- (H5AC_load_func_t)H5B2_cache_internal_load,
- (H5AC_flush_func_t)H5B2_cache_internal_flush,
- (H5AC_dest_func_t)H5B2_cache_internal_dest,
- (H5AC_clear_func_t)H5B2_cache_internal_clear,
- (H5AC_size_func_t)H5B2_cache_internal_size,
+/* H5B2 inherits cache-like properties from H5AC2 */
+const H5AC2_class_t H5AC2_BT2_INT[1] = {{
+ H5AC2_BT2_INT_ID,
+ "v2 b-tree internal node",
+ H5FD_MEM_BTREE,
+ H5B2_cache_internal_deserialize,
+ NULL,
+ H5B2_cache_internal_serialize,
+ H5B2_cache_internal_free_icr,
+ NULL,
}};
-/* H5B2 inherits cache-like properties from H5AC */
-const H5AC_class_t H5AC_BT2_LEAF[1] = {{
- H5AC_BT2_LEAF_ID,
- (H5AC_load_func_t)H5B2_cache_leaf_load,
- (H5AC_flush_func_t)H5B2_cache_leaf_flush,
- (H5AC_dest_func_t)H5B2_cache_leaf_dest,
- (H5AC_clear_func_t)H5B2_cache_leaf_clear,
- (H5AC_size_func_t)H5B2_cache_leaf_size,
+/* H5B2 inherits cache-like properties from H5AC2 */
+const H5AC2_class_t H5AC2_BT2_LEAF[1] = {{
+ H5AC2_BT2_LEAF_ID,
+ "v2 b-tree leaf node",
+ H5FD_MEM_BTREE,
+ H5B2_cache_leaf_deserialize,
+ NULL,
+ H5B2_cache_leaf_serialize,
+ H5B2_cache_leaf_free_icr,
+ NULL,
}};
/*****************************/
@@ -126,7 +140,7 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_hdr_load
+ * Function: H5B2_cache_hdr_deserialize
*
* Purpose: Loads a B-tree header from the disk.
*
@@ -138,12 +152,18 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{
* koziol@ncsa.uiuc.edu
* Feb 1 2005
*
+ * Changes: Mike McGreevy
+ * mcgreevy@hdfgroup.prg
+ * June 18, 2008
+ * Converted from H5B2_cache_hdr_load
+ *
*-------------------------------------------------------------------------
*/
-static H5B2_t *
-H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void UNUSED *udata)
+static void *
+H5B2_cache_hdr_deserialize(haddr_t UNUSED addr, size_t UNUSED len,
+ const void *image, const void *_udata, hbool_t UNUSED *dirty)
{
- const H5B2_class_t *type = (const H5B2_class_t *) _type; /* Type of B-tree */
+ const H5B2_hdr_cache_ud_t *udata = (const 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 */
@@ -151,41 +171,24 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo
size_t size; /* Header size */
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
- H5WB_t *wb = NULL; /* Wrapped buffer for header data */
- uint8_t hdr_buf[H5B2_HDR_BUF_SIZE]; /* Buffer for header */
- uint8_t *hdr; /* Pointer to header buffer */
uint8_t *p; /* Pointer into raw data buffer */
H5B2_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5B2_cache_hdr_load, NULL)
+ FUNC_ENTER_NOAPI(H5B2_cache_hdr_deserialize, NULL)
/* Check arguments */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(type);
+ HDassert(image);
/* Allocate space for the B-tree data structure */
if(NULL == (bt2 = H5FL_MALLOC(H5B2_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemset(&bt2->cache_info, 0, sizeof(H5AC_info_t));
-
- /* Wrap the local buffer for serialized header info */
- if(NULL == (wb = H5WB_wrap(hdr_buf, sizeof(hdr_buf))))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't wrap buffer")
+ HDmemset(&bt2->cache_info, 0, sizeof(H5AC2_info_t));
/* Compute the size of the serialized B-tree header on disk */
- size = H5B2_HEADER_SIZE(f);
-
- /* Get a pointer to a buffer that's large enough for header */
- if(NULL == (hdr = H5WB_actual(wb, size)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "can't get actual buffer")
-
- /* Read header from disk */
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, hdr) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree header")
+ size = H5B2_HEADER_SIZE(udata->f);
/* Get temporary pointer to serialized header */
- p = hdr;
+ p = image;
/* Magic number */
if(HDmemcmp(p, H5B2_HDR_MAGIC, (size_t)H5B2_SIZEOF_MAGIC))
@@ -197,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) */
@@ -214,43 +217,40 @@ 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);
- /* Sanity check */
- HDassert((size_t)(p - hdr) == size);
-
/* Compute checksum on entire header */
- computed_chksum = H5_checksum_metadata(hdr, (size - H5B2_SIZEOF_CHKSUM), 0);
+ computed_chksum = H5_checksum_metadata(image, (size - H5B2_SIZEOF_CHKSUM), 0);
/* Verify checksum */
if(stored_chksum != computed_chksum)
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")
+ /* Sanity check */
+ HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len);
+
/* Set return value */
ret_value = bt2;
done:
- /* Release resources */
- if(wb && H5WB_unwrap(wb) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
if(!ret_value && bt2)
- (void)H5B2_cache_hdr_dest(f, bt2);
+ (void)H5B2_cache_hdr_dest(bt2);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */
+} /* end H5B2_cache_hdr_deserialize() */ /*lint !e818 Can't make udata a pointer to const */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_hdr_flush
+ * Function: H5B2_cache_hdr_serialize
*
* Purpose: Flushes a dirty B-tree header to disk.
*
@@ -265,224 +265,141 @@ done:
* entry is resized or renamed as a result of the flush.
* *flags_ptr is set to H5C_CALLBACK__NO_FLAGS_SET on entry.
*
+ * Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
+ * Converted from H5B2_cache_hdr_flush
+ *
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_t *bt2, unsigned UNUSED * flags_ptr)
+H5B2_cache_hdr_serialize(const H5F_t *f, haddr_t UNUSED addr, size_t UNUSED len,
+ void *image, void *_thing, unsigned *flags, haddr_t UNUSED *new_addr,
+ size_t UNUSED *new_len, void UNUSED **new_image)
{
- H5WB_t *wb = NULL; /* Wrapped buffer for header data */
- uint8_t hdr_buf[H5B2_HDR_BUF_SIZE]; /* Buffer for header */
+ H5B2_t *bt2 = (H5B2_t *)_thing; /* Pointer to the b-tree header */
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_shared_t *shared; /* Shared B-tree information */
+ uint8_t *p; /* Pointer into raw data buffer */
+ size_t size; /* Header size on disk */
+ uint32_t metadata_chksum; /* Computed metadata checksum value */
- FUNC_ENTER_NOAPI(H5B2_cache_hdr_flush, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_cache_hdr_serialize, FAIL)
/* check arguments */
HDassert(f);
- HDassert(H5F_addr_defined(addr));
+ HDassert(image);
HDassert(bt2);
+ HDassert(flags);
- if (bt2->cache_info.is_dirty) {
- H5B2_shared_t *shared; /* Shared B-tree information */
- uint8_t *hdr; /* Pointer to header buffer */
- uint8_t *p; /* Pointer into raw data buffer */
- size_t size; /* Header size on disk */
- uint32_t metadata_chksum; /* Computed metadata checksum value */
-
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2->shared);
- HDassert(shared);
-
- /* Wrap the local buffer for serialized header info */
- if(NULL == (wb = H5WB_wrap(hdr_buf, sizeof(hdr_buf))))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't wrap buffer")
-
- /* Compute the size of the serialized B-tree header on disk */
- size = H5B2_HEADER_SIZE(f);
-
- /* Get a pointer to a buffer that's large enough for header */
- if(NULL == (hdr = H5WB_actual(wb, size)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "can't get actual buffer")
-
- /* Get temporary pointer to serialized header */
- p = hdr;
-
- /* Magic number */
- HDmemcpy(p, H5B2_HDR_MAGIC, (size_t)H5B2_SIZEOF_MAGIC);
- p += H5B2_SIZEOF_MAGIC;
-
- /* Version # */
- *p++ = H5B2_HDR_VERSION;
-
- /* B-tree type */
- *p++ = shared->type->id;
-
- /* Node size (in bytes) */
- UINT32ENCODE(p, shared->node_size);
-
- /* Raw key size (in bytes) */
- UINT16ENCODE(p, shared->rrec_size);
-
- /* Depth of tree */
- UINT16ENCODE(p, shared->depth);
-
- /* Split & merge %s */
- *p++ = shared->split_percent;
- *p++ = shared->merge_percent;
-
- /* Root node pointer */
- H5F_addr_encode(f, &p, bt2->root.addr);
- UINT16ENCODE(p, bt2->root.node_nrec);
- H5F_ENCODE_LENGTH(f, p, bt2->root.all_nrec);
-
- /* Compute metadata checksum */
- metadata_chksum = H5_checksum_metadata(hdr, (size - H5B2_SIZEOF_CHKSUM), 0);
-
- /* Metadata checksum */
- UINT32ENCODE(p, metadata_chksum);
-
- /* Write the B-tree header. */
- HDassert((size_t)(p - hdr) == size);
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, hdr) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree header to disk")
+ /* Get the pointer to the shared B-tree info */
+ shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2->shared);
+ HDassert(shared);
- bt2->cache_info.is_dirty = FALSE;
- } /* end if */
+ /* Compute the size of the serialized B-tree header on disk */
+ size = H5B2_HEADER_SIZE(f);
- if(destroy)
- if(H5B2_cache_hdr_dest(f, bt2) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header")
+ /* Get temporary pointer to serialized header */
+ p = image;
-done:
- /* Release resources */
- if(wb && H5WB_unwrap(wb) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer")
+ /* Magic number */
+ HDmemcpy(p, H5B2_HDR_MAGIC, (size_t)H5B2_SIZEOF_MAGIC);
+ p += H5B2_SIZEOF_MAGIC;
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_cache_hdr_flush() */
+ /* Version # */
+ *p++ = H5B2_HDR_VERSION;
-
-/*-------------------------------------------------------------------------
- * Function: H5B2_cache_hdr_dest
- *
- * Purpose: Destroys a B-tree header in memory.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 1 2005
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-herr_t
-H5B2_cache_hdr_dest(H5F_t UNUSED *f, H5B2_t *bt2)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_hdr_dest)
+ /* B-tree type */
+ *p++ = shared->type->id;
- /*
- * Check arguments.
- */
- HDassert(bt2);
+ /* Node size (in bytes) */
+ UINT32ENCODE(p, shared->node_size);
- /* Decrement reference count on shared B-tree info */
- if(bt2->shared)
- H5RC_DEC(bt2->shared);
+ /* Raw key size (in bytes) */
+ UINT16ENCODE(p, shared->rrec_size);
- /* Free B-tree header info */
- H5FL_FREE(H5B2_t, bt2);
+ /* Depth of tree */
+ UINT16ENCODE(p, shared->depth);
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5B2_cache_hdr_dest() */
+ /* Split & merge %s */
+ *p++ = shared->split_percent;
+ *p++ = shared->merge_percent;
-
-/*-------------------------------------------------------------------------
- * Function: H5B2_cache_hdr_clear
- *
- * Purpose: Mark a B-tree header in memory as non-dirty.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 1 2005
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *bt2, hbool_t destroy)
-{
- herr_t ret_value = SUCCEED; /* Return value */
+ /* Root node pointer */
+ H5F_addr_encode(f, &p, bt2->root.addr);
+ UINT16ENCODE(p, bt2->root.node_nrec);
+ H5F_ENCODE_LENGTH(f, p, bt2->root.all_nrec);
- FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_hdr_clear)
+ /* Compute metadata checksum */
+ metadata_chksum = H5_checksum_metadata(image, (size - H5B2_SIZEOF_CHKSUM), 0);
- /*
- * Check arguments.
- */
- HDassert(bt2);
+ /* Metadata checksum */
+ UINT32ENCODE(p, metadata_chksum);
- /* Reset the dirty flag. */
- bt2->cache_info.is_dirty = FALSE;
+ /* Reset the cache flags for this operation */
+ *flags = 0;
- if(destroy)
- if(H5B2_cache_hdr_dest(f, bt2) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header")
+ /* Sanity check */
+ HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_cache_hdr_clear() */
+} /* H5B2_cache_hdr_serialize() */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_hdr_size
+ * Function: H5B2_cache_hdr_free_icr
*
- * Purpose: Compute the size in bytes of a B-tree header
- * on disk, and return it in *size_ptr. On failure,
- * the value of *size_ptr is undefined.
+ * Purpose: Destroy/release an "in core representation" of a data
+ * structure
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 1 2005
+ * Programmer: Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t UNUSED *bt2, size_t *size_ptr)
+H5B2_cache_hdr_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_hdr_size)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_hdr_free_icr)
- /* check arguments */
- HDassert(f);
- HDassert(size_ptr);
+ /* Check arguments */
+ HDassert(thing);
- /* Set size value */
- *size_ptr = H5B2_HEADER_SIZE(f);
+ /* Destroy v2 b-tree header */
+ H5B2_cache_hdr_dest(thing);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5B2_cache_hdr_size() */
+} /* H5B2_cache_hdr_free_icr() */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_internal_load
+ * Function: H5B2_cache_internal_deserialize
*
- * Purpose: Loads a B-tree internal node from the disk.
+ * Purpose: Deserialize a B-tree internal node from the disk.
*
* Return: Success: Pointer to a new B-tree internal node.
- *
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
* Feb 2 2005
*
+ * Changes: Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
+ * Converted from H5B2_cache_internal_load
+ *
*-------------------------------------------------------------------------
*/
-static H5B2_internal_t *
-H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata, void UNUSED *udata2)
+static void *
+H5B2_cache_internal_deserialize(haddr_t UNUSED addr, size_t UNUSED len,
+ const void *image, const void *_udata, hbool_t UNUSED *dirty)
{
- const H5B2_int_load_ud1_t *udata = (const H5B2_int_load_ud1_t *)_udata; /* Pointer to user data */
H5B2_shared_t *shared; /* Shared B-tree information */
H5B2_internal_t *internal = NULL; /* Internal node read */
uint8_t *p; /* Pointer into raw data buffer */
@@ -492,18 +409,18 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
uint32_t computed_chksum; /* Computed metadata checksum value */
unsigned u; /* Local index variable */
H5B2_internal_t *ret_value; /* Return value */
+ const H5B2_internal_cache_ud_t *udata = (const H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */
- FUNC_ENTER_NOAPI(H5B2_cache_internal_load, NULL)
+ FUNC_ENTER_NOAPI(H5B2_cache_internal_deserialize, NULL)
/* Check arguments */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
+ HDassert(image);
HDassert(udata);
/* Allocate new internal node and reset cache info */
if(NULL == (internal = H5FL_MALLOC(H5B2_internal_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemset(&internal->cache_info, 0, sizeof(H5AC_info_t));
+ HDmemset(&internal->cache_info, 0, sizeof(H5AC2_info_t));
/* Share common B-tree information */
internal->shared = udata->bt2_shared;
@@ -513,11 +430,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
HDassert(shared);
- /* Read header from disk */
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page)<0)
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree internal node")
-
- p = shared->page;
+ p = image;
/* Magic number */
if(HDmemcmp(p, H5B2_INT_MAGIC, (size_t)H5B2_SIZEOF_MAGIC))
@@ -548,7 +461,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 */
@@ -560,7 +473,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)
@@ -572,13 +485,13 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
} /* end for */
/* Compute checksum on internal node */
- computed_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
+ computed_chksum = H5_checksum_metadata(image, (size_t)(p - (const uint8_t *)image), 0);
/* Metadata checksum */
UINT32DECODE(p, stored_chksum);
/* Sanity check parsing */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
+ HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len);
/* Verify checksum */
if(stored_chksum != computed_chksum)
@@ -589,17 +502,18 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
done:
if(!ret_value && internal)
- (void)H5B2_cache_internal_dest(f, internal);
+ (void)H5B2_cache_internal_dest(internal);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_cache_internal_load() */ /*lint !e818 Can't make udata a pointer to const */
+} /* H5B2_cache_internal_deserialize() */ /*lint !e818 Can't make udata a pointer to const */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_internal_flush
+ * Function: H5B2_cache_internal_serialize
*
- * Purpose: Flushes a dirty B-tree internal node to disk.
+ * Purpose: Serializes a B-tree internal node for writing to disk.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
@@ -610,236 +524,147 @@ done:
* entry is resized or renamed as a result of the flush.
* *flags_ptr is set to H5C_CALLBACK__NO_FLAGS_SET on entry.
*
+ * Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
+ * Converted from H5B2_cache_internal_flush
+ *
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_internal_t *internal, unsigned UNUSED * flags_ptr)
+H5B2_cache_internal_serialize(const H5F_t *f, haddr_t UNUSED addr,
+ size_t UNUSED len, void *image, void *_thing, unsigned *flags,
+ haddr_t UNUSED *new_addr, size_t UNUSED *new_len, void UNUSED **new_image)
{
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_shared_t *shared; /* Shared B-tree information */
+ uint8_t *p; /* Pointer into raw data buffer */
+ uint8_t *native; /* Pointer to native record info */
+ H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */
+ uint32_t metadata_chksum; /* Computed metadata checksum value */
+ unsigned u; /* Local index variable */
+ H5B2_internal_t *internal = (H5B2_internal_t *)_thing; /* Pointer to the b-tree internal node */
- FUNC_ENTER_NOAPI(H5B2_cache_internal_flush, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_cache_internal_serialize, FAIL)
/* check arguments */
HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(internal);
-
- if(internal->cache_info.is_dirty) {
- H5B2_shared_t *shared; /* Shared B-tree information */
- uint8_t *p; /* Pointer into raw data buffer */
- uint8_t *native; /* Pointer to native record info */
- H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */
- uint32_t metadata_chksum; /* Computed metadata checksum value */
- unsigned u; /* Local index variable */
-
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
- HDassert(shared);
-
- p = shared->page;
-
- /* Magic number */
- HDmemcpy(p, H5B2_INT_MAGIC, (size_t)H5B2_SIZEOF_MAGIC);
- p += H5B2_SIZEOF_MAGIC;
-
- /* Version # */
- *p++ = H5B2_INT_VERSION;
-
- /* B-tree type */
- *p++ = shared->type->id;
- HDassert((size_t)(p - shared->page) == (H5B2_INT_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
-
- /* Serialize records for internal node */
- native = internal->int_native;
- for(u = 0; u < internal->nrec; u++) {
- /* Encode record */
- if((shared->type->encode)(f, p, native) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
-
- /* Move to next record */
- p += shared->rrec_size;
- native += shared->type->nrec_size;
- } /* end for */
-
- /* Serialize node pointers for internal node */
- int_node_ptr = internal->node_ptrs;
- for(u = 0; u < internal->nrec + 1; u++) {
- /* Encode node pointer */
- H5F_addr_encode(f, &p, int_node_ptr->addr);
- UINT64ENCODE_VAR(p, int_node_ptr->node_nrec, shared->max_nrec_size);
- if(internal->depth > 1)
- UINT64ENCODE_VAR(p, int_node_ptr->all_nrec, shared->node_info[internal->depth - 1].cum_max_nrec_size);
-
- /* Move to next node pointer */
- int_node_ptr++;
- } /* end for */
-
- /* Compute metadata checksum */
- metadata_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
-
- /* Metadata checksum */
- UINT32ENCODE(p, metadata_chksum);
-
- /* Write the B-tree internal node */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree internal node to disk")
-
- internal->cache_info.is_dirty = FALSE;
- } /* end if */
-
- if(destroy)
- if(H5B2_cache_internal_dest(f, internal) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_cache_internal_flush() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5B2_cache_internal_dest
- *
- * Purpose: Destroys a B-tree internal node in memory.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 2 2005
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-herr_t
-H5B2_cache_internal_dest(H5F_t UNUSED *f, H5B2_internal_t *internal)
-{
- H5B2_shared_t *shared; /* Shared B-tree information */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_internal_dest)
-
- /*
- * Check arguments.
- */
+ HDassert(image);
HDassert(internal);
+ HDassert(flags);
/* Get the pointer to the shared B-tree info */
shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
HDassert(shared);
- /* Release internal node's native key buffer */
- if(internal->int_native)
- H5FL_FAC_FREE(shared->node_info[internal->depth].nat_rec_fac, internal->int_native);
+ p = image;
- /* Release internal node's node pointer buffer */
- if(internal->node_ptrs)
- H5FL_FAC_FREE(shared->node_info[internal->depth].node_ptr_fac, internal->node_ptrs);
+ /* Magic number */
+ HDmemcpy(p, H5B2_INT_MAGIC, (size_t)H5B2_SIZEOF_MAGIC);
+ p += H5B2_SIZEOF_MAGIC;
- /* Decrement reference count on shared B-tree info */
- if(internal->shared)
- H5RC_DEC(internal->shared);
+ /* Version # */
+ *p++ = H5B2_INT_VERSION;
- /* Free B-tree internal node info */
- H5FL_FREE(H5B2_internal_t, internal);
+ /* B-tree type */
+ *p++ = shared->type->id;
+ HDassert((size_t)(p - (const uint8_t *)image) == (H5B2_INT_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5B2_cache_internal_dest() */
+ /* Serialize records for internal node */
+ native = internal->int_native;
+ for(u = 0; u < internal->nrec; u++) {
+ /* Encode record */
+ if((shared->type->encode)(f, p, native) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
-
-/*-------------------------------------------------------------------------
- * Function: H5B2_cache_internal_clear
- *
- * Purpose: Mark a B-tree internal node in memory as non-dirty.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 2 2005
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *internal, hbool_t destroy)
-{
- herr_t ret_value = SUCCEED;
+ /* Move to next record */
+ p += shared->rrec_size;
+ native += shared->type->nrec_size;
+ } /* end for */
- FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_internal_clear)
+ /* Serialize node pointers for internal node */
+ int_node_ptr = internal->node_ptrs;
+ for(u = 0; u < internal->nrec + 1; u++) {
+ /* Encode node pointer */
+ H5F_addr_encode(f, &p, int_node_ptr->addr);
+ UINT64ENCODE_VAR(p, int_node_ptr->node_nrec, shared->max_nrec_size);
+ if(internal->depth > 1)
+ UINT64ENCODE_VAR(p, int_node_ptr->all_nrec, shared->node_info[internal->depth - 1].cum_max_nrec_size);
- /*
- * Check arguments.
- */
- HDassert(internal);
+ /* Move to next node pointer */
+ int_node_ptr++;
+ } /* end for */
+
+ /* Compute metadata checksum */
+ metadata_chksum = H5_checksum_metadata(image, (size_t)(p - (const uint8_t *)image), 0);
+
+ /* Metadata checksum */
+ UINT32ENCODE(p, metadata_chksum);
- /* Reset the dirty flag. */
- internal->cache_info.is_dirty = FALSE;
+ /* Reset the cache flags for this operation */
+ *flags = 0;
- if(destroy)
- if(H5B2_cache_internal_dest(f, internal) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node")
+ /* Sanity check */
+ HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_cache_internal_clear() */
+} /* H5B2_cache_internal_serialize() */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_internal_size
+ * Function: H5B2_cache_internal_free_icr
*
- * Purpose: Compute the size in bytes of a B-tree internal node
- * on disk, and return it in *size_ptr. On failure,
- * the value of *size_ptr is undefined.
+ * Purpose: Destroy/release an "in core representation" of a data
+ * structure
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 2 2005
+ * Programmer: Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal, size_t *size_ptr)
+H5B2_cache_internal_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing)
{
- H5B2_shared_t *shared; /* Shared B-tree information */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_internal_size)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_internal_free_icr)
- /* check arguments */
- HDassert(internal);
- HDassert(size_ptr);
-
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
- HDassert(shared);
+ /* Check arguments */
+ HDassert(thing);
- /* Set size value */
- *size_ptr = shared->node_size;
+ /* Destroy v2 b-tree header */
+ H5B2_cache_internal_dest(thing);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5B2_cache_internal_size() */
+} /* H5B2_cache_internal_free_icr() */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_leaf_load
+ * Function: H5B2_cache_leaf_deserialize
*
- * Purpose: Loads a B-tree leaf from the disk.
+ * Purpose: Deserialize a B-tree leaf from the disk.
*
* Return: Success: Pointer to a new B-tree leaf node.
- *
* Failure: NULL
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
* Feb 2 2005
*
+ * Changes: Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
+ * Converted from H5B2_cache_leaf_load
+ *
*-------------------------------------------------------------------------
*/
-static H5B2_leaf_t *
-H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_bt2_shared)
+static void *
+H5B2_cache_leaf_deserialize(haddr_t UNUSED addr, size_t UNUSED len,
+ const void *image, const void *_udata, hbool_t UNUSED *dirty)
{
- const unsigned *nrec = (const unsigned *)_nrec;
- H5RC_t *bt2_shared = (H5RC_t *)_bt2_shared; /* Shared B-tree information */
H5B2_shared_t *shared; /* Shared B-tree information */
H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */
uint8_t *p; /* Pointer into raw data buffer */
@@ -848,31 +673,26 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
uint32_t computed_chksum; /* Computed metadata checksum value */
unsigned u; /* Local index variable */
H5B2_leaf_t *ret_value; /* Return value */
+ const H5B2_leaf_cache_ud_t *udata = (const H5B2_leaf_cache_ud_t *)_udata;
- FUNC_ENTER_NOAPI(H5B2_cache_leaf_load, NULL)
+ FUNC_ENTER_NOAPI(H5B2_cache_leaf_deserialize, NULL)
/* Check arguments */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(bt2_shared);
+ HDassert(image);
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));
+ HDmemset(&leaf->cache_info, 0, sizeof(H5AC2_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 */
shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
HDassert(shared);
- /* Read header from disk */
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree leaf node")
-
- p = shared->page;
+ p = image;
/* Magic number */
if(HDmemcmp(p, H5B2_LEAF_MAGIC, (size_t)H5B2_SIZEOF_MAGIC))
@@ -892,13 +712,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 */
@@ -907,34 +727,38 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
} /* end for */
/* Compute checksum on internal node */
- computed_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
+ computed_chksum = H5_checksum_metadata(image, (size_t)(p - (const uint8_t *)image), 0);
/* Metadata checksum */
UINT32DECODE(p, stored_chksum);
/* Sanity check parsing */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
+ HDassert((size_t)(p - (const uint8_t *)image) <= shared->node_size);
/* Verify checksum */
if(stored_chksum != computed_chksum)
HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 leaf node")
+ /* Sanity check */
+ HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len);
+
/* Set return value */
ret_value = leaf;
done:
if(!ret_value && leaf)
- (void)H5B2_cache_leaf_dest(f,leaf);
+ (void)H5B2_cache_leaf_dest(leaf);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_cache_leaf_load() */ /*lint !e818 Can't make udata a pointer to const */
+} /* H5B2_cache_leaf_deserialize() */ /*lint !e818 Can't make udata a pointer to const */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_leaf_flush
+ * Function: H5B2_cache_leaf_serialize
*
- * Purpose: Flushes a dirty B-tree leaf node to disk.
+ * Purpose: Serializes a B-tree leaf node for writing to disk.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
@@ -946,195 +770,105 @@ done:
* entry is resized or renamed as a result of the flush.
* *flags_ptr is set to H5C_CALLBACK__NO_FLAGS_SET on entry.
*
+ * Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
+ * Converted from H5B2_cache_leaf_flush
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_leaf_t *leaf, unsigned UNUSED * flags_ptr)
+H5B2_cache_leaf_serialize(const H5F_t *f, haddr_t UNUSED addr, size_t UNUSED len,
+ void *image, void *_thing, unsigned *flags, haddr_t UNUSED *new_addr,
+ size_t UNUSED *new_len, void UNUSED **new_image)
{
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_shared_t *shared; /* Shared B-tree information */
+ uint8_t *p; /* Pointer into raw data buffer */
+ uint8_t *native; /* Pointer to native keys */
+ uint32_t metadata_chksum; /* Computed metadata checksum value */
+ unsigned u; /* Local index variable */
+ H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; /* Pointer to the b-tree leaf node */
- FUNC_ENTER_NOAPI(H5B2_cache_leaf_flush, FAIL)
+ FUNC_ENTER_NOAPI(H5B2_cache_leaf_serialize, FAIL)
/* check arguments */
HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(leaf);
-
- if(leaf->cache_info.is_dirty) {
- H5B2_shared_t *shared; /* Shared B-tree information */
- uint8_t *p; /* Pointer into raw data buffer */
- uint8_t *native; /* Pointer to native keys */
- uint32_t metadata_chksum; /* Computed metadata checksum value */
- unsigned u; /* Local index variable */
-
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
- HDassert(shared);
-
- p = shared->page;
-
- /* magic number */
- HDmemcpy(p, H5B2_LEAF_MAGIC, (size_t)H5B2_SIZEOF_MAGIC);
- p += H5B2_SIZEOF_MAGIC;
-
- /* version # */
- *p++ = H5B2_LEAF_VERSION;
-
- /* b-tree type */
- *p++ = shared->type->id;
- HDassert((size_t)(p - shared->page) == (H5B2_LEAF_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
-
- /* Serialize records for leaf node */
- native = leaf->leaf_native;
- for(u = 0; u < leaf->nrec; u++) {
- /* Encode record */
- if((shared->type->encode)(f, p, native) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
-
- /* Move to next record */
- p += shared->rrec_size;
- native += shared->type->nrec_size;
- } /* end for */
-
- /* Compute metadata checksum */
- metadata_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
-
- /* Metadata checksum */
- UINT32ENCODE(p, metadata_chksum);
-
- /* Write the B-tree leaf node */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree leaf node to disk")
-
- leaf->cache_info.is_dirty = FALSE;
- } /* end if */
-
- if(destroy)
- if(H5B2_cache_leaf_dest(f, leaf) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B2_cache_leaf_flush() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5B2_cache_leaf_dest
- *
- * Purpose: Destroys a B-tree leaf node in memory.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 2 2005
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-herr_t
-H5B2_cache_leaf_dest(H5F_t UNUSED *f, H5B2_leaf_t *leaf)
-{
- H5B2_shared_t *shared; /* Shared B-tree information */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_leaf_dest)
-
- /*
- * Check arguments.
- */
+ HDassert(image);
HDassert(leaf);
+ HDassert(flags);
/* Get the pointer to the shared B-tree info */
shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
HDassert(shared);
- /* Release leaf's native key buffer */
- if(leaf->leaf_native)
- H5FL_FAC_FREE(shared->node_info[0].nat_rec_fac, leaf->leaf_native);
+ p = image;
- /* Decrement reference count on shared B-tree info */
- if(leaf->shared)
- H5RC_DEC(leaf->shared);
+ /* magic number */
+ HDmemcpy(p, H5B2_LEAF_MAGIC, (size_t)H5B2_SIZEOF_MAGIC);
+ p += H5B2_SIZEOF_MAGIC;
- /* Free B-tree leaf node info */
- H5FL_FREE(H5B2_leaf_t,leaf);
+ /* version # */
+ *p++ = H5B2_LEAF_VERSION;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5B2_cache_leaf_dest() */
+ /* b-tree type */
+ *p++ = shared->type->id;
+ HDassert((size_t)(p - (const uint8_t *)image) == (H5B2_LEAF_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
-
-/*-------------------------------------------------------------------------
- * Function: H5B2_cache_leaf_clear
- *
- * Purpose: Mark a B-tree leaf node in memory as non-dirty.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 2 2005
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *leaf, hbool_t destroy)
-{
- herr_t ret_value = SUCCEED;
+ /* Serialize records for leaf node */
+ native = leaf->leaf_native;
+ for(u = 0; u < leaf->nrec; u++) {
+ /* Encode record */
+ if((shared->type->encode)(f, p, native) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
- FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_leaf_clear)
+ /* Move to next record */
+ p += shared->rrec_size;
+ native += shared->type->nrec_size;
+ } /* end for */
- /*
- * Check arguments.
- */
- HDassert(leaf);
+ /* Compute metadata checksum */
+ metadata_chksum = H5_checksum_metadata(image, (size_t)((const uint8_t *)p - (const uint8_t *)image), 0);
+
+ /* Metadata checksum */
+ UINT32ENCODE(p, metadata_chksum);
- /* Reset the dirty flag. */
- leaf->cache_info.is_dirty = FALSE;
+ /* Reset the cache flags for this operation */
+ *flags = 0;
- if(destroy)
- if(H5B2_cache_leaf_dest(f, leaf) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node")
+ /* Sanity check */
+ HDassert((size_t)((const uint8_t *)p - (const uint8_t *)image) <= len);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_cache_leaf_clear() */
+} /* H5B2_cache_leaf_serialize() */
/*-------------------------------------------------------------------------
- * Function: H5B2_cache_leaf_size
+ * Function: H5B2_cache_leaf_free_icr
*
- * Purpose: Compute the size in bytes of a B-tree leaf node
- * on disk, and return it in *size_ptr. On failure,
- * the value of *size_ptr is undefined.
+ * Purpose: Destroy/release an "in core representation" of a data
+ * structure
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Feb 2 2005
+ * Programmer: Mike McGreevy
+ * mcgreevy@hdfgroup.org
+ * June 18, 2008
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_leaf_size(const H5F_t UNUSED *f, const H5B2_leaf_t *leaf, size_t *size_ptr)
+H5B2_cache_leaf_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing)
{
- H5B2_shared_t *shared; /* Shared B-tree information */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_leaf_size)
-
- /* check arguments */
- HDassert(leaf);
- HDassert(size_ptr);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_leaf_free_icr)
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
- HDassert(shared);
+ /* Check arguments */
+ HDassert(thing);
- /* Set size value */
- *size_ptr = shared->node_size;
+ /* Destroy v2 b-tree header */
+ H5B2_cache_leaf_dest(thing);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5B2_cache_leaf_size() */
-
+} /* H5B2_cache_leaf_free_icr() */
diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c
index 836486e..3946298 100644
--- a/src/H5B2dbg.c
+++ b/src/H5B2dbg.c
@@ -95,6 +95,7 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
unsigned u; /* Local index variable */
char temp_str[128]; /* Temporary string, for formatting */
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_hdr_debug, FAIL)
@@ -108,10 +109,13 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
HDassert(fwidth >= 0);
HDassert(type);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/*
* Load the B-tree header.
*/
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -175,7 +179,7 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
} /* end for */
done:
- if(bt2 && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(bt2 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header")
FUNC_LEAVE_NOAPI(ret_value)
@@ -205,6 +209,7 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
unsigned u; /* Local index variable */
char temp_str[128]; /* Temporary string, for formatting */
herr_t ret_value=SUCCEED; /* Return value */
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_int_debug, FAIL)
@@ -220,10 +225,13 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
HDassert(H5F_addr_defined(hdr_addr));
HDassert(nrec > 0);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/*
* Load the B-tree header.
*/
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, hdr_addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -233,11 +241,11 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
/*
* Load the B-tree internal node
*/
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2->shared, addr, nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2->shared, addr, nrec, depth, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node")
/* Release the B-tree header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, hdr_addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header")
bt2 = NULL;
@@ -304,7 +312,7 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
internal->node_ptrs[u].addr);
done:
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(internal && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -334,6 +342,7 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
unsigned u; /* Local index variable */
char temp_str[128]; /* Temporary string, for formatting */
herr_t ret_value=SUCCEED; /* Return value */
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI(H5B2_leaf_debug, FAIL)
@@ -349,10 +358,13 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
HDassert(H5F_addr_defined(hdr_addr));
HDassert(nrec > 0);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/*
* Load the B-tree header.
*/
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, hdr_addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header")
/* Get the pointer to the shared B-tree info */
@@ -362,11 +374,11 @@ 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)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, addr, (size_t)shared->node_size, &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree leaf node")
/* Release the B-tree header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, hdr_addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header")
bt2 = NULL;
@@ -414,7 +426,7 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
} /* end for */
done:
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(leaf && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, addr, (size_t)0, leaf, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5B2int.c b/src/H5B2int.c
index eae1291..90e687a 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -362,7 +362,7 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
unsigned *parent_cache_info_flags_ptr, H5B2_internal_t *internal,
unsigned *internal_flags_ptr, unsigned idx)
{
- const H5AC_class_t *child_class; /* Pointer to child node's class info */
+ const H5AC2_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void *left_child, *right_child; /* Pointers to child nodes */
unsigned *left_nrec, *right_nrec; /* Pointers to child # of records */
@@ -372,6 +372,7 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
unsigned mid_record; /* Index of "middle" record in current node */
unsigned old_node_nrec; /* Number of records in internal node split */
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_split1)
@@ -400,14 +401,14 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node")
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_INT;
+ child_class = H5AC2_BT2_INT;
left_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx + 1].addr;
/* Protect both leafs */
- if(NULL == (left_int = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (left_int = H5B2_protect_internal(f, dxpl_id, internal->shared, left_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
- if(NULL == (right_int = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (right_int = H5B2_protect_internal(f, dxpl_id, internal->shared, right_addr, internal->node_ptrs[idx + 1].node_nrec, (depth - 1), H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for child nodes */
@@ -429,14 +430,21 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new leaf node")
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_LEAF;
+ child_class = H5AC2_BT2_LEAF;
left_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx + 1].addr;
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec);
+ cache_leaf_udata.bt2_shared = internal->shared;
+
/* 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)))
+ if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, child_class, left_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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 *)H5AC2_protect(f, dxpl_id, child_class, right_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -498,13 +506,13 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
internal->nrec++;
/* Mark parent as dirty */
- *internal_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *internal_flags_ptr |= H5AC2__DIRTIED_FLAG;
/* Update grandparent info */
curr_node_ptr->node_nrec++;
/* Mark grandparent as dirty */
- *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *parent_cache_info_flags_ptr |= H5AC2__DIRTIED_FLAG;
#ifdef H5B2_DEBUG
H5B2_assert_internal((hsize_t)0,shared,internal);
@@ -519,9 +527,9 @@ H5B2_split1(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_node_ptr_t *curr_node_
#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(H5AC2_unprotect(f, dxpl_id, child_class, left_addr, (size_t)0, left_child, H5AC2__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node")
- if(H5AC_unprotect(f, dxpl_id, child_class, right_addr, right_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, child_class, right_addr, (size_t)0, right_child, H5AC2__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node")
done:
@@ -549,7 +557,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2, unsigned *bt2_flags_ptr)
{
H5B2_internal_t *new_root; /* Pointer to new root node */
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
- unsigned new_root_flags = H5AC__NO_FLAGS_SET; /* Cache flags for new root node */
+ unsigned new_root_flags = H5AC2__NO_FLAGS_SET; /* Cache flags for new root node */
H5B2_node_ptr_t old_root_ptr; /* Old node pointer to root node in B-tree */
herr_t ret_value = SUCCEED; /* Return value */
@@ -591,7 +599,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2, unsigned *bt2_flags_ptr)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create new internal node")
/* Protect new root node */
- if(NULL == (new_root = H5B2_protect_internal(f, dxpl_id, bt2->shared, bt2->root.addr, bt2->root.node_nrec, shared->depth, H5AC_WRITE)))
+ if(NULL == (new_root = H5B2_protect_internal(f, dxpl_id, bt2->shared, bt2->root.addr, bt2->root.node_nrec, shared->depth, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Set first node pointer in root node to old root node pointer info */
@@ -602,7 +610,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2, unsigned *bt2_flags_ptr)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split old root node")
/* Release new root node (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, bt2->root.addr, new_root, new_root_flags) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, bt2->root.addr, (size_t)0, new_root, new_root_flags) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree internal node")
done:
@@ -628,7 +636,7 @@ done:
static herr_t
H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *internal, unsigned idx)
{
- const H5AC_class_t *child_class; /* Pointer to child node's class info */
+ const H5AC2_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void *left_child, *right_child; /* Pointers to child nodes */
unsigned *left_nrec, *right_nrec; /* Pointers to child # of records */
@@ -637,6 +645,7 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int
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 */
herr_t ret_value=SUCCEED; /* Return value */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_redistribute2)
@@ -653,14 +662,14 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int
H5B2_internal_t *right_internal; /* Pointer to right internal node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_INT;
+ child_class = H5AC2_BT2_INT;
left_addr = internal->node_ptrs[idx].addr;
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), H5AC2_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), H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -678,14 +687,21 @@ H5B2_redistribute2(H5F_t *f, hid_t dxpl_id, unsigned depth, H5B2_internal_t *int
H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_LEAF;
+ child_class = H5AC2_BT2_LEAF;
left_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx+1].addr;
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec);
+ cache_leaf_udata.bt2_shared = internal->shared;
+
/* 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)))
+ if (NULL == (left_leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, child_class, left_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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 *)H5AC2_protect(f, dxpl_id, child_class, right_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -822,9 +838,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 (H5AC2_unprotect(f, dxpl_id, child_class, left_addr, (size_t)0, left_child, H5AC2__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 (H5AC2_unprotect(f, dxpl_id, child_class, right_addr, (size_t)0, right_child, H5AC2__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -851,7 +867,7 @@ static herr_t
H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx)
{
- const H5AC_class_t *child_class; /* Pointer to child node's class info */
+ const H5AC2_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
haddr_t middle_addr; /* Address of middle child node */
void *left_child, *right_child; /* Pointers to child nodes */
@@ -866,6 +882,7 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
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 */
herr_t ret_value=SUCCEED; /* Return value */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_redistribute3)
@@ -884,17 +901,17 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *right_internal; /* Pointer to right internal node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_INT;
+ child_class = H5AC2_BT2_INT;
left_addr = internal->node_ptrs[idx-1].addr;
middle_addr = internal->node_ptrs[idx].addr;
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), H5AC2_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), H5AC2_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), H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for child nodes */
@@ -917,17 +934,27 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_LEAF;
+ child_class = H5AC2_BT2_LEAF;
left_addr = internal->node_ptrs[idx-1].addr;
middle_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx+1].addr;
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(internal->node_ptrs[idx-1].node_nrec);
+ cache_leaf_udata.bt2_shared = internal->shared;
+
/* 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)))
+ if (NULL == (left_leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, child_class, left_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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 *)H5AC2_protect(f, dxpl_id, child_class, middle_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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 *)H5AC2_protect(f, dxpl_id, child_class, right_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for child nodes */
@@ -1136,7 +1163,7 @@ H5B2_redistribute3(H5F_t *f, hid_t dxpl_id, unsigned depth,
} /* end else */
/* Mark parent as dirty */
- *internal_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *internal_flags_ptr |= H5AC2__DIRTIED_FLAG;
#ifdef QAK
{
@@ -1194,11 +1221,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 (H5AC2_unprotect(f, dxpl_id, child_class, left_addr, (size_t)0, left_child, H5AC2__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 (H5AC2_unprotect(f, dxpl_id, child_class, middle_addr, (size_t)0, middle_child, H5AC2__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 (H5AC2_unprotect(f, dxpl_id, child_class, right_addr, (size_t)0, right_child, H5AC2__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -1226,7 +1253,7 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx)
{
- const H5AC_class_t *child_class; /* Pointer to child node's class info */
+ const H5AC2_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
void *left_child, *right_child; /* Pointers to left & right child nodes */
unsigned *left_nrec, *right_nrec; /* Pointers to left & right child # of records */
@@ -1234,6 +1261,7 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
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 */
herr_t ret_value=SUCCEED; /* Return value */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_merge2)
@@ -1253,14 +1281,14 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *right_internal; /* Pointer to right internal node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_INT;
+ child_class = H5AC2_BT2_INT;
left_addr = internal->node_ptrs[idx].addr;
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), H5AC2_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), H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for accessing child node information */
@@ -1278,14 +1306,21 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_LEAF;
+ child_class = H5AC2_BT2_LEAF;
left_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx+1].addr;
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec);
+ cache_leaf_udata.bt2_shared = internal->shared;
+
/* 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)))
+ if(NULL == (left_leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, child_class, left_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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 *)H5AC2_protect(f, dxpl_id, child_class, right_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for accessing child node information */
@@ -1329,13 +1364,13 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
internal->nrec--;
/* Mark parent as dirty */
- *internal_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *internal_flags_ptr |= H5AC2__DIRTIED_FLAG;
/* Update grandparent info */
curr_node_ptr->node_nrec--;
/* Mark grandparent as dirty */
- *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *parent_cache_info_flags_ptr |= H5AC2__DIRTIED_FLAG;
#ifdef H5B2_DEBUG
H5B2_assert_internal((hsize_t)0,shared,internal);
@@ -1346,13 +1381,13 @@ H5B2_merge2(H5F_t *f, hid_t dxpl_id, unsigned depth,
#endif /* H5B2_DEBUG */
/* Unlock left node (marked as dirty) */
- if(H5AC_unprotect(f, dxpl_id, child_class, left_addr, left_child, H5AC__DIRTIED_FLAG) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, child_class, left_addr, (size_t)0, left_child, H5AC2__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)
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(H5AC2_unprotect(f, dxpl_id, child_class, right_addr, (size_t)0, right_child, H5AC2__DIRTIED_FLAG|H5AC2__DELETED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -1380,7 +1415,7 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, unsigned *parent_cache_info_flags_ptr,
H5B2_internal_t *internal, unsigned *internal_flags_ptr, unsigned idx)
{
- const H5AC_class_t *child_class; /* Pointer to child node's class info */
+ const H5AC2_class_t *child_class; /* Pointer to child node's class info */
haddr_t left_addr, right_addr; /* Addresses of left & right child nodes */
haddr_t middle_addr; /* Address of middle child node */
void *left_child, *right_child; /* Pointers to left & right child nodes */
@@ -1394,6 +1429,7 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_shared_t *shared; /* B-tree's shared info */
hsize_t middle_moved_nrec; /* Number of records moved, for internal split */
herr_t ret_value=SUCCEED; /* Return value */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_merge3)
@@ -1414,17 +1450,17 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *right_internal; /* Pointer to right internal node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_INT;
+ child_class = H5AC2_BT2_INT;
left_addr = internal->node_ptrs[idx-1].addr;
middle_addr = internal->node_ptrs[idx].addr;
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), H5AC2_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), H5AC2_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), H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for accessing child node information */
@@ -1447,17 +1483,27 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_leaf_t *right_leaf; /* Pointer to right leaf node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_LEAF;
+ child_class = H5AC2_BT2_LEAF;
left_addr = internal->node_ptrs[idx-1].addr;
middle_addr = internal->node_ptrs[idx].addr;
right_addr = internal->node_ptrs[idx+1].addr;
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(internal->node_ptrs[idx-1].node_nrec);
+ cache_leaf_udata.bt2_shared = internal->shared;
+
/* 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)))
+ if (NULL == (left_leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, child_class, left_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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 *)H5AC2_protect(f, dxpl_id, child_class, middle_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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 *)H5AC2_protect(f, dxpl_id, child_class, right_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for accessing child node information */
@@ -1547,13 +1593,13 @@ H5B2_merge3(H5F_t *f, hid_t dxpl_id, unsigned depth,
internal->nrec--;
/* Mark parent as dirty */
- *internal_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *internal_flags_ptr |= H5AC2__DIRTIED_FLAG;
/* Update grandparent info */
curr_node_ptr->node_nrec--;
/* Mark grandparent as dirty */
- *parent_cache_info_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *parent_cache_info_flags_ptr |= H5AC2__DIRTIED_FLAG;
#ifdef H5B2_DEBUG
H5B2_assert_internal((hsize_t)0,shared,internal);
@@ -1568,15 +1614,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 (H5AC2_unprotect(f, dxpl_id, child_class, left_addr, (size_t)0, left_child, H5AC2__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 (H5AC2_unprotect(f, dxpl_id, child_class, middle_addr, (size_t)0, middle_child, H5AC2__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)
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 (H5AC2_unprotect(f, dxpl_id, child_class, right_addr, (size_t)0, right_child, H5AC2__DIRTIED_FLAG|H5AC2__DELETED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -1604,12 +1650,13 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *internal, unsigned *internal_flags_ptr,
unsigned idx, void *swap_loc)
{
- const H5AC_class_t *child_class; /* Pointer to child node's class info */
+ const H5AC2_class_t *child_class; /* Pointer to child node's class info */
haddr_t child_addr; /* Address of child node */
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 */
herr_t ret_value=SUCCEED; /* Return value */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_swap_leaf)
@@ -1627,11 +1674,11 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_internal_t *child_internal; /* Pointer to internal node */
/* Setup information for unlocking child node */
- child_class = H5AC_BT2_INT;
+ child_class = H5AC2_BT2_INT;
child_addr = internal->node_ptrs[idx].addr;
/* Lock B-tree child nodes */
- if(NULL == (child_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, child_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC_WRITE)))
+ if(NULL == (child_internal = H5B2_protect_internal(f, dxpl_id, internal->shared, child_addr, internal->node_ptrs[idx].node_nrec, (depth - 1), H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* More setup for accessing child node information */
@@ -1642,11 +1689,15 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
H5B2_leaf_t *child_leaf; /* Pointer to leaf node */
/* Setup information for unlocking child nodes */
- child_class = H5AC_BT2_LEAF;
+ child_class = H5AC2_BT2_LEAF;
child_addr = internal->node_ptrs[idx].addr;
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(internal->node_ptrs[idx].node_nrec);
+ cache_leaf_udata.bt2_shared = internal->shared;
+
/* 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)))
+ if (NULL == (child_leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, child_class, child_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* More setup for accessing child node information */
@@ -1660,7 +1711,7 @@ H5B2_swap_leaf(H5F_t *f, hid_t dxpl_id, unsigned depth,
HDmemcpy(swap_loc, shared->page, shared->type->nrec_size);
/* Mark parent as dirty */
- *internal_flags_ptr |= H5AC__DIRTIED_FLAG;
+ *internal_flags_ptr |= H5AC2__DIRTIED_FLAG;
#ifdef H5B2_DEBUG
H5B2_assert_internal((hsize_t)0,shared,internal);
@@ -1671,7 +1722,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 (H5AC2_unprotect(f, dxpl_id, child_class, child_addr, (size_t)0, child, H5AC2__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node")
done:
@@ -1701,6 +1752,7 @@ H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
int cmp; /* Comparison value of records */
unsigned idx; /* Location of record which matches key */
herr_t ret_value = SUCCEED;
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_insert_leaf)
@@ -1710,14 +1762,18 @@ 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")
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
/* 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 */
+ if (NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr->addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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);
@@ -1753,7 +1809,7 @@ H5B2_insert_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
done:
/* Release the B-tree leaf node (marked as dirty) */
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__DIRTIED_FLAG) < 0)
+ if(leaf && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr->addr, (size_t)0, leaf, H5AC2__DIRTIED_FLAG) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1779,7 +1835,7 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
H5B2_node_ptr_t *curr_node_ptr, void *udata)
{
H5B2_internal_t *internal; /* Pointer to internal node */
- unsigned internal_flags = H5AC__NO_FLAGS_SET;
+ unsigned internal_flags = H5AC2__NO_FLAGS_SET;
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
unsigned idx; /* Location of record which matches key */
herr_t ret_value = SUCCEED;
@@ -1795,7 +1851,7 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
HDassert(H5F_addr_defined(curr_node_ptr->addr));
/* Lock current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Get the pointer to the shared B-tree info */
@@ -1889,11 +1945,11 @@ H5B2_insert_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
curr_node_ptr->all_nrec++;
/* Mark node as dirty */
- internal_flags |= H5AC__DIRTIED_FLAG;
+ internal_flags |= H5AC2__DIRTIED_FLAG;
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 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr->addr, (size_t)0, internal, internal_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1933,7 +1989,7 @@ H5B2_create_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, H5B2_node_ptr_t *n
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree leaf info")
/* Set metadata cache info */
- HDmemset(&leaf->cache_info, 0, sizeof(H5AC_info_t));
+ HDmemset(&leaf->cache_info, 0, sizeof(H5AC2_info_t));
/* Share common B-tree information */
leaf->shared = bt2_shared;
@@ -1958,13 +2014,13 @@ HDmemset(leaf->leaf_native, 0, shared->type->nrec_size * shared->node_info[0].ma
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree leaf node")
/* Cache the new B-tree node */
- if(H5AC_set(f, dxpl_id, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_set(f, dxpl_id, H5AC2_BT2_LEAF, node_ptr->addr, (size_t)shared->node_size, leaf, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree leaf to cache")
done:
if(ret_value < 0) {
if(leaf)
- (void)H5B2_cache_leaf_dest(f,leaf);
+ (void)H5B2_cache_leaf_dest(leaf);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -2006,7 +2062,7 @@ H5B2_create_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal info")
/* Set metadata cache info */
- HDmemset(&internal->cache_info, 0, sizeof(H5AC_info_t));
+ HDmemset(&internal->cache_info, 0, sizeof(H5AC2_info_t));
/* Share common B-tree information */
internal->shared = bt2_shared;
@@ -2039,13 +2095,13 @@ HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (shared->node_info[de
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree internal node")
/* Cache the new B-tree node */
- if(H5AC_set(f, dxpl_id, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_set(f, dxpl_id, H5AC2_BT2_INT, node_ptr->addr, (size_t)shared->node_size, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree internal node to cache")
done:
if(ret_value < 0) {
if(internal)
- (void)H5B2_cache_internal_dest(f,internal);
+ (void)H5B2_cache_internal_dest(internal);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -2067,10 +2123,11 @@ done:
*/
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)
+ unsigned nrec, unsigned depth, H5AC2_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 */
+ H5B2_shared_t *shared; /* B-tree's shared info */
FUNC_ENTER_NOAPI_NOINIT(H5B2_protect_internal)
@@ -2084,9 +2141,14 @@ 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;
+
+ /* Get the pointer to the shared B-tree info */
+ shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2_shared);
+ HDassert(shared);
/* 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 *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_INT, addr, (size_t)shared->node_size, &udata, rw)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree internal node")
done:
@@ -2116,13 +2178,14 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data)
{
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
- const H5AC_class_t *curr_node_class = NULL; /* Pointer to current node's class info */
+ const H5AC2_class_t *curr_node_class = NULL; /* Pointer to current node's class info */
void *node = NULL; /* Pointers to current node */
uint8_t *node_native; /* Pointers to node's native records */
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 */
herr_t ret_value = H5_ITER_CONT; /* Iterator return value */
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_iterate_node)
@@ -2141,11 +2204,11 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
H5B2_internal_t *internal; /* Pointer to internal node */
/* Lock the current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Set up information about current node */
- curr_node_class = H5AC_BT2_INT;
+ curr_node_class = H5AC2_BT2_INT;
node = internal;
node_native = internal->int_native;
@@ -2159,12 +2222,16 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
else {
H5B2_leaf_t *leaf; /* Pointer to leaf node */
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node->node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
+
/* 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)))
+ if (NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node->addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Set up information about current node */
- curr_node_class = H5AC_BT2_LEAF;
+ curr_node_class = H5AC2_BT2_LEAF;
node = leaf;
node_native = leaf->leaf_native;
} /* end else */
@@ -2177,7 +2244,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
HDmemcpy(native, node_native, (shared->type->nrec_size * curr_node->node_nrec));
/* Unlock the node */
- if(H5AC_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, (size_t)0, node, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
node = NULL;
@@ -2233,10 +2300,11 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */
- unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */
+ unsigned leaf_flags = H5AC2__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 */
herr_t ret_value = SUCCEED;
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_leaf)
@@ -2246,15 +2314,19 @@ 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")
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
/* 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;
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, leaf_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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);
@@ -2272,7 +2344,7 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
leaf->nrec--;
/* Mark leaf node as dirty also */
- leaf_flags |= H5AC__DIRTIED_FLAG;
+ leaf_flags |= H5AC2__DIRTIED_FLAG;
if(leaf->nrec > 0) {
/* Pack record out of leaf */
@@ -2285,7 +2357,7 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree leaf node")
/* Let the cache know that the object is deleted */
- leaf_flags |= H5AC__DELETED_FLAG;
+ leaf_flags |= H5AC2__DELETED_FLAG;
/* Reset address of parent node pointer */
curr_node_ptr->addr = HADDR_UNDEF;
@@ -2296,7 +2368,7 @@ H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
done:
/* Release the B-tree leaf node */
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0)
+ if(leaf && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, leaf_addr, (size_t)0, leaf, leaf_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2319,15 +2391,15 @@ done:
herr_t
H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
hbool_t *depth_decreased, void *swap_loc, unsigned depth,
- H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
+ H5AC2_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op,
void *op_data)
{
- H5AC_info_t *new_cache_info; /* Pointer to new cache info */
+ H5AC2_info_t *new_cache_info; /* Pointer to new cache info */
unsigned *new_cache_info_flags_ptr = NULL;
H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */
H5B2_internal_t *internal; /* Pointer to internal node */
- unsigned internal_flags = H5AC__NO_FLAGS_SET;
+ unsigned internal_flags = H5AC2__NO_FLAGS_SET;
haddr_t internal_addr; /* Address of internal node */
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
size_t merge_nrec; /* Number of records to merge node at */
@@ -2347,7 +2419,7 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
/* Lock current B-tree node */
internal_addr = curr_node_ptr->addr;
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, internal_addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, internal_addr, curr_node_ptr->node_nrec, depth, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Get the pointer to the shared B-tree info */
@@ -2372,7 +2444,7 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree leaf node")
/* Let the cache know that the object is deleted */
- internal_flags |= H5AC__DELETED_FLAG;
+ internal_flags |= H5AC2__DELETED_FLAG;
/* Reset information in header's root node pointer */
curr_node_ptr->addr = internal->node_ptrs[0].addr;
@@ -2501,7 +2573,7 @@ H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
new_node_ptr->all_nrec--;
/* Mark node as dirty */
- internal_flags |= H5AC__DIRTIED_FLAG;
+ internal_flags |= H5AC2__DIRTIED_FLAG;
#ifdef H5B2_DEBUG
H5B2_assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec-1) : new_node_ptr->all_nrec),shared,internal);
@@ -2509,7 +2581,7 @@ H5B2_remove_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, internal_addr, internal, internal_flags) < 0)
+ if(internal && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, internal_addr, (size_t)0, internal, internal_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2537,9 +2609,10 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
{
H5B2_leaf_t *leaf; /* Pointer to leaf node */
haddr_t leaf_addr = HADDR_UNDEF; /* Leaf address on disk */
- unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting leaf node */
+ unsigned leaf_flags = H5AC2__NO_FLAGS_SET; /* Flags for unprotecting leaf node */
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
herr_t ret_value = SUCCEED;
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_remove_leaf_by_idx)
@@ -2549,15 +2622,19 @@ 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")
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
/* 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;
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, leaf_addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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);
@@ -2572,7 +2649,7 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
leaf->nrec--;
/* Mark leaf node as dirty also */
- leaf_flags |= H5AC__DIRTIED_FLAG;
+ leaf_flags |= H5AC2__DIRTIED_FLAG;
if(leaf->nrec > 0) {
/* Pack record out of leaf */
@@ -2585,7 +2662,7 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree leaf node")
/* Let the cache know that the object is deleted */
- leaf_flags |= H5AC__DELETED_FLAG;
+ leaf_flags |= H5AC2__DELETED_FLAG;
/* Reset address of parent node pointer */
curr_node_ptr->addr = HADDR_UNDEF;
@@ -2596,7 +2673,7 @@ H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
done:
/* Release the B-tree leaf node */
- if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0)
+ if(leaf && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, leaf_addr, (size_t)0, leaf, leaf_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2620,15 +2697,15 @@ done:
herr_t
H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
hbool_t *depth_decreased, void *swap_loc, unsigned depth,
- H5AC_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
+ H5AC2_info_t *parent_cache_info, unsigned *parent_cache_info_flags_ptr,
H5B2_node_ptr_t *curr_node_ptr, hsize_t n, H5B2_remove_t op,
void *op_data)
{
- H5AC_info_t *new_cache_info; /* Pointer to new cache info */
+ H5AC2_info_t *new_cache_info; /* Pointer to new cache info */
unsigned *new_cache_info_flags_ptr = NULL;
H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */
H5B2_internal_t *internal; /* Pointer to internal node */
- unsigned internal_flags = H5AC__NO_FLAGS_SET;
+ unsigned internal_flags = H5AC2__NO_FLAGS_SET;
haddr_t internal_addr; /* Address of internal node */
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
size_t merge_nrec; /* Number of records to merge node at */
@@ -2648,7 +2725,7 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
/* Lock current B-tree node */
internal_addr = curr_node_ptr->addr;
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, internal_addr, curr_node_ptr->node_nrec, depth, H5AC_WRITE)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, internal_addr, curr_node_ptr->node_nrec, depth, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
HDassert(internal->nrec == curr_node_ptr->node_nrec);
@@ -2676,7 +2753,7 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree leaf node")
/* Let the cache know that the object is deleted */
- internal_flags |= H5AC__DELETED_FLAG;
+ internal_flags |= H5AC2__DELETED_FLAG;
/* Reset information in header's root node pointer */
curr_node_ptr->addr = internal->node_ptrs[0].addr;
@@ -2857,7 +2934,7 @@ H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
new_node_ptr->all_nrec--;
/* Mark node as dirty */
- internal_flags |= H5AC__DIRTIED_FLAG;
+ internal_flags |= H5AC2__DIRTIED_FLAG;
#ifdef H5B2_DEBUG
H5B2_assert_internal((!collapsed_root ? (curr_node_ptr->all_nrec-1) : new_node_ptr->all_nrec),shared,internal);
@@ -2865,7 +2942,7 @@ H5B2_remove_internal_by_idx(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, internal_addr, internal, internal_flags) < 0)
+ if(internal && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, internal_addr, (size_t)0, internal, internal_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2908,6 +2985,7 @@ H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
unsigned idx; /* Location of record which matches key */
int cmp=0; /* Comparison value of records */
herr_t ret_value = SUCCEED;
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_neighbor_leaf)
@@ -2918,14 +2996,17 @@ 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")
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node_ptr->node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
/* 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 */
+ if (NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr->addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_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);
@@ -2958,7 +3039,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 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr->addr, (size_t)0, leaf, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -3013,7 +3094,7 @@ H5B2_neighbor_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
HDassert(op);
/* Lock current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Get the pointer to the shared B-tree info */
@@ -3049,7 +3130,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 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr->addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -3075,10 +3156,11 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data)
{
H5B2_shared_t *shared; /* Pointer to B-tree's shared information */
- const H5AC_class_t *curr_node_class=NULL; /* Pointer to current node's class info */
+ const H5AC2_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 */
herr_t ret_value = SUCCEED;
+ H5B2_leaf_cache_ud_t cache_leaf_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_delete_node)
@@ -3096,11 +3178,11 @@ 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, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Set up information about current node */
- curr_node_class = H5AC_BT2_INT;
+ curr_node_class = H5AC2_BT2_INT;
node = internal;
native = internal->int_native;
@@ -3112,12 +3194,16 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
else {
H5B2_leaf_t *leaf; /* Pointer to leaf node */
+ cache_leaf_udata.f = f;
+ cache_leaf_udata.nrec = &(curr_node->node_nrec);
+ cache_leaf_udata.bt2_shared = bt2_shared;
+
/* 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)))
+ if (NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node->addr, (size_t)shared->node_size, &cache_leaf_udata, H5AC2_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree leaf node")
/* Set up information about current node */
- curr_node_class = H5AC_BT2_LEAF;
+ curr_node_class = H5AC2_BT2_LEAF;
node = leaf;
native = leaf->leaf_native;
} /* end else */
@@ -3141,7 +3227,7 @@ H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
done:
/* Unlock & delete current node */
if(node)
- if(H5AC_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__DELETED_FLAG) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, (size_t)0, node, H5AC2__DELETED_FLAG) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -3183,7 +3269,7 @@ H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned dep
HDassert(shared);
/* Lock the current B-tree node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node->addr, curr_node->node_nrec, depth, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Recursively descend into child nodes, if we are above the "twig" level in the B-tree */
@@ -3202,7 +3288,7 @@ H5B2_iterate_size_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned dep
*btree_size += shared->node_size;
done:
- if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(internal && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node->addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h
index 43fab1f..1d02bf9 100644
--- a/src/H5B2pkg.h
+++ b/src/H5B2pkg.h
@@ -32,7 +32,7 @@
#include "H5B2private.h"
/* Other private headers needed by this file */
-#include "H5ACprivate.h" /* Metadata cache */
+#include "H5AC2private.h" /* Metadata cache */
#include "H5FLprivate.h" /* Free Lists */
#include "H5RCprivate.h" /* Reference counted object functions */
@@ -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 */
@@ -163,7 +184,7 @@ typedef struct H5B2_shared_t {
/* The B-tree information */
typedef struct H5B2_t {
/* Information for H5AC cache functions, _must_ be first field in structure */
- H5AC_info_t cache_info;
+ H5AC2_info_t cache_info;
/* Internal B-tree information */
H5B2_node_ptr_t root; /* Node pointer to root node in B-tree */
@@ -173,7 +194,7 @@ typedef struct H5B2_t {
/* B-tree leaf node information */
typedef struct H5B2_leaf_t {
/* Information for H5AC cache functions, _must_ be first field in structure */
- H5AC_info_t cache_info;
+ H5AC2_info_t cache_info;
/* Internal B-tree information */
H5RC_t *shared; /* Ref-counted shared info */
@@ -184,7 +205,7 @@ typedef struct H5B2_leaf_t {
/* B-tree internal node information */
typedef struct H5B2_internal_t {
/* Information for H5AC cache functions, _must_ be first field in structure */
- H5AC_info_t cache_info;
+ H5AC2_info_t cache_info;
/* Internal B-tree information */
H5RC_t *shared; /* Ref-counted shared info */
@@ -215,13 +236,13 @@ typedef struct {
/*****************************/
/* H5B2 header inherits cache-like properties from H5AC */
-H5_DLLVAR const H5AC_class_t H5AC_BT2_HDR[1];
+H5_DLLVAR const H5AC2_class_t H5AC2_BT2_HDR[1];
/* H5B2 internal node inherits cache-like properties from H5AC */
-H5_DLLVAR const H5AC_class_t H5AC_BT2_INT[1];
+H5_DLLVAR const H5AC2_class_t H5AC2_BT2_INT[1];
/* H5B2 leaf node inherits cache-like properties from H5AC */
-H5_DLLVAR const H5AC_class_t H5AC_BT2_LEAF[1];
+H5_DLLVAR const H5AC2_class_t H5AC2_BT2_LEAF[1];
/* Declare a free list to manage the H5B2_t struct */
H5FL_EXTERN(H5B2_t);
@@ -250,7 +271,7 @@ H5_DLL herr_t H5B2_shared_init(H5F_t *f, H5B2_t *bt2, const H5B2_class_t *type,
/* Routines for operating on internal nodes */
H5_DLL 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);
+ H5AC2_protect_t rw);
/* Routines for allocating nodes */
H5_DLL herr_t H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2,
@@ -284,14 +305,14 @@ H5_DLL herr_t H5B2_neighbor_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
/* Routines for removing records */
H5_DLL herr_t H5B2_remove_internal(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
- hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info,
+ hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC2_info_t *parent_cache_info,
hbool_t * parent_cache_info_dirtied_ptr, H5B2_node_ptr_t *curr_node_ptr, void *udata,
H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_leaf(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op,
void *op_data);
H5_DLL herr_t H5B2_remove_internal_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
- hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC_info_t *parent_cache_info,
+ hbool_t *depth_decreased, void *swap_loc, unsigned depth, H5AC2_info_t *parent_cache_info,
hbool_t * parent_cache_info_dirtied_ptr, H5B2_node_ptr_t *curr_node_ptr, hsize_t idx,
H5B2_remove_t op, void *op_data);
H5_DLL herr_t H5B2_remove_leaf_by_idx(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
@@ -304,9 +325,9 @@ H5_DLL herr_t H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared,
void *op_data);
/* Metadata cache callbacks */
-H5_DLL herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *b);
-H5_DLL herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *l);
-H5_DLL herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *i);
+H5_DLL herr_t H5B2_cache_hdr_dest(H5B2_t *b);
+H5_DLL herr_t H5B2_cache_leaf_dest(H5B2_leaf_t *l);
+H5_DLL herr_t H5B2_cache_internal_dest(H5B2_internal_t *i);
/* Debugging routines for dumping file structures */
H5_DLL herr_t H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
diff --git a/src/H5B2stat.c b/src/H5B2stat.c
index 899bb8a..b837a43 100644
--- a/src/H5B2stat.c
+++ b/src/H5B2stat.c
@@ -89,6 +89,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 */
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_stat_info)
@@ -98,8 +99,11 @@ H5B2_stat_info(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
HDassert(H5F_addr_defined(addr));
HDassert(info);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get pointer to reference counted shared B-tree info */
@@ -111,7 +115,7 @@ H5B2_stat_info(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
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 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5B2test.c b/src/H5B2test.c
index f2cf79d..4784a3b 100644
--- a/src/H5B2test.c
+++ b/src/H5B2test.c
@@ -259,6 +259,7 @@ H5B2_get_root_addr_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
{
H5B2_t *bt2 = NULL; /* Pointer to the B-tree header */
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for cache callback */
FUNC_ENTER_NOAPI_NOINIT(H5B2_get_root_addr_test)
@@ -268,8 +269,11 @@ H5B2_get_root_addr_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
HDassert(H5F_addr_defined(addr));
HDassert(root_addr);
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if(NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if(NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree header")
/* Get B-tree root addr */
@@ -277,7 +281,7 @@ H5B2_get_root_addr_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type,
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 && H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
FUNC_LEAVE_NOAPI(ret_value)
@@ -310,6 +314,7 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr
int cmp; /* Comparison value of records */
unsigned idx; /* Location of record which matches key */
herr_t ret_value = SUCCEED; /* Return value */
+ H5B2_hdr_cache_ud_t cache_udata; /* User-data for cache callback */
FUNC_ENTER_NOAPI(H5B2_get_node_info_test, FAIL)
@@ -318,8 +323,11 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr
HDassert(type);
HDassert(H5F_addr_defined(addr));
+ cache_udata.f = f;
+ cache_udata.type = type;
+
/* Look up the B-tree header */
- if (NULL == (bt2 = (H5B2_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, type, NULL, H5AC_READ)))
+ if (NULL == (bt2 = (H5B2_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)H5B2_HEADER_SIZE(f), &cache_udata, H5AC2_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,7 +346,7 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr
depth = shared->depth;
/* Release header */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, bt2, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_HDR, addr, (size_t)0, bt2, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header info")
bt2 = NULL;
@@ -353,7 +361,7 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr
H5B2_node_ptr_t next_node_ptr; /* Node pointer info for next node */
/* Lock B-tree current node */
- if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC_READ)))
+ if(NULL == (internal = H5B2_protect_internal(f, dxpl_id, bt2_shared, curr_node_ptr.addr, curr_node_ptr.node_nrec, depth, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate node pointer for child */
@@ -366,7 +374,7 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr
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(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Set pointer to next node to load */
@@ -374,7 +382,7 @@ H5B2_get_node_info_test(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr
} /* end if */
else {
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, curr_node_ptr.addr, internal, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_INT, curr_node_ptr.addr, (size_t)0, internal, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Fill in information about the node */
@@ -393,14 +401,14 @@ 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 */
/* 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)))
+ if(NULL == (leaf = (H5B2_leaf_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)shared->node_size, &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree internal node")
/* Locate record */
cmp = H5B2_locate_record(shared->type, leaf->nrec, shared->nat_off, leaf->leaf_native, udata, &idx);
/* Unlock current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT2_LEAF, curr_node_ptr.addr, (size_t)0, leaf, H5AC2__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
/* Indicate the depth that the record was found */