summaryrefslogtreecommitdiffstats
path: root/src/H5Gcache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-05-27 20:27:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-05-27 20:27:13 (GMT)
commit9f90e06bd0b400f5b5d9631eb680c00da3199894 (patch)
treea707a89c16689e8dee5eb927ffacd7ec5a7de91d /src/H5Gcache.c
parent2f5164b1047a705e81fff46f1b8107426cbcc61b (diff)
downloadhdf5-9f90e06bd0b400f5b5d9631eb680c00da3199894.zip
hdf5-9f90e06bd0b400f5b5d9631eb680c00da3199894.tar.gz
hdf5-9f90e06bd0b400f5b5d9631eb680c00da3199894.tar.bz2
[svn-r18917] Description:
Bring r18911 (plus some adaptions to match the code on the trunk) from the metadata journaling "merging" branch to the trunk: More general changes to align trunk with eventual changes from metadata journaling 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.3 (amazon) in debug mode Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5Gcache.c')
-rw-r--r--src/H5Gcache.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/H5Gcache.c b/src/H5Gcache.c
index 98052e1..ff758c4 100644
--- a/src/H5Gcache.c
+++ b/src/H5Gcache.c
@@ -124,7 +124,6 @@ static H5G_node_t *
H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
{
H5G_node_t *sym = NULL;
- size_t size;
H5WB_t *wb = NULL; /* Wrapped buffer for node data */
uint8_t node_buf[H5G_NODE_BUF_SIZE]; /* Buffer for node */
uint8_t *node; /* Pointer to node buffer */
@@ -144,19 +143,23 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
* Initialize variables.
*/
+ /* Allocate symbol table data structures */
+ if(NULL == (sym = H5FL_CALLOC(H5G_node_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ sym->node_size = H5G_NODE_SIZE(f);
+ if(NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f)))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+
/* Wrap the local buffer for serialized node info */
if(NULL == (wb = H5WB_wrap(node_buf, sizeof(node_buf))))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't wrap buffer")
- /* Compute the size of the serialized symbol table node on disk */
- size = H5G_node_size_real(f);
-
/* Get a pointer to a buffer that's large enough for node */
- if(NULL == (node = (uint8_t *)H5WB_actual(wb, size)))
+ if(NULL == (node = (uint8_t *)H5WB_actual(wb, sym->node_size)))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't get actual buffer")
/* Read the serialized symbol table node. */
- if(H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, node) < 0)
+ if(H5F_block_read(f, H5FD_MEM_BTREE, addr, sym->node_size, dxpl_id, node) < 0)
HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unable to read symbol table node")
/* Get temporary pointer to serialized node */
@@ -174,12 +177,6 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
/* reserved */
p++;
- /* Allocate symbol table data structures */
- if(NULL == (sym = H5FL_CALLOC(H5G_node_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- if(NULL == (sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t, (size_t)(2 * H5F_SYM_LEAF_K(f)))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
-
/* number of symbols */
UINT16DECODE(p, sym->nsyms);
@@ -237,17 +234,13 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_
if(sym->cache_info.is_dirty) {
uint8_t *node; /* Pointer to node buffer */
uint8_t *p; /* Pointer into raw data buffer */
- size_t size;
/* Wrap the local buffer for serialized node info */
if(NULL == (wb = H5WB_wrap(node_buf, sizeof(node_buf))))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't wrap buffer")
- /* Compute the size of the serialized symbol table node on disk */
- size = H5G_node_size_real(f);
-
/* Get a pointer to a buffer that's large enough for node */
- if(NULL == (node = (uint8_t *)H5WB_actual(wb, size)))
+ if(NULL == (node = (uint8_t *)H5WB_actual(wb, sym->node_size)))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't get actual buffer")
/* Get temporary pointer to serialized symbol table node */
@@ -269,10 +262,10 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_
/* entries */
if(H5G_ent_encode_vec(f, &p, sym->entry, sym->nsyms) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't serialize")
- HDmemset(p, 0, size - (size_t)(p - node));
+ HDmemset(p, 0, sym->node_size - (size_t)(p - node));
/* Write the serialized symbol table node. */
- if(H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, node) < 0)
+ if(H5F_block_write(f, H5FD_MEM_BTREE, addr, sym->node_size, dxpl_id, node) < 0)
HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "unable to write symbol table node to the file")
/* Reset the node's dirty flag */
@@ -332,7 +325,7 @@ H5G_node_dest(H5F_t *f, H5G_node_t *sym)
if(sym->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, sym->cache_info.addr, (hsize_t)H5G_node_size_real(f)) < 0)
+ if(H5MF_xfree(f, H5FD_MEM_BTREE, H5AC_dxpl_id, sym->cache_info.addr, (hsize_t)sym->node_size) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to free symbol table node")
} /* end if */
@@ -401,7 +394,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_size(const H5F_t *f, const H5G_node_t UNUSED *sym, size_t *size_ptr)
+H5G_node_size(const H5F_t UNUSED *f, const H5G_node_t *sym, size_t *size_ptr)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_size)
@@ -411,7 +404,7 @@ H5G_node_size(const H5F_t *f, const H5G_node_t UNUSED *sym, size_t *size_ptr)
HDassert(f);
HDassert(size_ptr);
- *size_ptr = H5G_node_size_real(f);
+ *size_ptr = sym->node_size;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5G_node_size() */