summaryrefslogtreecommitdiffstats
path: root/src/H5B2cache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
commitd2b87ec47ebdb096c331c7b62a195b9cea2f33ae (patch)
treea066f01361afaf5df457cef612bb0bb9fd80fe18 /src/H5B2cache.c
parentee5a1e07350f0dcf3ef07d9443aa2f4c073392f4 (diff)
downloadhdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.zip
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.gz
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.bz2
[svn-r17896] Description:
Bring r17546:17895 from trunk to revise_chunks branch. Changes to fixed and extensible array dataset chunk indexing code to accommodate changes to private APIs in those interfaces. Also, other adjustments to source code and expected output in response to changes on the trunk. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5B2cache.c')
-rw-r--r--src/H5B2cache.c398
1 files changed, 184 insertions, 214 deletions
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index 5ca7ed8..6737076 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -69,15 +69,15 @@
/********************/
/* Metadata cache callbacks */
-static H5B2_t *H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata);
-static herr_t H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_t *b, unsigned UNUSED * flags_ptr);
-static herr_t H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *b, hbool_t destroy);
-static herr_t H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t *bt, size_t *size_ptr);
-static H5B2_internal_t *H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_shared);
+static H5B2_hdr_t *H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata);
+static herr_t H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_hdr_t *hdr, unsigned UNUSED * flags_ptr);
+static herr_t H5B2_cache_hdr_clear(H5F_t *f, H5B2_hdr_t *hdr, hbool_t destroy);
+static herr_t H5B2_cache_hdr_size(const H5F_t *f, const H5B2_hdr_t *hdr, size_t *size_ptr);
+static H5B2_internal_t *H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *udata2);
static herr_t H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_internal_t *i, unsigned UNUSED * flags_ptr);
static herr_t H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *i, hbool_t destroy);
static herr_t H5B2_cache_internal_size(const H5F_t *f, const H5B2_internal_t *i, size_t *size_ptr);
-static H5B2_leaf_t *H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_shared);
+static H5B2_leaf_t *H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_hdr);
static herr_t H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_leaf_t *l, unsigned UNUSED * flags_ptr);
static herr_t H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *l, hbool_t destroy);
static herr_t H5B2_cache_leaf_size(const H5F_t *f, const H5B2_leaf_t *l, size_t *size_ptr);
@@ -138,7 +138,6 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{
* Purpose: Loads a B-tree header from the disk.
*
* Return: Success: Pointer to a new B-tree.
- *
* Failure: NULL
*
* Programmer: Quincey Koziol
@@ -147,52 +146,49 @@ const H5AC_class_t H5AC_BT2_LEAF[1] = {{
*
*-------------------------------------------------------------------------
*/
-static H5B2_t *
-H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void UNUSED *udata)
+static H5B2_hdr_t *
+H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2)
{
- const H5B2_class_t *type = (const H5B2_class_t *) _type; /* Type of B-tree */
- unsigned depth; /* Depth of B-tree */
- size_t node_size, rrec_size; /* Size info for B-tree */
- uint8_t split_percent, merge_percent; /* Split & merge %s for B-tree */
- H5B2_t *bt2 = NULL; /* B-tree info */
+ H5B2_create_t cparam; /* B-tree creation parameters */
+ H5B2_subid_t id; /* ID of B-tree class, as found in file */
+ uint16_t depth; /* Depth of B-tree */
+ H5B2_hdr_t *hdr = NULL; /* B-tree header */
size_t size; /* Header size */
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
H5WB_t *wb = NULL; /* Wrapped buffer for header data */
uint8_t hdr_buf[H5B2_HDR_BUF_SIZE]; /* Buffer for header */
- uint8_t *hdr; /* Pointer to header buffer */
+ uint8_t *buf; /* Pointer to header buffer */
uint8_t *p; /* Pointer into raw data buffer */
- H5B2_t *ret_value; /* Return value */
+ H5B2_hdr_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5B2_cache_hdr_load, NULL)
/* Check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
- HDassert(type);
- /* Allocate space for the B-tree data structure */
- if(NULL == (bt2 = H5FL_MALLOC(H5B2_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemset(&bt2->cache_info, 0, sizeof(H5AC_info_t));
+ /* Allocate new B-tree header and reset cache info */
+ if(NULL == (hdr = H5B2_hdr_alloc(f)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "allocation failed for B-tree header")
/* Wrap the local buffer for serialized header info */
if(NULL == (wb = H5WB_wrap(hdr_buf, sizeof(hdr_buf))))
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't wrap buffer")
/* Compute the size of the serialized B-tree header on disk */
- size = H5B2_HEADER_SIZE(f);
+ size = H5B2_HEADER_SIZE(hdr);
/* Get a pointer to a buffer that's large enough for header */
- if(NULL == (hdr = (uint8_t *)H5WB_actual(wb, size)))
+ if(NULL == (buf = (uint8_t *)H5WB_actual(wb, size)))
HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "can't get actual buffer")
/* Read header from disk */
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, hdr) < 0)
+ if(H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree header")
/* Get temporary pointer to serialized header */
- p = hdr;
+ p = buf;
/* Magic number */
if(HDmemcmp(p, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
@@ -203,54 +199,60 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, vo
if(*p++ != H5B2_HDR_VERSION)
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree header version")
- /* B-tree type */
- if(*p++ != (uint8_t)type->id)
- HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
+ /* B-tree class */
+ id = *p++;
+ if(id >= H5B2_NUM_BTREE_ID)
+ HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "invalid B-tree type")
/* Node size (in bytes) */
- UINT32DECODE(p, node_size);
+ UINT32DECODE(p, cparam.node_size);
/* Raw key size (in bytes) */
- UINT16DECODE(p, rrec_size);
+ UINT16DECODE(p, cparam.rrec_size);
/* Depth of tree */
UINT16DECODE(p, depth);
/* Split & merge %s */
- split_percent = *p++;
- merge_percent = *p++;
+ cparam.split_percent = *p++;
+ cparam.merge_percent = *p++;
/* Root node pointer */
- H5F_addr_decode(f, (const uint8_t **)&p, &(bt2->root.addr));
- UINT16DECODE(p, bt2->root.node_nrec);
- H5F_DECODE_LENGTH(f, p, bt2->root.all_nrec);
+ H5F_addr_decode(f, (const uint8_t **)&p, &(hdr->root.addr));
+ UINT16DECODE(p, hdr->root.node_nrec);
+ H5F_DECODE_LENGTH(f, p, hdr->root.all_nrec);
/* Metadata checksum */
UINT32DECODE(p, stored_chksum);
/* Sanity check */
- HDassert((size_t)(p - hdr) == size);
+ HDassert((size_t)(p - buf) == size);
/* Compute checksum on entire header */
- computed_chksum = H5_checksum_metadata(hdr, (size - H5B2_SIZEOF_CHKSUM), 0);
+ computed_chksum = H5_checksum_metadata(buf, (size - H5B2_SIZEOF_CHKSUM), 0);
/* Verify checksum */
if(stored_chksum != computed_chksum)
HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 B-tree header")
- /* Initialize shared B-tree info */
- if(H5B2_shared_init(f, bt2, type, depth, node_size, rrec_size, split_percent, merge_percent) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't create shared B-tree info")
+ /* Initialize B-tree header info */
+ cparam.cls = H5B2_client_class_g[id];
+ if(H5B2_hdr_init(f, hdr, &cparam, depth) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, NULL, "can't initialize B-tree header info")
+
+ /* Set the B-tree header's address */
+ hdr->addr = addr;
/* Set return value */
- ret_value = bt2;
+ ret_value = hdr;
done:
/* Release resources */
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
- if(!ret_value && bt2)
- (void)H5B2_cache_hdr_dest(f, bt2);
+ if(!ret_value && hdr)
+ if(H5B2_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, NULL, "can't release v2 B-tree header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B2_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */
@@ -266,17 +268,12 @@ done:
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
* Feb 1 2005
- * 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.
*
*-------------------------------------------------------------------------
*/
static herr_t
H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
- H5B2_t *bt2, unsigned UNUSED * flags_ptr)
+ H5B2_hdr_t *hdr, unsigned UNUSED * flags_ptr)
{
H5WB_t *wb = NULL; /* Wrapped buffer for header data */
uint8_t hdr_buf[H5B2_HDR_BUF_SIZE]; /* Buffer for header */
@@ -287,32 +284,30 @@ H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
- HDassert(bt2);
+ HDassert(hdr);
- if (bt2->cache_info.is_dirty) {
- H5B2_shared_t *shared; /* Shared B-tree information */
- uint8_t *hdr; /* Pointer to header buffer */
+ if(hdr->cache_info.is_dirty) {
+ uint8_t *buf; /* Pointer to header buffer */
uint8_t *p; /* Pointer into raw data buffer */
size_t size; /* Header size on disk */
uint32_t metadata_chksum; /* Computed metadata checksum value */
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(bt2->shared);
- HDassert(shared);
+ /* Set the B-tree header's file context for this operation */
+ hdr->f = f;
/* Wrap the local buffer for serialized header info */
if(NULL == (wb = H5WB_wrap(hdr_buf, sizeof(hdr_buf))))
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't wrap buffer")
/* Compute the size of the serialized B-tree header on disk */
- size = H5B2_HEADER_SIZE(f);
+ size = H5B2_HEADER_SIZE(hdr);
/* Get a pointer to a buffer that's large enough for header */
- if(NULL == (hdr = (uint8_t *)H5WB_actual(wb, size)))
+ if(NULL == (buf = (uint8_t *)H5WB_actual(wb, size)))
HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, FAIL, "can't get actual buffer")
/* Get temporary pointer to serialized header */
- p = hdr;
+ p = buf;
/* Magic number */
HDmemcpy(p, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
@@ -322,44 +317,44 @@ H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
*p++ = H5B2_HDR_VERSION;
/* B-tree type */
- *p++ = shared->type->id;
+ *p++ = hdr->cls->id;
/* Node size (in bytes) */
- UINT32ENCODE(p, shared->node_size);
+ UINT32ENCODE(p, hdr->node_size);
/* Raw key size (in bytes) */
- UINT16ENCODE(p, shared->rrec_size);
+ UINT16ENCODE(p, hdr->rrec_size);
/* Depth of tree */
- UINT16ENCODE(p, shared->depth);
+ UINT16ENCODE(p, hdr->depth);
/* Split & merge %s */
- H5_CHECK_OVERFLOW(shared->split_percent, /* From: */ unsigned, /* To: */ uint8_t);
- *p++ = (uint8_t)shared->split_percent;
- H5_CHECK_OVERFLOW(shared->merge_percent, /* From: */ unsigned, /* To: */ uint8_t);
- *p++ = (uint8_t)shared->merge_percent;
+ H5_CHECK_OVERFLOW(hdr->split_percent, /* From: */ unsigned, /* To: */ uint8_t);
+ *p++ = (uint8_t)hdr->split_percent;
+ H5_CHECK_OVERFLOW(hdr->merge_percent, /* From: */ unsigned, /* To: */ uint8_t);
+ *p++ = (uint8_t)hdr->merge_percent;
/* Root node pointer */
- H5F_addr_encode(f, &p, bt2->root.addr);
- UINT16ENCODE(p, bt2->root.node_nrec);
- H5F_ENCODE_LENGTH(f, p, bt2->root.all_nrec);
+ H5F_addr_encode(f, &p, hdr->root.addr);
+ UINT16ENCODE(p, hdr->root.node_nrec);
+ H5F_ENCODE_LENGTH(f, p, hdr->root.all_nrec);
/* Compute metadata checksum */
- metadata_chksum = H5_checksum_metadata(hdr, (size - H5B2_SIZEOF_CHKSUM), 0);
+ metadata_chksum = H5_checksum_metadata(buf, (size - H5B2_SIZEOF_CHKSUM), 0);
/* Metadata checksum */
UINT32ENCODE(p, metadata_chksum);
/* Write the B-tree header. */
- HDassert((size_t)(p - hdr) == size);
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, hdr) < 0)
+ HDassert((size_t)(p - buf) == size);
+ if(H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree header to disk")
- bt2->cache_info.is_dirty = FALSE;
+ hdr->cache_info.is_dirty = FALSE;
} /* end if */
if(destroy)
- if(H5B2_cache_hdr_dest(f, bt2) < 0)
+ if(H5B2_cache_hdr_dest(f, hdr) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header")
done:
@@ -385,7 +380,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *bt2)
+H5B2_cache_hdr_dest(H5F_t *f, H5B2_hdr_t *hdr)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -394,25 +389,23 @@ H5B2_cache_hdr_dest(H5F_t *f, H5B2_t *bt2)
/*
* Check arguments.
*/
- HDassert(bt2);
+ HDassert(hdr);
+ HDassert(hdr->rc == 0);
/* If we're going to free the space on disk, the address must be valid */
- HDassert(!bt2->cache_info.free_file_space_on_destroy || H5F_addr_defined(bt2->cache_info.addr));
+ HDassert(!hdr->cache_info.free_file_space_on_destroy || H5F_addr_defined(hdr->cache_info.addr));
/* Check for freeing file space for B-tree header */
- if(bt2->cache_info.free_file_space_on_destroy) {
+ if(hdr->cache_info.free_file_space_on_destroy) {
/* Release the space on disk */
/* (XXX: Nasty usage of internal DXPL value! -QAK) */
- if(H5MF_xfree(f, H5FD_MEM_BTREE, H5AC_dxpl_id, bt2->cache_info.addr, (hsize_t)H5B2_HEADER_SIZE(f)) < 0)
+ if(H5MF_xfree(f, H5FD_MEM_BTREE, H5AC_dxpl_id, hdr->cache_info.addr, (hsize_t)H5B2_HEADER_SIZE(hdr)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree header")
} /* end if */
- /* Decrement reference count on shared B-tree info */
- if(bt2->shared)
- H5RC_DEC(bt2->shared);
-
- /* Free B-tree header info */
- (void)H5FL_FREE(H5B2_t, bt2);
+ /* Release B-tree header info */
+ if(H5B2_hdr_free(hdr) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree header info")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -433,7 +426,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *bt2, hbool_t destroy)
+H5B2_cache_hdr_clear(H5F_t *f, H5B2_hdr_t *hdr, hbool_t destroy)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -442,13 +435,13 @@ H5B2_cache_hdr_clear(H5F_t *f, H5B2_t *bt2, hbool_t destroy)
/*
* Check arguments.
*/
- HDassert(bt2);
+ HDassert(hdr);
/* Reset the dirty flag. */
- bt2->cache_info.is_dirty = FALSE;
+ hdr->cache_info.is_dirty = FALSE;
if(destroy)
- if(H5B2_cache_hdr_dest(f, bt2) < 0)
+ if(H5B2_cache_hdr_dest(f, hdr) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header")
done:
@@ -472,7 +465,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t UNUSED *bt2, size_t *size_ptr)
+H5B2_cache_hdr_size(const H5F_t UNUSED *f, const H5B2_hdr_t *hdr, size_t *size_ptr)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_hdr_size)
@@ -481,7 +474,7 @@ H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t UNUSED *bt2, size_t *size_ptr)
HDassert(size_ptr);
/* Set size value */
- *size_ptr = H5B2_HEADER_SIZE(f);
+ *size_ptr = H5B2_HEADER_SIZE(hdr);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5B2_cache_hdr_size() */
@@ -493,7 +486,6 @@ H5B2_cache_hdr_size(const H5F_t *f, const H5B2_t UNUSED *bt2, size_t *size_ptr)
* Purpose: Loads a B-tree internal node from the disk.
*
* Return: Success: Pointer to a new B-tree internal node.
- *
* Failure: NULL
*
* Programmer: Quincey Koziol
@@ -506,7 +498,6 @@ static H5B2_internal_t *
H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata, void UNUSED *udata2)
{
const H5B2_int_load_ud1_t *udata = (const H5B2_int_load_ud1_t *)_udata; /* Pointer to user data */
- H5B2_shared_t *shared; /* Shared B-tree information */
H5B2_internal_t *internal = NULL; /* Internal node read */
uint8_t *p; /* Pointer into raw data buffer */
uint8_t *native; /* Pointer to native record info */
@@ -528,19 +519,21 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
HDmemset(&internal->cache_info, 0, sizeof(H5AC_info_t));
- /* Share common B-tree information */
- internal->shared = udata->bt2_shared;
- H5RC_INC(internal->shared);
+ /* Set the B-tree header's file context for this operation */
+ udata->hdr->f = f;
+
+ /* Increment ref. count on B-tree header */
+ if(H5B2_hdr_incr(udata->hdr) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header")
- /* Get the pointer to the shared B-tree info */
- shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
- HDassert(shared);
+ /* Share B-tree information */
+ internal->hdr = udata->hdr;
/* Read header from disk */
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page)<0)
+ if(H5F_block_read(f, H5FD_MEM_BTREE, addr, udata->hdr->node_size, dxpl_id, udata->hdr->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree internal node")
- p = shared->page;
+ p = udata->hdr->page;
/* Magic number */
if(HDmemcmp(p, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC))
@@ -552,15 +545,15 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree internal node version")
/* B-tree type */
- if(*p++ != (uint8_t)shared->type->id)
+ if(*p++ != (uint8_t)udata->hdr->cls->id)
HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
/* Allocate space for the native keys in memory */
- if((internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(shared->node_info[udata->depth].nat_rec_fac)) == NULL)
+ if(NULL == (internal->int_native = (uint8_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].nat_rec_fac)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal native keys")
/* Allocate space for the node pointers in memory */
- if((internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(shared->node_info[udata->depth].node_ptr_fac)) == NULL)
+ if(NULL == (internal->node_ptrs = (H5B2_node_ptr_t *)H5FL_FAC_MALLOC(udata->hdr->node_info[udata->depth].node_ptr_fac)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree internal node pointers")
/* Set the number of records in the leaf & it's depth */
@@ -571,22 +564,22 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
native = internal->int_native;
for(u = 0; u < internal->nrec; u++) {
/* Decode record */
- if((shared->type->decode)(f, p, native) < 0)
+ if((udata->hdr->cls->decode)(f, p, native) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode B-tree record")
/* Move to next record */
- p += shared->rrec_size;
- native += shared->type->nrec_size;
+ p += udata->hdr->rrec_size;
+ native += udata->hdr->cls->nrec_size;
} /* end for */
/* Deserialize node pointers for internal node */
int_node_ptr = internal->node_ptrs;
- for(u = 0; u < internal->nrec + 1; u++) {
+ for(u = 0; u < (unsigned)(internal->nrec + 1); u++) {
/* Decode node pointer */
H5F_addr_decode(f, (const uint8_t **)&p, &(int_node_ptr->addr));
- UINT64DECODE_VAR(p, int_node_ptr->node_nrec, shared->max_nrec_size);
+ UINT64DECODE_VAR(p, int_node_ptr->node_nrec, udata->hdr->max_nrec_size);
if(udata->depth > 1)
- UINT64DECODE_VAR(p, int_node_ptr->all_nrec, shared->node_info[udata->depth - 1].cum_max_nrec_size)
+ UINT64DECODE_VAR(p, int_node_ptr->all_nrec, udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size)
else
int_node_ptr->all_nrec = int_node_ptr->node_nrec;
@@ -595,13 +588,13 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda
} /* end for */
/* Compute checksum on internal node */
- computed_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
+ computed_chksum = H5_checksum_metadata(udata->hdr->page, (size_t)(p - udata->hdr->page), 0);
/* Metadata checksum */
UINT32DECODE(p, stored_chksum);
/* Sanity check parsing */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
+ HDassert((size_t)(p - udata->hdr->page) <= udata->hdr->node_size);
/* Verify checksum */
if(stored_chksum != computed_chksum)
@@ -627,11 +620,6 @@ done:
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
* Feb 3 2005
- * 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.
*
*-------------------------------------------------------------------------
*/
@@ -646,20 +634,19 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr
HDassert(f);
HDassert(H5F_addr_defined(addr));
HDassert(internal);
+ HDassert(internal->hdr);
if(internal->cache_info.is_dirty) {
- H5B2_shared_t *shared; /* Shared B-tree information */
uint8_t *p; /* Pointer into raw data buffer */
uint8_t *native; /* Pointer to native record info */
H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */
uint32_t metadata_chksum; /* Computed metadata checksum value */
unsigned u; /* Local index variable */
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
- HDassert(shared);
+ /* Set the B-tree header's file context for this operation */
+ internal->hdr->f = f;
- p = shared->page;
+ p = internal->hdr->page;
/* Magic number */
HDmemcpy(p, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC);
@@ -669,43 +656,43 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr
*p++ = H5B2_INT_VERSION;
/* B-tree type */
- *p++ = shared->type->id;
- HDassert((size_t)(p - shared->page) == (H5B2_INT_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
+ *p++ = internal->hdr->cls->id;
+ HDassert((size_t)(p - internal->hdr->page) == (H5B2_INT_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
/* Serialize records for internal node */
native = internal->int_native;
for(u = 0; u < internal->nrec; u++) {
/* Encode record */
- if((shared->type->encode)(f, p, native) < 0)
+ if((internal->hdr->cls->encode)(f, p, native) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
/* Move to next record */
- p += shared->rrec_size;
- native += shared->type->nrec_size;
+ p += internal->hdr->rrec_size;
+ native += internal->hdr->cls->nrec_size;
} /* end for */
/* Serialize node pointers for internal node */
int_node_ptr = internal->node_ptrs;
- for(u = 0; u < internal->nrec + 1; u++) {
+ for(u = 0; u < (unsigned)(internal->nrec + 1); u++) {
/* Encode node pointer */
H5F_addr_encode(f, &p, int_node_ptr->addr);
- UINT64ENCODE_VAR(p, int_node_ptr->node_nrec, shared->max_nrec_size);
+ UINT64ENCODE_VAR(p, int_node_ptr->node_nrec, internal->hdr->max_nrec_size);
if(internal->depth > 1)
- UINT64ENCODE_VAR(p, int_node_ptr->all_nrec, shared->node_info[internal->depth - 1].cum_max_nrec_size);
+ UINT64ENCODE_VAR(p, int_node_ptr->all_nrec, internal->hdr->node_info[internal->depth - 1].cum_max_nrec_size);
/* Move to next node pointer */
int_node_ptr++;
} /* end for */
/* Compute metadata checksum */
- metadata_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
+ metadata_chksum = H5_checksum_metadata(internal->hdr->page, (size_t)(p - internal->hdr->page), 0);
/* Metadata checksum */
UINT32ENCODE(p, metadata_chksum);
/* Write the B-tree internal node */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
+ HDassert((size_t)(p - internal->hdr->page) <= internal->hdr->node_size);
+ if(H5F_block_write(f, H5FD_MEM_BTREE, addr, internal->hdr->node_size, dxpl_id, internal->hdr->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree internal node to disk")
internal->cache_info.is_dirty = FALSE;
@@ -736,7 +723,6 @@ done:
herr_t
H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal)
{
- H5B2_shared_t *shared; /* Shared B-tree information */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_internal_dest)
@@ -744,37 +730,38 @@ H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal)
/*
* Check arguments.
*/
+ HDassert(f);
HDassert(internal);
+ HDassert(internal->hdr);
/* If we're going to free the space on disk, the address must be valid */
HDassert(!internal->cache_info.free_file_space_on_destroy || H5F_addr_defined(internal->cache_info.addr));
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
- HDassert(shared);
-
/* Check for freeing file space for B-tree internal node */
if(internal->cache_info.free_file_space_on_destroy) {
/* Release the space on disk */
/* (XXX: Nasty usage of internal DXPL value! -QAK) */
- if(H5MF_xfree(f, H5FD_MEM_BTREE, H5AC_dxpl_id, internal->cache_info.addr, (hsize_t)shared->node_size) < 0)
+ if(H5MF_xfree(f, H5FD_MEM_BTREE, H5AC_dxpl_id, internal->cache_info.addr, (hsize_t)internal->hdr->node_size) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree internal node")
} /* end if */
+ /* Set the B-tree header's file context for this operation */
+ internal->hdr->f = f;
+
/* Release internal node's native key buffer */
if(internal->int_native)
- H5FL_FAC_FREE(shared->node_info[internal->depth].nat_rec_fac, internal->int_native);
+ H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].nat_rec_fac, internal->int_native);
/* Release internal node's node pointer buffer */
if(internal->node_ptrs)
- H5FL_FAC_FREE(shared->node_info[internal->depth].node_ptr_fac, internal->node_ptrs);
+ H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].node_ptr_fac, internal->node_ptrs);
- /* Decrement reference count on shared B-tree info */
- if(internal->shared)
- H5RC_DEC(internal->shared);
+ /* Decrement ref. count on B-tree header */
+ if(H5B2_hdr_decr(internal->hdr) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header")
/* Free B-tree internal node info */
- (void)H5FL_FREE(H5B2_internal_t, internal);
+ internal = H5FL_FREE(H5B2_internal_t, internal);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -836,20 +823,15 @@ done:
static herr_t
H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal, size_t *size_ptr)
{
- H5B2_shared_t *shared; /* Shared B-tree information */
-
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_internal_size)
/* check arguments */
HDassert(internal);
+ HDassert(internal->hdr);
HDassert(size_ptr);
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared);
- HDassert(shared);
-
/* Set size value */
- *size_ptr = shared->node_size;
+ *size_ptr = internal->hdr->node_size;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5B2_cache_internal_size() */
@@ -861,7 +843,6 @@ H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal,
* Purpose: Loads a B-tree leaf from the disk.
*
* Return: Success: Pointer to a new B-tree leaf node.
- *
* Failure: NULL
*
* Programmer: Quincey Koziol
@@ -871,11 +852,10 @@ H5B2_cache_internal_size(const H5F_t UNUSED *f, const H5B2_internal_t *internal,
*-------------------------------------------------------------------------
*/
static H5B2_leaf_t *
-H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_bt2_shared)
+H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_hdr)
{
- const unsigned *nrec = (const unsigned *)_nrec;
- H5RC_t *bt2_shared = (H5RC_t *)_bt2_shared; /* Shared B-tree information */
- H5B2_shared_t *shared; /* Shared B-tree information */
+ const uint16_t *nrec = (const uint16_t *)_nrec;
+ H5B2_hdr_t *hdr = (H5B2_hdr_t *)_hdr; /* B-tree header information */
H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */
uint8_t *p; /* Pointer into raw data buffer */
uint8_t *native; /* Pointer to native keys */
@@ -889,25 +869,28 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
/* Check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
- HDassert(bt2_shared);
+ HDassert(hdr);
+ /* Allocate new leaf node and reset cache info */
if(NULL == (leaf = H5FL_MALLOC(H5B2_leaf_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
HDmemset(&leaf->cache_info, 0, sizeof(H5AC_info_t));
- /* Share common B-tree information */
- leaf->shared = bt2_shared;
- H5RC_INC(leaf->shared);
+ /* Set the B-tree header's file context for this operation */
+ hdr->f = f;
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
- HDassert(shared);
+ /* Increment ref. count on B-tree header */
+ if(H5B2_hdr_incr(hdr) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINC, NULL, "can't increment ref. count on B-tree header")
+
+ /* Share B-tree header information */
+ leaf->hdr = hdr;
/* Read header from disk */
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
+ if(H5F_block_read(f, H5FD_MEM_BTREE, addr, hdr->node_size, dxpl_id, hdr->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree leaf node")
- p = shared->page;
+ p = hdr->page;
/* Magic number */
if(HDmemcmp(p, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC))
@@ -919,12 +902,12 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree leaf node version")
/* B-tree type */
- if(*p++ != (uint8_t)shared->type->id)
+ if(*p++ != (uint8_t)hdr->cls->id)
HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, NULL, "incorrect B-tree type")
/* Allocate space for the native keys in memory */
- if((leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(shared->node_info[0].nat_rec_fac)) == NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys")
+ if(NULL == (leaf->leaf_native = (uint8_t *)H5FL_FAC_MALLOC(hdr->node_info[0].nat_rec_fac)))
+ HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree leaf native keys")
/* Set the number of records in the leaf */
leaf->nrec = *nrec;
@@ -933,22 +916,22 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
native = leaf->leaf_native;
for(u = 0; u < leaf->nrec; u++) {
/* Decode record */
- if((shared->type->decode)(f, p, native) < 0)
+ if((hdr->cls->decode)(f, p, native) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, NULL, "unable to decode B-tree record")
/* Move to next record */
- p += shared->rrec_size;
- native += shared->type->nrec_size;
+ p += hdr->rrec_size;
+ native += hdr->cls->nrec_size;
} /* end for */
/* Compute checksum on internal node */
- computed_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
+ computed_chksum = H5_checksum_metadata(hdr->page, (size_t)(p - hdr->page), 0);
/* Metadata checksum */
UINT32DECODE(p, stored_chksum);
/* Sanity check parsing */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
+ HDassert((size_t)(p - hdr->page) <= hdr->node_size);
/* Verify checksum */
if(stored_chksum != computed_chksum)
@@ -959,7 +942,7 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v
done:
if(!ret_value && leaf)
- (void)H5B2_cache_leaf_dest(f,leaf);
+ (void)H5B2_cache_leaf_dest(f, leaf);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5B2_cache_leaf_load() */ /*lint !e818 Can't make udata a pointer to const */
@@ -975,13 +958,6 @@ done:
* koziol@ncsa.uiuc.edu
* Feb 2 2005
*
- * 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.
- *
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -995,19 +971,18 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5
HDassert(f);
HDassert(H5F_addr_defined(addr));
HDassert(leaf);
+ HDassert(leaf->hdr);
if(leaf->cache_info.is_dirty) {
- H5B2_shared_t *shared; /* Shared B-tree information */
uint8_t *p; /* Pointer into raw data buffer */
uint8_t *native; /* Pointer to native keys */
uint32_t metadata_chksum; /* Computed metadata checksum value */
unsigned u; /* Local index variable */
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
- HDassert(shared);
+ /* Set the B-tree header's file context for this operation */
+ leaf->hdr->f = f;
- p = shared->page;
+ p = leaf->hdr->page;
/* magic number */
HDmemcpy(p, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC);
@@ -1017,30 +992,30 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5
*p++ = H5B2_LEAF_VERSION;
/* b-tree type */
- *p++ = shared->type->id;
- HDassert((size_t)(p - shared->page) == (H5B2_LEAF_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
+ *p++ = leaf->hdr->cls->id;
+ HDassert((size_t)(p - leaf->hdr->page) == (H5B2_LEAF_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
/* Serialize records for leaf node */
native = leaf->leaf_native;
for(u = 0; u < leaf->nrec; u++) {
/* Encode record */
- if((shared->type->encode)(f, p, native) < 0)
+ if((leaf->hdr->cls->encode)(f, p, native) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree record")
/* Move to next record */
- p += shared->rrec_size;
- native += shared->type->nrec_size;
+ p += leaf->hdr->rrec_size;
+ native += leaf->hdr->cls->nrec_size;
} /* end for */
/* Compute metadata checksum */
- metadata_chksum = H5_checksum_metadata(shared->page, (size_t)(p - shared->page), 0);
+ metadata_chksum = H5_checksum_metadata(leaf->hdr->page, (size_t)(p - leaf->hdr->page), 0);
/* Metadata checksum */
UINT32ENCODE(p, metadata_chksum);
/* Write the B-tree leaf node */
- HDassert((size_t)(p - shared->page) <= shared->node_size);
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, shared->node_size, dxpl_id, shared->page) < 0)
+ HDassert((size_t)(p - leaf->hdr->page) <= leaf->hdr->node_size);
+ if(H5F_block_write(f, H5FD_MEM_BTREE, addr, leaf->hdr->node_size, dxpl_id, leaf->hdr->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree leaf node to disk")
leaf->cache_info.is_dirty = FALSE;
@@ -1071,7 +1046,6 @@ done:
herr_t
H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf)
{
- H5B2_shared_t *shared; /* Shared B-tree information */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_leaf_dest)
@@ -1079,33 +1053,34 @@ H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf)
/*
* Check arguments.
*/
+ HDassert(f);
HDassert(leaf);
+ HDassert(leaf->hdr);
/* If we're going to free the space on disk, the address must be valid */
HDassert(!leaf->cache_info.free_file_space_on_destroy || H5F_addr_defined(leaf->cache_info.addr));
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
- HDassert(shared);
-
/* Check for freeing file space for B-tree leaf node */
if(leaf->cache_info.free_file_space_on_destroy) {
/* Release the space on disk */
/* (XXX: Nasty usage of internal DXPL value! -QAK) */
- if(H5MF_xfree(f, H5FD_MEM_BTREE, H5AC_dxpl_id, leaf->cache_info.addr, (hsize_t)shared->node_size) < 0)
+ if(H5MF_xfree(f, H5FD_MEM_BTREE, H5AC_dxpl_id, leaf->cache_info.addr, (hsize_t)leaf->hdr->node_size) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree leaf node")
} /* end if */
+ /* Set the B-tree header's file context for this operation */
+ leaf->hdr->f = f;
+
/* Release leaf's native key buffer */
if(leaf->leaf_native)
- H5FL_FAC_FREE(shared->node_info[0].nat_rec_fac, leaf->leaf_native);
+ H5FL_FAC_FREE(leaf->hdr->node_info[0].nat_rec_fac, leaf->leaf_native);
- /* Decrement reference count on shared B-tree info */
- if(leaf->shared)
- H5RC_DEC(leaf->shared);
+ /* Decrement ref. count on B-tree header */
+ if(H5B2_hdr_decr(leaf->hdr) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header")
/* Free B-tree leaf node info */
- (void)H5FL_FREE(H5B2_leaf_t, leaf);
+ leaf = H5FL_FREE(H5B2_leaf_t, leaf);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1167,20 +1142,15 @@ done:
static herr_t
H5B2_cache_leaf_size(const H5F_t UNUSED *f, const H5B2_leaf_t *leaf, size_t *size_ptr)
{
- H5B2_shared_t *shared; /* Shared B-tree information */
-
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_leaf_size)
/* check arguments */
HDassert(leaf);
+ HDassert(leaf->hdr);
HDassert(size_ptr);
- /* Get the pointer to the shared B-tree info */
- shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared);
- HDassert(shared);
-
/* Set size value */
- *size_ptr = shared->node_size;
+ *size_ptr = leaf->hdr->node_size;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5B2_cache_leaf_size() */