From 801b5b09f26dac69e77bb4a794f2785977f9eb7e Mon Sep 17 00:00:00 2001 From: John Mainzer Date: Thu, 13 Jul 2006 12:59:39 -0500 Subject: [svn-r12462] Committed a variety of metadata cache related changes: 1) Added trace file support to the metadata cache. This allows capture of all metadata cache calls in trace files for purposes of optimization and debuging. 2) Added an expunge entry function. This allows an entry to be deleteded from the cache without writing it to disk even if it is dirty. 3) Added a function call to resize pinned entries. 4) Added code to deal with entries that are dirty on load. This is needed in support of a bug fix which can alter object headers on load to repair files. 5) Added progress reporting code to the "MDC API smoke check" test in cache_api.c. To enable the progress reporting, set report_progress to TRUE in mdc_api_call_smoke_check(). Tested with h5committest, and a parallel test on phoenix (dual athelon linux box). --- configure | 90 +-- configure.in | 22 + src/H5AC.c | 897 +++++++++++++++++++++++++++++- src/H5ACprivate.h | 20 + src/H5ACpublic.h | 87 ++- src/H5C.c | 383 ++++++++++++- src/H5Cpkg.h | 14 + src/H5Cprivate.h | 18 + src/H5Edefin.h | 4 +- src/H5Einit.h | 10 + src/H5Epubgen.h | 6 +- src/H5Eterm.h | 272 +++++----- src/H5config.h.in | 3 + src/H5err.txt | 2 + test/cache.c | 1501 ++++++++++++++++++++++++++++++++++++++++++++++++++- test/cache_api.c | 470 ++++++++++++++-- test/cache_common.c | 65 ++- test/cache_common.h | 4 + testpar/t_cache.c | 761 +++++++++++++++++++++++++- 19 files changed, 4340 insertions(+), 289 deletions(-) diff --git a/configure b/configure index 176bc3e..0174f6f 100755 --- a/configure +++ b/configure @@ -1073,6 +1073,8 @@ Optional Features: debugging). --enable-group-revision Enable the group revision code (for internal developers only). + --enable-metadata-trace-file + Enable metadata trace file collection. --enable-trace Enable API tracing capability. Default=no if debug is disabled. --enable-instrument Enable library instrumentation of optimization @@ -3519,7 +3521,7 @@ fi # Provide some information about the compiler. -echo "$as_me:3522:" \ +echo "$as_me:3524:" \ "checking for Fortran compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -3814,7 +3816,7 @@ _ACEOF # flags. ac_save_FFLAGS=$FCFLAGS FCFLAGS="$FCFLAGS $ac_verb" -(eval echo $as_me:3817: \"$ac_link\") >&5 +(eval echo $as_me:3819: \"$ac_link\") >&5 ac_fc_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$ac_fc_v_output" >&5 FCFLAGS=$ac_save_FFLAGS @@ -3892,7 +3894,7 @@ _ACEOF # flags. ac_save_FFLAGS=$FCFLAGS FCFLAGS="$FCFLAGS $ac_cv_prog_fc_v" -(eval echo $as_me:3895: \"$ac_link\") >&5 +(eval echo $as_me:3897: \"$ac_link\") >&5 ac_fc_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$ac_fc_v_output" >&5 FCFLAGS=$ac_save_FFLAGS @@ -6617,7 +6619,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6620 "configure"' > conftest.$ac_ext + echo '#line 6622 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7747,7 +7749,7 @@ fi # Provide some information about the compiler. -echo "$as_me:7750:" \ +echo "$as_me:7752:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -8816,11 +8818,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8819: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8821: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8823: \$? = $ac_status" >&5 + echo "$as_me:8825: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -9071,11 +9073,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9074: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9076: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9078: \$? = $ac_status" >&5 + echo "$as_me:9080: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -9131,11 +9133,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9134: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9136: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9138: \$? = $ac_status" >&5 + echo "$as_me:9140: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11403,7 +11405,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:13742: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13744: \$? = $ac_status" >&5 + echo "$as_me:13746: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -13797,11 +13799,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13800: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13802: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13804: \$? = $ac_status" >&5 + echo "$as_me:13806: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15216,7 +15218,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:16174: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16176: \$? = $ac_status" >&5 + echo "$as_me:16178: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16229,11 +16231,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16232: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16234: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16236: \$? = $ac_status" >&5 + echo "$as_me:16238: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18285,11 +18287,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18288: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18290: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18292: \$? = $ac_status" >&5 + echo "$as_me:18294: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -18540,11 +18542,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18543: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18545: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18547: \$? = $ac_status" >&5 + echo "$as_me:18549: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -18600,11 +18602,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18603: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18605: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:18607: \$? = $ac_status" >&5 + echo "$as_me:18609: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -20872,7 +20874,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&6 ;; esac +echo "$as_me:$LINENO: checking whether metadata trace file code is enabled" >&5 +echo $ECHO_N "checking whether metadata trace file code is enabled... $ECHO_C" >&6 +# Check whether --enable-metadata-trace-file or --disable-metadata-trace-file was given. +if test "${enable_metadata_trace_file+set}" = set; then + enableval="$enable_metadata_trace_file" + METADATATRACEFILE=$enableval +fi; + +case "X-$METADATATRACEFILE" in + X-yes) + METADATATRACEFILE=yes + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define METADATA_TRACE_FILE 1 +_ACEOF + + ;; + *) + METADATATRACEFILE=no + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; +esac + echo "$as_me:$LINENO: checking for API tracing" >&5 echo $ECHO_N "checking for API tracing... $ECHO_C" >&6; diff --git a/configure.in b/configure.in index e70346d..2349ca5 100644 --- a/configure.in +++ b/configure.in @@ -2049,6 +2049,28 @@ case "X-$GROUPREVISION" in esac dnl ---------------------------------------------------------------------- +dnl Check if they would like the metadata trace file code compiled in +dnl +AC_MSG_CHECKING([whether metadata trace file code is enabled]) +AC_ARG_ENABLE([metadata-trace-file], + [AC_HELP_STRING([--enable-metadata-trace-file], + [Enable metadata trace file collection.])], + [METADATATRACEFILE=$enableval]) + +case "X-$METADATATRACEFILE" in + X-yes) + METADATATRACEFILE=yes + AC_MSG_RESULT([yes]) + AC_DEFINE([METADATA_TRACE_FILE], [1], + [Define if the metadata trace file code is to be compiled in]) + ;; + *) + METADATATRACEFILE=no + AC_MSG_RESULT([no]) + ;; +esac + +dnl ---------------------------------------------------------------------- dnl Enable tracing of the API dnl This must come after the enable-debug since it depends on debug. dnl diff --git a/src/H5AC.c b/src/H5AC.c index cf794c6..a7ae790 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -742,6 +742,10 @@ done: * Added code to free the auxiliary structure and its * associated slist if present. * JRM - 6/28/05 + * + * Added code to close the trace file if it is present. + * + * JRM - 6/8/06 * *------------------------------------------------------------------------- */ @@ -768,6 +772,14 @@ H5AC_dest(H5F_t *f, hid_t dxpl_id) } #endif /* H5_HAVE_PARALLEL */ +#if H5AC__TRACE_FILE_ENABLED + if ( H5AC_close_trace_file(cache) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5AC_close_trace_file() failed.") + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + if ( H5C_dest(f, dxpl_id, H5AC_noblock_dxpl_id, cache) < 0 ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't destroy cache") @@ -802,6 +814,92 @@ done: /*------------------------------------------------------------------------- + * Function: H5AC_expunge_entry + * + * Purpose: Expunge the target entry from the cache without writing it + * to disk even if it is dirty. The entry must not be either + * pinned or protected. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 6/30/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_expunge_entry(H5F_t *f, + hid_t dxpl_id, + const H5AC_class_t *type, + haddr_t addr) +{ + herr_t result; + herr_t ret_value=SUCCEED; /* Return value */ + H5AC_t * cache_ptr = NULL; +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ + + FUNC_ENTER_NOAPI(H5AC_expunge_entry, FAIL) + + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + HDassert(type); + HDassert(type->clear); + HDassert(type->dest); + HDassert(H5F_addr_defined(addr)); + + cache_ptr = f->shared->cache; + +#if H5AC__TRACE_FILE_ENABLED + /* 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. + */ + if ( ( cache_ptr != NULL ) && + ( H5C_get_trace_file_ptr(cache_ptr, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_expunge_entry %lx %d", + (unsigned long)addr, + (int)(type->id)); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + + result = H5C_expunge_entry(f, + dxpl_id, + H5AC_noblock_dxpl_id, + cache_ptr, + type, + addr); + + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ + "H5C_expunge_entry() failed.") + } + +done: + +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5AC_expunge_entry() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_flush * * Purpose: Flush (and possibly destroy) the metadata cache associated @@ -871,6 +969,9 @@ done: * JRM -- 5/11/06 * Added call to the write_done callback. * + * JRM -- 6/6/06 + * Added trace file support. + * *------------------------------------------------------------------------- */ herr_t @@ -882,6 +983,10 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, unsigned flags) H5AC_aux_t * aux_ptr = NULL; int mpi_code; #endif /* H5_HAVE_PARALLEL */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_flush, FAIL) @@ -889,6 +994,20 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, unsigned flags) HDassert(f); HDassert(f->shared->cache); +#if H5AC__TRACE_FILE_ENABLED + /* For the flush, only the flags are really necessary in the trace file. + * Write the result to catch occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_flush 0x%x", flags); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + #ifdef H5_HAVE_PARALLEL aux_ptr = f->shared->cache->aux_ptr; @@ -972,6 +1091,13 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, unsigned flags) done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush() */ @@ -1118,6 +1244,9 @@ done: * the PHDF5 case. It should have no effect on either the * serial or FPHSD5 cases. * + * JRM - 6/6/06 + * Added trace file support. + * *------------------------------------------------------------------------- */ @@ -1131,6 +1260,11 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void * #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + size_t trace_entry_size = 0; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_set, FAIL) @@ -1142,6 +1276,27 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void * HDassert(H5F_addr_defined(addr)); HDassert(thing); +#if H5AC__TRACE_FILE_ENABLED + /* For the insert, only the addr, size, type id and flags are really + * necessary in the trace file. Write the result to catch occult + * errors. + * + * Note that some data is not available right now -- put what we can + * in the trace buffer now, and fill in the rest at the end. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( 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", + (unsigned long)addr, + type->id, + flags); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + /* Get local copy of this information */ cache = f->shared->cache; info = (H5AC_info_t *)thing; @@ -1181,6 +1336,14 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void * HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C_insert_entry() failed") } +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + /* make note of the entry size */ + trace_entry_size = ((H5C_cache_entry_t *)thing)->size; + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + #ifdef H5_HAVE_PARALLEL if ( ( aux_ptr != NULL ) && ( aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold ) ) { @@ -1199,6 +1362,15 @@ H5AC_set(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, void * done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d %d\n", trace, + (int)trace_entry_size, + (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set() */ @@ -1220,7 +1392,7 @@ done: * * Modifications: * - * None + * Added trace file support. JRM -- 6/6/06 * *------------------------------------------------------------------------- */ @@ -1233,9 +1405,31 @@ H5AC_mark_pinned_entry_dirty(H5F_t * f, H5C_t *cache_ptr = f->shared->cache; herr_t result; herr_t ret_value = SUCCEED; /* Return value */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_mark_pinned_entry_dirty, FAIL) +#if H5AC__TRACE_FILE_ENABLED + /* For the mark pinned entry dirty call, only the addr, size_changed, + * and new_size are really necessary in the trace file. Write the result + * to catch occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_mark_pinned_entry_dirty 0x%lx %d %d", + (unsigned long)(((H5C_cache_entry_t *)thing)->addr), + (int)size_changed, + (int)new_size); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + #ifdef H5_HAVE_PARALLEL HDassert( cache_ptr ); @@ -1290,6 +1484,13 @@ H5AC_mark_pinned_entry_dirty(H5F_t * f, done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_pinned_entry_dirty() */ @@ -1311,7 +1512,7 @@ done: * * Modifications: * - * None + * Added trace file support. JRM -- 6/6/06 * *------------------------------------------------------------------------- */ @@ -1325,9 +1526,29 @@ H5AC_mark_pinned_or_protected_entry_dirty(H5F_t * f, #endif /* H5_HAVE_PARALLEL */ herr_t result; herr_t ret_value = SUCCEED; /* Return value */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_mark_pinned_or_protected_entry_dirty, FAIL) +#if H5AC__TRACE_FILE_ENABLED + /* For the mark pinned or protected entry dirty call, only the addr + * is really necessary in the trace file. Write the result to catch + * occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_mark_pinned_or_protected_entry_dirty %lx", + (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + #ifdef H5_HAVE_PARALLEL HDassert( cache_ptr ); @@ -1366,6 +1587,13 @@ H5AC_mark_pinned_or_protected_entry_dirty(H5F_t * f, done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_pinned_entry_dirty() */ @@ -1411,6 +1639,9 @@ done: * To maintain this invarient, only rename entries immediately * after you unprotect them. * + * JRM - 6/6/06 + * Added trace file support. + * *------------------------------------------------------------------------- */ herr_t @@ -1421,6 +1652,10 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_ad #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_rename, FAIL) @@ -1431,6 +1666,24 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_ad HDassert(H5F_addr_defined(new_addr)); HDassert(H5F_addr_ne(old_addr, new_addr)); +#if H5AC__TRACE_FILE_ENABLED + /* For the rename call, only the old addr and new addr are really + * necessary in the trace file. Include the type id so we don't have to + * look it up. Also write the result to catch occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_rename %lx %lx %d", + (unsigned long)old_addr, + (unsigned long)new_addr, + (int)(type->id)); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + #ifdef H5_HAVE_PARALLEL if ( NULL != (aux_ptr = f->shared->cache->aux_ptr) ) { @@ -1475,6 +1728,13 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_ad done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_rename() */ @@ -1493,7 +1753,7 @@ done: * * Modifications: * - * None. + * Added trace file support. 6/6/06 * *------------------------------------------------------------------------- */ @@ -1504,9 +1764,28 @@ H5AC_pin_protected_entry(H5F_t * f, H5C_t *cache_ptr = f->shared->cache; herr_t result; herr_t ret_value = SUCCEED; /* Return value */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_pin_protected_entry, FAIL) +#if H5AC__TRACE_FILE_ENABLED + /* For the pin protected entry call, only the addr is really necessary + * in the trace file. Also write the result to catch occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_pin_protected_entry %lx", + (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + result = H5C_pin_protected_entry(cache_ptr, thing); if ( result < 0 ) { @@ -1517,6 +1796,13 @@ H5AC_pin_protected_entry(H5F_t * f, done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_pin_protected_entry() */ @@ -1579,6 +1865,9 @@ done: * in H5C.c, and then re-wrote the function as a wrapper for * H5C_protect(). * + * JRM - 6/6/06 + * Added trace file support. + * *------------------------------------------------------------------------- */ void * @@ -1590,8 +1879,14 @@ H5AC_protect(H5F_t *f, void *udata2, H5AC_protect_t UNUSED rw) { - void * thing = NULL; + /* char * fcn_name = "H5AC_protect"; */ + void * thing = (void *)NULL; void * ret_value; /* Return value */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + size_t trace_entry_size = 0; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_protect, NULL) @@ -1603,6 +1898,24 @@ H5AC_protect(H5F_t *f, HDassert(type->load); HDassert(H5F_addr_defined(addr)); +#if H5AC__TRACE_FILE_ENABLED + /* For the protect call, only the addr and type id is really necessary + * in the trace file. Include the size of the entry protected as a + * sanity check. Also indicate whether the call was successful to + * catch occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_protect %lx %d", + (unsigned long)addr, + (int)(type->id)); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + thing = H5C_protect(f, dxpl_id, H5AC_noblock_dxpl_id, @@ -1617,17 +1930,146 @@ H5AC_protect(H5F_t *f, HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C_protect() failed.") } +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + /* make note of the entry size */ + trace_entry_size = ((H5C_cache_entry_t *)thing)->size; + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + /* Set return value */ ret_value = thing; done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d %d\n", trace, + (int)trace_entry_size, + (int)(ret_value != NULL)); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_protect() */ /*------------------------------------------------------------------------- + * Function: H5AC_resize_pinned_entry + * + * Purpose: Resize a pinned entry. The target entry MUST be + * be pinned, and MUST not be unprotected. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 7/5/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_resize_pinned_entry(H5F_t * f, + void * thing, + size_t new_size) +{ + H5C_t *cache_ptr = f->shared->cache; + herr_t result; + herr_t ret_value = SUCCEED; /* Return value */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ + + FUNC_ENTER_NOAPI(H5AC_resize_pinned_entry, FAIL) + +#if H5AC__TRACE_FILE_ENABLED + /* For the resize pinned entry call, only the addr, and new_size are + * really necessary in the trace file. Write the result to catch + * occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_resize_pinned_entry 0x%lx %d %d", + (unsigned long)(((H5C_cache_entry_t *)thing)->addr), + (int)new_size); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + +#ifdef H5_HAVE_PARALLEL + + HDassert( cache_ptr ); + HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert( thing ); + + if ( ( ((H5AC_info_t *)thing)->is_dirty == FALSE ) && + ( NULL != cache_ptr->aux_ptr) ) { + + H5AC_info_t * entry_ptr; + + entry_ptr = (H5AC_info_t *)thing; + + if ( ! ( entry_ptr->is_pinned ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, \ + "Entry isn't pinned??") + } + + if ( entry_ptr->is_protected ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, \ + "Entry is protected??") + } + + result = H5AC_log_dirtied_entry(cache_ptr, + entry_ptr, + entry_ptr->addr, + TRUE, + new_size); + + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, \ + "H5AC_log_dirtied_entry() failed.") + } + } +#endif /* H5_HAVE_PARALLEL */ + + result = H5C_resize_pinned_entry(cache_ptr, + thing, + new_size); + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, \ + "H5C_resize_pinned_entry() failed.") + + } + +done: + +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5AC_resize_pinned_entry() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_unpin_entry() * * Purpose: Unpin a cache entry. The entry must be unprotected at @@ -1640,7 +2082,7 @@ done: * * Modifications: * - * None. + * Added code supporting the trace file. JRM -- 6/7/06 * *------------------------------------------------------------------------- */ @@ -1651,9 +2093,28 @@ H5AC_unpin_entry(H5F_t * f, H5C_t *cache_ptr = f->shared->cache; herr_t result; herr_t ret_value = SUCCEED; /* Return value */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_unpin_entry, FAIL) +#if H5AC__TRACE_FILE_ENABLED + /* For the unpin entry call, only the addr is really necessary + * in the trace file. Also write the result to catch occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_unpin_entry %lx", + (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + result = H5C_unpin_entry(cache_ptr, thing); if ( result < 0 ) { @@ -1663,6 +2124,13 @@ H5AC_unpin_entry(H5F_t * f, done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unpin_entry() */ @@ -1756,6 +2224,9 @@ done: * H5C_cache_entry_t in the test to see if the entry has * been dirtied. * + * JRM - 6/7/06 + * Added support for the trace file. + * *------------------------------------------------------------------------- */ herr_t @@ -1770,6 +2241,12 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ +#if H5AC__TRACE_FILE_ENABLED + char trace[128] = ""; + size_t trace_new_size = 0; + unsigned trace_flags = 0; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_unprotect, FAIL) @@ -1783,6 +2260,25 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, HDassert( ((H5AC_info_t *)thing)->addr == addr ); HDassert( ((H5AC_info_t *)thing)->type == type ); +#if H5AC__TRACE_FILE_ENABLED + /* For the unprotect call, only the addr, type id, flags, and possible + * new size are really necessary in the trace file. Write the return + * value to catch occult errors. + */ + if ( ( f != NULL ) && + ( f->shared != NULL ) && + ( f->shared->cache != NULL ) && + ( H5C_get_trace_file_ptr(f->shared->cache, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + sprintf(trace, "H5AC_protect %lx %d", + (unsigned long)addr, + (int)(type->id)); + + trace_flags = flags; + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + dirtied = ( ( (flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG ) || ( ((H5AC_info_t *)thing)->dirtied ) ); @@ -1798,6 +2294,10 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, size_changed = TRUE; flags = flags | H5AC__SIZE_CHANGED_FLAG; +#if H5AC__TRACE_FILE_ENABLED + trace_flags = flags; + trace_new_size = new_size; +#endif /* H5AC__TRACE_FILE_ENABLED */ } } @@ -1870,6 +2370,17 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, done: +#if H5AC__TRACE_FILE_ENABLED + if ( trace_file_ptr != NULL ) { + + HDfprintf(trace_file_ptr, "%s %d %x %d\n", + trace, + (int)trace_new_size, + (unsigned)trace_flags, + (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unprotect() */ @@ -1983,6 +2494,9 @@ done: * Added support for the new dirty_bytes_threshold field of * both H5AC_cache_config_t and H5AC_aux_t. * + * JRM - 6/8/06 + * Added support for the new trace file related fields. + * *------------------------------------------------------------------------- */ @@ -2036,6 +2550,9 @@ H5AC_get_cache_auto_resize_config(H5AC_t * cache_ptr, config_ptr->rpt_fcn_enabled = TRUE; } + config_ptr->open_trace_file = FALSE; + config_ptr->close_trace_file = FALSE; + config_ptr->trace_file_name[0] = '\0'; config_ptr->set_initial_size = internal_config.set_initial_size; config_ptr->initial_size = internal_config.initial_size; config_ptr->min_clean_fraction = internal_config.min_clean_fraction; @@ -2224,10 +2741,13 @@ done: * John Mainzer -- 4/6/05 * Updated for the addition of H5AC_cache_config_t. * - * John Mainzer -- 1025/05 - * Added support for the new dirty_bytes_threshold field of + * John Mainzer -- 10/25/05 + * Added support for the new dirty_bytes_threshold field of * both H5AC_cache_config_t and H5AC_aux_t. * + * John Mainzer -- 6/7/06 + * Added trace file support. + * *------------------------------------------------------------------------- */ @@ -2235,12 +2755,29 @@ herr_t H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, H5AC_cache_config_t *config_ptr) { - herr_t result; - herr_t ret_value = SUCCEED; /* Return value */ + /* const char * fcn_name = "H5AC_set_cache_auto_resize_config"; */ + herr_t result; + herr_t ret_value = SUCCEED; /* Return value */ + int name_len; H5C_auto_size_ctl_t internal_config; +#if H5AC__TRACE_FILE_ENABLED + H5AC_cache_config_t trace_config = H5AC__DEFAULT_CACHE_CONFIG; + FILE * trace_file_ptr = NULL; +#endif /* H5AC__TRACE_FILE_ENABLED */ FUNC_ENTER_NOAPI(H5AC_set_cache_auto_resize_config, FAIL) +#if H5AC__TRACE_FILE_ENABLED + /* Make note of the new configuration. Don't look up the trace file + * pointer, as that may change before we use it. + */ + if ( config_ptr != NULL ) { + + trace_config = *config_ptr; + + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + if ( ( cache_ptr == NULL ) #ifdef H5_HAVE_PARALLEL || @@ -2271,10 +2808,63 @@ H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, if ( ( config_ptr->rpt_fcn_enabled != TRUE ) && ( config_ptr->rpt_fcn_enabled != FALSE ) ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ "config_ptr->rpt_fcn_enabled must be either TRUE or FALSE.") } + if ( ( config_ptr->open_trace_file != TRUE ) && + ( config_ptr->open_trace_file != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->open_trace_file must be either TRUE or FALSE.") + } + + if ( ( config_ptr->close_trace_file != TRUE ) && + ( config_ptr->close_trace_file != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->close_trace_file must be either TRUE or FALSE.") + } + + /* don't bother to test trace_file_name unless open_trace_file is TRUE */ + if ( config_ptr->open_trace_file ) { + + /* Can't really test the trace_file_name field without trying to + * open the file, so we will content ourselves with a couple of + * sanity checks on the length of the file name. + */ + name_len = HDstrlen(config_ptr->trace_file_name); + + if ( name_len <= 0 ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->trace_file_name is empty.") + + } else if ( name_len > H5AC__MAX_TRACE_FILE_NAME_LEN ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->trace_file_name too long.") + } + } + + if ( config_ptr->open_trace_file ) { + + FILE * file_ptr = NULL; + + if ( H5C_get_trace_file_ptr(cache_ptr, &file_ptr) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_get_trace_file_ptr() failed.") + } + + if ( ( ! ( config_ptr->close_trace_file ) ) && + ( file_ptr != NULL ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "Trace file already open.") + } + } + if ( ( config_ptr->dirty_bytes_threshold @@ -2293,6 +2883,25 @@ H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, "config_ptr->dirty_bytes_threshold out of range.") } + if ( config_ptr->close_trace_file ) { + + if ( H5AC_close_trace_file(cache_ptr) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5AC_close_trace_file() failed.") + } + } + + if ( config_ptr->open_trace_file ) { + + if ( H5AC_open_trace_file(cache_ptr, config_ptr->trace_file_name) < 0 ) + { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "H5AC_open_trace_file() failed.") + } + } + if ( H5AC_ext_config_2_int_config(config_ptr, &internal_config) != SUCCEED ) { @@ -2318,6 +2927,47 @@ H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, done: +#if H5AC__TRACE_FILE_ENABLED + /* For the set cache auto resize config call, only the contents + * of the config is necessary in the trace file. Write the return + * value to catch occult errors. + */ + if ( ( cache_ptr != NULL ) && + ( H5C_get_trace_file_ptr(cache_ptr, &trace_file_ptr) >= 0 ) && + ( trace_file_ptr != NULL ) ) { + + HDfprintf(trace_file_ptr, + "%s %d %d %d %d \"%s\" %d %d %f %d %d %ld %d %f %f %d %d %d %f %f %d %d %d %d %f %d %d\n", + "H5AC_set_cache_auto_resize_config", + trace_config.version, + (int)(trace_config.rpt_fcn_enabled), + (int)(trace_config.open_trace_file), + (int)(trace_config.close_trace_file), + trace_config.trace_file_name, + (int)(trace_config.set_initial_size), + (int)(trace_config.initial_size), + trace_config.min_clean_fraction, + (int)(trace_config.max_size), + (int)(trace_config.min_size), + trace_config.epoch_length, + (int)(trace_config.incr_mode), + trace_config.lower_hr_threshold, + trace_config.increment, + (int)(trace_config.apply_max_increment), + (int)(trace_config.max_increment), + (int)(trace_config.decr_mode), + trace_config.upper_hr_threshold, + trace_config.decrement, + (int)(trace_config.apply_max_decrement), + (int)(trace_config.max_decrement), + trace_config.epochs_before_eviction, + (int)(trace_config.apply_empty_reserve), + trace_config.empty_reserve, + trace_config.dirty_bytes_threshold, + (int)ret_value); + } +#endif /* H5AC__TRACE_FILE_ENABLED */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set_cache_auto_resize_config() */ @@ -2345,7 +2995,11 @@ done: * * Modifications: * - * None. + * - Added code testing the trace file configuration fields. + * These tests are not comprehensive, as many errors cannot + * be caught until the directives contained in these fields + * are applied. + * JRM - 5/15/06 * *------------------------------------------------------------------------- */ @@ -2354,8 +3008,9 @@ herr_t H5AC_validate_config(H5AC_cache_config_t * config_ptr) { - herr_t result; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t result; + herr_t ret_value = SUCCEED; /* Return value */ + int name_len; H5C_auto_size_ctl_t internal_config; FUNC_ENTER_NOAPI(H5AC_validate_config, FAIL) @@ -2377,6 +3032,41 @@ H5AC_validate_config(H5AC_cache_config_t * config_ptr) "config_ptr->rpt_fcn_enabled must be either TRUE or FALSE.") } + if ( ( config_ptr->open_trace_file != TRUE ) && + ( config_ptr->open_trace_file != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->open_trace_file must be either TRUE or FALSE.") + } + + if ( ( config_ptr->close_trace_file != TRUE ) && + ( config_ptr->close_trace_file != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->close_trace_file must be either TRUE or FALSE.") + } + + /* don't bother to test trace_file_name unless open_trace_file is TRUE */ + if ( config_ptr->open_trace_file ) { + + /* Can't really test the trace_file_name field without trying to + * open the file, so we will content ourselves with a couple of + * sanity checks on the length of the file name. + */ + name_len = HDstrlen(config_ptr->trace_file_name); + + if ( name_len <= 0 ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->trace_file_name is empty.") + + } else if ( name_len > H5AC__MAX_TRACE_FILE_NAME_LEN ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->trace_file_name too long.") + } + } + if ( config_ptr->dirty_bytes_threshold < H5AC__MIN_DIRTY_BYTES_THRESHOLD ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, @@ -2410,6 +3100,185 @@ done: } /* H5AC_validate_config() */ +/*------------------------------------------------------------------------- + * Function: H5AC_close_trace_file() + * + * Purpose: If a trace file is open, stop logging calls to the cache, + * and close the file. + * + * Note that the function does nothing if there is no trace + * file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 6/2/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +herr_t +H5AC_close_trace_file(H5AC_t * cache_ptr) + +{ + herr_t ret_value = SUCCEED; /* Return value */ + FILE * trace_file_ptr = NULL; + + FUNC_ENTER_NOAPI(H5AC_close_trace_file, FAIL) + + if ( cache_ptr == NULL ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL cache_ptr on entry.") + } + + if ( H5C_get_trace_file_ptr(cache_ptr, &trace_file_ptr) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_get_trace_file_ptr() failed.") + } + + if ( trace_file_ptr != NULL ) { + + if ( H5C_set_trace_file_ptr(cache_ptr, NULL) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_set_trace_file_ptr() failed.") + } + + if ( HDfclose(trace_file_ptr) != 0 ) { + + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, \ + "can't close metadata cache trace file") + } + } + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5AC_close_trace_file() */ + + +/*------------------------------------------------------------------------- + * Function: H5AC_open_trace_file() + * + * Purpose: Open a trace file, and start logging calls to the cache. + * + * This logging is done at the H5C level, and will only take + * place if H5C_TRACE_FILE_ENABLED (defined in H5Cprivate.h) + * is TRUE. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 6/1/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +herr_t +H5AC_open_trace_file(H5AC_t * cache_ptr, + const char * trace_file_name) +{ + herr_t ret_value = SUCCEED; /* Return value */ + char file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 2]; + FILE * file_ptr = NULL; +#ifdef H5_HAVE_PARALLEL + H5AC_aux_t * aux_ptr = NULL; +#endif /* H5_HAVE_PARALLEL */ + + FUNC_ENTER_NOAPI(H5AC_open_trace_file, FAIL) + + HDassert(cache_ptr); + + if ( cache_ptr == NULL ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr NULL on entry.") + } + + if ( trace_file_name == NULL ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "NULL trace_file_name on entry.") + } + + if ( HDstrlen(trace_file_name) > H5AC__MAX_TRACE_FILE_NAME_LEN ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "trace file name too long.") + } + + if ( H5C_get_trace_file_ptr(cache_ptr, &file_ptr) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_get_trace_file_ptr() failed.") + } + + if ( file_ptr != NULL ) { + + HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "trace file already open.") + } + +#ifdef H5_HAVE_PARALLEL + + aux_ptr = (H5AC_aux_t *)(cache_ptr->aux_ptr); + + if ( cache_ptr->aux_ptr == NULL ) { + + sprintf(file_name, "%s", trace_file_name); + + } else { + + if ( aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr->magic.") + } + + sprintf(file_name, "%s.%d", trace_file_name, aux_ptr->mpi_rank); + + } + + if ( HDstrlen(file_name) > + H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 1 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "cooked trace file name too long.") + } + +#else /* H5_HAVE_PARALLEL */ + + sprintf(file_name, "%s", trace_file_name); + +#endif /* H5_HAVE_PARALLEL */ + + if ( (file_ptr = HDfopen(file_name, "w")) == NULL ) { + + /* trace file open failed */ + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "trace file open failed.") + } + + HDfprintf(file_ptr, "### HDF5 metadata cache trace file version 1 ###\n"); + + if ( H5C_set_trace_file_ptr(cache_ptr, file_ptr) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_set_trace_file_ptr() failed.") + } + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5AC_open_trace_file() */ + + /*************************************************************************/ /**************************** Private Functions: *************************/ /*************************************************************************/ @@ -3063,7 +3932,7 @@ H5AC_log_flushed_entry(H5C_t * cache_ptr, haddr_t addr, hbool_t was_dirty, unsigned flags, - UNUSED int type_id) + int UNUSED type_id) { herr_t ret_value = SUCCEED; /* Return value */ hbool_t cleared; diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index c3433be..2cbda20 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -38,6 +38,11 @@ #include "H5Fprivate.h" /* File access */ #include "H5Cprivate.h" /* cache */ +#ifdef H5_METADATA_TRACE_FILE +#define H5AC__TRACE_FILE_ENABLED 1 +#else /* H5_METADATA_TRACE_FILE */ +#define H5AC__TRACE_FILE_ENABLED 0 +#endif /* H5_METADATA_TRACE_FILE */ /* Types of metadata objects cached */ typedef enum { @@ -185,6 +190,9 @@ extern hid_t H5AC_ind_dxpl_id; { \ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, \ /* hbool_t rpt_fcn_enabled = */ FALSE, \ + /* hbool_t open_trace_file = */ FALSE, \ + /* hbool_t close_trace_file = */ FALSE, \ + /* char trace_file_name[] = */ "", \ /* hbool_t set_initial_size = */ TRUE, \ /* size_t initial_size = */ ( 1 * 1024 * 1024), \ /* double min_clean_fraction = */ 0.5, \ @@ -251,6 +259,9 @@ H5_DLL herr_t H5AC_pin_protected_entry(H5F_t * f, void * thing); H5_DLL void * H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, const void *udata1, void *udata2, H5AC_protect_t rw); +H5_DLL herr_t H5AC_resize_pinned_entry(H5F_t * f, + void * thing, + size_t new_size); H5_DLL herr_t H5AC_unpin_entry(H5F_t * f, void * thing); H5_DLL herr_t H5AC_unprotect(H5F_t *f, hid_t dxpl_id, @@ -267,6 +278,10 @@ H5_DLL herr_t H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr); H5_DLL herr_t H5AC_dest(H5F_t *f, hid_t dxpl_id); + +H5_DLL herr_t H5AC_expunge_entry(H5F_t *f, hid_t dxpl_id, + const H5AC_class_t *type, haddr_t addr); + H5_DLL herr_t H5AC_set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)); H5_DLL herr_t H5AC_stats(const H5F_t *f); @@ -290,5 +305,10 @@ H5_DLL herr_t H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, H5_DLL herr_t H5AC_validate_config(H5AC_cache_config_t * config_ptr); +H5_DLL herr_t H5AC_close_trace_file( H5AC_t * cache_ptr); + +H5_DLL herr_t H5AC_open_trace_file(H5AC_t * cache_ptr, + const char * trace_file_name); + #endif /* !_H5ACprivate_H */ diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index 81d3319..a050a03 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -35,6 +35,8 @@ extern "C" { #endif +#define H5AC__MAX_TRACE_FILE_NAME_LEN 1024 + /**************************************************************************** * * structure H5AC_cache_config_t @@ -53,6 +55,11 @@ extern "C" { * considerable interaction between this value and the other fields in this * structure. * + * Similarly, the open_trace_file, close_trace_file, and trace_file_name + * fields do not appear in H5C_auto_size_ctl_t, as most trace file + * issues are handled at the H5AC level. The one exception is storage of + * the pointer to the trace file, which is handled by H5C. + * * The structure is in H5ACpublic.h as we may wish to allow different * configuration options for metadata and raw data caches. * @@ -69,6 +76,36 @@ extern "C" { * * This is a debugging function, and should normally be turned off. * + * open_trace_file: Boolean field indicating whether the trace_file_name + * field should be used to open a trace file for the cache. + * + * The trace file is a debuging feature that allow the capture of + * top level metadata cache requests for purposes of debugging and/or + * optimization. This field should normally be set to FALSE, as + * trace file collection imposes considerable overhead. + * + * This field should only be set to TRUE when the trace_file_name + * contains the full path of the desired trace file, and either + * there is no open trace file on the cache, or the close_trace_file + * field is also TRUE. + * + * close_trace_file: Boolean field indicating whether the current trace + * file (if any) should be closed. + * + * See the above comments on the open_trace_file field. This field + * should be set to FALSE unless there is an open trace file on the + * cache that you wish to close. + * + * trace_file_name: Full path of the trace file to be opened if the + * open_trace_file field is TRUE. + * + * In the parallel case, an ascii representation of the mpi rank of + * the process will be appended to the file name to yield a unique + * trace file name for each process. + * + * The length of the path must not exceed H5AC__MAX_TRACE_FILE_NAME_LEN + * characters. + * * set_initial_size: Boolean flag indicating whether the size of the * initial size of the cache is to be set to the value given in * the initial_size field. If set_initial_size is FALSE, the @@ -265,55 +302,59 @@ extern "C" { * ****************************************************************************/ -#define H5AC__CURR_CACHE_CONFIG_VERSION 1 +#define H5AC__CURR_CACHE_CONFIG_VERSION 1 typedef struct H5AC_cache_config_t { /* general configuration fields: */ - int version; + int version; + + hbool_t rpt_fcn_enabled; - hbool_t rpt_fcn_enabled; + hbool_t open_trace_file; + hbool_t close_trace_file; + char trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + 1]; - hbool_t set_initial_size; - size_t initial_size; + hbool_t set_initial_size; + size_t initial_size; - double min_clean_fraction; + double min_clean_fraction; - size_t max_size; - size_t min_size; + size_t max_size; + size_t min_size; - long int epoch_length; + long int epoch_length; /* size increase control fields: */ - enum H5C_cache_incr_mode incr_mode; + enum H5C_cache_incr_mode incr_mode; - double lower_hr_threshold; + double lower_hr_threshold; - double increment; + double increment; - hbool_t apply_max_increment; - size_t max_increment; + hbool_t apply_max_increment; + size_t max_increment; /* size decrease control fields: */ - enum H5C_cache_decr_mode decr_mode; + enum H5C_cache_decr_mode decr_mode; - double upper_hr_threshold; + double upper_hr_threshold; - double decrement; + double decrement; - hbool_t apply_max_decrement; - size_t max_decrement; + hbool_t apply_max_decrement; + size_t max_decrement; - int epochs_before_eviction; + int epochs_before_eviction; - hbool_t apply_empty_reserve; - double empty_reserve; + hbool_t apply_empty_reserve; + double empty_reserve; /* parallel configuration fields: */ - int dirty_bytes_threshold; + int dirty_bytes_threshold; } H5AC_cache_config_t; diff --git a/src/H5C.c b/src/H5C.c index dd0d56d..8283d77 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -1043,10 +1043,13 @@ if ( ( (cache_ptr) == NULL ) || \ * QAK -- 11/27/04 * Switched over to using skip list routines. * + * JRM -- 6/27/06 + * Added fail_val parameter. + * *------------------------------------------------------------------------- */ -#define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) \ +#define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ @@ -1057,7 +1060,7 @@ if ( ( (cache_ptr) == NULL ) || \ \ if ( H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &(entry_ptr)->addr) \ < 0 ) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), \ "Can't insert entry in skip list") \ \ (entry_ptr)->in_slist = TRUE; \ @@ -2459,6 +2462,9 @@ done: * JRM -- 3/16/06 * Added initialization for the pinned entry related fields. * + * JRM -- 5/31/06 + * Added initialization for the trace_file_ptr field. + * *------------------------------------------------------------------------- */ @@ -2513,6 +2519,8 @@ H5C_create(size_t max_cache_size, cache_ptr->magic = H5C__H5C_T_MAGIC; + cache_ptr->trace_file_ptr = NULL; + cache_ptr->aux_ptr = aux_ptr; cache_ptr->max_type_id = max_type_id; @@ -2690,7 +2698,11 @@ done: */ void H5C_def_auto_resize_rpt_fcn(H5C_t * cache_ptr, +#ifndef NDEBUG int32_t version, +#else /* NDEBUG */ + UNUSED int32_t version, +#endif /* NDEBUG */ double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, @@ -2951,6 +2963,116 @@ done: /*------------------------------------------------------------------------- + * + * Function: H5C_expunge_entry + * + * Purpose: Use this function to tell the cache to expunge an entry + * from the cache without writing it to disk even if it is + * dirty. The entry may not be either pinned or protected. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 6/29/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +herr_t +H5C_expunge_entry(H5F_t * f, + hid_t primary_dxpl_id, + hid_t secondary_dxpl_id, + H5C_t * cache_ptr, + const H5C_class_t * type, + haddr_t addr) +{ + herr_t result; + herr_t ret_value = SUCCEED; /* Return value */ + hbool_t first_flush = TRUE; + H5C_cache_entry_t * entry_ptr = NULL; + + FUNC_ENTER_NOAPI(H5C_expunge_entry, FAIL) + + HDassert( H5F_addr_defined(addr) ); + HDassert( cache_ptr ); + HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert( type ); + HDassert( type->clear ); + HDassert( type->dest ); + +#if H5C_DO_EXTREME_SANITY_CHECKS + if ( H5C_validate_lru_list(cache_ptr) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "LRU sanity check failed.\n"); + } +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + + if ( ( entry_ptr == NULL ) || ( entry_ptr->type != type ) ) { + + /* the target doesn't exist in the cache, so we are done. */ + HGOTO_DONE(SUCCEED) + } + + HDassert( entry_ptr->addr == addr ); + HDassert( entry_ptr->type == type ); + + if ( entry_ptr->is_protected ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ + "Target entry is protected.") + } + + if ( entry_ptr->is_pinned ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ + "Target entry is pinned.") + } + + /* If we get this far, call H5C_flush_single_entry() with the + * H5C__FLUSH_INVALIDATE_FLAG and the H5C__FLUSH_CLEAR_ONLY_FLAG. + * This will clear the entry, and then delete it from the cache. + */ + + 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, + &first_flush, + TRUE); + + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ + "H5C_flush_single_entry() failed.") + } + +done: + +#if H5C_DO_EXTREME_SANITY_CHECKS + if ( H5C_validate_lru_list(cache_ptr) < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "LRU sanity check failed.\n"); + } +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_expunge_entry() */ + + +/*------------------------------------------------------------------------- * Function: H5C_flush_cache * * Purpose: Flush (and possibly destroy) the entries contained in the @@ -3180,6 +3302,7 @@ H5C_flush_cache(H5F_t * f, done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5C_flush_cache() */ @@ -3678,6 +3801,54 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_get_trace_file_ptr + * + * Purpose: Get the trace_file_ptr field from the cache. + * + * This field will either be NULL (which indicates that trace + * file logging is turned off), or contain a pointer to the + * open file to which trace file data is to be written. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 1/20/06 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5C_get_trace_file_ptr(H5C_t * cache_ptr, + FILE ** trace_file_ptr_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5C_get_trace_file_ptr, FAIL) + + /* This would normally be an assert, but we need to use an HGOTO_ERROR + * call to shut up the compiler. + */ + if ( ( ! cache_ptr ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") + } + + if ( trace_file_ptr_ptr == NULL ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL trace_file_ptr_ptr") + } + + *trace_file_ptr_ptr = cache_ptr->trace_file_ptr; + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_get_trace_file_ptr() */ + + +/*------------------------------------------------------------------------- * Function: H5C_insert_entry * * Purpose: Adds the specified thing to the cache. The thing need not @@ -3932,7 +4103,7 @@ H5C_insert_entry(H5F_t * f, if ( entry_ptr->is_dirty ) { entry_ptr->flush_marker = set_flush_marker; - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) } else { @@ -4359,7 +4530,7 @@ H5C_mark_pinned_entry_dirty(H5C_t * cache_ptr, if ( ! (entry_ptr->in_slist) ) { - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) } H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) @@ -4426,7 +4597,7 @@ H5C_mark_pinned_or_protected_entry_dirty(H5C_t * cache_ptr, if ( ! (entry_ptr->in_slist) ) { - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) } H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) @@ -4565,7 +4736,7 @@ H5C_rename_entry(H5C_t * cache_ptr, H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) H5C__UPDATE_RP_FOR_RENAME(cache_ptr, entry_ptr, was_dirty, FAIL) @@ -4587,6 +4758,107 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_resize_pinned_entry + * + * Purpose: Resize a pinned entry. The target entry MUST be + * be pinned, and MUST not be unprotected. + * + * Resizing an entry dirties it, so if the entry is not + * already dirty, the function places the entry on the + * skip list. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 7/5/06 + * + * Modifications: + * + * None + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_resize_pinned_entry(H5C_t * cache_ptr, + void * thing, + size_t new_size) +{ + herr_t ret_value = SUCCEED; /* Return value */ + H5C_cache_entry_t * entry_ptr; + + FUNC_ENTER_NOAPI(H5C_resize_pinned_entry, FAIL) + + HDassert( cache_ptr ); + HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); + HDassert( thing ); + + entry_ptr = (H5C_cache_entry_t *)thing; + + if ( new_size <= 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, \ + "New size is non-positive.") + } + + if ( ! ( entry_ptr->is_pinned ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, \ + "Entry isn't pinned??") + } + + if ( entry_ptr->is_protected ) { + + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, \ + "Entry is protected??") + } + + /* resizing dirties entries -- mark the entry as dirty if it + * isn't already + */ + entry_ptr->is_dirty = TRUE; + + /* update for change in entry size if necessary */ + if ( entry_ptr->size != new_size ) { + + /* update the protected entry list */ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pel_len), \ + (cache_ptr->pel_size), \ + (entry_ptr->size), (new_size)); + + /* update the hash table */ + H5C__UPDATE_INDEX_FOR_SIZE_CHANGE((cache_ptr), (entry_ptr->size),\ + (new_size)); + + /* if the entry is in the skip list, update that too */ + if ( entry_ptr->in_slist ) { + + H5C__UPDATE_SLIST_FOR_SIZE_CHANGE((cache_ptr), (entry_ptr->size),\ + (new_size)); + } + + /* update statistics just before changing the entry size */ + H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE((cache_ptr), (entry_ptr), \ + (new_size)); + + /* finally, update the entry size proper */ + entry_ptr->size = new_size; + } + + if ( ! (entry_ptr->in_slist) ) { + + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) + } + + H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_resize_pinned_entry() */ + + +/*------------------------------------------------------------------------- * Function: H5C_pin_protected_entry() * * Purpose: Pin a protected cache entry. The entry must be protected @@ -4706,6 +4978,11 @@ done: * Added code to set the new dirtied field in * H5C_cache_entry_t to FALSE prior to return. * + * JRM -- 6/23/06 + * Modified code to allow dirty entries to be loaded from + * disk. This is necessary as a bug fix in the object + * header code requires us to modify a header as it is read. + * *------------------------------------------------------------------------- */ @@ -4852,9 +5129,17 @@ H5C_protect(H5F_t * f, /* Insert the entry in the hash table. It can't be dirty yet, so * we don't even check to see if it should go in the skip list. + * + * This is no longer true -- due to a bug fix, we may modify + * data on load to repair a file. */ H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, NULL) + if ( ( entry_ptr->is_dirty ) && ( ! (entry_ptr->in_slist) ) ) { + + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, NULL) + } + /* insert the entry in the data structures used by the replacement * policy. We are just going to take it out again when we update * the replacement policy for a protect, but this simplifies the @@ -5359,6 +5644,49 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_set_trace_file_ptr + * + * Purpose: Set the trace_file_ptr field for the cache. + * + * This field must either be NULL (which turns of trace + * file logging), or be a pointer to an open file to which + * trace file data is to be written. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 1/20/06 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t +H5C_set_trace_file_ptr(H5C_t * cache_ptr, + FILE * trace_file_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5C_set_trace_file_ptr, FAIL) + + /* This would normally be an assert, but we need to use an HGOTO_ERROR + * call to shut up the compiler. + */ + if ( ( ! cache_ptr ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") + } + + cache_ptr->trace_file_ptr = trace_file_ptr; + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_set_trace_file_ptr() */ + + +/*------------------------------------------------------------------------- * Function: H5C_stats * * Purpose: Prints statistics about the cache. @@ -5984,6 +6312,12 @@ H5C_unprotect(H5F_t * f, pin_entry = ( (flags & H5C__PIN_ENTRY_FLAG) != 0 ); unpin_entry = ( (flags & H5C__UNPIN_ENTRY_FLAG) != 0 ); + /* Changing the size of an entry dirties it. Thus, set the + * dirtied flag if the size_changed flag is set. + */ + + dirtied |= size_changed; + HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); HDassert( cache_ptr->skip_file_checks || f ); @@ -6120,7 +6454,7 @@ H5C_unprotect(H5F_t * f, if ( ! (entry_ptr->in_slist) ) { - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) } } @@ -8272,6 +8606,12 @@ done: * JRM - 7/21/04 * Updated function for the addition of the hash table. * + * JRM - 6/23/06 + * Deleted assertion that verified that a newly loaded + * entry is clean. Due to a bug fix, this need not be + * the case, as our code will attempt to repair errors + * on load. + * *------------------------------------------------------------------------- */ @@ -8282,7 +8622,11 @@ H5C_load_entry(H5F_t * f, haddr_t addr, const void * udata1, void * udata2, +#ifndef NDEBUG hbool_t skip_file_checks) +#else /* NDEBUG */ + UNUSED hbool_t skip_file_checks) +#endif /* NDEBUG */ { void * thing = NULL; void * ret_value = NULL; @@ -8304,7 +8648,30 @@ H5C_load_entry(H5F_t * f, entry_ptr = (H5C_cache_entry_t *)thing; - HDassert( entry_ptr->is_dirty == FALSE ); + /* In general, an entry should be clean just after it is loaded. + * + * However, when this code is used in the metadata cache, it is + * possible that object headers will be dirty at this point, as + * the load function will alter object headers if necessary to + * fix an old bug. + * + * To support this bug fix, I have replace the old assert: + * + * HDassert( entry_ptr->is_dirty == FALSE ); + * + * with: + * + * HDassert( ( entry_ptr->is_dirty == FALSE ) || ( type->id == 4 ) ); + * + * Note that type id 4 is associated with object headers in the metadata + * cache. + * + * When we get to using H5C for other purposes, we may wish to + * tighten up the assert so that the loophole only applies to the + * metadata cache. + */ + + HDassert( ( entry_ptr->is_dirty == FALSE ) || ( type->id == 4 ) ); entry_ptr->addr = addr; entry_ptr->type = type; diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 16c27de..1a32f0a 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -87,6 +87,18 @@ * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. This * field is used to validate pointers to instances of H5C_t. * + * trace_file_ptr: File pointer pointing to the trace file, which is used + * to record cache operations for use in simulations and design + * studies. This field will usually be NULL, indicating that + * 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 + * H5C. Instead, H5AC reads the trace_file_ptr as needed. + * + * When we get to using H5C in other places, we may add + * code to write trace file data at the H5C level as well. + * * aux_ptr: Pointer to void used to allow wrapper code to associate * its data with an instance of H5C_t. The H5C cache code * sets this field to NULL, and otherwise leaves it alone. @@ -702,6 +714,8 @@ struct H5C_t { uint32_t magic; + FILE * trace_file_ptr; + void * aux_ptr; int32_t max_type_id; diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index fd54d69..ac8851a 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -35,6 +35,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ + #define H5C_DO_SANITY_CHECKS 0 #define H5C_DO_EXTREME_SANITY_CHECKS 0 @@ -799,6 +800,13 @@ H5_DLL herr_t H5C_dest(H5F_t * f, H5_DLL herr_t H5C_dest_empty(H5C_t * cache_ptr); +H5_DLL herr_t H5C_expunge_entry(H5F_t * f, + hid_t primary_dxpl_id, + hid_t secondary_dxpl_id, + H5C_t * cache_ptr, + const H5C_class_t * type, + haddr_t addr); + H5_DLL herr_t H5C_flush_cache(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, @@ -830,6 +838,9 @@ H5_DLL herr_t H5C_get_entry_status(H5C_t * cache_ptr, hbool_t * is_protected_ptr, hbool_t * is_pinned_ptr); +H5_DLL herr_t H5C_get_trace_file_ptr(H5C_t * cache_ptr, + FILE ** trace_file_ptr_ptr); + H5_DLL herr_t H5C_insert_entry(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, @@ -873,6 +884,10 @@ H5_DLL void * H5C_protect(H5F_t * f, H5_DLL herr_t H5C_reset_cache_hit_rate_stats(H5C_t * cache_ptr); +H5_DLL herr_t H5C_resize_pinned_entry(H5C_t * cache_ptr, + void * thing, + size_t new_size); + H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t * cache_ptr, H5C_auto_size_ctl_t *config_ptr); @@ -882,6 +897,9 @@ H5_DLL herr_t H5C_set_skip_flags(H5C_t * cache_ptr, hbool_t skip_file_checks, hbool_t skip_dxpl_id_checks); +H5_DLL herr_t H5C_set_trace_file_ptr(H5C_t * cache_ptr, + FILE * trace_file_ptr); + H5_DLL herr_t H5C_stats(H5C_t * cache_ptr, const char * cache_name, hbool_t display_detailed_stats); diff --git a/src/H5Edefin.h b/src/H5Edefin.h index 8602aca..229a67f 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -115,7 +115,7 @@ hid_t H5E_NOENCODER_g = FAIL; /* Filter present but encoding disabled hid_t H5E_CANTOPENOBJ_g = FAIL; /* Can't open object */ hid_t H5E_CANTCLOSEOBJ_g = FAIL; /* Can't close object */ hid_t H5E_COMPLEN_g = FAIL; /* Name component is too long */ -hid_t H5E_LINK_g = FAIL; /* Link-related failure */ +hid_t H5E_LINK_g = FAIL; /* Link failure */ hid_t H5E_SLINK_g = FAIL; /* Symbolic link error */ hid_t H5E_PATH_g = FAIL; /* Problem with path to object */ @@ -156,6 +156,8 @@ hid_t H5E_CANTPIN_g = FAIL; /* Unable to pin cache entry */ hid_t H5E_CANTUNPIN_g = FAIL; /* Unable to un-pin cache entry */ hid_t H5E_CANTMARKDIRTY_g = FAIL; /* Unable to mark a pinned entry as dirty */ hid_t H5E_CANTDIRTY_g = FAIL; /* Unable to mark metadata as dirty */ +hid_t H5E_CANTEXPUNGE_g = FAIL; /* Unable to expunge a metadata cache entry */ +hid_t H5E_CANTRESIZE_g = FAIL; /* Unable to resize a metadata cache entry */ /* Parallel MPI errors */ hid_t H5E_MPI_g = FAIL; /* Some MPI function failed */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 5f95ca8..a5a3f18 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -586,6 +586,16 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to mark metadata as dirty"))==N HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_CANTDIRTY_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTEXPUNGE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to expunge a metadata cache entry"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTEXPUNGE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_CANTRESIZE_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to resize a metadata cache entry"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_CANTRESIZE_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") /* Parallel MPI errors */ assert(H5E_MPI_g==(-1)); diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index b989db7..70334fa 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -196,7 +196,7 @@ H5_DLLVAR hid_t H5E_NOENCODER_g; /* Filter present but encoding disabled */ H5_DLLVAR hid_t H5E_CANTOPENOBJ_g; /* Can't open object */ H5_DLLVAR hid_t H5E_CANTCLOSEOBJ_g; /* Can't close object */ H5_DLLVAR hid_t H5E_COMPLEN_g; /* Name component is too long */ -H5_DLLVAR hid_t H5E_LINK_g; /* Link count failure */ +H5_DLLVAR hid_t H5E_LINK_g; /* Link failure */ H5_DLLVAR hid_t H5E_SLINK_g; /* Symbolic link error */ H5_DLLVAR hid_t H5E_PATH_g; /* Problem with path to object */ @@ -253,6 +253,8 @@ H5_DLLVAR hid_t H5E_NOIDS_g; /* Out of IDs for group */ #define H5E_CANTUNPIN (H5OPEN H5E_CANTUNPIN_g) #define H5E_CANTMARKDIRTY (H5OPEN H5E_CANTMARKDIRTY_g) #define H5E_CANTDIRTY (H5OPEN H5E_CANTDIRTY_g) +#define H5E_CANTEXPUNGE (H5OPEN H5E_CANTEXPUNGE_g) +#define H5E_CANTRESIZE (H5OPEN H5E_CANTRESIZE_g) H5_DLLVAR hid_t H5E_CANTFLUSH_g; /* Unable to flush data from cache */ H5_DLLVAR hid_t H5E_CANTSERIALIZE_g; /* Unable to serialize data from cache */ H5_DLLVAR hid_t H5E_CANTLOAD_g; /* Unable to load metadata into cache */ @@ -267,6 +269,8 @@ H5_DLLVAR hid_t H5E_CANTPIN_g; /* Unable to pin cache entry */ H5_DLLVAR hid_t H5E_CANTUNPIN_g; /* Unable to un-pin cache entry */ H5_DLLVAR hid_t H5E_CANTMARKDIRTY_g; /* Unable to mark a pinned entry as dirty */ H5_DLLVAR hid_t H5E_CANTDIRTY_g; /* Unable to mark metadata as dirty */ +H5_DLLVAR hid_t H5E_CANTEXPUNGE_g; /* Unable to expunge a metadata cache entry */ +H5_DLLVAR hid_t H5E_CANTRESIZE_g; /* Unable to resize a metadata cache entry */ /* Parallel MPI errors */ #define H5E_MPI (H5OPEN H5E_MPI_g) diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 0b3a85e..c0d6f56 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -20,180 +20,182 @@ #define _H5Eterm_H /* Reset major error IDs */ - -H5E_DATASET_g= -H5E_FUNC_g= -H5E_STORAGE_g= -H5E_FILE_g= -H5E_SYM_g= -H5E_VFL_g= -H5E_INTERNAL_g= -H5E_BTREE_g= -H5E_REFERENCE_g= -H5E_DATASPACE_g= -H5E_RESOURCE_g= -H5E_PLIST_g= -H5E_DATATYPE_g= -H5E_RS_g= -H5E_HEAP_g= -H5E_OHDR_g= -H5E_ATOM_g= -H5E_ATTR_g= -H5E_NONE_MAJOR_g= -H5E_IO_g= -H5E_SLIST_g= -H5E_EFL_g= -H5E_TST_g= -H5E_ARGS_g= -H5E_ERROR_g= -H5E_PLINE_g= -H5E_FSPACE_g= + +H5E_DATASET_g= +H5E_FUNC_g= +H5E_STORAGE_g= +H5E_FILE_g= +H5E_SYM_g= +H5E_VFL_g= +H5E_INTERNAL_g= +H5E_BTREE_g= +H5E_REFERENCE_g= +H5E_DATASPACE_g= +H5E_RESOURCE_g= +H5E_PLIST_g= +H5E_DATATYPE_g= +H5E_RS_g= +H5E_HEAP_g= +H5E_OHDR_g= +H5E_ATOM_g= +H5E_ATTR_g= +H5E_NONE_MAJOR_g= +H5E_IO_g= +H5E_SLIST_g= +H5E_EFL_g= +H5E_TST_g= +H5E_ARGS_g= +H5E_ERROR_g= +H5E_PLINE_g= +H5E_FSPACE_g= H5E_CACHE_g= (-1); /* Reset minor error IDs */ -/* Generic low-level file I/O errors */ -H5E_SEEKERROR_g= -H5E_READERROR_g= -H5E_WRITEERROR_g= -H5E_CLOSEERROR_g= -H5E_OVERFLOW_g= +/* Generic low-level file I/O errors */ +H5E_SEEKERROR_g= +H5E_READERROR_g= +H5E_WRITEERROR_g= +H5E_CLOSEERROR_g= +H5E_OVERFLOW_g= H5E_FCNTL_g= -/* Resource errors */ -H5E_NOSPACE_g= -H5E_CANTALLOC_g= -H5E_CANTCOPY_g= -H5E_CANTFREE_g= -H5E_ALREADYEXISTS_g= -H5E_CANTLOCK_g= -H5E_CANTUNLOCK_g= -H5E_CANTGC_g= +/* Resource errors */ +H5E_NOSPACE_g= +H5E_CANTALLOC_g= +H5E_CANTCOPY_g= +H5E_CANTFREE_g= +H5E_ALREADYEXISTS_g= +H5E_CANTLOCK_g= +H5E_CANTUNLOCK_g= +H5E_CANTGC_g= H5E_CANTGETSIZE_g= -/* Heap errors */ -H5E_CANTRESTORE_g= -H5E_CANTCOMPUTE_g= -H5E_CANTEXTEND_g= -H5E_CANTATTACH_g= +/* Heap errors */ +H5E_CANTRESTORE_g= +H5E_CANTCOMPUTE_g= +H5E_CANTEXTEND_g= +H5E_CANTATTACH_g= H5E_CANTUPDATE_g= -/* Function entry/exit interface errors */ -H5E_CANTINIT_g= -H5E_ALREADYINIT_g= +/* Function entry/exit interface errors */ +H5E_CANTINIT_g= +H5E_ALREADYINIT_g= H5E_CANTRELEASE_g= -/* Property list errors */ -H5E_CANTGET_g= -H5E_CANTSET_g= +/* Property list errors */ +H5E_CANTGET_g= +H5E_CANTSET_g= H5E_DUPCLASS_g= -/* Free space errors */ -H5E_CANTMERGE_g= -H5E_CANTREVIVE_g= +/* Free space errors */ +H5E_CANTMERGE_g= +H5E_CANTREVIVE_g= H5E_CANTSHRINK_g= -/* Object header related errors */ -H5E_LINKCOUNT_g= -H5E_VERSION_g= -H5E_ALIGNMENT_g= -H5E_BADMESG_g= -H5E_CANTDELETE_g= -H5E_BADITER_g= +/* Object header related errors */ +H5E_LINKCOUNT_g= +H5E_VERSION_g= +H5E_ALIGNMENT_g= +H5E_BADMESG_g= +H5E_CANTDELETE_g= +H5E_BADITER_g= H5E_CANTPACK_g= -/* System level errors */ +/* System level errors */ H5E_SYSERRSTR_g= -/* I/O pipeline errors */ -H5E_NOFILTER_g= -H5E_CALLBACK_g= -H5E_CANAPPLY_g= -H5E_SETLOCAL_g= +/* I/O pipeline errors */ +H5E_NOFILTER_g= +H5E_CALLBACK_g= +H5E_CANAPPLY_g= +H5E_SETLOCAL_g= H5E_NOENCODER_g= -/* Group related errors */ -H5E_CANTOPENOBJ_g= -H5E_CANTCLOSEOBJ_g= -H5E_COMPLEN_g= -H5E_LINK_g= -H5E_SLINK_g= +/* Group related errors */ +H5E_CANTOPENOBJ_g= +H5E_CANTCLOSEOBJ_g= +H5E_COMPLEN_g= +H5E_LINK_g= +H5E_SLINK_g= H5E_PATH_g= -/* No error */ +/* No error */ H5E_NONE_MINOR_g= -/* File accessability errors */ -H5E_FILEEXISTS_g= -H5E_FILEOPEN_g= -H5E_CANTCREATE_g= -H5E_CANTOPENFILE_g= -H5E_CANTCLOSEFILE_g= -H5E_NOTHDF5_g= -H5E_BADFILE_g= -H5E_TRUNCATED_g= +/* File accessability errors */ +H5E_FILEEXISTS_g= +H5E_FILEOPEN_g= +H5E_CANTCREATE_g= +H5E_CANTOPENFILE_g= +H5E_CANTCLOSEFILE_g= +H5E_NOTHDF5_g= +H5E_BADFILE_g= +H5E_TRUNCATED_g= H5E_MOUNT_g= -/* Object atom related errors */ -H5E_BADATOM_g= -H5E_BADGROUP_g= -H5E_CANTREGISTER_g= -H5E_CANTINC_g= -H5E_CANTDEC_g= +/* Object atom related errors */ +H5E_BADATOM_g= +H5E_BADGROUP_g= +H5E_CANTREGISTER_g= +H5E_CANTINC_g= +H5E_CANTDEC_g= H5E_NOIDS_g= -/* Cache related errors */ -H5E_CANTFLUSH_g= -H5E_CANTSERIALIZE_g= -H5E_CANTLOAD_g= -H5E_PROTECT_g= -H5E_NOTCACHED_g= -H5E_SYSTEM_g= -H5E_CANTINS_g= -H5E_CANTRENAME_g= -H5E_CANTPROTECT_g= -H5E_CANTUNPROTECT_g= -H5E_CANTPIN_g= -H5E_CANTUNPIN_g= -H5E_CANTMARKDIRTY_g= -H5E_CANTDIRTY_g= - -/* Parallel MPI errors */ -H5E_MPI_g= -H5E_MPIERRSTR_g= +/* Cache related errors */ +H5E_CANTFLUSH_g= +H5E_CANTSERIALIZE_g= +H5E_CANTLOAD_g= +H5E_PROTECT_g= +H5E_NOTCACHED_g= +H5E_SYSTEM_g= +H5E_CANTINS_g= +H5E_CANTRENAME_g= +H5E_CANTPROTECT_g= +H5E_CANTUNPROTECT_g= +H5E_CANTPIN_g= +H5E_CANTUNPIN_g= +H5E_CANTMARKDIRTY_g= +H5E_CANTDIRTY_g= +H5E_CANTEXPUNGE_g= +H5E_CANTRESIZE_g= + +/* Parallel MPI errors */ +H5E_MPI_g= +H5E_MPIERRSTR_g= H5E_CANTRECV_g= -/* Dataspace errors */ -H5E_CANTCLIP_g= -H5E_CANTCOUNT_g= -H5E_CANTSELECT_g= -H5E_CANTNEXT_g= -H5E_BADSELECT_g= +/* Dataspace errors */ +H5E_CANTCLIP_g= +H5E_CANTCOUNT_g= +H5E_CANTSELECT_g= +H5E_CANTNEXT_g= +H5E_BADSELECT_g= H5E_CANTCOMPARE_g= -/* B-tree related errors */ -H5E_NOTFOUND_g= -H5E_EXISTS_g= -H5E_CANTENCODE_g= -H5E_CANTDECODE_g= -H5E_CANTSPLIT_g= -H5E_CANTREDISTRIBUTE_g= -H5E_CANTSWAP_g= -H5E_CANTINSERT_g= -H5E_CANTLIST_g= -H5E_CANTMODIFY_g= +/* B-tree related errors */ +H5E_NOTFOUND_g= +H5E_EXISTS_g= +H5E_CANTENCODE_g= +H5E_CANTDECODE_g= +H5E_CANTSPLIT_g= +H5E_CANTREDISTRIBUTE_g= +H5E_CANTSWAP_g= +H5E_CANTINSERT_g= +H5E_CANTLIST_g= +H5E_CANTMODIFY_g= H5E_CANTREMOVE_g= -/* Argument errors */ -H5E_UNINITIALIZED_g= -H5E_UNSUPPORTED_g= -H5E_BADTYPE_g= -H5E_BADRANGE_g= +/* Argument errors */ +H5E_UNINITIALIZED_g= +H5E_UNSUPPORTED_g= +H5E_BADTYPE_g= +H5E_BADRANGE_g= H5E_BADVALUE_g= -/* Datatype conversion errors */ -H5E_CANTCONVERT_g= +/* Datatype conversion errors */ +H5E_CANTCONVERT_g= H5E_BADSIZE_g= (-1); #endif /* H5Eterm_H */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 86e30f2..9022204 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -398,6 +398,9 @@ values correctly. */ #undef LLONG_TO_LDOUBLE_CORRECT +/* Define if the metadata trace file code is to be compiled in */ +#undef METADATA_TRACE_FILE + /* Define if your system can handle complicated MPI derived datatype correctly. */ #undef MPI_COMPLEX_DERIVED_DATATYPE_WORKS diff --git a/src/H5err.txt b/src/H5err.txt index 7cc1c15..25accb7 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -161,6 +161,8 @@ MINOR, CACHE, H5E_CANTPIN, Unable to pin cache entry MINOR, CACHE, H5E_CANTUNPIN, Unable to un-pin cache entry MINOR, CACHE, H5E_CANTMARKDIRTY, Unable to mark a pinned entry as dirty MINOR, CACHE, H5E_CANTDIRTY, Unable to mark metadata as dirty +MINOR, CACHE, H5E_CANTEXPUNGE, Unable to expunge a metadata cache entry +MINOR, CACHE, H5E_CANTRESIZE, Unable to resize a metadata cache entry # B-tree related errors MINOR, BTREE, H5E_NOTFOUND, Object not found diff --git a/test/cache.c b/test/cache.c index 01859f1..98f68d5 100644 --- a/test/cache.c +++ b/test/cache.c @@ -76,10 +76,12 @@ static void check_flush_cache__pinned_single_entry_test(H5C_t * cache_ptr, hbool_t expected_destroyed); static void check_flush_protected_err(void); static void check_get_entry_status(void); +static void check_expunge_entry(void); static void check_rename_entry(void); static void check_rename_entry__run_test(H5C_t * cache_ptr, int test_num, struct rename_entry_test_spec * spec_ptr); static void check_pin_protected_entry(void); +static void check_resize_entry(void); static void check_destroy_pinned_err(void); static void check_destroy_protected_err(void); static void check_duplicate_insert_err(void); @@ -90,6 +92,8 @@ static void check_pin_entry_errs(void); static void check_double_protect_err(void); static void check_double_unprotect_err(void); static void check_mark_entry_dirty_errs(void); +static void check_expunge_entry_errs(void); +static void check_resize_entry_errs(void); static void check_auto_cache_resize(void); static void check_auto_cache_resize_disable(void); static void check_auto_cache_resize_epoch_markers(void); @@ -6651,6 +6655,306 @@ check_get_entry_status(void) /*------------------------------------------------------------------------- + * Function: check_expunge_entry() + * + * Purpose: Verify that H5C_expunge_entry() behaves as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 7/5/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static void +check_expunge_entry(void) +{ + const char * fcn_name = "check_expunge_entry"; + static char msg[128]; + herr_t result; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + + TESTING("H5C_expunge_entry() functionality"); + + pass = TRUE; + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + + base_addr = entries[0]; + entry_ptr = &(base_addr[0]); + } + + if ( pass ) { + + /* entry not in cache -- only in_cache should be touched by + * the status call. Thus, only check that boolean. + */ + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 1."); + failure_mssg = msg; + + } else if ( in_cache ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 1."); + failure_mssg = msg; + + } else if ( ( entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); + failure_mssg = msg; + + } + } + + /* protect an entry to force the cache to load it, and then unprotect + * it without marking it dirty. + */ + + protect_entry(cache_ptr, 0, 0); + + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 2."); + failure_mssg = msg; + + } else if ( !in_cache || is_dirty || is_protected || is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 2."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); + failure_mssg = msg; + + } + } + + /* Expunge the entry and then verify that it is no longer in the cache. + * Also verify that the entry was loaded, cleared, and destroyed, but + * not flushed. + */ + expunge_entry(cache_ptr, 0, 0); + + if ( pass ) { + + /* entry shouldn't be in cache -- only in_cache should be touched + * by the status call. Thus, only check that boolean. + */ + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 3."); + failure_mssg = msg; + + } else if ( in_cache ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 3."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( ! entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); + failure_mssg = msg; + + } + } + + /* now repeat the process with a different entry. On unprotect + * mark the entry as dirty. Verify that it is not flushed. + */ + + base_addr = entries[0]; + entry_ptr = &(base_addr[1]); + + if ( pass ) { + + /* entry not in cache -- only in_cache should be touched by + * the status call. Thus, only check that boolean. + */ + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 4."); + failure_mssg = msg; + + } else if ( in_cache ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 4."); + failure_mssg = msg; + + } else if ( ( entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); + failure_mssg = msg; + + } + } + + /* protect the entry to force the cache to load it, and then unprotect + * it with the dirty flag set. + */ + + protect_entry(cache_ptr, 0, 1); + + unprotect_entry(cache_ptr, 0, 1, TRUE, H5C__NO_FLAGS_SET); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 5."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 5."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); + failure_mssg = msg; + + } + } + + /* Expunge the entry and then verify that it is no longer in the cache. + * Also verify that the entry was loaded, cleared and destroyed, but not + * flushed. + */ + expunge_entry(cache_ptr, 0, 1); + + if ( pass ) { + + /* entry shouldn't be in cache -- only in_cache should be touched + * by the status call. Thus, only check that boolean. + */ + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 6."); + failure_mssg = msg; + + } else if ( in_cache ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 6."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( ! entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_expunge_entry() */ + + +/*------------------------------------------------------------------------- * Function: check_rename_entry() * * Purpose: Verify that H5C_rename_entry behaves as expected. In @@ -6938,52 +7242,973 @@ check_pin_protected_entry(void) test_entry_t * base_addr; test_entry_t * entry_ptr; - TESTING("H5C_pin_protected_entry() functionality"); + TESTING("H5C_pin_protected_entry() functionality"); + + pass = TRUE; + + /* Create a cache, protect an entry, and then use H5C_pin_protected_entry() + * to pin it. Verify that the entry is in fact pined. Unprotect the entry + * to unpin it, and then destroy the cache. + */ + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + } + + protect_entry(cache_ptr, 0, 0); + + if ( pass ) { + + base_addr = entries[0]; + entry_ptr = &(base_addr[0]); + + result = H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5C_pin_protected_entry() reports failure."); + failure_mssg = msg; + + } else if ( ! ( entry_ptr->header.is_pinned ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "entry not pinned when it should be."); + failure_mssg = msg; + + } else { + + entry_ptr->is_pinned = TRUE; + } + } + + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__UNPIN_ENTRY_FLAG); + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_pin_protected_entry() */ + + +/*------------------------------------------------------------------------- + * Function: check_resize_entry() + * + * Purpose: Verify that H5C_resize_entry() and H5C_unprotect() resize + * entries as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 7/7/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static void +check_resize_entry(void) +{ + const char * fcn_name = "check_resize_entry"; + static char msg[128]; + herr_t result; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; + size_t reported_entry_size; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + + TESTING("entry resize functionality"); + + /* Setup a cache and verify that it is empty. + * + * Then force the load of an entry by protecting it, and verify that + * the entry and cache have the expected sizes. + * + * Then unprotect the entry with the size changed flag and a reduced + * size. Verify that the entry and cache have the expected expected + * sizes. + * + * Use a second protect/unprotect cycle to restore the entry to + * its original size. Verify that the entry and cache have the + * expected sizes. + * + * Protect and unprotect the entry again to pin it. Use + * H5C_resize_entry to reduce its size. Verify that the entry + * and cache have the expected sizes. + * + * Use H5C_resize_entry again to restore the entry to its original + * size. Verify that the entry and cache have the expected sizes. + * + * Use a protect / unprotect cycle to unpin and destroy the entry. + * Verify that the entry and cache have the expected sizes. + * + * + * Obesrve that all the above tests have been done with only one + * entry in the cache. Repeat the tests with several entries in + * the cache. + */ + + pass = TRUE; + + /* tests with only one entry in the cache: */ + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + + base_addr = entries[LARGE_ENTRY_TYPE]; + entry_ptr = &(base_addr[0]); + entry_size = LARGE_ENTRY_SIZE; + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 1."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + + if ( pass ) { + + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 2."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 1."); + failure_mssg = msg; + + } else if ( !in_cache || is_dirty || !is_protected || is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 1."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_unprotect(NULL, -1, -1, cache_ptr, + &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, + (void *)entry_ptr, + H5C__SIZE_CHANGED_FLAG | H5C__DIRTIED_FLAG, + (LARGE_ENTRY_SIZE / 2)); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 1."); + failure_mssg = msg; + + } else { + + /* tidy up so we play nice with the standard protect / unprotect + * calls. + */ + entry_ptr->is_protected = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE / 2; + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != (LARGE_ENTRY_SIZE / 2) ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 2) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 3."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 2."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || is_pinned || + ( reported_entry_size != (LARGE_ENTRY_SIZE / 2) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 2."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + + if ( pass ) { + + result = H5C_unprotect(NULL, -1, -1, cache_ptr, + &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, + (void *)entry_ptr, + (H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG), + LARGE_ENTRY_SIZE); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 2."); + failure_mssg = msg; + + } else { + + /* tidy up so we play nice with the standard protect / unprotect + * calls. + */ + entry_ptr->is_protected = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE; + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 4."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 3."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || is_pinned || + ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 3."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG); + + if ( pass ) { + + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, + (LARGE_ENTRY_SIZE / 4)); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5C_resize_pinned_entry() reports failure 1."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != (LARGE_ENTRY_SIZE / 4) ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 4) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 5."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 4."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || + ( reported_entry_size != (LARGE_ENTRY_SIZE / 4) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 4."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, + LARGE_ENTRY_SIZE); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5C_resize_pinned_entry() reports failure 2."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 6."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 5."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || + ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 5."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, + H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 6."); + failure_mssg = msg; + + } else if ( in_cache ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 6."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( ! entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 7."); + failure_mssg = msg; + + } + } + + + /* now repreat the above tests with several entries in the cache: */ + + if ( pass ) { + + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 8."); + failure_mssg = msg; + + } + base_addr = entries[LARGE_ENTRY_TYPE]; + entry_ptr = &(base_addr[3]); + entry_size = LARGE_ENTRY_SIZE; + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET); + + if ( pass ) { + + if ( ( cache_ptr->index_len != 3 ) || + ( cache_ptr->index_size != 3 * LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 9."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); + + if ( pass ) { + + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 10."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 7."); + failure_mssg = msg; + + } else if ( !in_cache || is_dirty || !is_protected || is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 7."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 7."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_unprotect(NULL, -1, -1, cache_ptr, + &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, + (void *)entry_ptr, + H5C__SIZE_CHANGED_FLAG | H5C__DIRTIED_FLAG, + (LARGE_ENTRY_SIZE / 2)); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 3."); + failure_mssg = msg; + + } else { + + /* tidy up so we play nice with the standard protect / unprotect + * calls. + */ + entry_ptr->is_protected = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE / 2; + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != + ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 2)) ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != + (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 2)) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 11."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 8."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || is_pinned || + ( reported_entry_size != (LARGE_ENTRY_SIZE / 2) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 8."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 8."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); + + if ( pass ) { + + result = H5C_unprotect(NULL, -1, -1, cache_ptr, + &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, + (void *)entry_ptr, + (H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG), + LARGE_ENTRY_SIZE); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 4."); + failure_mssg = msg; + + } else { + + /* tidy up so we play nice with the standard protect / unprotect + * calls. + */ + entry_ptr->is_protected = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE; + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != 2 * LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 12."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 9."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || is_pinned || + ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 9."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 9."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); + + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG); + + if ( pass ) { + + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, + (LARGE_ENTRY_SIZE / 4)); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5C_resize_pinned_entry() reports failure 3."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != + ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 4)) ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != + (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 4)) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 13."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 10."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || + ( reported_entry_size != (LARGE_ENTRY_SIZE / 4) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 10."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 10."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, + LARGE_ENTRY_SIZE); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5C_resize_pinned_entry() reports failure 4."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != (4 * LARGE_ENTRY_SIZE) ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != (2 * LARGE_ENTRY_SIZE) ) ) { - pass = TRUE; + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 14."); + failure_mssg = msg; - /* Create a cache, protect an entry, and then use H5C_pin_protected_entry() - * to pin it. Verify that the entry is in fact pined. Unprotect the entry - * to unpin it, and then destroy the cache. - */ + } + } if ( pass ) { - reset_entries(); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); - cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 11."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || + ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 11."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 11."); + failure_mssg = msg; + + } } - protect_entry(cache_ptr, 0, 0); + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); - if ( pass ) { + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE, + H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); - base_addr = entries[0]; - entry_ptr = &(base_addr[0]); + if ( pass ) { - result = H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); if ( result < 0 ) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5C_pin_protected_entry() reports failure."); + "H5AC_get_entry_status() reports failure 12."); failure_mssg = msg; - } else if ( ! ( entry_ptr->header.is_pinned ) ) { + } else if ( in_cache ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "entry not pinned when it should be."); + HDsnprintf(msg, (size_t)128, "Unexpected status 12."); failure_mssg = msg; - } else { + } else if ( ( ! entry_ptr->loaded ) || + ( ! entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 12."); + failure_mssg = msg; - entry_ptr->is_pinned = TRUE; } } - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__UNPIN_ENTRY_FLAG); + if ( pass ) { + + if ( ( cache_ptr->index_len != 3 ) || + ( cache_ptr->index_size != (3 * LARGE_ENTRY_SIZE) ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 15."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG); + + + if ( pass ) { + + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 16."); + failure_mssg = msg; + + } + } if ( pass ) { @@ -7000,7 +8225,7 @@ check_pin_protected_entry(void) return; -} /* check_pin_protected_entry() */ +} /* check_resize_entry() */ /*------------------------------------------------------------------------- @@ -7991,6 +9216,236 @@ check_mark_entry_dirty_errs(void) /*------------------------------------------------------------------------- + * Function: check_expunge_entry_errs() + * + * Purpose: Verify that invalid calls to H5C_expunge_entry() + * generate errors as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 7/6/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static void +check_expunge_entry_errs(void) +{ + const char * fcn_name = "check_expunge_entry_errs()"; + herr_t result; + H5C_t * cache_ptr = NULL; + test_entry_t * entry_ptr; + + TESTING("expunge entry related errors"); + + pass = TRUE; + + /* Allocate a cache, protect an entry, and then call H5C_expunge_entry() + * to expunge it -- this should fail + * + * Unprotect the the entry with the pinned flag, and then call + * H5C_expunge_entry() again. This should fail too. + * + * Finally, unpin the entry and call H5C_expunge_entry() yet again. + * This should succeed. + * + * Destroy the cache -- should succeed. + */ + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024), + (size_t)(1 * 1024)); + + entry_ptr = &((entries[0])[0]); + + protect_entry(cache_ptr, 0, 0); + + } + + if ( pass ) { + + result = H5C_expunge_entry(NULL, -1, -1, cache_ptr, + &(types[0]), entry_ptr->addr); + + if ( result > 0 ) { + + pass = FALSE; + failure_mssg = + "attempt to expunge a protected entry succeeded.\n"; + + } else { + + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG); + + } + } + + if ( pass ) { + + result = H5C_expunge_entry(NULL, -1, -1, cache_ptr, + &(types[0]), entry_ptr->addr); + + if ( result > 0 ) { + + pass = FALSE; + failure_mssg = + "attempt to expunge a pinned entry succeeded.\n"; + + } else { + + unpin_entry(cache_ptr, 0, 0); + + } + } + + if ( pass ) { + + result = H5C_expunge_entry(NULL, -1, -1, cache_ptr, + &(types[0]), entry_ptr->addr); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = + "attempt to expunge an unpinned and unprotected entry failed.\n"; + + } + } + + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_expunge_entry_errs() */ + + +/*------------------------------------------------------------------------- + * Function: check_resize_entry_errs() + * + * Purpose: Verify that invalid calls to H5C_resize_pinned_entry() + * generates errors as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 7/7/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static void +check_resize_entry_errs(void) +{ + const char * fcn_name = "check_resize_entry_errs()"; + herr_t result; + H5C_t * cache_ptr = NULL; + test_entry_t * entry_ptr; + + TESTING("resize entry related errors"); + + pass = TRUE; + + /* Allocate a cache, protect an entry, and then call + * H5C_resize_pinned_entry() to resize it -- this should fail. + * + * Unprotect the the entry with the pinned flag, and then call + * H5C_resize_pinned_entry() again with new size of zero. + * This should fail too. + * + * Finally, unpin the entry and destroy the cache. + * This should succeed. + */ + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024), + (size_t)(1 * 1024)); + + entry_ptr = &((entries[0])[0]); + + protect_entry(cache_ptr, 0, 0); + + } + + if ( pass ) { + + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, 1); + + if ( result > 0 ) { + + pass = FALSE; + failure_mssg = + "Call to H5C_resize_pinned_entry on a protected entry succeeded.\n"; + + } else { + + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG); + + } + } + + if ( pass ) { + + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, 0); + + if ( result > 0 ) { + + pass = FALSE; + failure_mssg = + "Call to H5C_resize_pinned_entry with 0 new size succeeded.\n"; + + } else { + + unpin_entry(cache_ptr, 0, 0); + + } + } + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_resize_entry_errs() */ + + +/*------------------------------------------------------------------------- * Function: check_auto_cache_resize() * * Purpose: Exercise the automatic cache resizing functionality. @@ -16995,8 +18450,10 @@ main(void) write_permitted_check(); check_flush_cache(); check_get_entry_status(); + check_expunge_entry(); check_rename_entry(); check_pin_protected_entry(); + check_resize_entry(); check_flush_protected_err(); check_destroy_pinned_err(); check_destroy_protected_err(); @@ -17008,6 +18465,8 @@ main(void) check_double_protect_err(); check_double_unprotect_err(); check_mark_entry_dirty_errs(); + check_expunge_entry_errs(); + check_resize_entry_errs(); check_auto_cache_resize(); check_auto_cache_resize_disable(); check_auto_cache_resize_epoch_markers(); diff --git a/test/cache_api.c b/test/cache_api.c index f303601..e72a903 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -187,6 +187,9 @@ check_fapl_mdc_api_calls(void) /* 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, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 + 1), /* double min_clean_fraction = */ 0.2, @@ -748,6 +751,9 @@ check_file_mdc_api_calls(void) { /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 + 1), /* double min_clean_fraction = */ 0.2, @@ -773,6 +779,9 @@ check_file_mdc_api_calls(void) { /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ TRUE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (512 * 1024), /* double min_clean_fraction = */ 0.1, @@ -798,6 +807,9 @@ check_file_mdc_api_calls(void) { /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.2, @@ -823,6 +835,9 @@ check_file_mdc_api_calls(void) { /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.15, @@ -1306,6 +1321,9 @@ check_and_validate_cache_size(hid_t file_id, * * Modifications: * + * JRM -- 7/12/06 + * Added progress reporting code. + * *------------------------------------------------------------------------- */ @@ -1320,6 +1338,7 @@ mdc_api_call_smoke_check(void) const char * fcn_name = "mdc_api_call_smoke_check()"; char filename[512]; hbool_t valid_chunk; + hbool_t report_progress = FALSE; hbool_t dump_hit_rate = FALSE; int64_t min_accesses = 1000; double min_hit_rate = 0.90; @@ -1332,6 +1351,7 @@ mdc_api_call_smoke_check(void) hid_t properties; char dset_name[64]; int i, j, k, l, m, n; + int progress_counter; herr_t status; hsize_t dims[2]; hsize_t a_size[2]; @@ -1343,6 +1363,9 @@ mdc_api_call_smoke_check(void) { /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 500000, /* double min_clean_fraction = */ 0.1, @@ -1368,6 +1391,9 @@ mdc_api_call_smoke_check(void) { /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 12000000, /* double min_clean_fraction = */ 0.1, @@ -1393,6 +1419,9 @@ mdc_api_call_smoke_check(void) { /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 2000000, /* double min_clean_fraction = */ 0.1, @@ -1428,6 +1457,13 @@ mdc_api_call_smoke_check(void) */ /* setup the file name */ + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout,"\nSetting up file ... "); + HDfflush(stdout); + } + if ( pass ) { if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) @@ -1466,8 +1502,21 @@ mdc_api_call_smoke_check(void) /* verify that the cache is now set to the alternate config */ validate_mdc_config(file_id, &mod_config_1, TRUE, 2); + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout,"Done.\n"); /* setting up file */ + HDfflush(stdout); + } + /* create the datasets */ + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout,"Creating datasets ... "); + HDfflush(stdout); + } + if ( pass ) { i = 0; @@ -1572,8 +1621,22 @@ mdc_api_call_smoke_check(void) } } + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout,"Done.\n"); + HDfflush(stdout); + } + /* initialize all datasets on a round robin basis */ i = 0; + progress_counter = 0; + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout, "Initializing datasets "); + HDfflush(stdout); + } + while ( ( pass ) && ( i < DSET_SIZE ) ) { j = 0; @@ -1639,6 +1702,24 @@ mdc_api_call_smoke_check(void) } i += CHUNK_SIZE; + + if ( ( pass ) && ( report_progress ) ) { + + progress_counter += CHUNK_SIZE; + + if ( progress_counter >= DSET_SIZE / 20 ) { + + progress_counter = 0; + HDfprintf(stdout, "."); + HDfflush(stdout); + } + } + } + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout," Done.\n"); /* initializing data sets */ + HDfflush(stdout); } /* set alternate config 2 */ @@ -1655,7 +1736,15 @@ mdc_api_call_smoke_check(void) validate_mdc_config(file_id, &mod_config_2, TRUE, 3); /* do random reads on all datasets */ + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout, "Doing random reads on all datasets "); + HDfflush(stdout); + } + n = 0; + progress_counter = 0; while ( ( pass ) && ( n < NUM_RANDOM_ACCESSES ) ) { m = rand() % NUM_DSETS; @@ -1738,8 +1827,27 @@ mdc_api_call_smoke_check(void) } n++; + + if ( ( pass ) && ( report_progress ) ) { + + progress_counter++; + + if ( progress_counter >= NUM_RANDOM_ACCESSES / 20 ) { + + progress_counter = 0; + HDfprintf(stdout, "."); + HDfflush(stdout); + } + } + } + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout, " Done.\n"); /* random reads on all data sets */ + HDfflush(stdout); } + /* close the file spaces we are done with */ i = 1; while ( ( pass ) && ( i < NUM_DSETS ) ) @@ -1779,8 +1887,16 @@ mdc_api_call_smoke_check(void) validate_mdc_config(file_id, &mod_config_3, TRUE, 4); /* do random reads on data set 0 only */ + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout, "Doing random reads on dataset 0 "); + HDfflush(stdout); + } + m = 0; n = 0; + progress_counter = 0; while ( ( pass ) && ( n < NUM_RANDOM_ACCESSES ) ) { i = (rand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE; @@ -1858,8 +1974,34 @@ mdc_api_call_smoke_check(void) } n++; + + if ( ( pass ) && ( report_progress ) ) { + + progress_counter++; + + if ( progress_counter >= NUM_RANDOM_ACCESSES / 20 ) { + + progress_counter = 0; + HDfprintf(stdout, "."); + HDfflush(stdout); + } + } + } + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout, " Done.\n"); /* random reads data set 0 */ + HDfflush(stdout); } + + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout,"Shutting down ... "); + HDfflush(stdout); + } + + /* close file space 0 */ if ( pass ) { @@ -1916,6 +2058,13 @@ mdc_api_call_smoke_check(void) } } + if ( ( pass ) && ( report_progress ) ) { + + HDfprintf(stdout,"Done.\n"); /* shutting down */ + HDfflush(stdout); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } if ( ! pass ) @@ -1929,7 +2078,7 @@ mdc_api_call_smoke_check(void) * used to test error rejection in the MDC related API calls. */ -#define NUM_INVALID_CONFIGS 31 +#define NUM_INVALID_CONFIGS 34 H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = { @@ -1937,6 +2086,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* 0 -- bad version */ /* int version = */ -1, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -1962,6 +2114,9 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* 1 -- bad rpt_fcn_enabled */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ -1, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -1984,9 +2139,96 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 2 -- bad set_initial_size */ + /* 2 -- bad open_trace_file */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ -1, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024), + /* double min_clean_fraction = */ 0.25, + /* size_t max_size = */ (16 * 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, + /* double increment = */ 2.0, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024), + /* 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, + /* size_t max_decrement = */ (1 * 1024 * 1024), + /* int epochs_before_eviction = */ 3, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.1, + /* int dirty_bytes_threshold = */ (256 * 1024) + }, + { + /* 3 -- bad close_trace_file */ + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ -1, + /* char trace_file_name[] = */ "", + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024), + /* double min_clean_fraction = */ 0.25, + /* size_t max_size = */ (16 * 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, + /* double increment = */ 2.0, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024), + /* 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, + /* size_t max_decrement = */ (1 * 1024 * 1024), + /* int epochs_before_eviction = */ 3, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.1, + /* int dirty_bytes_threshold = */ (256 * 1024) + }, + { + /* 4 -- open_trace_file == TRUE and empty trace_file_name */ + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ TRUE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024), + /* double min_clean_fraction = */ 0.25, + /* size_t max_size = */ (16 * 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, + /* double increment = */ 2.0, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024), + /* 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, + /* size_t max_decrement = */ (1 * 1024 * 1024), + /* int epochs_before_eviction = */ 3, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.1, + /* int dirty_bytes_threshold = */ (256 * 1024) + }, + { + /* 5 -- bad set_initial_size */ + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ 2, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2009,9 +2251,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 3 -- max_size too big */ + /* 6 -- max_size too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2034,9 +2279,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 4 -- min_size too small */ + /* 7 -- min_size too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2059,9 +2307,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 5 -- min_size > max_size */ + /* 8 -- min_size > max_size */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ FALSE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2084,9 +2335,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 6 -- initial size out of range (too big) */ + /* 9 -- initial size out of range (too big) */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (16 * 1024 * 1024 + 1), /* double min_clean_fraction = */ 0.25, @@ -2109,9 +2363,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 7 -- initial_size out of range (too small) */ + /* 10 -- initial_size out of range (too small) */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 - 1), /* double min_clean_fraction = */ 0.25, @@ -2134,9 +2391,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 8 -- min_clean_fraction too big */ + /* 11 -- min_clean_fraction too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 1.000001, @@ -2159,9 +2419,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 9 -- min_clean_fraction too small */ + /* 12 -- min_clean_fraction too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ -0.00000001, @@ -2184,9 +2447,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 10 -- epoch_length too small */ + /* 13 -- epoch_length too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2209,9 +2475,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 11 -- epoch_length too big */ + /* 14 -- epoch_length too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2234,9 +2503,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 12 -- invalid incr_mode */ + /* 15 -- invalid incr_mode */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2259,9 +2531,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 13 -- lower_hr_threshold too small */ + /* 16 -- lower_hr_threshold too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2284,9 +2559,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 14 -- lower_hr_threshold too big */ + /* 17 -- lower_hr_threshold too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2309,9 +2587,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 15 -- increment too small */ + /* 18 -- increment too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2334,9 +2615,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 16 -- bad apply_max_increment */ + /* 19 -- bad apply_max_increment */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2359,9 +2643,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 17 -- bad decr_mode */ + /* 20 -- bad decr_mode */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2384,9 +2671,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 18 -- upper_hr_threshold too big */ + /* 21 -- upper_hr_threshold too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2409,9 +2699,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 19 -- decrement too small */ + /* 22 -- decrement too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2434,9 +2727,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 20 -- decrement too big */ + /* 23 -- decrement too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2459,9 +2755,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 21 -- epochs_before_eviction too small */ + /* 24 -- epochs_before_eviction too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2484,9 +2783,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 22 -- epochs_before_eviction too big */ + /* 24 -- epochs_before_eviction too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2509,9 +2811,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 23 -- invalid apply_empty_reserve */ + /* 26 -- invalid apply_empty_reserve */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2534,9 +2839,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 24 -- empty_reserve too small */ + /* 27 -- empty_reserve too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2559,9 +2867,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 25 -- empty_reserve too big */ + /* 28 -- empty_reserve too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2584,9 +2895,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 26 -- upper_hr_threshold too small */ + /* 29 -- upper_hr_threshold too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2609,9 +2923,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 27 -- upper_hr_threshold too big */ + /* 30 -- upper_hr_threshold too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2634,9 +2951,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 28 -- upper_hr_threshold <= lower_hr_threshold */ + /* 31 -- upper_hr_threshold <= lower_hr_threshold */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2659,9 +2979,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (256 * 1024) }, { - /* 29 -- dirty_bytes_threshold too small */ + /* 32 -- dirty_bytes_threshold too small */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2684,9 +3007,12 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* int dirty_bytes_threshold = */ (H5C__MIN_MAX_CACHE_SIZE / 2) - 1 }, { - /* 30 -- dirty_bytes_threshold too big */ + /* 33 -- dirty_bytes_threshold too big */ /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2758,7 +3084,7 @@ check_fapl_mdc_api_errs(void) } } - /* Create a FAPL for test purposes, and veify that it contains the + /* Create a FAPL for test purposes, and verify that it contains the * default MDC configuration. */ @@ -2902,6 +3228,7 @@ check_file_mdc_api_errs(void) const char * fcn_name = "check_file_mdc_api_errs()"; char filename[512]; static char msg[128]; + hbool_t show_progress = FALSE; int i; herr_t result; hid_t file_id = -1; @@ -2924,6 +3251,11 @@ check_file_mdc_api_errs(void) /* setup the file name */ if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: calling h5_fixname().\n", fcn_name); + } + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { @@ -2934,6 +3266,11 @@ check_file_mdc_api_errs(void) if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: calling H5Fcreate().\n", fcn_name); + } + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if ( file_id < 0 ) { @@ -2951,6 +3288,11 @@ check_file_mdc_api_errs(void) scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fget_mdc_config() 1.\n", fcn_name); + } + H5E_BEGIN_TRY { result = H5Fget_mdc_config(-1, &scratch); } H5E_END_TRY; @@ -2964,6 +3306,11 @@ check_file_mdc_api_errs(void) if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fget_mdc_config() 2.\n", fcn_name); + } + H5E_BEGIN_TRY { result = H5Fget_mdc_config(file_id, NULL); } H5E_END_TRY; @@ -2978,6 +3325,11 @@ check_file_mdc_api_errs(void) scratch.version = -1; /* a convenient, invalid value */ if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fget_mdc_config() 3.\n", fcn_name); + } + H5E_BEGIN_TRY { result = H5Fget_mdc_config(file_id, &scratch); } H5E_END_TRY; @@ -2995,6 +3347,11 @@ check_file_mdc_api_errs(void) scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER; if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fset_mdc_config() 1.\n", fcn_name); + } + H5E_BEGIN_TRY { result = H5Fset_mdc_config(-1, &default_config); } H5E_END_TRY; @@ -3008,6 +3365,11 @@ check_file_mdc_api_errs(void) if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fset_mdc_config() 2.\n", fcn_name); + } + H5E_BEGIN_TRY { result = H5Fset_mdc_config(file_id, NULL); } H5E_END_TRY; @@ -3022,6 +3384,13 @@ check_file_mdc_api_errs(void) i = 0; while ( ( pass ) && ( i < NUM_INVALID_CONFIGS ) ) { + if ( show_progress ) { + + HDfprintf(stdout, + "%s: testing H5Fset_mdc_config() with invalid config %d.\n", + fcn_name, i); + } + H5E_BEGIN_TRY { result = H5Fset_mdc_config(file_id, &(invalid_configs[i])); } H5E_END_TRY; @@ -3045,6 +3414,12 @@ check_file_mdc_api_errs(void) /* test H5Fget_mdc_hit_rate() */ if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 1.\n", + fcn_name); + } + H5E_BEGIN_TRY { result = H5Fget_mdc_hit_rate(-1, &hit_rate); } H5E_END_TRY; @@ -3058,6 +3433,12 @@ check_file_mdc_api_errs(void) if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 2.\n", + fcn_name); + } + H5E_BEGIN_TRY { result = H5Fget_mdc_hit_rate(file_id, NULL); } H5E_END_TRY; @@ -3073,6 +3454,12 @@ check_file_mdc_api_errs(void) /* test H5Freset_mdc_hit_rate_stats() */ if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Freset_mdc_hit_rate_stats().\n", + fcn_name); + } + H5E_BEGIN_TRY { result = H5Freset_mdc_hit_rate_stats(-1); } H5E_END_TRY; @@ -3089,6 +3476,11 @@ check_file_mdc_api_errs(void) /* test H5Fget_mdc_size() */ if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fget_mdc_size() 1.\n", fcn_name); + } + H5E_BEGIN_TRY { result = H5Fget_mdc_size(-1, &max_size, &min_clean_size, &cur_size, &cur_num_entries); @@ -3103,6 +3495,11 @@ check_file_mdc_api_errs(void) if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: testing H5Fget_mdc_size() 2.\n", fcn_name); + } + if ( ( H5Fget_mdc_size(file_id, &max_size, NULL, NULL, NULL) < 0 ) || ( H5Fget_mdc_size(file_id, NULL, &min_clean_size, NULL, NULL) < 0 ) || @@ -3120,6 +3517,11 @@ check_file_mdc_api_errs(void) /* close the file and delete it */ if ( pass ) { + if ( show_progress ) { + + HDfprintf(stdout, "%s: cleaning up from tests.\n", fcn_name); + } + if ( H5Fclose(file_id) < 0 ) { pass = FALSE; @@ -3173,11 +3575,17 @@ main(void) #if 1 check_fapl_mdc_api_calls(); +#endif +#if 1 check_file_mdc_api_calls(); #endif +#if 1 mdc_api_call_smoke_check(); +#endif #if 1 check_fapl_mdc_api_errs(); +#endif +#if 1 check_file_mdc_api_errs(); #endif diff --git a/test/cache_common.c b/test/cache_common.c index ad5fe12..7e04d37 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -1449,6 +1449,69 @@ takedown_cache(H5C_t * cache_ptr, /*------------------------------------------------------------------------- + * Function: expunge_entry() + * + * Purpose: Expunge the entry indicated by the type and index. + * + * Do nothing if pass is FALSE on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 7/6/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +void +expunge_entry(H5C_t * cache_ptr, + int32_t type, + int32_t idx) +{ + /* const char * fcn_name = "expunge_entry()"; */ + herr_t result; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + + if ( pass ) { + + HDassert( cache_ptr ); + HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); + HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); + + base_addr = entries[type]; + entry_ptr = &(base_addr[idx]); + + HDassert( entry_ptr->index == idx ); + HDassert( entry_ptr->type == type ); + HDassert( entry_ptr == entry_ptr->self ); + HDassert( entry_ptr->cache_ptr == cache_ptr ); + HDassert( ! ( entry_ptr->header.is_protected ) ); + HDassert( ! ( entry_ptr->is_protected ) ); + HDassert( ! ( entry_ptr->header.is_pinned ) ); + HDassert( ! ( entry_ptr->is_pinned ) ); + + result = H5C_expunge_entry(NULL, -1, -1, cache_ptr, &(types[type]), + entry_ptr->addr); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "error in H5C_expunge_entry()."; + + } + } + + return; + +} /* expunge_entry() */ + + +/*------------------------------------------------------------------------- * Function: flush_cache() * * Purpose: Flush the specified cache, destroying all entries if @@ -1709,7 +1772,7 @@ mark_pinned_or_protected_entry_dirty(H5C_t * cache_ptr, int32_t type, int32_t idx) { - const char * fcn_name = "mark_pinned_or_protected_entry_dirty()"; + /* const char * fcn_name = "mark_pinned_or_protected_entry_dirty()"; */ herr_t result; test_entry_t * base_addr; test_entry_t * entry_ptr; diff --git a/test/cache_common.h b/test/cache_common.h index 452824e..c6c2a32 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -423,6 +423,10 @@ haddr_t type_and_index_to_addr(int32_t type, int32_t idx); #endif +void expunge_entry(H5C_t * cache_ptr, + int32_t type, + int32_t idx); + void insert_entry(H5C_t * cache_ptr, int32_t type, int32_t idx, diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 4b7d298..448b760 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -93,6 +93,13 @@ long local_pins = 0; * * len: Length of the entry. * + * local_len: Length of the entry according to the cache. This + * value must be positive, and may not be larger than len. + * + * The field exists to allow us change the sizes of entries + * in the cache without upsetting the server. This value + * is only used locally, and is never sent to the server. + * * ver: Version number of the entry. This number is initialize * to zero, and incremented each time the entry is modified. * @@ -131,6 +138,7 @@ struct datum H5C_cache_entry_t header; haddr_t base_addr; size_t len; + size_t local_len; int ver; hbool_t dirty; hbool_t valid; @@ -325,6 +333,7 @@ const H5C_class_t types[NUMBER_OF_ENTRY_TYPES] = /* test utility functions */ +void expunge_entry(H5C_t * cache_ptr, H5F_t * file_ptr, int32_t idx); void insert_entry(H5C_t * cache_ptr, H5F_t * file_ptr, int32_t idx, unsigned int flags); void local_pin_and_unpin_random_entries(H5C_t * cache_ptr, H5F_t * file_ptr, @@ -349,8 +358,12 @@ void mark_pinned_or_protected_entry_dirty(H5C_t * cache_ptr, int32_t idx); void pin_entry(H5C_t * cache_ptr, H5F_t * file_ptr, int32_t idx, hbool_t global, hbool_t dirty); +void pin_protected_entry(H5C_t * cache_ptr, H5F_t * file_ptr, + int32_t idx, hbool_t global); void rename_entry(H5C_t * cache_ptr, H5F_t * file_ptr, int32_t old_idx, int32_t new_idx); +void resize_entry(H5C_t * cache_ptr, H5F_t * file_ptr, + int32_t idx, size_t new_size); hbool_t setup_cache_for_test(hid_t * fid_ptr, H5F_t ** file_ptr_ptr, H5C_t ** cache_ptr_ptr); void setup_rand(void); @@ -369,6 +382,7 @@ hbool_t smoke_check_2(void); hbool_t smoke_check_3(void); hbool_t smoke_check_4(void); hbool_t smoke_check_5(void); +hbool_t trace_file_check(void); /*****************************************************************************/ @@ -627,7 +641,7 @@ set_up_file_communicator(void) int addr_to_datum_index(haddr_t base_addr) { - const char * fcn_name = "addr_to_datum_index()"; + /* const char * fcn_name = "addr_to_datum_index()"; */ int top = NUM_DATA_ENTRIES - 1; int bottom = 0; int middle = (NUM_DATA_ENTRIES - 1) / 2; @@ -673,14 +687,15 @@ addr_to_datum_index(haddr_t base_addr) * * Modifications: * - * None. + * JRM -- 7/11/06 + * Added support for the local_len field. * *****************************************************************************/ void init_data(void) { - const char * fcn_name = "init_data()"; + /* const char * fcn_name = "init_data()"; */ /* The set of address offsets is chosen so as to avoid allowing the * base addresses to fall in a pattern of that will annoy the hash * table, and to give a good range of entry sizes. @@ -705,6 +720,7 @@ init_data(void) { data[i].base_addr = addr; data[i].len = (size_t)(addr_offsets[j]); + data[i].local_len = (size_t)(addr_offsets[j]); data[i].ver = 0; data[i].dirty = FALSE; data[i].valid = FALSE; @@ -814,7 +830,6 @@ do_sync(void) { const char * fcn_name = "do_sync()"; - herr_t ret_value = SUCCEED; struct mssg_t mssg; if ( nerrors <= 0 ) { @@ -1640,6 +1655,12 @@ serve_write_request(struct mssg_t * mssg_ptr) * * Modifications: * + * JRM -- 7/11/06 + * Modified code to support the local_len field of datum. + * This field allow us to track the cache's value for the + * length of the entry, while retaining the original + * value for communications with the server. + * *------------------------------------------------------------------------- */ @@ -1663,7 +1684,8 @@ clear_datum(H5F_t * f, HDassert( &(data[idx]) == entry_ptr ); HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); - HDassert( entry_ptr->header.size == entry_ptr->len ); + HDassert( ( entry_ptr->header.size == entry_ptr->len ) || + ( entry_ptr->header.size == entry_ptr->local_len ) ); entry_ptr->header.is_dirty = FALSE; entry_ptr->dirty = FALSE; @@ -1700,6 +1722,12 @@ clear_datum(H5F_t * f, * * Modifications: * + * JRM -- 7/11/06 + * Modified code to support the local_len field of datum. + * This field allow us to track the cache's value for the + * length of the entry, while retaining the original + * value for communications with the server. + * *------------------------------------------------------------------------- */ @@ -1722,7 +1750,8 @@ destroy_datum(H5F_t UNUSED * f, HDassert( &(data[idx]) == entry_ptr ); HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); - HDassert( entry_ptr->header.size == entry_ptr->len ); + HDassert( ( entry_ptr->header.size == entry_ptr->len ) || + ( entry_ptr->header.size == entry_ptr->local_len ) ); HDassert( !(entry_ptr->dirty) ); HDassert( !(entry_ptr->header.is_dirty) ); @@ -1755,6 +1784,12 @@ destroy_datum(H5F_t UNUSED * f, * a bug spotted on Cobalt. If it doesn't fix the problem, * it will narrow down the possibilities. * + * JRM -- 7/11/06 + * Modified code to support the local_len field of datum. + * This field allow us to track the cache's value for the + * length of the entry, while retaining the original + * value for communications with the server. + * *------------------------------------------------------------------------- */ @@ -1783,7 +1818,8 @@ flush_datum(H5F_t *f, HDassert( &(data[idx]) == entry_ptr ); HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); - HDassert( entry_ptr->header.size == entry_ptr->len ); + HDassert( ( entry_ptr->header.size == entry_ptr->len ) || + ( entry_ptr->header.size == entry_ptr->local_len ) ); HDassert( entry_ptr->header.is_dirty == entry_ptr->dirty ); @@ -2052,6 +2088,14 @@ load_datum(H5F_t UNUSED *f, * * Modifications: * + * JRM -- 7/11/06 + * Modified function to return the local_len field instead + * of the len field. These two fields usually contain the + * same value, but if the size of an entry is changed, we + * store the altered size in local_len without changing + * len. Note that local_len must be positive, and may + * not exceed len. + * *------------------------------------------------------------------------- */ @@ -2074,10 +2118,12 @@ size_datum(H5F_t UNUSED * f, HDassert( idx < NUM_DATA_ENTRIES ); HDassert( idx < virt_num_data_entries ); HDassert( &(data[idx]) == entry_ptr ); + HDassert( entry_ptr->local_len > 0 ); + HDassert( entry_ptr->local_len <= entry_ptr->len ); HDassert( entry_ptr->header.addr == entry_ptr->base_addr ); - *size_ptr = entry_ptr->len; + *size_ptr = entry_ptr->local_len; return(SUCCEED); @@ -2089,6 +2135,90 @@ size_datum(H5F_t UNUSED * f, /*****************************************************************************/ /***************************************************************************** + * Function: expunge_entry() + * + * Purpose: Expunge the entry indicated by the type and index, mark it + * as clean, and don't increment its version number. + * + * Do nothing if nerrors is non-zero on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 07/11/06 + * + * Modifications: + * + * None. + * + *****************************************************************************/ + +void +expunge_entry(H5C_t * cache_ptr, + H5F_t * file_ptr, + int32_t idx) +{ + const char * fcn_name = "expunge_entry()"; + hbool_t in_cache; + herr_t result; + struct datum * entry_ptr; + + HDassert( cache_ptr ); + HDassert( file_ptr ); + HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); + HDassert( idx < virt_num_data_entries ); + + entry_ptr = &(data[idx]); + + HDassert( !(entry_ptr->locked) ); + HDassert( !(entry_ptr->global_pinned) ); + HDassert( !(entry_ptr->local_pinned) ); + + entry_ptr->dirty = TRUE; + + if ( nerrors == 0 ) { + + result = H5AC_expunge_entry(file_ptr, -1, &(types[0]), + entry_ptr->header.addr); + + if ( result < 0 ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: Error in H5AC_expunge_entry().\n", + world_mpi_rank, fcn_name); + } + } + + HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert( ! ((entry_ptr->header).is_dirty) ); + + result = H5C_get_entry_status(cache_ptr, entry_ptr->base_addr, + NULL, &in_cache, NULL, NULL, NULL); + + if ( result < 0 ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: Error in H5C_get_entry_status().\n", + world_mpi_rank, fcn_name); + } + } else if ( in_cache ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: Expunged entry still in cache?!?\n", + world_mpi_rank, fcn_name); + } + } + } + + return; + +} /* expunge_entry() */ + + +/***************************************************************************** * Function: insert_entry() * * Purpose: Insert the entry indicated by the type and index, mark it @@ -2205,7 +2335,7 @@ local_pin_and_unpin_random_entries(H5C_t * cache_ptr, int min_count, int max_count) { - const char * fcn_name = "local_pin_and_unpin_random_entries()"; + /* const char * fcn_name = "local_pin_and_unpin_random_entries()"; */ if ( nerrors == 0 ) { @@ -2280,7 +2410,7 @@ local_pin_random_entry(H5C_t * cache_ptr, int min_idx, int max_idx) { - const char * fcn_name = "local_pin_random_entry()"; + /* const char * fcn_name = "local_pin_random_entry()"; */ int idx; if ( nerrors == 0 ) { @@ -2329,7 +2459,7 @@ local_unpin_all_entries(H5C_t * cache_ptr, H5F_t * file_ptr, hbool_t via_unprotect) { - const char * fcn_name = "local_unpin_all_entries()"; + /* const char * fcn_name = "local_unpin_all_entries()"; */ if ( nerrors == 0 ) { @@ -2377,7 +2507,7 @@ local_unpin_next_pinned_entry(H5C_t * cache_ptr, int start_idx, hbool_t via_unprotect) { - const char * fcn_name = "local_unpin_next_pinned_entry()"; + /* const char * fcn_name = "local_unpin_next_pinned_entry()"; */ int i = 0; int idx = -1; @@ -2442,7 +2572,7 @@ lock_and_unlock_random_entries(H5C_t * cache_ptr, int min_count, int max_count) { - const char * fcn_name = "lock_and_unlock_random_entries()"; + /* const char * fcn_name = "lock_and_unlock_random_entries()"; */ int count; int i; @@ -2492,7 +2622,7 @@ lock_and_unlock_random_entry(H5C_t * cache_ptr, int min_idx, int max_idx) { - const char * fcn_name = "lock_and_unlock_random_entry()"; + /* const char * fcn_name = "lock_and_unlock_random_entry()"; */ int idx; if ( nerrors == 0 ) { @@ -2532,6 +2662,10 @@ lock_and_unlock_random_entry(H5C_t * cache_ptr, * * Modifications: * + * JRM -- 7/11/06 + * Modified asserts to handle the new local_len field in + * datum. + * *****************************************************************************/ void @@ -2559,7 +2693,8 @@ lock_entry(H5C_t * cache_ptr, if ( ( cache_entry_ptr != (void *)(&(entry_ptr->header)) ) || ( entry_ptr->header.type != &(types[0]) ) || - ( entry_ptr->len != entry_ptr->header.size ) || + ( ( entry_ptr->len != entry_ptr->header.size ) && + ( entry_ptr->local_len != entry_ptr->header.size ) ) || ( entry_ptr->base_addr != entry_ptr->header.addr ) ) { nerrors++; @@ -2573,7 +2708,6 @@ lock_entry(H5C_t * cache_ptr, } - HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); } @@ -2735,7 +2869,7 @@ pin_entry(H5C_t * cache_ptr, hbool_t global, hbool_t dirty) { - const char * fcn_name = "pin_entry()"; + /* const char * fcn_name = "pin_entry()"; */ unsigned int flags = H5AC__PIN_ENTRY_FLAG; struct datum * entry_ptr; @@ -2785,6 +2919,85 @@ pin_entry(H5C_t * cache_ptr, /***************************************************************************** + * Function: pin_protected_entry() + * + * Purpose: Insert the entry indicated by the type and index, mark it + * as dirty, and increment its version number. + * + * Do nothing if nerrors is non-zero on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 01/04/06 + * + * Modifications: + * + * None. + * + *****************************************************************************/ + +void +pin_protected_entry(H5C_t * cache_ptr, + H5F_t * file_ptr, + int32_t idx, + hbool_t global) +{ + const char * fcn_name = "pin_protected_entry()"; + herr_t result; + struct datum * entry_ptr; + + HDassert( cache_ptr ); + HDassert( file_ptr ); + HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); + HDassert( idx < virt_num_data_entries ); + + entry_ptr = &(data[idx]); + + HDassert( entry_ptr->locked ); + + if ( nerrors == 0 ) { + + result = H5AC_pin_protected_entry(file_ptr, (void *)entry_ptr); + + if ( ( result < 0 ) || + ( entry_ptr->header.type != &(types[0]) ) || + ( ( entry_ptr->len != entry_ptr->header.size ) && + ( entry_ptr->local_len != entry_ptr->header.size ) )|| + ( entry_ptr->base_addr != entry_ptr->header.addr ) || + ( ! ( (entry_ptr->header).is_pinned ) ) ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, + "%d:%s: Error in H5AC_pin_protected entry().\n", + world_mpi_rank, fcn_name); + } + } + + if ( global ) { + + entry_ptr->global_pinned = TRUE; + + global_pins++; + + } else { + + entry_ptr->local_pinned = TRUE; + + local_pins++; + + } + + HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + } + + return; + +} /* pin_protected_entry() */ + + +/***************************************************************************** * Function: rename_entry() * * Purpose: Rename the entry indicated old_idx to the entry indicated @@ -2801,7 +3014,8 @@ pin_entry(H5C_t * cache_ptr, * * Modifications: * - * None. + * 7/11/06 -- JRM + * Added support for the phony_len field in datum. * *****************************************************************************/ @@ -2814,6 +3028,7 @@ rename_entry(H5C_t * cache_ptr, const char * fcn_name = "rename_entry()"; herr_t result; int tmp; + size_t tmp_len; haddr_t old_addr = HADDR_UNDEF; haddr_t new_addr = HADDR_UNDEF; struct datum * old_entry_ptr; @@ -2876,6 +3091,13 @@ rename_entry(H5C_t * cache_ptr, tmp = old_entry_ptr->index; old_entry_ptr->index = new_entry_ptr->index; new_entry_ptr->index = tmp; + + if ( old_entry_ptr->local_len != new_entry_ptr->local_len ) { + + tmp_len = old_entry_ptr->local_len; + old_entry_ptr->local_len = new_entry_ptr->local_len; + new_entry_ptr->local_len = tmp_len; + } } } @@ -2885,6 +3107,86 @@ rename_entry(H5C_t * cache_ptr, /***************************************************************************** + * Function: resize_entry() + * + * Purpose: Resize the pinned entry indicated by idx to the new_size. + * Note that new_size must be greater than 0, and must be + * less than or equal to the original size of the entry. + * + * Do nothing if nerrors isn't zero. + * + * Return: void + * + * Programmer: John Mainzer + * 7/11/06 + * + * Modifications: + * + * None + * + *****************************************************************************/ + +void +resize_entry(H5C_t * cache_ptr, + H5F_t * file_ptr, + int32_t idx, + size_t new_size) +{ + const char * fcn_name = "resize_entry()"; + herr_t result; + struct datum * entry_ptr; + + if ( nerrors == 0 ) { + + HDassert( cache_ptr ); + HDassert( file_ptr ); + HDassert( ( 0 <= idx ) && ( idx < NUM_DATA_ENTRIES ) ); + HDassert( idx < virt_num_data_entries ); + + entry_ptr = &(data[idx]); + + HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert( !(entry_ptr->header.is_protected) ); + HDassert( !(entry_ptr->locked) ); + HDassert( ( entry_ptr->global_pinned ) && + ( ! entry_ptr->local_pinned ) ); + HDassert( ( entry_ptr->header.size == entry_ptr->len ) || + ( entry_ptr->header.size == entry_ptr->local_len ) ); + HDassert( new_size > 0 ); + HDassert( new_size <= entry_ptr->len ); + + result = H5AC_resize_pinned_entry(file_ptr, (void *)entry_ptr, + new_size); + + if ( result < 0 ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: H5AC_rename() failed.\n", + world_mpi_rank, fcn_name); + } + + } else { + + HDassert( ((entry_ptr->header).type)->id == DATUM_ENTRY_TYPE ); + HDassert( entry_ptr->header.is_dirty ); + HDassert( entry_ptr->header.size == new_size ); + + entry_ptr->dirty = TRUE; + entry_ptr->local_len = new_size; + + /* touch up version. */ + + (entry_ptr->ver)++; + } + } + + return; + +} /* resize_entry() */ + + +/***************************************************************************** * * Function: setup_cache_for_test() * @@ -3283,6 +3585,9 @@ take_down_cache(hid_t fid) * * Modifications: * + * 7/11/06 + * Updated for the new local_len field in datum. + * *****************************************************************************/ void @@ -3321,7 +3626,8 @@ unlock_entry(H5C_t * cache_ptr, if ( ( result < 0 ) || ( entry_ptr->header.type != &(types[0]) ) || - ( entry_ptr->len != entry_ptr->header.size ) || + ( ( entry_ptr->len != entry_ptr->header.size ) && + ( entry_ptr->local_len != entry_ptr->header.size ) ) || ( entry_ptr->base_addr != entry_ptr->header.addr ) ) { nerrors++; @@ -3408,7 +3714,8 @@ unpin_entry(H5C_t * cache_ptr, if ( dirty ) { - mark_pinned_entry_dirty(cache_ptr, file_ptr, idx, FALSE, (size_t)0); + mark_pinned_entry_dirty(cache_ptr, file_ptr, idx, FALSE, + (size_t)0); } @@ -4684,7 +4991,9 @@ smoke_check_4(void) * * Modifications: * - * None. + * JRM -- 7/12/06 + * Added test code for H5AC_expunge_entry() and + * H5AC_resize_pinned_entry(). * *****************************************************************************/ @@ -4758,6 +5067,17 @@ smoke_check_5(void) } unlock_entry(cache_ptr, file_ptr, i, H5AC__NO_FLAGS_SET); + + if ( i % 2 == 1 ) + { + if ( i % 4 == 1 ) { + + lock_entry(cache_ptr, file_ptr, i); + unlock_entry(cache_ptr, file_ptr, i, H5AC__DIRTIED_FLAG); + } + + expunge_entry(cache_ptr, file_ptr, i); + } } for ( i = (virt_num_data_entries / 2) - 1; @@ -4768,6 +5088,11 @@ smoke_check_5(void) if ( i % 2 == 0 ) { + if ( i % 8 <= 4 ) { + + resize_entry(cache_ptr, file_ptr, i, data[i].len / 2); + } + if ( i % 4 == 0 ) { mark_pinned_or_protected_entry_dirty(cache_ptr, @@ -4778,7 +5103,13 @@ smoke_check_5(void) mark_pinned_entry_dirty(cache_ptr, file_ptr, i, FALSE, (size_t)0); } + + if ( i % 8 <= 4 ) { + + resize_entry(cache_ptr, file_ptr, i, data[i].len); + } } + unpin_entry(cache_ptr, file_ptr, i, TRUE, FALSE, FALSE); } @@ -4853,6 +5184,383 @@ smoke_check_5(void) /***************************************************************************** * + * Function: trace_file_check() + * + * Purpose: A basic test of the trace file capability. In essence, + * we invoke all operations that generate trace file output, + * and then verify that the expected output was generated. + * + * Note that the trace file is currently implemented at the + * H5AC level, so all calls have to go through H5AC. Thus it + * is more convenient to test trace file capabilities in the + * parallel cache test which works at the H5AC level, instead + * of in the serial test code which does everything at the + * H5C level. + * + * The function must test trace file output in the following + * functions: + * + * - H5AC_flush() + * - H5AC_set() + * - H5AC_mark_pinned_entry_dirty() + * - H5AC_mark_pinned_or_protected_entry_dirty() + * H5AC_rename() + * - H5AC_pin_protected_entry() + * - H5AC_protect() + * - H5AC_unpin_entry() + * - H5AC_unprotect() + * - H5AC_set_cache_auto_resize_config() + * - H5AC_expunge_entry() + * - H5AC_resize_pinned_entry() + * + * This test is skipped if H5_METADATA_TRACE_FILE is undefined. + * + * Return: Success: TRUE + * + * Failure: FALSE + * + * Programmer: JRM -- 6/13/06 + * + * Modifications: + * + * JRM -- 7/11/06 + * Updated fro H5AC_expunge_entry() and + * H5AC_resize_pinned_entry(). + * + *****************************************************************************/ + +hbool_t +trace_file_check(void) +{ + hbool_t success = TRUE; + +#ifdef H5_METADATA_TRACE_FILE + + const char * fcn_name = "trace_file_check()"; + const char * expected_output[] = + { + "### HDF5 metadata cache trace file version 1 ###\n", + "H5AC_set_cache_auto_resize_config 1 0 1 0 \"t_cache_trace.txt\" 0 1048576 0.500000 16777216 1048576 50000 1 0.900000 2.000000 1 4194304 3 0.999000 0.900000 1 1048576 3 1 0.100000 262144 0\n", + "H5AC_set 0x0 12 0x0 2 0\n", + "H5AC_set 0x2 12 0x0 2 0\n", + "H5AC_set 0x4 12 0x0 4 0\n", + "H5AC_set 0x8 12 0x0 6 0\n", + "H5AC_protect 0 12 2 1\n", + "H5AC_mark_pinned_or_protected_entry_dirty 0 0\n", + "H5AC_protect 0 12 0 0 0\n", + "H5AC_protect 2 12 2 1\n", + "H5AC_pin_protected_entry 2 0\n", + "H5AC_protect 2 12 0 0 0\n", + "H5AC_unpin_entry 2 0\n", + "H5AC_expunge_entry 2 12 0\n", + "H5AC_protect 4 12 4 1\n", + "H5AC_pin_protected_entry 4 0\n", + "H5AC_protect 4 12 0 0 0\n", + "H5AC_mark_pinned_entry_dirty 0x4 0 0 0\n", + "H5AC_resize_pinned_entry 0x4 2 0 0\n", + "H5AC_resize_pinned_entry 0x4 4 0 0\n", + "H5AC_unpin_entry 4 0\n", + "H5AC_rename 0 8a65 12 0\n", + "H5AC_rename 8a65 0 12 0\n", + "H5AC_flush 0x0 0\n", + NULL + }; + char buffer[256]; + char trace_file_name[64]; + hbool_t done = FALSE; + int i; + int max_nerrors; + int expected_line_len; + int actual_line_len; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + FILE * trace_file_ptr = NULL; + H5AC_cache_config_t config; + struct mssg_t mssg; + +#endif /* H5_METADATA_TRACE_FILE */ + + if ( world_mpi_rank == 0 ) { + + TESTING("trace file collection"); + } + +#ifdef H5_METADATA_TRACE_FILE + + nerrors = 0; + init_data(); + reset_stats(); + + if ( world_mpi_rank == world_server_mpi_rank ) { + + if ( ! server_main() ) { + + /* some error occured in the server -- report failure */ + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: server_main() failed.\n", + world_mpi_rank, fcn_name); + } + } + } + else /* run the clients */ + { + + if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr) ) { + + nerrors++; + fid = -1; + cache_ptr = NULL; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", + world_mpi_rank, fcn_name); + } + } + + if ( nerrors == 0 ) { + + config.version = H5AC__CURR_CACHE_CONFIG_VERSION; + + if ( H5AC_get_cache_auto_resize_config(cache_ptr, &config) + != SUCCEED ) { + + nerrors++; + HDfprintf(stdout, + "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", + world_mpi_rank, fcn_name); + + } else { + + config.open_trace_file = TRUE; + strcpy(config.trace_file_name, "t_cache_trace.txt"); + + if ( H5AC_set_cache_auto_resize_config(cache_ptr, &config) + != SUCCEED ) { + + nerrors++; + HDfprintf(stdout, + "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", + world_mpi_rank, fcn_name); + } + } + } + + insert_entry(cache_ptr, file_ptr, 0, H5AC__NO_FLAGS_SET); + insert_entry(cache_ptr, file_ptr, 1, H5AC__NO_FLAGS_SET); + insert_entry(cache_ptr, file_ptr, 2, H5AC__NO_FLAGS_SET); + insert_entry(cache_ptr, file_ptr, 3, H5AC__NO_FLAGS_SET); + + lock_entry(cache_ptr, file_ptr, 0); + mark_pinned_or_protected_entry_dirty(cache_ptr, file_ptr, 0); + unlock_entry(cache_ptr, file_ptr, 0, H5AC__NO_FLAGS_SET); + + lock_entry(cache_ptr, file_ptr, 1); + pin_protected_entry(cache_ptr, file_ptr, 1, TRUE); + unlock_entry(cache_ptr, file_ptr, 1, H5AC__NO_FLAGS_SET); + unpin_entry(cache_ptr, file_ptr, 1, TRUE, FALSE, FALSE); + + expunge_entry(cache_ptr,file_ptr, 1); + + lock_entry(cache_ptr, file_ptr, 2); + pin_protected_entry(cache_ptr, file_ptr, 2, TRUE); + unlock_entry(cache_ptr, file_ptr, 2, H5AC__NO_FLAGS_SET); + mark_pinned_entry_dirty(cache_ptr, file_ptr, 2, FALSE, 0); + resize_entry(cache_ptr, file_ptr, 2, data[2].len / 2); + resize_entry(cache_ptr, file_ptr, 2, data[2].len); + unpin_entry(cache_ptr, file_ptr, 2, TRUE, FALSE, FALSE); + + rename_entry(cache_ptr, file_ptr, 0, 20); + rename_entry(cache_ptr, file_ptr, 0, 20); + + if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", + world_mpi_rank, fcn_name); + } + } + + if ( nerrors == 0 ) { + + config.version = H5AC__CURR_CACHE_CONFIG_VERSION; + + if ( H5AC_get_cache_auto_resize_config(cache_ptr, &config) + != SUCCEED ) { + + nerrors++; + HDfprintf(stdout, + "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", + world_mpi_rank, fcn_name); + + } else { + + config.open_trace_file = FALSE; + config.close_trace_file = TRUE; + config.trace_file_name[0] = '\0'; + + if ( H5AC_set_cache_auto_resize_config(cache_ptr, &config) + != SUCCEED ) { + + nerrors++; + HDfprintf(stdout, + "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", + world_mpi_rank, fcn_name); + } + } + } + + if ( fid >= 0 ) { + + if ( ! take_down_cache(fid) ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", + world_mpi_rank, fcn_name); + } + } + } + + /* verify that all instance of datum are back where the started + * and are clean. + */ + + for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) + { + HDassert( data_index[i] == i ); + HDassert( ! (data[i].dirty) ); + } + + /* compose the done message */ + mssg.req = DONE_REQ_CODE; + mssg.src = world_mpi_rank; + mssg.dest = world_server_mpi_rank; + mssg.mssg_num = -1; /* set by send function */ + mssg.base_addr = 0; /* not used */ + mssg.len = 0; /* not used */ + mssg.ver = 0; /* not used */ + mssg.magic = MSSG_MAGIC; + + if ( success ) { + + success = send_mssg(&mssg, FALSE); + + if ( ! success ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", + world_mpi_rank, fcn_name); + } + } + } + + if ( nerrors == 0 ) { + + sprintf(trace_file_name, "t_cache_trace.txt.%d", + (int)file_mpi_rank); + + if ( (trace_file_ptr = HDfopen(trace_file_name, "r")) == NULL ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, "%d:%s: HDfopen failed.\n", + world_mpi_rank, fcn_name); + } + } + } + + i = 0; + while ( ( nerrors == 0 ) && ( ! done ) ) + { + if ( expected_output[i] == NULL ) { + + expected_line_len = 0; + + } else { + + expected_line_len = HDstrlen(expected_output[i]); + } + + if ( HDfgets(buffer, 255, trace_file_ptr) != NULL ) { + + actual_line_len = strlen(buffer); + + } else { + + actual_line_len = 0; + } + + if ( ( actual_line_len == 0 ) && ( expected_line_len == 0 ) ) { + + done = TRUE; + + } else if ( ( actual_line_len != expected_line_len ) || + ( HDstrcmp(buffer, expected_output[i]) != 0 ) ) { + + nerrors++; + if ( verbose ) { + HDfprintf(stdout, + "%d:%s: Unexpected data in trace file line %d.\n", + world_mpi_rank, fcn_name, i); + HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", + world_mpi_rank, fcn_name, expected_output[i], + expected_line_len); + HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", + world_mpi_rank, fcn_name, buffer, + actual_line_len); + } + } else { + i++; + } + } + + if ( trace_file_ptr != NULL ) { + + HDfclose(trace_file_ptr); + trace_file_ptr = NULL; +#if 1 + HDremove(trace_file_name); +#endif + } + } + + max_nerrors = get_max_nerrors(); + + if ( world_mpi_rank == 0 ) { + + if ( max_nerrors == 0 ) { + + PASSED(); + + } else { + + failures++; + H5_FAILED(); + } + } + + success = ( ( success ) && ( max_nerrors == 0 ) ); + +#else /* H5_METADATA_TRACE_FILE */ + + if ( world_mpi_rank == 0 ) { + + SKIPPED(); + + HDfprintf(stdout, " trace file support disabled.\n"); + } + +#endif /* H5_METADATA_TRACE_FILE */ + + return(success); + +} /* trace_file_check() */ + + +/***************************************************************************** + * * Function: main() * * Purpose: Main function for the parallel cache test. @@ -4890,7 +5598,11 @@ main(int argc, char **argv) H5open(); - if ( (express_test = do_express_test()) ) { + express_test = do_express_test(); +#if 0 /* JRM */ + express_test = 0; +#endif /* JRM */ + if ( express_test ) { virt_num_data_entries = EXPRESS_VIRT_NUM_DATA_ENTRIES; @@ -5030,7 +5742,10 @@ main(int argc, char **argv) #endif #if 1 smoke_check_5(); -#endif +#endif +#if 1 + trace_file_check(); +#endif finish: /* make sure all processes are finished before final report, cleanup -- cgit v0.12