summaryrefslogtreecommitdiffstats
path: root/src/H5FScache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-04-02 01:38:53 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-04-02 01:38:53 (GMT)
commit63611c3aa26d64aeee583ef88316290c4a85c123 (patch)
treebd3d6aa7d589dca091d2b5d193a24a675b4ba61b /src/H5FScache.c
parentd891ae199770c15e2c841badfbd2a68fee54b638 (diff)
downloadhdf5-63611c3aa26d64aeee583ef88316290c4a85c123.zip
hdf5-63611c3aa26d64aeee583ef88316290c4a85c123.tar.gz
hdf5-63611c3aa26d64aeee583ef88316290c4a85c123.tar.bz2
[svn-r18494] Description:
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) 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 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/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 1761adf..b17a7f1 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);
@@ -254,7 +254,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;
@@ -264,7 +264,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 */
@@ -442,17 +443,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 */
@@ -461,14 +459,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 */
@@ -480,12 +470,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)
@@ -710,7 +697,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);
@@ -720,9 +707,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 */
@@ -913,7 +901,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;
@@ -929,76 +917,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.
@@ -1011,20 +929,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));
@@ -1040,32 +953,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)