summaryrefslogtreecommitdiffstats
path: root/src/H5B.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-07-02 16:36:15 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-07-02 16:36:15 (GMT)
commitddf9e4a4afc81c4be4ce38a13641ada81204b6ac (patch)
treeefd184e9c0a5687a2927d655d7bd02e546fcfe5f /src/H5B.c
parent4cf99e9f288d42bc756f1585c72ad584620fdec9 (diff)
downloadhdf5-ddf9e4a4afc81c4be4ce38a13641ada81204b6ac.zip
hdf5-ddf9e4a4afc81c4be4ce38a13641ada81204b6ac.tar.gz
hdf5-ddf9e4a4afc81c4be4ce38a13641ada81204b6ac.tar.bz2
[svn-r11014] Purpose:
Code cleanup Description: Refactor metadata cache to merge "dirtied" flag in with other flags for H5AC_unprotect and H5C_unprotect. Platforms tested: FreeBSD 4.11 (sleipnir) h5committest
Diffstat (limited to 'src/H5B.c')
-rw-r--r--src/H5B.c182
1 files changed, 64 insertions, 118 deletions
diff --git a/src/H5B.c b/src/H5B.c
index 41aae64..3123bfc 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -132,11 +132,11 @@ static H5B_ins_t H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr,
uint8_t *rt_key,
hbool_t *rt_key_changed,
haddr_t *retval);
-static herr_t H5B_insert_child(H5B_t *bt, hbool_t * bt_dirtied_ptr,
+static herr_t H5B_insert_child(H5B_t *bt, unsigned *bt_flags,
unsigned idx, haddr_t child,
H5B_ins_t anchor, const void *md_key);
static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt,
- hbool_t * old_bt_dirtied_ptr, haddr_t old_addr,
+ unsigned *old_bt_flags, haddr_t old_addr,
unsigned idx, void *udata, haddr_t *new_addr/*out*/);
static H5B_t * H5B_copy(const H5B_t *old_bt);
static herr_t H5B_serialize(const H5F_t *f, const H5B_t *bt);
@@ -744,7 +744,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u
}
done:
- if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE, H5AC__NO_FLAGS_SET)
+ if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET)
< 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
@@ -789,14 +789,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, hbool_t * old_bt_dirtied_ptr,
- haddr_t old_addr, unsigned idx, void *udata,
- haddr_t *new_addr_p/*out*/)
+H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
+ haddr_t old_addr, unsigned idx, void *udata, haddr_t *new_addr_p/*out*/)
{
H5P_genplist_t *dx_plist; /* Data transfer property list */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
- hbool_t new_bt_dirtied = FALSE, tmp_bt_dirtied = FALSE;
- H5B_t *new_bt = NULL, *tmp_bt = NULL;
+ unsigned new_bt_flags = H5AC__NO_FLAGS_SET;
+ H5B_t *new_bt = NULL;
unsigned nleft, nright; /* Number of keys in left & right halves */
double split_ratios[3]; /* B-tree split ratios */
herr_t ret_value = SUCCEED; /* Return value */
@@ -808,7 +807,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, hbool_t * old_bt_dirtied_ptr,
*/
assert(f);
assert(old_bt);
- assert(old_bt_dirtied_ptr);
+ assert(old_bt_flags);
assert(H5F_addr_defined(old_addr));
/*
@@ -892,7 +891,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, hbool_t * old_bt_dirtied_ptr,
* dirty again.
* -- JRM
*/
- new_bt_dirtied = TRUE;
+ new_bt_flags |= H5AC__DIRTIED_FLAG;
HDmemcpy(new_bt->native,
old_bt->native + nleft * shared->type->sizeof_nkey,
(nright+1) * shared->type->sizeof_nkey);
@@ -905,7 +904,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, hbool_t * old_bt_dirtied_ptr,
/*
* Truncate the old node.
*/
- *old_bt_dirtied_ptr = TRUE;
+ *old_bt_flags |= H5AC__DIRTIED_FLAG;
old_bt->nchildren = nleft;
/*
@@ -915,23 +914,23 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, hbool_t * old_bt_dirtied_ptr,
new_bt->right = old_bt->right;
if (H5F_addr_defined(old_bt->right)) {
+ H5B_t *tmp_bt;
+
if (NULL == (tmp_bt = H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, shared->type, udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling")
- tmp_bt_dirtied = TRUE;
tmp_bt->left = *new_addr_p;
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, old_bt->right, tmp_bt,
- tmp_bt_dirtied, H5AC__NO_FLAGS_SET) != SUCCEED)
+ H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
- tmp_bt=NULL; /* Make certain future references will be caught */
}
old_bt->right = *new_addr_p;
done:
if (new_bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_addr_p, new_bt,
- new_bt_dirtied, H5AC__NO_FLAGS_SET) < 0)
+ new_bt_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -986,9 +985,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
hbool_t lt_key_changed = FALSE, rt_key_changed = FALSE;
haddr_t child, old_root;
unsigned level;
- hbool_t bt_dirtied = FALSE;
H5B_t *bt;
- hbool_t new_bt_dirtied = FALSE;
H5B_t *new_bt; /* Copy of B-tree info */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
H5B_ins_t my_ins = H5B_INS_ERROR;
@@ -1020,12 +1017,9 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
if (!lt_key_changed)
HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey);
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET) != SUCCEED)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
-
bt = NULL;
- bt_dirtied = FALSE;
/* the new node */
if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_READ)))
@@ -1034,12 +1028,9 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
if (!rt_key_changed)
HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey);
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET) != SUCCEED)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, H5AC__NO_FLAGS_SET) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
-
bt = NULL;
- bt_dirtied = FALSE;
/*
* Copy the old root node to some other file location and make the new
@@ -1054,15 +1045,11 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child")
- bt_dirtied = TRUE;
bt->left = old_root;
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET) != SUCCEED)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
-
bt=NULL; /* Make certain future references will be caught */
- bt_dirtied = FALSE;
/*
* Move the node to the new location by checking it out & checking it in
@@ -1074,32 +1061,26 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
/* Make certain the old root info is marked as dirty before moving it, */
/* so it is certain to be written out at the new location */
- bt_dirtied = TRUE;
/* Make a copy of the old root information */
if (NULL == (new_bt = H5B_copy(bt))) {
HCOMMON_ERROR(H5E_BTREE, H5E_CANTLOAD, "unable to copy old root");
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET) != SUCCEED)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
HGOTO_DONE(FAIL)
}
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET) != SUCCEED)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
-
bt=NULL; /* Make certain future references will be caught */
- bt_dirtied = FALSE;
/* Move the location of the old root on the disk */
if (H5AC_rename(f, H5AC_BT, addr, old_root) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node")
/* clear the old root info at the old address (we already copied it) */
- new_bt_dirtied = TRUE;
new_bt->left = HADDR_UNDEF;
new_bt->right = HADDR_UNDEF;
@@ -1156,7 +1137,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_insert_child(H5B_t *bt, hbool_t * bt_dirtied_ptr, unsigned idx,
+H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx,
haddr_t child, H5B_ins_t anchor, const void *md_key)
{
H5B_shared_t *shared; /* Pointer to shared B-tree info */
@@ -1165,13 +1146,11 @@ H5B_insert_child(H5B_t *bt, hbool_t * bt_dirtied_ptr, unsigned idx,
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_insert_child)
assert(bt);
- assert(bt_dirtied_ptr);
+ assert(bt_flags);
shared=H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
assert(bt->nchildren<shared->two_k);
- *bt_dirtied_ptr = TRUE;
-
/* Check for inserting right-most key into node (common when just appending
* records to an unlimited dimension chunked dataset)
*/
@@ -1207,6 +1186,9 @@ H5B_insert_child(H5B_t *bt, hbool_t * bt_dirtied_ptr, unsigned idx,
bt->child[idx] = child;
bt->nchildren += 1;
+ /* Mark node as dirty */
+ *bt_flags |= H5AC__DIRTIED_FLAG;
+
FUNC_LEAVE_NOAPI(SUCCEED)
}
@@ -1270,7 +1252,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
uint8_t *rt_key, hbool_t *rt_key_changed,
haddr_t *new_node_p/*out*/)
{
- hbool_t bt_dirtied = FALSE, twin_dirtied = FALSE;
+ unsigned bt_flags = H5AC__NO_FLAGS_SET, twin_flags = H5AC__NO_FLAGS_SET;
H5B_t *bt = NULL, *twin = NULL;
H5B_shared_t *shared; /* Pointer to shared B-tree info */
unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */
@@ -1330,7 +1312,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
H5B_NKEY(bt,shared,1), bt->child + 0/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node")
bt->nchildren = 1;
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
idx = 0;
if (type->follow_min) {
@@ -1444,14 +1426,14 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* Update the left and right keys of the current node.
*/
if (*lt_key_changed) {
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
if (idx > 0)
*lt_key_changed = FALSE;
else
HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey);
}
if (*rt_key_changed) {
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
if (idx+1 < bt->nchildren)
*rt_key_changed = FALSE;
else
@@ -1462,37 +1444,36 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* The insertion simply changed the address for the child.
*/
bt->child[idx] = child_addr;
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
ret_value = H5B_INS_NOOP;
} else if (H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) {
- hbool_t *tmp_bt_dirtied_ptr = NULL;
+ hbool_t *tmp_bt_flags_ptr = NULL;
H5B_t *tmp_bt;
/*
* If this node is full then split it before inserting the new child.
*/
if (bt->nchildren == shared->two_k) {
- if (H5B_split(f, dxpl_id, bt, &bt_dirtied, addr, idx, udata, new_node_p/*out*/)<0)
+ if (H5B_split(f, dxpl_id, bt, &bt_flags, addr, idx, udata, new_node_p/*out*/)<0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node")
if (NULL == (twin = H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node")
if (idx<bt->nchildren) {
tmp_bt = bt;
- tmp_bt_dirtied_ptr = &bt_dirtied;
+ tmp_bt_flags_ptr = &bt_flags;
} else {
idx -= bt->nchildren;
tmp_bt = twin;
- tmp_bt_dirtied_ptr = &twin_dirtied;
+ tmp_bt_flags_ptr = &twin_flags;
}
} else {
tmp_bt = bt;
- tmp_bt_dirtied_ptr = &bt_dirtied;
+ tmp_bt_flags_ptr = &bt_flags;
}
/* Insert the child */
- if (H5B_insert_child(tmp_bt, tmp_bt_dirtied_ptr, idx,
- child_addr, my_ins, md_key) < 0)
+ if (H5B_insert_child(tmp_bt, tmp_bt_flags_ptr, idx, child_addr, my_ins, md_key) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child")
}
@@ -1519,10 +1500,9 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
done:
{
herr_t e1 = (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt,
- bt_dirtied, H5AC__NO_FLAGS_SET) < 0);
+ bt_flags) < 0);
herr_t e2 = (twin && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_node_p,
- twin, twin_dirtied,
- H5AC__NO_FLAGS_SET)<0);
+ twin, twin_flags)<0);
if (e1 || e2) /*use vars to prevent short-circuit of side effects */
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node(s)")
}
@@ -1563,7 +1543,6 @@ done:
herr_t
H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op, haddr_t addr, void *udata)
{
- hbool_t bt_dirtied = FALSE;
H5B_t *bt = NULL;
H5B_shared_t *shared; /* Pointer to shared B-tree info */
haddr_t next_addr;
@@ -1595,12 +1574,9 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
level = bt->level;
left_child = bt->child[0];
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET) < 0)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
-
bt = NULL; /* Make certain future references will be caught */
- bt_dirtied = FALSE;
if (level > 0) {
/* Keep following the left-most child until we reach a leaf node. */
@@ -1630,12 +1606,9 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
next_addr = bt->right;
nchildren = bt->nchildren;
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, cur_addr, bt,
- bt_dirtied, H5AC__NO_FLAGS_SET) < 0)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, cur_addr, bt, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
-
bt = NULL;
- bt_dirtied = FALSE;
/*
* Perform the iteration operator, which might invoke an
@@ -1698,8 +1671,8 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
hbool_t *lt_key_changed/*out*/, void *udata,
uint8_t *rt_key/*out*/, hbool_t *rt_key_changed/*out*/)
{
- hbool_t bt_dirtied = FALSE, sibling_dirtied = FALSE;
H5B_t *bt = NULL, *sibling = NULL;
+ unsigned bt_flags = H5AC__NO_FLAGS_SET;
H5B_shared_t *shared; /* Pointer to shared B-tree info */
unsigned idx=0, lt=0, rt; /* Final, left & right indices */
int cmp=1; /* Key comparison value */
@@ -1780,16 +1753,16 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* our right key and indicate that it changed.
*/
if (*lt_key_changed) {
- bt_dirtied = TRUE;
- if (idx>0) {
+ bt_flags |= H5AC__DIRTIED_FLAG;
+
+ if (idx>0)
/* Don't propagate change out of this B-tree node */
*lt_key_changed = FALSE;
- } else {
+ else
HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey);
- }
}
if (*rt_key_changed) {
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
if (idx+1<bt->nchildren) {
/* Don't propagate change out of this B-tree node */
*rt_key_changed = FALSE;
@@ -1807,15 +1780,11 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
/* Make certain the native key for the right sibling is set up */
HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey);
- sibling_dirtied = TRUE;
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling,
- sibling_dirtied, H5AC__NO_FLAGS_SET)
- != SUCCEED)
+ H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
-
sibling=NULL; /* Make certain future references will be caught */
- sibling_dirtied = FALSE;
}
}
}
@@ -1831,7 +1800,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* keys and the subtree pointer. Free this node (unless it's the
* root node) and return H5B_INS_REMOVE.
*/
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
bt->nchildren = 0;
if (level>0) {
if (H5F_addr_defined(bt->left)) {
@@ -1839,15 +1808,11 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node from tree")
sibling->right = bt->right;
- sibling_dirtied = TRUE;
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->left, sibling,
- sibling_dirtied, H5AC__NO_FLAGS_SET)
- != SUCCEED)
+ H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
-
sibling=NULL; /* Make certain future references will be caught */
- sibling_dirtied = FALSE;
}
if (H5F_addr_defined(bt->right)) {
if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE)))
@@ -1857,27 +1822,23 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,0), type->sizeof_nkey);
sibling->left = bt->left;
- sibling_dirtied = TRUE;
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling,
- sibling_dirtied, H5AC__NO_FLAGS_SET)
- != SUCCEED)
+ H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
-
sibling=NULL; /* Make certain future references will be caught */
- sibling_dirtied = FALSE;
}
bt->left = HADDR_UNDEF;
bt->right = HADDR_UNDEF;
H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t);
if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode)<0
- || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied, H5C__DELETED_FLAG)<0) {
+ || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags | H5C__DELETED_FLAG)<0) {
bt = NULL;
- bt_dirtied = FALSE;
+ bt_flags = H5AC__NO_FLAGS_SET;
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node")
}
bt = NULL;
- bt_dirtied = FALSE;
+ bt_flags = H5AC__NO_FLAGS_SET;
}
} else if (H5B_INS_REMOVE==ret_value && 0==idx) {
@@ -1888,7 +1849,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* key into lt_key and notify the caller that the left key has
* changed. Return H5B_INS_NOOP.
*/
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
bt->nchildren -= 1;
HDmemmove(bt->native,
@@ -1908,7 +1869,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* freed). We copy the new right-most key into rt_key and notify the
* caller that the right key has changed. Return H5B_INS_NOOP.
*/
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
bt->nchildren -= 1;
HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey);
*rt_key_changed = TRUE;
@@ -1923,15 +1884,11 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey);
- sibling_dirtied = TRUE;
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling,
- sibling_dirtied, H5AC__NO_FLAGS_SET)
- != SUCCEED)
+ H5AC__DIRTIED_FLAG) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
-
sibling=NULL; /* Make certain future references will be caught */
- sibling_dirtied = FALSE;
}
}
@@ -1945,7 +1902,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* the right are shifted left by one place. The subtree has already
* been freed). Return H5B_INS_NOOP.
*/
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
bt->nchildren -= 1;
HDmemmove(bt->native + idx * type->sizeof_nkey,
@@ -1961,7 +1918,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
}
done:
- if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied, H5AC__NO_FLAGS_SET)<0)
+ if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags)<0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2002,7 +1959,7 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
uint8_t *rt_key = (uint8_t*)_rt_key; /*right key*/
hbool_t lt_key_changed = FALSE; /*left key changed?*/
hbool_t rt_key_changed = FALSE; /*right key changed?*/
- hbool_t bt_dirtied = FALSE;
+ unsigned bt_flags = H5AC__NO_FLAGS_SET;
H5B_t *bt = NULL; /*btree node */
herr_t ret_value=SUCCEED; /* Return value */
@@ -2028,16 +1985,12 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
if (0==bt->nchildren && 0!=bt->level) {
bt->level = 0;
- bt_dirtied = TRUE;
+ bt_flags |= H5AC__DIRTIED_FLAG;
}
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET)
- != SUCCEED)
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags) != SUCCEED)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
-
bt=NULL; /* Make certain future references will be caught */
- bt_dirtied = FALSE;
#ifdef H5B_DEBUG
H5B_assert(f, dxpl_id, addr, type, udata);
@@ -2070,7 +2023,6 @@ done:
herr_t
H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata)
{
- hbool_t bt_dirtied = FALSE;
H5B_t *bt; /* B-tree node being operated on */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
unsigned u; /* Local index variable */
@@ -2117,7 +2069,7 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree node")
done:
- if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied, H5C__DELETED_FLAG)<0)
+ if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5C__DELETED_FLAG)<0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node in cache")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2351,8 +2303,7 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
}
done:
- if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE,
- H5AC__NO_FLAGS_SET) < 0)
+ if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2386,7 +2337,6 @@ done:
static herr_t
H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void *udata)
{
- hbool_t bt_dirtied = FALSE;
H5B_t *bt = NULL;
H5B_shared_t *shared; /* Pointer to shared B-tree info */
int i, ncell, cmp;
@@ -2419,11 +2369,9 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
cur->level = bt->level;
head = tail = cur;
- status = H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET);
+ status = H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET);
assert(status >= 0);
bt=NULL; /* Make certain future references will be caught */
- bt_dirtied = FALSE;
/*
* Do a breadth-first search of the tree. New nodes are added to the end
@@ -2474,11 +2422,9 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
}
}
/* Release node */
- status = H5AC_unprotect(f, dxpl_id, H5AC_BT, cur->addr, bt, bt_dirtied,
- H5AC__NO_FLAGS_SET);
+ status = H5AC_unprotect(f, dxpl_id, H5AC_BT, cur->addr, bt, H5AC__NO_FLAGS_SET);
assert(status >= 0);
bt=NULL; /* Make certain future references will be caught */
- bt_dirtied = FALSE;
/* Advance current location in queue */
prev = cur;