diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-01-28 13:11:38 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-01-28 13:11:38 (GMT) |
commit | 3360c3af0c100ac4d3a2fe2865f34661da862ec5 (patch) | |
tree | 9caf7dba62679504aa39ec02ebb72d8b8b5a848d /src/H5Bcache.c | |
parent | 5b4d3279099e7e4fad6e0092c77aa93dfd35d616 (diff) | |
download | hdf5-3360c3af0c100ac4d3a2fe2865f34661da862ec5.zip hdf5-3360c3af0c100ac4d3a2fe2865f34661da862ec5.tar.gz hdf5-3360c3af0c100ac4d3a2fe2865f34661da862ec5.tar.bz2 |
[svn-r18175] Description:
Bring r17986:18172 from trunk to revise_chunks branch.
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.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 0424134..cc5bbbf 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 */ @@ -217,8 +225,8 @@ 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(f, (const uint8_t **)&p, &(bt->left)); + H5F_addr_decode(f, (const uint8_t **)&p, &(bt->right)); /* the child/key pairs */ native = bt->native; @@ -230,7 +238,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) native += type->sizeof_nkey; /* Decode address value */ - H5F_addr_decode(f, (const uint8_t **) &p, bt->child + u); + H5F_addr_decode(f, (const uint8_t **)&p, bt->child + u); } /* end for */ /* Decode final key */ @@ -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,33 +264,27 @@ 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 H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, unsigned UNUSED * flags_ptr) { - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + 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: |