diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-17 22:21:08 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-17 22:21:08 (GMT) |
commit | 1bc07c6aaeadd03d73216af25db0cb46db2391e0 (patch) | |
tree | 79cfb25eaad5e610b1c10f9a21b27ec9c07685b0 /src/H5Bcache.c | |
parent | df2fef9759940bf5d80e8aa5a8dcd1251d58d490 (diff) | |
parent | 77038a81755bd6c853323ba261c9c671800d7be7 (diff) | |
download | hdf5-1bc07c6aaeadd03d73216af25db0cb46db2391e0.zip hdf5-1bc07c6aaeadd03d73216af25db0cb46db2391e0.tar.gz hdf5-1bc07c6aaeadd03d73216af25db0cb46db2391e0.tar.bz2 |
[svn-r18031] Description:
Bring r18030 from merge_metadata_journaling branch to trunk:
Bring "brush clearing" changes (whitespace & style issues, mostly) from
metadata_journaling branch to the "merging" branch, to converge the trunk and
the metadata_journaling branch.
Also, some other minor cleanups along the way.
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/H5Bcache.c')
-rw-r--r-- | src/H5Bcache.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 0424134..dc60f9d 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -39,14 +39,17 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5MFprivate.h" /* File memory management */ + /****************/ /* Local Macros */ /****************/ + /******************/ /* Local Typedefs */ /******************/ + /********************/ /* Local Prototypes */ /********************/ @@ -60,6 +63,7 @@ static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, 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); + /*********************/ /* Package Variables */ /*********************/ @@ -79,14 +83,14 @@ const H5AC_class_t H5AC_BT[1] = {{ /* Local Variables */ /*******************/ + /*------------------------------------------------------------------------- * Function: H5B_serialize * * Purpose: Serialize the data structure for writing to disk. * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Non-negative on success/Negative on failure * * Programmer: Bill Wendling * wendling@ncsa.uiuc.edu @@ -159,7 +163,6 @@ done: * Purpose: Loads a B-tree node from the disk. * * Return: Success: Pointer to a new B-tree node. - * * Failure: NULL * * Programmer: Robb Matzke @@ -173,13 +176,13 @@ 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; + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + const uint8_t *p; /* Pointer into raw data buffer */ + uint8_t *native; /* Pointer to native keys */ + unsigned u; /* Local index variable */ + H5B_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5B_load, NULL) + FUNC_ENTER_NOAPI_NOINIT(H5B_load) /* Check arguments */ HDassert(f); @@ -188,19 +191,24 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) 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(NULL == (bt->rc_shared=(type->get_shared)(f, udata))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate B-tree struct") + HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t)); + + if(NULL == (bt->rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't retrieve B-tree node buffer") 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) + /* 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_CANTALLOC, 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_CANTALLOC, NULL, "can't allocate buffer for child addresses") + + 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") + /* Set the pointer into the raw data buffer */ p = shared->page; /* magic number */ @@ -246,6 +254,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) done: if(!ret_value && bt) (void)H5B_dest(f, bt); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -255,18 +264,12 @@ done: * * Purpose: Flushes a dirty B-tree node to disk. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Jun 23 1997 * - * 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 @@ -275,13 +278,13 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns H5B_shared_t *shared; /* Pointer to shared B-tree info */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5B_flush, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5B_flush) /* check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(bt); - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); HDassert(shared->type); HDassert(shared->type->encode); @@ -302,7 +305,7 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, uns } /* end if */ if(destroy) - if(H5B_dest(f,bt) < 0) + if(H5B_dest(f, bt) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: |