diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-08 15:30:10 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-08 15:30:10 (GMT) |
commit | 13d61651f8bfba0739aac1cad17d4b11affb59ae (patch) | |
tree | 78dd33346cc19aa02ade365659e2ba37b62c0d17 | |
parent | 42efc1c2b591e4cd45ec6cb3bdf32044343118d2 (diff) | |
download | hdf5-13d61651f8bfba0739aac1cad17d4b11affb59ae.zip hdf5-13d61651f8bfba0739aac1cad17d4b11affb59ae.tar.gz hdf5-13d61651f8bfba0739aac1cad17d4b11affb59ae.tar.bz2 |
[svn-r18534] Description:
Bring r18446:18533 from trunk to revise_chunks 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-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
98 files changed, 2765 insertions, 1690 deletions
@@ -1631,6 +1631,7 @@ ./tools/h5repack/testfiles/ublock.bin ./tools/h5repack/testfiles/h5repack_named_dtypes.h5 ./tools/h5repack/testfiles/h5repack_refs.h5 +./tools/h5repack/testfiles/h5repack_attr_refs.h5 # jam utility and tests ./tools/h5jam/h5jam.c @@ -1,4 +1,4 @@ -HDF5 version 1.9.64-FA_a4 currently under development +HDF5 version 1.9.66-FA_a4 currently under development Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index 12fb36a..a76a9ef 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -390,7 +390,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 54 +LT_VERS_REVISION = 56 LT_VERS_AGE = 0 # Include src directory diff --git a/config/ibm-aix b/config/ibm-aix index 2336040..954dc7f 100644 --- a/config/ibm-aix +++ b/config/ibm-aix @@ -91,7 +91,8 @@ ac_cv_sizeof_char=${ac_cv_sizeof_char=1} ac_cv_sizeof_short=${ac_cv_sizeof_short=2} ac_cv_sizeof_int=${ac_cv_sizeof_int=4} ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long=8} -ac_cv_sizeof___int64=${ac_cv_sizeof___int64=8} +# Do not cache __int64 since it is not a standard C type and some compilers +# (e.g., gcc) does not support it. ac_cv_sizeof_float=${ac_cv_sizeof_float=4} ac_cv_sizeof_double=${ac_cv_sizeof_double=8} ac_cv_sizeof_long_double=${ac_cv_sizeof_long_double=8} diff --git a/config/lt_vers.am b/config/lt_vers.am index 8586714..5096b76 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -17,7 +17,7 @@ # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 54 +LT_VERS_REVISION = 56 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Id: configure.in 18175 2010-01-28 14:11:38Z koziol . +# From configure.in Id: configure.in 18451 2010-03-25 03:51:41Z koziol . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for HDF5 1.9.64-FA_a4. +# Generated by GNU Autoconf 2.64 for HDF5 1.9.66-FA_a4. # # Report bugs to <help@hdfgroup.org>. # @@ -699,8 +699,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='HDF5' PACKAGE_TARNAME='hdf5' -PACKAGE_VERSION='1.9.64-FA_a4' -PACKAGE_STRING='HDF5 1.9.64-FA_a4' +PACKAGE_VERSION='1.9.66-FA_a4' +PACKAGE_STRING='HDF5 1.9.66-FA_a4' PACKAGE_BUGREPORT='help@hdfgroup.org' PACKAGE_URL='' @@ -1571,7 +1571,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HDF5 1.9.64-FA_a4 to adapt to many kinds of systems. +\`configure' configures HDF5 1.9.66-FA_a4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1641,7 +1641,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HDF5 1.9.64-FA_a4:";; + short | recursive ) echo "Configuration of HDF5 1.9.66-FA_a4:";; esac cat <<\_ACEOF @@ -1828,7 +1828,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HDF5 configure 1.9.64-FA_a4 +HDF5 configure 1.9.66-FA_a4 generated by GNU Autoconf 2.64 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2912,7 +2912,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HDF5 $as_me 1.9.64-FA_a4, which was +It was created by HDF5 $as_me 1.9.66-FA_a4, which was generated by GNU Autoconf 2.64. Invocation command line was $ $0 $@ @@ -3725,7 +3725,7 @@ fi # Define the identity of the package. PACKAGE='hdf5' - VERSION='1.9.64-FA_a4' + VERSION='1.9.66-FA_a4' cat >>confdefs.h <<_ACEOF @@ -28847,7 +28847,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HDF5 $as_me 1.9.64-FA_a4, which was +This file was extended by HDF5 $as_me 1.9.66-FA_a4, which was generated by GNU Autoconf 2.64. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -28911,7 +28911,7 @@ Report bugs to <help@hdfgroup.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -HDF5 config.status 1.9.64-FA_a4 +HDF5 config.status 1.9.66-FA_a4 configured by $0, generated by GNU Autoconf 2.64, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.in b/configure.in index ffb3ca3..d266f5d 100644 --- a/configure.in +++ b/configure.in @@ -26,7 +26,7 @@ dnl dnl NOTE: Don't forget to change the version number here when we do a dnl release!!! dnl -AC_INIT([HDF5], [1.9.64-FA_a4], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.66-FA_a4], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AM_CONFIG_HEADER([src/H5config.h]) diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in index d0122f2..f3226f5 100644 --- a/fortran/src/Makefile.in +++ b/fortran/src/Makefile.in @@ -424,7 +424,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 54 +LT_VERS_REVISION = 56 LT_VERS_AGE = 0 # Include src directory in both Fortran and C flags (C compiler is used diff --git a/hl/c++/src/Makefile.in b/hl/c++/src/Makefile.in index 101ab32..bd90cd2 100644 --- a/hl/c++/src/Makefile.in +++ b/hl/c++/src/Makefile.in @@ -380,7 +380,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 54 +LT_VERS_REVISION = 56 LT_VERS_AGE = 0 # Include src directory diff --git a/hl/fortran/src/Makefile.in b/hl/fortran/src/Makefile.in index 2bd5e27..c92f09f 100644 --- a/hl/fortran/src/Makefile.in +++ b/hl/fortran/src/Makefile.in @@ -389,7 +389,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 54 +LT_VERS_REVISION = 56 LT_VERS_AGE = 0 INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/hl/src -I$(top_builddir)/hl/src \ -I$(top_srcdir)/fortran/src -I$(top_builddir)/fortran/src diff --git a/hl/src/Makefile.in b/hl/src/Makefile.in index caed2ae..cac49d3 100644 --- a/hl/src/Makefile.in +++ b/hl/src/Makefile.in @@ -380,7 +380,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 54 +LT_VERS_REVISION = 56 LT_VERS_AGE = 0 # This library is our main target. diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index c8ec41b..84af92e 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.64-FA_a4 currently under development +HDF5 version 1.9.66-FA_a4 currently under development ================================================================================ @@ -22,7 +22,6 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5lib_settings.h" /* Library build setings */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ @@ -29,11 +29,11 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ -#include "H5Opkg.h" /* Object headers */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5SMprivate.h" /* Shared Object Header Messages */ @@ -395,7 +395,6 @@ H5AC_term_interface(void) H5AC_dxpl_id=(-1); H5AC_noblock_dxpl_id=(-1); H5AC_ind_dxpl_id=(-1); - #endif /* H5_HAVE_PARALLEL */ /* Reset interface initialization flag */ H5_interface_initialize_g = 0; @@ -620,40 +619,40 @@ H5AC_create(const H5F_t *f, if ( aux_ptr->mpi_rank == 0 ) { f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, - (H5AC_NTYPES - 1), - (const char **)H5AC_entry_type_names, - H5AC_check_if_write_permitted, - TRUE, - H5AC_log_flushed_entry, - (void *)aux_ptr); + H5AC__DEFAULT_MIN_CLEAN_SIZE, + (H5AC_NTYPES - 1), + (const char **)H5AC_entry_type_names, + H5AC_check_if_write_permitted, + TRUE, + H5AC_log_flushed_entry, + (void *)aux_ptr); } else { f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, - (H5AC_NTYPES - 1), - (const char **)H5AC_entry_type_names, - NULL, - FALSE, + H5AC__DEFAULT_MIN_CLEAN_SIZE, + (H5AC_NTYPES - 1), + (const char **)H5AC_entry_type_names, + NULL, + FALSE, #if 0 /* this is useful debugging code -- keep it for a while */ /* JRM */ - H5AC_log_flushed_entry_dummy, + H5AC_log_flushed_entry_dummy, #else /* JRM */ - NULL, + NULL, #endif /* JRM */ - (void *)aux_ptr); + (void *)aux_ptr); } } else { f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, - (H5AC_NTYPES - 1), - (const char **)H5AC_entry_type_names, - H5AC_check_if_write_permitted, - TRUE, - NULL, - NULL); + H5AC__DEFAULT_MIN_CLEAN_SIZE, + (H5AC_NTYPES - 1), + (const char **)H5AC_entry_type_names, + H5AC_check_if_write_permitted, + TRUE, + NULL, + NULL); } } else { #endif /* H5_HAVE_PARALLEL */ @@ -662,13 +661,13 @@ H5AC_create(const H5F_t *f, * -- JRM */ f->shared->cache = H5C_create(H5AC__DEFAULT_MAX_CACHE_SIZE, - H5AC__DEFAULT_MIN_CLEAN_SIZE, - (H5AC_NTYPES - 1), - (const char **)H5AC_entry_type_names, - H5AC_check_if_write_permitted, - TRUE, - NULL, - NULL); + H5AC__DEFAULT_MIN_CLEAN_SIZE, + (H5AC_NTYPES - 1), + (const char **)H5AC_entry_type_names, + H5AC_check_if_write_permitted, + TRUE, + NULL, + NULL); #ifdef H5_HAVE_PARALLEL } #endif /* H5_HAVE_PARALLEL */ @@ -830,12 +829,12 @@ H5AC_expunge_entry(H5F_t *f, haddr_t addr, unsigned flags) { - herr_t result; + herr_t result; #if H5AC__TRACE_FILE_ENABLED char trace[128] = ""; FILE * trace_file_ptr = NULL; #endif /* H5AC__TRACE_FILE_ENABLED */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_expunge_entry, FAIL) @@ -851,7 +850,6 @@ H5AC_expunge_entry(H5F_t *f, { H5AC_t * cache_ptr = f->shared->cache; - /* For the expunge entry call, only the addr, and type id are really * necessary in the trace file. Write the return value to catch occult * errors. @@ -860,7 +858,7 @@ H5AC_expunge_entry(H5F_t *f, ( H5C_get_trace_file_ptr(cache_ptr, &trace_file_ptr) >= 0 ) && ( trace_file_ptr != NULL ) ) { - sprintf(trace, "H5AC_expunge_entry %lx %d", + sprintf(trace, "H5AC_expunge_entry 0x%lx %d", (unsigned long)addr, (int)(type->id)); } @@ -926,6 +924,7 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id) FUNC_ENTER_NOAPI(H5AC_flush, FAIL) HDassert(f); + HDassert(f->shared); HDassert(f->shared->cache); #if H5AC__TRACE_FILE_ENABLED @@ -1058,9 +1057,6 @@ done: * exist on disk yet, but it must have an address and disk * space reserved. * - * If H5AC_DEBUG is defined then this function checks - * that the object being inserted isn't a protected object. - * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke @@ -1134,6 +1130,7 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, FUNC_ENTER_NOAPI(H5AC_set, FAIL) HDassert(f); + HDassert(f->shared); HDassert(f->shared->cache); HDassert(type); HDassert(type->flush); @@ -1156,7 +1153,7 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, if ( ( f != NULL ) && ( f->shared != NULL ) && ( f->shared->cache != NULL ) && - ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0) && ( trace_file_ptr != NULL ) ) { sprintf(trace, "H5AC_set 0x%lx %d 0x%x", @@ -1358,8 +1355,8 @@ H5AC_mark_pinned_or_protected_entry_dirty(void *thing) * occult errors. */ if((H5C_get_trace_file_ptr_from_entry(thing, &trace_file_ptr) >= 0) && - (NULL != trace_file_ptr)) - sprintf(trace, "%s %lx", FUNC, + (NULL != trace_file_ptr)) + sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); #endif /* H5AC__TRACE_FILE_ENABLED */ @@ -1372,7 +1369,7 @@ H5AC_mark_pinned_or_protected_entry_dirty(void *thing) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && - (entry_ptr->is_pinned) && (NULL != cache_ptr->aux_ptr)) { + (entry_ptr->is_pinned) && (NULL != cache_ptr->aux_ptr)) { if(H5AC_log_dirtied_entry(entry_ptr, entry_ptr->addr, FALSE, 0) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") } /* end if */ @@ -1398,10 +1395,6 @@ done: * Purpose: Use this function to notify the cache that an object's * file address changed. * - * If H5AC_DEBUG is defined then this function checks - * that the old and new addresses don't correspond to the - * address of a protected object. - * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke @@ -1467,10 +1460,10 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_ad if ( ( f != NULL ) && ( f->shared != NULL ) && ( f->shared->cache != NULL ) && - ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0) && ( trace_file_ptr != NULL ) ) { - sprintf(trace, "H5AC_rename %lx %lx %d", + sprintf(trace, "H5AC_rename 0x%lx 0x%lx %d", (unsigned long)old_addr, (unsigned long)new_addr, (int)(type->id)); @@ -1560,11 +1553,11 @@ H5AC_pin_protected_entry(void *thing) */ if((H5C_get_trace_file_ptr_from_entry(thing, &trace_file_ptr) >= 0) && (NULL != trace_file_ptr)) - sprintf(trace, "%s %lx", FUNC, + sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); #endif /* H5AC__TRACE_FILE_ENABLED */ - if(H5C_pin_protected_entry(thing) < 0 ) + if(H5C_pin_protected_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "can't pin entry") done: @@ -1657,9 +1650,6 @@ done: * The caller must call H5AC_unprotect() when finished with * the pointer. * - * If H5AC_DEBUG is defined then we check that the - * requested object isn't already protected. - * * Return: Success: Ptr to the object. * * Failure: NULL @@ -1741,7 +1731,7 @@ H5AC_protect(H5F_t *f, if ( ( f != NULL ) && ( f->shared != NULL ) && ( f->shared->cache != NULL ) && - ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0) && ( trace_file_ptr != NULL ) ) { char * rw_string; @@ -1759,7 +1749,7 @@ H5AC_protect(H5F_t *f, rw_string = "???"; } - sprintf(trace, "H5AC_protect %lx %d %s", + sprintf(trace, "H5AC_protect 0x%lx %d %s", (unsigned long)addr, (int)(type->id), rw_string); @@ -1899,7 +1889,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5AC_unpin_entry(void * thing) +H5AC_unpin_entry(void *thing) { #if H5AC__TRACE_FILE_ENABLED char trace[128] = ""; @@ -1918,7 +1908,7 @@ H5AC_unpin_entry(void * thing) */ if((H5C_get_trace_file_ptr_from_entry(thing, &trace_file_ptr) >= 0) && (NULL != trace_file_ptr)) - sprintf(trace, "%s %lx", FUNC, + sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); #endif /* H5AC__TRACE_FILE_ENABLED */ @@ -2015,10 +2005,6 @@ done: * If the DELETED flag is set, then this object has been deleted * from the file and should not be returned to the cache. * - * If H5AC_DEBUG is defined then this function fails - * if the TYPE and ADDR arguments are not what was used when the - * object was protected or if the object was never protected. - * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke @@ -2083,7 +2069,6 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags) { herr_t result; - herr_t ret_value=SUCCEED; /* Return value */ hbool_t dirtied; size_t new_size = 0; #ifdef H5_HAVE_PARALLEL @@ -2096,10 +2081,12 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, unsigned trace_flags = 0; FILE * trace_file_ptr = NULL; #endif /* H5AC__TRACE_FILE_ENABLED */ + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_unprotect, FAIL) HDassert(f); + HDassert(f->shared); HDassert(f->shared->cache); HDassert(type); HDassert(type->clear); @@ -2117,10 +2104,10 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, if ( ( f != NULL ) && ( f->shared != NULL ) && ( f->shared->cache != NULL ) && - ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0) && ( trace_file_ptr != NULL ) ) { - sprintf(trace, "H5AC_unprotect %lx %d", + sprintf(trace, "H5AC_unprotect 0x%lx %d", (unsigned long)addr, (int)(type->id)); @@ -2305,6 +2292,7 @@ H5AC_stats(const H5F_t *f) FUNC_ENTER_NOAPI(H5AC_stats, FAIL) HDassert(f); + HDassert(f->shared); HDassert(f->shared->cache); /* at present, this can't fail */ @@ -2430,9 +2418,9 @@ H5AC_get_cache_auto_resize_config(const H5AC_t * cache_ptr, config_ptr->max_increment = internal_config.max_increment; config_ptr->decr_mode = internal_config.decr_mode; config_ptr->upper_hr_threshold = internal_config.upper_hr_threshold; - config_ptr->flash_incr_mode = internal_config.flash_incr_mode; - config_ptr->flash_multiple = internal_config.flash_multiple; - config_ptr->flash_threshold = internal_config.flash_threshold; + config_ptr->flash_incr_mode = internal_config.flash_incr_mode; + config_ptr->flash_multiple = internal_config.flash_multiple; + config_ptr->flash_threshold = internal_config.flash_threshold; config_ptr->decrement = internal_config.decrement; config_ptr->apply_max_decrement = internal_config.apply_max_decrement; config_ptr->max_decrement = internal_config.max_decrement; @@ -2479,7 +2467,6 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5AC_get_cache_size(H5AC_t * cache_ptr, size_t * max_size_ptr, @@ -2527,29 +2514,18 @@ done: * *------------------------------------------------------------------------- */ - herr_t -H5AC_get_cache_hit_rate(H5AC_t * cache_ptr, - double * hit_rate_ptr) - +H5AC_get_cache_hit_rate(H5AC_t * cache_ptr, double * hit_rate_ptr) { - herr_t result; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_get_cache_hit_rate, FAIL) - result = H5C_get_cache_hit_rate((H5C_t *)cache_ptr, hit_rate_ptr); - - if ( result < 0 ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "H5C_get_cache_hit_rate() failed.") - } + if(H5C_get_cache_hit_rate((H5C_t *)cache_ptr, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_cache_hit_rate() failed.") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5AC_get_cache_hit_rate() */ @@ -2630,7 +2606,6 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) @@ -2843,15 +2818,13 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5AC_validate_config(H5AC_cache_config_t * config_ptr) - { herr_t result; - herr_t ret_value = SUCCEED; /* Return value */ - size_t name_len; + int name_len; H5C_auto_size_ctl_t internal_config; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_validate_config, FAIL) @@ -3039,7 +3012,6 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5AC_open_trace_file(H5AC_t * cache_ptr, const char * trace_file_name) @@ -3120,7 +3092,7 @@ H5AC_open_trace_file(H5AC_t * cache_ptr, HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "trace file open failed.") } - HDfprintf(file_ptr, "### HDF5 metadata cache trace file version 1 ###\n"); + HDfprintf(file_ptr, "### HDF5 metadata cache trace file ###\n"); if ( H5C_set_trace_file_ptr(cache_ptr, file_ptr) < 0 ) { @@ -3182,7 +3154,7 @@ H5AC_broadcast_clean_list(H5AC_t * cache_ptr) HDassert( cache_ptr != NULL ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - aux_ptr = cache_ptr->aux_ptr; + aux_ptr = (H5AC_aux_t *)(cache_ptr->aux_ptr); HDassert( aux_ptr != NULL ); HDassert( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ); @@ -3421,11 +3393,10 @@ done: * * Updated function for flash cache increment fields. * - * JRM -- 1/2/08 + * JRM -- 1/2/08 * *------------------------------------------------------------------------- */ - herr_t H5AC_ext_config_2_int_config(H5AC_cache_config_t * ext_conf_ptr, H5C_auto_size_ctl_t * int_conf_ptr) @@ -3457,32 +3428,28 @@ H5AC_ext_config_2_int_config(H5AC_cache_config_t * ext_conf_ptr, int_conf_ptr->min_clean_fraction = ext_conf_ptr->min_clean_fraction; int_conf_ptr->max_size = ext_conf_ptr->max_size; int_conf_ptr->min_size = ext_conf_ptr->min_size; - int_conf_ptr->epoch_length = - (int64_t)(ext_conf_ptr->epoch_length); + int_conf_ptr->epoch_length = (int64_t)(ext_conf_ptr->epoch_length); int_conf_ptr->incr_mode = ext_conf_ptr->incr_mode; int_conf_ptr->lower_hr_threshold = ext_conf_ptr->lower_hr_threshold; int_conf_ptr->increment = ext_conf_ptr->increment; int_conf_ptr->apply_max_increment = ext_conf_ptr->apply_max_increment; int_conf_ptr->max_increment = ext_conf_ptr->max_increment; - int_conf_ptr->flash_incr_mode = ext_conf_ptr->flash_incr_mode; - int_conf_ptr->flash_multiple = ext_conf_ptr->flash_multiple; - int_conf_ptr->flash_threshold = ext_conf_ptr->flash_threshold; + int_conf_ptr->flash_incr_mode = ext_conf_ptr->flash_incr_mode; + int_conf_ptr->flash_multiple = ext_conf_ptr->flash_multiple; + int_conf_ptr->flash_threshold = ext_conf_ptr->flash_threshold; int_conf_ptr->decr_mode = ext_conf_ptr->decr_mode; int_conf_ptr->upper_hr_threshold = ext_conf_ptr->upper_hr_threshold; int_conf_ptr->decrement = ext_conf_ptr->decrement; int_conf_ptr->apply_max_decrement = ext_conf_ptr->apply_max_decrement; int_conf_ptr->max_decrement = ext_conf_ptr->max_decrement; - int_conf_ptr->epochs_before_eviction = - (int32_t)(ext_conf_ptr->epochs_before_eviction); + int_conf_ptr->epochs_before_eviction = (int32_t)(ext_conf_ptr->epochs_before_eviction); int_conf_ptr->apply_empty_reserve = ext_conf_ptr->apply_empty_reserve; int_conf_ptr->empty_reserve = ext_conf_ptr->empty_reserve; done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5AC_ext_config_2_int_config() */ @@ -3632,7 +3599,7 @@ H5AC_log_dirtied_entry(const H5AC_info_t * entry_ptr, FUNC_ENTER_NOAPI(H5AC_log_dirtied_entry, FAIL) - HDassert( entry_ptr != NULL ); + HDassert( entry_ptr ); HDassert( entry_ptr->addr == addr ); HDassert( entry_ptr->is_dirty == FALSE ); @@ -4061,7 +4028,6 @@ done: * *------------------------------------------------------------------------- */ - #ifdef H5_HAVE_PARALLEL static herr_t H5AC_log_renamed_entry(const H5F_t *f, @@ -4069,12 +4035,12 @@ H5AC_log_renamed_entry(const H5F_t *f, haddr_t new_addr) { H5AC_t * cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ hbool_t entry_in_cache; hbool_t entry_dirty; size_t entry_size; H5AC_aux_t * aux_ptr = NULL; H5AC_slist_entry_t * slist_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5AC_log_renamed_entry, FAIL) @@ -4311,7 +4277,7 @@ H5AC_propagate_flushed_and_still_clean_entries_list(H5F_t * f, HDassert( cache_ptr != NULL ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - aux_ptr = cache_ptr->aux_ptr; + aux_ptr = (H5AC_aux_t *)(cache_ptr->aux_ptr); HDassert( aux_ptr != NULL ); HDassert( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ); @@ -4346,8 +4312,7 @@ H5AC_propagate_flushed_and_still_clean_entries_list(H5F_t * f, aux_ptr->write_permitted = TRUE; - result = H5C_flush_to_min_clean(f, dxpl_id, H5AC_noblock_dxpl_id, - cache_ptr); + result = H5C_flush_to_min_clean(f, dxpl_id, H5AC_noblock_dxpl_id); aux_ptr->write_permitted = FALSE; @@ -4442,7 +4407,7 @@ H5AC_receive_and_apply_clean_list(H5F_t * f, HDassert( cache_ptr != NULL ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - aux_ptr = cache_ptr->aux_ptr; + aux_ptr = (H5AC_aux_t *)(cache_ptr->aux_ptr); HDassert( aux_ptr != NULL ); HDassert( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC ); @@ -4518,8 +4483,7 @@ H5AC_receive_and_apply_clean_list(H5F_t * f, /* mark the indicated entries as clean */ if ( H5C_mark_entries_as_clean(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, (int32_t)num_entries, - &(haddr_buf_ptr[0])) < 0 ) { + (int32_t)num_entries, &(haddr_buf_ptr[0])) < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ "Can't mark entries clean.") diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 5f226ed..911aceb 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -25,6 +25,7 @@ * The one exception to this rule is testpar/t_cache.c. The * test code is easier to write if it can look at H5AC_aux_t. * Indeed, this is the main reason why this file was created. + * */ #ifndef H5AC_PACKAGE @@ -35,7 +36,7 @@ #define _H5ACpkg_H /* Get package's private header */ -#include "H5ACprivate.h" +#include "H5ACprivate.h" /* Metadata cache */ /* Get needed headers */ diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index f049a3b..04c3577 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -22,10 +22,6 @@ * Purpose: Constants and typedefs available to the rest of the * library. * - * Modifications: JRM - 6/4/04 - * Complete re-write for a new caching algorithm - * located in H5C.c - * *------------------------------------------------------------------------- */ @@ -36,8 +32,8 @@ /* Pivate headers needed by this header */ #include "H5private.h" /* Generic Functions */ +#include "H5Cprivate.h" /* Cache */ #include "H5Fprivate.h" /* File access */ -#include "H5Cprivate.h" /* cache */ #ifdef H5_METADATA_TRACE_FILE #define H5AC__TRACE_FILE_ENABLED 1 @@ -147,7 +143,7 @@ typedef H5C_clear_func_t H5AC_clear_func_t; typedef H5C_notify_func_t H5AC_notify_func_t; typedef H5C_size_func_t H5AC_size_func_t; -typedef H5C_class_t H5AC_class_t; +typedef H5C_class_t H5AC_class_t; /* The H5AC_NSLOTS #define is now obsolete, as the metadata cache no longer @@ -166,7 +162,7 @@ typedef H5C_class_t H5AC_class_t; #define H5AC_NSLOTS 10330 /* The library "likes" this number... */ -typedef H5C_cache_entry_t H5AC_info_t; +typedef H5C_cache_entry_t H5AC_info_t; /*===----------------------------------------------------------------------=== @@ -217,7 +213,7 @@ extern hid_t H5AC_ind_dxpl_id; #ifdef H5_HAVE_PARALLEL #define H5AC__DEFAULT_CACHE_CONFIG \ { \ - /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, \ + /* int version = */ H5AC__CURR_CACHE_CONFIG_VERSION, \ /* hbool_t rpt_fcn_enabled = */ FALSE, \ /* hbool_t open_trace_file = */ FALSE, \ /* hbool_t close_trace_file = */ FALSE, \ @@ -227,7 +223,7 @@ extern hid_t H5AC_ind_dxpl_id; /* size_t initial_size = */ ( 2 * 1024 * 1024), \ /* double min_clean_fraction = */ 0.3, \ /* size_t max_size = */ (32 * 1024 * 1024), \ - /* size_t min_size = */ ( 1 * 1024 * 1024), \ + /* size_t min_size = */ (1 * 1024 * 1024), \ /* long int epoch_length = */ 50000, \ /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, \ /* double lower_hr_threshold = */ 0.9, \ @@ -238,7 +234,7 @@ extern hid_t H5AC_ind_dxpl_id; /* flash_incr_mode = */ H5C_flash_incr__add_space, \ /* double flash_multiple = */ 1.0, \ /* double flash_threshold = */ 0.25, \ - /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold,\ + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold, \ /* double upper_hr_threshold = */ 0.999, \ /* double decrement = */ 0.9, \ /* hbool_t apply_max_decrement = */ TRUE, \ @@ -325,7 +321,7 @@ extern hid_t H5AC_ind_dxpl_id; H5_DLL herr_t H5AC_init(void); H5_DLL herr_t H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr); -H5_DLL herr_t H5AC_get_entry_status(const H5F_t * f, haddr_t addr, +H5_DLL herr_t H5AC_get_entry_status(const H5F_t *f, haddr_t addr, unsigned * status_ptr); H5_DLL herr_t H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned int flags); diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index 3c62fbf..02941b6 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -36,8 +36,6 @@ extern "C" { #endif -#define H5AC__MAX_TRACE_FILE_NAME_LEN 1024 - /**************************************************************************** * * structure H5AC_cache_config_t @@ -240,8 +238,8 @@ extern "C" { * stay within max_size. * * With a little thought, it should be obvious that the above flash - * cache size increase algorithm is not sufficient for all circumstances -- - * for example, suppose the user round robins through + * cache size increase algorithm is not sufficient for all circumstances + * -- for example, suppose the user round robins through * (1/flash_threshold) +1 groups, adding one data set to each on each * pass. Then all will increase in size at about the same time, requiring * the max cache size to at least double to maintain acceptable @@ -257,13 +255,12 @@ extern "C" { * flash_incr_mode section. This field is ignored unless flash_incr_mode * is H5C_flash_incr__add_space. * - * flash_threshold: Double containing the factor by which current max cache size - * is multiplied to obtain the size threshold for the add_space flash + * flash_threshold: Double containing the factor by which current max cache + * size is multiplied to obtain the size threshold for the add_space flash * increment algorithm. The field is ignored unless flash_incr_mode is * H5C_flash_incr__add_space. * * - * * Cache size decrease control fields: * * decr_mode: Instance of the H5C_cache_decr_mode enumerated type whose @@ -383,7 +380,8 @@ extern "C" { * ****************************************************************************/ -#define H5AC__CURR_CACHE_CONFIG_VERSION 1 +#define H5AC__CURR_CACHE_CONFIG_VERSION 1 +#define H5AC__MAX_TRACE_FILE_NAME_LEN 1024 typedef struct H5AC_cache_config_t { @@ -258,7 +258,8 @@ done: (void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)shared->sizeof_rnode); } /* end if */ if(bt) - (void)H5B_dest(f, bt); + if(H5B_node_dest(bt) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2045,3 +2046,34 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_valid() */ +/*------------------------------------------------------------------------- + * Function: H5B_node_dest + * + * Purpose: Destroy/release a B-tree node + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 26, 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B_node_dest(H5B_t *bt) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_node_dest) + + /* check arguments */ + HDassert(bt); + HDassert(bt->rc_shared); + + bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); + bt->native = H5FL_BLK_FREE(native_block, bt->native); + H5RC_DEC(bt->rc_shared); + bt = H5FL_FREE(H5B_t, bt); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B_node_dest() */ + @@ -1263,7 +1263,6 @@ done: if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") - FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_delete() */ diff --git a/src/H5B2cache.c b/src/H5B2cache.c index 1d795ec..af329c7 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -71,14 +71,17 @@ /* Metadata cache callbacks */ static H5B2_hdr_t *H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); static herr_t H5B2_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_hdr_t *hdr, unsigned UNUSED * flags_ptr); +static herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_hdr_t *hdr); static herr_t H5B2_cache_hdr_clear(H5F_t *f, H5B2_hdr_t *hdr, hbool_t destroy); static herr_t H5B2_cache_hdr_size(const H5F_t *f, const H5B2_hdr_t *hdr, size_t *size_ptr); static H5B2_internal_t *H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *udata2); static herr_t H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_internal_t *i, unsigned UNUSED * flags_ptr); +static herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal); static herr_t H5B2_cache_internal_clear(H5F_t *f, H5B2_internal_t *i, hbool_t destroy); static herr_t H5B2_cache_internal_size(const H5F_t *f, const H5B2_internal_t *i, size_t *size_ptr); static H5B2_leaf_t *H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, void *_hdr); static herr_t H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B2_leaf_t *l, unsigned UNUSED * flags_ptr); +static herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf); static herr_t H5B2_cache_leaf_clear(H5F_t *f, H5B2_leaf_t *l, hbool_t destroy); static herr_t H5B2_cache_leaf_size(const H5F_t *f, const H5B2_leaf_t *l, size_t *size_ptr); @@ -380,16 +383,14 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_hdr_t *hdr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_hdr_dest) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(hdr); HDassert(hdr->rc == 0); @@ -606,7 +607,8 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda done: if(!ret_value && internal) - (void)H5B2_cache_internal_dest(f, internal); + if(H5B2_internal_free(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_internal_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -722,16 +724,14 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_internal_dest) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(internal); HDassert(internal->hdr); @@ -747,23 +747,9 @@ H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree internal node") } /* end if */ - /* Set the B-tree header's file context for this operation */ - internal->hdr->f = f; - - /* Release internal node's native key buffer */ - if(internal->int_native) - H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].nat_rec_fac, internal->int_native); - - /* Release internal node's node pointer buffer */ - if(internal->node_ptrs) - H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); - - /* Decrement ref. count on B-tree header */ - if(H5B2_hdr_decr(internal->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") - - /* Free B-tree internal node info */ - internal = H5FL_FREE(H5B2_internal_t, internal); + /* Release v2 b-tree internal node */ + if(H5B2_internal_free(internal) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") done: FUNC_LEAVE_NOAPI(ret_value) @@ -944,7 +930,8 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v done: if(!ret_value && leaf) - (void)H5B2_cache_leaf_dest(f, leaf); + if(H5B2_leaf_free(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_leaf_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -1046,16 +1033,14 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_leaf_dest) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(leaf); HDassert(leaf->hdr); @@ -1071,19 +1056,9 @@ H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree leaf node") } /* end if */ - /* Set the B-tree header's file context for this operation */ - leaf->hdr->f = f; - - /* Release leaf's native key buffer */ - if(leaf->leaf_native) - H5FL_FAC_FREE(leaf->hdr->node_info[0].nat_rec_fac, leaf->leaf_native); - - /* Decrement ref. count on B-tree header */ - if(H5B2_hdr_decr(leaf->hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") - - /* Free B-tree leaf node info */ - leaf = H5FL_FREE(H5B2_leaf_t, leaf); + /* Destroy v2 b-tree leaf node */ + if(H5B2_leaf_free(leaf) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 668bce4..a219859 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -519,7 +519,7 @@ H5B2_hdr_free(H5B2_hdr_t *hdr) /* Free the B-tree node buffer */ if(hdr->page) - (void)H5FL_BLK_FREE(node_page, hdr->page); + hdr->page = H5FL_BLK_FREE(node_page, hdr->page); /* Free the array of offsets into the native key block */ if(hdr->nat_off) @@ -544,7 +544,7 @@ H5B2_hdr_free(H5B2_hdr_t *hdr) } /* end if */ /* Free B-tree header info */ - (void)H5FL_FREE(H5B2_hdr_t, hdr); + hdr = H5FL_FREE(H5B2_hdr_t, hdr); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2int.c b/src/H5B2int.c index f7312a5..5423bf7 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1730,7 +1730,8 @@ HDmemset(leaf->leaf_native, 0, hdr->cls->nrec_size * hdr->node_info[0].max_nrec) done: if(ret_value < 0) { if(leaf) - (void)H5B2_cache_leaf_dest(hdr->f, leaf); + if(H5B2_leaf_free(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree leaf node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1808,7 +1809,8 @@ HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (hdr->node_info[depth done: if(ret_value < 0) { if(internal) - (void)H5B2_cache_internal_dest(hdr->f, internal); + if(H5B2_internal_free(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2890,6 +2892,92 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_node_size() */ + +/*------------------------------------------------------------------------- + * Function: H5B2_internal_free + * + * Purpose: Destroys a B-tree internal node in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 2 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_internal_free(H5B2_internal_t *internal) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_internal_free) + + /* + * Check arguments. + */ + HDassert(internal); + + /* Release internal node's native key buffer */ + if(internal->int_native) + H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].nat_rec_fac, internal->int_native); + + /* Release internal node's node pointer buffer */ + if(internal->node_ptrs) + H5FL_FAC_FREE(internal->hdr->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); + + /* Decrement ref. count on B-tree header */ + if(H5B2_hdr_decr(internal->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") + + /* Free B-tree internal node info */ + internal = H5FL_FREE(H5B2_internal_t, internal); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2_internal_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_leaf_free + * + * Purpose: Destroys a B-tree leaf node in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 2 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_leaf_free(H5B2_leaf_t *leaf) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_leaf_free) + + /* + * Check arguments. + */ + HDassert(leaf); + + /* Release leaf's native key buffer */ + if(leaf->leaf_native) + H5FL_FAC_FREE(leaf->hdr->node_info[0].nat_rec_fac, leaf->leaf_native); + + /* Decrement ref. count on B-tree header */ + if(H5B2_hdr_decr(leaf->hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header") + + /* Free B-tree leaf node info */ + leaf = H5FL_FREE(H5B2_leaf_t, leaf); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2_leaf_free() */ + #ifdef H5B2_DEBUG /*------------------------------------------------------------------------- diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 5817d22..6307187 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -266,7 +266,6 @@ H5_DLL herr_t H5B2_hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2_hdr_fuse_incr(H5B2_hdr_t *hdr); H5_DLL size_t H5B2_hdr_fuse_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2_hdr_dirty(H5B2_hdr_t *hdr); -H5_DLL herr_t H5B2_hdr_free(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2_hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id); /* Routines for operating on internal nodes */ @@ -278,6 +277,11 @@ H5_DLL herr_t H5B2_split_root(H5B2_hdr_t *hdr, hid_t dxpl_id); H5_DLL herr_t H5B2_create_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *node_ptr); +/* Routines for releasing structures */ +H5_DLL herr_t H5B2_hdr_free(H5B2_hdr_t *hdr); +H5_DLL herr_t H5B2_leaf_free(H5B2_leaf_t *l); +H5_DLL herr_t H5B2_internal_free(H5B2_internal_t *i); + /* Routines for inserting records */ H5_DLL herr_t H5B2_insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, unsigned *parent_cache_info_flags_ptr, @@ -321,11 +325,6 @@ H5_DLL herr_t H5B2_remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, H5_DLL herr_t H5B2_delete_node(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data); -/* Metadata cache callbacks */ -H5_DLL herr_t H5B2_cache_hdr_dest(H5F_t *f, H5B2_hdr_t *b); -H5_DLL herr_t H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *l); -H5_DLL herr_t H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *i); - /* Debugging routines for dumping file structures */ H5_DLL herr_t H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B2_class_t *type); diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 99cd0cd..76c27c8 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -57,6 +57,7 @@ /* Metadata cache callbacks */ static H5B_t *H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *b, unsigned UNUSED * flags_ptr); +static herr_t H5B_dest(H5F_t *f, H5B_t *bt); static herr_t H5B_clear(H5F_t *f, H5B_t *b, hbool_t destroy); static herr_t H5B_compute_size(const H5F_t *f, const H5B_t *bt, size_t *size_ptr); @@ -182,7 +183,8 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) done: if(!ret_value && bt) - (void)H5B_dest(f, bt); + if(H5B_node_dest(bt) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_load() */ /*lint !e818 Can't make udata a pointer to const */ @@ -292,7 +294,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5B_dest(H5F_t *f, H5B_t *bt) { herr_t ret_value = SUCCEED; /* Return value */ @@ -323,11 +325,9 @@ H5B_dest(H5F_t *f, H5B_t *bt) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree node") } /* end if */ - /* Release resources for B-tree node */ - bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); - bt->native = H5FL_BLK_FREE(native_block, bt->native); - H5RC_DEC(bt->rc_shared); - bt = H5FL_FREE(H5B_t, bt); + /* Destroy B-tree node */ + if(H5B_node_dest(bt) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 79b5e8a..ad88351 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -51,8 +51,8 @@ /* The B-tree node as stored in memory... */ typedef struct H5B_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions */ - /* _must_ be first field in structure */ + H5AC_info_t cache_info; /* Information for H5AC cache functions */ + /* _must_ be first field in structure */ H5RC_t *rc_shared; /*ref-counted shared info */ unsigned level; /*node level */ unsigned nchildren; /*number of child pointers */ @@ -82,7 +82,7 @@ H5FL_EXTERN(H5B_t); /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5B_dest(H5F_t *f, H5B_t *b); +H5_DLL herr_t H5B_node_dest(H5B_t *b); #ifdef H5B_DEBUG herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void *udata); @@ -95,7 +95,7 @@ * **************************************************************************/ -#define H5C_PACKAGE /*suppress error about including H5Cpkg */ +#define H5C_PACKAGE /*suppress error about including H5Cpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ @@ -111,7 +111,7 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SLprivate.h" /* Skip lists */ - + /* * Private file-scope variables. */ @@ -119,22 +119,21 @@ /* Declare a free list to manage the H5C_t struct */ H5FL_DEFINE_STATIC(H5C_t); + /* * Private file-scope function declarations: */ -static herr_t H5C__auto_adjust_cache_size(H5C_t * cache_ptr, - H5F_t * f, +static herr_t H5C__auto_adjust_cache_size(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, hbool_t write_permitted, hbool_t * first_flush_ptr); -static herr_t H5C__autoadjust__ageout(H5C_t * cache_ptr, +static herr_t H5C__autoadjust__ageout(H5F_t * f, double hit_rate, enum H5C_resize_status * status_ptr, size_t * new_max_cache_size_ptr, - H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, hbool_t write_permitted, @@ -145,7 +144,6 @@ static herr_t H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t * cache_ptr); static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, hbool_t write_permitted, hbool_t * first_flush_ptr); @@ -159,20 +157,18 @@ static herr_t H5C__flash_increase_cache_size(H5C_t * cache_ptr, size_t old_entry_size, size_t new_entry_size); -static herr_t H5C_flush_single_entry(H5F_t * f, +static herr_t H5C_flush_single_entry(const H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, const H5C_class_t * type_ptr, haddr_t addr, unsigned flags, hbool_t * first_flush_ptr, hbool_t del_entry_from_slist_on_destroy); -static herr_t H5C_flush_invalidate_cache(H5F_t * f, +static herr_t H5C_flush_invalidate_cache(const H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, unsigned flags); static void * H5C_load_entry(H5F_t * f, @@ -186,7 +182,6 @@ static void * H5C_load_entry(H5F_t * f, static herr_t H5C_make_space_in_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, size_t space_needed, hbool_t write_permitted, hbool_t * first_flush_ptr); @@ -461,7 +456,6 @@ H5C_create(size_t max_cache_size, HDassert( HDstrlen(( type_name_table_ptr)[i]) > 0 ); } - if ( NULL == (cache_ptr = H5FL_CALLOC(H5C_t)) ) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, \ @@ -486,6 +480,7 @@ H5C_create(size_t max_cache_size, cache_ptr->aux_ptr = aux_ptr; cache_ptr->max_type_id = max_type_id; + cache_ptr->type_name_table_ptr = type_name_table_ptr; cache_ptr->max_cache_size = max_cache_size; @@ -564,10 +559,9 @@ H5C_create(size_t max_cache_size, (cache_ptr->resize_ctl).apply_max_increment = TRUE; (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; - (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; - (cache_ptr->resize_ctl).flash_multiple = 1.0; - (cache_ptr->resize_ctl).flash_threshold = 0.25; - + (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; + (cache_ptr->resize_ctl).flash_multiple = 1.0; + (cache_ptr->resize_ctl).flash_threshold = 0.25; (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; @@ -593,8 +587,8 @@ H5C_create(size_t max_cache_size, { (cache_ptr->epoch_marker_active)[i] = FALSE; #ifndef NDEBUG - ((cache_ptr->epoch_markers)[i]).magic = - H5C__H5C_CACHE_ENTRY_T_MAGIC; + ((cache_ptr->epoch_markers)[i]).magic = + H5C__H5C_CACHE_ENTRY_T_MAGIC; #endif /* NDEBUG */ ((cache_ptr->epoch_markers)[i]).addr = (haddr_t)i; ((cache_ptr->epoch_markers)[i]).type = &epoch_marker_class; @@ -662,7 +656,7 @@ done: * H5C_t in output. * * JRM 12/31/07 - * Updated function to handle flash size increases. + * Updated function to handle flash size increases. * *------------------------------------------------------------------------- */ @@ -714,19 +708,19 @@ H5C_def_auto_resize_rpt_fcn(H5C_t * cache_ptr, HDassert( old_max_cache_size < new_max_cache_size ); HDfprintf(stdout, - "%sflash cache resize(%d) -- size threshold = %Zu.\n", - cache_ptr->prefix, - (int)((cache_ptr->resize_ctl).flash_incr_mode), - cache_ptr->flash_size_increase_threshold); + "%sflash cache resize(%d) -- size threshold = %Zu.\n", + cache_ptr->prefix, + (int)((cache_ptr->resize_ctl).flash_incr_mode), + cache_ptr->flash_size_increase_threshold); HDfprintf(stdout, - "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", - cache_ptr->prefix, - old_max_cache_size, - old_min_clean_size, - new_max_cache_size, - new_min_clean_size); - break; + "%s cache size increased from (%Zu/%Zu) to (%Zu/%Zu).\n", + cache_ptr->prefix, + old_max_cache_size, + old_min_clean_size, + new_max_cache_size, + new_min_clean_size); + break; case decrease: HDassert( old_max_cache_size > new_max_cache_size ); @@ -872,7 +866,7 @@ H5C_dest(H5F_t * f, /* Flush and invalidate all cache entries */ if(H5C_flush_invalidate_cache(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, H5C__NO_FLAGS_SET) < 0 ) + H5C__NO_FLAGS_SET) < 0 ) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") if(cache_ptr->slist_ptr != NULL) { @@ -916,7 +910,7 @@ H5C_expunge_entry(H5F_t * f, haddr_t addr, unsigned flags) { - H5C_t * cache_ptr; + H5C_t * cache_ptr; herr_t result; hbool_t first_flush = TRUE; H5C_cache_entry_t * entry_ptr = NULL; @@ -977,11 +971,9 @@ H5C_expunge_entry(H5F_t * f, result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, entry_ptr->addr, - H5C__FLUSH_INVALIDATE_FLAG | - H5C__FLUSH_CLEAR_ONLY_FLAG, + H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, &first_flush, TRUE); @@ -1104,10 +1096,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_flush_cache(H5F_t * f, - hid_t primary_dxpl_id, - hid_t secondary_dxpl_id, - unsigned flags) +H5C_flush_cache(H5F_t *f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsigned flags) { H5C_t * cache_ptr = f->shared->cache; herr_t status; @@ -1134,7 +1123,7 @@ H5C_flush_cache(H5F_t * f, HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( cache_ptr->skip_file_checks || f ); + HDassert( cache_ptr->skip_file_checks || f); HDassert( cache_ptr->slist_ptr ); ignore_protected = ( (flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0 ); @@ -1158,7 +1147,6 @@ H5C_flush_cache(H5F_t * f, status = H5C_flush_invalidate_cache(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, flags); if ( status < 0 ) { @@ -1311,7 +1299,7 @@ H5C_flush_cache(H5F_t * f, HDassert( next_entry_ptr->in_slist ); } else { next_entry_ptr = NULL; - } + } HDassert( entry_ptr != NULL ); HDassert( entry_ptr->in_slist ); @@ -1342,7 +1330,6 @@ H5C_flush_cache(H5F_t * f, status = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, NULL, entry_ptr->addr, flags, @@ -1376,7 +1363,6 @@ H5C_flush_cache(H5F_t * f, status = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, NULL, entry_ptr->addr, flags, @@ -1456,7 +1442,7 @@ end_of_inner_loop: } #endif /* H5C_DO_SANITY_CHECKS */ - } + } done: @@ -1522,11 +1508,10 @@ done: herr_t H5C_flush_to_min_clean(H5F_t * f, hid_t primary_dxpl_id, - hid_t secondary_dxpl_id, - H5C_t * cache_ptr) + hid_t secondary_dxpl_id) { + H5C_t * cache_ptr; herr_t result; - herr_t ret_value = SUCCEED; hbool_t first_flush = TRUE; hbool_t write_permitted; #if 0 /* modified code -- commented out for now */ @@ -1537,9 +1522,15 @@ H5C_flush_to_min_clean(H5F_t * f, haddr_t * flushed_entries_list = NULL; H5C_cache_entry_t * entry_ptr = NULL; #endif /* JRM */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5C_flush_to_min_clean, FAIL) + HDassert( f ); + HDassert( f->shared ); + + cache_ptr = f->shared->cache; + HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); @@ -1569,7 +1560,6 @@ H5C_flush_to_min_clean(H5F_t * f, result = H5C_make_space_in_cache(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, (size_t)0, write_permitted, &first_flush); @@ -1646,15 +1636,6 @@ H5C_flush_to_min_clean(H5F_t * f, entry_ptr = entry_ptr->aux_prev; } - if ( ( flushed_entries_count > cache_ptr->slist_len) || - ( flushed_entries_size < space_needed ) ) { - HDfprintf(stdout, "flushed_entries_count = %d <= %d = slist_size\n", - (int)flushed_entries_count, (int)(cache_ptr->slist_size)); - HDfprintf(stdout, - "flushed_entries_size = %d < %d = space_needed.\n", - (int)flushed_entries_size, (int)space_needed); - } - HDassert( flushed_entries_count <= cache_ptr->slist_len ); HDassert( flushed_entries_size >= space_needed ); @@ -1715,7 +1696,6 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5C_get_cache_auto_resize_config(const H5C_t * cache_ptr, H5C_auto_size_ctl_t *config_ptr) @@ -1766,7 +1746,6 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5C_get_cache_size(H5C_t * cache_ptr, size_t * max_size_ptr, @@ -1830,7 +1809,6 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5C_get_cache_hit_rate(H5C_t * cache_ptr, double * hit_rate_ptr) @@ -1897,7 +1875,6 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, @@ -1925,7 +1902,7 @@ H5C_get_entry_status(const H5F_t *f, HDassert( H5F_addr_defined(addr) ); HDassert( in_cache_ptr != NULL ); - /* this test duplicates tow of the above asserts, but we need an + /* this test duplicates two of the above asserts, but we need an * invocation of HGOTO_ERROR to keep the compiler happy. */ if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { @@ -1987,23 +1964,22 @@ done: /*------------------------------------------------------------------------- * Function: H5C_get_evictions_enabled() * - * Purpose: Copy the current value of cache_ptr->evictions_enabled into - * *evictions_enabled_ptr. + * Purpose: Copy the current value of cache_ptr->evictions_enabled into + * *evictions_enabled_ptr. * * Return: SUCCEED on success, and FAIL on failure. * * Programmer: John Mainzer - * 7/27/07 + * 7/27/07 * * Modifications: * - * None. + * None. * *------------------------------------------------------------------------- */ - herr_t -H5C_get_evictions_enabled(const H5C_t * cache_ptr, +H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t * evictions_enabled_ptr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2018,7 +1994,7 @@ H5C_get_evictions_enabled(const H5C_t * cache_ptr, if ( evictions_enabled_ptr == NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Bad evictions_enabled_ptr on entry.") + "Bad evictions_enabled_ptr on entry.") } *evictions_enabled_ptr = cache_ptr->evictions_enabled; @@ -2051,7 +2027,6 @@ H5C_get_trace_file_ptr(const H5C_t *cache_ptr, FILE **trace_file_ptr_ptr) { FUNC_ENTER_NOAPI_NOFUNC(H5C_get_trace_file_ptr) - /* Sanity checks */ HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(trace_file_ptr_ptr); @@ -2088,7 +2063,6 @@ H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr, HDassert(entry_ptr); HDassert(entry_ptr->cache_ptr); - /* Go get the trace file pointer for the cache */ H5C_get_trace_file_ptr(entry_ptr->cache_ptr, trace_file_ptr_ptr); FUNC_LEAVE_NOAPI(SUCCEED) @@ -2202,7 +2176,6 @@ H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr, * *------------------------------------------------------------------------- */ - herr_t H5C_insert_entry(H5F_t * f, hid_t primary_dxpl_id, @@ -2284,8 +2257,8 @@ H5C_insert_entry(H5F_t * f, entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; #endif /* NDEBUG */ entry_ptr->cache_ptr = cache_ptr; - entry_ptr->addr = addr; - entry_ptr->type = type; + entry_ptr->addr = addr; + entry_ptr->type = type; entry_ptr->is_protected = FALSE; entry_ptr->is_read_only = FALSE; @@ -2430,7 +2403,6 @@ H5C_insert_entry(H5F_t * f, result = H5C_make_space_in_cache(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, space_needed, write_permitted, &first_flush); @@ -2537,17 +2509,15 @@ done: * *------------------------------------------------------------------------- */ - #ifdef H5_HAVE_PARALLEL herr_t H5C_mark_entries_as_clean(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, int32_t ce_array_len, haddr_t * ce_array_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr; hbool_t first_flush = TRUE; int entries_cleared; int entries_examined; @@ -2562,9 +2532,13 @@ H5C_mark_entries_as_clean(H5F_t * f, #endif /* H5C_DO_SANITY_CHECKS */ H5C_cache_entry_t * clear_ptr = NULL; H5C_cache_entry_t * entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_mark_entries_as_clean, FAIL) + HDassert( f ); + HDassert( f->shared ); + cache_ptr = f->shared->cache; HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); @@ -2647,7 +2621,6 @@ H5C_mark_entries_as_clean(H5F_t * f, if ( H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, addr, H5C__FLUSH_CLEAR_ONLY_FLAG, @@ -2707,7 +2680,6 @@ H5C_mark_entries_as_clean(H5F_t * f, if ( H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, clear_ptr->type, clear_ptr->addr, H5C__FLUSH_CLEAR_ONLY_FLAG, @@ -2745,7 +2717,6 @@ H5C_mark_entries_as_clean(H5F_t * f, if ( H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, clear_ptr->type, clear_ptr->addr, H5C__FLUSH_CLEAR_ONLY_FLAG, @@ -2867,7 +2838,7 @@ H5C_mark_pinned_entry_dirty(void *thing, hbool_t size_changed, size_t new_size) } } - /* update the protected entry list */ + /* update the pinned entry list */ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pel_len), \ (cache_ptr->pel_size), \ (entry_ptr->size), (new_size)); @@ -2981,8 +2952,8 @@ H5C_mark_pinned_or_protected_entry_dirty(void *thing) } else { - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, \ - "Entry is neither pinned nor protected??") + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, \ + "Entry is neither pinned nor protected??") } done: @@ -3020,7 +2991,7 @@ done: * Updated function to support renaming of pinned entries. * * JRM -- 8/24/06 - * Updated function to refrain from alterning the index, the + * Updated function to refrain from altering the index, the * replacement policy data structures, and skip list when * the function is called within the flush callback for the * target entry and the target entry is being destroyed. @@ -3035,20 +3006,19 @@ done: * *------------------------------------------------------------------------- */ - herr_t H5C_rename_entry(H5C_t * cache_ptr, const H5C_class_t * type, haddr_t old_addr, haddr_t new_addr) { - herr_t ret_value = SUCCEED; /* Return value */ - hbool_t was_dirty; + hbool_t was_dirty; H5C_cache_entry_t * entry_ptr = NULL; H5C_cache_entry_t * test_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - hbool_t removed_entry_from_slist = FALSE; + hbool_t removed_entry_from_slist = FALSE; #endif /* H5C_DO_SANITY_CHECKS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_rename_entry, FAIL) @@ -3213,7 +3183,7 @@ H5C_resize_pinned_entry(void *thing, size_t new_size) { H5C_t * cache_ptr; H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)thing; - size_t size_increase; + size_t size_increase; hbool_t was_clean; herr_t ret_value = SUCCEED; /* Return value */ @@ -3252,13 +3222,8 @@ H5C_resize_pinned_entry(void *thing, size_t new_size) size_increase = new_size - entry_ptr->size; - if ( size_increase >= - cache_ptr->flash_size_increase_threshold ) { - - - if(H5C__flash_increase_cache_size(cache_ptr, - entry_ptr->size, - new_size) < 0) + if(size_increase >= cache_ptr->flash_size_increase_threshold) { + if(H5C__flash_increase_cache_size(cache_ptr, entry_ptr->size, new_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "flash cache increase failed") } } @@ -3440,9 +3405,9 @@ done: * make space in the cache. * * JRM -- 11/12/04 - * Added code to call to H5C_make_space_in_cache() after the - * call to H5C__auto_adjust_cache_size() if that function - * sets the size_decreased flag is TRUE. + * Added code to call to H5C_make_space_in_cache() + * after the call to H5C__auto_adjust_cache_size() if that + * function sets the size_decreased flag is TRUE. * * JRM -- 4/25/05 * The size_decreased flag can also be set to TRUE in @@ -3499,7 +3464,6 @@ done: * *------------------------------------------------------------------------- */ - void * H5C_protect(H5F_t * f, hid_t primary_dxpl_id, @@ -3510,8 +3474,7 @@ H5C_protect(H5F_t * f, void * udata2, unsigned flags) { - /* const char * fcn_name = "H5C_protect()"; */ - H5C_t * cache_ptr; + H5C_t * cache_ptr; hbool_t hit; hbool_t first_flush; hbool_t have_write_permitted = FALSE; @@ -3528,7 +3491,9 @@ H5C_protect(H5F_t * f, /* check args */ HDassert( f ); HDassert( f->shared ); + cache_ptr = f->shared->cache; + HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); @@ -3561,9 +3526,11 @@ H5C_protect(H5F_t * f, HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") hit = TRUE; - thing = (void *)entry_ptr; + thing = (void *)entry_ptr; + + } else { - } else { /* must try to load the entry from disk. */ + /* must try to load the entry from disk. */ hit = FALSE; @@ -3577,20 +3544,20 @@ H5C_protect(H5F_t * f, entry_ptr = (H5C_cache_entry_t *)thing; - /* If the entry is very large, and we are configured to allow it, - * we may wish to perform a flash cache size increase. - */ + /* If the entry is very large, and we are configured to allow it, + * we may wish to perform a flash cache size increase. + */ if ( ( cache_ptr->flash_size_increase_possible ) && ( entry_ptr->size > cache_ptr->flash_size_increase_threshold ) ) { result = H5C__flash_increase_cache_size(cache_ptr, 0, - entry_ptr->size); + entry_ptr->size); if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, \ "H5C__flash_increase_cache_size failed.") - } + } } if ( cache_ptr->index_size >= cache_ptr->max_cache_size ) { @@ -3608,16 +3575,12 @@ H5C_protect(H5F_t * f, * regardless if the min_free_space requirement is not met. */ - if ( ( cache_ptr->evictions_enabled ) - && + if ( ( cache_ptr->evictions_enabled ) && ( ( (cache_ptr->index_size + entry_ptr->size) > - cache_ptr->max_cache_size - ) + cache_ptr->max_cache_size) || - ( - ( ( empty_space + cache_ptr->clean_index_size ) < - cache_ptr->min_clean_size ) - ) + ( ( empty_space + cache_ptr->clean_index_size ) < + cache_ptr->min_clean_size ) ) ) { @@ -3679,18 +3642,22 @@ H5C_protect(H5F_t * f, * * Second, when writes are not permitted it is also possible * for the cache to grow without bound. + * + * Third, the user may choose to disable evictions -- causing + * the cache to grow without bound until evictions are + * re-enabled. * * Finally, we usually don't check to see if the cache is * oversized at the end of an unprotect. As a result, it is * possible to have a vastly oversized cache with no protected * entries as long as all the protects preceed the unprotects. * - * Since items 1 and 2 are not changing any time soon, I see - * no point in worrying about the third. + * Since items 1, 2, and 3 are not changing any time soon, I + * see no point in worrying about the fourth. */ result = H5C_make_space_in_cache(f, primary_dxpl_id, - secondary_dxpl_id, cache_ptr, + secondary_dxpl_id, space_needed, write_permitted, &first_flush); @@ -3767,7 +3734,7 @@ H5C_protect(H5F_t * f, ret_value = thing; if ( ( cache_ptr->evictions_enabled ) && - ( ( cache_ptr->size_decreased ) || + ( ( cache_ptr->size_decreased ) || ( ( cache_ptr->resize_enabled ) && ( cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length ) ) ) ) { @@ -3805,8 +3772,7 @@ H5C_protect(H5F_t * f, ( cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length ) ) { - result = H5C__auto_adjust_cache_size(cache_ptr, - f, + result = H5C__auto_adjust_cache_size(f, primary_dxpl_id, secondary_dxpl_id, write_permitted, @@ -3852,7 +3818,7 @@ H5C_protect(H5F_t * f, } result = H5C_make_space_in_cache(f, primary_dxpl_id, - secondary_dxpl_id, cache_ptr, + secondary_dxpl_id, (size_t)0, write_permitted, &first_flush); @@ -3870,7 +3836,6 @@ done: #if H5C_DO_EXTREME_SANITY_CHECKS if ( H5C_validate_lru_list(cache_ptr) < 0 ) { - HDassert(0); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, \ "LRU sanity check failed.\n"); } @@ -3949,12 +3914,11 @@ done: * in cache size. * * JRM -- 12/31/07 - * Added code supporting the new flash cache size increase - * code. + * Added code supporting the new flash cache size increase + * code. * *------------------------------------------------------------------------- */ - herr_t H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr) @@ -4087,7 +4051,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, if ( config_ptr->max_size == config_ptr->min_size ) { cache_ptr->size_increase_possible = FALSE; - cache_ptr->flash_size_increase_possible = FALSE; + cache_ptr->flash_size_increase_possible = FALSE; cache_ptr->size_decrease_possible = FALSE; } @@ -4195,7 +4159,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, { case H5C_flash_incr__off: cache_ptr->flash_size_increase_possible = FALSE; - break; + break; case H5C_flash_incr__add_space: cache_ptr->flash_size_increase_possible = TRUE; @@ -4206,9 +4170,9 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, break; default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Unknown flash_incr_mode?!?!?.") - break; + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "Unknown flash_incr_mode?!?!?.") + break; } } @@ -4222,21 +4186,20 @@ done: /*------------------------------------------------------------------------- * Function: H5C_set_evictions_enabled() * - * Purpose: Set cache_ptr->evictions_enabled to the value of the - * evictions enabled parameter. + * Purpose: Set cache_ptr->evictions_enabled to the value of the + * evictions enabled parameter. * * Return: SUCCEED on success, and FAIL on failure. * * Programmer: John Mainzer - * 7/27/07 + * 7/27/07 * * Modifications: * - * None. + * None. * *------------------------------------------------------------------------- */ - herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) @@ -4253,7 +4216,7 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, if ( ( evictions_enabled != TRUE ) && ( evictions_enabled != FALSE ) ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Bad evictions_enabled on entry.") + "Bad evictions_enabled on entry.") } /* There is no fundamental reason why we should not permit @@ -4267,7 +4230,7 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, ( cache_ptr->resize_ctl.decr_mode != H5C_decr__off ) ) ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Can't disable evictions when auto resize enabled.") + "Can't disable evictions when auto resize enabled.") } cache_ptr->evictions_enabled = evictions_enabled; @@ -4680,11 +4643,11 @@ H5C_stats(H5C_t * cache_ptr, hit_rate); HDfprintf(stdout, - "%s Total write / read (max) protects = %ld / %ld (%d)\n", + "%s Total write / read (max) protects = %ld / %ld (%ld)\n", cache_ptr->prefix, (long)total_write_protects, (long)total_read_protects, - max_read_protects); + (long)max_read_protects); HDfprintf(stdout, "%s Total clears / flushes / evictions = %ld / %ld / %ld\n", @@ -5102,10 +5065,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_unpin_entry(void *thing) +H5C_unpin_entry(void *_entry_ptr) { H5C_t * cache_ptr; - H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)thing; /* Pointer to entry to unpin */ + H5C_cache_entry_t * entry_ptr = (H5C_cache_entry_t *)_entry_ptr; /* Pointer to entry to unpin */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_unpin_entry, FAIL) @@ -5264,11 +5227,11 @@ H5C_unprotect(H5F_t * f, #ifdef H5_HAVE_PARALLEL hbool_t clear_entry = FALSE; #endif /* H5_HAVE_PARALLEL */ - herr_t ret_value = SUCCEED; /* Return value */ herr_t result; - size_t size_increase = 0; + size_t size_increase = 0; H5C_cache_entry_t * entry_ptr; H5C_cache_entry_t * test_entry_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5C_unprotect, FAIL) @@ -5434,7 +5397,7 @@ H5C_unprotect(H5F_t * f, if ( result < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "H5C__flash_increase_cache_size failed.") + "H5C__flash_increase_cache_size failed.") } } } @@ -5557,7 +5520,6 @@ H5C_unprotect(H5F_t * f, if ( H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, type, addr, flush_flags, @@ -5595,7 +5557,6 @@ H5C_unprotect(H5F_t * f, if ( H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, type, addr, H5C__FLUSH_CLEAR_ONLY_FLAG, @@ -5643,7 +5604,7 @@ done: * * Added validation for the flash increment fields. * - * JRM -- 12/31/07 + * JRM -- 12/31/07 * *------------------------------------------------------------------------- */ @@ -5745,7 +5706,7 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, ( config_ptr->apply_max_increment != FALSE ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "apply_max_increment must be either TRUE or FALSE"); + "apply_max_increment must be either TRUE or FALSE"); } /* no need to check max_increment, as it is a size_t, @@ -5755,11 +5716,11 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, switch ( config_ptr->flash_incr_mode ) { - case H5C_flash_incr__off: + case H5C_flash_incr__off: /* nothing to do here */ - break; + break; - case H5C_flash_incr__add_space: + case H5C_flash_incr__add_space: if ( ( config_ptr->flash_multiple < 0.1 ) || ( config_ptr->flash_multiple > 10.0 ) ) { @@ -5771,15 +5732,15 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, ( config_ptr->flash_threshold > 1.0 ) ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "flash_threshold must be in the range [0.1, 1.0]"); + "flash_threshold must be in the range [0.1, 1.0]"); } - break; + break; - default: + default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "Invalid flash_incr_mode"); - break; - } + "Invalid flash_incr_mode"); + break; + } } /* H5C_RESIZE_CFG__VALIDATE_INCREMENT */ @@ -6266,20 +6227,18 @@ done: * H5C_auto_size_ctl_t structure. * * JRM -- 1/5/08 - * Added support for flash cache size increases. + * Added support for flash cache size increases. * *------------------------------------------------------------------------- */ - static herr_t -H5C__auto_adjust_cache_size(H5C_t * cache_ptr, - H5F_t * f, +H5C__auto_adjust_cache_size(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, hbool_t write_permitted, hbool_t * first_flush_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = f->shared->cache; herr_t result; hbool_t inserted_epoch_marker = FALSE; size_t new_max_cache_size = 0; @@ -6288,9 +6247,11 @@ H5C__auto_adjust_cache_size(H5C_t * cache_ptr, size_t old_min_clean_size = 0; double hit_rate; enum H5C_resize_status status = in_spec; /* will change if needed */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5C__auto_adjust_cache_size) + HDassert( f ); HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->cache_accesses >= @@ -6475,11 +6436,10 @@ H5C__auto_adjust_cache_size(H5C_t * cache_ptr, } else { - result = H5C__autoadjust__ageout(cache_ptr, + result = H5C__autoadjust__ageout(f, hit_rate, &status, &new_max_cache_size, - f, primary_dxpl_id, secondary_dxpl_id, write_permitted, @@ -6552,14 +6512,15 @@ H5C__auto_adjust_cache_size(H5C_t * cache_ptr, cache_ptr->size_decreased = TRUE; } - /* update flash cache size increase fields as appropriate */ - if ( cache_ptr->flash_size_increase_possible ) { + /* update flash cache size increase fields as appropriate */ + if ( cache_ptr->flash_size_increase_possible ) { switch ( (cache_ptr->resize_ctl).flash_incr_mode ) { case H5C_flash_incr__off: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "flash_size_increase_possible but H5C_flash_incr__off?!") + "flash_size_increase_possible but H5C_flash_incr__off?!") break; case H5C_flash_incr__add_space: @@ -6567,7 +6528,7 @@ H5C__auto_adjust_cache_size(H5C_t * cache_ptr, (size_t) (((double)(cache_ptr->max_cache_size)) * ((cache_ptr->resize_ctl).flash_threshold)); - break; + break; default: /* should be unreachable */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ @@ -6627,24 +6588,24 @@ done: * *------------------------------------------------------------------------- */ - static herr_t -H5C__autoadjust__ageout(H5C_t * cache_ptr, +H5C__autoadjust__ageout(H5F_t * f, double hit_rate, enum H5C_resize_status * status_ptr, size_t * new_max_cache_size_ptr, - H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, hbool_t write_permitted, hbool_t * first_flush_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = f->shared->cache; herr_t result; size_t test_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5C__autoadjust__ageout) + HDassert( f ); HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( ( status_ptr ) && ( *status_ptr == in_spec ) ); @@ -6676,21 +6637,9 @@ H5C__autoadjust__ageout(H5C_t * cache_ptr, if ( cache_ptr->max_cache_size > (cache_ptr->resize_ctl).min_size ){ /* evict aged out cache entries if appropriate... */ - result = H5C__autoadjust__ageout__evict_aged_out_entries - ( - f, - primary_dxpl_id, - secondary_dxpl_id, - cache_ptr, - write_permitted, - first_flush_ptr - ); - - if ( result != SUCCEED ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "error flushing aged out entries.") - } + if(H5C__autoadjust__ageout__evict_aged_out_entries(f, primary_dxpl_id, + secondary_dxpl_id, write_permitted, first_flush_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error flushing aged out entries.") /* ... and then reduce cache size if appropriate */ if ( cache_ptr->index_size < cache_ptr->max_cache_size ) { @@ -6910,26 +6859,26 @@ done: * *------------------------------------------------------------------------- */ - static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, hbool_t write_permitted, hbool_t * first_flush_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = f->shared->cache; herr_t result; size_t eviction_size_limit; size_t bytes_evicted = 0; - hbool_t prev_is_dirty = FALSE; + hbool_t prev_is_dirty = FALSE; H5C_cache_entry_t * entry_ptr; H5C_cache_entry_t * next_ptr; H5C_cache_entry_t * prev_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5C__autoadjust__ageout__evict_aged_out_entries) + HDassert( f ); HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); @@ -6971,7 +6920,6 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, entry_ptr->addr, H5C__NO_FLAGS_SET, @@ -6984,7 +6932,6 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, entry_ptr->addr, H5C__FLUSH_INVALIDATE_FLAG, @@ -7002,24 +6949,24 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, #ifndef NDEBUG if ( prev_ptr->magic != H5C__H5C_CACHE_ENTRY_T_MAGIC ) { - /* something horrible has happened to *prev_ptr -- - * scream and die. - */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "*prev_ptr corrupt") + /* something horrible has happened to *prev_ptr -- + * scream and die. + */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "*prev_ptr corrupt") } else #endif /* NDEBUG */ if ( ( prev_ptr->is_dirty != prev_is_dirty ) - || - ( prev_ptr->next != next_ptr ) - || - ( prev_ptr->is_protected ) - || - ( prev_ptr->is_pinned ) ) { + || + ( prev_ptr->next != next_ptr ) + || + ( prev_ptr->is_protected ) + || + ( prev_ptr->is_pinned ) ) { /* something has happened to the LRU -- start over - * from the tail. + * from the tail. */ entry_ptr = cache_ptr->LRU_tail_ptr; @@ -7028,11 +6975,11 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, entry_ptr = prev_ptr; } - } else { + } else { - entry_ptr = NULL; + entry_ptr = NULL; - } + } } /* end while */ /* for now at least, don't bother to maintain the minimum clean size, @@ -7083,7 +7030,6 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, entry_ptr->addr, H5C__FLUSH_INVALIDATE_FLAG, @@ -7376,12 +7322,13 @@ done: } /* H5C__autoadjust__ageout__remove_excess_markers() */ + /*------------------------------------------------------------------------- * - * Function: H5C__flash_increase_cache_size + * Function: H5C__flash_increase_cache_size * - * Purpose: If there is not at least new_entry_size - old_entry_size - * bytes of free space in the cache and the current + * Purpose: If there is not at least new_entry_size - old_entry_size + * bytes of free space in the cache and the current * max_cache_size is less than (cache_ptr->resize_ctl).max_size, * perform a flash increase in the cache size and then reset * the full cache hit rate statistics, and exit. @@ -7392,27 +7339,26 @@ done: * * Modifications: * - * None. + * None. * *------------------------------------------------------------------------- */ - static herr_t H5C__flash_increase_cache_size(H5C_t * cache_ptr, size_t old_entry_size, size_t new_entry_size) { - /* const char * fcn_name = "H5C__flash_increase_cache_size()";*/ - herr_t ret_value = SUCCEED; /* Return value */ - size_t new_max_cache_size = 0; - size_t old_max_cache_size = 0; - size_t new_min_clean_size = 0; - size_t old_min_clean_size = 0; - size_t space_needed; - enum H5C_resize_status status = flash_increase; /* may change */ - double hit_rate; + size_t new_max_cache_size = 0; + size_t old_max_cache_size = 0; + size_t new_min_clean_size = 0; + size_t old_min_clean_size = 0; + size_t space_needed; + enum H5C_resize_status status = flash_increase; /* may change */ + double hit_rate; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5C__flash_increase_cache_size) + HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->flash_size_increase_possible ); @@ -7428,7 +7374,7 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, space_needed = new_entry_size - old_entry_size; if ( ( (cache_ptr->index_size + space_needed) > - cache_ptr->max_cache_size ) && + cache_ptr->max_cache_size ) && ( cache_ptr->max_cache_size < (cache_ptr->resize_ctl).max_size ) ) { /* we have work to do */ @@ -7441,15 +7387,16 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, break; case H5C_flash_incr__add_space: - if ( cache_ptr->index_size < cache_ptr->max_cache_size ) { + if ( cache_ptr->index_size < cache_ptr->max_cache_size ) { - HDassert( (cache_ptr->max_cache_size - cache_ptr->index_size) - < space_needed ); - space_needed -= cache_ptr->max_cache_size - cache_ptr->index_size; - } - space_needed = - (size_t)(((double)space_needed) * - (cache_ptr->resize_ctl).flash_multiple); + HDassert( (cache_ptr->max_cache_size - cache_ptr->index_size) + < space_needed ); + space_needed -= cache_ptr->max_cache_size - + cache_ptr->index_size; + } + space_needed = + (size_t)(((double)space_needed) * + (cache_ptr->resize_ctl).flash_multiple); new_max_cache_size = cache_ptr->max_cache_size + space_needed; @@ -7463,7 +7410,7 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, if ( new_max_cache_size > (cache_ptr->resize_ctl).max_size ) { - new_max_cache_size = (cache_ptr->resize_ctl).max_size; + new_max_cache_size = (cache_ptr->resize_ctl).max_size; } HDassert( new_max_cache_size > cache_ptr->max_cache_size ); @@ -7487,7 +7434,7 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, { case H5C_flash_incr__off: HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "flash_size_increase_possible but H5C_flash_incr__off?!") + "flash_size_increase_possible but H5C_flash_incr__off?!") break; case H5C_flash_incr__add_space: @@ -7504,15 +7451,15 @@ H5C__flash_increase_cache_size(H5C_t * cache_ptr, } /* note that we don't cycle the epoch markers. We can - * argue either way as to whether we should, but for now - * we don't. - */ + * argue either way as to whether we should, but for now + * we don't. + */ if ( (cache_ptr->resize_ctl).rpt_fcn != NULL ) { - /* get the hit rate for the reporting function. Should still - * be good as we havent reset the hit rate statistics. - */ + /* get the hit rate for the reporting function. Should still + * be good as we havent reset the hit rate statistics. + */ if ( H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED ) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate.") @@ -7601,19 +7548,18 @@ done: * but one can argue that I should just scream and die if I * ever detect the condidtion. * - * -- JRM 10/13/07 + * -- JRM 10/13/07 * *------------------------------------------------------------------------- */ -herr_t -H5C_flush_invalidate_cache(H5F_t * f, +static herr_t +H5C_flush_invalidate_cache(const H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, unsigned flags) { + H5C_t * cache_ptr = f->shared->cache; herr_t status; - herr_t ret_value = SUCCEED; hbool_t first_flush = TRUE; int32_t protected_entries = 0; int32_t i; @@ -7630,9 +7576,11 @@ H5C_flush_invalidate_cache(H5F_t * f, size_t actual_slist_size = 0; size_t initial_slist_size = 0; #endif /* H5C_DO_SANITY_CHECKS */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5C_flush_invalidate_cache, FAIL) + HDassert( f ); HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); @@ -7727,6 +7675,7 @@ H5C_flush_invalidate_cache(H5F_t * f, HDassert( next_entry_ptr->in_slist ); } + #if H5C_DO_SANITY_CHECKS /* Depending on circumstances, H5C_flush_single_entry() will * remove dirty entries from the slist as it flushes them. @@ -7818,7 +7767,7 @@ H5C_flush_invalidate_cache(H5F_t * f, HDassert( next_entry_ptr->in_slist ); } else { next_entry_ptr = NULL; - } + } /* Note that we now remove nodes from the slist as we flush * the associated entries, instead of leaving them there @@ -7867,7 +7816,6 @@ H5C_flush_invalidate_cache(H5F_t * f, status = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, NULL, entry_ptr->addr, H5C__NO_FLAGS_SET, @@ -7894,11 +7842,9 @@ H5C_flush_invalidate_cache(H5F_t * f, status = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, NULL, entry_ptr->addr, - (cooked_flags | - H5C__FLUSH_INVALIDATE_FLAG), + (cooked_flags | H5C__FLUSH_INVALIDATE_FLAG), &first_flush, TRUE); if ( status < 0 ) { @@ -7955,6 +7901,9 @@ H5C_flush_invalidate_cache(H5F_t * f, while ( next_entry_ptr != NULL ) { entry_ptr = next_entry_ptr; +#ifndef NDEBUG + HDassert( entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC ); +#endif /* NDEBUG */ next_entry_ptr = entry_ptr->ht_next; HDassert ( ( next_entry_ptr == NULL ) || @@ -7979,11 +7928,9 @@ H5C_flush_invalidate_cache(H5F_t * f, status = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, NULL, entry_ptr->addr, - (cooked_flags | - H5C__FLUSH_INVALIDATE_FLAG), + (cooked_flags | H5C__FLUSH_INVALIDATE_FLAG), &first_flush, TRUE); if ( status < 0 ) { @@ -8213,16 +8160,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5C_flush_single_entry(H5F_t * f, +H5C_flush_single_entry(const H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, const H5C_class_t * type_ptr, haddr_t addr, unsigned flags, hbool_t * first_flush_ptr, hbool_t del_entry_from_slist_on_destroy) { + H5C_t * cache_ptr = f->shared->cache; hbool_t destroy; hbool_t clear_only; hbool_t take_ownership; @@ -8231,12 +8178,12 @@ H5C_flush_single_entry(H5F_t * f, herr_t status; int type_id; unsigned flush_flags = H5C_CALLBACK__NO_FLAGS_SET; - H5C_cache_entry_t * entry_ptr = NULL; + H5C_cache_entry_t * entry_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5C_flush_single_entry) - + HDassert( f ); HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); @@ -8288,8 +8235,8 @@ H5C_flush_single_entry(H5F_t * f, */ else { HDfprintf(stdout, - "H5C_flush_single_entry(): non-existant entry. addr = %a\n", - addr); + "H5C_flush_single_entry(): non-existant entry. addr = %a\n", + addr); HDfflush(stdout); } #endif @@ -8414,38 +8361,56 @@ H5C_flush_single_entry(H5F_t * f, if ( destroy ) { /* AKA eviction */ #if 0 /* JRM */ - /* This test code may come in handy -- lets keep it for a while */ + /* This test code may come in handy -- lets keep it for a while. + * + * Note that it will cause spurious errors in the serial case + * unless we are maintaining the clean and dirty LRU lists. + */ { if ( entry_ptr->is_dirty ) { if ( cache_ptr->dLRU_head_ptr == NULL ) - HDfprintf(stdout,"cache_ptr->dLRU_head_ptr == NULL.\n"); + HDfprintf(stdout, + "%s: cache_ptr->dLRU_head_ptr == NULL.\n", + FUNC); if ( cache_ptr->dLRU_tail_ptr == NULL ) - HDfprintf(stdout,"cache_ptr->dLRU_tail_ptr == NULL.\n"); + HDfprintf(stdout, + "%s: cache_ptr->dLRU_tail_ptr == NULL.\n", + FUNC); if ( cache_ptr->dLRU_list_len <= 0 ) - HDfprintf(stdout,"cache_ptr->dLRU_list_len <= 0.\n"); + HDfprintf(stdout, + "%s: cache_ptr->dLRU_list_len <= 0.\n", + FUNC); if ( cache_ptr->dLRU_list_size <= 0 ) - HDfprintf(stdout,"cache_ptr->dLRU_list_size <= 0.\n"); + HDfprintf(stdout, + "%s: cache_ptr->dLRU_list_size <= 0.\n", + FUNC); if ( cache_ptr->dLRU_list_size < entry_ptr->size ) HDfprintf(stdout, - "cache_ptr->dLRU_list_size < entry_ptr->size.\n"); + "%s: cache_ptr->dLRU_list_size < entry_ptr->size.\n", + FUNC); if ( ( (cache_ptr->dLRU_list_size) == entry_ptr->size ) && ( ! ( (cache_ptr->dLRU_list_len) == 1 ) ) ) HDfprintf(stdout, - "dLRU_list_size == size && dLRU_list_len != 1\n"); + "%s: dLRU_list_size == size && dLRU_list_len != 1\n", + FUNC); if ( ( entry_ptr->aux_prev == NULL ) && ( cache_ptr->dLRU_head_ptr != entry_ptr ) ) - HDfprintf(stdout, "entry_ptr->aux_prev == NULL && dLRU_head_ptr != entry_ptr\n"); + HDfprintf(stdout, + "%s: entry_ptr->aux_prev == NULL && dLRU_head_ptr != entry_ptr\n", + FUNC); if ( ( entry_ptr->aux_next == NULL ) && ( cache_ptr->dLRU_tail_ptr != entry_ptr ) ) - HDfprintf(stdout, "entry_ptr->aux_next == NULL && dLRU_tail_ptr != entry_ptr\n"); + HDfprintf(stdout, + "%s: entry_ptr->aux_next == NULL && dLRU_tail_ptr != entry_ptr\n", + FUNC); if ( ( cache_ptr->dLRU_list_len == 1 ) && ( ! ( ( cache_ptr->dLRU_head_ptr == entry_ptr ) && @@ -8457,40 +8422,52 @@ H5C_flush_single_entry(H5F_t * f, ) ) { - HDfprintf(stdout, "single entry dlru sanity check fails\n"); + HDfprintf(stdout, + "%s: single entry dlru sanity check fails\n", + FUNC); } } else { if ( cache_ptr->cLRU_head_ptr == NULL ) - HDfprintf(stdout,"cache_ptr->cLRU_head_ptr == NULL.\n"); + HDfprintf(stdout, + "%s: cache_ptr->cLRU_head_ptr == NULL.\n", + FUNC); if ( cache_ptr->cLRU_tail_ptr == NULL ) - HDfprintf(stdout,"cache_ptr->cLRU_tail_ptr == NULL.\n"); + HDfprintf(stdout, + "%s: cache_ptr->cLRU_tail_ptr == NULL.\n", + FUNC); if ( cache_ptr->cLRU_list_len <= 0 ) - HDfprintf(stdout,"cache_ptr->cLRU_list_len <= 0.\n"); + HDfprintf(stdout, + "%s: cache_ptr->cLRU_list_len <= 0.\n", + FUNC); if ( cache_ptr->cLRU_list_size <= 0 ) - HDfprintf(stdout,"cache_ptr->cLRU_list_size <= 0.\n"); + HDfprintf(stdout, + "%s: cache_ptr->cLRU_list_size <= 0.\n", + FUNC); if ( cache_ptr->cLRU_list_size < entry_ptr->size ) HDfprintf(stdout, - "cache_ptr->cLRU_list_size < entry_ptr->size.\n"); + "%s: cache_ptr->cLRU_list_size < entry_ptr->size.\n", + FUNC); if ( ( (cache_ptr->cLRU_list_size) == entry_ptr->size ) && ( ! ( (cache_ptr->cLRU_list_len) == 1 ) ) ) HDfprintf(stdout, - "cLRU_list_size == size && cLRU_list_len != 1\n"); + "%s: cLRU_list_size == size && cLRU_list_len != 1\n", + FUNC); if ( ( entry_ptr->aux_prev == NULL ) && ( cache_ptr->cLRU_head_ptr != entry_ptr ) ) - HDfprintf(stdout, "entry_ptr->aux_prev == NULL && cLRU_head_ptr != entry_ptr\n"); + HDfprintf(stdout, "%s: entry_ptr->aux_prev == NULL && cLRU_head_ptr != entry_ptr\n", FUNC); if ( ( entry_ptr->aux_next == NULL ) && ( cache_ptr->cLRU_tail_ptr != entry_ptr ) ) - HDfprintf(stdout, "entry_ptr->aux_next == NULL && cLRU_tail_ptr != entry_ptr\n"); + HDfprintf(stdout, "%s: entry_ptr->aux_next == NULL && cLRU_tail_ptr != entry_ptr\n", FUNC); if ( ( cache_ptr->cLRU_list_len == 1 ) && ( ! ( ( cache_ptr->cLRU_head_ptr == entry_ptr ) && @@ -8502,7 +8479,9 @@ H5C_flush_single_entry(H5F_t * f, ) ) { - HDfprintf(stdout, "single entry clru sanity check fails\n"); + HDfprintf(stdout, + "%s: single entry clru sanity check fails\n", + FUNC); } } } @@ -8779,7 +8758,6 @@ done: * *------------------------------------------------------------------------- */ - static void * H5C_load_entry(H5F_t * f, hid_t dxpl_id, @@ -8800,6 +8778,9 @@ H5C_load_entry(H5F_t * f, FUNC_ENTER_NOAPI_NOINIT(H5C_load_entry) + HDassert( f ); + HDassert( f->shared ); + HDassert( f->shared->cache ); HDassert( skip_file_checks || f ); HDassert( type ); HDassert( type->load ); @@ -8839,21 +8820,21 @@ H5C_load_entry(H5F_t * f, HDassert( ( entry_ptr->is_dirty == FALSE ) || ( type->id == 5 ) ); #ifndef NDEBUG - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; + entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; #endif /* NDEBUG */ - entry_ptr->cache_ptr = f->shared->cache; - entry_ptr->addr = addr; - entry_ptr->type = type; - entry_ptr->is_protected = FALSE; - entry_ptr->is_read_only = FALSE; - entry_ptr->ro_ref_count = 0; - entry_ptr->in_slist = FALSE; - entry_ptr->flush_marker = FALSE; + entry_ptr->cache_ptr = f->shared->cache; + entry_ptr->addr = addr; + entry_ptr->type = type; + entry_ptr->is_protected = FALSE; + entry_ptr->is_read_only = FALSE; + entry_ptr->ro_ref_count = 0; + entry_ptr->in_slist = FALSE; + entry_ptr->flush_marker = FALSE; #ifdef H5_HAVE_PARALLEL - entry_ptr->clear_on_unprotect = FALSE; + entry_ptr->clear_on_unprotect = FALSE; #endif /* H5_HAVE_PARALLEL */ - entry_ptr->flush_in_progress = FALSE; - entry_ptr->destroy_in_progress = FALSE; + entry_ptr->flush_in_progress = FALSE; + entry_ptr->destroy_in_progress = FALSE; entry_ptr->free_file_space_on_destroy = FALSE; if ( (type->size)(f, thing, &(entry_ptr->size)) < 0 ) { @@ -8873,11 +8854,11 @@ H5C_load_entry(H5F_t * f, entry_ptr->ht_next = NULL; entry_ptr->ht_prev = NULL; - entry_ptr->next = NULL; - entry_ptr->prev = NULL; + entry_ptr->next = NULL; + entry_ptr->prev = NULL; - entry_ptr->aux_next = NULL; - entry_ptr->aux_prev = NULL; + entry_ptr->aux_next = NULL; + entry_ptr->aux_prev = NULL; H5C__RESET_CACHE_ENTRY_STATS(entry_ptr); @@ -8984,17 +8965,15 @@ done: * scanned statistics. *------------------------------------------------------------------------- */ - static herr_t H5C_make_space_in_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, - H5C_t * cache_ptr, size_t space_needed, hbool_t write_permitted, hbool_t * first_flush_ptr) { - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t * cache_ptr = f->shared->cache; herr_t result; #if H5C_COLLECT_CACHE_STATS int32_t clean_entries_skipped = 0; @@ -9003,14 +8982,16 @@ H5C_make_space_in_cache(H5F_t * f, int32_t entries_examined = 0; int32_t initial_list_len; size_t empty_space; - hbool_t prev_is_dirty = FALSE; + hbool_t prev_is_dirty = FALSE; hbool_t didnt_flush_entry = FALSE; H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * next_ptr; H5C_cache_entry_t * prev_ptr; + H5C_cache_entry_t * next_ptr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5C_make_space_in_cache) + HDassert( f ); HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( first_flush_ptr != NULL ); @@ -9055,13 +9036,13 @@ H5C_make_space_in_cache(H5F_t * f, HDassert( ! (entry_ptr->is_read_only) ); HDassert( (entry_ptr->ro_ref_count) == 0 ); - next_ptr = entry_ptr->next; - prev_ptr = entry_ptr->prev; + next_ptr = entry_ptr->next; + prev_ptr = entry_ptr->prev; if ( prev_ptr != NULL ) { - prev_is_dirty = prev_ptr->is_dirty; - } + prev_is_dirty = prev_ptr->is_dirty; + } if ( (entry_ptr->type)->id != H5C__EPOCH_MARKER_TYPE ) { @@ -9080,7 +9061,6 @@ H5C_make_space_in_cache(H5F_t * f, result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, entry_ptr->addr, H5C__NO_FLAGS_SET, @@ -9096,7 +9076,6 @@ H5C_make_space_in_cache(H5F_t * f, result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, entry_ptr->addr, H5C__FLUSH_INVALIDATE_FLAG, @@ -9136,48 +9115,51 @@ H5C_make_space_in_cache(H5F_t * f, "unable to flush entry") } - if ( prev_ptr != NULL ) { + if ( prev_ptr != NULL ) { #ifndef NDEBUG - if ( prev_ptr->magic != H5C__H5C_CACHE_ENTRY_T_MAGIC ) { + if ( prev_ptr->magic != H5C__H5C_CACHE_ENTRY_T_MAGIC ) { - /* something horrible has happened to *prev_ptr -- - * scream and die. - */ + /* something horrible has happened to *prev_ptr -- + * scream and die. + */ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "*prev_ptr corrupt 1") + "*prev_ptr corrupt 1") } #endif /* NDEBUG */ if ( didnt_flush_entry ) { - entry_ptr = prev_ptr; + /* epoch markers don't get flushed, so the sanity checks + * on normal entries will fail -- thus just set entry_ptr + * to prev_ptr and go on. + */ + entry_ptr = prev_ptr; } else if ( ( prev_ptr->is_dirty != prev_is_dirty ) - || - ( prev_ptr->next != next_ptr ) - || - ( prev_ptr->is_protected ) - || - ( prev_ptr->is_pinned ) ) { - - /* something has happened to the LRU -- start over - * from the tail. - */ - - entry_ptr = cache_ptr->LRU_tail_ptr; + || + ( prev_ptr->next != next_ptr ) + || + ( prev_ptr->is_protected ) + || + ( prev_ptr->is_pinned ) ) { + + /* something has happened to the LRU -- start over + * from the tail. + */ + entry_ptr = cache_ptr->LRU_tail_ptr; - } else { + } else { - entry_ptr = prev_ptr; + entry_ptr = prev_ptr; - } - } else { + } + } else { - entry_ptr = NULL; + entry_ptr = NULL; - } + } - entries_examined++; + entries_examined++; if ( cache_ptr->index_size >= cache_ptr->max_cache_size ) { @@ -9198,7 +9180,6 @@ H5C_make_space_in_cache(H5F_t * f, #if H5C_COLLECT_CACHE_STATS cache_ptr->calls_to_msic++; - cache_ptr->total_entries_skipped_in_msic += clean_entries_skipped; cache_ptr->total_entries_scanned_in_msic += total_entries_scanned; @@ -9255,7 +9236,6 @@ H5C_make_space_in_cache(H5F_t * f, result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, - cache_ptr, entry_ptr->type, entry_ptr->addr, H5C__FLUSH_INVALIDATE_FLAG, @@ -9322,13 +9302,11 @@ H5C_validate_lru_list(H5C_t * cache_ptr) ( cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr ) ) { - HDfprintf(stdout,"H5C_validate_lru_list: Check 1 failed.\n"); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } if ( ( cache_ptr->LRU_list_len < 0 ) || ( cache_ptr->LRU_list_size < 0 ) ) { - HDfprintf(stdout,"H5C_validate_lru_list: Check 2 failed.\n"); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") } @@ -9342,7 +9320,6 @@ H5C_validate_lru_list(H5C_t * cache_ptr) ) ) { - HDfprintf(stdout,"H5C_validate_lru_list: Check 3 failed.\n"); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") } @@ -9358,7 +9335,6 @@ H5C_validate_lru_list(H5C_t * cache_ptr) ) ) { - HDfprintf(stdout,"H5C_validate_lru_list: Check 4 failed.\n"); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") } @@ -9370,7 +9346,6 @@ H5C_validate_lru_list(H5C_t * cache_ptr) ( ( entry_ptr->prev == NULL ) || ( entry_ptr->prev->next != entry_ptr ) ) ) { - HDfprintf(stdout,"H5C_validate_lru_list: Check 5 failed.\n"); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") } @@ -9378,7 +9353,6 @@ H5C_validate_lru_list(H5C_t * cache_ptr) ( ( entry_ptr->next == NULL ) || ( entry_ptr->next->prev != entry_ptr ) ) ) { - HDfprintf(stdout,"H5C_validate_lru_list: Check 6 failed.\n"); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") } @@ -9390,7 +9364,6 @@ H5C_validate_lru_list(H5C_t * cache_ptr) if ( ( cache_ptr->LRU_list_len != len ) || ( cache_ptr->LRU_list_size != size ) ) { - HDfprintf(stdout,"H5C_validate_lru_list: Check 7 failed.\n"); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") } @@ -9455,9 +9428,6 @@ H5C_verify_not_in_index(H5C_t * cache_ptr, { if ( scan_ptr == entry_ptr ) { - HDfprintf(stdout, - "H5C_verify_not_in_index: entry in index (%d/%d)\n", - i, depth); HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ "Entry already in index.") } diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index db68e88..5ffb0ca 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -17,7 +17,7 @@ * Programmer: John Mainzer -- 10/12/04 * * Purpose: This file contains declarations which are normally visible - * only within the H5C package (just H5C.c at present). + * only within the H5C package. * * Source files outside the H5C package should include * H5Cprivate.h instead. @@ -50,6 +50,8 @@ * #define is used to set an upper limit on the number of passes. * The current value was obtained via personal communication with * Quincey. I have applied a fudge factor of 2. + * + * -- JRM */ #define H5C__MAX_PASSES_ON_FLUSH 4 @@ -94,10 +96,11 @@ * * JRM - 9/26/05 * - * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. This - * field is used to validate pointers to instances of H5C_t. + * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. + * This field is used to validate pointers to instances of + * H5C_t. * - * flush_in_progress: Boolean flag indicating whether a flush is in + * flush_in_progress: Boolean flag indicating whether a flush is in * progress. * * trace_file_ptr: File pointer pointing to the trace file, which is used @@ -106,7 +109,7 @@ * no trace file should be recorded. * * Since much of the code supporting the parallel metadata - * cache is in H5AC, we don't write the trace file from + * cache is in H5AC, we don't write the trace file from * H5C. Instead, H5AC reads the trace_file_ptr as needed. * * When we get to using H5C in other places, we may add @@ -123,9 +126,9 @@ * indexed by the ids. * * type_name_table_ptr: Pointer to an array of pointer to char of length - * max_type_id + 1. The strings pointed to by the entries - * in the array are the names of the entry types associated - * with the indexing type IDs. + * max_type_id + 1. The strings pointed to by the entries + * in the array are the names of the entry types associated + * with the indexing type IDs. * * max_cache_size: Nominal maximum number of bytes that may be stored in the * cache. This value should be viewed as a soft limit, as the @@ -179,10 +182,10 @@ * writes. The following field is used to implement this. * * evictions_enabled: Boolean flag that is initialized to TRUE. When - * this flag is set to FALSE, the metadata cache will not + * this flag is set to FALSE, the metadata cache will not * attempt to evict entries to make space for newly protected * entries, and instead the will grow without limit. - * + * * Needless to say, this feature must be used with care. * * @@ -285,7 +288,7 @@ * following two fields have been added. They are only compiled in when * H5C_DO_SANITY_CHECKS is TRUE. * - * slist_len_increase: Number of entries that have been added to the + * slist_len_increase: Number of entries that have been added to the * slist since the last time this field was set to zero. * * slist_size_increase: Total size of all entries that have been added @@ -496,16 +499,16 @@ * we receive a new configuration. * * flash_size_increase_possible: Depending on the configuration data given - * in the resize_ctl field, it may or may not be possible - * for a flash size increase to occur. We set this flag - * whenever we receive a new configuration so as to avoid - * repeated calculations. + * in the resize_ctl field, it may or may not be possible + * for a flash size increase to occur. We set this flag + * whenever we receive a new configuration so as to avoid + * repeated calculations. * * flash_size_increase_threshold: If a flash cache size increase is possible, - * this field is used to store the minimum size of a new entry - * or size increase needed to trigger a flash cache size - * increase. Note that this field must be updated whenever - * the size of the cache is changed. + * this field is used to store the minimum size of a new entry + * or size increase needed to trigger a flash cache size + * increase. Note that this field must be updated whenever + * the size of the cache is changed. * * size_decrease_possible: Depending on the configuration data given * in the resize_ctl field, it may or may not be possible @@ -622,23 +625,23 @@ * equal to the array index has not been in cache when * requested in the current epoch. * - * write_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with - * type id equal to the array index has been write protected - * in the current epoch. + * write_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The + * cells are used to record the number of times an entry with + * type id equal to the array index has been write protected + * in the current epoch. * * Observe that (hits + misses) = (write_protects + read_protects). * - * read_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id - * equal to the array index has been read protected in the - * current epoch. + * read_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The + * cells are used to record the number of times an entry with + * type id equal to the array index has been read protected in + * the current epoch. * * Observe that (hits + misses) = (write_protects + read_protects). * - * max_read_protects: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to maximum number of simultaneous read - * protects on any entry with type id equal to the array index + * max_read_protects: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. + * The cells are used to maximum number of simultaneous read + * protects on any entry with type id equal to the array index * in the current epoch. * * insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells @@ -646,9 +649,9 @@ * id equal to the array index has been inserted into the * cache in the current epoch. * - * pinned_insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry - * with type id equal to the array index has been inserted + * pinned_insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. + * The cells are used to record the number of times an entry + * with type id equal to the array index has been inserted * pinned into the cache in the current epoch. * * clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells @@ -671,13 +674,13 @@ * id equal to the array index has been renamed in the current * epoch. * - * entry_flush_renames: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry + * entry_flush_renames: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. + * The cells are used to record the number of times an entry * with type id equal to the array index has been renamed * during its flush callback in the current epoch. * - * cache_flush_renames: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry + * cache_flush_renames: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. + * The cells are used to record the number of times an entry * with type id equal to the array index has been renamed * during a cache flush in the current epoch. * @@ -716,14 +719,14 @@ * with type id equal to the array index has decreased in * size in the current epoch. * - * entry_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the + * entry_flush_size_changes: Array of int64 of length + * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record + * the number of times an entry with type id equal to the * array index has changed size while in its flush callback. * - * cache_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the + * cache_flush_size_changes: Array of int64 of length + * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record + * the number of times an entry with type id equal to the * array index has changed size during a cache flush * * total_ht_insertions: Number of times entries have been inserted into the @@ -966,10 +969,8 @@ struct H5C_t int64_t pinned_clears[H5C__MAX_NUM_TYPE_IDS + 1]; int64_t size_increases[H5C__MAX_NUM_TYPE_IDS + 1]; int64_t size_decreases[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t entry_flush_size_changes - [H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t cache_flush_size_changes - [H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t entry_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; int64_t total_ht_insertions; int64_t total_ht_deletions; @@ -1022,7 +1023,6 @@ struct H5C_t /***************************** Macro Definitions ****************************/ /****************************************************************************/ - /**************************************************************************** * * We maintain doubly linked lists of instances of H5C_cache_entry_t for a @@ -1449,7 +1449,7 @@ if ( ( (entry_ptr) == NULL ) || \ * More pinned entry stats related updates. * * JRM -- 3/31/07 - * Updated H5C__UPDATE_STATS_FOR_PROTECT() to keep stats on + * Updated H5C__UPDATE_STATS_FOR_PROTECT() to keep stats on * read and write protects. * * MAM -- 1/15/09 diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index dc8d7b1..6f96838 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -30,7 +30,7 @@ #ifndef _H5Cprivate_H #define _H5Cprivate_H -#include "H5Cpublic.h" /*public prototypes */ +#include "H5Cpublic.h" /* public prototypes */ /* Private headers needed by this header */ #include "H5private.h" /* Generic Functions */ @@ -228,7 +228,7 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t * cache_ptr, * * JRM - 4/26/04 * - * magic: Unsigned 32 bit integer that must always be set to + * magic: Unsigned 32 bit integer that must always be set to * H5C__H5C_CACHE_ENTRY_T_MAGIC when the entry is valid. * The field must be set to H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC * just before the entry is freed. @@ -368,7 +368,7 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t * cache_ptr, * * flush_marker: Boolean flag indicating that the entry is to be flushed * the next time H5C_flush_cache() is called with the - * H5AC__FLUSH_MARKED_ENTRIES_FLAG. The flag is reset when + * H5C__FLUSH_MARKED_ENTRIES_FLAG. The flag is reset when * the entry is flushed for whatever reason. * * clear_on_unprotect: Boolean flag used only in PHDF5. When H5C is used @@ -526,32 +526,32 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t * cache_ptr, ****************************************************************************/ #ifndef NDEBUG -#define H5C__H5C_CACHE_ENTRY_T_MAGIC 0x005CAC0A -#define H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC 0xDeadBeef +#define H5C__H5C_CACHE_ENTRY_T_MAGIC 0x005CAC0A +#define H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC 0xDeadBeef #endif /* NDEBUG */ typedef struct H5C_cache_entry_t { #ifndef NDEBUG - uint32_t magic; + uint32_t magic; #endif /* NDEBUG */ - H5C_t * cache_ptr; - haddr_t addr; - size_t size; - const H5C_class_t * type; - hbool_t is_dirty; - hbool_t dirtied; - hbool_t is_protected; - hbool_t is_read_only; - int ro_ref_count; - hbool_t is_pinned; - hbool_t in_slist; - hbool_t flush_marker; + H5C_t * cache_ptr; + haddr_t addr; + size_t size; + const H5C_class_t * type; + hbool_t is_dirty; + hbool_t dirtied; + hbool_t is_protected; + hbool_t is_read_only; + int ro_ref_count; + hbool_t is_pinned; + hbool_t in_slist; + hbool_t flush_marker; #ifdef H5_HAVE_PARALLEL - hbool_t clear_on_unprotect; + hbool_t clear_on_unprotect; #endif /* H5_HAVE_PARALLEL */ - hbool_t flush_in_progress; - hbool_t destroy_in_progress; + hbool_t flush_in_progress; + hbool_t destroy_in_progress; hbool_t free_file_space_on_destroy; /* fields supporting the 'flush dependency' feature: */ @@ -689,55 +689,55 @@ typedef struct H5C_cache_entry_t * cache size can be increased in a single re-size. * * flash_incr_mode: Instance of the H5C_cache_flash_incr_mode enumerated - * type whose value indicates whether and by what algorithm we should - * make flash increases in the size of the cache to accomodate insertion - * of large entries and large increases in the size of a single entry. + * type whose value indicates whether and by what algorithm we should + * make flash increases in the size of the cache to accomodate insertion + * of large entries and large increases in the size of a single entry. * - * The addition of the flash increment mode was occasioned by performance - * problems that appear when a local heap is increased to a size in excess - * of the current cache size. While the existing re-size code dealt with - * this eventually, performance was very bad for the remainder of the - * epoch. + * The addition of the flash increment mode was occasioned by performance + * problems that appear when a local heap is increased to a size in excess + * of the current cache size. While the existing re-size code dealt with + * this eventually, performance was very bad for the remainder of the + * epoch. * - * At present, there are two possible values for the flash_incr_mode: + * At present, there are two possible values for the flash_incr_mode: * - * H5C_flash_incr__off: Don't perform flash increases in the size of - * the cache. + * H5C_flash_incr__off: Don't perform flash increases in the size of + * the cache. * - * H5C_flash_incr__add_space: Let x be either the size of a newly - * newly inserted entry, or the number of bytes by which the - * size of an existing entry has been increased. + * H5C_flash_incr__add_space: Let x be either the size of a newly + * newly inserted entry, or the number of bytes by which the + * size of an existing entry has been increased. * - * If - * x > flash_threshold * current max cache size, + * If + * x > flash_threshold * current max cache size, * - * increase the current maximum cache size by x * flash_multiple - * less any free space in the cache, and start a new epoch. For - * now at least, pay no attention to the maximum increment. + * increase the current maximum cache size by x * flash_multiple + * less any free space in the cache, and start a new epoch. For + * now at least, pay no attention to the maximum increment. * * - * With a little thought, it should be obvious that the above flash - * cache size increase algorithm is not sufficient for all circumstances -- - * for example, suppose the user round robins through - * (1/flash_threshold) +1 groups, adding one data set to each on each - * pass. Then all will increase in size at about the same time, requiring - * the max cache size to at least double to maintain acceptable + * With a little thought, it should be obvious that the above flash + * cache size increase algorithm is not sufficient for all + * circumstances -- for example, suppose the user round robins through + * (1/flash_threshold) +1 groups, adding one data set to each on each + * pass. Then all will increase in size at about the same time, requiring + * the max cache size to at least double to maintain acceptable * performance, however the above flash increment algorithm will not be - * triggered. + * triggered. * - * Hopefully, the add space algorithm detailed above will be sufficient - * for the performance problems encountered to date. However, we should - * expect to revisit the issue. + * Hopefully, the add space algorithm detailed above will be sufficient + * for the performance problems encountered to date. However, we should + * expect to revisit the issue. * * flash_multiple: Double containing the multiple described above in the - * H5C_flash_incr__add_space section of the discussion of the - * flash_incr_mode section. This field is ignored unless flash_incr_mode - * is H5C_flash_incr__add_space. + * H5C_flash_incr__add_space section of the discussion of the + * flash_incr_mode section. This field is ignored unless flash_incr_mode + * is H5C_flash_incr__add_space. * - * flash_threshold: Double containing the factor by which current max cache size - * is multiplied to obtain the size threshold for the add_space flash - * increment algorithm. The field is ignored unless flash_incr_mode is - * H5C_flash_incr__add_space. + * flash_threshold: Double containing the factor by which current max cache + * size is multiplied to obtain the size threshold for the add_space + * flash increment algorithm. The field is ignored unless + * flash_incr_mode is H5C_flash_incr__add_space. * * * Cache size decrease control fields: @@ -853,8 +853,8 @@ typedef struct H5C_cache_entry_t #define H5C__DEF_AR_MIN_CLEAN_FRAC 0.5 #define H5C__DEF_AR_INCREMENT 2.0 #define H5C__DEF_AR_MAX_INCREMENT ((size_t)( 2 * 1024 * 1024)) -#define H5C__DEF_AR_FLASH_MULTIPLE 1.0 -#define H5C__DEV_AR_FLASH_THRESHOLD 0.25 +#define H5C__DEF_AR_FLASH_MULTIPLE 1.0 +#define H5C__DEV_AR_FLASH_THRESHOLD 0.25 #define H5C__DEF_AR_DECREMENT 0.9 #define H5C__DEF_AR_MAX_DECREMENT ((size_t)( 1 * 1024 * 1024)) #define H5C__DEF_AR_EPCHS_B4_EVICT 3 @@ -912,9 +912,10 @@ typedef struct H5C_auto_size_ctl_t hbool_t apply_max_increment; size_t max_increment; - enum H5C_cache_flash_incr_mode flash_incr_mode; - double flash_multiple; - double flash_threshold; + enum H5C_cache_flash_incr_mode flash_incr_mode; + double flash_multiple; + double flash_threshold; + /* size decrease control fields: */ enum H5C_cache_decr_mode decr_mode; @@ -1003,13 +1004,12 @@ typedef struct H5C_auto_size_ctl_t #define H5C__FREE_FILE_SPACE_FLAG 0x0800 #define H5C__TAKE_OWNERSHIP_FLAG 0x1000 - H5_DLL H5C_t * H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, - const char * (* type_name_table_ptr), + const char * (* type_name_table_ptr), H5C_write_permitted_func_t check_write_permitted, - hbool_t write_permitted, + hbool_t write_permitted, H5C_log_flush_func_t log_flush, void * aux_ptr); @@ -1040,8 +1040,7 @@ H5_DLL herr_t H5C_flush_cache(H5F_t * f, H5_DLL herr_t H5C_flush_to_min_clean(H5F_t * f, hid_t primary_dxpl_id, - hid_t secondary_dxpl_id, - H5C_t * cache_ptr); + hid_t secondary_dxpl_id); H5_DLL herr_t H5C_get_cache_auto_resize_config(const H5C_t * cache_ptr, H5C_auto_size_ctl_t *config_ptr); @@ -1081,12 +1080,11 @@ H5_DLL herr_t H5C_insert_entry(H5F_t * f, void * thing, unsigned int flags); -H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t * f, - hid_t primary_dxpl_id, - hid_t secondary_dxpl_id, - H5C_t * cache_ptr, - int32_t ce_array_len, - haddr_t * ce_array_ptr); +H5_DLL herr_t H5C_mark_entries_as_clean(H5F_t * f, + hid_t primary_dxpl_id, + hid_t secondary_dxpl_id, + int32_t ce_array_len, + haddr_t *ce_array_ptr); H5_DLL herr_t H5C_mark_pinned_entry_dirty(void * thing, hbool_t size_changed, diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h index 0a3742b..39ebbe3 100644 --- a/src/H5Cpublic.h +++ b/src/H5Cpublic.h @@ -43,8 +43,8 @@ enum H5C_cache_incr_mode enum H5C_cache_flash_incr_mode { - H5C_flash_incr__off, - H5C_flash_incr__add_space + H5C_flash_incr__off, + H5C_flash_incr__add_space }; enum H5C_cache_decr_mode diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 69a311f..658e64c 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -329,7 +329,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(hdr && H5EA__cache_hdr_dest(f, hdr) < 0) + if(hdr && H5EA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") END_FUNC(STATIC) /* end H5EA__cache_hdr_load() */ @@ -685,7 +685,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(iblock && H5EA__cache_iblock_dest(f, iblock) < 0) + if(iblock && H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") END_FUNC(STATIC) /* end H5EA__cache_iblock_load() */ @@ -960,7 +960,7 @@ H5EA__cache_iblock_dest(H5F_t *f, H5EA_iblock_t *iblock)) } /* end if */ /* Release the index block */ - if(H5EA__iblock_dest(f, iblock) < 0) + if(H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array index block") CATCH @@ -1097,7 +1097,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(sblock && H5EA__cache_sblock_dest(f, sblock) < 0) + if(sblock && H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") END_FUNC(STATIC) /* end H5EA__cache_sblock_load() */ @@ -1362,7 +1362,7 @@ H5EA__cache_sblock_dest(H5F_t *f, H5EA_sblock_t *sblock)) } /* end if */ /* Release the super block */ - if(H5EA__sblock_dest(f, sblock) < 0) + if(H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array super block") CATCH @@ -1497,7 +1497,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(dblock && H5EA__cache_dblock_dest(f, dblock) < 0) + if(dblock && H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") END_FUNC(STATIC) /* end H5EA__cache_dblock_load() */ @@ -1767,7 +1767,7 @@ H5EA__cache_dblock_dest(H5F_t *f, H5EA_dblock_t *dblock)) } /* end if */ /* Release the data block */ - if(H5EA__dblock_dest(f, dblock) < 0) + if(H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "can't free extensible array data block") CATCH @@ -1876,7 +1876,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(dblk_page && H5EA__cache_dblk_page_dest(f, dblk_page) < 0) + if(dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") END_FUNC(STATIC) /* end H5EA__cache_dblk_page_load() */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index 429e9f8..7b42afc 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -310,7 +310,7 @@ H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) } /* end if */ /* Free the data block page itself */ - (void)H5FL_FREE(H5EA_dblk_page_t, dblk_page); + dblk_page = H5FL_FREE(H5EA_dblk_page_t, dblk_page); CATCH diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index 344b9fa..d56e157 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -141,7 +141,7 @@ H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) CATCH if(!ret_value) - if(dblock && H5EA__dblock_dest(hdr->f, dblock) < 0) + if(dblock && H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") END_FUNC(PKG) /* end H5EA__dblock_alloc() */ @@ -230,7 +230,7 @@ CATCH H5E_THROW(H5E_CANTFREE, "unable to release extensible array data block") /* Destroy data block */ - if(H5EA__dblock_dest(hdr->f, dblock) < 0) + if(H5EA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") } /* end if */ @@ -455,7 +455,7 @@ END_FUNC(PKG) /* end H5EA__dblock_delete() */ /* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, -H5EA__dblock_dest(H5F_t UNUSED *f, H5EA_dblock_t *dblock)) +H5EA__dblock_dest(H5EA_dblock_t *dblock)) /* Sanity check */ HDassert(dblock); @@ -479,7 +479,7 @@ H5EA__dblock_dest(H5F_t UNUSED *f, H5EA_dblock_t *dblock)) } /* end if */ /* Free the data block itself */ - (void)H5FL_FREE(H5EA_dblock_t, dblock); + dblock = H5FL_FREE(H5EA_dblock_t, dblock); CATCH diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index 45bb498..769ad30 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -349,7 +349,7 @@ HDfprintf(stderr, "%s: nelmts = %Zu, hdr->data_blk_min_elmts = %u, idx = %u\n", /* Free buffer for elements in index block */ HDassert(idx < hdr->elmt_fac.nalloc); HDassert(hdr->elmt_fac.fac[idx]); - (void)H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); + elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 9920277..734dda0 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -157,7 +157,7 @@ HDfprintf(stderr, "%s: iblock->nsblk_addrs = %Zu\n", FUNC, iblock->nsblk_addrs); CATCH if(!ret_value) - if(iblock && H5EA__iblock_dest(hdr->f, iblock) < 0) + if(iblock && H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") END_FUNC(PKG) /* end H5EA__iblock_alloc() */ @@ -257,7 +257,7 @@ CATCH H5E_THROW(H5E_CANTFREE, "unable to release extensible array index block") /* Destroy index block */ - if(H5EA__iblock_dest(hdr->f, iblock) < 0) + if(H5EA__iblock_dest(iblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") } /* end if */ @@ -432,7 +432,7 @@ END_FUNC(PKG) /* end H5EA__iblock_delete() */ /* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, -H5EA__iblock_dest(H5F_t *f, H5EA_iblock_t *iblock)) +H5EA__iblock_dest(H5EA_iblock_t *iblock)) /* Sanity check */ HDassert(iblock); @@ -440,9 +440,6 @@ H5EA__iblock_dest(H5F_t *f, H5EA_iblock_t *iblock)) /* Check if shared header field has been initialized */ if(iblock->hdr) { - /* Set the shared array header's file context for this operation */ - iblock->hdr->f = f; - /* Check if we've got elements in the index block */ if(iblock->elmts) { /* Free buffer for index block elements */ @@ -473,7 +470,7 @@ H5EA__iblock_dest(H5F_t *f, H5EA_iblock_t *iblock)) } /* end if */ /* Free the index block itself */ - (void)H5FL_FREE(H5EA_iblock_t, iblock); + iblock = H5FL_FREE(H5EA_iblock_t, iblock); CATCH diff --git a/src/H5EApkg.h b/src/H5EApkg.h index 39e6546..319ae51 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -392,7 +392,7 @@ H5_DLL H5EA_iblock_t *H5EA__iblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, H5_DLL herr_t H5EA__iblock_unprotect(H5EA_iblock_t *iblock, hid_t dxpl_id, unsigned cache_flags); H5_DLL herr_t H5EA__iblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id); -H5_DLL herr_t H5EA__iblock_dest(H5F_t *f, H5EA_iblock_t *iblock); +H5_DLL herr_t H5EA__iblock_dest(H5EA_iblock_t *iblock); /* Super block routines */ H5_DLL H5EA_sblock_t *H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, @@ -405,7 +405,7 @@ H5_DLL herr_t H5EA__sblock_unprotect(H5EA_sblock_t *sblock, hid_t dxpl_id, unsigned cache_flags); H5_DLL herr_t H5EA__sblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx); -H5_DLL herr_t H5EA__sblock_dest(H5F_t *f, H5EA_sblock_t *sblock); +H5_DLL herr_t H5EA__sblock_dest(H5EA_sblock_t *sblock); /* Data block routines */ H5_DLL H5EA_dblock_t *H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, @@ -419,7 +419,7 @@ H5_DLL herr_t H5EA__dblock_unprotect(H5EA_dblock_t *dblock, hid_t dxpl_id, unsigned cache_flags); H5_DLL herr_t H5EA__dblock_delete(H5EA_hdr_t *hdr, hid_t dxpl_id, void *parent, haddr_t dblk_addr, size_t dblk_nelmts); -H5_DLL herr_t H5EA__dblock_dest(H5F_t *f, H5EA_dblock_t *dblock); +H5_DLL herr_t H5EA__dblock_dest(H5EA_dblock_t *dblock); /* Data block page routines */ H5_DLL H5EA_dblk_page_t *H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent); diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index c6a4306..44c0a02 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -170,7 +170,7 @@ HDfprintf(stderr, "%s: hdr->dblk_page_nelmts = %Zu, sblock->ndblks = %Zu, sblock CATCH if(!ret_value) - if(sblock && H5EA__sblock_dest(hdr->f, sblock) < 0) + if(sblock && H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") END_FUNC(PKG) /* end H5EA__sblock_alloc() */ @@ -253,7 +253,7 @@ CATCH H5E_THROW(H5E_CANTFREE, "unable to release extensible array super block") /* Destroy super block */ - if(H5EA__sblock_dest(hdr->f, sblock) < 0) + if(H5EA__sblock_dest(sblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") } /* end if */ @@ -407,7 +407,7 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ /* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, -H5EA__sblock_dest(H5F_t *f, H5EA_sblock_t *sblock)) +H5EA__sblock_dest(H5EA_sblock_t *sblock)) /* Sanity check */ HDassert(sblock); @@ -418,9 +418,6 @@ HDfprintf(stderr, "%s: sblock->hdr->dblk_page_nelmts = %Zu, sblock->ndblks = %Zu /* Check if shared header field has been initialized */ if(sblock->hdr) { - /* Set the shared array header's file context for this operation */ - sblock->hdr->f = f; - /* Free buffer for super block data block addresses, if there are any */ if(sblock->dblk_addrs) sblock->dblk_addrs = H5FL_SEQ_FREE(haddr_t, sblock->dblk_addrs); @@ -438,7 +435,7 @@ HDfprintf(stderr, "%s: sblock->hdr->dblk_page_nelmts = %Zu, sblock->ndblks = %Zu } /* end if */ /* Free the super block itself */ - (void)H5FL_FREE(H5EA_sblock_t, sblock); + sblock = H5FL_FREE(H5EA_sblock_t, sblock); CATCH diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 9fa9941..f9bf595 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -279,7 +279,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(hdr && H5FA__cache_hdr_dest(f, hdr) < 0) + if(hdr && H5FA__hdr_dest(hdr) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") END_FUNC(STATIC) /* end H5FA__cache_hdr_load() */ @@ -485,7 +485,6 @@ CATCH END_FUNC(STATIC) /* end H5FA__cache_hdr_dest() */ - /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_load @@ -614,7 +613,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(dblock && H5FA__cache_dblock_dest(f, dblock) < 0) + if(dblock && H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") END_FUNC(STATIC) /* end H5FA__cache_dblock_load() */ @@ -833,7 +832,7 @@ H5FA__cache_dblock_dest(H5F_t *f, H5FA_dblock_t *dblock)) } /* end if */ /* Release the data block */ - if(H5FA__dblock_dest(f, dblock) < 0) + if(H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "can't free fixed array data block") CATCH @@ -941,7 +940,7 @@ CATCH if(wb && H5WB_unwrap(wb) < 0) H5E_THROW(H5E_CLOSEERROR, "can't close wrapped buffer") if(!ret_value) - if(dblk_page && H5FA__cache_dblk_page_dest(f, dblk_page) < 0) + if(dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") END_FUNC(STATIC) /* end H5FA__cache_dblk_page_load() */ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index a1bd90e..2291063 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -280,7 +280,6 @@ END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -/* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) @@ -293,8 +292,7 @@ H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) /* Check if buffer for data block page elements has been initialized */ if(dblk_page->elmts) { /* Free buffer for data block page elements */ - (void) H5FL_BLK_FREE(page_elmts, dblk_page->elmts); - dblk_page->elmts = NULL; + dblk_page->elmts = H5FL_BLK_FREE(page_elmts, dblk_page->elmts); } /* end if */ /* Decrement reference count on shared info */ @@ -304,7 +302,7 @@ H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) } /* end if */ /* Free the data block page itself */ - (void)H5FL_FREE(H5FA_dblk_page_t, dblk_page); + dblk_page = H5FL_FREE(H5FA_dblk_page_t, dblk_page); CATCH diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index f564fee..d2ab5d9 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -166,7 +166,7 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr, hsize_t nelmts)) CATCH if(!ret_value) - if(dblock && H5FA__dblock_dest(hdr->f, dblock) < 0) + if(dblock && H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") END_FUNC(PKG) /* end H5FA__dblock_alloc() */ @@ -243,7 +243,7 @@ CATCH H5E_THROW(H5E_CANTFREE, "unable to release fixed array data block") /* Destroy data block */ - if(H5FA__dblock_dest(hdr->f, dblock) < 0) + if(H5FA__dblock_dest(dblock) < 0) H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") } /* end if */ @@ -401,10 +401,9 @@ END_FUNC(PKG) /* end H5FA__dblock_delete() */ * *------------------------------------------------------------------------- */ -/* ARGSUSED */ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, -H5FA__dblock_dest(H5F_t UNUSED *f, H5FA_dblock_t *dblock)) +H5FA__dblock_dest(H5FA_dblock_t *dblock)) /* Sanity check */ HDassert(dblock); @@ -415,8 +414,7 @@ H5FA__dblock_dest(H5F_t UNUSED *f, H5FA_dblock_t *dblock)) if(dblock->elmts && !dblock->npages) { /* Free buffer for data block elements */ HDassert(dblock->hdr->cparam.nelmts > 0); - (void) H5FL_BLK_FREE(chunk_elmts, dblock->elmts); - dblock->elmts = NULL; + dblock->elmts = H5FL_BLK_FREE(chunk_elmts, dblock->elmts); } /* end if */ /* Check if data block is paged */ @@ -434,7 +432,7 @@ H5FA__dblock_dest(H5F_t UNUSED *f, H5FA_dblock_t *dblock)) } /* end if */ /* Free the data block itself */ - (void)H5FL_FREE(H5FA_dblock_t, dblock); + dblock = H5FL_FREE(H5FA_dblock_t, dblock); CATCH diff --git a/src/H5FApkg.h b/src/H5FApkg.h index eb224a6..04bf6da 100644 --- a/src/H5FApkg.h +++ b/src/H5FApkg.h @@ -258,7 +258,7 @@ H5_DLL herr_t H5FA__dblock_unprotect(H5FA_dblock_t *dblock, hid_t dxpl_id, unsigned cache_flags); H5_DLL herr_t H5FA__dblock_delete(H5FA_hdr_t *hdr, hid_t dxpl_id, haddr_t dblk_addr, hsize_t dblk_nelmts); -H5_DLL herr_t H5FA__dblock_dest(H5F_t *f, H5FA_dblock_t *dblock); +H5_DLL herr_t H5FA__dblock_dest(H5FA_dblock_t *dblock); /* Data block page routines */ H5_DLL herr_t H5FA__dblk_page_create(H5FA_hdr_t *hdr, hid_t dxpl_id, @@ -55,6 +55,8 @@ /********************/ /* Local Prototypes */ /********************/ +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); /*********************/ @@ -156,7 +158,8 @@ HDfprintf(stderr, "%s: fspace = %p, fspace->addr = %a\n", FUNC, fspace, fspace-> done: 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") #ifdef H5FS_DEBUG HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); @@ -220,7 +223,7 @@ HDfprintf(stderr, "%s: fspace->rc = %u\n", FUNC, fspace->rc); /* Increment the reference count on the free space manager header */ HDassert(fspace->rc <= 1); - if(H5FS_incr(f, fspace) < 0) + if(H5FS_incr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header") fspace->alignment = alignment; @@ -465,7 +468,7 @@ HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); } /* end else */ /* Destroy section info */ - if(H5FS_cache_sinfo_dest(f, fspace->sinfo) < 0) + if(H5FS_sinfo_dest(fspace->sinfo) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "unable to destroy free space section info") } /* end else */ @@ -480,7 +483,7 @@ HDfprintf(stderr, "%s: Section info is NOT for file free space\n", FUNC); } /* end else */ /* Decrement the reference count on the free space manager header */ - if(H5FS_decr(f, fspace) < 0) + if(H5FS_decr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTDEC, FAIL, "unable to decrement ref. count on free space header") done: @@ -616,7 +619,7 @@ H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size) *------------------------------------------------------------------------- */ herr_t -H5FS_incr(H5F_t *f, H5FS_t *fspace) +H5FS_incr(H5FS_t *fspace) { herr_t ret_value = SUCCEED; /* Return value */ @@ -628,7 +631,6 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp /* * Check arguments. */ - HDassert(f); HDassert(fspace); /* Check if we should pin the header in the cache */ @@ -658,7 +660,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FS_decr(H5F_t *f, H5FS_t *fspace) +H5FS_decr(H5FS_t *fspace) { herr_t ret_value = SUCCEED; /* Return value */ @@ -670,7 +672,6 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp /* * Check arguments. */ - HDassert(f); HDassert(fspace); /* Decrement reference count on header */ @@ -683,7 +684,7 @@ HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fsp HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin free space header") } /* end if */ else { - if(H5FS_cache_hdr_dest(f, fspace) < 0) + if(H5FS_hdr_dest(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, "unable to destroy free space header") } /* end else */ } /* end if */ @@ -707,7 +708,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FS_dirty(H5F_t *f, H5FS_t *fspace) +H5FS_dirty(H5FS_t *fspace) { herr_t ret_value = SUCCEED; /* Return value */ @@ -717,7 +718,6 @@ HDfprintf(stderr, "%s: Marking free space header as dirty\n", FUNC); #endif /* QAK */ /* Sanity check */ - HDassert(f); HDassert(fspace); /* Check if the free space manager is persistant */ @@ -802,7 +802,7 @@ H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id) fspace->alloc_sect_size = fspace->sect_size; /* Mark free-space header as dirty */ - if(H5FS_dirty(f, fspace) < 0) + if(H5FS_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") /* Cache the free-space section info */ @@ -873,7 +873,7 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hid_t dxpl_id) HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to release free space sections") /* Mark free-space manager header as dirty */ - if(H5FS_dirty(f, fspace) < 0) + if(H5FS_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } @@ -907,6 +907,177 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_free() */ + +/*------------------------------------------------------------------------- + * Function: H5FS_hdr_dest + * + * Purpose: Destroys a free space header in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * May 2 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FS_hdr_dest(H5FS_t *fspace) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5FS_hdr_dest) + + /* + * Check arguments. + */ + HDassert(fspace); + + /* 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 */ + + /* 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 */ + fspace = H5FL_FREE(H5FS_t, fspace); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FS_hdr_dest() */ + + +/*------------------------------------------------------------------------- + * 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 + * + *------------------------------------------------------------------------- + */ +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); + + /* 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 */ + fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); + + FUNC_LEAVE_NOAPI(0) +} /* H5FS_sinfo_free_node_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5FS_sinfo_dest + * + * Purpose: Destroys a free space section info in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * July 31 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FS_sinfo_dest(H5FS_sinfo_t *sinfo) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5FS_sinfo_dest) + + /* + * Check arguments. + */ + HDassert(sinfo); + HDassert(sinfo->fspace); + HDassert(sinfo->bins); + + /* 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 = 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(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 */ + sinfo = H5FL_FREE(H5FS_sinfo_t, sinfo); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FS_sinfo_dest() */ + #ifdef H5FS_DEBUG_ASSERT /*------------------------------------------------------------------------- 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) diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 1786b44..a287d23 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -213,16 +213,16 @@ H5FL_EXTERN(H5FS_t); /* Free space manager header routines */ H5_DLL H5FS_t *H5FS_new(size_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata); -H5_DLL herr_t H5FS_incr(H5F_t *f, H5FS_t *fspace); -H5_DLL herr_t H5FS_decr(H5F_t *f, H5FS_t *fspace); -H5_DLL herr_t H5FS_dirty(H5F_t *f, H5FS_t *fspace); +H5_DLL herr_t H5FS_incr(H5FS_t *fspace); +H5_DLL herr_t H5FS_decr(H5FS_t *fspace); +H5_DLL herr_t H5FS_dirty(H5FS_t *fspace); /* Free space section routines */ H5_DLL H5FS_sinfo_t *H5FS_sinfo_new(H5F_t *f, H5FS_t *fspace); -/* Metadata cache callbacks */ -H5_DLL herr_t H5FS_cache_hdr_dest(H5F_t *f, H5FS_t *hdr); -H5_DLL herr_t H5FS_cache_sinfo_dest(H5F_t *f, H5FS_sinfo_t *sinfo); +/* Routines for destroying structures */ +H5_DLL herr_t H5FS_hdr_dest(H5FS_t *hdr); +H5_DLL herr_t H5FS_sinfo_dest(H5FS_sinfo_t *sinfo); /* Sanity check routines */ #ifdef H5FS_DEBUG diff --git a/src/H5FSsection.c b/src/H5FSsection.c index a9b8e3b..79baac0 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -159,7 +159,7 @@ HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for free space section bin array") /* Increment the reference count on the free space manager header */ - if(H5FS_incr(f, fspace) < 0) + if(H5FS_incr(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINC, NULL, "unable to increment ref. count on free space header") sinfo->fspace = fspace; @@ -335,7 +335,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* Assume that the modification will affect the statistics in the header * and mark that dirty also */ - if(H5FS_dirty(f, fspace) < 0) + if(H5FS_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ @@ -430,7 +430,7 @@ HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC); /* If we haven't already marked the header dirty, do so now */ if(!modified) - if(H5FS_dirty(f, fspace) < 0) + if(H5FS_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") #ifdef H5FS_SINFO_DEBUG diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index ba55b8f..0ae0eb1 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -136,7 +136,6 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) HDassert(root_oloc); root_ent.type = H5G_NOTHING_CACHED; root_ent.header = root_oloc->addr; - root_ent.file = f; /* Display root group symbol table entry info */ H5G_ent_debug(&root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 7075683..e1cb396 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -225,7 +225,7 @@ typedef struct H5F_file_t { unsigned gc_ref; /* Garbage-collect references? */ hbool_t latest_format; /* Always use the latest format? */ hbool_t store_msg_crt_idx; /* Store creation index for object header messages? */ - int ncwfs; /* Num entries on cwfs list */ + unsigned ncwfs; /* Num entries on cwfs list */ struct H5HG_heap_t **cwfs; /* Global heap cache */ struct H5G_t *root_grp; /* Open root group */ H5FO_t *open_objs; /* Open objects in file */ @@ -302,6 +302,7 @@ H5_DLL herr_t H5F_flush_mounts(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_init(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size); +H5_DLL herr_t H5F_super_free(H5F_super_t *sblock); /* Superblock extension related routines */ H5_DLL herr_t H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index f42c7f6..7ee21f3 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -618,7 +618,8 @@ done: } /* end if */ else /* Free superblock */ - sblock = (H5F_super_t *)H5FL_FREE(H5F_super_t, sblock); + if(H5F_super_free(sblock) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") /* Reset variables in file structure */ f->shared->sblock = NULL; @@ -664,6 +665,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_super_free + * + * Purpose: Destroyer the file's superblock + * + * Return: Success: non-negative on success + * Failure: Negative + * + * Programmer: Quincey Koziol + * April 1, 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_super_free(H5F_super_t *sblock) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_super_free) + + /* Sanity check */ + HDassert(sblock); + + /* Free root group symbol table entry, if any */ + sblock->root_ent = (H5G_entry_t *)H5MM_xfree(sblock->root_ent); + + /* Free superblock */ + sblock = (H5F_super_t *)H5FL_FREE(H5F_super_t, sblock); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5F_super_free() */ + + +/*------------------------------------------------------------------------- * Function: H5F_super_size * * Purpose: Get storage size of the superblock and superblock extension diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index a103351..00d53e9 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -613,7 +613,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, const void UNUSED done: /* Release the [possibly partially initialized] superblock on errors */ if(!ret_value && sblock) - if(H5F_sblock_dest(f, sblock) < 0) + if(H5F_super_free(sblock) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data") FUNC_LEAVE_NOAPI(ret_value) @@ -840,18 +840,19 @@ done: static herr_t H5F_sblock_dest(H5F_t UNUSED *f, H5F_super_t* sblock) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sblock_dest) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5F_sblock_dest) /* Sanity check */ HDassert(sblock); - /* Free root group symbol table entry, if any */ - sblock->root_ent = (H5G_entry_t *)H5MM_xfree(sblock->root_ent); - /* Free superblock */ - sblock = (H5F_super_t *)H5FL_FREE(H5F_super_t, sblock); + if(H5F_super_free(sblock) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_sblock_dest() */ diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 1b352ca..52d14fe 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -198,7 +198,7 @@ done: if(wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") if(!ret_value) - if(sym && H5G_node_dest(f, sym) < 0) + if(sym && H5G_node_free(sym) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, NULL, "unable to destroy symbol table node") FUNC_LEAVE_NOAPI(ret_value) @@ -236,18 +236,6 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_ HDassert(sym); /* - * Look for dirty entries and set the node dirty flag. - */ - for(u = 0; u < sym->nsyms; u++) - if(sym->entry[u].dirty) { - /* Set the node's dirty flag */ - sym->cache_info.is_dirty = TRUE; - - /* Reset the entry's dirty flag */ - sym->entry[u].dirty = FALSE; - } /* end if */ - - /* * Write the symbol node to disk. */ if(sym->cache_info.is_dirty) { @@ -352,10 +340,9 @@ H5G_node_dest(H5F_t *f, H5G_node_t *sym) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to free symbol table node") } /* end if */ - /* Release resources */ - if(sym->entry) - sym->entry = (H5G_entry_t *)H5FL_SEQ_FREE(H5G_entry_t, sym->entry); - sym = H5FL_FREE(H5G_node_t, sym); + /* Destroy symbol table node */ + if(H5G_node_free(sym) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to destroy symbol table node") done: FUNC_LEAVE_NOAPI(ret_value) @@ -378,7 +365,6 @@ done: static herr_t H5G_node_clear(H5F_t *f, H5G_node_t *sym, hbool_t destroy) { - unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5G_node_clear) @@ -388,9 +374,7 @@ H5G_node_clear(H5F_t *f, H5G_node_t *sym, hbool_t destroy) */ HDassert(sym); - /* Look for dirty entries and reset their dirty flag. */ - for(u = 0; u < sym->nsyms; u++) - sym->entry[u].dirty = FALSE; + /* Reset the node's dirty flag */ sym->cache_info.is_dirty = FALSE; /* diff --git a/src/H5Gent.c b/src/H5Gent.c index 18883ac..8e87995 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -107,9 +107,6 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) HDassert(pp); HDassert(ent); - /* Set the entry's file pointer */ - ent->file = f; - /* decode header */ H5F_DECODE_LENGTH(f, *pp, ent->name_off); H5F_addr_decode(f, pp, &(ent->header)); @@ -400,9 +397,6 @@ H5G_ent_convert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, const char *name, HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type") } /* end switch */ - /* Set the file for the entry */ - ent->file = f; - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_ent_convert() */ @@ -423,7 +417,7 @@ done: */ herr_t H5G_ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, - H5HL_t *heap) + const H5HL_t *heap) { const char *lval = NULL; int nested_indent, nested_fwidth; @@ -441,9 +435,6 @@ H5G_ent_debug(const H5G_entry_t *ent, FILE *stream, int indent, int fwidth, HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Object header address:", ent->header); - HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, - "Dirty:", - ent->dirty ? "Yes" : "No"); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cache info type:"); switch(ent->type) { diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 1df2fe4..3c07313 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -32,6 +32,7 @@ /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FLprivate.h" /* Free Lists */ @@ -51,6 +52,7 @@ typedef struct H5G_node_key_t { size_t offset; /*offset into heap for name */ } H5G_node_key_t; + /* Private macros */ #define H5G_NODE_SIZEOF_HDR(F) (H5_SIZEOF_MAGIC + 4) @@ -261,6 +263,40 @@ H5G_node_size_real(const H5F_t *f) /*------------------------------------------------------------------------- + * Function: H5G_node_free + * + * Purpose: Destroy a symbol table node in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Jan 15 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_node_free(H5G_node_t *sym) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_free) + + /* + * Check arguments. + */ + HDassert(sym); + + /* Verify that node is clean */ + HDassert(sym->cache_info.is_dirty == FALSE); + + if(sym->entry) + sym->entry = H5FL_SEQ_FREE(H5G_entry_t, sym->entry); + sym = H5FL_FREE(H5G_node_t, sym); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5G_node_free() */ + + +/*------------------------------------------------------------------------- * Function: H5G_node_create * * Purpose: Creates a new empty symbol table node. This function is @@ -699,9 +735,6 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, /* Copy new entry into table */ H5G_ent_copy(&(insert_into->entry[idx]), &ent, H5_COPY_SHALLOW); - /* Flag entry as dirty */ - insert_into->entry[idx].dirty = TRUE; - /* Increment # of symbols in table */ insert_into->nsyms += 1; diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index b80b1b1..15e9254 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -32,7 +32,6 @@ #include "H5Gprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5B2private.h" /* v2 B-trees */ #include "H5FLprivate.h" /* Free Lists */ #include "H5HFprivate.h" /* Fractal heaps */ @@ -103,12 +102,10 @@ typedef union H5G_cache_t { * points. */ struct H5G_entry_t { - hbool_t dirty; /*entry out-of-date? */ H5G_cache_type_t type; /*type of information cached */ H5G_cache_t cache; /*cached data from object header */ size_t name_off; /*offset of name within name heap */ haddr_t header; /*file address of object header */ - H5F_t *file; /*file to which this obj hdr belongs */ }; /* @@ -118,10 +115,10 @@ struct H5G_entry_t { * table or group. */ typedef struct H5G_node_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - unsigned nsyms; /*number of symbols */ - H5G_entry_t *entry; /*array of symbol table entries */ + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + unsigned nsyms; /*number of symbols */ + H5G_entry_t *entry; /*array of symbol table entries */ } H5G_node_t; /* @@ -434,7 +431,7 @@ H5_DLL herr_t H5G_ent_encode_vec(const H5F_t *f, uint8_t **pp, H5_DLL herr_t H5G_ent_convert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, const char *name, const H5O_link_t *lnk, H5G_entry_t *ent); H5_DLL herr_t H5G_ent_debug(const H5G_entry_t *ent, FILE * stream, int indent, - int fwidth, H5HL_t *heap); + int fwidth, const H5HL_t *heap); /* Functions that understand symbol table nodes */ H5_DLL herr_t H5G_node_init(H5F_t *f); @@ -451,6 +448,7 @@ H5_DLL int H5G_node_build_table(H5F_t *f, hid_t dxpl_id, const void *_lt_key, ha const void *_rt_key, void *_udata); H5_DLL herr_t H5G_node_iterate_size(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); +H5_DLL herr_t H5G_node_free(H5G_node_t *sym); /* Functions that understand links in groups */ H5_DLL int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2); diff --git a/src/H5Groot.c b/src/H5Groot.c index 0d21bfe..1110b19 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -156,11 +156,9 @@ H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") /* Initialize the root group symbol table entry */ - f->shared->sblock->root_ent->dirty = TRUE; f->shared->sblock->root_ent->type = H5G_NOTHING_CACHED; /* We will cache the stab later */ f->shared->sblock->root_ent->name_off = 0; /* No name (yet) */ f->shared->sblock->root_ent->header = root_loc.oloc->addr; - f->shared->sblock->root_ent->file = root_loc.oloc->file; } /* end if */ } /* end if */ else { diff --git a/src/H5HFcache.c b/src/H5HFcache.c index f96e876..9c17ef6 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -80,14 +80,17 @@ static herr_t H5HF_dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dt /* Metadata cache (H5AC) callbacks */ static H5HF_hdr_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_hdr_t *hdr, unsigned UNUSED * flags_ptr); +static herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr); static herr_t H5HF_cache_hdr_clear(H5F_t *f, H5HF_hdr_t *hdr, hbool_t destroy); static herr_t H5HF_cache_hdr_size(const H5F_t *f, const H5HF_hdr_t *hdr, size_t *size_ptr); static H5HF_indirect_t *H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5HF_cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_indirect_t *iblock, unsigned UNUSED * flags_ptr); +static herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock); static herr_t H5HF_cache_iblock_clear(H5F_t *f, H5HF_indirect_t *iblock, hbool_t destroy); static herr_t H5HF_cache_iblock_size(const H5F_t *f, const H5HF_indirect_t *iblock, size_t *size_ptr); static H5HF_direct_t *H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_direct_t *dblock, unsigned UNUSED * flags_ptr); +static herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock); static herr_t H5HF_cache_dblock_clear(H5F_t *f, H5HF_direct_t *dblock, hbool_t destroy); static herr_t H5HF_cache_dblock_size(const H5F_t *f, const H5HF_direct_t *dblock, size_t *size_ptr); @@ -581,7 +584,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -608,6 +611,7 @@ H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr) /* Free the shared info itself */ if(H5HF_hdr_free(hdr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "unable to release fractal heap header") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_cache_hdr_dest() */ @@ -867,7 +871,7 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows /* Allocate & initialize child indirect block pointer array */ if(NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC(H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block entries") + HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for block entries") } /* end if */ else iblock->child_iblocks = NULL; @@ -880,7 +884,8 @@ done: if(wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_HEAP, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") if(!ret_value && iblock) - (void)H5HF_cache_iblock_dest(f, iblock); + if(H5HF_man_iblock_dest(iblock) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_cache_iblock_load() */ @@ -1086,7 +1091,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1115,26 +1120,9 @@ H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock) } /* end if */ } /* end if */ - /* Set the shared heap header's file context for this operation */ - iblock->hdr->f = f; - - /* Decrement reference count on shared info */ - if(H5HF_hdr_decr(iblock->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") - if(iblock->parent) - if(H5HF_iblock_decr(iblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") - - /* Release entry tables */ - if(iblock->ents) - (void)H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents); - if(iblock->filt_ents) - (void)H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents); - if(iblock->child_iblocks) - (void)H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); - - /* Free fractal heap indirect block info */ - (void)H5FL_FREE(H5HF_indirect_t, iblock); + /* Destroy fractal heap indirect block */ + if(H5HF_man_iblock_dest(iblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1378,7 +1366,8 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size, done: if(!ret_value && dblock) - (void)H5HF_cache_dblock_dest(f, dblock); + if(H5HF_man_dblock_dest(dblock) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_cache_dblock_load() */ @@ -1670,7 +1659,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1700,22 +1689,9 @@ H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock) } /* end if */ } /* end if */ - /* Set the shared heap header's file context for this operation */ - dblock->hdr->f = f; - - /* Decrement reference count on shared fractal heap info */ - HDassert(dblock->hdr); - if(H5HF_hdr_decr(dblock->hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") - if(dblock->parent) - if(H5HF_iblock_decr(dblock->parent) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") - - /* Free block's buffer */ - dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk); - - /* Free fractal heap direct block info */ - (void)H5FL_FREE(H5HF_direct_t, dblock); + /* Destroy fractal heap direct block */ + if(H5HF_man_dblock_dest(dblock) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 7a511a0..e00dbf3 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -196,7 +196,8 @@ HDmemset(dblock->blk, 0, dblock->size); done: if(ret_value < 0) if(dblock) - (void)H5HF_cache_dblock_dest(hdr->f, dblock); + if(H5HF_man_dblock_dest(dblock) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_dblock_create() */ @@ -640,3 +641,47 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_dblock_delete() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_man_dblock_dest + * + * Purpose: Destroys a fractal heap direct block in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 27 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_man_dblock_dest(H5HF_direct_t *dblock) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_dest) + + /* + * Check arguments. + */ + HDassert(dblock); + + /* Decrement reference count on shared fractal heap info */ + HDassert(dblock->hdr != NULL); + if(H5HF_hdr_decr(dblock->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") + if(dblock->parent) + if(H5HF_iblock_decr(dblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + + /* Free block's buffer */ + dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk); + + /* Free fractal heap direct block info */ + dblock = H5FL_FREE(H5HF_direct_t, dblock); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_man_dblock_dest() */ + diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index e55f472..468f9c2 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -1343,7 +1343,9 @@ done: herr_t H5HF_hdr_free(H5HF_hdr_t *hdr) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_free) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_free) /* * Check arguments. @@ -1351,16 +1353,19 @@ H5HF_hdr_free(H5HF_hdr_t *hdr) HDassert(hdr); /* Free the block size lookup table for the doubling table */ - H5HF_dtable_dest(&hdr->man_dtable); + if(H5HF_dtable_dest(&hdr->man_dtable) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap doubling table") /* Release any I/O pipeline filter information */ if(hdr->pline.nused) - H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)); + if(H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to reset I/O pipeline message") /* Free the shared info itself */ hdr = H5FL_FREE(H5HF_hdr_t, hdr); - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_free() */ diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 26c60a3..74fbe63 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -1046,7 +1046,8 @@ H5HF_man_iblock_create(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *par_iblo done: if(ret_value < 0) if(iblock) - (void)H5HF_cache_iblock_dest(hdr->f, iblock); + if(H5HF_man_iblock_dest(iblock) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_create() */ @@ -1557,3 +1558,53 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iblock_size() */ + +/*------------------------------------------------------------------------- + * Function: H5HF_man_iblock_dest + * + * Purpose: Destroys a fractal heap indirect block in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 6 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HF_man_iblock_dest(H5HF_indirect_t *iblock) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iblock_dest) + + /* + * Check arguments. + */ + HDassert(iblock); + HDassert(iblock->rc == 0); + + /* Decrement reference count on shared info */ + HDassert(iblock->hdr); + if(H5HF_hdr_decr(iblock->hdr) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header") + if(iblock->parent) + if(H5HF_iblock_decr(iblock->parent) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") + + /* Release entry tables */ + if(iblock->ents) + H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents); + if(iblock->filt_ents) + H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents); + if(iblock->child_iblocks) + H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks); + + /* Free fractal heap indirect block info */ + iblock = H5FL_FREE(H5HF_indirect_t, iblock); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HF_man_iblock_dest() */ + diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 61f018f..f5a705c 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -563,6 +563,7 @@ H5_DLL herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off); H5_DLL herr_t H5HF_hdr_empty(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF_hdr_free(H5HF_hdr_t *hdr); H5_DLL herr_t H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id); +H5_DLL herr_t H5HF_hdr_dest(H5HF_hdr_t *hdr); /* Indirect block routines */ H5_DLL herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock); @@ -593,6 +594,7 @@ H5_DLL herr_t H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id, unsigned par_entry); H5_DLL herr_t H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size/*out*/); +H5_DLL herr_t H5HF_man_iblock_dest(H5HF_indirect_t *iblock); /* Direct block routines */ H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request, @@ -611,6 +613,7 @@ H5_DLL herr_t H5HF_man_dblock_locate(H5HF_hdr_t *hdr, hid_t dxpl_id, unsigned *par_entry, hbool_t *par_did_protect, H5AC_protect_t rw); H5_DLL herr_t H5HF_man_dblock_delete(H5F_t *f, hid_t dxpl_id, haddr_t dblock_addr, hsize_t dblock_size); +H5_DLL herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock); /* Managed object routines */ H5_DLL herr_t H5HF_man_insert(H5HF_hdr_t *fh, hid_t dxpl_id, size_t obj_size, @@ -659,11 +662,6 @@ H5_DLL herr_t H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void *op_data); H5_DLL herr_t H5HF_tiny_remove(H5HF_hdr_t *fh, const uint8_t *id); -/* Metadata cache callbacks */ -H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr); -H5_DLL herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock); -H5_DLL herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock); - /* Debugging routines for dumping file structures */ H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth); @@ -164,6 +164,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") heap->addr = addr; heap->size = size; + heap->shared = f->shared; if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed") @@ -222,7 +223,7 @@ HDmemset(heap->chunk, 0, size); HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, MIN(f->shared->ncwfs, H5HG_NCWFS - 1) * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; - f->shared->ncwfs = MIN(H5HG_NCWFS, f->shared->ncwfs+1); + f->shared->ncwfs = MIN(H5HG_NCWFS, f->shared->ncwfs + 1); } /* end else */ /* Add the heap to the cache */ @@ -242,7 +243,7 @@ done: /* Check if the heap object was allocated */ if(heap) /* Destroy the heap object */ - if(H5HG_dest(f, heap) < 0) + if(H5HG_free(heap) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy global heap collection") } /* end if */ } /* end if */ @@ -485,7 +486,7 @@ herr_t H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/) { size_t need; /*total space needed for object */ - int cwfsno; + unsigned cwfsno; size_t idx; haddr_t addr = HADDR_UNDEF; H5HG_heap_t *heap = NULL; @@ -544,7 +545,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/ if(!found) { size_t new_need; - for (cwfsno=0; cwfsno<f->shared->ncwfs; cwfsno++) { + for(cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) { new_need = need; new_need -= f->shared->cwfs[cwfsno]->obj[0].size; new_need = MAX(f->shared->cwfs[cwfsno]->size, new_need); @@ -575,7 +576,6 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/ if(!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection") - cwfsno = 0; } /* end if */ else { /* Move the collection forward in the CWFS list, if it's not @@ -671,13 +671,13 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/, * with the H5AC_protect(), but it won't hurt to do it twice. */ if(heap->obj[0].begin) { - int i; + unsigned u; /* Local index variable */ - for(i = 0; i < f->shared->ncwfs; i++) - if(f->shared->cwfs[i] == heap) { - if(i) { - f->shared->cwfs[i] = f->shared->cwfs[i - 1]; - f->shared->cwfs[i - 1] = heap; + for(u = 0; u < f->shared->ncwfs; u++) + if(f->shared->cwfs[u] == heap) { + if(u) { + f->shared->cwfs[u] = f->shared->cwfs[u - 1]; + f->shared->cwfs[u - 1] = heap; } /* end if */ break; } /* end if */ @@ -691,7 +691,7 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/, ret_value = object; done: - if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET)<0) + if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header") if(NULL == ret_value && NULL == orig_object && object) @@ -838,22 +838,20 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj) flags |= H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; /* Indicate that the object was deleted, for the unprotect call */ } /* end if */ else { - int i; /* Local index variable */ - /* * If the heap is in the CWFS list then advance it one position. The * H5AC_protect() might have done that too, but that's okay. If the * heap isn't on the CWFS list then add it to the end. */ - for(i = 0; i < f->shared->ncwfs; i++) - if(f->shared->cwfs[i] == heap) { - if(i) { - f->shared->cwfs[i] = f->shared->cwfs[i - 1]; - f->shared->cwfs[i - 1] = heap; + for(u = 0; u < f->shared->ncwfs; u++) + if(f->shared->cwfs[u] == heap) { + if(u) { + f->shared->cwfs[u] = f->shared->cwfs[u - 1]; + f->shared->cwfs[u - 1] = heap; } /* end if */ break; } /* end if */ - if(i >= f->shared->ncwfs) { + if(u >= f->shared->ncwfs) { f->shared->ncwfs = MIN(f->shared->ncwfs + 1, H5HG_NCWFS); f->shared->cwfs[f->shared->ncwfs - 1] = heap; } /* end if */ @@ -866,3 +864,44 @@ done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5HG_remove() */ + +/*------------------------------------------------------------------------- + * Function: H5HG_free + * + * Purpose: Destroys a global heap collection in memory + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, January 15, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5HG_free(H5HG_heap_t *heap) +{ + unsigned u; /* Local index variable */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HG_free) + + /* Check arguments */ + HDassert(heap); + + /* Remove the heap from the CWFS list */ + for(u = 0; u < heap->shared->ncwfs; u++) { + if(heap->shared->cwfs[u] == heap) { + heap->shared->ncwfs -= 1; + HDmemmove(heap->shared->cwfs + u, heap->shared->cwfs + u + 1, (heap->shared->ncwfs - u) * sizeof(H5HG_heap_t *)); + break; + } /* end if */ + } /* end for */ + + if(heap->chunk) + heap->chunk = H5FL_BLK_FREE(gheap_chunk, heap->chunk); + if(heap->obj) + heap->obj = H5FL_SEQ_FREE(H5HG_obj_t, heap->obj); + heap = H5FL_FREE(H5HG_heap_t, heap); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5HG_free() */ + diff --git a/src/H5HGcache.c b/src/H5HGcache.c index b7a701a..79a1526 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -67,6 +67,7 @@ static H5HG_heap_t *H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void void *udata2); static herr_t H5HG_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr, H5HG_heap_t *heap, unsigned UNUSED * flags_ptr); +static herr_t H5HG_dest(H5F_t *f, H5HG_heap_t *heap); static herr_t H5HG_clear(H5F_t *f, H5HG_heap_t *heap, hbool_t destroy); static herr_t H5HG_size(const H5F_t *f, const H5HG_heap_t *heap, size_t *size_ptr); @@ -117,12 +118,12 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, void UNUSED * udata2) { H5HG_heap_t *heap = NULL; - uint8_t *p = NULL; + uint8_t *p; size_t nalloc, need; size_t max_idx = 0; /* The maximum index seen */ H5HG_heap_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5HG_load, NULL) + FUNC_ENTER_NOAPI_NOINIT(H5HG_load) /* check arguments */ HDassert(f); @@ -134,15 +135,17 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") heap->addr = addr; + heap->shared = f->shared; if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, (size_t)H5HG_MINSIZE))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if(H5F_block_read(f, H5FD_MEM_GHEAP, addr, (size_t)H5HG_MINSIZE, dxpl_id, heap->chunk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection") + p = heap->chunk; /* Magic number */ - if(HDmemcmp(heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) + if(HDmemcmp(p, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad global heap collection signature") - p = heap->chunk + H5_SIZEOF_MAGIC; + p += H5_SIZEOF_MAGIC; /* Version */ if(H5HG_VERSION != *p++) @@ -186,7 +189,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, * assume that it's free space. */ HDassert(NULL == heap->obj[0].begin); - heap->obj[0].size = (heap->chunk + heap->size) - p; + heap->obj[0].size = ((const uint8_t *)heap->chunk + heap->size) - p; heap->obj[0].begin = p; p += heap->obj[0].size; } /* end if */ @@ -215,7 +218,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* Update heap information */ heap->nalloc = new_alloc; heap->obj = new_obj; - HDassert(heap->nalloc>heap->nused); + HDassert(heap->nalloc > heap->nused); } /* end if */ UINT16DECODE(p, heap->obj[idx].nrefs); @@ -259,8 +262,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, * free space than this heap. */ if(!f->shared->cwfs) { - f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5HG_NCWFS * sizeof(H5HG_heap_t *)); - if(NULL == f->shared->cwfs) + if(NULL == (f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5HG_NCWFS * sizeof(H5HG_heap_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") f->shared->ncwfs = 1; f->shared->cwfs[0] = heap; @@ -283,7 +285,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, done: if(!ret_value && heap) - if(H5HG_dest(f, heap) < 0) + if(H5HG_free(heap) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection") FUNC_LEAVE_NOAPI(ret_value) @@ -308,7 +310,7 @@ H5HG_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HG_heap_t * { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5HG_flush, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5HG_flush) /* Check arguments */ HDassert(f); @@ -343,10 +345,9 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5HG_dest(H5F_t *f, H5HG_heap_t *heap) { - int i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HG_dest) @@ -368,20 +369,9 @@ H5HG_dest(H5F_t *f, H5HG_heap_t *heap) HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free global heap") } /* end if */ - /* Remove heap from NCWFS array, if it's present */ - for(i = 0; i < f->shared->ncwfs; i++) - if(f->shared->cwfs[i] == heap) { - f->shared->ncwfs -= 1; - HDmemmove(f->shared->cwfs + i, f->shared->cwfs + i + 1, (f->shared->ncwfs - i) * sizeof(H5HG_heap_t *)); - break; - } /* end if */ - - /* Release resources */ - if(heap->chunk) - heap->chunk = H5FL_BLK_FREE(gheap_chunk, heap->chunk); - if(heap->obj) - heap->obj = H5FL_SEQ_FREE(H5HG_obj_t, heap->obj); - heap = H5FL_FREE(H5HG_heap_t, heap); + /* Destroy global heap collection */ + if(H5HG_free(heap) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy global heap collection") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index bda9832..07de139 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -67,13 +67,13 @@ H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, FUNC_ENTER_NOAPI(H5HG_debug, FAIL); /* check arguments */ - assert(f); - assert(H5F_addr_defined (addr)); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); + HDassert(f); + HDassert(H5F_addr_defined (addr)); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); - if (NULL == (h = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_READ))) + if(NULL == (h = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection"); fprintf(stream, "%*sGlobal Heap Collection...\n", indent, ""); @@ -135,7 +135,7 @@ H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, } done: - if (h && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, addr, h, H5AC__NO_FLAGS_SET) != SUCCEED) + if (h && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, addr, h, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index 96be009..7ce18c9 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -128,6 +128,9 @@ typedef struct H5HG_obj_t { uint8_t *begin; /*ptr to object into heap->chunk*/ } H5HG_obj_t; +/* Forward declarations for fields */ +struct H5F_file_t; + struct H5HG_heap_t { H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ /* first field in structure */ @@ -139,13 +142,14 @@ struct H5HG_heap_t { /* If this value is >65535 then all indices */ /* have been used at some time and the */ /* correct new index should be searched for */ + struct H5F_file_t *shared; /* shared file */ H5HG_obj_t *obj; /*array of object descriptions */ }; /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5HG_dest(H5F_t *f, H5HG_heap_t *heap); +H5_DLL herr_t H5HG_free(H5HG_heap_t *heap); #endif /* _H5HGpkg_H */ @@ -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 47d5d6f..0bccd26 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -455,7 +455,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: @@ -481,7 +481,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 */ @@ -551,7 +551,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: @@ -708,7 +708,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: @@ -730,7 +730,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 */ @@ -780,7 +780,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 */ @@ -794,7 +794,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: @@ -42,7 +42,7 @@ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Ipkg.h" /* IDs */ @@ -1245,7 +1245,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) @@ -3060,3 +3060,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 0709e60..780d5bb 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); @@ -628,7 +629,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) @@ -814,7 +815,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: @@ -835,17 +836,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); @@ -856,51 +852,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 0bab7aa..b575e29 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -24,7 +24,7 @@ #include "H5Oprivate.h" /* Object headers */ /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5FLprivate.h" /* Free Lists */ /* Object header macros */ @@ -480,6 +480,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, @@ -540,9 +541,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); diff --git a/src/H5Otest.c b/src/H5Otest.c index 5282538..041194a 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -33,6 +33,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ @@ -20,7 +20,7 @@ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gprivate.h" /* Groups */ @@ -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 070b00e..428cd38 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -233,7 +233,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() */ @@ -366,17 +367,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() */ @@ -681,9 +685,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, @@ -34,7 +34,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 2320b28..c7f0259 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -32,7 +32,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 07d3865..b3bd298 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -41,7 +41,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ diff --git a/src/H5detect.c b/src/H5detect.c index 8fc1690..50b36fd 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -108,7 +108,6 @@ static void detect_C99_integers16(void); static void detect_C99_integers32(void); static void detect_C99_integers64(void); static void detect_alignments(void); -static void insert_libhdf5_settings(FILE *flibinfo); static size_t align_g[] = {1, 2, 4, 8, 16}; static jmp_buf jbuf_g; diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index 771c510..d903592 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -35,11 +35,12 @@ static const char *FileHeader = "\n\ * 17 Mar 2010 * Quincey Koziol * - * Purpose: Generate the H5libsettings.h header file from the + * Purpose: Generate the H5libsettings.c file from the * libhdf5.settings file. * *------------------------------------------------------------------------- */ + #include <stdio.h> #include <time.h> #include "H5private.h" @@ -68,47 +69,50 @@ insert_libhdf5_settings(FILE *flibinfo) #ifdef H5_HAVE_EMBEDDED_LIBINFO FILE *fsettings; /* for files libhdf5.settings */ int inchar; - int bol=0; /* indicates the beginning of a new line */ + int bol = 0; /* indicates the beginning of a new line */ + + if(NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) { + HDperror(LIBSETTINGSFNAME); + HDexit(1); + } /* end if */ - if (NULL==(fsettings=HDfopen(LIBSETTINGSFNAME, "r"))){ - perror(LIBSETTINGSFNAME); - exit(1); - } /* print variable definition and the string */ - fprintf(flibinfo, "static const char H5libhdf5_settings[]=\n"); + /* Do not use const else AIX strings does not show it. */ + fprintf(flibinfo, "char H5libhdf5_settings[]=\n"); bol++; - while (EOF != (inchar = getc(fsettings))){ - if (bol){ + while(EOF != (inchar = HDgetc(fsettings))) { + if(bol) { /* Start a new line */ fprintf(flibinfo, "\t\""); bol = 0; - } - if (inchar == '\n'){ + } /* end if */ + if(inchar == '\n') { /* end of a line */ fprintf(flibinfo, "\\n\"\n"); bol++; - }else{ - putc(inchar, flibinfo); - } - } - if (feof(fsettings)){ + } /* end if */ + else + HDputc(inchar, flibinfo); + } /* end while */ + if(feof(fsettings)) { /* wrap up */ - if (!bol){ + if(!bol) /* EOF found without a new line */ fprintf(flibinfo, "\\n\"\n"); - }; fprintf(flibinfo, ";\n\n"); - }else{ + } /* end if */ + else { fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); - exit(1); - } - if (0 != fclose(fsettings)){ - perror(LIBSETTINGSFNAME); - exit(1); - } + HDexit(1); + } /* end else */ + if(0 != HDfclose(fsettings)) { + HDperror(LIBSETTINGSFNAME); + HDexit(1); + } /* end if */ #else /* print variable definition and an empty string */ - fprintf(flibinfo, "static const char H5libhdf5_settings[]=\"\";\n"); + /* Do not use const else AIX strings does not show it. */ + fprintf(flibinfo, "char H5libhdf5_settings[]=\"\";\n"); #endif } /* insert_libhdf5_settings() */ @@ -138,7 +142,7 @@ make_libinfo(void) /*------------------------------------------------------------------------- * Function: print_header * - * Purpose: Prints the C file header for the generated file. + * Purpose: Prints the header for the generated file. * * Return: void * @@ -146,15 +150,13 @@ make_libinfo(void) * matzke@llnl.gov * Mar 12 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static void print_header(void) { - time_t now = time(NULL); - struct tm *tm = localtime(&now); + time_t now = HDtime(NULL); + struct tm *tm = HDlocaltime(&now); char real_name[30]; char host_name[256]; int i; @@ -179,18 +181,20 @@ information about the library build configuration\n"; { size_t n; char *comma; - if ((pwd = getpwuid(getuid()))) { - if ((comma = strchr(pwd->pw_gecos, ','))) { - n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); - strncpy(real_name, pwd->pw_gecos, n); + + if((pwd = HDgetpwuid(getuid()))) { + if((comma = HDstrchr(pwd->pw_gecos, ','))) { + n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); + HDstrncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; - } else { - strncpy(real_name, pwd->pw_gecos, sizeof(real_name)); + } /* end if */ + else { + HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); real_name[sizeof(real_name) - 1] = '\0'; - } - } else { + } /* end else */ + } /* end if */ + else real_name[0] = '\0'; - } } #else real_name[0] = '\0'; @@ -200,9 +204,8 @@ information about the library build configuration\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if (gethostname(host_name, sizeof(host_name)) < 0) { + if(gethostname(host_name, sizeof(host_name)) < 0) host_name[0] = '\0'; - } #else host_name[0] = '\0'; #endif @@ -211,34 +214,59 @@ information about the library build configuration\n"; * The file header: warning, copyright notice, build information. */ printf("/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n"); - puts(FileHeader); /*the copyright notice--see top of this file */ + HDputs(FileHeader); /*the copyright notice--see top of this file */ printf(" *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); - if (pwd || real_name[0] || host_name[0]) { + if(pwd || real_name[0] || host_name[0]) { printf(" *\t\t\t"); - if (real_name[0]) printf("%s <", real_name); + if(real_name[0]) + printf("%s <", real_name); #ifdef H5_HAVE_GETPWUID - if (pwd) fputs(pwd->pw_name, stdout); + if(pwd) + HDfputs(pwd->pw_name, stdout); #endif - if (host_name[0]) printf("@%s", host_name); - if (real_name[0]) printf(">"); - putchar('\n'); - } + if(host_name[0]) + printf("@%s", host_name); + if(real_name[0]) + printf(">"); + HDputchar('\n'); + } /* end if */ printf(" *\n * Purpose:\t\t"); - for (s = purpose; *s; s++) { - putchar(*s); - if ('\n' == *s && s[1]) printf(" *\t\t\t"); - } + for(s = purpose; *s; s++) { + HDputchar(*s); + if('\n' == *s && s[1]) + printf(" *\t\t\t"); + } /* end for */ printf(" *\n * Modifications:\n *\n"); printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); printf(" *\tIt was generated by code in `H5make_libsettings.c'.\n"); printf(" *\n *"); - for (i = 0; i < 73; i++) putchar('-'); + for(i = 0; i < 73; i++) + HDputchar('-'); printf("\n */\n\n"); +} + +/*------------------------------------------------------------------------- + * Function: print_footer + * + * Purpose: Prints the file footer for the generated file. + * + * Return: void + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2010 + * + *------------------------------------------------------------------------- + */ +static void +print_footer(void) +{ + /* nothing */ } @@ -251,28 +279,20 @@ information about the library build configuration\n"; * * Failure: exit(1) * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 12, 1996 - * - * Modifications: - * Albert Cheng, 2004/05/20 - * Some compilers, e.g., Intel C v7.0, took a long time to compile - * with optimization when a module routine contains many code lines. - * Divide up all those types detections macros into subroutines, both - * to avoid the compiler optimization error and cleaner codes. + * Programmer: Albert Cheng + * 2010/4/1 * *------------------------------------------------------------------------- */ int main(void) { - print_header(); /* Generate embedded library information variable definition */ make_libinfo(); - return 0; -} + print_footer(); + HDexit(0); +} diff --git a/src/H5private.h b/src/H5private.h index 277fe70..c8de6bf 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1535,6 +1535,8 @@ typedef struct H5_debug_t { extern H5_debug_t H5_debug_g; #define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) +/* Do not use const else AIX strings does not show it. */ +extern char H5libhdf5_settings[]; /* embedded library information */ /*------------------------------------------------------------------------- * Purpose: These macros are inserted automatically just after the @@ -1635,7 +1637,7 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ /* `S' is the name of a function which is being tested to check if its */ /* an API function */ -#define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4])) +#define H5_IS_API(S) ('_'!=((char*)S)[2] && '_'!=((char*)S)[3] && (!((char*)S)[4] || '_'!=((char*)S)[4])) /* global library version information string */ extern char H5_lib_vers_info_g[]; diff --git a/src/H5public.h b/src/H5public.h index 7213909..d23c922 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -71,10 +71,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 64 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 66 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "FA_a4" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.64-FA_a4" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.66-FA_a4" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) diff --git a/src/Makefile.am b/src/Makefile.am index 899cdde..39b765e 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,8 +35,8 @@ lib_LTLIBRARIES=libhdf5.la # Add libtool numbers to the HDF5 library (from config/lt_vers.am) libhdf5_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) -# H5Tinit.c is a generated file, and should be cleaned. -MOSTLYCLEANFILES=H5Tinit.c H5lib_settings.h +# H5Tinit.c and H5lib_settings.c are generated files and should be cleaned. +MOSTLYCLEANFILES=H5Tinit.c H5lib_settings.c # H5pubconf.h is generated by configure, and should be cleaned. DISTCLEANFILES=H5pubconf.h @@ -72,7 +72,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ H5HG.c H5HGcache.c H5HGdbg.c \ H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c \ - H5HP.c H5I.c H5L.c H5Lexternal.c \ + H5HP.c H5I.c H5L.c H5Lexternal.c H5lib_settings.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ H5MM.c H5MP.c H5MPtest.c \ H5O.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ @@ -133,21 +133,19 @@ settings_DATA=libhdf5.settings H5Tinit.c: H5detect$(EXEEXT) LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ sed -e 's/-L/:/g' -e 's/ //g'`" \ - $(RUNSERIAL) ./H5detect$(EXEEXT) > H5Tinit.c || \ + $(RUNSERIAL) ./H5detect$(EXEEXT) > $@ || \ (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ ($(RM) $@ ; exit 1) -H5.o H5.lo: H5lib_settings.h - # Build configuration header file generation # The LD_LIBRARY_PATH setting is a kludge. # Things should have been all set during H5make_libsettings making. -# Remove the generated .h file if errors occur unless HDF5_Make_Ignore +# Remove the generated .c file if errors occur unless HDF5_Make_Ignore # is set to ignore the error. -H5lib_settings.h: H5make_libsettings$(EXEEXT) libhdf5.settings +H5lib_settings.c: H5make_libsettings$(EXEEXT) libhdf5.settings LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ sed -e 's/-L/:/g' -e 's/ //g'`" \ - $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > H5lib_settings.h || \ + $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > $@ || \ (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ ($(RM) $@ ; exit 1) diff --git a/src/Makefile.in b/src/Makefile.in index 059176a..1f42fc0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -124,29 +124,29 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5HFman.lo H5HFsection.lo H5HFspace.lo H5HFstat.lo H5HFtest.lo \ H5HFtiny.lo H5HG.lo H5HGcache.lo H5HGdbg.lo H5HL.lo \ H5HLcache.lo H5HLdbg.lo H5HLint.lo H5HP.lo H5I.lo H5L.lo \ - H5Lexternal.lo H5MF.lo H5MFaggr.lo H5MFdbg.lo H5MFsection.lo \ - H5MM.lo H5MP.lo H5MPtest.lo H5O.lo H5Oainfo.lo H5Oalloc.lo \ - H5Oattr.lo H5Oattribute.lo H5Obogus.lo H5Obtreek.lo \ - H5Ocache.lo H5Ocont.lo H5Ocopy.lo H5Odbg.lo H5Odrvinfo.lo \ - H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Ofsinfo.lo H5Oginfo.lo \ - H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omessage.lo H5Omtime.lo \ - H5Oname.lo H5Onull.lo H5Opline.lo H5Orefcount.lo H5Osdspace.lo \ - H5Oshared.lo H5Oshmesg.lo H5Ostab.lo H5Ostorage.lo H5Otest.lo \ - H5Ounknown.lo H5P.lo H5Pacpl.lo H5Pdapl.lo H5Pdcpl.lo \ - H5Pdeprec.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo H5Pfmpl.lo \ - H5Pgcpl.lo H5Pint.lo H5Plapl.lo H5Plcpl.lo H5Pocpl.lo \ - H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo H5R.lo H5Rdeprec.lo \ - H5RC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo H5Shyper.lo \ - H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo H5Stest.lo \ - H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo H5SMmessage.lo \ - H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo H5Tcommit.lo \ - H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo \ - H5Tenum.lo H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo \ - H5Tnative.lo H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo \ - H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo \ - H5TS.lo H5V.lo H5WB.lo H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo \ - H5Znbit.lo H5Zshuffle.lo H5Zszip.lo H5Zscaleoffset.lo \ - H5Ztrans.lo + H5Lexternal.lo H5lib_settings.lo H5MF.lo H5MFaggr.lo \ + H5MFdbg.lo H5MFsection.lo H5MM.lo H5MP.lo H5MPtest.lo H5O.lo \ + H5Oainfo.lo H5Oalloc.lo H5Oattr.lo H5Oattribute.lo H5Obogus.lo \ + H5Obtreek.lo H5Ocache.lo H5Ocont.lo H5Ocopy.lo H5Odbg.lo \ + H5Odrvinfo.lo H5Odtype.lo H5Oefl.lo H5Ofill.lo H5Ofsinfo.lo \ + H5Oginfo.lo H5Olayout.lo H5Olinfo.lo H5Olink.lo H5Omessage.lo \ + H5Omtime.lo H5Oname.lo H5Onull.lo H5Opline.lo H5Orefcount.lo \ + H5Osdspace.lo H5Oshared.lo H5Oshmesg.lo H5Ostab.lo \ + H5Ostorage.lo H5Otest.lo H5Ounknown.lo H5P.lo H5Pacpl.lo \ + H5Pdapl.lo H5Pdcpl.lo H5Pdeprec.lo H5Pdxpl.lo H5Pfapl.lo \ + H5Pfcpl.lo H5Pfmpl.lo H5Pgcpl.lo H5Pint.lo H5Plapl.lo \ + H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo \ + H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo \ + H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \ + H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo \ + H5SMmessage.lo H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo \ + H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo \ + H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo H5Tfixed.lo \ + H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo H5Toh.lo \ + H5Topaque.lo H5Torder.lo H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo \ + H5Tvisit.lo H5Tvlen.lo H5TS.lo H5V.lo H5WB.lo H5Z.lo \ + H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ + H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) libhdf5_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -444,7 +444,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 54 +LT_VERS_REVISION = 56 LT_VERS_AGE = 0 H5detect_CFLAGS = -g $(AM_CFLAGS) @@ -454,8 +454,8 @@ lib_LTLIBRARIES = libhdf5.la # Add libtool numbers to the HDF5 library (from config/lt_vers.am) libhdf5_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) -# H5Tinit.c is a generated file, and should be cleaned. -MOSTLYCLEANFILES = H5Tinit.c H5lib_settings.h +# H5Tinit.c and H5lib_settings.c are generated files and should be cleaned. +MOSTLYCLEANFILES = H5Tinit.c H5lib_settings.c # H5pubconf.h is generated by configure, and should be cleaned. DISTCLEANFILES = H5pubconf.h @@ -491,7 +491,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ H5HG.c H5HGcache.c H5HGdbg.c \ H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c \ - H5HP.c H5I.c H5L.c H5Lexternal.c \ + H5HP.c H5I.c H5L.c H5Lexternal.c H5lib_settings.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ H5MM.c H5MP.c H5MPtest.c \ H5O.c H5Oainfo.c H5Oalloc.c H5Oattr.c \ @@ -925,6 +925,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5checksum.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5dbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5detect-H5detect.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5lib_settings.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5make_libsettings.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5system.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5timer.Plo@am__quote@ @@ -1253,21 +1254,19 @@ help: H5Tinit.c: H5detect$(EXEEXT) LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ sed -e 's/-L/:/g' -e 's/ //g'`" \ - $(RUNSERIAL) ./H5detect$(EXEEXT) > H5Tinit.c || \ + $(RUNSERIAL) ./H5detect$(EXEEXT) > $@ || \ (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ ($(RM) $@ ; exit 1) -H5.o H5.lo: H5lib_settings.h - # Build configuration header file generation # The LD_LIBRARY_PATH setting is a kludge. # Things should have been all set during H5make_libsettings making. -# Remove the generated .h file if errors occur unless HDF5_Make_Ignore +# Remove the generated .c file if errors occur unless HDF5_Make_Ignore # is set to ignore the error. -H5lib_settings.h: H5make_libsettings$(EXEEXT) libhdf5.settings +H5lib_settings.c: H5make_libsettings$(EXEEXT) libhdf5.settings LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ sed -e 's/-L/:/g' -e 's/ //g'`" \ - $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > H5lib_settings.h || \ + $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > $@ || \ (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ ($(RM) $@ ; exit 1) diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c index 2d5b95d..992195d 100644 --- a/tools/h5copy/h5copy.c +++ b/tools/h5copy/h5copy.c @@ -90,11 +90,21 @@ usage: h5copy [OPTIONS] [OBJECTS...]\n\ -V, --version Print version number and exit\n\ -f, --flag Flag type\n\n\ Flag type is one of the following strings:\n\n\ - shallow Copy only immediate members for groups\n\ - soft Expand soft links into new objects\n\ - ext Expand external links into new objects\n\ - ref Copy objects that are pointed by references\n\ - noattr Copy object without copying attributes\n\ + shallow Copy only immediate members for groups\n\n\ + soft Expand soft links into new objects\n\n\ + ext Expand external links into new objects\n\n\ + ref Copy references and any referenced objects, i.e., objects\n\ + that the references point to.\n\ + Referenced objects are copied in addition to the objects\n\ + specified on the command line and reference datasets are\n\ + populated with correct reference values. Copies of referenced\n\ + datasets outside the copy range specified on the command line\n\ + will normally have a different name from the original.\n\ + (Default:Without this option, reference value(s) in any\n\ + reference datasets are set to NULL and referenced objects are\n\ + not copied unless they are otherwise within the copy range\n\ + specified on the command line.)\n\n\ + noattr Copy object without copying attributes\n\n\ allflags Switches all flags from the default to the non-default setting\n\n\ These flag types correspond to the following API symbols\n\n\ H5O_COPY_SHALLOW_HIERARCHY_FLAG\n\ diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index a82f9b1..4632ea0 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -242,6 +242,337 @@ int h5repack_addlayout(const char* str, return 0; } +/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr() + * were located in h5repack_copy.c as static prior to bugfix1726. + * Made shared functions as copy_attr() was needed in h5repack_refs.c. + * However copy_attr() may be obsoleted when H5Acopy is available and put back + * others to static in h5repack_copy.c. + */ +/*------------------------------------------------------------------------- +* Function: copy_named_datatype +* +* Purpose: Copies the specified datatype anonymously, and returns an open +* id for that datatype in the output file. The first time this +* is called it scans every named datatype in travt into a +* private stack, afterwards it simply scans that stack. The id +* returned must be closed after it is no longer needed. +* named_datatype_free must be called before the program exits +* to free the stack. +* +* Programmer: Neil Fortner +* +* Date: April 14, 2009 +* +*------------------------------------------------------------------------- +*/ +hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) +{ + named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ + named_dt_t *dt_ret = NULL; /* Datatype to return */ + H5O_info_t oinfo; /* Object info of input dtype */ + hid_t ret_value = -1; /* The identifier of the named dtype in the out file */ + + if(H5Oget_info(type_in, &oinfo) < 0) + goto error; + + if(*named_dt_head_p) + { + /* Stack already exists, search for the datatype */ + while(dt && dt->addr_in != oinfo.addr) + dt = dt->next; + + dt_ret = dt; + } + else + { + /* Create the stack */ + size_t i; + + for(i=0; i<travt->nobjs; i++) + if(travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) + { + /* Push onto the stack */ + if(NULL == (dt = (named_dt_t *) HDmalloc(sizeof(named_dt_t)))) + goto error; + dt->next = *named_dt_head_p; + *named_dt_head_p = dt; + + /* Update the address and id */ + dt->addr_in = travt->objs[i].objno; + dt->id_out = -1; + + /* Check if this type is the one requested */ + if(oinfo.addr == dt->addr_in) + { + HDassert(!dt_ret); + dt_ret = dt; + } /* end if */ + } /* end if */ + } /* end else */ + + /* Handle the case that the requested datatype was not found. This is + * possible if the datatype was committed anonymously in the input file. */ + if(!dt_ret) + { + /* Push the new datatype onto the stack */ + if(NULL == (dt_ret = (named_dt_t *) HDmalloc(sizeof(named_dt_t)))) + goto error; + dt_ret->next = *named_dt_head_p; + *named_dt_head_p = dt_ret; + + /* Update the address and id */ + dt_ret->addr_in = oinfo.addr; + dt_ret->id_out = -1; + } /* end if */ + + /* If the requested datatype does not yet exist in the output file, copy it + * anonymously */ + if(dt_ret->id_out < 0) + { + if (options->use_native==1) + dt_ret->id_out = h5tools_get_native_type(type_in); + else + dt_ret->id_out = H5Tcopy(type_in); + if(dt_ret->id_out < 0) + goto error; + if(H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto error; + } /* end if */ + + /* Set return value */ + ret_value = dt_ret->id_out; + + /* Increment the ref count on id_out, because the calling function will try + * to close it */ + if(H5Iinc_ref(ret_value) < 0) + goto error; + + return(ret_value); + +error: + return(-1); +} /* end copy_named_datatype */ + + +/*------------------------------------------------------------------------- +* Function: named_datatype_free +* +* Purpose: Frees the stack of named datatypes. +* +* Programmer: Neil Fortner +* +* Date: April 14, 2009 +* +*------------------------------------------------------------------------- +*/ +int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) +{ + named_dt_t *dt = *named_dt_head_p; + + while(dt) + { + /* Pop the datatype off the stack and free it */ + if(H5Tclose(dt->id_out) < 0 && !ignore_err) + goto error; + dt = dt->next; + HDfree(*named_dt_head_p); + *named_dt_head_p = dt; + } /* end while */ + + return 0; + +error: + return -1; +} /* end named_datatype_free */ + +/*------------------------------------------------------------------------- +* Function: copy_attr +* +* Purpose: copy attributes located in LOC_IN, which is obtained either from +* loc_id = H5Gopen2( fid, name); +* loc_id = H5Dopen2( fid, name); +* loc_id = H5Topen2( fid, name); +* +* Return: 0, ok, -1 no +* +* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu +* +* Date: October, 28, 2003 +* +*------------------------------------------------------------------------- +*/ +int copy_attr(hid_t loc_in, + hid_t loc_out, + named_dt_t **named_dt_head_p, + trav_table_t *travt, + pack_opt_t *options) +{ + hid_t attr_id=-1; /* attr ID */ + hid_t attr_out=-1; /* attr ID */ + hid_t space_id=-1; /* space ID */ + hid_t ftype_id=-1; /* file type ID */ + hid_t wtype_id=-1; /* read/write type ID */ + size_t msize; /* size of type */ + void *buf=NULL; /* data buffer */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + htri_t is_named; /* Whether the datatype is named */ + hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + char name[255]; + H5O_info_t oinfo; /* object info */ + int j; + unsigned u; + + if(H5Oget_info(loc_in, &oinfo) < 0) + goto error; + + /*------------------------------------------------------------------------- + * copy all attributes + *------------------------------------------------------------------------- + */ + + for ( u = 0; u < (unsigned)oinfo.num_attrs; u++) + { + buf=NULL; + + /* open attribute */ + if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + + /* get name */ + if (H5Aget_name( attr_id, (size_t)255, name ) < 0) + goto error; + + /* get the file datatype */ + if ((ftype_id = H5Aget_type( attr_id )) < 0 ) + goto error; + + /* Check if the datatype is committed */ + if((is_named = H5Tcommitted(ftype_id)) < 0) + goto error; + if(is_named) + { + hid_t fidout; + + /* Create out file id */ + if((fidout = H5Iget_file_id(loc_out)) < 0) + goto error; + + /* Copy named dt */ + if((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, + travt, options)) < 0) + { + H5Fclose(fidout); + goto error; + } /* end if */ + + if(H5Fclose(fidout) < 0) + goto error; + } /* end if */ + + /* get the dataspace handle */ + if ((space_id = H5Aget_space( attr_id )) < 0 ) + goto error; + + /* get dimensions */ + if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 ) + goto error; + + nelmts=1; + for (j=0; j<rank; j++) + nelmts*=dims[j]; + + /* wtype_id will have already been set if using a named dtype */ + if(!is_named) + { + if (options->use_native==1) + wtype_id = h5tools_get_native_type(ftype_id); + else + wtype_id = H5Tcopy(ftype_id); + } /* end if */ + + if ((msize=H5Tget_size(wtype_id))==0) + goto error; + + /*------------------------------------------------------------------------- + * object references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + * this is done on a second sweep of the file that just copies + * the referenced objects + *------------------------------------------------------------------------- + */ + + if (H5T_REFERENCE==H5Tget_class(wtype_id)) + { + ; + } + else + { + /*------------------------------------------------------------------------- + * read to memory + *------------------------------------------------------------------------- + */ + + buf = (void *)HDmalloc((size_t)(nelmts * msize)); + if(buf == NULL) + { + error_msg("h5repack", "cannot read into memory\n" ); + goto error; + } + if(H5Aread(attr_id, wtype_id, buf) < 0) + goto error; + + /*------------------------------------------------------------------------- + * copy + *------------------------------------------------------------------------- + */ + + if((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if(H5Awrite(attr_out, wtype_id, buf) < 0) + goto error; + + /*close*/ + if(H5Aclose(attr_out) < 0) + goto error; + + + if(buf) + free(buf); + + } /*H5T_REFERENCE*/ + + + if(options->verbose) + printf(FORMAT_OBJ_ATTR, "attr", name); + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + + if (H5Tclose(ftype_id) < 0) goto error; + if (H5Tclose(wtype_id) < 0) goto error; + if (H5Sclose(space_id) < 0) goto error; + if (H5Aclose(attr_id) < 0) goto error; + + } /* u */ + + + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(ftype_id); + H5Tclose(wtype_id); + H5Sclose(space_id); + H5Aclose(attr_id); + H5Aclose(attr_out); + if (buf) + free(buf); + } H5E_END_TRY; + return -1; +} /*------------------------------------------------------------------------- * Function: check_options diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index d02d41c..0e959a2 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -119,6 +119,11 @@ typedef struct { } pack_opt_t; +typedef struct named_dt_t { + haddr_t addr_in; /* Address of the named dtype in the in file */ + hid_t id_out; /* Open identifier for the dtype in the out file */ + struct named_dt_t *next; /* Next dtype */ +} named_dt_t; /*------------------------------------------------------------------------- * public functions @@ -138,6 +143,17 @@ int h5repack_end(pack_opt_t *options); int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options); int h5repack_cmp_pl(const char *fname1, const char *fname2); +/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr() + * and struct named_dt_t were located in h5repack_copy.c as static prior to + * bugfix1726. + * Made shared functions as copy_attr() was needed in h5repack_refs.c. + * However copy_attr() may be obsoleted when H5Acopy is available and put back + * others to static in h5repack_copy.c. + */ +hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options); +int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err); +int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, + trav_table_t *travt, pack_opt_t *options); #ifdef __cplusplus } diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index 35fc5fd..2b63fc0 100755 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -60,6 +60,7 @@ FILE14=h5repack_layouto.h5 # A file with an older version of the layout mes FILE15=h5repack_named_dtypes.h5 FILE16=tfamily%05d.h5 # located in common testfiles folder FILE_REF=h5repack_refs.h5 +FILE_ATTR_REF=h5repack_attr_refs.h5 nerrors=0 @@ -532,9 +533,15 @@ TOOLTEST $FILE15 # tests family driver (file is located in common testfiles folder, uses TOOLTEST1 TOOLTEST1 $FILE16 -# test various references (bug 1814) +# test various references (bug 1814 and 1726) TOOLTEST $FILE_REF +# test attribute with various references (bug 1797) +# the references in attribute of compund or vlen datatype +# TODO: include this test when code portion is completed. +SKIP $FILE_ATTR_REF +#TOOLTEST $FILE_ATTR_REF + if test $nerrors -eq 0 ; then echo "All $TESTNAME tests passed." exit $EXIT_SUCCESS diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index f95db63..12fdabc 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -25,11 +25,6 @@ * typedefs *------------------------------------------------------------------------- */ -typedef struct named_dt_t { - haddr_t addr_in; /* Address of the named dtype in the in file */ - hid_t id_out; /* Open identifier for the dtype in the out file */ - struct named_dt_t *next; /* Next dtype */ -} named_dt_t; /*------------------------------------------------------------------------- * globals @@ -49,11 +44,6 @@ extern char *progname; */ static void print_dataset_info(hid_t dcpl_id,char *objname,double per, int pr); static int do_copy_objects(hid_t fidin,hid_t fidout,trav_table_t *travt,pack_opt_t *options); -static int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, - trav_table_t *travt, pack_opt_t *options); -static hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, - trav_table_t *travt, pack_opt_t *options); -static int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err); static int copy_user_block(const char *infile, const char *outfile, hsize_t size); #if defined (H5REPACK_DEBUG_USER_BLOCK) static void print_user_block(const char *filename, hid_t fid); @@ -1200,195 +1190,6 @@ error: /*------------------------------------------------------------------------- -* Function: copy_attr -* -* Purpose: copy attributes located in LOC_IN, which is obtained either from -* loc_id = H5Gopen2( fid, name); -* loc_id = H5Dopen2( fid, name); -* loc_id = H5Topen2( fid, name); -* -* Return: 0, ok, -1 no -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: October, 28, 2003 -* -*------------------------------------------------------------------------- -*/ - -int copy_attr(hid_t loc_in, - hid_t loc_out, - named_dt_t **named_dt_head_p, - trav_table_t *travt, - pack_opt_t *options - ) -{ - hid_t attr_id=-1; /* attr ID */ - hid_t attr_out=-1; /* attr ID */ - hid_t space_id=-1; /* space ID */ - hid_t ftype_id=-1; /* file type ID */ - hid_t wtype_id=-1; /* read/write type ID */ - size_t msize; /* size of type */ - void *buf=NULL; /* data buffer */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - htri_t is_named; /* Whether the datatype is named */ - hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ - char name[255]; - H5O_info_t oinfo; /* object info */ - int j; - unsigned u; - - if(H5Oget_info(loc_in, &oinfo) < 0) - goto error; - - /*------------------------------------------------------------------------- - * copy all attributes - *------------------------------------------------------------------------- - */ - - for ( u = 0; u < (unsigned)oinfo.num_attrs; u++) - { - - buf=NULL; - - /* open attribute */ - if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - - /* get name */ - if (H5Aget_name( attr_id, (size_t)255, name ) < 0) - goto error; - - /* get the file datatype */ - if ((ftype_id = H5Aget_type( attr_id )) < 0 ) - goto error; - - /* Check if the datatype is committed */ - if((is_named = H5Tcommitted(ftype_id)) < 0) - goto error; - if(is_named) { - hid_t fidout; - - /* Create out file id */ - if((fidout = H5Iget_file_id(loc_out)) < 0) - goto error; - - /* Copy named dt */ - if((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, - travt, options)) < 0) { - H5Fclose(fidout); - goto error; - } /* end if */ - - if(H5Fclose(fidout) < 0) - goto error; - } /* end if */ - - /* get the dataspace handle */ - if ((space_id = H5Aget_space( attr_id )) < 0 ) - goto error; - - /* get dimensions */ - if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 ) - goto error; - - nelmts=1; - for (j=0; j<rank; j++) - nelmts*=dims[j]; - - /* wtype_id will have already been set if using a named dtype */ - if(!is_named) { - if (options->use_native==1) - wtype_id = h5tools_get_native_type(ftype_id); - else - wtype_id = H5Tcopy(ftype_id); - } /* end if */ - - if ((msize=H5Tget_size(wtype_id))==0) - goto error; - - /*------------------------------------------------------------------------- - * object references are a special case - * we cannot just copy the buffers, but instead we recreate the reference - * this is done on a second sweep of the file that just copies - * the referenced objects - *------------------------------------------------------------------------- - */ - - if (H5T_REFERENCE==H5Tget_class(wtype_id)) - { - ; - } - else - { - /*------------------------------------------------------------------------- - * read to memory - *------------------------------------------------------------------------- - */ - - buf = (void *)HDmalloc((size_t)(nelmts * msize)); - if(buf == NULL) { - error_msg(progname, "cannot read into memory\n" ); - goto error; - } - if(H5Aread(attr_id, wtype_id, buf) < 0) - goto error; - - /*------------------------------------------------------------------------- - * copy - *------------------------------------------------------------------------- - */ - - if((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - if(H5Awrite(attr_out, wtype_id, buf) < 0) - goto error; - - /*close*/ - if(H5Aclose(attr_out) < 0) - goto error; - - - if(buf) - free(buf); - - } /*H5T_REFERENCE*/ - - - if(options->verbose) - printf(FORMAT_OBJ_ATTR, "attr", name); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - if (H5Tclose(ftype_id) < 0) goto error; - if (H5Tclose(wtype_id) < 0) goto error; - if (H5Sclose(space_id) < 0) goto error; - if (H5Aclose(attr_id) < 0) goto error; - - } /* u */ - - - return 0; - -error: - H5E_BEGIN_TRY { - H5Tclose(ftype_id); - H5Tclose(wtype_id); - H5Sclose(space_id); - H5Aclose(attr_id); - H5Aclose(attr_out); - if (buf) - free(buf); - } H5E_END_TRY; - return -1; -} - - -/*------------------------------------------------------------------------- * Function: print_dataset_info * * Purpose: print name, filters, percentage compression of a dataset @@ -1494,138 +1295,6 @@ static void print_dataset_info(hid_t dcpl_id, /*------------------------------------------------------------------------- -* Function: copy_named_datatype -* -* Purpose: Copies the specified datatype anonymously, and returns an open -* id for that datatype in the output file. The first time this -* is called it scans every named datatype in travt into a -* private stack, afterwards it simply scans that stack. The id -* returned must be closed after it is no longer needed. -* named_datatype_free must be called before the program exits -* to free the stack. -* -* Programmer: Neil Fortner -* -* Date: April 14, 2009 -* -*------------------------------------------------------------------------- -*/ -static hid_t -copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) -{ - named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ - named_dt_t *dt_ret = NULL; /* Datatype to return */ - H5O_info_t oinfo; /* Object info of input dtype */ - hid_t ret_value = -1; /* The identifier of the named dtype in the out file */ - - if(H5Oget_info(type_in, &oinfo) < 0) - goto error; - - if(*named_dt_head_p) { - /* Stack already exists, search for the datatype */ - while(dt && dt->addr_in != oinfo.addr) - dt = dt->next; - - dt_ret = dt; - } else { - /* Create the stack */ - size_t i; - - for(i=0; i<travt->nobjs; i++) - if(travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { - /* Push onto the stack */ - if(NULL == (dt = (named_dt_t *) HDmalloc(sizeof(named_dt_t)))) - goto error; - dt->next = *named_dt_head_p; - *named_dt_head_p = dt; - - /* Update the address and id */ - dt->addr_in = travt->objs[i].objno; - dt->id_out = -1; - - /* Check if this type is the one requested */ - if(oinfo.addr == dt->addr_in) { - HDassert(!dt_ret); - dt_ret = dt; - } /* end if */ - } /* end if */ - } /* end else */ - - /* Handle the case that the requested datatype was not found. This is - * possible if the datatype was committed anonymously in the input file. */ - if(!dt_ret) { - /* Push the new datatype onto the stack */ - if(NULL == (dt_ret = (named_dt_t *) HDmalloc(sizeof(named_dt_t)))) - goto error; - dt_ret->next = *named_dt_head_p; - *named_dt_head_p = dt_ret; - - /* Update the address and id */ - dt_ret->addr_in = oinfo.addr; - dt_ret->id_out = -1; - } /* end if */ - - /* If the requested datatype does not yet exist in the output file, copy it - * anonymously */ - if(dt_ret->id_out < 0) { - if (options->use_native==1) - dt_ret->id_out = h5tools_get_native_type(type_in); - else - dt_ret->id_out = H5Tcopy(type_in); - if(dt_ret->id_out < 0) - goto error; - if(H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0) - goto error; - } /* end if */ - - /* Set return value */ - ret_value = dt_ret->id_out; - - /* Increment the ref count on id_out, because the calling function will try - * to close it */ - if(H5Iinc_ref(ret_value) < 0) - goto error; - - return(ret_value); - -error: - return(-1); -} /* end copy_named_datatype */ - - -/*------------------------------------------------------------------------- -* Function: named_datatype_free -* -* Purpose: Frees the stack of named datatypes. -* -* Programmer: Neil Fortner -* -* Date: April 14, 2009 -* -*------------------------------------------------------------------------- -*/ -static int -named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) -{ - named_dt_t *dt = *named_dt_head_p; - - while(dt) { - /* Pop the datatype off the stack and free it */ - if(H5Tclose(dt->id_out) < 0 && !ignore_err) - goto error; - dt = dt->next; - HDfree(*named_dt_head_p); - *named_dt_head_p = dt; - } /* end while */ - - return 0; - -error: - return -1; -} /* end named_datatype_free */ - - -/*------------------------------------------------------------------------- * Function: copy_user_block * * Purpose: copy user block from one file to another diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index 9945f49..fcdfbd5 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -68,6 +68,8 @@ int do_copy_refobjs(hid_t fidin, hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ unsigned int i, j; int k; + named_dt_t *named_dt_head=NULL; /* Pointer to the stack of named datatypes + copied */ /*------------------------------------------------------------------------- * browse @@ -220,13 +222,20 @@ int do_copy_refobjs(hid_t fidin, HDfree(buf); if(refbuf) HDfree(refbuf); + + /*------------------------------------------------------ + * copy attrs + *----------------------------------------------------*/ + if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + goto error; } /*H5T_STD_REF_OBJ*/ /*------------------------------------------------------------------------- * dataset region references *------------------------------------------------------------------------- */ - else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { + else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) + { hid_t refobj_id; hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ hdset_reg_ref_t *buf = NULL; /* output buffer */ @@ -305,6 +314,12 @@ int do_copy_refobjs(hid_t fidin, HDfree(buf); if(refbuf) HDfree(refbuf); + + /*----------------------------------------------------- + * copy attrs + *----------------------------------------------------*/ + if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + goto error; } /* H5T_STD_REF_DSETREG */ /*------------------------------------------------------------------------- * not references, open previously created object in 1st traversal @@ -380,6 +395,12 @@ int do_copy_refobjs(hid_t fidin, } /* end switch */ } /* end for */ + /* Finalize (link) the stack of named datatypes (if any) + * This function is paired with copy_named_datatype() which is called + * in copy_attr(), so need to free. + */ + named_datatype_free(&named_dt_head, 0); + return 0; error: @@ -393,6 +414,7 @@ error: H5Tclose(ftype_id); H5Tclose(mtype_id); H5Tclose(type_in); + named_datatype_free(&named_dt_head, 0); } H5E_END_TRY; return -1; diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 50e4cfe..1d262cf 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -81,6 +81,9 @@ /* obj and region references */ #define FNAME_REF "h5repack_refs.h5" +/* obj and region references in attr of compound and vlen type */ +#define FNAME_ATTR_REF "h5repack_attr_refs.h5" + const char *H5REPACK_FILENAMES[] = { "h5repack_big_out", NULL @@ -103,11 +106,11 @@ int d_status = EXIT_SUCCESS; #define USERBLOCK_SIZE 2048 /* obj and region references */ -#define NAME_OBJ_DS "Dset1" +#define NAME_OBJ_DS1 "Dset1" #define NAME_OBJ_GRP "Group" #define NAME_OBJ_NDTYPE "NamedDatatype" +#define NAME_OBJ_DS2 "Dset2" #define REG_REF_DS1 "Dset_REGREF" -#define REG_REF_DS2 "Dset2" /*------------------------------------------------------------------------- * prototypes @@ -142,6 +145,7 @@ static int verify_userblock( const char* filename); static int make_userblock_file(void); static int make_named_dtype(hid_t loc_id); static int make_references(hid_t loc_id); +static int make_complex_attr_references(hid_t loc_id); /*------------------------------------------------------------------------- @@ -1823,15 +1827,29 @@ int make_testfiles(void) return -1; /*------------------------------------------------------------------------- - * create a file with obj and region references + * create obj and region reference type datasets (bug1814) + * add attribute with int type (bug1726) + * add attribute with obj and region reference type (bug1726) *-------------------------------------------------------------------------*/ if((fid = H5Fcreate(FNAME_REF,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) return -1; + /* create reference type datasets */ if (make_references(fid) < 0) goto out; if(H5Fclose(fid) < 0) return -1; + /*------------------------------------------------------------------------- + * create a file with obj and region references in attribute of compound and + * vlen datatype + *-------------------------------------------------------------------------*/ + if((fid = H5Fcreate(FNAME_ATTR_REF,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + return -1; + if (make_complex_attr_references(fid) < 0) + goto out; + if(H5Fclose(fid) < 0) + return -1; + return 0; out: @@ -5653,29 +5671,172 @@ out: } /* end make_named_dtype() */ /*------------------------------------------------------------------------- - * Function: gen_obj_ref + * Function: add_attr_with_objref * * Purpose: - * Generate object references to objects (dataset,group and named datatype) + * Create attributes with object reference to objects (dset, + * group, datatype). * * Note: - * copied from h5copygentest.c and upate to create named datatype + * this function depends on locally created objects, however can be modified + * to be independent as necessary * - * Programmer: Jonathan Kim (March 18, 2010) + * Programmer: Jonathan Kim (March 23, 2010) *------------------------------------------------------------------------*/ -static herr_t gen_obj_ref(hid_t loc_id) +static herr_t add_attr_with_objref(hid_t file_id, hid_t obj_id) { - hid_t sid=0, oid=0, tid=0; - hsize_t dims1[1]={3}; - hsize_t dims2[1]={3}; - int data[3] = {10,20,30}; - hobj_ref_t objref_buf[3]; /* write buffer for obj reference */ + int ret = SUCCEED; + int status; + /* attr obj ref */ + hsize_t dim_attr_objref[1]={3}; + hobj_ref_t data_attr_objref[3]; + + /* -------------------------------- + * add attribute with obj ref type + */ + /* ref to dset */ + status = H5Rcreate(&data_attr_objref[0],file_id,NAME_OBJ_DS1,H5R_OBJECT,-1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* ref to group */ + status = H5Rcreate(&data_attr_objref[1],file_id,NAME_OBJ_GRP,H5R_OBJECT,-1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* ref to datatype */ + status = H5Rcreate(&data_attr_objref[2],file_id,NAME_OBJ_NDTYPE,H5R_OBJECT,-1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* create attr with obj ref type */ + status = make_attr(obj_id,1,dim_attr_objref,"Attr_OBJREF",H5T_STD_REF_OBJ,data_attr_objref); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + +out: + + return ret; +} + +/*------------------------------------------------------------------------- + * Function: add_attr_with_regref + * + * Purpose: + * Create attributes with region reference to dset + * + * Note: + * this function depends on locally created objects, however can be modified + * to be independent as necessary + * + * Programmer: Jonathan Kim (March 23, 2010) + *------------------------------------------------------------------------*/ +static herr_t add_attr_with_regref(hid_t file_id, hid_t obj_id) +{ + int ret = SUCCEED; + int status; + + /* attr region ref */ + hid_t sid_regrefed_dset=0; + hsize_t dim_regrefed_dset[2]={3,6}; + hsize_t coords_regrefed_dset[3][2] = {{0,1},{1,2},{2,3}}; + hsize_t dim_attr_regref[1]= {1}; /* dim of */ + hdset_reg_ref_t data_attr_regref[1]; + + + /* ----------------------------------- + * add attribute with region ref type + */ + sid_regrefed_dset = H5Screate_simple (2, dim_regrefed_dset, NULL); + if (sid_regrefed_dset < 0) + { + fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* select elements space for reference */ + status = H5Sselect_elements (sid_regrefed_dset, H5S_SELECT_SET, 3, coords_regrefed_dset[0]); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* create region reference from elements space */ + status = H5Rcreate (&data_attr_regref[0], file_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_regrefed_dset); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* create attr with region ref type */ + status = make_attr(obj_id,1,dim_attr_regref,"Attr_REGREF",H5T_STD_REF_DSETREG,data_attr_regref); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> make_attr failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + +out: + if (sid_regrefed_dset > 0) + H5Sclose (sid_regrefed_dset); + + return ret; + +} + +/*------------------------------------------------------------------------- + * Function: gen_refered_objs + * + * Purpose: + * Create objects (dataset, group, datatype) to be referenced + * + * Note: + * This function is to use along with gen_obj_ref() gen_region_ref() + * + * Programmer: Jonathan Kim (March 23, 2010) + *------------------------------------------------------------------------*/ +static herr_t gen_refered_objs(hid_t loc_id) +{ int status; herr_t ret = SUCCEED; - /*-------------- - * add dataset */ + /* objects (dset, group, datatype) */ + hid_t sid=0, did1=0, gid=0, tid=0; + hsize_t dims1[1]={3}; + int data[3] = {10,20,30}; + + /* Dset2 */ + hid_t sid2=0, did2=0; + hsize_t dims2[2] = {3,16}; + char data2[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; + + /*----------------------- + * add short dataset + * (define NAME_OBJ_DS1) + */ sid = H5Screate_simple(1, dims1, NULL); if (sid < 0) { @@ -5684,15 +5845,15 @@ static herr_t gen_obj_ref(hid_t loc_id) goto out; } - oid = H5Dcreate2 (loc_id, NAME_OBJ_DS, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (oid < 0) + did1 = H5Dcreate2 (loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (did1 < 0) { fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - status = H5Dwrite(oid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + status = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); @@ -5700,22 +5861,21 @@ static herr_t gen_obj_ref(hid_t loc_id) goto out; } - H5Dclose(oid); - H5Sclose(sid); - /*-------------- - * add group */ - oid = H5Gcreate2 (loc_id, NAME_OBJ_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (oid < 0) + * add group + * (define NAME_OBJ_GRP) + */ + gid = H5Gcreate2 (loc_id, NAME_OBJ_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (gid < 0) { fprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } - H5Gclose(oid); /*---------------------- * add named datatype + * (define NAME_OBJ_NDTYPE) */ tid = H5Tcopy(H5T_NATIVE_INT); status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -5726,12 +5886,87 @@ static herr_t gen_obj_ref(hid_t loc_id) goto out; } + + /*-------------------------- + * create long dataset + * (define NAME_OBJ_DS2) + */ + sid2 = H5Screate_simple (2, dims2, NULL); + if (sid2 < 0) + { + fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* create normal dataset which is refered */ + did2 = H5Dcreate2 (loc_id, NAME_OBJ_DS2, H5T_STD_I8LE, sid2, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); + if (did2 < 0) + { + fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* write values to dataset */ + status = H5Dwrite (did2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + +out: + if(did1 > 0) + H5Dclose(did1); + if(gid > 0) + H5Gclose(gid); + if(tid > 0) + H5Tclose(tid); + if(sid > 0) + H5Sclose(sid); + + if(did2 > 0) + H5Dclose(did2); + if(sid2 > 0) + H5Sclose(sid2); + return ret; + +} + +/*------------------------------------------------------------------------- + * Function: gen_obj_ref + * + * Purpose: + * Generate object references to objects (dataset,group and named datatype) + * + * Note: + * copied from h5copygentest.c and upate to create named datatype + * + * Programmer: Jonathan Kim (March 18, 2010) + *------------------------------------------------------------------------*/ +static herr_t gen_obj_ref(hid_t loc_id) +{ + int status; + herr_t ret = SUCCEED; + + hid_t sid=0, oid=0; + hsize_t dims_dset_objref[1]={3}; + + /* attr with int type */ + hsize_t dim_attr_int[1]={2}; + int data_attr_int[2] = {10,20}; + + /* write buffer for obj reference */ + hobj_ref_t objref_buf[3]; + /*--------------------------------------------------------- * create obj references to the previously created objects. * Passing -1 as reference is an object.*/ /* obj ref to dataset */ - status = H5Rcreate (&objref_buf[0], loc_id, NAME_OBJ_DS, H5R_OBJECT, -1); + status = H5Rcreate (&objref_buf[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, -1); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); @@ -5760,7 +5995,7 @@ static herr_t gen_obj_ref(hid_t loc_id) /*--------------------------------------------------------- * create dataset contain references */ - sid = H5Screate_simple (1, dims2, NULL); + sid = H5Screate_simple (1, dims_dset_objref, NULL); if (sid < 0) { fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); @@ -5784,11 +6019,31 @@ static herr_t gen_obj_ref(hid_t loc_id) goto out; } + /* add attribute with int type */ + if (make_attr(oid,1,dim_attr_int,"integer",H5T_NATIVE_INT,data_attr_int) < 0) + goto out; + + /* add attribute with obj ref */ + status = add_attr_with_objref(loc_id, oid); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* add attribute with region ref */ + status = add_attr_with_regref(loc_id, oid); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + out: if(oid > 0) H5Dclose(oid); - if(tid > 0) - H5Tclose(tid); if(sid > 0) H5Sclose(sid); @@ -5808,13 +6063,18 @@ out: *------------------------------------------------------------------------*/ static herr_t gen_region_ref(hid_t loc_id) { - hid_t sid=0, oid1=0, oid2=0; int status; herr_t ret = SUCCEED; - char data[3][16] = {"The quick brown", "fox jumps over ", "the 5 lazy dogs"}; - hsize_t dims2[2] = {3,16}; - hsize_t coords[4][2] = { {0,1}, {2,11}, {1,0}, {2,4} }; + /* target dataset */ + hid_t sid_trg=0; + hsize_t dims_trg[2] = {3,16}; + + /* dset with region ref type */ + hid_t sid_ref=0, oid_ref=0; + + /* region ref to target dataset */ + hsize_t coords[4][2] = { {0,1}, {2,11}, {1,0}, {2,4} }; hdset_reg_ref_t rr_data[2]; hsize_t start[2] = {0,0}; hsize_t stride[2] = {2,11}; @@ -5822,34 +6082,20 @@ static herr_t gen_region_ref(hid_t loc_id) hsize_t block[2] = {1,3}; hsize_t dims1[1] = {2}; - sid = H5Screate_simple (2, dims2, NULL); - if (sid < 0) - { - fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); - ret = FAIL; - goto out; - } - - /* create normal dataset which is refered */ - oid2 = H5Dcreate2 (loc_id, REG_REF_DS2, H5T_STD_I8LE, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid2 < 0) - { - fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); - ret = FAIL; - goto out; - } + /* attr with int type */ + hsize_t dim_attr_int[1]={2}; + int data_attr_int[2] = {10,20}; - /* write values to dataset */ - status = H5Dwrite (oid2, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if (status < 0) + sid_trg = H5Screate_simple (2, dims_trg, NULL); + if (sid_trg < 0) { - fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; goto out; } /* select elements space for reference */ - status = H5Sselect_elements (sid, H5S_SELECT_SET, 4, coords[0]); + status = H5Sselect_elements (sid_trg, H5S_SELECT_SET, 4, coords[0]); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); @@ -5858,7 +6104,7 @@ static herr_t gen_region_ref(hid_t loc_id) } /* create region reference from elements space */ - status = H5Rcreate (&rr_data[0], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); + status = H5Rcreate (&rr_data[0], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); @@ -5867,7 +6113,7 @@ static herr_t gen_region_ref(hid_t loc_id) } /* select hyperslab space for reference */ - status = H5Sselect_hyperslab (sid, H5S_SELECT_SET, start, stride, count, block); + status = H5Sselect_hyperslab (sid_trg, H5S_SELECT_SET, start, stride, count, block); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Sselect_hyperslab failed.\n", FUNC, __LINE__); @@ -5876,7 +6122,7 @@ static herr_t gen_region_ref(hid_t loc_id) } /* create region reference from hyperslab space */ - status = H5Rcreate (&rr_data[1], loc_id, REG_REF_DS2, H5R_DATASET_REGION, sid); + status = H5Rcreate (&rr_data[1], loc_id, NAME_OBJ_DS2, H5R_DATASET_REGION, sid_trg); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); @@ -5884,11 +6130,9 @@ static herr_t gen_region_ref(hid_t loc_id) goto out; } - H5Sclose (sid); - /* Create dataspace. */ - sid = H5Screate_simple (1, dims1, NULL); - if (sid < 0) + sid_ref = H5Screate_simple (1, dims1, NULL); + if (sid_ref < 0) { fprintf(stderr, "Error: %s %d> H5Screate_simple failed.\n", FUNC, __LINE__); ret = FAIL; @@ -5896,8 +6140,8 @@ static herr_t gen_region_ref(hid_t loc_id) } /* create region reference dataset */ - oid1 = H5Dcreate2 (loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - if (oid1 < 0) + oid_ref = H5Dcreate2 (loc_id, REG_REF_DS1, H5T_STD_REF_DSETREG, sid_ref, H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); + if (oid_ref < 0) { fprintf(stderr, "Error: %s %d> H5Dcreate2 failed.\n", FUNC, __LINE__); ret = FAIL; @@ -5905,7 +6149,7 @@ static herr_t gen_region_ref(hid_t loc_id) } /* write data as region references */ - status = H5Dwrite (oid1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); + status = H5Dwrite (oid_ref, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rr_data); if (status < 0) { fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); @@ -5913,13 +6157,35 @@ static herr_t gen_region_ref(hid_t loc_id) goto out; } + /* add attribute with int type */ + if (make_attr(oid_ref,1,dim_attr_int,"integer",H5T_NATIVE_INT,data_attr_int) < 0) + goto out; + + /* add attribute with obj ref */ + status = add_attr_with_objref(loc_id, oid_ref); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> add_attr_with_objref failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* add attribute with region ref */ + status = add_attr_with_regref(loc_id, oid_ref); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> add_attr_with_regref failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + out: - if (oid1 > 0) - H5Dclose (oid1); - if (oid2 > 0) - H5Dclose (oid2); - if (sid > 0) - H5Sclose (sid); + if (oid_ref > 0) + H5Dclose (oid_ref); + if (sid_ref > 0) + H5Sclose (sid_ref); + if (sid_trg > 0) + H5Sclose (sid_trg); return ret; } @@ -5937,6 +6203,14 @@ static herr_t make_references(hid_t loc_id) herr_t ret = SUCCEED; herr_t status; + /* add target objects */ + status = gen_refered_objs(loc_id); + if (status == FAIL) + { + fprintf(stderr, "Failed to generate referenced object.\n"); + ret = FAIL; + } + /* add object reference */ status = gen_obj_ref(loc_id); if (status == FAIL) @@ -5956,3 +6230,436 @@ static herr_t make_references(hid_t loc_id) return ret; } +/*------------------------------------------------------------------------- +* Function: make_complex_attr_references +* +* Purpose: +* create a file with : +* 1. obj ref in attribute of compound type +* 2. region ref in attribute of compound type +* 3. obj ref in attribute of vlen type +* 4. region ref in attribute of vlen type +* +* Programmer: Jonathan (March 25, 2010) +*------------------------------------------------------------------------- +*/ +/* obj dset */ +#define RANK_OBJ 2 +#define DIM0_OBJ 6 +#define DIM1_OBJ 10 +/* container dset */ +#define RANK_DSET 1 +#define DIM_DSET 4 +/* 1. obj references in compound attr */ +#define RANK_COMP_OBJREF 1 +#define DIM_COMP_OBJREF 3 /* for dataset, group, datatype */ +/* 2. region references in compound attr */ +#define RANK_COMP_REGREF 1 +#define DIM_COMP_REGREF 1 /* for element region */ +/* 3. obj references in vlen attr */ +#define RANK_VLEN_OBJREF 1 +#define DIM_VLEN_OBJREF 3 /* for dataset, group, datatype */ +#define LEN0_VLEN_OBJREF 1 /* dataset */ +#define LEN1_VLEN_OBJREF 1 /* group */ +#define LEN2_VLEN_OBJREF 1 /* datatype */ +/* 4. region references in vlen attr */ +#define RANK_VLEN_REGREF 1 +#define DIM_VLEN_REGREF 1 /* for element region */ +#define LEN0_VLEN_REGREF 1 /* element region */ + +static herr_t make_complex_attr_references(hid_t loc_id) +{ + herr_t ret = SUCCEED; + herr_t status; + /* + * for objects + */ + hid_t objgid=0, objdid=0, objtid=0, objsid=0; + hsize_t obj_dims[RANK_OBJ] = {DIM0_OBJ, DIM1_OBJ}; + int obj_data[DIM0_OBJ][DIM1_OBJ]= + {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, + {10,11,12,13,14,15,16,17,18,19}, + {20,21,22,23,24,25,26,27,28,29}, + {30,31,32,33,34,35,36,37,38,39}, + {40,41,42,43,44,45,46,47,48,49}, + {50,51,52,53,54,55,56,57,58,59}}; + + /* + * group main + */ + hid_t main_gid=0; + /* + * dataset which the attribute will be attached to + */ + hsize_t main_dset_dims[RANK_DSET] = {DIM_DSET}; + hid_t main_sid=0, main_did=0; + /* + * 1. obj references in compound attr + */ + hid_t comp_objref_tid=0, comp_objref_aid=0; + typedef struct comp_objref_t { + hobj_ref_t val_objref; + int val_int; + } comp_objref_t; + comp_objref_t comp_objref_data[DIM_COMP_OBJREF]; + hid_t comp_objref_attr_sid=0; + hsize_t comp_objref_dim[RANK_COMP_OBJREF] = {DIM_COMP_OBJREF}; + + /* + * 2. region references in compound attr + */ + hid_t comp_regref_tid=0, comp_regref_aid=0; + typedef struct comp_regref_t { + hdset_reg_ref_t val_regref; + int val_int; + } comp_regref_t; + comp_regref_t comp_regref_data[DIM_COMP_REGREF]; + hid_t comp_regref_attr_sid=0; + hsize_t comp_regref_dim[RANK_COMP_REGREF] = {DIM_COMP_REGREF}; + hsize_t coords[4][2] = { {0,1}, {2,3}, {3,4}, {4,5} }; + + /* + * 3. obj references in vlen attr + */ + hid_t vlen_objref_attr_tid=0, vlen_objref_attr_sid=0; + hid_t vlen_objref_attr_id=0; + hvl_t vlen_objref_data[DIM_VLEN_OBJREF]; + hsize_t vlen_objref_dims[RANK_VLEN_OBJREF] = {DIM_VLEN_OBJREF}; + + /* + * 4. region references in vlen attr + */ + hid_t vlen_regref_attr_tid=0, vlen_regref_attr_sid=0; + hid_t vlen_regref_attr_id=0; + hvl_t vlen_regref_data[DIM_VLEN_REGREF]; + hsize_t vlen_regref_dim[RANK_VLEN_REGREF] = {DIM_VLEN_REGREF}; + + + /* --------------------------------------- + * create objects which to be referenced + */ + /* object1 group */ + objgid = H5Gcreate2(loc_id, NAME_OBJ_GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + /* object2 dataset */ + objsid = H5Screate_simple(RANK_OBJ, obj_dims, NULL); + objdid = H5Dcreate2(loc_id, NAME_OBJ_DS1, H5T_NATIVE_INT, objsid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + status = H5Dwrite(objdid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_data[0]); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* object3 named datatype */ + objtid = H5Tcopy(H5T_NATIVE_INT); + status = H5Tcommit2(loc_id, NAME_OBJ_NDTYPE, objtid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Tcommit2 failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + + /* --------------------------------------------- + * Put testing objs in this group + * create group contain dataset with attribute and the attribute has + * compound type which contain obj and region reference */ + main_gid = H5Gcreate2(loc_id, "group_main", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (main_gid < 0) + { + fprintf(stderr, "Error: %s %d> H5Gcreate2 failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /*---------------------------------------------------------- + * create dataset which the attribute will be attached to + */ + main_sid = H5Screate_simple(RANK_DSET, main_dset_dims, NULL); + + main_did = H5Dcreate2(main_gid, "dset_main", H5T_NATIVE_INT, main_sid, H5P_DEFAULT,H5P_DEFAULT, H5P_DEFAULT); + + status = H5Dwrite(main_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obj_data[0]); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Dwrite failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /*------------------------------------------------------------------- + * 1. create obj references in a attribute of compound type + */ + + /* + * create compound type for attribute + */ + comp_objref_tid = H5Tcreate (H5T_COMPOUND, sizeof(comp_objref_t)); + + H5Tinsert(comp_objref_tid, "value_objref", HOFFSET(comp_objref_t, val_objref), H5T_STD_REF_OBJ); + H5Tinsert(comp_objref_tid, "value_int", HOFFSET(comp_objref_t, val_int), H5T_NATIVE_INT); + + /* + * Create the object references into compound type + */ + /* references to dataset */ + status = H5Rcreate (&(comp_objref_data[0].val_objref), loc_id, NAME_OBJ_DS1, H5R_OBJECT,-1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + comp_objref_data[0].val_int = 0; + + /* references to group */ + status = H5Rcreate (&(comp_objref_data[1].val_objref), loc_id, NAME_OBJ_GRP, H5R_OBJECT,-1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + comp_objref_data[1].val_int = 10; + + /* references to datatype */ + status = H5Rcreate (&(comp_objref_data[2].val_objref), loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT,-1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + comp_objref_data[2].val_int = 20; + + /* + * create attribute and write the object ref + */ + comp_objref_attr_sid = H5Screate_simple (RANK_COMP_OBJREF, comp_objref_dim, NULL); + comp_objref_aid = H5Acreate2 (main_did, "Comp_OBJREF", comp_objref_tid, comp_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite (comp_objref_aid, comp_objref_tid, comp_objref_data); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /*------------------------------------------------------------------- + * 2. create region references in attribute of compound type + */ + /* + * create compound type for attribute + */ + comp_regref_tid = H5Tcreate (H5T_COMPOUND, sizeof(comp_regref_t)); + + H5Tinsert(comp_regref_tid, "value_regref", HOFFSET(comp_regref_t, val_regref), H5T_STD_REF_DSETREG); + H5Tinsert(comp_regref_tid, "value_int", HOFFSET(comp_regref_t, val_int), H5T_NATIVE_INT); + + /* + * create the region reference + */ + status = H5Sselect_elements (objsid, H5S_SELECT_SET, 4, coords[0]); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + status = H5Rcreate (&(comp_regref_data[0].val_regref), loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + comp_regref_data[0].val_int = 10; + + /* + * create attribute and write the region ref + */ + comp_regref_attr_sid = H5Screate_simple (RANK_COMP_REGREF, comp_regref_dim, NULL); + comp_regref_aid = H5Acreate2 (main_did, "Comp_REGREF", comp_regref_tid, comp_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite (comp_regref_aid, comp_regref_tid, comp_regref_data); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + + /*------------------------------------------------------------------- + * 3. create obj references in attribute of vlen type + */ + /* + * prepare vlen data + */ + vlen_objref_data[0].len = LEN0_VLEN_OBJREF; + vlen_objref_data[0].p = malloc (vlen_objref_data[0].len * sizeof(hobj_ref_t)); + vlen_objref_data[1].len = LEN1_VLEN_OBJREF; + vlen_objref_data[1].p = malloc (vlen_objref_data[1].len * sizeof(hobj_ref_t)); + vlen_objref_data[2].len = LEN2_VLEN_OBJREF; + vlen_objref_data[2].p = malloc (vlen_objref_data[2].len * sizeof(hobj_ref_t)); + + /* + * create obj references + */ + /* reference to dataset */ + status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_OBJECT, -1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + /* reference to group */ + status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[1].p)[0], loc_id, NAME_OBJ_GRP, H5R_OBJECT, -1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + /* reference to datatype */ + status = H5Rcreate (&((hobj_ref_t*)vlen_objref_data[2].p)[0], loc_id, NAME_OBJ_NDTYPE, H5R_OBJECT, -1); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* + * create vlen type with obj reference + */ + vlen_objref_attr_tid = H5Tvlen_create (H5T_STD_REF_OBJ); + vlen_objref_attr_sid = H5Screate_simple (RANK_VLEN_OBJREF, vlen_objref_dims, NULL); + + /* + * create attribute and write the object reference + */ + vlen_objref_attr_id = H5Acreate2(main_did, "Vlen_OBJREF", vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite (vlen_objref_attr_id, vlen_objref_attr_tid, vlen_objref_data); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* close resource for vlen data */ + status = H5Dvlen_reclaim (vlen_objref_attr_tid, vlen_objref_attr_sid, H5P_DEFAULT, vlen_objref_data); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /*------------------------------------------------------------------- + * 4. create region references in a attribute of vlen type + */ + + /* + * prepare vlen data + */ + vlen_regref_data[0].len = LEN0_VLEN_REGREF; + vlen_regref_data[0].p = malloc (vlen_regref_data[0].len * sizeof(hdset_reg_ref_t)); + + /* + * create region reference + */ + status = H5Sselect_elements(objsid, H5S_SELECT_SET, 4, coords[0]); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Sselect_elements failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + status = H5Rcreate (&((hdset_reg_ref_t*)vlen_regref_data[0].p)[0], loc_id, NAME_OBJ_DS1, H5R_DATASET_REGION, objsid); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Rcreate failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* + * create vlen type with region reference + */ + vlen_regref_attr_tid = H5Tvlen_create(H5T_STD_REF_DSETREG); + vlen_regref_attr_sid = H5Screate_simple(RANK_VLEN_REGREF, vlen_regref_dim, NULL); + + /* + * create attribute and write the region reference + */ + vlen_regref_attr_id = H5Acreate2(main_did, "Vlen_REGREF", vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, H5P_DEFAULT); + status = H5Awrite(vlen_regref_attr_id, vlen_regref_attr_tid, vlen_regref_data); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Awrite failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + + /* close resource for vlen data */ + status = H5Dvlen_reclaim (vlen_regref_attr_tid, vlen_regref_attr_sid, H5P_DEFAULT, vlen_regref_data); + if (status < 0) + { + fprintf(stderr, "Error: %s %d> H5Dvlen_reclaim failed.\n", FUNC, __LINE__); + ret = FAIL; + goto out; + } + +out: + /* release resources */ + if (objgid < 0) + H5Gclose(objgid); + if (objsid < 0) + H5Sclose(objsid); + if (objdid < 0) + H5Dclose(objdid); + if (objtid < 0) + H5Tclose(objtid); + + if (main_gid < 0) + H5Gclose(main_gid); + if (main_sid < 0) + H5Sclose(main_sid); + if (main_did < 0) + H5Dclose(main_did); + /* comp obj ref */ + if (comp_objref_tid < 0) + H5Tclose(comp_objref_tid); + if (comp_objref_aid < 0) + H5Aclose(comp_objref_aid); + if (comp_objref_attr_sid < 0) + H5Sclose(comp_objref_attr_sid); + /* comp region ref */ + if (comp_regref_tid < 0) + H5Tclose(comp_regref_tid); + if (comp_regref_aid < 0) + H5Aclose(comp_regref_aid); + if (comp_regref_attr_sid < 0) + H5Sclose(comp_regref_attr_sid); + /* vlen obj ref */ + if (vlen_objref_attr_id < 0); + H5Aclose (vlen_objref_attr_id); + if (vlen_objref_attr_sid < 0); + H5Sclose (vlen_objref_attr_sid); + if (vlen_objref_attr_tid < 0); + H5Tclose (vlen_objref_attr_tid); + /* vlen region ref */ + if (vlen_regref_attr_id < 0); + H5Aclose (vlen_regref_attr_id); + if (vlen_regref_attr_sid < 0); + H5Sclose (vlen_regref_attr_sid); + if (vlen_regref_attr_tid < 0); + H5Tclose (vlen_regref_attr_tid); + + return ret; +} diff --git a/tools/h5repack/testfiles/h5repack_attr_refs.h5 b/tools/h5repack/testfiles/h5repack_attr_refs.h5 Binary files differnew file mode 100644 index 0000000..56974a3 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_attr_refs.h5 diff --git a/tools/h5repack/testfiles/h5repack_refs.h5 b/tools/h5repack/testfiles/h5repack_refs.h5 Binary files differindex 23d53e6..525267f 100644 --- a/tools/h5repack/testfiles/h5repack_refs.h5 +++ b/tools/h5repack/testfiles/h5repack_refs.h5 diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index a197134..950ce17 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -489,13 +489,13 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.64-FA_a4" +#define H5_PACKAGE_STRING "HDF5 1.9.66-FA_a4" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.64-FA_a4" +#define H5_PACKAGE_VERSION "1.9.66-FA_a4" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "ll" @@ -651,7 +651,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.64-FA_a4" +#define H5_VERSION "1.9.66-FA_a4" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ diff --git a/windows/misc/typegen/h5libsettings/h5libsettings.vcproj b/windows/misc/typegen/h5libsettings/h5libsettings.vcproj index 0077340..6f19395 100644 --- a/windows/misc/typegen/h5libsettings/h5libsettings.vcproj +++ b/windows/misc/typegen/h5libsettings/h5libsettings.vcproj @@ -195,8 +195,8 @@ />
<Tool
Name="VCPostBuildEventTool"
- Description="Generating H5lib_settings.h"
- CommandLine="if not exist "$(TargetDir)..\..\H5lib_settings.h" "$(TargetPath)" > "$(TargetDir)..\..\H5lib_settings.h""
+ Description="Generating H5lib_settings.c"
+ CommandLine="if not exist "$(TargetDir)..\..\H5lib_settings.c" "$(TargetPath)" > "$(TargetDir)..\..\H5lib_settings.c""
/>
</Configuration>
<Configuration
@@ -285,8 +285,8 @@ />
<Tool
Name="VCPostBuildEventTool"
- Description="Generating H5lib_settings.h"
- CommandLine="if not exist "$(TargetDir)..\..\H5lib_settings.h" "$(TargetPath)" > "$(TargetDir)..\..\H5lib_settings.h""
+ Description="Generating H5lib_settings.c"
+ CommandLine="if not exist "$(TargetDir)..\..\H5lib_settings.c" "$(TargetPath)" > "$(TargetDir)..\..\H5lib_settings.c""
/>
</Configuration>
<Configuration
@@ -376,8 +376,8 @@ />
<Tool
Name="VCPostBuildEventTool"
- Description="Generating H5lib_settings.h"
- CommandLine="if not exist "$(TargetDir)..\..\H5lib_settings.h" "$(TargetPath)" > "$(TargetDir)..\..\H5lib_settings.h""
+ Description="Generating H5lib_settings.c"
+ CommandLine="if not exist "$(TargetDir)..\..\H5lib_settings.c" "$(TargetPath)" > "$(TargetDir)..\..\H5lib_settings.c""
/>
</Configuration>
</Configurations>
diff --git a/windows/proj/hdf5/hdf5.vcproj b/windows/proj/hdf5/hdf5.vcproj index 4112451..2bc2d64 100644 --- a/windows/proj/hdf5/hdf5.vcproj +++ b/windows/proj/hdf5/hdf5.vcproj @@ -866,6 +866,10 @@ >
</File>
<File
+ RelativePath="..\..\..\src\H5lib_settings.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\src\H5MF.c"
>
</File>
diff --git a/windows/proj/hdf5dll/hdf5dll.vcproj b/windows/proj/hdf5dll/hdf5dll.vcproj index e2ed985..c755e83 100644 --- a/windows/proj/hdf5dll/hdf5dll.vcproj +++ b/windows/proj/hdf5dll/hdf5dll.vcproj @@ -953,6 +953,10 @@ >
</File>
<File
+ RelativePath="..\..\..\src\H5lib_settings.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\src\H5MF.c"
>
</File>
diff --git a/windows/src/H5pubconf.h b/windows/src/H5pubconf.h index c1f2a8c..8b3eb55 100755 --- a/windows/src/H5pubconf.h +++ b/windows/src/H5pubconf.h @@ -479,13 +479,13 @@ #define H5_PACKAGE_NAME "HDF5" /* Define to the full name and version of this package. */ -#define H5_PACKAGE_STRING "HDF5 1.9.64-FA_a4" +#define H5_PACKAGE_STRING "HDF5 1.9.66-FA_a4" /* Define to the one symbol short name of this package. */ #define H5_PACKAGE_TARNAME "hdf5" /* Define to the version of this package. */ -#define H5_PACKAGE_VERSION "1.9.64-FA_a4" +#define H5_PACKAGE_VERSION "1.9.66-FA_a4" /* Width for printf() for type `long long' or `__int64', use `ll' */ #define H5_PRINTF_LL_WIDTH "I64" @@ -642,7 +642,7 @@ /* #undef H5_USING_MEMCHECKER */ /* Version number of package */ -#define H5_VERSION "1.9.64-FA_a4" +#define H5_VERSION "1.9.66-FA_a4" /* Define if vsnprintf() returns the correct value for formatted strings that don't fit into size allowed */ |