summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5.c1
-rw-r--r--src/H5AC2.c73
-rw-r--r--src/H5AC2private.h4
-rw-r--r--src/H5Atest.c1
-rw-r--r--src/H5B.c287
-rw-r--r--src/H5Bcache.c401
-rw-r--r--src/H5Bpkg.h27
-rw-r--r--src/H5Bprivate.h10
-rw-r--r--src/H5C2.c221
-rw-r--r--src/H5C2journal.c119
-rw-r--r--src/H5C2pkg.h11
-rw-r--r--src/H5C2private.h63
-rw-r--r--src/H5D.c1
-rw-r--r--src/H5Ddbg.c1
-rw-r--r--src/H5Ddeprec.c1
-rw-r--r--src/H5Dfill.c1
-rw-r--r--src/H5Distore.c46
-rw-r--r--src/H5F.c81
-rw-r--r--src/H5Fpkg.h3
-rw-r--r--src/H5Fprivate.h17
-rw-r--r--src/H5Gnode.c60
-rw-r--r--src/H5I.c1
-rw-r--r--src/H5Omdj_msg.c25
-rw-r--r--src/H5Pdcpl.c1
-rw-r--r--src/H5Pfapl.c1
-rw-r--r--src/H5R.c1
-rw-r--r--src/H5Rdeprec.c1
-rw-r--r--src/H5T.c1
-rw-r--r--src/H5Tcommit.c1
-rw-r--r--src/H5Tdeprec.c1
-rw-r--r--src/H5Zscaleoffset.c1
31 files changed, 725 insertions, 738 deletions
diff --git a/src/H5.c b/src/H5.c
index 39f7b3a..049501c 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -22,6 +22,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
diff --git a/src/H5AC2.c b/src/H5AC2.c
index 49e4934..c4575b7 100644
--- a/src/H5AC2.c
+++ b/src/H5AC2.c
@@ -196,7 +196,7 @@ static herr_t H5AC2_receive_and_apply_clean_list(H5F_t * f,
hid_t dxpl_id,
H5AC2_t * cache_ptr);
-static herr_t H5AC2_log_renamed_entry(H5AC2_t * cache_ptr,
+static herr_t H5AC2_log_renamed_entry(H5F_t * f,
haddr_t old_addr,
haddr_t new_addr);
#endif /* H5_HAVE_PARALLEL */
@@ -617,8 +617,7 @@ H5AC2_create(const H5F_t *f,
if ( aux_ptr->mpi_rank == 0 ) {
- f->shared->cache2 = H5C2_create(f,
- H5AC2__DEFAULT_MAX_CACHE_SIZE,
+ f->shared->cache2 = H5C2_create(H5AC2__DEFAULT_MAX_CACHE_SIZE,
H5AC2__DEFAULT_MIN_CLEAN_SIZE,
(H5AC2_NTYPES - 1),
(const char **)H5AC2_entry_type_names,
@@ -629,8 +628,7 @@ H5AC2_create(const H5F_t *f,
} else {
- f->shared->cache2 = H5C2_create(f,
- H5AC2__DEFAULT_MAX_CACHE_SIZE,
+ f->shared->cache2 = H5C2_create(H5AC2__DEFAULT_MAX_CACHE_SIZE,
H5AC2__DEFAULT_MIN_CLEAN_SIZE,
(H5AC2_NTYPES - 1),
(const char **)H5AC2_entry_type_names,
@@ -646,8 +644,7 @@ H5AC2_create(const H5F_t *f,
} else {
- f->shared->cache2 = H5C2_create(f,
- H5AC2__DEFAULT_MAX_CACHE_SIZE,
+ f->shared->cache2 = H5C2_create(H5AC2__DEFAULT_MAX_CACHE_SIZE,
H5AC2__DEFAULT_MIN_CLEAN_SIZE,
(H5AC2_NTYPES - 1),
(const char **)H5AC2_entry_type_names,
@@ -663,8 +660,7 @@ H5AC2_create(const H5F_t *f,
* -- JRM
*/
- f->shared->cache2 = H5C2_create(f,
- H5AC2__DEFAULT_MAX_CACHE_SIZE,
+ f->shared->cache2 = H5C2_create(H5AC2__DEFAULT_MAX_CACHE_SIZE,
H5AC2__DEFAULT_MIN_CLEAN_SIZE,
(H5AC2_NTYPES - 1),
(const char **)H5AC2_entry_type_names,
@@ -694,7 +690,7 @@ H5AC2_create(const H5F_t *f,
}
#endif /* H5_HAVE_PARALLEL */
- result = H5AC2_set_cache_auto_resize_config(f->shared->cache2, config_ptr);
+ result = H5AC2_set_cache_auto_resize_config(f, config_ptr);
if ( result != SUCCEED ) {
@@ -803,7 +799,7 @@ H5AC2_dest(H5F_t *f, hid_t dxpl_id)
}
#endif /* H5AC2__TRACE_FILE_ENABLED */
- if ( H5C2_dest(cache, dxpl_id) < 0 ) {
+ if ( H5C2_dest(f, dxpl_id) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't destroy cache")
}
@@ -895,7 +891,7 @@ H5AC2_expunge_entry(H5F_t *f,
}
#endif /* H5AC2__TRACE_FILE_ENABLED */
- result = H5C2_expunge_entry(cache_ptr,
+ result = H5C2_expunge_entry(f,
dxpl_id,
type,
addr);
@@ -1076,7 +1072,7 @@ H5AC2_flush(H5F_t *f, hid_t dxpl_id, unsigned flags)
aux_ptr->write_permitted = TRUE;
- status = H5C2_flush_cache(f->shared->cache2,
+ status = H5C2_flush_cache(f,
dxpl_id,
init_flush_flags);
@@ -1101,7 +1097,7 @@ H5AC2_flush(H5F_t *f, hid_t dxpl_id, unsigned flags)
} /* end if ( aux_ptr != NULL ) */
#endif /* H5_HAVE_PARALLEL */
- status = H5C2_flush_cache(f->shared->cache2,
+ status = H5C2_flush_cache(f,
dxpl_id,
flags);
@@ -1157,7 +1153,6 @@ H5AC2_get_entry_status(H5F_t * f,
haddr_t addr,
unsigned * status_ptr)
{
- H5C2_t *cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
herr_t result;
hbool_t in_cache;
@@ -1169,15 +1164,15 @@ H5AC2_get_entry_status(H5F_t * f,
FUNC_ENTER_NOAPI(H5AC2_get_entry_status, FAIL)
- if ( ( cache_ptr == NULL ) ||
- ( cache_ptr->magic != H5C2__H5C2_T_MAGIC ) ||
+ if ( ( f->shared->cache2 == NULL ) ||
+ ( f->shared->cache2->magic != H5C2__H5C2_T_MAGIC ) ||
( ! H5F_addr_defined(addr) ) ||
( status_ptr == NULL ) ) {
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry.")
}
- result = H5C2_get_entry_status(cache_ptr, addr, &entry_size, &in_cache,
+ result = H5C2_get_entry_status(f, addr, &entry_size, &in_cache,
&is_dirty, &is_protected, &is_pinned);
if ( result < 0 ) {
@@ -1282,7 +1277,6 @@ H5AC2_set(H5F_t *f, hid_t dxpl_id, const H5AC2_class_t *type, haddr_t addr, size
{
herr_t result;
H5AC2_info_t *info;
- H5AC2_t *cache;
herr_t ret_value=SUCCEED; /* Return value */
#ifdef H5_HAVE_PARALLEL
H5AC2_aux_t * aux_ptr = NULL;
@@ -1325,7 +1319,6 @@ H5AC2_set(H5F_t *f, hid_t dxpl_id, const H5AC2_class_t *type, haddr_t addr, size
#endif /* H5AC2__TRACE_FILE_ENABLED */
/* Get local copy of this information */
- cache = f->shared->cache2;
info = (H5AC2_info_t *)thing;
info->addr = addr;
@@ -1350,7 +1343,7 @@ H5AC2_set(H5F_t *f, hid_t dxpl_id, const H5AC2_class_t *type, haddr_t addr, size
}
#endif /* H5_HAVE_PARALLEL */
- result = H5C2_insert_entry(cache,
+ result = H5C2_insert_entry(f,
dxpl_id,
type,
addr,
@@ -1432,7 +1425,9 @@ H5AC2_mark_pinned_entry_dirty(H5F_t * f,
hbool_t size_changed,
size_t new_size)
{
+#ifdef H5_HAVE_PARALLEL
H5C2_t *cache_ptr = f->shared->cache2;
+#endif /* H5_HAVE_PARALLEL */
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
#if H5AC2__TRACE_FILE_ENABLED
@@ -1501,7 +1496,7 @@ H5AC2_mark_pinned_entry_dirty(H5F_t * f,
}
#endif /* H5_HAVE_PARALLEL */
- result = H5C2_mark_pinned_entry_dirty(cache_ptr,
+ result = H5C2_mark_pinned_entry_dirty(f,
thing,
size_changed,
new_size);
@@ -1553,8 +1548,8 @@ herr_t
H5AC2_mark_pinned_or_protected_entry_dirty(H5F_t * f,
void * thing)
{
- H5C2_t * cache_ptr = f->shared->cache2;
#ifdef H5_HAVE_PARALLEL
+ H5C2_t * cache_ptr = f->shared->cache2;
H5AC2_info_t * info_ptr;
#endif /* H5_HAVE_PARALLEL */
herr_t result;
@@ -1609,7 +1604,7 @@ H5AC2_mark_pinned_or_protected_entry_dirty(H5F_t * f,
}
#endif /* H5_HAVE_PARALLEL */
- result = H5C2_mark_pinned_or_protected_entry_dirty(cache_ptr, thing);
+ result = H5C2_mark_pinned_or_protected_entry_dirty(f, thing);
if ( result < 0 ) {
@@ -1724,7 +1719,7 @@ H5AC2_rename(H5F_t *f, const H5AC2_class_t *type, haddr_t old_addr, haddr_t new_
#ifdef H5_HAVE_PARALLEL
if ( NULL != (aux_ptr = f->shared->cache2->aux_ptr) ) {
- result = H5AC2_log_renamed_entry(f->shared->cache2,
+ result = H5AC2_log_renamed_entry(f,
old_addr,
new_addr);
@@ -1801,7 +1796,6 @@ herr_t
H5AC2_pin_protected_entry(H5F_t * f,
void * thing)
{
- H5C2_t *cache_ptr = f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
#if H5AC2__TRACE_FILE_ENABLED
@@ -1826,7 +1820,7 @@ H5AC2_pin_protected_entry(H5F_t * f,
}
#endif /* H5AC2__TRACE_FILE_ENABLED */
- result = H5C2_pin_protected_entry(cache_ptr, thing);
+ result = H5C2_pin_protected_entry(f, thing);
if ( result < 0 ) {
@@ -1995,7 +1989,7 @@ H5AC2_protect(H5F_t *f,
protect_flags |= H5C2__READ_ONLY_FLAG;
}
- thing = H5C2_protect(f->shared->cache2,
+ thing = H5C2_protect(f,
dxpl_id,
type,
addr,
@@ -2059,7 +2053,9 @@ H5AC2_resize_pinned_entry(H5F_t * f,
void * thing,
size_t new_size)
{
+#ifdef H5_HAVE_PARALLEL
H5C2_t *cache_ptr = f->shared->cache2;
+#endif /* H5_HAVE_PARALLEL */
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
#if H5AC2__TRACE_FILE_ENABLED
@@ -2125,7 +2121,7 @@ H5AC2_resize_pinned_entry(H5F_t * f,
}
#endif /* H5_HAVE_PARALLEL */
- result = H5C2_resize_pinned_entry(cache_ptr,
+ result = H5C2_resize_pinned_entry(f,
thing,
new_size);
if ( result < 0 ) {
@@ -2173,7 +2169,6 @@ herr_t
H5AC2_unpin_entry(H5F_t * f,
void * thing)
{
- H5C2_t *cache_ptr = f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
#if H5AC2__TRACE_FILE_ENABLED
@@ -2198,7 +2193,7 @@ H5AC2_unpin_entry(H5F_t * f,
}
#endif /* H5AC2__TRACE_FILE_ENABLED */
- result = H5C2_unpin_entry(cache_ptr, thing);
+ result = H5C2_unpin_entry(f, thing);
if ( result < 0 ) {
@@ -2406,7 +2401,7 @@ H5AC2_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC2_class_t *type,
}
#endif /* H5_HAVE_PARALLEL */
- result = H5C2_unprotect(f->shared->cache2,
+ result = H5C2_unprotect(f,
dxpl_id,
type,
addr,
@@ -2883,10 +2878,11 @@ done:
*/
herr_t
-H5AC2_set_cache_auto_resize_config(H5AC2_t * cache_ptr,
+H5AC2_set_cache_auto_resize_config(const H5F_t * f,
H5AC2_cache_config_t *config_ptr)
{
/* const char * fcn_name = "H5AC2_set_cache_auto_resize_config"; */
+ H5AC2_t * cache_ptr = (H5AC2_t *)f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
H5C2_auto_size_ctl_t internal_config;
@@ -2994,7 +2990,7 @@ H5AC2_set_cache_auto_resize_config(H5AC2_t * cache_ptr,
"H5AC2_ext_config_2_int_config() failed.")
}
- result = H5C2_set_cache_auto_resize_config((H5C2_t *)cache_ptr,
+ result = H5C2_set_cache_auto_resize_config(f,
&internal_config);
if ( result < 0 ) {
@@ -3003,7 +2999,7 @@ H5AC2_set_cache_auto_resize_config(H5AC2_t * cache_ptr,
}
- result = H5C2_set_evictions_enabled((H5C2_t *)cache_ptr,
+ result = H5C2_set_evictions_enabled(f,
config_ptr->evictions_enabled);
if ( result < 0 ) {
@@ -4333,11 +4329,12 @@ done:
#ifdef H5_HAVE_PARALLEL
static herr_t
-H5AC2_log_renamed_entry(H5AC2_t * cache_ptr,
+H5AC2_log_renamed_entry(H5F_t * f,
haddr_t old_addr,
haddr_t new_addr)
{
herr_t ret_value = SUCCEED; /* Return value */
+ H5AC2_t * cache_ptr = (H5AC2_t *)f->shared->cache2;
hbool_t entry_in_cache;
hbool_t entry_dirty;
size_t entry_size;
@@ -4355,7 +4352,7 @@ H5AC2_log_renamed_entry(H5AC2_t * cache_ptr,
HDassert( aux_ptr->magic == H5AC2__H5AC2_AUX_T_MAGIC );
/* get entry status, size, etc here */
- if ( H5C2_get_entry_status(cache_ptr, old_addr, &entry_size, &entry_in_cache,
+ if ( H5C2_get_entry_status(f, old_addr, &entry_size, &entry_in_cache,
&entry_dirty, NULL, NULL) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get entry status.")
@@ -4609,7 +4606,7 @@ H5AC2_propagate_flushed_and_still_clean_entries_list(H5F_t * f,
aux_ptr->write_permitted = TRUE;
- result = H5C2_flush_to_min_clean(cache_ptr, dxpl_id);
+ result = H5C2_flush_to_min_clean(f, dxpl_id);
aux_ptr->write_permitted = FALSE;
diff --git a/src/H5AC2private.h b/src/H5AC2private.h
index ca2522f..6676d7e 100644
--- a/src/H5AC2private.h
+++ b/src/H5AC2private.h
@@ -128,7 +128,7 @@ typedef enum {
typedef H5C2_deserialize_func_t H5AC2_deserialize_func_t;
typedef H5C2_image_len_func_t H5AC2_image_len_func_t;
typedef H5C2_serialize_func_t H5AC2_serialize_func_t;
-typedef H5C2_free_icr_func_t H5CA2_free_icr_func_t;
+typedef H5C2_free_icr_func_t H5AC2_free_icr_func_t;
typedef H5C2_clear_dirty_bits_func_t H5AC2_clear_dirty_bits_func_t;
typedef H5C2_class_t H5AC2_class_t;
@@ -305,7 +305,7 @@ H5_DLL herr_t H5AC2_get_cache_hit_rate(H5AC2_t * cache_ptr,
H5_DLL herr_t H5AC2_reset_cache_hit_rate_stats(H5AC2_t * cache_ptr);
-H5_DLL herr_t H5AC2_set_cache_auto_resize_config(H5AC2_t * cache_ptr,
+H5_DLL herr_t H5AC2_set_cache_auto_resize_config(const H5F_t * f,
H5AC2_cache_config_t *config_ptr);
H5_DLL herr_t H5AC2_validate_config(H5AC2_cache_config_t * config_ptr);
diff --git a/src/H5Atest.c b/src/H5Atest.c
index df88472..845c6c8 100644
--- a/src/H5Atest.c
+++ b/src/H5Atest.c
@@ -37,6 +37,7 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5SMprivate.h" /* Shared object header messages */
diff --git a/src/H5B.c b/src/H5B.c
index 9847b7a..01dc119 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -236,6 +236,7 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
bt->nchildren = 0;
if((bt->rc_shared=(type->get_shared)(f, udata))==NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree node buffer")
+ H5RC_INC(bt->rc_shared);
shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) ||
@@ -247,7 +248,7 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
/*
* Cache the new B-tree node.
*/
- if (H5AC_set(f, dxpl_id, H5AC_BT, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_set(f, dxpl_id, H5AC2_BT, *addr_p, shared->sizeof_rnode, bt, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache")
#ifdef H5B_DEBUG
H5B_assert(f, dxpl_id, *addr_p, shared->type, udata);
@@ -260,7 +261,7 @@ done:
(void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)shared->sizeof_rnode);
} /* end if */
if (bt)
- (void)H5B_dest(f,bt);
+ (void)H5B_dest(bt);
}
FUNC_LEAVE_NOAPI(ret_value)
@@ -297,8 +298,10 @@ herr_t
H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata)
{
H5B_t *bt = NULL;
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
- unsigned idx=0, lt = 0, rt; /* Final, left & right key indices */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
+ unsigned idx=0, lt = 0, rt; /* Final, left & right key indices */
int cmp = 1; /* Key comparison value */
int ret_value = SUCCEED; /* Return value */
@@ -314,14 +317,21 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u
assert(type->found);
assert(H5F_addr_defined(addr));
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/*
* Perform a binary search to locate the child which contains
* the thing for which we're searching.
*/
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
rt = bt->nchildren;
while (lt < rt && cmp) {
@@ -375,8 +385,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, H5AC__NO_FLAGS_SET)
- < 0)
+ if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -425,6 +434,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
{
H5P_genplist_t *dx_plist; /* Data transfer property list */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
unsigned new_bt_flags = H5AC__NO_FLAGS_SET;
H5B_t *new_bt = NULL;
unsigned nleft, nright; /* Number of keys in left & right halves */
@@ -507,7 +517,10 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
*/
if (H5B_create(f, dxpl_id, shared->type, udata, new_addr_p/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree")
- if (NULL==(new_bt=(H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_addr_p, shared->type, udata, H5AC_WRITE)))
+ cache_udata.f = f;
+ cache_udata.type = shared->type;
+ cache_udata.rc_shared = old_bt->rc_shared;
+ if(NULL == (new_bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, *new_addr_p, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree")
new_bt->level = old_bt->level;
@@ -544,24 +557,26 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
new_bt->left = old_addr;
new_bt->right = old_bt->right;
- if (H5F_addr_defined(old_bt->right)) {
+ if(H5F_addr_defined(old_bt->right)) {
H5B_t *tmp_bt;
+ H5B_cache_ud_t cache_udata2; /* User-data for metadata cache callback */
- if (NULL == (tmp_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, shared->type, udata, H5AC_WRITE)))
+ cache_udata2.f = f;
+ cache_udata2.type = shared->type;
+ cache_udata2.rc_shared = old_bt->rc_shared;
+ if(NULL == (tmp_bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, old_bt->right, shared->sizeof_rnode, &cache_udata2, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling")
tmp_bt->left = *new_addr_p;
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, old_bt->right, tmp_bt,
- H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, old_bt->right, (size_t)0, tmp_bt, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
- }
+ } /* end if */
old_bt->right = *new_addr_p;
done:
- if (new_bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_addr_p, new_bt,
- new_bt_flags) < 0)
+ if(new_bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, *new_addr_p, (size_t)0, new_bt, new_bt_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -618,7 +633,9 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
unsigned level;
H5B_t *bt;
H5B_t *new_bt; /* Copy of B-tree info */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
H5B_ins_t my_ins = H5B_INS_ERROR;
herr_t ret_value = SUCCEED;
@@ -635,31 +652,38 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key")
if (H5B_INS_NOOP == my_ins)
HGOTO_DONE(SUCCEED)
- assert(H5B_INS_RIGHT == my_ins);
+ HDassert(H5B_INS_RIGHT == my_ins);
+
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
/* the current root */
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree")
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
level = bt->level;
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, H5AC__NO_FLAGS_SET) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
bt = NULL;
/* the new node */
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_READ)))
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, child, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node")
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, H5AC__NO_FLAGS_SET) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, child, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
bt = NULL;
@@ -673,21 +697,21 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root")
/* update the new child's left pointer */
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_WRITE)))
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, child, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child")
bt->left = old_root;
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, child, (size_t)0, bt, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
- bt=NULL; /* Make certain future references will be caught */
+ bt = NULL; /* Make certain future references will be caught */
/*
* Move the node to the new location by checking it out & checking it in
* at the new location -QAK
*/
/* Bring the old root into the cache if it's not already */
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE)))
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child")
/* Make certain the old root info is marked as dirty before moving it, */
@@ -697,18 +721,18 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
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, H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__DIRTIED_FLAG) < 0)
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, H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
- bt=NULL; /* Make certain future references will be caught */
+ bt = NULL; /* Make certain future references will be caught */
/* Move the location of the old root on the disk */
- if (H5AC_rename(f, H5AC_BT, addr, old_root) < 0)
+ if(H5AC2_rename(f, H5AC2_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) */
@@ -728,7 +752,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
HDmemcpy(H5B_NKEY(new_bt,shared,2), rt_key, shared->type->sizeof_nkey);
/* Insert the modified copy of the old root into the file again */
- if (H5AC_set(f, dxpl_id, H5AC_BT, addr, new_bt, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_set(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, new_bt, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to flush old B-tree root node")
#ifdef H5B_DEBUG
@@ -885,7 +909,9 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
{
unsigned bt_flags = H5AC__NO_FLAGS_SET, twin_flags = H5AC__NO_FLAGS_SET;
H5B_t *bt = NULL, *twin = NULL;
+ H5RC_t *rc_shared; /* Ref-counted shared info */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */
int cmp = -1; /* Key comparison value */
haddr_t child_addr = HADDR_UNDEF;
@@ -912,15 +938,22 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
*lt_key_changed = FALSE;
*rt_key_changed = FALSE;
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/*
* Use a binary search to find the child that will receive the new
* data. When the search completes IDX points to the child that
* should get the new data.
*/
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node")
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
rt = bt->nchildren;
while (lt < rt && cmp) {
@@ -1088,7 +1121,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
if (bt->nchildren == shared->two_k) {
if (H5B_split(f, dxpl_id, bt, &bt_flags, addr, idx, udata, new_node_p/*out*/)<0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node")
- if (NULL == (twin = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE)))
+ if(NULL == (twin = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, *new_node_p, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node")
if (idx<bt->nchildren) {
tmp_bt = bt;
@@ -1130,10 +1163,8 @@ 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_flags) < 0);
- herr_t e2 = (twin && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_node_p,
- twin, twin_flags)<0);
+ herr_t e1 = (bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags) < 0);
+ herr_t e2 = (twin && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, *new_node_p, (size_t)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)")
}
@@ -1175,6 +1206,9 @@ 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)
{
H5B_t *bt = NULL; /* Pointer to current B-tree node */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5B_iterate, FAIL)
@@ -1188,8 +1222,17 @@ H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op,
HDassert(H5F_addr_defined(addr));
HDassert(udata);
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/* Protect the initial/current node */
- if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
if(bt->level > 0) {
@@ -1226,7 +1269,7 @@ H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op,
/* Protect the next node to the right, if there is one */
if(H5F_addr_defined(bt->right)) {
next_addr = bt->right;
- if(NULL == (next_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, next_addr, type, udata, H5AC_READ)))
+ if(NULL == (next_bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, next_addr, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node")
} /* end if */
else {
@@ -1235,10 +1278,10 @@ H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op,
} /* end if */
/* Unprotect this node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) {
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0) {
if(next_bt) {
HDassert(H5F_addr_defined(next_addr));
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, next_addr, next_bt, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, next_addr, (size_t)0, next_bt, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
} /* end if */
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
@@ -1252,7 +1295,7 @@ H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op,
} /* end else */
done:
- if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
+ if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1300,7 +1343,9 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
{
H5B_t *bt = NULL, *sibling = NULL;
unsigned bt_flags = H5AC__NO_FLAGS_SET;
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
unsigned idx=0, lt=0, rt; /* Final, left & right indices */
int cmp=1; /* Key comparison value */
H5B_ins_t ret_value = H5B_INS_ERROR;
@@ -1316,14 +1361,21 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
assert(udata);
assert(rt_key && rt_key_changed);
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/*
* Perform a binary search to locate the child which contains the thing
* for which we're searching.
*/
- if (NULL==(bt=(H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node")
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
rt = bt->nchildren;
while (lt<rt && cmp) {
@@ -1402,14 +1454,13 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
*/
if (ret_value!=H5B_INS_REMOVE && level>0) {
if (H5F_addr_defined(bt->right)) {
- if (NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE)))
+ if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->right, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
/* 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);
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling,
- H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->right, (size_t)0, sibling, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
sibling=NULL; /* Make certain future references will be caught */
}
@@ -1431,18 +1482,17 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
bt->nchildren = 0;
if (level>0) {
if (H5F_addr_defined(bt->left)) {
- if (NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata, H5AC_WRITE)))
+ if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->left, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node from tree")
sibling->right = bt->right;
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->left, sibling,
- H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->left, (size_t)0, sibling, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
sibling=NULL; /* Make certain future references will be caught */
}
if (H5F_addr_defined(bt->right)) {
- if (NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE)))
+ if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->right, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
/* Copy left-most key from deleted node to left-most key in it's right neighbor */
@@ -1450,8 +1500,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
sibling->left = bt->left;
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling,
- H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->right, (size_t)0, sibling, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
sibling=NULL; /* Make certain future references will be caught */
}
@@ -1459,7 +1508,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
bt->right = HADDR_UNDEF;
H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t);
if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode)<0
- || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags | H5C__DELETED_FLAG)<0) {
+ || H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags | H5C__DELETED_FLAG) < 0) {
bt = NULL;
bt_flags = H5AC__NO_FLAGS_SET;
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node")
@@ -1507,13 +1556,12 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
*/
if (level>0) {
if (H5F_addr_defined(bt->right)) {
- if (NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE)))
+ if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->right, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
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);
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling,
- H5AC__DIRTIED_FLAG) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->right, (size_t)0, sibling, H5AC__DIRTIED_FLAG) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
sibling=NULL; /* Make certain future references will be caught */
}
@@ -1545,7 +1593,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_flags)<0)
+ if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1588,6 +1636,9 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
hbool_t rt_key_changed = FALSE; /*right key changed?*/
unsigned bt_flags = H5AC__NO_FLAGS_SET;
H5B_t *bt = NULL; /*btree node */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B_remove, FAIL)
@@ -1603,11 +1654,20 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
udata, rt_key, &rt_key_changed)==H5B_INS_ERROR)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree")
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/*
* If the B-tree is now empty then make sure we mark the root node as
* being at level zero
*/
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node")
if (0==bt->nchildren && 0!=bt->level) {
@@ -1615,7 +1675,7 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
bt_flags |= H5AC__DIRTIED_FLAG;
}
- if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags) != SUCCEED)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
bt=NULL; /* Make certain future references will be caught */
@@ -1650,8 +1710,10 @@ done:
herr_t
H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata)
{
- H5B_t *bt; /* B-tree node being operated on */
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_t *bt = NULL; /* B-tree node being operated on */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
unsigned u; /* Local index variable */
herr_t ret_value=SUCCEED; /* Return value */
@@ -1662,11 +1724,18 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
assert(type);
assert(H5F_addr_defined(addr));
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/* Lock this B-tree node into memory for now */
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_WRITE)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
/* Iterate over all children in tree, deleting them */
if (bt->level > 0) {
@@ -1696,7 +1765,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, H5C__DELETED_FLAG)<0)
+ if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, 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)
@@ -1846,7 +1915,9 @@ H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
H5B_operator_t op, haddr_t addr, H5B_info_ud_t *bh_udata)
{
H5B_t *bt = NULL; /* Pointer to current B-tree node */
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B_iterate_size, FAIL)
@@ -1859,11 +1930,18 @@ H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
HDassert(H5F_addr_defined(addr));
HDassert(bh_udata);
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, bh_udata->udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/* Protect the initial/current node */
- if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, bh_udata->udata, H5AC_READ)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
- shared = H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
/* Keep following the left-most child until we reach a leaf node. */
if(bt->level > 0)
@@ -1893,13 +1971,13 @@ H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
next_addr = bt->right;
/* Unprotect current node */
- if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
/* Protect bt's next node to the right, if there is one */
if(H5F_addr_defined(next_addr)) {
addr = next_addr;
- if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, bh_udata->udata, H5AC_READ)))
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node")
} /* end if */
else
@@ -1907,7 +1985,7 @@ H5B_iterate_size(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type,
} /* end while */
done:
- if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0)
+ if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1915,6 +1993,38 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B_dest
+ *
+ * Purpose: Destroy/release an "in core representation" of a B-tree node
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Mar 26, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B_dest(H5B_t *bt)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_dest)
+
+ /* check arguments */
+ HDassert(bt);
+ HDassert(bt->rc_shared);
+
+ H5FL_SEQ_FREE(haddr_t, bt->child);
+ H5FL_BLK_FREE(native_block, bt->native);
+ H5RC_DEC(bt->rc_shared);
+ H5FL_FREE(H5B_t, bt);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5B_dest() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B_debug
*
* Purpose: Prints debugging info about a B-tree.
@@ -1935,7 +2045,9 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
const H5B_class_t *type, void *udata)
{
H5B_t *bt = NULL;
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
unsigned u; /* Local index variable */
herr_t ret_value=SUCCEED; /* Return value */
@@ -1951,13 +2063,20 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
assert(fwidth >= 0);
assert(type);
+ /* Get shared info for B-tree */
+ if(NULL == (rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
+ HDassert(shared);
+
/*
* Load the tree node.
*/
- if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ)))
+ cache_udata.f = f;
+ cache_udata.type = type;
+ cache_udata.rc_shared = rc_shared;
+ if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
/*
* Print the values.
@@ -2018,7 +2137,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, H5AC__NO_FLAGS_SET) < 0)
+ if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Bcache.c b/src/H5Bcache.c
index 2748963..553876a 100644
--- a/src/H5Bcache.c
+++ b/src/H5Bcache.c
@@ -38,176 +38,112 @@
#include "H5Bpkg.h" /* B-link trees */
#include "H5Eprivate.h" /* Error handling */
+
/****************/
/* Local Macros */
/****************/
+
/******************/
/* Local Typedefs */
/******************/
+
/********************/
/* Local Prototypes */
/********************/
-/* General routines */
-static herr_t H5B_serialize(const H5F_t *f, const H5B_t *bt);
-
/* Metadata cache callbacks */
-static H5B_t *H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata);
-static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *b, unsigned UNUSED * flags_ptr);
-static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy);
-static herr_t H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr);
+static void *H5B_deserialize(haddr_t addr, size_t len, const void *image,
+ const void *udata, hbool_t *dirty);
+static herr_t H5B_serialize(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 H5B_free_icr(haddr_t addr, size_t len, void *thing);
+
/*********************/
/* Package Variables */
/*********************/
/* H5B inherits cache-like properties from H5AC */
-const H5AC_class_t H5AC_BT[1] = {{
- H5AC_BT_ID,
- (H5AC_load_func_t)H5B_load,
- (H5AC_flush_func_t)H5B_flush,
- (H5AC_dest_func_t)H5B_dest,
- (H5AC_clear_func_t)H5B_clear,
- (H5AC_size_func_t)H5B_compute_size,
+const H5AC2_class_t H5AC2_BT[1] = {{
+ H5AC2_BT_ID,
+ "v1 B-tree",
+ H5FD_MEM_BTREE,
+ H5B_deserialize,
+ NULL,
+ H5B_serialize,
+ H5B_free_icr,
+ NULL
}};
/*******************/
/* Local Variables */
/*******************/
+
/*-------------------------------------------------------------------------
- * Function: H5B_serialize
+ * Function: H5B_deserialize
*
- * Purpose: Serialize the data structure for writing to disk.
+ * Purpose: Deserialize the data structure from disk.
*
* Return: Success: SUCCEED
* Failure: FAIL
*
- * Programmer: Bill Wendling
- * wendling@ncsa.uiuc.edu
- * Sept. 15, 2003
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Mar 24, 2008
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5B_serialize(const H5F_t *f, const H5B_t *bt)
+static void *
+H5B_deserialize(haddr_t UNUSED addr, size_t UNUSED len, const void *image, const void *_udata,
+ hbool_t UNUSED *dirty)
{
- H5B_shared_t *shared=NULL; /* Pointer to shared B-tree info */
- unsigned u;
- uint8_t *p; /* Pointer into raw data buffer */
- uint8_t *native; /* Pointer to native keys */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5B_t *bt = NULL; /* Pointer to the deserialized B-tree node */
+ const H5B_cache_ud_t *udata = (const H5B_cache_ud_t *)_udata; /* User data for callback */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ const uint8_t *p; /* Pointer into image buffer */
+ uint8_t *native; /* Pointer to native keys */
+ unsigned u; /* Local index variable */
+ H5B_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5B_serialize, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT(H5B_deserialize)
/* check arguments */
- HDassert(f);
- HDassert(bt);
- HDassert(bt->rc_shared);
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
+ HDassert(image);
- p = shared->page;
+ /* Allocate the B-tree node in memory */
+ if(NULL == (bt = H5FL_MALLOC(H5B_t)))
+ HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "can't allocate B-tree struct")
+ HDmemset(&bt->cache_info, 0, sizeof(bt->cache_info));
- /* magic number */
- HDmemcpy(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC);
- p += 4;
-
- /* node type and level */
- *p++ = (uint8_t)shared->type->id;
- H5_CHECK_OVERFLOW(bt->level, unsigned, uint8_t);
- *p++ = (uint8_t)bt->level;
-
- /* entries used */
- UINT16ENCODE(p, bt->nchildren);
-
- /* sibling pointers */
- H5F_addr_encode(f, &p, bt->left);
- H5F_addr_encode(f, &p, bt->right);
+ /* Set & increment the ref-counted "shared" B-tree information for the node */
+ bt->rc_shared = udata->rc_shared;
+ H5RC_INC(bt->rc_shared);
- /* child keys and pointers */
- native=bt->native;
- for (u = 0; u < bt->nchildren; ++u) {
- /* encode the key */
- if (shared->type->encode(f, bt, p, native) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
- p += shared->sizeof_rkey;
- native += shared->type->sizeof_nkey;
-
- /* encode the child address */
- H5F_addr_encode(f, &p, bt->child[u]);
- } /* end for */
- if(bt->nchildren>0) {
- /* Encode the final key */
- if (shared->type->encode(f, bt, p, native) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B_serialize() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5B_load
- *
- * Purpose: Loads a B-tree node from the disk.
- *
- * Return: Success: Pointer to a new B-tree node.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
- *
- *-------------------------------------------------------------------------
- */
-static H5B_t *
-H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
-{
- const H5B_class_t *type = (const H5B_class_t *) _type;
- H5B_t *bt = NULL;
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
- uint8_t *p; /* Pointer into raw data buffer */
- uint8_t *native; /* Pointer to native keys */
- unsigned u; /* Local index variable */
- H5B_t *ret_value;
-
- FUNC_ENTER_NOAPI(H5B_load, NULL)
-
- /* Check arguments */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(type);
- HDassert(type->get_shared);
-
- if (NULL==(bt = H5FL_MALLOC(H5B_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemset(&bt->cache_info,0,sizeof(H5AC_info_t));
- if((bt->rc_shared=(type->get_shared)(f, udata))==NULL)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer")
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
+ /* Get a pointer to the shared info, for convenience */
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
- if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) ||
- NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- if (H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page)<0)
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node")
+ /* Allocate space for the native keys and child addresses */
+ if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)))
+ HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "can't allocate buffer for native keys")
+ if(NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k)))
+ HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "can't allocate buffer for child addresses")
- p = shared->page;
+ /* Set the pointer into the image */
+ p = image;
/* magic number */
- if (HDmemcmp(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC))
+ if(HDmemcmp(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature")
p += 4;
/* node type and level */
- if (*p++ != (uint8_t)type->id)
+ if(*p++ != (uint8_t)udata->type->id)
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type")
bt->level = *p++;
@@ -215,26 +151,26 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
UINT16DECODE(p, bt->nchildren);
/* sibling pointers */
- H5F_addr_decode(f, (const uint8_t **) &p, &(bt->left));
- H5F_addr_decode(f, (const uint8_t **) &p, &(bt->right));
+ H5F_addr_decode(udata->f, (const uint8_t **)&p, &(bt->left));
+ H5F_addr_decode(udata->f, (const uint8_t **)&p, &(bt->right));
/* the child/key pairs */
- native=bt->native;
- for (u = 0; u < bt->nchildren; u++) {
+ native = bt->native;
+ for(u = 0; u < bt->nchildren; u++) {
/* Decode native key value */
- if ((type->decode) (f, bt, p, native) < 0)
+ if((udata->type->decode)(shared, p, native) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key")
p += shared->sizeof_rkey;
- native += type->sizeof_nkey;
+ native += udata->type->sizeof_nkey;
/* Decode address value */
- H5F_addr_decode(f, (const uint8_t **) &p, bt->child + u);
- }
+ H5F_addr_decode(udata->f, (const uint8_t **)&p, bt->child + u);
+ } /* end for */
/* Decode final key */
- if(bt->nchildren>0) {
+ if(bt->nchildren > 0) {
/* Decode native key value */
- if ((type->decode) (f, bt, p, native) < 0)
+ if((udata->type->decode)(shared, p, native) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key")
} /* end if */
@@ -242,182 +178,119 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
ret_value = bt;
done:
- if (!ret_value && bt)
- (void)H5B_dest(f,bt);
+ if(!ret_value && bt)
+ (void)H5B_dest(bt);
+
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B_load() */ /*lint !e818 Can't make udata a pointer to const */
+} /* end H5B_deserialize() */
/*-------------------------------------------------------------------------
- * Function: H5B_flush
- *
- * Purpose: Flushes a dirty B-tree node to disk.
+ * Function: H5B_serialize
*
- * Return: Non-negative on success/Negative on failure
+ * Purpose: Serialize the data structure for writing to disk.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
- * Changes: JRM -- 8/21/06
- * Added the flags_ptr parameter. This parameter exists to
- * allow the flush routine to report to the cache if the
- * entry is resized or renamed as a result of the flush.
- * *flags_ptr is set to H5C_CALLBACK__NO_FLAGS_SET on entry.
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Mar 24, 2008
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, unsigned UNUSED * flags_ptr)
+H5B_serialize(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)
{
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ H5B_t *bt = (H5B_t *)_thing; /* Pointer to the B-tree node */
+ H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ uint8_t *p; /* Pointer into image buffer */
+ uint8_t *native; /* Pointer to native keys */
+ unsigned u;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5B_flush, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT(H5B_serialize)
/* check arguments */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
+ HDassert(image);
HDassert(bt);
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
+ HDassert(bt->rc_shared);
+ HDassert(flags);
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
- HDassert(shared->type);
- HDassert(shared->type->encode);
-
- if (bt->cache_info.is_dirty) {
- if (H5B_serialize(f, bt) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTSERIALIZE, FAIL, "unable to serialize B-tree")
-
- /*
- * Write the disk page. We always write the header, but we don't
- * bother writing data for the child entries that don't exist or
- * for the final unchanged children.
- */
- if (H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree node to disk")
-
- bt->cache_info.is_dirty = FALSE;
- } /* end if */
-
- if (destroy)
- if (H5B_dest(f,bt) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B_flush() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5B_dest
- *
- * Purpose: Destroys a B-tree node in memory.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Jan 15 2003
- *
- *-------------------------------------------------------------------------
- */
-/* ARGSUSED */
-herr_t
-H5B_dest(H5F_t UNUSED *f, H5B_t *bt)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_dest)
- /*
- * Check arguments.
- */
- HDassert(bt);
- HDassert(bt->rc_shared);
+ /* Set the local pointer into the serialized image */
+ p = image;
- H5FL_SEQ_FREE(haddr_t,bt->child);
- H5FL_BLK_FREE(native_block,bt->native);
- H5RC_DEC(bt->rc_shared);
- H5FL_FREE(H5B_t,bt);
+ /* magic number */
+ HDmemcpy(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC);
+ p += 4;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5B_dest() */
+ /* node type and level */
+ *p++ = (uint8_t)shared->type->id;
+ H5_CHECK_OVERFLOW(bt->level, unsigned, uint8_t);
+ *p++ = (uint8_t)bt->level;
-
-/*-------------------------------------------------------------------------
- * Function: H5B_clear
- *
- * Purpose: Mark a B-tree node in memory as non-dirty.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Mar 20 2003
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5B_clear(H5F_t *f, H5B_t *bt, hbool_t destroy)
-{
- herr_t ret_value = SUCCEED;
+ /* entries used */
+ UINT16ENCODE(p, bt->nchildren);
- FUNC_ENTER_NOAPI_NOINIT(H5B_clear)
+ /* sibling pointers */
+ H5F_addr_encode_len(&p, bt->left, shared->sizeof_addr);
+ H5F_addr_encode_len(&p, bt->right, shared->sizeof_addr);
- /*
- * Check arguments.
- */
- HDassert(bt);
+ /* child keys and pointers */
+ native = bt->native;
+ for(u = 0; u < bt->nchildren; ++u) {
+ /* encode the key */
+ if(shared->type->encode(shared, p, native) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
+ p += shared->sizeof_rkey;
+ native += shared->type->sizeof_nkey;
- /* Reset the dirty flag. */
- bt->cache_info.is_dirty = FALSE;
+ /* encode the child address */
+ H5F_addr_encode_len(&p, bt->child[u], shared->sizeof_addr);
+ } /* end for */
+ if(bt->nchildren > 0) {
+ /* Encode the final key */
+ if(shared->type->encode(shared, p, native) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
+ } /* end if */
- if (destroy)
- if (H5B_dest(f, bt) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node")
+ /* Reset the cache flags for this operation (metadata not resized or renamed) */
+ *flags = 0;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B_clear() */
+} /* end H5B_serialize() */
/*-------------------------------------------------------------------------
- * Function: H5B_compute_size
+ * Function: H5B_free_icr
*
- * Purpose: Compute the size in bytes of the specified instance of
- * H5B_t on disk, and return it in *len_ptr. On failure,
- * the value of *len_ptr is undefined.
+ * Purpose: Destroy/release an "in core representation" of a data structure
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Success: SUCCEED
+ * Failure: FAIL
*
- * Programmer: John Mainzer
- * 5/13/04
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Mar 26, 2008
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr)
+H5B_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing)
{
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
- size_t size;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5B_compute_size)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_free_icr)
- /* check arguments */
- HDassert(f);
- HDassert(bt);
- HDassert(bt->rc_shared);
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
- HDassert(shared->type);
- HDassert(size_ptr);
+ /* Check arguments */
+ HDassert(thing);
- /* Check node's size */
- if ((size = H5B_nodesize(f, shared, NULL)) == 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGETSIZE, FAIL, "H5B_nodesize() failed")
+ /* Destroy B-tree node */
+ H5B_dest(thing);
- /* Set size value */
- *size_ptr = size;
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5B_free_icr() */
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5B_compute_size() */
diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h
index cd79cf7..ed03b99 100644
--- a/src/H5Bpkg.h
+++ b/src/H5Bpkg.h
@@ -32,20 +32,22 @@
#include "H5Bprivate.h"
/* Other private headers needed by this file */
-#include "H5RCprivate.h" /* Reference counted objects */
+#include "H5AC2private.h" /* Metadata cache #2 */
+
/**************************/
/* Package Private Macros */
/**************************/
+
/****************************/
/* Package Private Typedefs */
/****************************/
/* The B-tree node as stored in memory... */
-struct H5B_t {
- H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
- /* first field in structure */
+typedef struct H5B_t {
+ H5AC2_info_t cache_info; /* Information for H5AC2 cache functions */
+ /* _must_ be first field in structure */
H5RC_t *rc_shared; /*ref-counted shared info */
unsigned level; /*node level */
unsigned nchildren; /*number of child pointers */
@@ -53,14 +55,21 @@ struct H5B_t {
haddr_t right; /*address of right sibling */
uint8_t *native; /*array of keys in native format */
haddr_t *child; /*2k child pointers */
-};
+} H5B_t;
+
+/* Callback info for loading a B-tree node into the cache */
+typedef struct H5B_cache_ud_t {
+ H5F_t *f; /* File that B-tree node is within */
+ const struct H5B_class_t *type; /* Type of tree */
+ H5RC_t *rc_shared; /* Ref-counted shared info */
+} H5B_cache_ud_t;
/*****************************/
/* Package Private Variables */
/*****************************/
-/* H5B header inherits cache-like properties from H5AC */
-H5_DLLVAR const H5AC_class_t H5AC_BT[1];
+/* H5B header inherits cache-like properties from H5AC2 */
+H5_DLLVAR const H5AC2_class_t H5AC2_BT[1];
/* Declare a free list to manage the haddr_t sequence information */
H5FL_SEQ_EXTERN(haddr_t);
@@ -71,9 +80,11 @@ H5FL_BLK_EXTERN(native_block);
/* Declare a free list to manage the H5B_t struct */
H5FL_EXTERN(H5B_t);
+
/******************************/
/* Package Private Prototypes */
/******************************/
-herr_t H5B_dest(H5F_t *f, H5B_t *b);
+herr_t H5B_dest(H5B_t *bt);
#endif /*_H5Bpkg_H*/
+
diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h
index 4dfea84..ef2a159 100644
--- a/src/H5Bprivate.h
+++ b/src/H5Bprivate.h
@@ -33,7 +33,6 @@
/* Private headers needed by this file */
#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
#include "H5Fprivate.h" /* File access */
#include "H5FLprivate.h" /* Free Lists */
#include "H5RCprivate.h" /* Reference counted object functions */
@@ -73,9 +72,6 @@ typedef enum H5B_ins_t {
typedef int (*H5B_operator_t)(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr,
const void *_rt_key, void *_udata);
-/* Typedef for B-tree in memory (defined in H5Bpkg.h) */
-typedef struct H5B_t H5B_t;
-
/* Each B-tree has certain information that can be shared across all
* the instances of nodes in that B-tree.
*/
@@ -85,6 +81,8 @@ typedef struct H5B_shared_t {
size_t sizeof_rkey; /* Size of raw (disk) key */
size_t sizeof_rnode; /* Size of raw (disk) node */
size_t sizeof_keys; /* Size of native (memory) key node */
+ size_t sizeof_addr; /* Size of file address (in bytes) */
+ size_t sizeof_len; /* Size of file lengths (in bytes) */
uint8_t *page; /* Disk page */
size_t *nkey; /* Offsets of each native key in native key buffer */
} H5B_shared_t;
@@ -119,8 +117,8 @@ typedef struct H5B_class_t {
hbool_t*);
/* encode, decode, debug key values */
- herr_t (*decode)(const H5F_t*, const struct H5B_t*, const uint8_t*, void*);
- herr_t (*encode)(const H5F_t*, const struct H5B_t*, uint8_t*, void*);
+ herr_t (*decode)(const H5B_shared_t*, const uint8_t*, void*);
+ herr_t (*encode)(const H5B_shared_t*, uint8_t*, const void*);
herr_t (*debug_key)(FILE*, H5F_t*, hid_t, int, int, const void*, const void*);
} H5B_class_t;
diff --git a/src/H5C2.c b/src/H5C2.c
index 987c518..a9de919 100644
--- a/src/H5C2.c
+++ b/src/H5C2.c
@@ -2565,20 +2565,23 @@ H5FL_DEFINE_STATIC(H5C2_t);
* Private file-scope function declarations:
*/
-static herr_t H5C2__auto_adjust_cache_size(H5C2_t * cache_ptr,
+static herr_t H5C2__auto_adjust_cache_size(H5F_t * f,
hid_t dxpl_id,
+ H5C2_t * cache_ptr,
hbool_t write_permitted);
-static herr_t H5C2__autoadjust__ageout(H5C2_t * cache_ptr,
+static herr_t H5C2__autoadjust__ageout(H5F_t * f,
+ hid_t dxpl_id,
+ H5C2_t * cache_ptr,
double hit_rate,
enum H5C2_resize_status * status_ptr,
size_t * new_max_cache_size_ptr,
- hid_t dxpl_id,
hbool_t write_permitted);
static herr_t H5C2__autoadjust__ageout__cycle_epoch_marker(H5C2_t * cache_ptr);
-static herr_t H5C2__autoadjust__ageout__evict_aged_out_entries(hid_t dxpl_id,
+static herr_t H5C2__autoadjust__ageout__evict_aged_out_entries(H5F_t * f,
+ hid_t dxpl_id,
H5C2_t * cache_ptr,
hbool_t write_permitted);
@@ -2600,7 +2603,8 @@ static herr_t H5C2_flush_single_entry(H5F_t * f,
unsigned flags,
hbool_t del_entry_from_slist_on_destroy);
-static herr_t H5C2_flush_invalidate_cache(hid_t dxpl_id,
+static herr_t H5C2_flush_invalidate_cache(H5F_t * f,
+ hid_t dxpl_id,
H5C2_t * cache_ptr,
unsigned flags);
@@ -2612,7 +2616,8 @@ static void * H5C2_load_entry(H5F_t * f,
hbool_t chk_len,
const void * udata_ptr);
-static herr_t H5C2_make_space_in_cache(hid_t dxpl_id,
+static herr_t H5C2_make_space_in_cache(H5F_t * f,
+ hid_t dxpl_id,
H5C2_t * cache_ptr,
size_t space_needed,
hbool_t write_permitted);
@@ -2866,8 +2871,7 @@ done:
*/
H5C2_t *
-H5C2_create(const H5F_t * f,
- size_t max_cache_size,
+H5C2_create(size_t max_cache_size,
size_t min_clean_size,
int max_type_id,
const char * (* type_name_table_ptr),
@@ -2882,8 +2886,6 @@ H5C2_create(const H5F_t * f,
FUNC_ENTER_NOAPI(H5C2_create, NULL)
- HDassert( f );
-
HDassert( max_cache_size >= H5C2__MIN_MAX_CACHE_SIZE );
HDassert( max_cache_size <= H5C2__MAX_MAX_CACHE_SIZE );
HDassert( min_clean_size <= max_cache_size );
@@ -2917,8 +2919,6 @@ H5C2_create(const H5F_t * f,
cache_ptr->magic = H5C2__H5C2_T_MAGIC;
- cache_ptr->f = (H5F_t *)f;
-
cache_ptr->flush_in_progress = FALSE;
cache_ptr->trace_file_ptr = NULL;
@@ -3328,9 +3328,10 @@ H5C2_def_auto_resize_rpt_fcn(H5C2_t * cache_ptr,
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_dest(H5C2_t * cache_ptr,
+H5C2_dest(H5F_t * f,
hid_t dxpl_id)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C2_dest, FAIL)
@@ -3338,7 +3339,7 @@ H5C2_dest(H5C2_t * cache_ptr,
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- if ( H5C2_flush_cache(cache_ptr, dxpl_id,
+ if ( H5C2_flush_cache(f, dxpl_id,
H5C2__FLUSH_INVALIDATE_FLAG) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
@@ -3439,12 +3440,13 @@ done:
*/
herr_t
-H5C2_expunge_entry(H5C2_t * cache_ptr,
+H5C2_expunge_entry(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr)
{
/* const char * fcn_name = "H5C2_expunge_entry()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
H5C2_cache_entry_t * entry_ptr = NULL;
@@ -3492,7 +3494,7 @@ H5C2_expunge_entry(H5C2_t * cache_ptr,
* This will clear the entry, and then delete it from the cache.
*/
- result = H5C2_flush_single_entry(cache_ptr->f,
+ result = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -3639,11 +3641,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_flush_cache(H5C2_t * cache_ptr,
+H5C2_flush_cache(H5F_t *f,
hid_t dxpl_id,
unsigned flags)
{
- /* const char * fcn_name = "H5C2_flush_cache()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t status;
herr_t ret_value = SUCCEED;
hbool_t destroy;
@@ -3667,7 +3669,7 @@ H5C2_flush_cache(H5C2_t * cache_ptr,
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->skip_file_checks || cache_ptr->f );
+ HDassert( cache_ptr->skip_file_checks || f);
HDassert( cache_ptr->slist_ptr );
ignore_protected = ( (flags & H5C2__FLUSH_IGNORE_PROTECTED_FLAG) != 0 );
@@ -3688,7 +3690,8 @@ H5C2_flush_cache(H5C2_t * cache_ptr,
if ( destroy ) {
- status = H5C2_flush_invalidate_cache(dxpl_id,
+ status = H5C2_flush_invalidate_cache(f,
+ dxpl_id,
cache_ptr,
flags);
@@ -3888,7 +3891,7 @@ H5C2_flush_cache(H5C2_t * cache_ptr,
flushed_entries_count++;
flushed_entries_size += entry_ptr->size;
#endif /* H5C2_DO_SANITY_CHECKS */
- status = H5C2_flush_single_entry(cache_ptr->f,
+ status = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -3910,7 +3913,7 @@ H5C2_flush_cache(H5C2_t * cache_ptr,
flushed_entries_count++;
flushed_entries_size += entry_ptr->size;
#endif /* H5C2_DO_SANITY_CHECKS */
- status = H5C2_flush_single_entry(cache_ptr->f,
+ status = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -4038,9 +4041,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_flush_to_min_clean(H5C2_t * cache_ptr,
+H5C2_flush_to_min_clean(H5F_t * f,
hid_t dxpl_id)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED;
hbool_t write_permitted;
@@ -4057,11 +4061,11 @@ H5C2_flush_to_min_clean(H5C2_t * cache_ptr,
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->skip_file_checks || cache_ptr->f );
+ HDassert( cache_ptr->skip_file_checks || f );
if ( cache_ptr->check_write_permitted != NULL ) {
- result = (cache_ptr->check_write_permitted)(cache_ptr->f,
+ result = (cache_ptr->check_write_permitted)(f,
dxpl_id,
&write_permitted);
@@ -4081,7 +4085,8 @@ H5C2_flush_to_min_clean(H5C2_t * cache_ptr,
"cache write is not permitted!?!\n");
}
#if 1 /* original code */
- result = H5C2_make_space_in_cache(dxpl_id,
+ result = H5C2_make_space_in_cache(f,
+ dxpl_id,
cache_ptr,
(size_t)0,
write_permitted);
@@ -4412,7 +4417,7 @@ done:
*/
herr_t
-H5C2_get_entry_status(H5C2_t * cache_ptr,
+H5C2_get_entry_status(H5F_t * f,
haddr_t addr,
size_t * size_ptr,
hbool_t * in_cache_ptr,
@@ -4421,6 +4426,7 @@ H5C2_get_entry_status(H5C2_t * cache_ptr,
hbool_t * is_pinned_ptr)
{
/* const char * fcn_name = "H5C2_get_entry_status()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
H5C2_cache_entry_t * entry_ptr = NULL;
@@ -4668,7 +4674,7 @@ done:
*/
herr_t
-H5C2_insert_entry(H5C2_t * cache_ptr,
+H5C2_insert_entry(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr,
@@ -4677,6 +4683,7 @@ H5C2_insert_entry(H5C2_t * cache_ptr,
unsigned int flags)
{
/* const char * fcn_name = "H5C2_insert_entry()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
hbool_t insert_pinned;
@@ -4689,7 +4696,7 @@ H5C2_insert_entry(H5C2_t * cache_ptr,
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->skip_file_checks || cache_ptr->f );
+ HDassert( cache_ptr->skip_file_checks || f );
HDassert( type );
HDassert( H5F_addr_defined(addr) );
HDassert( thing );
@@ -4772,7 +4779,7 @@ H5C2_insert_entry(H5C2_t * cache_ptr,
if ( cache_ptr->check_write_permitted != NULL ) {
- result = (cache_ptr->check_write_permitted)(cache_ptr->f,
+ result = (cache_ptr->check_write_permitted)(f,
dxpl_id,
&write_permitted);
@@ -4820,7 +4827,8 @@ H5C2_insert_entry(H5C2_t * cache_ptr,
* no point in worrying about the third.
*/
- result = H5C2_make_space_in_cache(dxpl_id,
+ result = H5C2_make_space_in_cache(f,
+ dxpl_id,
cache_ptr,
space_needed,
write_permitted);
@@ -5080,7 +5088,7 @@ H5C2_mark_entries_as_clean(H5C2_t * cache_ptr,
} else {
- if ( H5C2_flush_single_entry(cache_ptr->f,
+ if ( H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -5138,7 +5146,7 @@ H5C2_mark_entries_as_clean(H5C2_t * cache_ptr,
entry_ptr = entry_ptr->prev;
entries_cleared++;
- if ( H5C2_flush_single_entry(cache_ptr->f,
+ if ( H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
clear_ptr->type,
@@ -5174,7 +5182,7 @@ H5C2_mark_entries_as_clean(H5C2_t * cache_ptr,
entry_ptr = entry_ptr->next;
entries_cleared++;
- if ( H5C2_flush_single_entry(cache_ptr->f,
+ if ( H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
clear_ptr->type,
@@ -5257,11 +5265,12 @@ done:
*/
herr_t
-H5C2_mark_pinned_entry_dirty(H5C2_t * cache_ptr,
+H5C2_mark_pinned_entry_dirty(H5F_t * f,
void * thing,
hbool_t size_changed,
size_t new_size)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
herr_t result;
size_t size_increase;
@@ -5389,9 +5398,10 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_mark_pinned_or_protected_entry_dirty(H5C2_t * cache_ptr,
+H5C2_mark_pinned_or_protected_entry_dirty(H5F_t * f,
void * thing)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
H5C2_cache_entry_t * entry_ptr;
@@ -5661,11 +5671,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_resize_pinned_entry(H5C2_t * cache_ptr,
+H5C2_resize_pinned_entry(H5F_t * f,
void * thing,
size_t new_size)
{
/* const char * fcn_name = "H5C2_resize_pinned_entry()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
herr_t result;
H5C2_cache_entry_t * entry_ptr;
@@ -5796,14 +5807,15 @@ done:
*/
#ifndef NDEBUG
herr_t
-H5C2_pin_protected_entry(H5C2_t * cache_ptr,
+H5C2_pin_protected_entry(H5F_t * f,
void * thing)
#else
herr_t
-H5C2_pin_protected_entry(H5C2_t UNUSED * cache_ptr,
+H5C2_pin_protected_entry(H5F_t UNUSED * f,
void * thing)
#endif
{
+ H5C2_t *cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
H5C2_cache_entry_t * entry_ptr;
@@ -5933,7 +5945,7 @@ done:
*/
void *
-H5C2_protect(H5C2_t * cache_ptr,
+H5C2_protect(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr,
@@ -5942,6 +5954,7 @@ H5C2_protect(H5C2_t * cache_ptr,
unsigned flags)
{
/* const char * fcn_name = "H5C2_protect()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
hbool_t hit;
hbool_t first_flush;
hbool_t have_write_permitted = FALSE;
@@ -5958,7 +5971,7 @@ H5C2_protect(H5C2_t * cache_ptr,
/* check args */
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->skip_file_checks || cache_ptr->f );
+ HDassert( cache_ptr->skip_file_checks || f );
HDassert( type );
HDassert( H5F_addr_defined(addr) );
HDassert( len > 0 );
@@ -5996,7 +6009,7 @@ H5C2_protect(H5C2_t * cache_ptr,
hit = FALSE;
- thing = H5C2_load_entry(cache_ptr->f, dxpl_id, type,
+ thing = H5C2_load_entry(f, dxpl_id, type,
addr, len, chk_len, udata);
if ( thing == NULL ) {
@@ -6035,7 +6048,7 @@ H5C2_protect(H5C2_t * cache_ptr,
if ( cache_ptr->check_write_permitted != NULL ) {
- result = (cache_ptr->check_write_permitted)(cache_ptr->f,
+ result = (cache_ptr->check_write_permitted)(f,
dxpl_id,
&write_permitted);
@@ -6097,7 +6110,7 @@ H5C2_protect(H5C2_t * cache_ptr,
* see no point in worrying about the fourth.
*/
- result = H5C2_make_space_in_cache(dxpl_id, cache_ptr,
+ result = H5C2_make_space_in_cache(f, dxpl_id, cache_ptr,
space_needed, write_permitted);
if ( result < 0 ) {
@@ -6175,7 +6188,7 @@ H5C2_protect(H5C2_t * cache_ptr,
if ( cache_ptr->check_write_permitted != NULL ) {
- result = (cache_ptr->check_write_permitted)(cache_ptr->f,
+ result = (cache_ptr->check_write_permitted)(f,
dxpl_id,
&write_permitted);
@@ -6204,8 +6217,9 @@ H5C2_protect(H5C2_t * cache_ptr,
( cache_ptr->cache_accesses >=
(cache_ptr->resize_ctl).epoch_length ) ) {
- result = H5C2__auto_adjust_cache_size(cache_ptr,
+ result = H5C2__auto_adjust_cache_size(f,
dxpl_id,
+ cache_ptr,
write_permitted);
if ( result != SUCCEED ) {
@@ -6226,7 +6240,8 @@ H5C2_protect(H5C2_t * cache_ptr,
cache_ptr->cache_full = TRUE;
- result = H5C2_make_space_in_cache(dxpl_id,
+ result = H5C2_make_space_in_cache(f,
+ dxpl_id,
cache_ptr,
(size_t)0,
write_permitted);
@@ -6331,10 +6346,11 @@ done:
*/
herr_t
-H5C2_set_cache_auto_resize_config(H5C2_t * cache_ptr,
+H5C2_set_cache_auto_resize_config(const H5F_t * f,
H5C2_auto_size_ctl_t *config_ptr)
{
/* const char *fcn_name = "H5C2_set_cache_auto_resize_config()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
herr_t result;
size_t new_max_cache_size;
@@ -6615,9 +6631,10 @@ done:
*/
herr_t
-H5C2_set_evictions_enabled(H5C2_t * cache_ptr,
+H5C2_set_evictions_enabled(const H5F_t * f,
hbool_t evictions_enabled)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C2_set_evictions_enabled, FAIL)
@@ -7361,9 +7378,10 @@ H5C2_stats__reset(H5C2_t UNUSED * cache_ptr)
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_unpin_entry(H5C2_t * cache_ptr,
+H5C2_unpin_entry(H5F_t * f,
void * thing)
{
+ H5C2_t *cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
H5C2_cache_entry_t * entry_ptr;
@@ -7500,7 +7518,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5C2_unprotect(H5C2_t * cache_ptr,
+H5C2_unprotect(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr,
@@ -7509,6 +7527,7 @@ H5C2_unprotect(H5C2_t * cache_ptr,
size_t new_size)
{
/* const char * fcn_name = "H5C2_unprotect()"; */
+ H5C2_t * cache_ptr = f->shared->cache2;
hbool_t deleted;
hbool_t dirtied;
hbool_t set_flush_marker;
@@ -7541,7 +7560,7 @@ H5C2_unprotect(H5C2_t * cache_ptr,
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->skip_file_checks || cache_ptr->f );
+ HDassert( cache_ptr->skip_file_checks || f );
HDassert( type );
HDassert( H5F_addr_defined(addr) );
HDassert( thing );
@@ -7787,7 +7806,7 @@ H5C2_unprotect(H5C2_t * cache_ptr,
"hash table contains multiple entries for addr?!?.")
}
- if ( H5C2_flush_single_entry(cache_ptr->f,
+ if ( H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
type,
@@ -7817,7 +7836,7 @@ H5C2_unprotect(H5C2_t * cache_ptr,
"hash table contains multiple entries for addr?!?.")
}
- if ( H5C2_flush_single_entry(cache_ptr->f,
+ if ( H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
type,
@@ -8156,8 +8175,9 @@ done:
*/
static herr_t
-H5C2__auto_adjust_cache_size(H5C2_t * cache_ptr,
+H5C2__auto_adjust_cache_size(H5F_t * f,
hid_t dxpl_id,
+ H5C2_t * cache_ptr,
hbool_t write_permitted)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -8172,6 +8192,7 @@ H5C2__auto_adjust_cache_size(H5C2_t * cache_ptr,
FUNC_ENTER_NOAPI_NOINIT(H5C2__auto_adjust_cache_size)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
HDassert( cache_ptr->cache_accesses >=
@@ -8356,11 +8377,12 @@ H5C2__auto_adjust_cache_size(H5C2_t * cache_ptr,
} else {
- result = H5C2__autoadjust__ageout(cache_ptr,
+ result = H5C2__autoadjust__ageout(f,
+ dxpl_id,
+ cache_ptr,
hit_rate,
&status,
&new_max_cache_size,
- dxpl_id,
write_permitted);
if ( result != SUCCEED ) {
@@ -8512,11 +8534,12 @@ done:
*/
static herr_t
-H5C2__autoadjust__ageout(H5C2_t * cache_ptr,
+H5C2__autoadjust__ageout(H5F_t * f,
+ hid_t dxpl_id,
+ H5C2_t * cache_ptr,
double hit_rate,
enum H5C2_resize_status * status_ptr,
size_t * new_max_cache_size_ptr,
- hid_t dxpl_id,
hbool_t write_permitted)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -8525,6 +8548,7 @@ H5C2__autoadjust__ageout(H5C2_t * cache_ptr,
FUNC_ENTER_NOAPI_NOINIT(H5C2__autoadjust__ageout)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
HDassert( ( status_ptr ) && ( *status_ptr == in_spec2 ) );
@@ -8558,6 +8582,7 @@ H5C2__autoadjust__ageout(H5C2_t * cache_ptr,
/* evict aged out cache entries if appropriate... */
result = H5C2__autoadjust__ageout__evict_aged_out_entries
(
+ f,
dxpl_id,
cache_ptr,
write_permitted
@@ -8793,7 +8818,8 @@ done:
*/
static herr_t
-H5C2__autoadjust__ageout__evict_aged_out_entries(hid_t dxpl_id,
+H5C2__autoadjust__ageout__evict_aged_out_entries(H5F_t * f,
+ hid_t dxpl_id,
H5C2_t * cache_ptr,
hbool_t write_permitted)
{
@@ -8810,6 +8836,7 @@ H5C2__autoadjust__ageout__evict_aged_out_entries(hid_t dxpl_id,
FUNC_ENTER_NOAPI_NOINIT(H5C2__autoadjust__ageout__evict_aged_out_entries)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
@@ -8848,7 +8875,7 @@ H5C2__autoadjust__ageout__evict_aged_out_entries(hid_t dxpl_id,
if ( entry_ptr->is_dirty ) {
- result = H5C2_flush_single_entry(cache_ptr->f,
+ result = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -8859,7 +8886,7 @@ H5C2__autoadjust__ageout__evict_aged_out_entries(hid_t dxpl_id,
bytes_evicted += entry_ptr->size;
- result = H5C2_flush_single_entry(cache_ptr->f,
+ result = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -8956,7 +8983,7 @@ H5C2__autoadjust__ageout__evict_aged_out_entries(hid_t dxpl_id,
if ( ! (entry_ptr->is_dirty) ) {
- result = H5C2_flush_single_entry(cache_ptr->f,
+ result = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -9495,8 +9522,9 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5C2_flush_invalidate_cache(hid_t dxpl_id,
+static herr_t
+H5C2_flush_invalidate_cache(H5F_t * f,
+ hid_t dxpl_id,
H5C2_t * cache_ptr,
unsigned flags)
{
@@ -9522,9 +9550,10 @@ H5C2_flush_invalidate_cache(hid_t dxpl_id,
FUNC_ENTER_NOAPI(H5C2_flush_invalidate_cache, FAIL)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->skip_file_checks || cache_ptr->f );
+ HDassert( cache_ptr->skip_file_checks || f );
HDassert( cache_ptr->slist_ptr );
/* Filter out the flags that are not relevant to the flush/invalidate.
@@ -9768,7 +9797,7 @@ H5C2_flush_invalidate_cache(hid_t dxpl_id,
* condition here.
*/
- status = H5C2_flush_single_entry(cache_ptr->f,
+ status = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -9787,7 +9816,7 @@ H5C2_flush_invalidate_cache(hid_t dxpl_id,
}
} else {
- status = H5C2_flush_single_entry(cache_ptr->f,
+ status = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -9868,7 +9897,7 @@ H5C2_flush_invalidate_cache(hid_t dxpl_id,
} else if ( ! ( entry_ptr->is_pinned ) ) {
status =
- H5C2_flush_single_entry(cache_ptr->f,
+ H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -10432,7 +10461,7 @@ H5C2_flush_single_entry(H5F_t * f,
/* only call the clear_dirty_bits callback if debugging
* is enabled.
*/
- if ( entry_ptr->type->clear_dirty_bits(addr,
+ if ( entry_ptr->type->clear_dirty_bits && entry_ptr->type->clear_dirty_bits(addr,
entry_ptr->size,
(void *)entry_ptr)
!= SUCCEED )
@@ -10798,8 +10827,6 @@ H5C2_load_entry(H5F_t * f,
{
/* const char * fcn_name = "H5C2_load_entry()"; */
hbool_t dirty = FALSE;
- haddr_t abs_eoa; /* Absolute end of file address */
- haddr_t rel_eoa; /* Relative end of file address */
void * image_ptr = NULL;
void * thing = NULL;
void * ret_value = NULL;
@@ -10815,44 +10842,6 @@ H5C2_load_entry(H5F_t * f,
HDassert( type->deserialize );
HDassert( ( ! chk_len ) || ( type->image_len ) );
- /* Make certain we don't speculatively read off the end of the file */
- if ( HADDR_UNDEF == (abs_eoa = H5F_get_eoa(f)) )
- {
- HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \
- "unable to determine file size")
- }
-
- /* Adjust absolute EOA address to relative EOA address */
- rel_eoa = abs_eoa - H5F_get_base_addr(f);
-
- HDassert( rel_eoa > addr );
-
- if ( (rel_eoa - addr) < (haddr_t)len )
- {
- /* either the client is speculatively reading beyond the end of
- * file, or there is a major screw up. Adjust the len in the
- * former case, and scream and die in the latter
- */
- if ( chk_len ) /* i.e. possible speculative read beyond eof */
- {
- /* Quincey: Did I use this correctly? In the example I
- * stole it from, the from type was hsize_t even though
- * the source was a haddr_t. I changed the from to match
- * the source. Is this as it should be?
- */
- /* JRM */
- H5_ASSIGN_OVERFLOW(len, (rel_eoa - addr), \
- /* from: */ haddr_t, /* to: */ size_t);
- HDassert( len > 0 );
- }
- else
- {
- HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \
- "tried to read beyond eof")
-
- }
- }
-
image_ptr = H5MM_malloc(len);
if ( image_ptr == NULL )
@@ -11037,7 +11026,8 @@ done:
*/
static herr_t
-H5C2_make_space_in_cache(hid_t dxpl_id,
+H5C2_make_space_in_cache(H5F_t * f,
+ hid_t dxpl_id,
H5C2_t * cache_ptr,
size_t space_needed,
hbool_t write_permitted)
@@ -11058,6 +11048,7 @@ H5C2_make_space_in_cache(hid_t dxpl_id,
FUNC_ENTER_NOAPI_NOINIT(H5C2_make_space_in_cache)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
@@ -11094,7 +11085,7 @@ H5C2_make_space_in_cache(hid_t dxpl_id,
if ( entry_ptr->is_dirty ) {
- result = H5C2_flush_single_entry(cache_ptr->f,
+ result = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -11104,7 +11095,7 @@ H5C2_make_space_in_cache(hid_t dxpl_id,
} else {
result =
- H5C2_flush_single_entry(cache_ptr->f,
+ H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -11211,7 +11202,7 @@ H5C2_make_space_in_cache(hid_t dxpl_id,
HDassert( prev_ptr->is_dirty );
}
- result = H5C2_flush_single_entry(cache_ptr->f,
+ result = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
@@ -11313,7 +11304,7 @@ H5C2_make_space_in_cache(hid_t dxpl_id,
prev_ptr = entry_ptr->aux_prev;
- result = H5C2_flush_single_entry(cache_ptr->f,
+ result = H5C2_flush_single_entry(f,
dxpl_id,
cache_ptr,
entry_ptr->type,
diff --git a/src/H5C2journal.c b/src/H5C2journal.c
index 6109cd7..27eabf7 100644
--- a/src/H5C2journal.c
+++ b/src/H5C2journal.c
@@ -163,10 +163,11 @@ done:
*/
herr_t
-H5C2_create_journal_config_block(H5C2_t * cache_ptr,
+H5C2_create_journal_config_block(H5F_t * f,
hid_t dxpl_id,
const char * journal_file_name_ptr)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
size_t path_len = 0;
hsize_t block_len = 0;
haddr_t block_addr = HADDR_UNDEF;
@@ -179,9 +180,9 @@ H5C2_create_journal_config_block(H5C2_t * cache_ptr,
FUNC_ENTER_NOAPI(H5C2_create_journal_config_block, FAIL)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->f != NULL );
if ( cache_ptr->mdj_conf_block_ptr != NULL ) {
@@ -195,7 +196,7 @@ H5C2_create_journal_config_block(H5C2_t * cache_ptr,
HDassert( path_len > 0 );
- block_len = H5C2__JOURNAL_BLOCK_LEN(path_len, cache_ptr->f);
+ block_len = H5C2__JOURNAL_BLOCK_LEN(path_len, f);
block_ptr = (void *)H5MM_malloc((size_t)block_len);
@@ -216,7 +217,7 @@ H5C2_create_journal_config_block(H5C2_t * cache_ptr,
p++;
/* copy the length of the journal file path into the config block */
- H5F_ENCODE_LENGTH(cache_ptr->f, p, path_len);
+ H5F_ENCODE_LENGTH(f, p, path_len);
/* copy the path to the journal file into the config block, including
* the terminalting null. Before we do so, make note of p, as its
@@ -239,7 +240,7 @@ H5C2_create_journal_config_block(H5C2_t * cache_ptr,
* we must now allocate space for it in file, and write it to disk.
*/
- block_addr = H5MF_alloc(cache_ptr->f,
+ block_addr = H5MF_alloc(f,
H5FD_MEM_MDJCONFIG,
dxpl_id,
block_len);
@@ -253,7 +254,7 @@ H5C2_create_journal_config_block(H5C2_t * cache_ptr,
/* now write the block to disk -- note that we don't sync. We will
* have to do that later.
*/
- if ( H5F_block_write(cache_ptr->f, H5FD_MEM_MDJCONFIG, block_addr,
+ if ( H5F_block_write(f, H5FD_MEM_MDJCONFIG, block_addr,
(size_t)block_len, dxpl_id, block_ptr) < 0 )
{
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
@@ -303,16 +304,17 @@ done:
*/
herr_t
-H5C2_discard_journal_config_block(H5C2_t * cache_ptr,
+H5C2_discard_journal_config_block(H5F_t * f,
hid_t dxpl_id)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C2_discard_journal_config_block, FAIL)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->f != NULL );
if ( ( cache_ptr->mdj_conf_block_addr == HADDR_UNDEF ) ||
( cache_ptr->mdj_conf_block_len == 0 ) ||
@@ -323,7 +325,7 @@ H5C2_discard_journal_config_block(H5C2_t * cache_ptr,
"metadata journaling config block undefined on entry?!?")
}
- if ( H5MF_xfree(cache_ptr->f, H5FD_MEM_MDJCONFIG, dxpl_id,
+ if ( H5MF_xfree(f, H5FD_MEM_MDJCONFIG, dxpl_id,
cache_ptr->mdj_conf_block_addr,
cache_ptr->mdj_conf_block_len) < 0 ) {
@@ -379,27 +381,28 @@ done:
*/
herr_t
-H5C2_get_journaling_in_progress(H5C2_t * cache_ptr,
+H5C2_get_journaling_in_progress(H5F_t * f,
hid_t dxpl_id)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C2_mark_journaling_in_progress, FAIL)
+ HDassert( f );
+ HDassert( f->shared != NULL );
+ HDassert( ! f->shared->mdc_jrnl_enabled );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->f != NULL );
- HDassert( cache_ptr->f->shared != NULL );
- HDassert( ! cache_ptr->f->shared->mdc_jrnl_enabled );
HDassert( cache_ptr->mdj_conf_block_addr == HADDR_UNDEF );
HDassert( cache_ptr->mdj_conf_block_len == 0 );
HDassert( cache_ptr->mdj_conf_block_ptr == NULL );
HDassert( cache_ptr->mdj_file_name_ptr == NULL );
- if ( cache_ptr->f->shared->mdc_jrnl_enabled == TRUE ) {
+ if ( f->shared->mdc_jrnl_enabled == TRUE ) {
- result = H5C2_load_journal_config_block(cache_ptr,
+ result = H5C2_load_journal_config_block(f,
dxpl_id,
cache_ptr->mdj_conf_block_addr,
cache_ptr->mdj_conf_block_len);
@@ -436,11 +439,12 @@ done:
*/
herr_t
-H5C2_load_journal_config_block(H5C2_t * cache_ptr,
+H5C2_load_journal_config_block(H5F_t * f,
hid_t dxpl_id,
haddr_t block_addr,
hsize_t block_len)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
size_t path_len = 0;
void * block_ptr = NULL;
uint8_t version;
@@ -452,9 +456,9 @@ H5C2_load_journal_config_block(H5C2_t * cache_ptr,
FUNC_ENTER_NOAPI(H5C2_load_journal_config_block, FAIL)
+ HDassert( f );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->f != NULL );
if ( cache_ptr->mdj_conf_block_ptr != NULL ) {
@@ -473,7 +477,7 @@ H5C2_load_journal_config_block(H5C2_t * cache_ptr,
p = (uint8_t *)block_ptr;
/* read the metadata journaling block from file */
- if ( H5F_block_read(cache_ptr->f, H5FD_MEM_MDJCONFIG, block_addr,
+ if ( H5F_block_read(f, H5FD_MEM_MDJCONFIG, block_addr,
(size_t)block_len, dxpl_id, block_ptr) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
@@ -499,7 +503,7 @@ H5C2_load_journal_config_block(H5C2_t * cache_ptr,
}
/* get the length of the journal file path into the config block */
- H5F_DECODE_LENGTH(cache_ptr->f, p, path_len);
+ H5F_DECODE_LENGTH(f, p, path_len);
/* Verify that the length matches the actual path length. Also,
* make note of p, as its value will be the address of our copy of
@@ -569,20 +573,21 @@ done:
*/
herr_t
-H5C2_mark_journaling_in_progress(H5C2_t * cache_ptr,
+H5C2_mark_journaling_in_progress(H5F_t * f,
hid_t dxpl_id,
const char * journal_file_name_ptr)
{
+ H5C2_t * cache_ptr = f->shared->cache2;
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C2_mark_journaling_in_progress, FAIL)
+ HDassert( f != NULL );
+ HDassert( f->shared != NULL );
+ HDassert( ! f->shared->mdc_jrnl_enabled );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->f != NULL );
- HDassert( cache_ptr->f->shared != NULL );
- HDassert( ! cache_ptr->f->shared->mdc_jrnl_enabled );
HDassert( cache_ptr->mdj_conf_block_addr == HADDR_UNDEF );
HDassert( cache_ptr->mdj_conf_block_len == 0 );
HDassert( cache_ptr->mdj_conf_block_ptr == NULL );
@@ -592,14 +597,14 @@ H5C2_mark_journaling_in_progress(H5C2_t * cache_ptr,
/* Can't journal a read only file, so verify that we are
* opened read/write and fail if we are not.
*/
- if ( (cache_ptr->f->shared->flags & H5F_ACC_RDWR) == 0 ) {
+ if ( (f->shared->flags & H5F_ACC_RDWR) == 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
"File is opened read only.")
}
/* first, create a metadata journaling configuration block */
- result = H5C2_create_journal_config_block(cache_ptr,
+ result = H5C2_create_journal_config_block(f,
dxpl_id,
journal_file_name_ptr);
@@ -618,11 +623,11 @@ H5C2_mark_journaling_in_progress(H5C2_t * cache_ptr,
* into shared, and then call H5F_super_write_mdj_msg() to write
* the metadata journaling superblock extension message to file.
*/
- cache_ptr->f->shared->mdc_jrnl_enabled = TRUE;
- cache_ptr->f->shared->mdc_jrnl_block_loc = cache_ptr->mdj_conf_block_addr;
- cache_ptr->f->shared->mdc_jrnl_block_len = cache_ptr->mdj_conf_block_len;
+ f->shared->mdc_jrnl_enabled = TRUE;
+ f->shared->mdc_jrnl_block_loc = cache_ptr->mdj_conf_block_addr;
+ f->shared->mdc_jrnl_block_len = cache_ptr->mdj_conf_block_len;
- if ( H5F_super_write_mdj_msg(cache_ptr->f, dxpl_id) < 0 ) {
+ if ( H5F_super_write_mdj_msg(f, dxpl_id) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
"H5F_super_write_mdj_msg() failed.")
@@ -646,7 +651,7 @@ H5C2_mark_journaling_in_progress(H5C2_t * cache_ptr,
* files -- a point we haven't discussed. We should do so.
*/
- if ( H5Fflush(cache_ptr->f->file_id, H5F_SCOPE_GLOBAL) < 0 ) {
+ if ( H5Fflush(f->file_id, H5F_SCOPE_GLOBAL) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, "H5Fflush() failed.")
}
@@ -684,40 +689,43 @@ done:
*/
herr_t
-H5C2_unmark_journaling_in_progress(H5C2_t * cache_ptr,
+H5C2_unmark_journaling_in_progress(H5F_t * f,
hid_t dxpl_id)
{
+#ifndef NDEBUG
+ H5C2_t * cache_ptr = f->shared->cache2;
+#endif /* NDEBUG */
herr_t result;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C2_unmark_journaling_in_progress, FAIL)
+ HDassert( f != NULL );
+ HDassert( f->shared != NULL );
+ HDassert( f->shared->mdc_jrnl_enabled );
HDassert( cache_ptr );
HDassert( cache_ptr->magic == H5C2__H5C2_T_MAGIC );
- HDassert( cache_ptr->f != NULL );
- HDassert( cache_ptr->f->shared != NULL );
- HDassert( cache_ptr->f->shared->mdc_jrnl_enabled );
HDassert( cache_ptr->mdj_conf_block_addr != HADDR_UNDEF );
HDassert( cache_ptr->mdj_conf_block_len > 0 );
HDassert( cache_ptr->mdj_conf_block_ptr != NULL );
HDassert( cache_ptr->mdj_file_name_ptr != NULL );
- HDassert( cache_ptr->f->shared->mdc_jrnl_block_loc ==
+ HDassert( f->shared->mdc_jrnl_block_loc ==
cache_ptr->mdj_conf_block_addr );
- HDassert( cache_ptr->f->shared->mdc_jrnl_block_len ==
+ HDassert( f->shared->mdc_jrnl_block_len ==
cache_ptr->mdj_conf_block_len );
/* Can't journal a read only file, so verify that we are
* opened read/write and fail if we are not.
*/
- if ( (cache_ptr->f->shared->flags & H5F_ACC_RDWR) == 0 ) {
+ if ( (f->shared->flags & H5F_ACC_RDWR) == 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
"File is opened read only.")
}
/* next, discard the metadata journaling configuration block */
- result = H5C2_discard_journal_config_block(cache_ptr, dxpl_id);
+ result = H5C2_discard_journal_config_block(f, dxpl_id);
if ( result != SUCCEED ) {
@@ -734,11 +742,11 @@ H5C2_unmark_journaling_in_progress(H5C2_t * cache_ptr,
* progress, and then call H5F_super_write_mdj_msg() to write
* the changes to disk.
*/
- cache_ptr->f->shared->mdc_jrnl_enabled = FALSE;
- cache_ptr->f->shared->mdc_jrnl_block_loc = HADDR_UNDEF;
- cache_ptr->f->shared->mdc_jrnl_block_len = 0;
+ f->shared->mdc_jrnl_enabled = FALSE;
+ f->shared->mdc_jrnl_block_loc = HADDR_UNDEF;
+ f->shared->mdc_jrnl_block_len = 0;
- if ( H5F_super_write_mdj_msg(cache_ptr->f, dxpl_id) < 0 ) {
+ if ( H5F_super_write_mdj_msg(f, dxpl_id) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, \
"H5F_super_write_mdj_msg() failed.")
@@ -762,7 +770,7 @@ H5C2_unmark_journaling_in_progress(H5C2_t * cache_ptr,
* files -- a point we haven't discussed. We should do so.
*/
- if ( H5Fflush(cache_ptr->f->file_id, H5F_SCOPE_GLOBAL) < 0 ) {
+ if ( H5Fflush(f->file_id, H5F_SCOPE_GLOBAL) < 0 ) {
HGOTO_ERROR(H5E_CACHE, H5E_CANTJOURNAL, FAIL, "H5Fflush() failed.")
}
@@ -1318,8 +1326,8 @@ done:
herr_t
H5C2_jb__init(H5C2_jbrb_t * struct_ptr,
- char * HDF5_file_name,
- char * journal_file_name,
+ const char * HDF5_file_name,
+ const char * journal_file_name,
size_t buf_size,
int num_bufs,
hbool_t use_aio,
@@ -1341,7 +1349,7 @@ H5C2_jb__init(H5C2_jbrb_t * struct_ptr,
/* Open journal file */
struct_ptr->journal_file_fd =
- open(journal_file_name, O_WRONLY|O_CREAT|O_EXCL, 0777);
+ HDopen(journal_file_name, O_WRONLY|O_CREAT|O_EXCL, 0777);
if ( struct_ptr->journal_file_fd == -1) {
@@ -1563,7 +1571,7 @@ H5C2_jb__journal_entry(H5C2_jbrb_t * struct_ptr,
unsigned long trans_num,
haddr_t base_addr,
size_t length,
- const char * body)
+ const uint8_t * body)
{
char * temp = NULL;
@@ -1601,7 +1609,7 @@ H5C2_jb__journal_entry(H5C2_jbrb_t * struct_ptr,
/* Write journal entry */
HDsnprintf(temp,
(size_t)(length + 100),
- "2 trans_num %ld length %d base_addr 0x%lx body ",
+ "2 trans_num %ld length %zu base_addr 0x%lx body ",
trans_num,
length,
(unsigned long)base_addr); /* <== fix this */
@@ -1747,7 +1755,7 @@ done:
herr_t
H5C2_jb__comment(H5C2_jbrb_t * struct_ptr,
- char * comment_ptr)
+ const char * comment_ptr)
{
char * temp = NULL;
size_t temp_len;
@@ -2066,19 +2074,17 @@ done:
******************************************************************************/
herr_t
-H5C2_jb__bin2hex(uint8_t * buf,
- uint8_t * hexdata,
+H5C2_jb__bin2hex(const uint8_t * buf,
+ char * hexdata,
size_t * hexlength,
size_t buf_offset,
size_t buf_size)
{
-
- herr_t ret_value = SUCCEED;
size_t u, v; /* Local index variable */
uint8_t c;
- FUNC_ENTER_NOAPI(H5C2_jb__bin2hex, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5C2_jb__bin2hex)
HDsnprintf(hexdata, (size_t)2, " ");
@@ -2102,9 +2108,6 @@ H5C2_jb__bin2hex(uint8_t * buf,
* hexlength = HDstrlen(hexdata);
-done:
-
- FUNC_LEAVE_NOAPI(ret_value)
-
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5C2_jb__bin2hex*/
diff --git a/src/H5C2pkg.h b/src/H5C2pkg.h
index 7d12053..878e372 100644
--- a/src/H5C2pkg.h
+++ b/src/H5C2pkg.h
@@ -174,8 +174,8 @@ struct H5C2_jbrb_t
unsigned long cur_trans;
unsigned long last_trans_on_disk;
hbool_t trans_in_prog;
- char * jname;
- char * hdf5_file_name;
+ const char * jname;
+ const char * hdf5_file_name;
hbool_t header_present;
size_t cur_buf_free_space;
size_t rb_space_to_rollover;
@@ -243,11 +243,6 @@ struct H5C2_jbrb_t
* This field is used to validate pointers to instances of
* H5C2_t.
*
- * f: Pointer to the instance of H5F_t associated with this
- * instance of the metadata cache. This field is set at
- * create, and then used until the file is closed (at which
- * point, the cache will be shut down as well).
- *
* flush_in_progress: Boolean flag indicating whether a flush is in
* progress.
*
@@ -1024,8 +1019,6 @@ struct H5C2_t
{
uint32_t magic;
- H5F_t * f;
-
hbool_t flush_in_progress;
FILE * trace_file_ptr;
diff --git a/src/H5C2private.h b/src/H5C2private.h
index 67d59a9..73f75e5 100644
--- a/src/H5C2private.h
+++ b/src/H5C2private.h
@@ -156,7 +156,7 @@ typedef struct H5C2_t H5C2_t;
*
* If the image contains valid data, and is of the correct length,
* the deserialize function must allocate space for an in core
- * represntation of that data, load the contents of the image into
+ * representation of that data, load the contents of the image into
* the space allocated for the in core representation, and return
* a pointer to the in core representation. Observe that an
* instance of H5C2_cache_entry_t must be the first item in this
@@ -1268,8 +1268,7 @@ typedef struct H5C2_auto_size_ctl_t
#define H5C2__READ_ONLY_FLAG 0x0400
#define H5C2__CHECK_SIZE_FLAG 0x0800
-H5_DLL H5C2_t * H5C2_create(const H5F_t * f,
- size_t max_cache_size,
+H5_DLL H5C2_t * H5C2_create(size_t max_cache_size,
size_t min_clean_size,
int max_type_id,
const char * (* type_name_table_ptr),
@@ -1287,22 +1286,22 @@ H5_DLL void H5C2_def_auto_resize_rpt_fcn(H5C2_t * cache_ptr,
size_t old_min_clean_size,
size_t new_min_clean_size);
-H5_DLL herr_t H5C2_dest(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_dest(H5F_t * f,
hid_t dxpl_id);
H5_DLL herr_t H5C2_dest_empty(H5C2_t * cache_ptr);
-H5_DLL herr_t H5C2_expunge_entry(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_expunge_entry(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr);
-H5_DLL herr_t H5C2_flush_cache(H5C2_t * cache_ptr,
- hid_t dxpl_id,
- unsigned flags);
+H5_DLL herr_t H5C2_flush_cache(H5F_t *f,
+ hid_t dxpl_id,
+ unsigned flags);
-H5_DLL herr_t H5C2_flush_to_min_clean(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_flush_to_min_clean(H5F_t * f,
hid_t dxpl_id);
H5_DLL herr_t H5C2_get_cache_auto_resize_config(H5C2_t * cache_ptr,
@@ -1317,7 +1316,7 @@ H5_DLL herr_t H5C2_get_cache_size(H5C2_t * cache_ptr,
H5_DLL herr_t H5C2_get_cache_hit_rate(H5C2_t * cache_ptr,
double * hit_rate_ptr);
-H5_DLL herr_t H5C2_get_entry_status(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_get_entry_status(H5F_t * f,
haddr_t addr,
size_t * size_ptr,
hbool_t * in_cache_ptr,
@@ -1331,7 +1330,7 @@ H5_DLL herr_t H5C2_get_evictions_enabled(H5C2_t * cache_ptr,
H5_DLL herr_t H5C2_get_trace_file_ptr(H5C2_t * cache_ptr,
FILE ** trace_file_ptr_ptr);
-H5_DLL herr_t H5C2_insert_entry(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_insert_entry(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr,
@@ -1344,12 +1343,12 @@ H5_DLL herr_t H5C2_mark_entries_as_clean(H5C2_t * cache_ptr,
int32_t ce_array_len,
haddr_t * ce_array_ptr);
-H5_DLL herr_t H5C2_mark_pinned_entry_dirty(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_mark_pinned_entry_dirty(H5F_t * f,
void * thing,
hbool_t size_changed,
size_t new_size);
-H5_DLL herr_t H5C2_mark_pinned_or_protected_entry_dirty(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_mark_pinned_or_protected_entry_dirty(H5F_t * f,
void * thing);
H5_DLL herr_t H5C2_rename_entry(H5C2_t * cache_ptr,
@@ -1357,10 +1356,10 @@ H5_DLL herr_t H5C2_rename_entry(H5C2_t * cache_ptr,
haddr_t old_addr,
haddr_t new_addr);
-H5_DLL herr_t H5C2_pin_protected_entry(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_pin_protected_entry(H5F_t * f,
void * thing);
-H5_DLL void * H5C2_protect(H5C2_t * cache_ptr,
+H5_DLL void * H5C2_protect(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr,
@@ -1370,14 +1369,14 @@ H5_DLL void * H5C2_protect(H5C2_t * cache_ptr,
H5_DLL herr_t H5C2_reset_cache_hit_rate_stats(H5C2_t * cache_ptr);
-H5_DLL herr_t H5C2_resize_pinned_entry(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_resize_pinned_entry(H5F_t * f,
void * thing,
size_t new_size);
-H5_DLL herr_t H5C2_set_cache_auto_resize_config(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_set_cache_auto_resize_config(const H5F_t * f,
H5C2_auto_size_ctl_t *config_ptr);
-H5_DLL herr_t H5C2_set_evictions_enabled(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_set_evictions_enabled(const H5F_t * f,
hbool_t evictions_enabled);
H5_DLL herr_t H5C2_set_prefix(H5C2_t * cache_ptr, char * prefix);
@@ -1395,9 +1394,9 @@ H5_DLL herr_t H5C2_stats(H5C2_t * cache_ptr,
H5_DLL void H5C2_stats__reset(H5C2_t * cache_ptr);
-H5_DLL herr_t H5C2_unpin_entry(H5C2_t * cache_ptr, void * thing);
+H5_DLL herr_t H5C2_unpin_entry(H5F_t * file_ptr, void * thing);
-H5_DLL herr_t H5C2_unprotect(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_unprotect(H5F_t * f,
hid_t dxpl_id,
const H5C2_class_t * type,
haddr_t addr,
@@ -1437,8 +1436,8 @@ H5_DLL herr_t H5C2_jb__write_to_buffer(H5C2_jbrb_t * struct_ptr,
unsigned long trans_num);
H5_DLL herr_t H5C2_jb__init(H5C2_jbrb_t * struct_ptr,
- char * HDF5_file_name,
- char * journal_file_name,
+ const char * HDF5_file_name,
+ const char * journal_file_name,
size_t buf_size,
int num_bufs,
hbool_t use_aio,
@@ -1451,13 +1450,13 @@ H5_DLL herr_t H5C2_jb__journal_entry(H5C2_jbrb_t * struct_ptr,
unsigned long trans_num,
haddr_t base_addr,
size_t length,
- const char * body);
+ const uint8_t * body);
H5_DLL herr_t H5C2_jb__end_transaction(H5C2_jbrb_t * struct_ptr,
unsigned long trans_num);
H5_DLL herr_t H5C2_jb__comment(H5C2_jbrb_t * struct_ptr,
- char * comment_ptr);
+ const char * comment_ptr);
H5_DLL herr_t H5C2_jb__get_last_transaction_on_disk(H5C2_jbrb_t * struct_ptr,
unsigned long * trans_num_ptr);
@@ -1471,8 +1470,8 @@ H5_DLL herr_t H5C2_jb__reconfigure(H5C2_jbrb_t * struct_ptr,
int new_num_bufs,
hbool_t new_use_aio);
-H5_DLL herr_t H5C2_jb__bin2hex(uint8_t * buf,
- uint8_t * hexdata,
+H5_DLL herr_t H5C2_jb__bin2hex(const uint8_t * buf,
+ char * hexdata,
size_t * hexlength,
size_t buf_offset,
size_t buf_size);
@@ -1481,26 +1480,26 @@ H5_DLL herr_t H5C2_jb__bin2hex(uint8_t * buf,
/********** journal config block management function definitions: ************/
/*****************************************************************************/
-H5_DLL herr_t H5C2_create_journal_config_block(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_create_journal_config_block(H5F_t *f,
hid_t dxpl_id,
const char * journal_file_name_ptr);
-H5_DLL herr_t H5C2_discard_journal_config_block(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_discard_journal_config_block(H5F_t * f,
hid_t dxpl_id);
-H5_DLL herr_t H5C2_get_journaling_in_progress(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_get_journaling_in_progress(H5F_t * f,
hid_t dxpl_id);
-H5_DLL herr_t H5C2_load_journal_config_block(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_load_journal_config_block(H5F_t * f,
hid_t dxpl_id,
haddr_t block_addr,
hsize_t block_len);
-H5_DLL herr_t H5C2_mark_journaling_in_progress(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_mark_journaling_in_progress(H5F_t * f,
hid_t dxpl_id,
const char * journal_file_name_ptr);
-H5_DLL herr_t H5C2_unmark_journaling_in_progress(H5C2_t * cache_ptr,
+H5_DLL herr_t H5C2_unmark_journaling_in_progress(H5F_t * f,
hid_t dxpl_id);
diff --git a/src/H5D.c b/src/H5D.c
index 49dc4a5..81872c5 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -27,6 +27,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c
index 4ca5b21..4ffe458 100644
--- a/src/H5Ddbg.c
+++ b/src/H5Ddbg.c
@@ -27,6 +27,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c
index 95f89cf..f0d7487 100644
--- a/src/H5Ddeprec.c
+++ b/src/H5Ddeprec.c
@@ -41,6 +41,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
diff --git a/src/H5Dfill.c b/src/H5Dfill.c
index bfb4354..0f4c2ca 100644
--- a/src/H5Dfill.c
+++ b/src/H5Dfill.c
@@ -34,6 +34,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dpkg.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 848668a..f78ba36 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -45,7 +45,6 @@
/* Module Setup */
/****************/
-#define H5B_PACKAGE /*suppress error about including H5Bpkg */
#define H5D_PACKAGE /*suppress error about including H5Dpkg */
@@ -53,7 +52,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
-#include "H5Bpkg.h" /* B-link trees */
+#include "H5Bprivate.h" /* B-link trees */
#include "H5Dpkg.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
@@ -249,10 +248,8 @@ static H5B_ins_t H5D_istore_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *
static H5B_ins_t H5D_istore_remove( H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key,
hbool_t *lt_key_changed, void *_udata, void *_rt_key,
hbool_t *rt_key_changed);
-static herr_t H5D_istore_decode_key(const H5F_t *f, const H5B_t *bt, const uint8_t *raw,
- void *_key);
-static herr_t H5D_istore_encode_key(const H5F_t *f, const H5B_t *bt, uint8_t *raw,
- void *_key);
+static herr_t H5D_istore_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key);
+static herr_t H5D_istore_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key);
static herr_t H5D_istore_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id,
int indent, int fwidth, const void *key,
const void *udata);
@@ -332,9 +329,6 @@ H5D_istore_get_shared(const H5F_t UNUSED *f, const void *_udata)
HDassert(udata->mesg);
HDassert(udata->mesg->u.chunk.btree_shared);
- /* Increment reference count on B-tree info */
- H5RC_INC(udata->mesg->u.chunk.btree_shared);
-
/* Return the pointer to the ref-count object */
FUNC_LEAVE_NOAPI(udata->mesg->u.chunk.btree_shared)
} /* end H5D_istore_get_shared() */
@@ -353,29 +347,25 @@ H5D_istore_get_shared(const H5F_t UNUSED *f, const void *_udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_decode_key(const H5F_t UNUSED *f, const H5B_t *bt, const uint8_t *raw, void *_key)
+H5D_istore_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key)
{
H5D_istore_key_t *key = (H5D_istore_key_t *) _key;
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
size_t ndims;
unsigned u;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_decode_key)
/* check args */
- assert(f);
- assert(bt);
- shared=H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
- assert(raw);
- assert(key);
+ HDassert(raw);
+ HDassert(key);
ndims = H5D_ISTORE_NDIMS(shared);
- assert(ndims<=H5O_LAYOUT_NDIMS);
+ HDassert(ndims <= H5O_LAYOUT_NDIMS);
/* decode */
UINT32DECODE(raw, key->nbytes);
UINT32DECODE(raw, key->filter_mask);
- for (u=0; u<ndims; u++)
+ for(u = 0; u < ndims; u++)
UINT64DECODE(raw, key->offset[u]);
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -395,29 +385,25 @@ H5D_istore_decode_key(const H5F_t UNUSED *f, const H5B_t *bt, const uint8_t *raw
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_istore_encode_key(const H5F_t UNUSED *f, const H5B_t *bt, uint8_t *raw, void *_key)
+H5D_istore_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key)
{
- H5D_istore_key_t *key = (H5D_istore_key_t *) _key;
- H5B_shared_t *shared; /* Pointer to shared B-tree info */
+ const H5D_istore_key_t *key = (const H5D_istore_key_t *) _key;
size_t ndims;
unsigned u;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_istore_encode_key)
/* check args */
- assert(f);
- assert(bt);
- shared=H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
- assert(raw);
- assert(key);
+ HDassert(raw);
+ HDassert(key);
ndims = H5D_ISTORE_NDIMS(shared);
- assert(ndims<=H5O_LAYOUT_NDIMS);
+ HDassert(ndims <= H5O_LAYOUT_NDIMS);
/* encode */
UINT32ENCODE(raw, key->nbytes);
UINT32ENCODE(raw, key->filter_mask);
- for (u=0; u<ndims; u++)
+ for(u = 0; u < ndims; u++)
UINT64ENCODE(raw, key->offset[u]);
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -1488,6 +1474,10 @@ H5D_istore_shared_create (const H5F_t *f, H5O_layout_t *layout)
assert(shared->sizeof_rkey);
shared->sizeof_rnode = H5B_nodesize(f, shared, &shared->sizeof_keys);
assert(shared->sizeof_rnode);
+ shared->sizeof_addr = H5F_SIZEOF_ADDR(f);
+ assert(shared->sizeof_addr);
+ shared->sizeof_len = H5F_SIZEOF_SIZE(f);
+ assert(shared->sizeof_len);
if(NULL==(shared->page=H5FL_BLK_MALLOC(chunk_page,shared->sizeof_rnode)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page")
#ifdef H5_CLEAR_MEMORY
diff --git a/src/H5F.c b/src/H5F.c
index 3b0770f..0f70009 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -23,9 +23,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Aprivate.h" /* Attributes */
#include "H5ACprivate.h" /* Metadata cache */
-#if 1 /* JRM */
#include "H5AC2private.h" /* Metadata cache2 */
-#endif /* JRM */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
@@ -933,15 +931,14 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
*/
if(SUCCEED != H5AC_create(f, &(f->shared->mdc_initCacheCfg)))
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create meta data cache")
-#if 1 /* JRM */
- /* create a metadata cache with modified API along side the regular
+
+ /* Create a metadata cache with modified API along side the regular
* version. For now, this is just for testing. Once we get it
* fully in use, we will delete the old version.
*/
- if(SUCCEED != H5AC2_create(f,
- (H5AC2_cache_config_t *)&(f->shared->mdc_initCacheCfg)))
+ if(H5AC2_create(f, (H5AC2_cache_config_t *)&(f->shared->mdc_initCacheCfg)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create meta data cache2")
-#endif /* JRM */
+
/* Create the file's "open object" information */
if(H5FO_create(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure")
@@ -1040,12 +1037,10 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
if(H5AC_dest(f, dxpl_id))
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file")
-#if 1 /* JRM */
/* also destroy the modified cache */
if(H5AC2_dest(f, dxpl_id))
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file")
-#endif /* JRM */
if(H5FO_dest(f) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file")
@@ -1719,12 +1714,9 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags)
if((flags & H5F_FLUSH_INVALIDATE) != 0 )
H5AC_flags |= H5AC__FLUSH_INVALIDATE_FLAG;
if(H5AC_flush(f, dxpl_id, H5AC_flags) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush meta data cache")
-#if 1 /* JRM */
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache")
if(H5AC2_flush(f, dxpl_id, H5AC_flags) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \
- "unable to flush meta data cache2")
-#endif /* JRM */
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache2")
/*
* If we are invalidating everything (which only happens just before
@@ -3075,7 +3067,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_addr_encode
+ * Function: H5F_addr_encode_len
*
* Purpose: Encodes an address into the buffer pointed to by *PP and
* then increments the pointer to the first byte after the
@@ -3086,31 +3078,54 @@ done:
* Programmer: Robb Matzke
* Friday, November 7, 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
void
-H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr)
+H5F_addr_encode_len(uint8_t **pp/*in,out*/, haddr_t addr, unsigned addr_len)
{
- unsigned i;
+ unsigned u; /* Local index variable */
- assert(f);
- assert(pp && *pp);
+ HDassert(pp && *pp);
- if (H5F_addr_defined(addr)) {
- for (i=0; i<H5F_SIZEOF_ADDR(f); i++) {
+ if(H5F_addr_defined(addr)) {
+ for(u = 0; u < addr_len; u++) {
*(*pp)++ = (uint8_t)(addr & 0xff);
addr >>= 8;
- }
+ } /* end for */
assert("overflow" && 0 == addr);
-
- } else {
- for (i=0; i<H5F_SIZEOF_ADDR(f); i++)
+ } /* end if */
+ else {
+ for(u = 0; u < addr_len; u++)
*(*pp)++ = 0xff;
- }
-}
+ } /* end else */
+} /* end H5F_addr_encode_len() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_addr_encode
+ *
+ * Purpose: Encodes an address into the buffer pointed to by *PP and
+ * then increments the pointer to the first byte after the
+ * address. An undefined value is stored as all 1's.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 7, 1997
+ *
+ * Modifications:
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
+ *-------------------------------------------------------------------------
+ */
+void
+H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr)
+{
+ HDassert(f);
+ HDassert(pp && *pp);
+
+ H5F_addr_encode_len(pp, addr, H5F_SIZEOF_ADDR(f));
+} /* end H5F_addr_encode() */
/*-------------------------------------------------------------------------
@@ -3351,9 +3366,9 @@ H5Fset_mdc_config(hid_t file_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \
"H5AC_set_cache_auto_resize_config() failed.");
}
-#if 1 /* JRM */
+
/* pass the resize configuration to the modified cache as well. */
- result = H5AC2_set_cache_auto_resize_config(file->shared->cache2,
+ result = H5AC2_set_cache_auto_resize_config(file,
(H5AC2_cache_config_t *)config_ptr);
if ( result != SUCCEED ) {
@@ -3361,7 +3376,7 @@ H5Fset_mdc_config(hid_t file_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \
"H5AC2_set_cache_auto_resize_config() failed.");
}
-#endif /* JRM */
+
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index f6fc8c4..9df85bb 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -36,12 +36,13 @@
/* Other private headers needed by this file */
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5AC2private.h" /* cache */
#include "H5FLprivate.h" /* Free Lists */
#include "H5FOprivate.h" /* File objects */
#include "H5Gprivate.h" /* Groups */
#include "H5Oprivate.h" /* Object header messages */
#include "H5RCprivate.h" /* Reference counted object functions */
-#include "H5AC2private.h" /* cache */
/*
* Feature: Define this constant on the compiler command-line if you want to
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index f9a1f57..4b45481 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -301,18 +301,22 @@ typedef struct H5F_t H5F_t;
case 2: UINT16DECODE(p, o); break; \
}
-#define H5F_ENCODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \
+#define H5F_ENCODE_LENGTH_LEN(p,l,s) switch(s) { \
case 4: UINT32ENCODE(p,l); break; \
case 8: UINT64ENCODE(p,l); break; \
case 2: UINT16ENCODE(p,l); break; \
}
-#define H5F_DECODE_LENGTH(f,p,l) switch(H5F_SIZEOF_SIZE(f)) { \
+#define H5F_ENCODE_LENGTH(f,p,l) H5F_ENCODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f))
+
+#define H5F_DECODE_LENGTH_LEN(p,l,s) switch(s) { \
case 4: UINT32DECODE(p,l); break; \
case 8: UINT64DECODE(p,l); break; \
case 2: UINT16DECODE(p,l); break; \
}
+#define H5F_DECODE_LENGTH(f,p,l) H5F_DECODE_LENGTH_LEN(p,l,H5F_SIZEOF_SIZE(f))
+
/*
* Macros that check for overflows. These are somewhat dangerous to fiddle
* with.
@@ -457,9 +461,12 @@ H5_DLL herr_t H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr,
size_t size, hid_t dxpl_id, const void *buf);
/* Address-related functions */
-H5_DLL void H5F_addr_encode(const H5F_t *, uint8_t** /*in,out*/, haddr_t);
-H5_DLL void H5F_addr_decode(const H5F_t *, const uint8_t** /*in,out*/,
- haddr_t* /*out*/);
+H5_DLL void H5F_addr_encode_len(uint8_t **pp/*in,out*/, haddr_t addr,
+ unsigned addr_len);
+H5_DLL void H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/,
+ haddr_t addr);
+H5_DLL void H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/,
+ haddr_t *addr_p/*out*/);
/* File access property list callbacks */
H5_DLL herr_t H5P_facc_close(hid_t dxpl_id, void *close_data);
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 6cff5a0..e7a2d30 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -104,10 +104,8 @@ static H5B_ins_t H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_l
static H5B_ins_t H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *lt_key,
hbool_t *lt_key_changed, void *udata,
void *rt_key, hbool_t *rt_key_changed);
-static herr_t H5G_node_decode_key(const H5F_t *f, const H5B_t *bt, const uint8_t *raw,
- void *_key);
-static herr_t H5G_node_encode_key(const H5F_t *f, const H5B_t *bt, uint8_t *raw,
- void *_key);
+static herr_t H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key);
+static herr_t H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key);
static herr_t H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id,
int indent, int fwidth, const void *key,
const void *udata);
@@ -173,18 +171,12 @@ H5FL_BLK_DEFINE_STATIC(grp_page);
static H5RC_t *
H5G_node_get_shared(const H5F_t *f, const void UNUSED *_udata)
{
- H5RC_t *rc;
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_get_shared)
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_get_shared);
-
- assert(f);
-
- /* Increment reference count on shared B-tree node */
- rc=H5F_GRP_BTREE_SHARED(f);
- H5RC_INC(rc);
+ HDassert(f);
/* Return the pointer to the ref-count object */
- FUNC_LEAVE_NOAPI(rc);
+ FUNC_LEAVE_NOAPI(H5F_GRP_BTREE_SHARED(f))
} /* end H5G_node_get_shared() */
@@ -199,25 +191,23 @@ H5G_node_get_shared(const H5F_t *f, const void UNUSED *_udata)
* matzke@llnl.gov
* Jul 8 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_decode_key(const H5F_t *f, const H5B_t UNUSED *bt, const uint8_t *raw, void *_key)
+H5G_node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key)
{
H5G_node_key_t *key = (H5G_node_key_t *) _key;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_decode_key);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_decode_key)
- assert(f);
- assert(raw);
- assert(key);
+ HDassert(shared);
+ HDassert(raw);
+ HDassert(key);
- H5F_DECODE_LENGTH(f, raw, key->offset);
+ H5F_DECODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len);
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5G_node_decode_key() */
/*-------------------------------------------------------------------------
@@ -231,25 +221,23 @@ H5G_node_decode_key(const H5F_t *f, const H5B_t UNUSED *bt, const uint8_t *raw,
* matzke@llnl.gov
* Jul 8 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_encode_key(const H5F_t *f, const H5B_t UNUSED *bt, uint8_t *raw, void *_key)
+H5G_node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key)
{
- H5G_node_key_t *key = (H5G_node_key_t *) _key;
+ const H5G_node_key_t *key = (const H5G_node_key_t *) _key;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_encode_key);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_encode_key)
- assert(f);
- assert(raw);
- assert(key);
+ HDassert(shared);
+ HDassert(raw);
+ HDassert(key);
- H5F_ENCODE_LENGTH(f, raw, key->offset);
+ H5F_ENCODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len);
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5G_node_encode_key() */
/*-------------------------------------------------------------------------
@@ -1637,6 +1625,10 @@ H5G_node_init(H5F_t *f)
assert(shared->sizeof_rkey);
shared->sizeof_rnode = H5B_nodesize(f, shared, &shared->sizeof_keys);
assert(shared->sizeof_rnode);
+ shared->sizeof_addr = H5F_SIZEOF_ADDR(f);
+ assert(shared->sizeof_addr);
+ shared->sizeof_len = H5F_SIZEOF_SIZE(f);
+ assert(shared->sizeof_len);
if(NULL==(shared->page=H5FL_BLK_MALLOC(grp_page,shared->sizeof_rnode)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree page")
#ifdef H5_CLEAR_MEMORY
diff --git a/src/H5I.c b/src/H5I.c
index 0b8b84e..2bba730 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -42,6 +42,7 @@
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Ipkg.h" /* IDs */
diff --git a/src/H5Omdj_msg.c b/src/H5Omdj_msg.c
index 0f8115b..b95e843 100644
--- a/src/H5Omdj_msg.c
+++ b/src/H5Omdj_msg.c
@@ -124,7 +124,6 @@ H5O_mdj_msg_decode(H5F_t *f,
unsigned UNUSED mesg_flags,
const uint8_t *p)
{
- const char * fcn_name = "H5O_mdj_msg_decode()";
uint16_t flags = 0; /* packed boolean fields */
H5O_mdj_msg_t *mesg; /* Native message */
void *ret_value; /* Return value */
@@ -260,7 +259,6 @@ done:
static void *
H5O_mdj_msg_copy(const void *_mesg, void *_dest)
{
- const char * fcn_name = "H5O_mdj_msg_copy()";
const H5O_mdj_msg_t *mesg = (const H5O_mdj_msg_t *)_mesg;
H5O_mdj_msg_t *dest = (H5O_mdj_msg_t *)_dest;
void *ret_value;
@@ -312,9 +310,7 @@ H5O_mdj_msg_size(const H5F_t *f,
hbool_t UNUSED disable_shared,
const void *_mesg)
{
- const char * fcn_name = "H5O_mdj_msg_size()";
const H5O_mdj_msg_t * mesg = (const H5O_mdj_msg_t *)_mesg;
- size_t ret_value;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mdj_msg_size)
@@ -322,12 +318,7 @@ H5O_mdj_msg_size(const H5F_t *f,
HDassert(f);
HDassert(mesg);
- ret_value = MDJ_MSG_LEN(f);
-
-done:
-
- FUNC_LEAVE_NOAPI(ret_value)
-
+ FUNC_LEAVE_NOAPI(MDJ_MSG_LEN(f))
} /* end H5O_mdj_msg_size() */
@@ -350,23 +341,19 @@ done:
static herr_t
H5O_mdj_msg_reset(void *_mesg)
{
- const char * fcn_name = "H5O_mdj_msg_reset()";
H5O_mdj_msg_t *mesg = (H5O_mdj_msg_t *) _mesg;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mdj_msg_reset);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mdj_msg_reset)
/* check args */
- assert(mesg);
+ HDassert(mesg);
/* reset */
mesg->mdc_jrnl_enabled = FALSE;
mesg->mdc_jrnl_block_loc = HADDR_UNDEF;
mesg->mdc_jrnl_block_len = 0;
-done:
-
- FUNC_LEAVE_NOAPI(SUCCEED);
-
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5O_mdj_msg_reset() */
@@ -391,7 +378,6 @@ H5O_mdj_msg_debug(H5F_t UNUSED *f,
int indent,
int fwidth)
{
- const char * fcn_name = "H5O_mdj_msg_debug()";
const H5O_mdj_msg_t *mesg = (const H5O_mdj_msg_t *)_mesg;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_mdj_msg_debug)
@@ -415,9 +401,6 @@ H5O_mdj_msg_debug(H5F_t UNUSED *f,
"mdc_jrnl_block_len:",
(int)(mesg->mdc_jrnl_block_len));
-done:
-
FUNC_LEAVE_NOAPI(SUCCEED)
-
} /* end H5O_mdj_msg_debug() */
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 8d6b9ab..5f98bbd 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -35,6 +35,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 81dba0c..44ac3c4 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -34,6 +34,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
diff --git a/src/H5R.c b/src/H5R.c
index 627626b..ca5d8fe 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -20,6 +20,7 @@
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gprivate.h" /* Groups */
diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c
index 9dcfa45..0e2acc8 100644
--- a/src/H5Rdeprec.c
+++ b/src/H5Rdeprec.c
@@ -41,6 +41,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gprivate.h" /* Groups */
#include "H5Oprivate.h" /* Object headers */
diff --git a/src/H5T.c b/src/H5T.c
index 04d6c0b..3602e60 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -27,6 +27,7 @@
#include "H5private.h" /*generic functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /*datasets (for H5Tcopy) */
#include "H5Eprivate.h" /*error handling */
#include "H5Fprivate.h" /* Files */
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index bcb9962..1e52325 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -25,6 +25,7 @@
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5FOprivate.h" /* File objects */
#include "H5Iprivate.h" /* IDs */
diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c
index 64386b1..56ca889 100644
--- a/src/H5Tdeprec.c
+++ b/src/H5Tdeprec.c
@@ -41,6 +41,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5FOprivate.h" /* File objects */
#include "H5Iprivate.h" /* IDs */
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index 7482275..b970cdf 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -16,6 +16,7 @@
#define H5Z_PACKAGE /*suppress error about including H5Zpkg */
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */