summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-04-06 20:19:02 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-04-06 20:19:02 (GMT)
commiteeb841b26bdd371f2e3ae506af6390828205691a (patch)
tree2d385486eb48397020489d16c8eec34cd0231f39 /src
parentc0d7b109c9ee0c2c3e150e17bc265324c79818a9 (diff)
downloadhdf5-eeb841b26bdd371f2e3ae506af6390828205691a.zip
hdf5-eeb841b26bdd371f2e3ae506af6390828205691a.tar.gz
hdf5-eeb841b26bdd371f2e3ae506af6390828205691a.tar.bz2
[svn-r18521] Description:
Bring r18520 from trunk to 1.8 branch: Bring r18519 from metadata journaling "merging" branch to trunk: Converge metadata_journaling branch and trunk: separate destroy routines for data structures from cache callbacks. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode (h5committested on trunk)
Diffstat (limited to 'src')
-rw-r--r--src/H5HL.c23
-rw-r--r--src/H5HLcache.c14
-rwxr-xr-xsrc/H5SM.c57
-rw-r--r--src/H5SMcache.c22
-rwxr-xr-xsrc/H5SMpkg.h4
5 files changed, 83 insertions, 37 deletions
diff --git a/src/H5HL.c b/src/H5HL.c
index f7c1f22..5899ccc 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -130,9 +130,9 @@ H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/)
size_hint = H5HL_SIZEOF_FREE(f);
size_hint = H5HL_ALIGN(size_hint);
- /* Allocate memory structure */
+ /* Allocate new heap structure */
if(NULL == (heap = H5HL_new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f))))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate new heap struct")
/* Allocate file space */
total_size = heap->prfx_size + size_hint;
@@ -1098,25 +1098,6 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
} /* end if */
} /* end if */
- /* Check if the heap is contiguous on disk */
- if(heap->single_cache_obj) {
- /* Free the contiguous local heap in one call */
- H5_CHECK_OVERFLOW(heap->prfx_size + heap->dblk_size, size_t, hsize_t);
- if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, addr, (hsize_t)(heap->prfx_size + heap->dblk_size)) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free contiguous local heap")
- } /* end if */
- else {
- /* Free the local heap's prefix */
- H5_CHECK_OVERFLOW(heap->prfx_size, size_t, hsize_t);
- if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->prfx_addr, (hsize_t)heap->prfx_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap header")
-
- /* Free the local heap's data block */
- H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t);
- if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->dblk_addr, (hsize_t)heap->dblk_size) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data")
- } /* end else */
-
/* Set the flags for releasing the prefix and data block */
cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG;
diff --git a/src/H5HLcache.c b/src/H5HLcache.c
index 2063780..b224343 100644
--- a/src/H5HLcache.c
+++ b/src/H5HLcache.c
@@ -453,7 +453,7 @@ H5HL_prefix_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Should we destroy the memory version? */
if(destroy)
- if(H5HL_prfx_dest(prfx) < 0)
+ if(H5HL_prefix_dest(f, prfx) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix")
done:
@@ -479,7 +479,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HL_prefix_dest(H5F_t UNUSED *f, void *thing)
+H5HL_prefix_dest(H5F_t *f, void *thing)
{
H5HL_prfx_t *prfx = (H5HL_prfx_t *)thing; /* Local heap prefix to destroy */
herr_t ret_value = SUCCEED; /* Return value */
@@ -549,7 +549,7 @@ H5HL_prefix_clear(H5F_t UNUSED *f, void *thing, hbool_t destroy)
prfx->cache_info.is_dirty = FALSE;
if(destroy)
- if(H5HL_prfx_dest(prfx) < 0)
+ if(H5HL_prefix_dest(f, prfx) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix")
done:
@@ -706,7 +706,7 @@ H5HL_datablock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Should we destroy the memory version? */
if(destroy)
- if(H5HL_dblk_dest(dblk) < 0)
+ if(H5HL_datablock_dest(f, dblk) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block")
done:
@@ -728,7 +728,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HL_datablock_dest(H5F_t UNUSED *f, void *_thing)
+H5HL_datablock_dest(H5F_t *f, void *_thing)
{
H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */
herr_t ret_value = SUCCEED; /* Return value */
@@ -778,7 +778,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HL_datablock_clear(H5F_t UNUSED *f, void *_thing, hbool_t destroy)
+H5HL_datablock_clear(H5F_t *f, void *_thing, hbool_t destroy)
{
H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */
herr_t ret_value = SUCCEED; /* Return value */
@@ -792,7 +792,7 @@ H5HL_datablock_clear(H5F_t UNUSED *f, void *_thing, hbool_t destroy)
dblk->cache_info.is_dirty = FALSE;
if(destroy)
- if(H5HL_dblk_dest(dblk) < 0)
+ if(H5HL_datablock_dest(f, dblk) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block")
done:
diff --git a/src/H5SM.c b/src/H5SM.c
index f731df8..d5d0140 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -2291,6 +2291,63 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5SM_table_free
+ *
+ * Purpose: Frees memory used by the SOHM table.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: James Laird
+ * November 6, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5SM_table_free(H5SM_master_table_t *table)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_table_free)
+
+ /* Sanity check */
+ HDassert(table);
+ HDassert(table->indexes);
+
+ H5FL_ARR_FREE(H5SM_index_header_t, table->indexes);
+
+ H5FL_FREE(H5SM_master_table_t, table);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5SM_table_free() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5SM_list_free
+ *
+ * Purpose: Frees all memory used by the list.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: James Laird
+ * November 6, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5SM_list_free(H5SM_list_t *list)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_list_free)
+
+ HDassert(list);
+ HDassert(list->messages);
+
+ H5FL_ARR_FREE(H5SM_sohm_t, list->messages);
+
+ H5FL_FREE(H5SM_list_t, list);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5SM_list_free() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5SM_table_debug
*
* Purpose: Print debugging information for the master table.
diff --git a/src/H5SMcache.c b/src/H5SMcache.c
index 0136a5c..f675287 100644
--- a/src/H5SMcache.c
+++ b/src/H5SMcache.c
@@ -231,7 +231,8 @@ done:
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_SOHM, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
if(!ret_value && table)
- (void)H5SM_table_dest(f, table);
+ if(H5SM_table_free(table) < 0)
+ HDONE_ERROR(H5E_SOHM, H5E_CANTFREE, NULL, "unable to destroy sohm table")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_table_load() */
@@ -364,17 +365,20 @@ done:
static herr_t
H5SM_table_dest(H5F_t UNUSED *f, H5SM_master_table_t* table)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_table_dest)
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5SM_table_dest)
/* Sanity check */
HDassert(table);
HDassert(table->indexes);
- H5FL_ARR_FREE(H5SM_index_header_t, table->indexes);
+ /* Destroy Shared Object Header Message table */
+ if(H5SM_table_free(table) < 0)
+ HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message table")
- (void)H5FL_FREE(H5SM_master_table_t, table);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_table_dest() */
@@ -679,9 +683,9 @@ H5SM_list_dest(H5F_t *f, H5SM_list_t* list)
HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "unable to free shared message list")
} /* end if */
- /* Release resources */
- H5FL_ARR_FREE(H5SM_sohm_t, list->messages);
- (void)H5FL_FREE(H5SM_list_t, list);
+ /* Destroy Shared Object Header Message list */
+ if(H5SM_list_free(list) < 0)
+ HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message list")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h
index 64f0ccb..b023c97 100755
--- a/src/H5SMpkg.h
+++ b/src/H5SMpkg.h
@@ -251,6 +251,10 @@ H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data);
/* Fractal heap 'op' callback to compute hash value for message "in place" */
H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata);
+/* Routines to release data structures */
+herr_t H5SM_table_free(H5SM_master_table_t *table);
+herr_t H5SM_list_free(H5SM_list_t *list);
+
/* Testing functions */
#ifdef H5SM_TESTING
H5_DLL herr_t H5SM_get_mesg_count_test(H5F_t *f, hid_t dxpl_id, unsigned type_id,