From fa279bfcb7bb294e5e2611453e2b778f76752844 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 6 Apr 2010 17:01:24 -0500 Subject: [svn-r18526] Description: Bring r18525 from trunk to 1.8 branch: Bring r18523 from metadata journaling "merging" branch to trunk: Bring metadata journaling branch into closer correspondence with trunk: extract data structure freeing routines from metadata cache client 'destroy' callbacks. Tested on: FreeBSD/32 6.3 (duty) in debug mode (h5committested on trunk) --- src/H5O.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/H5Ocache.c | 64 ++++++++++++-------------------------------------------- src/H5Ocopy.c | 2 +- src/H5Opkg.h | 4 +--- 4 files changed, 80 insertions(+), 56 deletions(-) diff --git a/src/H5O.c b/src/H5O.c index 402e7ee..609d9ad 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1243,7 +1243,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, done: if(ret_value < 0 && oh) - if(H5O_dest(f, oh) < 0) + if(H5O_free(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) @@ -3058,3 +3058,67 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_visit() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_free + * + * Purpose: Destroys an object header. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Jan 15 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_free(H5O_t *oh) +{ + unsigned u; /* Local index variable */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_free) + + /* check args */ + HDassert(oh); + + /* Destroy chunks */ + if(oh->chunk) { + for(u = 0; u < oh->nchunks; u++) { + /* Verify that chunk is clean */ + HDassert(oh->chunk[u].dirty == 0); + + oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image); + } /* end for */ + + oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk); + } /* end if */ + + /* Destroy messages */ + if(oh->mesg) { + for(u = 0; u < oh->nmesgs; u++) { +#ifndef NDEBUG + /* Verify that message is clean, unless it could have been marked + * dirty by decoding */ + if(oh->ndecode_dirtied && oh->mesg[u].dirty) + oh->ndecode_dirtied--; + else + HDassert(oh->mesg[u].dirty == 0); +#endif /* NDEBUG */ + + H5O_msg_free_mesg(&oh->mesg[u]); + } /* end for */ + + /* Make sure we accounted for all the messages dirtied by decoding */ + HDassert(!oh->ndecode_dirtied); + + oh->mesg = (H5O_mesg_t *)H5FL_SEQ_FREE(H5O_mesg_t, oh->mesg); + } /* end if */ + + /* destroy object header */ + oh = H5FL_FREE(H5O_t, oh); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_free() */ + diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 0bcf37d..d3e736e 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -70,6 +70,7 @@ static H5O_t *H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata1, void *_udata2); static herr_t H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh, unsigned UNUSED * flags_ptr); +static herr_t H5O_dest(H5F_t *f, H5O_t *oh); static herr_t H5O_clear(H5F_t *f, H5O_t *oh, hbool_t destroy); static herr_t H5O_size(const H5F_t *f, const H5O_t *oh, size_t *size_ptr); @@ -627,7 +628,7 @@ H5O_assert(oh); done: /* Release the [possibly partially initialized] object header on errors */ if(!ret_value && oh) - if(H5O_dest(f, oh) < 0) + if(H5O_free(oh) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) @@ -813,7 +814,7 @@ H5O_assert(oh); /* Destroy the object header, if requested */ if(destroy) - if(H5O_dest(f,oh) < 0) + if(H5O_dest(f, oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") done: @@ -834,17 +835,12 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5O_dest(H5F_t *f, H5O_t *oh) { - unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dest) -#ifdef QAK -HDfprintf(stderr, "%s: oh->cache_info.addr = %a\n", FUNC, oh->cache_info.addr); -HDfprintf(stderr, "%s: oh->cache_info.free_file_space_on_destroy = %t\n", FUNC, oh->cache_info.free_file_space_on_destroy); -#endif /* QAK */ /* check args */ HDassert(oh); @@ -855,51 +851,17 @@ HDfprintf(stderr, "%s: oh->cache_info.free_file_space_on_destroy = %t\n", FUNC, /* If we're going to free the space on disk, the address must be valid */ HDassert(!oh->cache_info.free_file_space_on_destroy || H5F_addr_defined(oh->cache_info.addr)); - /* destroy chunks */ - if(oh->chunk) { - /* Check for releasing file space for object header */ - if(oh->cache_info.free_file_space_on_destroy) { - /* Free main (first) object header "chunk" */ - /* (XXX: Nasty usage of internal DXPL value! -QAK) */ - if(H5MF_xfree(f, H5FD_MEM_OHDR, H5AC_dxpl_id, oh->chunk[0].addr, (hsize_t)oh->chunk[0].size) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header") - } /* end if */ - - /* Release buffer for each chunk */ - for(u = 0; u < oh->nchunks; u++) { - /* Verify that chunk is clean */ - HDassert(oh->chunk[u].dirty == 0); - - oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image); - } /* end for */ - - /* Release array of chunk info */ - oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk); - } /* end if */ - - /* destroy messages */ - if(oh->mesg) { - for(u = 0; u < oh->nmesgs; u++) { - /* Verify that message is clean, unless it could have been marked - * dirty by decoding */ -#ifndef NDEBUG - if(oh->ndecode_dirtied && oh->mesg[u].dirty) - oh->ndecode_dirtied--; - else - HDassert(oh->mesg[u].dirty == 0); -#endif /* NDEBUG */ - - H5O_msg_free_mesg(&oh->mesg[u]); - } /* end for */ - - /* Make sure we accounted for all the messages dirtied by decoding */ - HDassert(!oh->ndecode_dirtied); - - oh->mesg = (H5O_mesg_t *)H5FL_SEQ_FREE(H5O_mesg_t, oh->mesg); + /* Check for releasing file space for object header */ + if(oh->chunk && oh->cache_info.free_file_space_on_destroy) { + /* Free main (first) object header "chunk" */ + /* (XXX: Nasty usage of internal DXPL value! -QAK) */ + if(H5MF_xfree(f, H5FD_MEM_OHDR, H5AC_dxpl_id, oh->chunk[0].addr, (hsize_t)oh->chunk[0].size) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header") } /* end if */ - /* destroy object header */ - (void)H5FL_FREE(H5O_t, oh); + /* Destroy object header */ + if(H5O_free(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index da91782..f9bf533 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -736,7 +736,7 @@ done: HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") /* Release pointer to destination object header */ - if(ret_value < 0 && oh_dst && H5O_dest(oloc_dst->file, oh_dst) < 0) + if(ret_value < 0 && oh_dst && H5O_free(oh_dst) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") /* Release user data for particular type of object to copy */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 262a7dc..25cea5a 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -474,6 +474,7 @@ H5_DLL herr_t H5O_flush_msgs(H5F_t *f, H5O_t *oh); H5_DLL hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref); H5_DLL herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, H5O_mesg_t *mesg); H5_DLL const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); +H5_DLL herr_t H5O_free(H5O_t *oh); /* Object header message routines */ H5_DLL unsigned H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, @@ -534,9 +535,6 @@ H5_DLL herr_t H5O_attr_count_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, /* These functions operate on object locations */ H5_DLL H5O_loc_t *H5O_get_loc(hid_t id); -/* Useful metadata cache callbacks */ -H5_DLL herr_t H5O_dest(H5F_t *f, H5O_t *oh); - /* Testing functions */ #ifdef H5O_TESTING H5_DLL htri_t H5O_is_attr_empty_test(hid_t oid); -- cgit v0.12