summaryrefslogtreecommitdiffstats
path: root/src/H5Bcache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-03-02 20:07:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-03-02 20:07:10 (GMT)
commit483185409e16ec83c24301e21bfdc92234506730 (patch)
treee97c85158440c18965ce515b90ff5139e75566b1 /src/H5Bcache.c
parenta074829c66d295ebd83b77aac9abc27ba4457e33 (diff)
downloadhdf5-483185409e16ec83c24301e21bfdc92234506730.zip
hdf5-483185409e16ec83c24301e21bfdc92234506730.tar.gz
hdf5-483185409e16ec83c24301e21bfdc92234506730.tar.bz2
[svn-r18357] Description:
Bring r18356 from metadata journaling merge branch to trunk: Converge metadata journaling branch with trunk with a bunch of v1 B-tree changes: - Remove H5ACprivate.h header from H5Bprivate.h header - Revise v1 B-tree client callbacks - Get rid of H5B_serialize() by bringing it into H5B_flush() 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 (amani) 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
Diffstat (limited to 'src/H5Bcache.c')
-rw-r--r--src/H5Bcache.c124
1 files changed, 45 insertions, 79 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c
index cc5bbbf..99cd0cd 100644
--- a/src/H5Bcache.c
+++ b/src/H5Bcache.c
@@ -54,9 +54,6 @@
/* 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);
@@ -86,78 +83,6 @@ const H5AC_class_t H5AC_BT[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5B_serialize
- *
- * Purpose: Serialize the data structure for writing to disk.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Bill Wendling
- * wendling@ncsa.uiuc.edu
- * Sept. 15, 2003
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5B_serialize(const H5F_t *f, const H5B_t *bt)
-{
- 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 */
-
- FUNC_ENTER_NOAPI(H5B_serialize, FAIL)
-
- /* check arguments */
- HDassert(f);
- HDassert(bt);
- HDassert(bt->rc_shared);
- shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
- HDassert(shared);
-
- p = shared->page;
-
- /* magic number */
- HDmemcpy(p, H5B_MAGIC, (size_t)H5_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);
-
- /* 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.
@@ -194,8 +119,12 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate B-tree struct")
HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t));
+ /* Set & increment the ref-counted "shared" B-tree information for the node */
if(NULL == (bt->rc_shared = (type->get_shared)(f, udata)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't retrieve B-tree node buffer")
+ H5RC_INC(bt->rc_shared);
+
+ /* Get a pointer to the shared info, for convenience */
shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
@@ -232,7 +161,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
native = bt->native;
for(u = 0; u < bt->nchildren; u++) {
/* Decode native key value */
- if((type->decode)(f, bt, p, native) < 0)
+ if((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;
@@ -244,7 +173,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
/* Decode final key */
if(bt->nchildren > 0) {
/* Decode native key value */
- if((type->decode)(f, bt, p, native) < 0)
+ if((type->decode)(shared, p, native) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, NULL, "unable to decode key")
} /* end if */
@@ -290,8 +219,45 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns
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")
+ uint8_t *p; /* Pointer into raw data buffer */
+ uint8_t *native; /* Pointer to native keys */
+ unsigned u; /* Local index variable */
+
+ p = shared->page;
+
+ /* magic number */
+ HDmemcpy(p, H5B_MAGIC, (size_t)H5_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);
+
+ /* 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;
+
+ /* 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(shared, p, native) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
+ } /* end if */
/*
* Write the disk page. We always write the header, but we don't