summaryrefslogtreecommitdiffstats
path: root/src/H5FScache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-04-02 01:48:23 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-04-02 01:48:23 (GMT)
commitbacf7149e948c6c33401a9ecb0ad16e60805a9a2 (patch)
tree8e4a2b205b7bbed025d6b58066f55a8e21c920d4 /src/H5FScache.c
parent2b8896eea1636e62ee6cbdd8bc6344b18c704566 (diff)
downloadhdf5-bacf7149e948c6c33401a9ecb0ad16e60805a9a2.zip
hdf5-bacf7149e948c6c33401a9ecb0ad16e60805a9a2.tar.gz
hdf5-bacf7149e948c6c33401a9ecb0ad16e60805a9a2.tar.bz2
[svn-r18495] Description:
Bring r18494 from trunk to 1.8 branch: Bring r18491 from metadata journaling "merging" branch to trunk: Extract data structure 'destroy' routines from metadata cache client 'destroy' callbacks. Tested on: FreeBSD/32 6.3 (duty) w/debug (h5committested on trunk)
Diffstat (limited to 'src/H5FScache.c')
-rw-r--r--src/H5FScache.c152
1 files changed, 21 insertions, 131 deletions
diff --git a/src/H5FScache.c b/src/H5FScache.c
index 000a462..9e5f2b9 100644
--- a/src/H5FScache.c
+++ b/src/H5FScache.c
@@ -74,18 +74,18 @@ typedef struct {
/********************/
/* Section info routines */
-static herr_t H5FS_sinfo_free_sect_cb(void *item, void *key, void *op_data);
-static herr_t H5FS_sinfo_free_node_cb(void *item, void *key, void *op_data);
static herr_t H5FS_sinfo_serialize_sect_cb(void *_item, void UNUSED *key, void *_udata);
static herr_t H5FS_sinfo_serialize_node_cb(void *_item, void UNUSED *key, void *_udata);
/* Metadata cache callbacks */
static H5FS_t *H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
static herr_t H5FS_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FS_t *fspace, unsigned UNUSED * flags_ptr);
+static herr_t H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *fspace);
static herr_t H5FS_cache_hdr_clear(H5F_t *f, H5FS_t *fspace, hbool_t destroy);
static herr_t H5FS_cache_hdr_size(const H5F_t *f, const H5FS_t *fspace, size_t *size_ptr);
static H5FS_sinfo_t *H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
static herr_t H5FS_cache_sinfo_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5FS_sinfo_t *sinfo, unsigned UNUSED * flags_ptr);
+static herr_t H5FS_cache_sinfo_dest(H5F_t *f, H5FS_sinfo_t *sinfo);
static herr_t H5FS_cache_sinfo_clear(H5F_t *f, H5FS_sinfo_t *sinfo, hbool_t destroy);
static herr_t H5FS_cache_sinfo_size(const H5F_t *f, const H5FS_sinfo_t *sinfo, size_t *size_ptr);
@@ -252,7 +252,7 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_fs_prot,
/* Verify checksum */
if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block")
+ HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block")
/* Set return value */
ret_value = fspace;
@@ -262,7 +262,8 @@ done:
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_FSPACE, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
if(!ret_value && fspace)
- (void)H5FS_cache_hdr_dest(f, fspace);
+ if(H5FS_hdr_dest(fspace) < 0)
+ HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */
@@ -449,17 +450,14 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
+static herr_t
H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *fspace)
{
- unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_hdr_dest)
- /*
- * Check arguments.
- */
+ /* Check arguments */
HDassert(fspace);
/* We should not still be holding on to the free space section info */
@@ -468,14 +466,6 @@ H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *fspace)
/* If we're going to free the space on disk, the address must be valid */
HDassert(!fspace->cache_info.free_file_space_on_destroy || H5F_addr_defined(fspace->cache_info.addr));
- /* Terminate the section classes for this free space list */
- for(u = 0; u < fspace->nclasses ; u++) {
- /* Call the class termination routine, if there is one */
- if(fspace->sect_cls[u].term_cls)
- if((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "unable to finalize section class")
- } /* end for */
-
/* Check for freeing file space for free space header */
if(fspace->cache_info.free_file_space_on_destroy) {
/* Sanity check */
@@ -487,12 +477,9 @@ H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *fspace)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space header")
} /* end if */
- /* Release the memory for the free space section classes */
- if(fspace->sect_cls)
- fspace->sect_cls = (H5FS_section_class_t *)H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls);
-
- /* Free free space info */
- (void)H5FL_FREE(H5FS_t, fspace);
+ /* Destroy free space header */
+ if(H5FS_hdr_dest(fspace) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -717,7 +704,7 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *
/* Verify checksum */
if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block")
+ HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block")
/* Sanity check */
HDassert((size_t)(p - (const uint8_t *)buf) == old_sect_size);
@@ -727,9 +714,10 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *
done:
if(buf)
- (void)H5FL_BLK_FREE(sect_block, buf);
+ buf = H5FL_BLK_FREE(sect_block, buf);
if(!ret_value && sinfo)
- (void)H5FS_cache_sinfo_dest(f, sinfo);
+ if(H5FS_sinfo_dest(sinfo) < 0)
+ HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space section info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS_cache_sinfo_load() */ /*lint !e818 Can't make udata a pointer to const */
@@ -920,7 +908,7 @@ H5FS_cache_sinfo_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H
if(H5F_block_write(f, H5FD_MEM_FSPACE_SINFO, sinfo->fspace->sect_addr, (size_t)sinfo->fspace->sect_size, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFLUSH, FAIL, "unable to save free space sections to disk")
- (void)H5FL_BLK_FREE(sect_block, buf);
+ buf = H5FL_BLK_FREE(sect_block, buf);
sinfo->cache_info.is_dirty = FALSE;
sinfo->dirty = FALSE;
@@ -936,76 +924,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_free_sect_cb
- *
- * Purpose: Free a size-tracking node for a bin
- *
- * Return: Success: non-negative
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Saturday, March 11, 2006
- *
- * Modifications:
- * Vailin Choi, July 29th, 2008
- * Add HDassert() to make sure "free" method exists before calling
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FS_sinfo_free_sect_cb(void *_sect, void UNUSED *key, void *op_data)
-{
- H5FS_section_info_t *sect = (H5FS_section_info_t *)_sect; /* Section to free */
- const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)op_data; /* Free space manager for section */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_sinfo_free_sect_cb)
-
- HDassert(sect);
- HDassert(sinfo);
- HDassert(sinfo->fspace->sect_cls[sect->type].free);
-
- /* Call the section's class 'free' method on the section */
- (*sinfo->fspace->sect_cls[sect->type].free)(sect);
-
- FUNC_LEAVE_NOAPI(0)
-} /* H5FS_sinfo_free_sect_cb() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FS_sinfo_free_node_cb
- *
- * Purpose: Free a size-tracking node for a bin
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Saturday, March 11, 2006
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FS_sinfo_free_node_cb(void *item, void UNUSED *key, void *op_data)
-{
- H5FS_node_t *fspace_node = (H5FS_node_t *)item; /* Temporary pointer to free space list node */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_sinfo_free_node_cb)
-
- HDassert(fspace_node);
- HDassert(op_data);
-
- /* Release the skip list for sections of this size */
- H5SL_destroy(fspace_node->sect_list, H5FS_sinfo_free_sect_cb, op_data);
-
- /* Release free space list node */
- (void)H5FL_FREE(H5FS_node_t, fspace_node);
-
- FUNC_LEAVE_NOAPI(0)
-} /* H5FS_sinfo_free_node_cb() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5FS_cache_sinfo_dest
*
* Purpose: Destroys a free space section info in memory.
@@ -1018,20 +936,15 @@ H5FS_sinfo_free_node_cb(void *item, void UNUSED *key, void *op_data)
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5FS_cache_sinfo_dest(H5F_t UNUSED *f, H5FS_sinfo_t *sinfo)
+static herr_t
+H5FS_cache_sinfo_dest(H5F_t *f, H5FS_sinfo_t *sinfo)
{
- unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_sinfo_dest)
- /*
- * Check arguments.
- */
+ /* Check arguments */
HDassert(sinfo);
- HDassert(sinfo->fspace);
- HDassert(sinfo->bins);
/* If we're going to free the space on disk, the address must be valid */
HDassert(!sinfo->cache_info.free_file_space_on_destroy || H5F_addr_defined(sinfo->cache_info.addr));
@@ -1047,32 +960,9 @@ H5FS_cache_sinfo_dest(H5F_t UNUSED *f, H5FS_sinfo_t *sinfo)
HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to free free space section info")
} /* end if */
- /* Clear out lists of nodes */
- for(u = 0; u < sinfo->nbins; u++)
- if(sinfo->bins[u].bin_list) {
- H5SL_destroy(sinfo->bins[u].bin_list, H5FS_sinfo_free_node_cb, sinfo);
- sinfo->bins[u].bin_list = NULL;
- } /* end if */
-
- /* Release bins for skip lists */
- sinfo->bins = (H5FS_bin_t *)H5FL_SEQ_FREE(H5FS_bin_t, sinfo->bins);
-
- /* Release skip list for merging sections */
- if(sinfo->merge_list)
- if(H5SL_close(sinfo->merge_list) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "can't destroy section merging skip list")
-
- /* Decrement the reference count on free space header */
- /* (make certain this is last action with section info, to allow for header
- * disappearing immediately)
- */
- sinfo->fspace->sinfo = NULL;
- if(H5FS_decr(f, sinfo->fspace) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEC, FAIL, "unable to decrement ref. count on free space header")
- sinfo->fspace = NULL;
-
- /* Release free space section info */
- (void)H5FL_FREE(H5FS_sinfo_t, sinfo);
+ /* Destroy free space info */
+ if(H5FS_sinfo_dest(sinfo) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space info")
done:
FUNC_LEAVE_NOAPI(ret_value)