diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2022-03-23 13:48:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 13:48:05 (GMT) |
commit | fbb532cd633e216f47ce846493b38af02cfbb43a (patch) | |
tree | 1ef7bc9f25ec0832f8b25bb8ea4be34d53bd144d /src | |
parent | 78375882485a99a81caa933928ed08d7a38ef88b (diff) | |
download | hdf5-fbb532cd633e216f47ce846493b38af02cfbb43a.zip hdf5-fbb532cd633e216f47ce846493b38af02cfbb43a.tar.gz hdf5-fbb532cd633e216f47ce846493b38af02cfbb43a.tar.bz2 |
VFD SWMR: Normalization with develop (#1506)
* Brought over plugin and test script changes
* Removes remaining register keywords (#1481)
* Fixed warnings in the aux process code
* Minor fixes from develop
* Minor changes from develop, fixed format warnings
* Formatted source
* Added HD prefix to timespec_get
* Cleanup in new files
* Removes the MANIFEST file and unused release files (#1497)
* Removes the MANIFEST file and unused release files
* Updated tar command
* checkposix corrections
* More checkposix fixes
* Ripped out unused instrumentation functionality
* Brought over cache tagging changes from develop
* Changes to tagged metadata expulsion iteration
* Fixed typo
* Brought over H5O__free() changes from develop
* Brings (unused) parallel page buffer test in line with develop
* Moved the functionality in supervise.subr to test_vfd_swmr.sh
* Tools VFD parameter updates
* Committing clang-format changes
* H5F VFD SWMR refactoring
* Committing clang-format changes
* Misc changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src')
46 files changed, 1131 insertions, 1518 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dcb74a9..4ebc8bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -250,7 +250,6 @@ set (H5FD_SOURCES ${HDF5_SRC_DIR}/H5FDstdio.c ${HDF5_SRC_DIR}/H5FDtest.c ${HDF5_SRC_DIR}/H5FDvfd_swmr.c - ${HDF5_SRC_DIR}/H5FDvfd_swmr_instr.c ${HDF5_SRC_DIR}/H5FDwindows.c ) @@ -912,7 +911,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5FDmirror_priv.h ${HDF5_SRC_DIR}/H5FDpkg.h ${HDF5_SRC_DIR}/H5FDprivate.h - ${HDF5_SRC_DIR}/H5FDvfd_swmr_private.h ${HDF5_SRC_DIR}/H5FLprivate.h @@ -1075,20 +1073,23 @@ if (LOCAL_BATCH_TEST) endif () endif () +#### make the H5detect program set (lib_prog_deps) -if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") - add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) - target_include_directories (H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) - TARGET_C_PROPERTIES (H5detect STATIC) - target_link_libraries (H5detect - PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib> - ) - target_compile_options(H5detect - PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>" - ) - set (lib_prog_deps ${lib_prog_deps} H5detect) +add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) +target_include_directories (H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) +TARGET_C_PROPERTIES (H5detect STATIC) +target_link_libraries (H5detect + PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib> +) +target_compile_options(H5detect + PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>" +) +set (lib_prog_deps ${lib_prog_deps} H5detect) +# check if a pregenerated H5Tinit.c file is present +if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") + # execute the H5detect program if (HDF5_BATCH_H5DETECT) configure_file ( ${HDF5_SOURCE_DIR}/bin/batch/${HDF5_BATCH_H5DETECT_SCRIPT}.in.cmake @@ -1096,9 +1097,9 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") ) add_custom_command ( OUTPUT gen_SRCS.stamp1 + BYPRODUCTS H5Tinit.c COMMAND ${HDF5_BATCH_CMD} ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} - BYPRODUCTS H5Tinit.c gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E echo "Executed batch command to create H5Tinit.c" COMMAND ${CMAKE_COMMAND} @@ -1109,31 +1110,30 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") add_custom_target (gen_H5Tinit COMMAND ${CMAKE_COMMAND} -P ${HDF5_SOURCE_DIR}/config/cmake/wait_H5Tinit.cmake ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) else () - add_custom_command (TARGET H5detect POST_BUILD + add_custom_command ( + OUTPUT gen_SRCS.stamp1 + BYPRODUCTS H5Tinit.c COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5detect> ARGS H5Tinit.c - BYPRODUCTS H5Tinit.c gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch gen_SRCS.stamp1 DEPENDS H5detect WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Create H5Tinit.c" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) - add_custom_command (TARGET H5detect POST_BUILD + add_custom_command ( + OUTPUT shared/shared_gen_SRCS.stamp1 + BYPRODUCTS shared/H5Tinit.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c - BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp1 - DEPENDS H5detect H5Tinit.c + DEPENDS H5detect gen_SRCS.stamp1 WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Copy H5Tinit.c to shared folder" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () endif () else () @@ -1149,16 +1149,15 @@ else () if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT shared/shared_gen_SRCS.stamp1 + BYPRODUCTS shared/H5Tinit.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c - BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp1 - DEPENDS H5Tinit.c + DEPENDS H5Tinit.c gen_SRCS.stamp1 WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Copy existing H5Tinit.c to shared folder" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () endif () @@ -1169,6 +1168,7 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_SRC_DETECT_FORMAT ${HDF5_SRC_DIR}/H5detect.c) endif () +# make the H5make_libsettings program add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c) target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) @@ -1188,10 +1188,12 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_SRC_LIBSETTINGS_FORMAT H5make_libsettings) endif () -add_custom_command (TARGET H5make_libsettings POST_BUILD +# execute the H5make_libsettings program +add_custom_command ( + OUTPUT gen_SRCS.stamp2 + BYPRODUCTS H5lib_settings.c COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5make_libsettings> ARGS H5lib_settings.c - BYPRODUCTS H5lib_settings.c gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E touch gen_SRCS.stamp2 DEPENDS H5make_libsettings @@ -1200,17 +1202,17 @@ add_custom_command (TARGET H5make_libsettings POST_BUILD ) set_source_files_properties (${HDF5_SRC_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) - add_custom_command (TARGET H5make_libsettings POST_BUILD + add_custom_command ( + OUTPUT shared/shared_gen_SRCS.stamp2 + BYPRODUCTS shared/H5lib_settings.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5lib_settings.c shared/H5lib_settings.c - BYPRODUCTS shared/H5lib_settings.c shared/shared_gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp2 - DEPENDS H5make_libsettings H5lib_settings.c + DEPENDS H5make_libsettings gen_SRCS.stamp2 WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR} COMMENT "Copy H5lib_settings.c to shared folder" ) - set_source_files_properties (${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE) endif () ## all_packages="AC,B,B2,D,F,FA,FL,FS,HL,I,O,S,ST,T,Z" @@ -1223,7 +1225,7 @@ option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF) if (NOT ONLY_SHARED_LIBS) set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c) add_custom_target (gen_${HDF5_LIB_TARGET} ALL - DEPENDS ${lib_prog_deps} ${gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2 + DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2 COMMENT "Generation target files" ) @@ -1262,7 +1264,7 @@ endif () if (BUILD_SHARED_LIBS) set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c) add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL - DEPENDS ${lib_prog_deps} ${shared_gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 + DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 COMMENT "Shared generation target files" ) @@ -234,7 +234,7 @@ H5AC_cache_image_pending(const H5F_t *f) * Programmer: Robb Matzke * Jul 9 1997 * - * Changes: Added code to configrue the metadata cache for VFD SWMR + * Changes: Added code to configure the metadata cache for VFD SWMR * reader operations when indicated. * * JRM -- 1/15/19 @@ -2452,7 +2452,7 @@ done: /*------------------------------------------------------------------------------ * Function: H5AC_expunge_tag_type_metadata() * - * Purpose: Wrapper for cache level function which expunge entries with + * Purpose: Wrapper for cache level function which expunges entries with * a specific tag and type id. * * Return: SUCCEED on success, FAIL otherwise. @@ -2462,7 +2462,7 @@ done: *------------------------------------------------------------------------------ */ herr_t -H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, hbool_t type_match) +H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags) { /* Variable Declarations */ herr_t ret_value = SUCCEED; @@ -2475,7 +2475,7 @@ H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flag HDassert(f->shared); /* Call cache level function to expunge entries with specified tag and type id */ - if (H5C_expunge_tag_type_metadata(f, tag, type_id, flags, type_match) < 0) + if (H5C_expunge_tag_type_metadata(f, tag, type_id, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot expunge tagged type entries") done: @@ -2483,6 +2483,40 @@ done: } /* H5AC_expunge_tag_type_metadata*/ /*------------------------------------------------------------------------------ + * Function: H5AC_expunge_all_tagged_metadata() + * + * Purpose: Wrapper for cache level function which expunges all tagged + * entries + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Spring 2022 + * + *------------------------------------------------------------------------------ + */ +herr_t +H5AC_expunge_all_tagged_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags) +{ + /* Variable Declarations */ + herr_t ret_value = SUCCEED; + + /* Function Enter Macro */ + FUNC_ENTER_NOAPI(FAIL) + + /* Assertions */ + HDassert(f); + HDassert(f->shared); + + /* Call cache level function to expunge all tagged entries */ + if (H5C_expunge_all_tagged_metadata(f, tag, type_id, flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cannot expunge all entries") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_expunge_all_tagged_metadata*/ + +/*------------------------------------------------------------------------------ * Function: H5AC_get_tag() * * Purpose: Get the tag for a metadata cache entry. diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index ff632d0..758f63d 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -430,8 +430,8 @@ H5_DLL herr_t H5AC_get_entry_ring(const H5F_t *f, haddr_t addr, H5AC_ring_t *rin H5_DLL void H5AC_set_ring(H5AC_ring_t ring, H5AC_ring_t *orig_ring); H5_DLL herr_t H5AC_unsettle_entry_ring(void *entry); H5_DLL herr_t H5AC_unsettle_ring(H5F_t *f, H5AC_ring_t ring); -H5_DLL herr_t H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, - hbool_t type_match); +H5_DLL herr_t H5AC_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags); +H5_DLL herr_t H5AC_expunge_all_tagged_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags); H5_DLL herr_t H5AC_get_tag(const void *thing, /*OUT*/ haddr_t *tag); H5_DLL herr_t H5AC_set_vfd_swmr_reader(H5AC_t *cache_ptr, hbool_t vfd_swmr_reader, hsize_t page_size); @@ -11,9 +11,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* TEMPORARY (during VFD SWMR sync with develop - reduces churn) */ -/* clang-format off */ - /*------------------------------------------------------------------------- * * Created: H5C.c @@ -36,7 +33,7 @@ * * Code Changes: * - * - Remove extra functionality in H5C__flush_single_entry()? + * - Remove extra functionality in H5C__flush_single_entry()? * * - Change protect/unprotect to lock/unlock. * @@ -54,18 +51,18 @@ * the LRU list, eliminating skip list lookups when evicting objects * from the cache. * - * - Create MPI type for dirty objects when flushing in parallel. + * - Create MPI type for dirty objects when flushing in parallel. * - * - Now that TBBT routines aren't used, fix nodes in memory to + * - Now that TBBT routines aren't used, fix nodes in memory to * point directly to the skip list node from the LRU list, eliminating * skip list lookups when evicting objects from the cache. * - * Tests: + * Tests: * - * - Trim execution time. (This is no longer a major issue with the - * shift from the TBBT to a hash table for indexing.) + * - Trim execution time. (This is no longer a major issue with the + * shift from the TBBT to a hash table for indexing.) * - * - Add random tests. + * - Add random tests. * **************************************************************************/ @@ -79,17 +76,18 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5retry_private.h" /* Retry loops. */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ + +#include "H5retry_private.h" /* Retry loops */ /****************/ /* Local Macros */ @@ -1064,12 +1062,6 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, uint32_t lengt HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(cache_ptr->vfd_swmr_reader); -#if 0 /* JRM */ - HDfprintf(stderr, - "H5C_evict_or_refresh_all_entries_in_page() entering. page = %lld\n", - page); -#endif /* JRM */ - /* since file must be opened R/O for a VFD SWMR reader, the skip * list must be empty. Verify this. */ @@ -1117,11 +1109,6 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, uint32_t lengt tag = entry_ptr->tag_info->tag; HDassert(!(entry_ptr->tag_info->corked)); -#if 0 /* JRM */ - HDfprintf(stderr, - "evicting tagged entries addr/page/tag == %lld/%lld/%lld\n", - entry_ptr->addr, entry_ptr->page, tag); -#endif /* JRM */ /* passing TRUE for the match_global parameter. Look * into this and verify that it is the right thing to @@ -1137,10 +1124,7 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, uint32_t lengt follow_ptr = entry_ptr = NULL; } else if (entry_ptr->type->refresh) { -#if 0 /* JRM */ - HDfprintf(stderr, "refreshing addr/page/tag == %lld/%lld\n", - entry_ptr->addr, entry_ptr->page); -#endif /* JRM */ + /* If there is a refresh callback, use it to minimize * overhead. * @@ -1281,19 +1265,6 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, uint32_t lengt * skip list -- thus no need for the * H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG. */ -#if 0 /* JRM */ - if ( entry_ptr->tag_info ) { - - HDfprintf(stderr, - "evicting entry addr/page/tag == %lld/%lld/%lld\n", - entry_ptr->addr, entry_ptr->page, - entry_ptr->tag_info->tag); - } else { - HDfprintf(stderr, - "evicting entry addr/page == %lld/%lld no tag\n", - entry_ptr->addr, entry_ptr->page); - } -#endif /* JRM */ if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't evict unpinned entry") @@ -1348,10 +1319,7 @@ H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, uint32_t lengt entry_ptr = (cache_ptr->page_index)[i]; while (entry_ptr) { - HDassert((entry_ptr->page != page) || (entry_ptr->refreshed_in_tick == tick)); - ; - entry_ptr = entry_ptr->pi_next; } @@ -1703,7 +1671,7 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - /* if this is a VFD SWMR reader, verify that the page size is defined */ + /* If this is a VFD SWMR reader, verify that the page size is defined */ HDassert((!cache_ptr->vfd_swmr_reader) || (cache_ptr->page_size > 0)); HDassert(type); @@ -1831,14 +1799,10 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u entry_ptr->tag_info = NULL; /* initialize fields supporting VFD SWMR */ - if (cache_ptr->vfd_swmr_reader) { - + if (cache_ptr->vfd_swmr_reader) entry_ptr->page = (addr / cache_ptr->page_size); - } - else { - + else entry_ptr->page = 0; - } entry_ptr->refreshed_in_tick = 0; entry_ptr->pi_next = NULL; entry_ptr->pi_prev = NULL; @@ -2281,7 +2245,7 @@ H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, hadd HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - /* if this is a VFD SWMR reader, verify that the page size is defined */ + /* If this is a VFD SWMR reader, verify that the page size is defined */ HDassert((!cache_ptr->vfd_swmr_reader) || (cache_ptr->page_size > 0)); HDassert(type); @@ -2346,13 +2310,11 @@ H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, hadd entry_ptr->addr = new_addr; - /* update the page in which the entry resides if the file is opened - * as a VFD SWMR reader. + /* Update the page in which the entry resides if the file is opened + * as a VFD SWMR reader */ - if (cache_ptr->vfd_swmr_reader) { - + if (cache_ptr->vfd_swmr_reader) entry_ptr->page = (new_addr / cache_ptr->page_size); - } if (!entry_ptr->destroy_in_progress) { hbool_t was_dirty; /* Whether the entry was previously dirty */ @@ -2806,15 +2768,16 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign #endif /* H5_HAVE_PARALLEL */ type, addr, udata))) { /* Print out meaningful message for VFD SWMR reader */ - if(f->shared->vfd_swmr && !f->shared->vfd_swmr_writer) { - uint64_t tmp_tick_num = 0; + if (f->shared->vfd_swmr && !f->shared->vfd_swmr_writer) { + uint64_t tmp_tick_num = 0; if (H5FD_vfd_swmr_get_tick_and_idx(f->shared->lf, TRUE, &tmp_tick_num, NULL, NULL) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, NULL, "error in retrieving tick_num from driver"); if (tmp_tick_num >= f->shared->tick_num + f->shared->vfd_swmr_config.max_lag) - HDONE_ERROR(H5E_FILE, H5E_SYSTEM, NULL, - "Reader's API time exceeds max_lag ticks, suggest to increase the value of max_lag."); + HDONE_ERROR( + H5E_FILE, H5E_SYSTEM, NULL, + "Reader's API time exceeds max_lag ticks, suggest to increase the value of max_lag."); } HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't load entry") @@ -3520,7 +3483,7 @@ done: * Programmer: John Mainzer * 1/15/19 * - * Changes: None. + * Changes: None * *------------------------------------------------------------------------- */ @@ -6817,12 +6780,6 @@ done: * be cleared and not flushed, and the call can't be part of a * sequence of flushes. * - * If the caller knows the address of the skip list node at - * which the target entry resides, it can avoid a lookup - * by supplying that address in the tgt_node_ptr parameter. - * If this parameter is NULL, the function will do a skip list - * search for the entry instead. - * * The function does nothing silently if there is no entry * at the supplied address, or if the entry found has the * wrong type. @@ -7134,7 +7091,8 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) H5C__SET_PB_WRITE_HINTS(cache_ptr, entry_ptr->type) - if (H5F_block_write(f, mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < 0) { + if (H5F_block_write(f, mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < + 0) { H5C__RESET_PB_WRITE_HINTS(cache_ptr) @@ -7488,7 +7446,7 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) */ /* VFD SWMR TODO: Think on this, and decide if we need to extend - * this for multi page metadata entries. + * this for multi-page metadata entries. */ if (update_page_buffer) { @@ -7601,10 +7559,7 @@ done: * * Programmer: John Mainzer, 5/18/04 * - * Changes: Please maintain the change list and do not delete entries - * unless the have been folded into the header comment. - * - * Reverted optimization that avoided re-reading the prefix + * Changes: Reverted optimization that avoided re-reading the prefix * of a metadata entry when a speculative read proved too * small. * JRM -- 3/25/20 @@ -7664,10 +7619,6 @@ H5C__load_entry(H5F_t *f, HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image size") HDassert(len > 0); -#if 0 -init_len = len; -#endif - /* Check for possible speculative read off the end of the file */ if (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) if (H5C__verify_len_eoa(f, type, addr, &len, FALSE) < 0) @@ -7708,8 +7659,8 @@ init_len = len; * --determine the actual size of the metadata * --perform checksum verification */ - for (do_try = h5_retry_init(&retry, H5F_GET_READ_ATTEMPTS(f), 1, H5_RETRY_ONE_HOUR / 3600 / 100); - do_try; do_try = h5_retry_next(&retry)) { + for (do_try = H5_retry_init(&retry, H5F_GET_READ_ATTEMPTS(f), 1, H5_RETRY_ONE_HOUR / 3600 / 100); + do_try; do_try = H5_retry_next(&retry)) { if (actual_len != len) { if (NULL == (new_image = H5MM_realloc(image, len + H5C_IMAGE_EXTRA_SPACE))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") @@ -7776,61 +7727,50 @@ init_len = len; #ifdef H5_HAVE_PARALLEL if (!coll_access || 0 == mpi_rank) { #endif /* H5_HAVE_PARALLEL */ -#if 0 /* JRM */ - /* If the thing's image needs to be bigger for - * a speculatively loaded thing, go get the - * on-disk image again (the extra portion). - */ - if ( H5F_block_read(f, type->mem_type, addr + len, - actual_len - len, image + len) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \ - "can't read image") -#else /* JRM */ + /* the original version of this code re-read + * the entire buffer. At some point, someone + * reworked this code to avoid re-reading the + * initial portion of the buffer. + * + * In addition to being of questionable utility, + * this optimization changed the invariant that + * that metadata is read and written atomically. + * While this didn't cause immediate problems, + * the page buffer in VFD SWMR depends on this + * invariant in its management of multi-page + * metadata entries. + * + * To repair this issue, I have reverted to + * the original algorithm for managing the + * speculative load case. Note that I have + * done so crudely -- before merge, we should + * remove the infrastructure that supports the + * optimization. + * + * We should also verify my impression that the + * that the optimization is of no measurable + * value. If it is, we will put it back, but + * disable it in the VFD SWMR case. + * + * While this issue was detected in the global + * heap case, note that the super block, the + * local heap, and the fractal heap also use + * speculative loads. + * + * JRM -- 3/24/20 + */ - /* the original version of this code re-read - * the entire buffer. At some point, someone - * reworked this code to avoid re-reading the - * initial portion of the buffer. - * - * In addition to being of questionable utility, - * this optimization changed the invariant that - * that metadata is read and written atomically. - * While this didn't cause immediate problems, - * the page buffer in VFD SWMR depends on this - * invariant in its management of multi-page - * metadata entries. - * - * To repair this issue, I have reverted to - * the original algorithm for managing the - * speculative load case. Note that I have - * done so crudely -- before merge, we should - * remove the infrastructure that supports the - * optimization. - * - * We should also verify my impression that the - * that the optimization is of no measurable - * value. If it is, we will put it back, but - * disable it in the VFD SWMR case. - * - * While this issue was detected in the global - * heap case, note that the super block, the - * local heap, and the fractal heap also use - * speculative loads. - * - * JRM -- 3/24/20 - */ + H5C__SET_PB_READ_HINTS(f->shared->cache, type, FALSE); - H5C__SET_PB_READ_HINTS(f->shared->cache, type, FALSE); + if (H5F_block_read(f, type->mem_type, addr, actual_len, image) < 0) { - if (H5F_block_read(f, type->mem_type, addr, actual_len, image) < 0) { + H5C__RESET_PB_READ_HINTS(f->shared->cache) - H5C__RESET_PB_READ_HINTS(f->shared->cache) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") + } + H5C__RESET_PB_READ_HINTS(f->shared->cache) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") - } - H5C__RESET_PB_READ_HINTS(f->shared->cache) -#endif /* JRM */ #ifdef H5_HAVE_PARALLEL } /* If the collective metadata read optimization is turned on, @@ -7870,34 +7810,15 @@ init_len = len; } /* Check for too many tries */ - if (!do_try) { -#if 0 /* JRM */ - haddr_t eoa; - int64_t page = (int64_t)(addr / f->shared->cache->page_size); - - eoa = H5F_get_eoa(f, type->mem_type); - - HDfprintf(stderr, "addr = 0x%llx, init_len = %lld, len = %lld\n", - (int64_t)addr, (int64_t)init_len, (int64_t)len); - HDfprintf(stderr, "type = %s, eoa = 0x%llx, tick = %lld\n", - type->name, (int64_t)eoa, f->shared->tick_num); - HDfprintf(stderr, "page = %lld, index_len = %d\n", - page, f->shared->mdf_idx_entries_used); - H5FD_vfd_swmr_dump_status(f->shared->lf, page); -#endif /* JRM */ + if (!do_try) HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, - "incorrect metadata checksum after all read attempts addr %" PRIuHADDR - " size %zu", - addr, len); - } - - /* Calculate and track the # of retries */ - if ((tries = h5_retry_tries(&retry)) > 1) { /* Does not track 0 retry */ - - if (H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, tries - 1) < 0) + "incorrect metadata checksum after all read attempts addr %" PRIuHADDR " size %zu", + addr, len) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "cannot track read tries = %u ", tries) - } + /* Calculate and track the # of retries (does not track 0 retries) */ + if ((tries = H5_retry_tries(&retry)) > 1) + if (H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, tries - 1) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "cannot track read tries = %u ", tries) /* Set the final length (in case it wasn't set earlier) */ len = actual_len; @@ -8004,14 +7925,10 @@ init_len = len; entry->tag_info = NULL; /* initialize fields supporting VFD SWMR */ - if (f->shared->cache->vfd_swmr_reader) { - + if (f->shared->cache->vfd_swmr_reader) entry->page = (addr / f->shared->cache->page_size); - } - else { - + else entry->page = 0; - } entry->refreshed_in_tick = 0; entry->pi_next = NULL; entry->pi_prev = NULL; @@ -8352,10 +8269,8 @@ done: * * Programmer: John Mainzer, 7/14/05 * - * Changes: - * - * Added code to verify that the LRU contains no pinned - * entries. JRM -- 4/25/14 + * Changes: Added code to verify that the LRU contains no pinned + * entries. JRM -- 4/25/14 * *------------------------------------------------------------------------- */ @@ -8434,9 +8349,7 @@ done: * * Programmer: John Mainzer, 4/25/14 * - * Changes: - * - * None. + * Changes: None * *------------------------------------------------------------------------- */ @@ -8518,9 +8431,7 @@ done: * * Programmer: John Mainzer, 4/25/14 * - * Changes: - * - * None. + * Changes: None * *------------------------------------------------------------------------- */ @@ -8600,9 +8511,7 @@ done: * * Programmer: John Mainzer, 11/1/14 * - * Changes: - * - * None. + * Changes: None * *------------------------------------------------------------------------- */ @@ -9716,10 +9625,8 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) entry_ptr->addr = new_addr; /* In the VFD SWMR reader case, update the entry page field */ - if (cache_ptr->vfd_swmr_reader) { - + if (cache_ptr->vfd_swmr_reader) entry_ptr->page = (new_addr / cache_ptr->page_size); - } /* And then reinsert in the index and slist */ H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); @@ -9898,6 +9805,3 @@ H5C_remove_entry(void *_entry) done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__remove_entry() */ - -/* TEMPORARY (during VFD SWMR sync with develop - reduces churn) */ -/* clang-format on */ diff --git a/src/H5Cimage.c b/src/H5Cimage.c index bdfba08..bec337b 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -862,53 +862,6 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) } /* H5C__free_image_entries_array() */ /*------------------------------------------------------------------------- - * Function: H5C_force_cache_image_load() - * - * Purpose: On rare occasions, it is necessary to run - * H5MF_tidy_self_referential_fsm_hack() prior to the first - * metadata cache access. This is a problem as if there is a - * cache image at the end of the file, that routine will - * discard it. - * - * We solve this issue by calling this function, which will - * load the cache image and then call - * H5MF_tidy_self_referential_fsm_hack() to discard it. - * - * Return: SUCCEED on success, and FAIL on failure. - * - * Programmer: John Mainzer - * 1/11/17 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_force_cache_image_load(H5F_t *f) -{ - H5C_t *cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(f); - HDassert(f->shared); - cache_ptr = f->shared->cache; - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->load_image); - - /* Load the cache image, if requested */ - if (cache_ptr->load_image) { - cache_ptr->load_image = FALSE; - if (H5C__load_cache_image(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "can't load cache image") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_force_cache_image_load() */ - -/*------------------------------------------------------------------------- * Function: H5C_get_cache_image_config * * Purpose: Copy the current configuration for cache image generation diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index dd286a9..405d03a 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -53,7 +53,7 @@ /* Cache configuration settings */ #define H5C__HASH_TABLE_LEN (64 * 1024) /* must be a power of 2 */ -#define H5C__PAGE_HASH_TABLE_LEN (4 * 1024) /* must be a poser of 2 */ +#define H5C__PAGE_HASH_TABLE_LEN (4 * 1024) /* must be a power of 2 */ #define H5C__H5C_T_MAGIC 0x005CAC0E /* Initial allocated size of the "flush_dep_parent" array */ @@ -1235,7 +1235,7 @@ if ( ( (cache_ptr) == NULL ) || \ ( ( !((entry_ptr)->is_dirty ) || \ ( (cache_ptr)->dirty_index_size < (new_size) ) ) && \ ( ( ((entry_ptr)->is_dirty) ) || \ - ( (cache_ptr)->clean_index_size < (new_size) ) ) ) || \ + ( (cache_ptr)->clean_index_size < (new_size) ) ) ) || \ ( ( (cache_ptr)->index_len == 1 ) && \ ( (cache_ptr)->index_size != (new_size) ) ) || \ ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ @@ -1510,10 +1510,10 @@ if ( ( (cache_ptr)->index_size != \ H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ + -= (entry_ptr)->size; \ (cache_ptr)->clean_index_size += (entry_ptr)->size; \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ + += (entry_ptr)->size; \ H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ } @@ -1522,18 +1522,18 @@ if ( ( (cache_ptr)->index_size != \ H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ + -= (entry_ptr)->size; \ (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ + += (entry_ptr)->size; \ H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ } #define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ + entry_ptr, was_clean) \ { \ H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ + entry_ptr, was_clean) \ (cache_ptr)->index_size -= (old_size); \ (cache_ptr)->index_size += (new_size); \ ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (old_size); \ @@ -1542,14 +1542,14 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->clean_index_size -= (old_size); \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])-= (old_size); \ } else { \ - (cache_ptr)->dirty_index_size -= (old_size); \ + (cache_ptr)->dirty_index_size -= (old_size); \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])-= (old_size); \ } \ if((entry_ptr)->is_dirty) { \ (cache_ptr)->dirty_index_size += (new_size); \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])+= (new_size); \ } else { \ - (cache_ptr)->clean_index_size += (new_size); \ + (cache_ptr)->clean_index_size += (new_size); \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])+= (new_size); \ } \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->il_len, \ @@ -1836,7 +1836,7 @@ if ( ( (cache_ptr)->index_size != \ } else { /* slist disabled */ \ \ HDassert( (cache_ptr)->slist_len == 0 ); \ - HDassert( (cache_ptr)->slist_size == 0 ); \ + HDassert( (cache_ptr)->slist_size == 0 ); \ } \ } /* H5C__REMOVE_ENTRY_FROM_SLIST */ @@ -2078,16 +2078,16 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head.\ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* Use the dirty flag to infer whether the entry is on the clean or \ @@ -2141,16 +2141,16 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head \ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2333,28 +2333,28 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ + * head. \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* since the entry is being flushed or cleared, one would think \ - * that it must be dirty -- but that need not be the case. Use the \ - * dirty flag to infer whether the entry is on the clean or dirty \ - * LRU list, and remove it. Then insert it at the head of the \ - * clean LRU list. \ + * that it must be dirty -- but that need not be the case. Use the \ + * dirty flag to infer whether the entry is on the clean or dirty \ + * LRU list, and remove it. Then insert it at the head of the \ + * clean LRU list. \ * \ * The function presumes that a dirty entry will be either cleared \ - * or flushed shortly, so it is OK if we put a dirty entry on the \ - * clean LRU list. \ + * or flushed shortly, so it is OK if we put a dirty entry on the \ + * clean LRU list. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ @@ -2395,17 +2395,17 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ + * head. \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2469,7 +2469,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* insert the entry at the tail of the clean or dirty LRU list as \ @@ -2510,7 +2510,7 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->pel_tail_ptr, \ (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ - \ + \ } else { \ \ /* modified LRU specific code */ \ @@ -2519,7 +2519,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2603,7 +2603,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* insert the entry at the head of the clean or dirty LRU list as \ @@ -2644,7 +2644,7 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->pel_tail_ptr, \ (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ - \ + \ } else { \ \ /* modified LRU specific code */ \ @@ -2653,7 +2653,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2722,12 +2722,12 @@ if ( ( (cache_ptr)->index_size != \ HDassert( !((entry_ptr)->is_read_only) ); \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ - \ + \ if ( (entry_ptr)->is_pinned ) { \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ \ } else { \ @@ -2738,7 +2738,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* Similarly, remove the entry from the clean or dirty LRU list \ @@ -2784,12 +2784,12 @@ if ( ( (cache_ptr)->index_size != \ HDassert( !((entry_ptr)->is_read_only) ); \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ - \ + \ if ( (entry_ptr)->is_pinned ) { \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ \ } else { \ @@ -2800,7 +2800,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2849,21 +2849,21 @@ if ( ( (cache_ptr)->index_size != \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ - \ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) {\ + \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* remove the entry from either the clean or dirty LUR list as \ @@ -2872,7 +2872,7 @@ if ( ( (cache_ptr)->index_size != \ if ( was_dirty ) { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, \ @@ -2881,34 +2881,34 @@ if ( ( (cache_ptr)->index_size != \ } else { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ + (fail_val)) \ } \ \ /* insert the entry at the head of either the clean or dirty \ - * LRU list as appropriate. \ + * LRU list as appropriate. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ + (fail_val)) \ \ } else { \ \ H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ + (fail_val)) \ } \ \ /* End modified LRU specific code. */ \ @@ -2917,7 +2917,7 @@ if ( ( (cache_ptr)->index_size != \ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ +#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ @@ -2926,21 +2926,21 @@ if ( ( (cache_ptr)->index_size != \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ - \ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) {\ + \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2997,49 +2997,49 @@ if ( ( (cache_ptr)->index_size != \ \ if ( (entry_ptr)->coll_access ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, \ + (cache_ptr)->coll_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ } \ \ if ( (entry_ptr)->is_pinned ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ } else { \ \ /* modified LRU specific code */ \ \ - /* Update the size of the LRU list */ \ + /* Update the size of the LRU list */ \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ /* Similarly, update the size of the clean or dirty LRU list as \ - * appropriate. At present, the entry must be clean, but that \ - * could change. \ + * appropriate. At present, the entry must be clean, but that \ + * could change. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ } else { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ } \ \ /* End modified LRU specific code. */ \ @@ -3062,21 +3062,21 @@ if ( ( (cache_ptr)->index_size != \ \ if ( (entry_ptr)->is_pinned ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ } else { \ \ /* modified LRU specific code */ \ \ - /* Update the size of the LRU list */ \ + /* Update the size of the LRU list */ \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ /* End modified LRU specific code. */ \ } \ @@ -3363,7 +3363,7 @@ if ( ( (hd_ptr) == NULL ) || \ ( (Size) < (entry_ptr)->size ) || \ ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ ( ( (entry_ptr)->coll_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->coll_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ + ( ( (entry_ptr)->coll_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) ||\ ( ( (len) == 1 ) && \ ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ ( (entry_ptr)->coll_next == NULL ) && \ @@ -3395,10 +3395,10 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ) \ ) { \ HDassert(0 && "COLL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed")\ } -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv)\ if ( ( (entry_ptr) == NULL ) || \ ( (entry_ptr)->coll_next != NULL ) || \ ( (entry_ptr)->coll_prev != NULL ) || \ diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 524a276..dad5029 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -2370,10 +2370,9 @@ H5_DLL herr_t H5C_evict_or_refresh_all_entries_in_page(H5F_t *f, uint64_t page, H5_DLL herr_t H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flags); H5_DLL herr_t H5C_flush_cache(H5F_t *f, unsigned flags); H5_DLL herr_t H5C_flush_tagged_entries(H5F_t *f, haddr_t tag); -H5_DLL herr_t H5C_force_cache_image_load(H5F_t *f); H5_DLL herr_t H5C_evict_tagged_entries(H5F_t *f, haddr_t tag, hbool_t match_global); -H5_DLL herr_t H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, - hbool_t type_match); +H5_DLL herr_t H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags); +H5_DLL herr_t H5C_expunge_all_tagged_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags); H5_DLL herr_t H5C_get_tag(const void *thing, /*OUT*/ haddr_t *tag); #if H5C_DO_TAGGING_SANITY_CHECKS herr_t H5C_verify_tag(int id, haddr_t tag); diff --git a/src/H5Ctag.c b/src/H5Ctag.c index a3f04e8..2095cf8 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -72,7 +72,6 @@ typedef struct { H5F_t * f; /* File pointer for evicting entry */ int type_id; /* Cache entry type to expunge */ unsigned flags; /* Flags for expunging entry */ - hbool_t type_match; } H5C_tag_iter_ettm_ctx_t; /* Typedef for tagged entry iterator callback context - mark corked */ @@ -818,7 +817,7 @@ H5C__expunge_tag_type_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) HDassert(ctx); /* Found one with the same tag and type id */ - if (entry->type->id == ctx->type_id || !ctx->type_match) + if (entry->type->id == ctx->type_id) if (H5C_expunge_entry(ctx->f, entry->type, entry->addr, ctx->flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, H5_ITER_ERROR, "can't expunge entry") @@ -841,7 +840,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags, hbool_t type_match) +H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags) { H5C_t * cache; /* Pointer to cache structure */ H5C_tag_iter_ettm_ctx_t ctx; /* Context for iterator callback */ @@ -858,10 +857,9 @@ H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Construct context for iterator callbacks */ - ctx.f = f; - ctx.type_id = type_id; - ctx.flags = flags; - ctx.type_match = type_match; + ctx.f = f; + ctx.type_id = type_id; + ctx.flags = flags; /* Iterate through hash table entries, expunge those with specified tag and type id */ if (H5C__iter_tagged_entries(cache, tag, FALSE, H5C__expunge_tag_type_metadata_cb, &ctx) < 0) @@ -873,6 +871,82 @@ done: /*------------------------------------------------------------------------- * + * Function: H5C__expunge_all_tagged_metadata_cb + * + * Purpose: Callback for expunging all tagged cache entries + * + * Return: H5_ITER_ERROR if error is detected, H5_ITER_CONT otherwise. + * + * Programmer: Dana Robinson + * Spring 2022 + * + *------------------------------------------------------------------------- + */ +static int +H5C__expunge_all_tagged_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) +{ + H5C_tag_iter_ettm_ctx_t *ctx = (H5C_tag_iter_ettm_ctx_t *)_ctx; /* Get pointer to iterator context */ + int ret_value = H5_ITER_CONT; /* Return value */ + + /* Function enter macro */ + FUNC_ENTER_STATIC + + /* Santify checks */ + HDassert(entry); + HDassert(ctx); + + if (H5C_expunge_entry(ctx->f, entry->type, entry->addr, ctx->flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, H5_ITER_ERROR, "can't expunge entry") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__expunge_all_tagged_metadata_cb() */ + +/*------------------------------------------------------------------------- + * + * Function: H5C_expunge_all_tagged_metadata + * + * Purpose: Expunge all cache entries + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Spring 2022 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_expunge_all_tagged_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags) +{ + H5C_t * cache; /* Pointer to cache structure */ + H5C_tag_iter_ettm_ctx_t ctx; /* Context for iterator callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Function enter macro */ + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + cache = f->shared->cache; /* Get cache pointer */ + HDassert(cache != NULL); + HDassert(cache->magic == H5C__H5C_T_MAGIC); + + /* Construct context for iterator callbacks */ + ctx.f = f; + ctx.type_id = type_id; + ctx.flags = flags; + + /* Iterate through all tagged entries, expunging them */ + if (H5C__iter_tagged_entries(cache, tag, FALSE, H5C__expunge_all_tagged_metadata_cb, &ctx) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iterated expunging of tagged entries failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_expunge_all_tagged_metadata() */ + +/*------------------------------------------------------------------------- + * * Function: H5C_get_tag() * * Purpose: Get the tag for a metadata cache entry. diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 9078877..35916d2 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -2874,20 +2874,29 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_term() */ -/* Close the given dataset's chunk index, or destroy it if `destroy` - * is true. A closed index merely releases holds on metadata cache - * entries; the index can be reopened. Once a dataset's index is - * destroyed, however, the dataset must not try to use the index, again. +/*------------------------------------------------------------------------- + * Function: H5D__chunk_index_close + * + * Purpose: Close the given dataset's chunk index, or destroy it if + * `destroy` is true. A closed index merely releases holds + * on metadata cache entries; the index can be reopened. Once + * a dataset's index is + * destroyed, however, the dataset must not try to use the + * index, again. + * + * A useful side-effect of closing the chunk index is the + * release of pinned/tagged metadata cache entries connected + * with the index. * - * A useful side-effect of closing the chunk index is the release - * pinned/tagged metadata cache entries connected with the index. + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- */ static herr_t H5D__chunk_index_close(const H5D_t *dset, bool destroy) { H5D_chk_idx_info_t idx_info; H5O_storage_chunk_t * sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; H5D_chunk_close_func_t fn; FUNC_ENTER_STATIC diff --git a/src/H5Dint.c b/src/H5Dint.c index 15092f3..cc17265 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -3374,7 +3374,7 @@ done: /* Expunge from cache all v1 B-tree type entries associated with tag */ if (H5AC_expunge_tag_type_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_BT_ID, - H5AC__NO_FLAGS_SET, TRUE)) + H5AC__NO_FLAGS_SET)) HDONE_ERROR(H5E_DATASET, H5E_CANTEXPUNGE, FAIL, "unable to expunge index metadata") } /* end if */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 527fc7b..8577001 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -446,7 +446,7 @@ static FILE * debug_stream = NULL; do { \ if (debug_stream && H5D_MPIO_DEBUG_THIS_RANK(rank)) { \ HDfprintf(debug_stream, "%*s(Rank %d) " string "\n", debug_indent, "", rank); \ - fflush(debug_stream); \ + HDfflush(debug_stream); \ } \ } while (0) @@ -455,7 +455,7 @@ static FILE * debug_stream = NULL; do { \ if (debug_stream && H5D_MPIO_DEBUG_THIS_RANK(rank)) { \ HDfprintf(debug_stream, "%*s(Rank %d) " string "\n", debug_indent, "", rank, __VA_ARGS__); \ - fflush(debug_stream); \ + HDfflush(debug_stream); \ } \ } while (0) @@ -465,7 +465,7 @@ static FILE * debug_stream = NULL; \ if (trace_flag) { \ H5D_MPIO_DEBUG_VA(rank, "%s%s", trace_in_pre, __func__); \ - debug_indent += (int)strlen(trace_in_pre); \ + debug_indent += (int)HDstrlen(trace_in_pre); \ } \ } while (0) @@ -474,7 +474,7 @@ static FILE * debug_stream = NULL; hbool_t trace_flag = H5D_mpio_debug_flags_s[(int)'t']; \ \ if (trace_flag) { \ - debug_indent -= (int)strlen(trace_out_pre); \ + debug_indent -= (int)HDstrlen(trace_out_pre); \ H5D_MPIO_DEBUG_VA(rank, "%s%s", trace_out_pre, __func__); \ } \ } while (0) @@ -1141,8 +1141,8 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HGOTO_ERROR(H5E_IO, H5E_OPENERROR, FAIL, "couldn't open debugging log file") /* Print a short header for this I/O operation */ - time_now = time(NULL); - HDfprintf(debug_log_file, "##### %s", asctime(localtime(&time_now))); + time_now = HDtime(NULL); + HDfprintf(debug_log_file, "##### %s", HDasctime(HDlocaltime(&time_now))); debug_stream = debug_log_file; } @@ -2809,7 +2809,7 @@ H5Fvfd_swmr_end_tick(hid_t file_id) if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Check on this when go parallel for VFD SWMR */ + /* TODO: Revisit this when VFD SWMR + parallel works */ /* Set up collective metadata if appropriate */ if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") @@ -2848,7 +2848,7 @@ H5Fvfd_swmr_disable_end_of_tick(hid_t file_id) if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Check on this when go parallel for VFD SWMR */ + /* TODO: Revisit this when VFD SWMR + parallel works */ /* Set up collective metadata if appropriate */ if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") @@ -2886,7 +2886,7 @@ H5Fvfd_swmr_enable_end_of_tick(hid_t file_id) if (NULL == vol_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Check on this when go parallel for VFD SWMR */ + /* TODO: Revisit this when VFD SWMR + parallel works */ /* Set up collective metadata if appropriate */ if (H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") @@ -970,7 +970,7 @@ H5FD_close(H5FD_t *file) { const H5FD_class_t *driver; H5FD_wrap_t * item; - H5FD_wrap_t * delete_me = NULL; + H5FD_wrap_t * temp = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -989,11 +989,12 @@ H5FD_close(H5FD_t *file) if (item->file->exc_owner == file) item->file->exc_owner = NULL; if (item->file == file) - delete_me = item; + temp = item; } - HDassert(delete_me); - TAILQ_REMOVE(&all_vfds, delete_me, link); - H5MM_xfree(delete_me); + + HDassert(temp); + TAILQ_REMOVE(&all_vfds, temp, link); + H5MM_xfree(temp); /* Dispatch to the driver for actual close. If the driver fails to * close the file then the file will be in an unusable state. @@ -1056,9 +1057,10 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { int ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI_NOERR /* return value is arbitrary */ + FUNC_ENTER_NOAPI_NOERR; /* return value is arbitrary */ - if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HGOTO_DONE(0) + if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) + HGOTO_DONE(0) if (!f1 || !f1->cls) HGOTO_DONE(-1) if (!f2 || !f2->cls) diff --git a/src/H5FDdevelop.h b/src/H5FDdevelop.h index fd62ad7..32cd36f 100644 --- a/src/H5FDdevelop.h +++ b/src/H5FDdevelop.h @@ -227,6 +227,9 @@ struct H5FD_t { hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */ }; +/* VFD initialization function */ +typedef hid_t (*H5FD_init_t)(void); + /********************/ /* Public Variables */ /********************/ @@ -239,7 +242,7 @@ struct H5FD_t { extern "C" { #endif -H5_DLL hid_t H5FDperform_init(hid_t (*)(void)); +H5_DLL hid_t H5FDperform_init(H5FD_init_t op); H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); H5_DLL htri_t H5FDis_driver_registered_by_name(const char *driver_name); H5_DLL htri_t H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value); diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 4e54197..3f0080e 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -233,20 +233,20 @@ H5FD__family_get_default_printf_filename(const char *old_filename) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "can't allocate new filename buffer") /* Determine if filename contains a ".h5" extension. */ - if ((file_extension = strstr(old_filename, ".h5"))) { + if ((file_extension = HDstrstr(old_filename, ".h5"))) { /* Insert the printf format between the filename and ".h5" extension. */ HDstrcpy(tmp_buffer, old_filename); - file_extension = strstr(tmp_buffer, ".h5"); + file_extension = HDstrstr(tmp_buffer, ".h5"); HDsprintf(file_extension, "%s%s", suffix, ".h5"); } - else if ((file_extension = strrchr(old_filename, '.'))) { + else if ((file_extension = HDstrrchr(old_filename, '.'))) { char *new_extension_loc = NULL; /* If the filename doesn't contain a ".h5" extension, but contains * AN extension, just insert the printf format before that extension. */ HDstrcpy(tmp_buffer, old_filename); - new_extension_loc = strrchr(tmp_buffer, '.'); + new_extension_loc = HDstrrchr(tmp_buffer, '.'); HDsprintf(new_extension_loc, "%s%s", suffix, file_extension); } else { diff --git a/src/H5FDint.c b/src/H5FDint.c index d09801f..b1b48c9 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -182,26 +182,6 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /* HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ -#if 0 /* JRM */ - /* If the file is open for SWMR read access, allow access to data past - * the end of the allocated space (the 'eoa'). This is done because the - * eoa stored in the file's superblock might be out of sync with the - * objects being written within the file by the application performing - * SWMR write operations. - */ - if (!(file->access_flags & H5F_ACC_SWMR_READ)) { - haddr_t eoa; - - if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") - - if ((addr + file->base_addr + size) > eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", - (unsigned long long)(addr + file->base_addr), (unsigned long long)size, - (unsigned long long)eoa) - } -#endif /* JRM */ - /* Dispatch to driver */ if ((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") diff --git a/src/H5FDperform.c b/src/H5FDperform.c index 096fdd6..4a68c6e 100644 --- a/src/H5FDperform.c +++ b/src/H5FDperform.c @@ -29,13 +29,14 @@ * Function: H5FDperform_init * * Purpose: Ensure that the library is initialized and then call - * the provided VFD initializer. + * the provided VFD initializer * - * Return: Success: identifier for the VFD just initialized + * Return: Success: Identifier for the VFD just initialized * Failure: H5I_INVALID_HID *------------------------------------------------------------------------- */ -hid_t H5FDperform_init(hid_t (*init)(void)) +hid_t +H5FDperform_init(H5FD_init_t op) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -43,16 +44,16 @@ hid_t H5FDperform_init(hid_t (*init)(void)) /*NO TRACE*/ /* It is possible that an application will evaluate an - * `H5FD_*` symbol (`H5FD_FAMILY`, `H5FD_MULTI`, `H5FD_SEC2`, et - * cetera) before the library has had an opportunity to initialize. - * Call H5_init_library() to make sure that the library has been - * initialized before `init` is run. + * `H5FD_*` symbol (`H5FD_FAMILY`, `H5FD_MULTI`, `H5FD_SEC2`, etc. + * before the library has had an opportunity to initialize. Call + * H5_init_library() to make sure that the library has been initialized + * before `init` is run. */ - if (H5_init_library() < 0) { + if (H5_init_library() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, H5I_INVALID_HID, "library initialization failed") - } - ret_value = init(); + ret_value = op(); + done: FUNC_LEAVE_API_NOINIT(ret_value) } diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 4ba7060..fa51574 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -220,8 +220,8 @@ typedef struct H5FD_vfd_swmr_md_header { * is false. */ static inline H5FD_vfd_swmr_idx_entry_t * -vfd_swmr_pageno_to_mdf_idx_entry(H5FD_vfd_swmr_idx_entry_t *idx, uint32_t nentries, uint64_t target_page, - bool reuse_garbage) +H5FD_vfd_swmr_pageno_to_mdf_idx_entry(H5FD_vfd_swmr_idx_entry_t *idx, uint32_t nentries, uint64_t target_page, + bool reuse_garbage) { uint32_t top; uint32_t bottom; @@ -336,7 +336,7 @@ H5_DLL htri_t H5FD_is_driver_registered_by_value(H5FD_class_value_t driver_value H5_DLL hid_t H5FD_get_driver_id_by_name(const char *name, hbool_t is_api); H5_DLL hid_t H5FD_get_driver_id_by_value(H5FD_class_value_t value, hbool_t is_api); H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -H5FD_t * H5FD_deduplicate(H5FD_t *, hid_t); +H5FD_t * H5FD_deduplicate(H5FD_t *file, hid_t fapl_id); H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); H5_DLL herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/); @@ -368,14 +368,13 @@ H5_DLL haddr_t H5FD_get_base_addr(const H5FD_t *file); H5_DLL herr_t H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged); H5_DLL herr_t H5FD_init(void); + /* Function prototypes for VFD SWMR */ -H5_DLL int shadow_image_defer_free(struct H5F_shared_t *, const H5FD_vfd_swmr_idx_entry_t *); H5_DLL herr_t H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t read_index, uint64_t *tick_ptr, uint32_t *num_entries_ptr, H5FD_vfd_swmr_idx_entry_t index[]); -H5_DLL H5FD_vfd_swmr_idx_entry_t *vfd_swmr_enlarge_shadow_index(struct H5F_t *); -H5_DLL void H5FD_vfd_swmr_dump_status(H5FD_t *, uint64_t); -H5_DLL void H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file); -H5_DLL void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *, uint64_t); +H5_DLL void H5FD_vfd_swmr_dump_status(H5FD_t *file, uint64_t page); +H5_DLL void H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file); +H5_DLL void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *_file, uint64_t elapsed); H5_DLL H5FD_t *H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl_id); /* Function prototypes for MPI based VFDs*/ diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 31438cd..509c18e 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -527,20 +527,20 @@ H5FD__splitter_get_default_wo_path(char *new_path, size_t new_path_len, const ch HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "filename exceeds max length") /* Determine if filename contains a ".h5" extension. */ - if ((file_extension = strstr(base_filename, ".h5"))) { + if ((file_extension = HDstrstr(base_filename, ".h5"))) { /* Insert the suffix between the filename and ".h5" extension. */ HDstrcpy(new_path, base_filename); - file_extension = strstr(new_path, ".h5"); + file_extension = HDstrstr(new_path, ".h5"); HDsprintf(file_extension, "%s%s", suffix, ".h5"); } - else if ((file_extension = strrchr(base_filename, '.'))) { + else if ((file_extension = HDstrrchr(base_filename, '.'))) { char *new_extension_loc = NULL; /* If the filename doesn't contain a ".h5" extension, but contains * AN extension, just insert the suffix before that extension. */ HDstrcpy(new_path, base_filename); - new_extension_loc = strrchr(new_path, '.'); + new_extension_loc = HDstrrchr(new_path, '.'); HDsprintf(new_extension_loc, "%s%s", suffix, file_extension); } else { diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c index 11c177b..cd1a02e 100644 --- a/src/H5FDvfd_swmr.c +++ b/src/H5FDvfd_swmr.c @@ -235,9 +235,9 @@ H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "could not allocate API elapsed ticks") /* Retry on opening the metadata file */ - for (do_try = h5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, H5_RETRY_DEFAULT_MINIVAL, + for (do_try = H5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, H5_RETRY_DEFAULT_MINIVAL, H5_RETRY_DEFAULT_MAXIVAL); - do_try; do_try = h5_retry_next(&retry)) { + do_try; do_try = H5_retry_next(&retry)) { if ((file->md_fd = HDopen(file->md_file_path, O_RDONLY)) >= 0) break; } @@ -358,8 +358,6 @@ done: static void H5FD__swmr_reader_close(H5FD_vfd_swmr_t *file) { - vfd_swmr_reader_did_increase_tick_to(0); - if (file->api_elapsed_ticks != NULL) H5MM_xfree(file->api_elapsed_ticks); @@ -770,7 +768,7 @@ H5FD__vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id /* Try finding the addr from the index */ target_page = addr / fs_page_size; - entry = vfd_swmr_pageno_to_mdf_idx_entry(index, num_entries, target_page, FALSE); + entry = H5FD_vfd_swmr_pageno_to_mdf_idx_entry(index, num_entries, target_page, FALSE); if (entry == NULL) { /* Cannot find addr in index, read from the underlying hdf5 file */ @@ -1011,9 +1009,9 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) FUNC_ENTER_STATIC - for (do_try = h5_retry_init(&retry, H5FD_VFD_SWMR_MD_LOAD_RETRY_MAX, H5_RETRY_ONE_SECOND / 10, + for (do_try = H5_retry_init(&retry, H5FD_VFD_SWMR_MD_LOAD_RETRY_MAX, H5_RETRY_ONE_SECOND / 10, H5_RETRY_ONE_SECOND); - do_try; do_try = h5_retry_next(&retry)) { + do_try; do_try = H5_retry_next(&retry)) { /* Load and decode the header. Go around again on a temporary * failure (FALSE). Bail on an irrecoverable failure (FAIL). @@ -1170,7 +1168,8 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_header UINT32DECODE(p, md_header->fs_page_size); UINT64DECODE(p, md_header->tick_num); UINT64DECODE(p, md_header->index_offset); - if ((index_length = uint64_decode(&p)) > SIZE_MAX) + UINT64DECODE(p, index_length); + if (index_length > SIZE_MAX) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "index is too large to hold in core") md_header->index_length = (size_t)index_length; @@ -1181,13 +1180,6 @@ H5FD__vfd_swmr_header_deserialize(H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_header /* Sanity check */ HDassert((size_t)(p - image) <= H5FD_MD_HEADER_SIZE); -#if 0 /* JRM */ - HDfprintf(stderr, - "---read header ps/tick/idx_off/idx_len = %d / %lld / %lld / %lld\n", - md_header->fs_page_size, md_header->tick_num, - md_header->index_offset, md_header->index_length); -#endif /* JRM */ - ret_value = TRUE; done: @@ -1320,12 +1312,6 @@ H5FD__vfd_swmr_index_deserialize(const H5FD_vfd_swmr_t *file, H5FD_vfd_swmr_md_i /* Sanity check */ HDassert((size_t)(p - image) <= md_header->index_length); -#if 0 /* JRM */ - HDfprintf(stderr, - " ---- read index tick/num_entries = %lld / %d \n", - md_index->tick_num, md_index->num_entries); -#endif /* JRM */ - done: if (image != NULL) image = H5MM_xfree(image); diff --git a/src/H5FDvfd_swmr_instr.c b/src/H5FDvfd_swmr_instr.c deleted file mode 100644 index ad4885a..0000000 --- a/src/H5FDvfd_swmr_instr.c +++ /dev/null @@ -1,58 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by Akadio, Inc. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "H5private.h" /* H5_ATTR_UNUSED */ -#include "H5Fpublic.h" -#include "H5FDvfd_swmr.h" - -/* vfd_swmr_writer_may_increase_tick_to() and - * vfd_swmr_reader_did_increase_tick_to() are instrumentation points for - * VFD SWMR tests to use to coordinate the tick-number increases - * on a single writer with the progress of a single reader. - * - * This file provides the default, do-nothing implementations for both - * instrumentation routines. - * - * A VFD SWMR writer calls vfd_swmr_writer_may_increase_tick_to() with the - * increased tick number that it proposes, `tick_num`. The argument - * `wait_for_reader` tells whether or not the writer can wait for the reader - * before increasing its tick number. If `true`, then - * vfd_swmr_writer_may_increase_tick_to() should - * block until the reader is finished using the shadow-file content - * from ticks `tick_num - max_lag` and before, returning `true`. - * If `false`, then - * vfd_swmr_writer_may_increase_tick_to() immediately return `true` if - * the new tick number does permissible, otherwise `false`. - * - * After a VFD SWMR reader increases its tick number, it calls - * vfd_swmr_reader_did_increase_tick_to() with the new tick number. - * - * The test programs test/vfd_swmr_zoo_{reader,writer} provide - * their own vfd_swmr_writer_may_increase_tick_to() and - * vfd_swmr_reader_did_increase_tick_to() implementations that override the - * ones in the library. In the "zoo" - * test (test/vfd_swmr_zoo_{reader,writer}), the reader and the writer - * use a shared file to coordinate tick-number increases so that the writer - * can call H5Fvfd_swmr_end_tick() to increase its tick number at an arbitrary - * rate without outrunning the reader. - */ -bool -vfd_swmr_writer_may_increase_tick_to(uint64_t H5_ATTR_UNUSED tick_num, bool H5_ATTR_UNUSED wait_for_reader) -{ - return true; -} - -void -vfd_swmr_reader_did_increase_tick_to(uint64_t H5_ATTR_UNUSED tick_num) -{ - return; -} diff --git a/src/H5FDvfd_swmr_private.h b/src/H5FDvfd_swmr_private.h deleted file mode 100644 index f5cf484..0000000 --- a/src/H5FDvfd_swmr_private.h +++ /dev/null @@ -1,87 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by Akadio, Inc. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef H5FDvfd_swmr_private_H -#define H5FDvfd_swmr_private_H - -#include "H5queue.h" /* for TAILQ_* */ - -/* Forward declaration */ -struct H5F_t; -struct H5F_shared_t; -struct H5FD_vfd_swmr_idx_entry_t; - -/* - * struct eot_queue_entry_t - * - * This is the structure for an entry on the end-of-tick queue (EOT queue) of files - * opened in either VFD SWMR write or VFD SWMR read mode. This queue is maintained - * in increasing end of tick time order. - * The structure contains all information required to determine whether the end - * of tick has arrived for the specified file, and to initiate end of tick processing - * if it has. - * - * The fields of eot_queue_entry_t are discussed below: - * - * vfd_swmr_file: Pointer to the instance of H5F_file_t containing the shared - * fields of the associated file that has been opened in VFD SWMR mode - * NOTE: for the time being use H5F_t instead of H5F_file_t - * - * vfd_swmr_writer: Boolean flag that is set to TRUE if the associated file - * has been opened in VFD SWMR writer mode, and FALSE if it has been - * opened in VFD SWMR reader mode. - * - * tick_num: Number of the current tick of the target file. - * - * end_of_tick: Expiration time of the current tick of the target file. - * - * link: Forward and backward linkage between the next element and the previous - * element (or the queue head). Note that if there is a following entry, - * `next`, then `next->end_of_tick` must be greater than or equal to - * `end_of_tick`. - */ -typedef struct eot_queue_entry { - hbool_t vfd_swmr_writer; - uint64_t tick_num; - struct timespec end_of_tick; - struct H5F_t * vfd_swmr_file; /* NOTE: for the time being use H5F_t instead H5F_shared_t */ - TAILQ_ENTRY(eot_queue_entry) link; -} eot_queue_entry_t; - -H5_DLLVAR unsigned int vfd_swmr_api_entries_g; - -/* The head of the EOT queue */ -typedef TAILQ_HEAD(eot_queue, eot_queue_entry) eot_queue_t; - -H5_DLLVAR eot_queue_t eot_queue_g; - -/***************************************/ -/* Library-private Function Prototypes */ -/***************************************/ - -H5_DLL herr_t H5F_vfd_swmr_init(struct H5F_t *f, hbool_t file_create); -H5_DLL herr_t H5F_vfd_swmr_close_or_flush(struct H5F_t *f, hbool_t closing); -H5_DLL herr_t H5F_update_vfd_swmr_metadata_file(struct H5F_t *f, uint32_t index_len, - struct H5FD_vfd_swmr_idx_entry_t *index); -H5_DLL herr_t H5F_vfd_swmr_writer__delay_write(struct H5F_shared_t *, uint64_t, uint64_t *); -H5_DLL herr_t H5F_vfd_swmr_writer__prep_for_flush_or_close(struct H5F_t *f); -herr_t H5F_vfd_swmr_process_eot_queue(hbool_t); -H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(struct H5F_t *f, hbool_t); -H5_DLL herr_t H5F_vfd_swmr_writer__dump_index(struct H5F_shared_t *); -H5_DLL herr_t H5F_vfd_swmr_reader_end_of_tick(struct H5F_t *f, hbool_t); - -H5_DLL herr_t H5F_vfd_swmr_remove_entry_eot(struct H5F_t *f); -H5_DLL herr_t H5F_vfd_swmr_insert_entry_eot(struct H5F_t *f); -H5_DLL void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *); -H5_DLL herr_t H5F_dump_eot_queue(void); - -#endif /* H5FDvfd_swmr_private_H */ diff --git a/src/H5Fint.c b/src/H5Fint.c index 729aeea..9909256 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -32,7 +32,6 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MFprivate.h" /* File memory management */ -#include "H5MVprivate.h" /* File memory management for VFD SWMR */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ @@ -1541,7 +1540,7 @@ H5F__dest(H5F_t *f, hbool_t flush) /* If this is a VFD SWMR writer, prep for flush or close */ if ((f->shared->vfd_swmr) && (f->shared->vfd_swmr_writer) && - (H5F_vfd_swmr_writer__prep_for_flush_or_close(f) < 0)) + (H5F_vfd_swmr_writer_prep_for_flush_or_close(f) < 0)) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "vfd swmr prep for flush or close failed") @@ -2070,7 +2069,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if (H5F_VFD_SWMR_CONFIG(file)) { /* Set up the VFD SWMR LOG file */ - /* Kent*/ if (HDstrlen(vfd_swmr_config_ptr->log_file_path) > 0) shared->vfd_swmr_log_on = TRUE; if (TRUE == shared->vfd_swmr_log_on) { @@ -2082,7 +2080,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if (H5_timer_start(&(shared->vfd_swmr_log_start_time)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't obtain the time from the HDF5 timer.") } - /* End of Kent */ /* Initialization for VFD SWMR writer and reader */ if (1 == shared->nrefs) { @@ -2205,14 +2202,16 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* Success */ ret_value = file; -#if 1 /*Kent: write to the log file when H5F_open ends. Tested, can be commented out if necessary.*/ + /* Write to the log file when H5F_open ends. + * TODO: Tested, can be commented out if necessary. + */ H5F_POST_VFD_SWMR_LOG_ENTRY(file, FILE_OPEN, "File open ends"); -#endif + done: if ((NULL == ret_value) && file) { if (file->shared->root_grp && file->shared->nrefs == 1) { - if (H5AC_expunge_tag_type_metadata(file, H5G_oloc(file->shared->root_grp)->addr, H5AC_OHDR_ID, - H5AC__NO_FLAGS_SET, FALSE) < 0) + if (H5AC_expunge_all_tagged_metadata(file, H5G_oloc(file->shared->root_grp)->addr, H5AC_OHDR_ID, + H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, NULL, "unable to expunge root group tagged entries") } @@ -2358,7 +2357,7 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) /* If this is a VFD SWMR writer, prep for flush or close */ if ((f->shared->vfd_swmr) && (f->shared->vfd_swmr_writer) && - (H5F_vfd_swmr_writer__prep_for_flush_or_close(f) < 0)) + (H5F_vfd_swmr_writer_prep_for_flush_or_close(f) < 0)) /* Push error, but keep going*/ HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "vfd swmr prep for flush or close failed") @@ -4114,142 +4113,3 @@ H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_min_dset_ohdr() */ - -/*------------------------------------------------------------------------- - * Function: H5F__vfd_swmr_end_tick() - * - * Purpose: To trigger end of tick processing - * - * Return: Non-negative on success/Negative on errors - *------------------------------------------------------------------------- - */ -herr_t -H5F__vfd_swmr_end_tick(H5F_t *f) -{ - eot_queue_entry_t *curr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(f); - HDassert(f->shared); - - /* The file should be opened with VFD SWMR configured.*/ - if (!(H5F_USE_VFD_SWMR(f))) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") - - /* Search EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) - { - if (curr->vfd_swmr_file == f) - break; - } - - /* If the file does not exist on the EOT queue, flag an error */ - if (curr == NULL) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has been disabled") - - if (f->shared->vfd_swmr_writer) { - if (H5F_vfd_swmr_writer_end_of_tick(f, true) < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR writer"); - } - else if (H5F_vfd_swmr_reader_end_of_tick(f, true) < 0) { - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR reader"); - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__vfd_swmr_end_tick() */ - -/*------------------------------------------------------------------------- - * Function: H5F__vfd_swmr_disable_end_of_tick() - * - * Purpose: To disable end of tick processing - * - * Return: Non-negative on success/Negative on errors - *------------------------------------------------------------------------- - */ -herr_t -H5F__vfd_swmr_disable_end_of_tick(H5F_t *f) -{ - eot_queue_entry_t *curr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(f); - HDassert(f->shared); - - /* The file should be opened with VFD SWMR configured.*/ - if (!(H5F_USE_VFD_SWMR(f))) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") - - /* Search EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) - { - if (curr->vfd_swmr_file == f) - break; - } - - /* If the file does not exist on the EOT queue, flag an error */ - if (curr == NULL) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has already been disabled") - - /* Remove the entry that corresponds to "f" from the EOT queue */ - if (H5F_vfd_swmr_remove_entry_eot(f) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__vfd_swmr_disable_end_of_tick() */ - -/*------------------------------------------------------------------------- - * Function: H5F__vfd_swmr_enable_end_of_tick() - * - * Purpose: To enable end of tick processing - * - * Return: Non-negative on success/Negative on errors - *------------------------------------------------------------------------- - */ -herr_t -H5F__vfd_swmr_enable_end_of_tick(H5F_t *f) -{ - eot_queue_entry_t *curr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(f); - HDassert(f->shared); - - /* The file should be opened with VFD SWMR configured.*/ - if (!(H5F_USE_VFD_SWMR(f))) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") - - /* Search EOT queue */ - TAILQ_FOREACH(curr, &eot_queue_g, link) - { - if (curr->vfd_swmr_file == f) - break; - } - - /* If the file already exists on the EOT queue, flag an error */ - if (curr != NULL) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has already been enabled") - - /* Insert the entry that corresponds to "f" onto the EOT queue */ - if (H5F_vfd_swmr_insert_entry_eot(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") - - /* Check if the tick has expired, if so call end of tick processing */ - if (H5F_vfd_swmr_process_eot_queue(true) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "error processing EOT queue") - - /* FUNC_LEAVE_API could do the check, but not so for reader_end_of_tick() */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__vfd_swmr_enable_end_of_tick() */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 2edcc60..ca714c1 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -153,6 +153,62 @@ /* Size of file consistency flags (status_flags) in the superblock */ #define H5F_SUPER_STATUS_FLAGS_SIZE(v) (v >= 2 ? 1 : 4) +/* VFD SMWR LOG REPORTING MACROS */ + +/* H5F_POST_VFD_SWMR_LOG_ENTRY is the macro that can help the developers debug VFD SWMR features. + * It calls an internal reporting function H5F_post_vfd_swmr_log_entry() that receives + * a log entry_type_code, which generates a log tag, and the message log_info, which + * the developers want to save into a log file. + * + * The macro H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, number_entry_production, m) is + * called by H5F_POST_VFD_SWMR_LOG_ENTRY when the HDF5 library is built with the + * production mode. Number_entry_production will control the number of entry tags that + * applications can receive. Currently this number is set to 1 and is subject to change + * when more tags are useful to be present to applications. + * + * The first argument of the macro is the HDF5 file pointer(H5F_t *). + * Its value needs to be checked to avoid a failure caused by "Low-Level File I/O " + * in the testhdf5 program, which involves the test of a non-existing HDF5 file. + */ + +#define H5F_POST_VFD_SWMR_LOG_ENTRY_INTERNAL(fp, entry_type_code, log_info) \ + do { \ + if (fp != NULL) { \ + if (fp->shared != NULL) { \ + if (fp->shared->vfd_swmr_log_on == TRUE) { \ + H5F__post_vfd_swmr_log_entry(fp, entry_type_code, log_info); \ + } \ + } \ + } \ + } while (0) + +#define H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(fp, entry_type_code, max_code, log_info) \ + do { \ + if (entry_type_code < max_code) { \ + H5F_POST_VFD_SWMR_LOG_ENTRY_INTERNAL(fp, entry_type_code, log_info); \ + } \ + } while (0) + +/* Note: change H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, 1, m) on the following lines to + * H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, your_number_entry_production, m) + * as necessary. + */ +#ifndef NDEBUG +#define H5F_POST_VFD_SWMR_LOG_ENTRY(f, c, m) H5F_POST_VFD_SWMR_LOG_ENTRY_INTERNAL(f, c, m) +#else +#define H5F_POST_VFD_SWMR_LOG_ENTRY(f, c, m) H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, 1, m) +#endif + +/* Macros for VFD SWMR log entry code + * Note: this should be consistent with const char *H5Fvfd_swmr_log_tags[] declared at + * H5Fvfd_swmr.c . + */ +#define EOT_PROCESSING_TIME 0 +#define FILE_OPEN 1 +#define FILE_CLOSE 2 +#define EOT_TRIGGER_TIME 3 +#define EOT_META_FILE_INDEX 4 + /* Forward declaration external file cache struct used below (defined in * H5Fefc.c) */ typedef struct H5F_efc_t H5F_efc_t; @@ -564,6 +620,8 @@ H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t hi H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); H5_DLL herr_t H5F__parse_file_lock_env_var(htri_t *use_locks); H5_DLL herr_t H5F__delete(const char *filename, hid_t fapl_id); + +/* VFD SWMR routines */ H5_DLL herr_t H5F__vfd_swmr_end_tick(H5F_t *f); H5_DLL herr_t H5F__vfd_swmr_disable_end_of_tick(H5F_t *f); H5_DLL herr_t H5F__vfd_swmr_enable_end_of_tick(H5F_t *f); @@ -626,6 +684,9 @@ H5_DLL herr_t H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa); /* Functions that flush or evict */ H5_DLL herr_t H5F__evict_cache_entries(H5F_t *f); +/* VFD SWMR log functions */ +H5_DLL void H5F__post_vfd_swmr_log_entry(H5F_t *f, int entry_type_code, const char *log_info); + /* Testing functions */ #ifdef H5F_TESTING H5_DLL herr_t H5F__get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t *mesg_count); @@ -641,61 +702,4 @@ H5_DLL htri_t H5F__same_file_test(hid_t file_id1, hid_t file_id2); H5_DLL herr_t H5F__reparse_file_lock_variable_test(void); #endif /* H5F_TESTING */ -/* VFD SMWR LOG REPORTING MACROS */ - -/* H5F_POST_VFD_SWMR_LOG_ENTRY is the macro that can help the developers debug VFD SWMR features. - * It calls an internal reporting function H5F_post_vfd_swmr_log_entry() that receives - * a log entry_type_code, which generates a log tag, and the message log_info, which - * the developers want to save into a log file. - * - * The macro H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, number_entry_production, m) is - * called by H5F_POST_VFD_SWMR_LOG_ENTRY when the HDF5 library is built with the - * production mode. Number_entry_production will control the number of entry tags that - * applications can receive. Currently this number is set to 1 and is subject to change - * when more tags are useful to be present to applications. - * - * The first argument of the macro is the HDF5 file pointer(H5F_t *). - * Its value needs to be checked to avoid a failure caused by "Low-Level File I/O " - * in the testhdf5 program, which involves the test of a non-existing HDF5 file. - */ - -H5_DLL void H5F__post_vfd_swmr_log_entry(H5F_t *f, int entry_type_code, const char *log_info); - -#define H5F_POST_VFD_SWMR_LOG_ENTRY_INTERNAL(fp, entry_type_code, log_info) \ - do { \ - if (fp != NULL) { \ - if (fp->shared != NULL) { \ - if (fp->shared->vfd_swmr_log_on == TRUE) { \ - H5F__post_vfd_swmr_log_entry(fp, entry_type_code, log_info); \ - } \ - } \ - } \ - } while (0) - -#define H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(fp, entry_type_code, max_code, log_info) \ - do { \ - if (entry_type_code < max_code) { \ - H5F_POST_VFD_SWMR_LOG_ENTRY_INTERNAL(fp, entry_type_code, log_info); \ - } \ - } while (0) - -/* Note: change H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, 1, m) on the following lines to - * H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, your_number_entry_production, m) - * as necessary. - */ -#ifndef NDEBUG -#define H5F_POST_VFD_SWMR_LOG_ENTRY(f, c, m) H5F_POST_VFD_SWMR_LOG_ENTRY_INTERNAL(f, c, m) -#else -#define H5F_POST_VFD_SWMR_LOG_ENTRY(f, c, m) H5F_POST_VFD_SWMR_LOG_ENTRY_PRODUCTION(f, c, 1, m) -#endif - -/* Macros for VFD SWMR log entry code - * Note: this should be consistent with const char *H5Fvfd_swmr_log_tags[] declared at - * H5Fvfd_swmr.c . - */ -#define EOT_PROCESSING_TIME 0 -#define FILE_OPEN 1 -#define FILE_CLOSE 2 -#define EOT_TRIGGER_TIME 3 -#define EOT_META_FILE_INDEX 4 #endif /* H5Fpkg_H */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index e94ee64..ffc369b 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -238,20 +238,6 @@ typedef struct H5F_t H5F_t; (p) += 8; \ } -static inline uint64_t -uint64_decode(uint8_t **pp) -{ - int i; - uint8_t *p = *pp; - uint64_t v = 0; - - for (i = 0; i < 8; i++) { - v = (v << 8) | p[7 - i]; - } - *pp += 8; - return v; -} - #define UINT64DECODE(p, n) \ { \ /* WE DON'T CHECK FOR OVERFLOW! */ \ @@ -388,10 +374,7 @@ uint64_decode(uint8_t **pp) #define H5F_THRESHOLD(F) ((F)->shared->threshold) #define H5F_PGEND_META_THRES(F) ((F)->shared->fs.pgend_meta_thres) #define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) -#define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) -#define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) #define H5F_USE_VFD_SWMR(F) ((F)->shared->vfd_swmr) -#define H5F_VFD_SWMR_MD_EOA(F) ((F)->shared->vfd_swmr_md_eoa) #define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr) #define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) #define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) @@ -455,9 +438,7 @@ uint64_decode(uint8_t **pp) #define H5F_THRESHOLD(F) (H5F_get_threshold(F)) #define H5F_PGEND_META_THRES(F) (H5F_get_pgend_meta_thres(F)) #define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) -#define H5F_FIRST_ALLOC_DEALLOC(F) (H5F_get_first_alloc_dealloc(F)) -#define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) -#define H5F_USE_VFD_SWMR(F) (H5F_use_vfd_swmr(F)) +#define H5F_USE_VFD_SWMR(F) (H5F_get_use_vfd_swmr(F)) #define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F)) #define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) #define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) @@ -641,16 +622,23 @@ uint64_decode(uint8_t **pp) /* Default configuration for VFD SWMR: not configured */ #define H5F_ACS_VFD_SWMR_CONFIG_NAME "vfd_swmr_config" +/* clang-format off */ #define H5F__DEFAULT_VFD_SWMR_CONFIG \ { \ - /* int32_t version = */ 0, /* int32_t tick_len = */ 0, \ - /* int32_t max_lag = */ 0, /* hbool_t vfd_swmr_writer = */ FALSE, \ - /* hbool_t maintain_metadata_file = */ FALSE, \ - /* hbool_t generate_updater_files = */ FALSE, \ - /* hbool_t flush_raw_data = */ FALSE, /* int32_t md_pages_reserved = */ 0, \ - /* int32_t pb_expansion_threshold = */ 0, /* char md_file_path[] = */ "", \ - /* char updater_file_path[] = */ "", /* char log_file_path[] = */ "" \ + /* int32_t version = */ 0, \ + /* int32_t tick_len = */ 0, \ + /* int32_t max_lag = */ 0, \ + /* hbool_t vfd_swmr_writer = */ FALSE, \ + /* hbool_t maintain_metadata_file = */ FALSE, \ + /* hbool_t generate_updater_files = */ FALSE, \ + /* hbool_t flush_raw_data = */ FALSE, \ + /* int32_t md_pages_reserved = */ 0, \ + /* int32_t pb_expansion_threshold = */ 0, \ + /* char md_file_path[] = */ "", \ + /* char updater_file_path[] = */ "", \ + /* char log_file_path[] = */ "" \ } +/* clang-format on */ /* For VFD SWMR testing only: private property to generate checksum for metadata file via callback */ #define H5F_ACS_GENERATE_MD_CK_CB_NAME "generate md ck callback" @@ -841,18 +829,6 @@ uint64_decode(uint8_t **pp) + H5F_SIZEOF_CHKSUM /* Updater file change list checksum */ \ ) -/* - * For VFD SWMR testing only: - */ - -/* Callback routine to generate checksum for metadata file specified by md_path */ -typedef herr_t (*H5F_generate_md_ck_t)(char *md_path, uint64_t updater_seq_num); - -/* Structure for "generate checksum callback" private property */ -typedef struct H5F_generate_md_ck_cb_t { - H5F_generate_md_ck_t func; -} H5F_generate_md_ck_cb_t; - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -865,6 +841,7 @@ struct H5O_loc_t; struct H5HG_heap_t; struct H5VL_class_t; struct H5P_genplist_t; +struct H5FD_vfd_swmr_idx_entry_t; /* Forward declarations for anonymous H5F objects */ @@ -929,6 +906,44 @@ typedef enum H5F_prefix_open_t { /*---------------------------------------------------------------------------- * + * struct eot_queue_entry_t + * + * This is the structure for an entry on the end-of-tick queue (EOT queue) of files + * opened in either VFD SWMR write or VFD SWMR read mode. This queue is maintained + * in increasing end of tick time order. + * The structure contains all information required to determine whether the end + * of tick has arrived for the specified file, and to initiate end of tick processing + * if it has. + * + * The fields of eot_queue_entry_t are discussed below: + * + * vfd_swmr_file: Pointer to the instance of H5F_shared_t containing the shared + * fields of the associated file that has been opened in VFD SWMR mode + * NOTE: for the time being use H5F_t instead of H5F_shared_t + * + * vfd_swmr_writer: Boolean flag that is set to TRUE if the associated file + * has been opened in VFD SWMR writer mode, and FALSE if it has been + * opened in VFD SWMR reader mode. + * + * tick_num: Number of the current tick of the target file. + * + * end_of_tick: Expiration time of the current tick of the target file. + * + * link: Forward and backward linkage between the next element and the previous + * element (or the queue head). Note that if there is a following entry, + * `next`, then `next->end_of_tick` must be greater than or equal to + * `end_of_tick`. + */ +typedef struct eot_queue_entry { + hbool_t vfd_swmr_writer; + uint64_t tick_num; + struct timespec end_of_tick; + H5F_t * vfd_swmr_file; + TAILQ_ENTRY(eot_queue_entry) link; +} eot_queue_entry_t; + +/*---------------------------------------------------------------------------- + * * struct H5F_vfd_swmr_updater_cl_entry_t * * An array of instances of H5F_vfd_swmr_updater_cl_entry_t of length equal to @@ -1097,6 +1112,14 @@ typedef struct H5F_vfd_swmr_updater_t { H5F_vfd_swmr_updater_cl_entry_t *change_list; } H5F_vfd_swmr_updater_t; +/* Callback routine to generate checksum for metadata file specified by md_path */ +typedef herr_t (*H5F_generate_md_ck_t)(char *md_path, uint64_t updater_seq_num); + +/* Structure for "generate checksum callback" private property */ +typedef struct H5F_generate_md_ck_cb_t { + H5F_generate_md_ck_t func; +} H5F_generate_md_ck_cb_t; + /*****************************/ /* Library-private Variables */ /*****************************/ @@ -1189,7 +1212,22 @@ H5_DLL herr_t H5F_shared_get_file_driver(const H5F_shared_t *f_sh, H5FD_t **fil H5_DLL herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle); /* VFD SWMR functions */ -H5_DLL hbool_t H5F_use_vfd_swmr(const H5F_t *f); +H5_DLL hbool_t H5F_get_use_vfd_swmr(const H5F_t *f); +H5_DLL herr_t H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create); +H5_DLL herr_t H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing); +H5_DLL herr_t H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t index_len, + H5FD_vfd_swmr_idx_entry_t *index); +H5_DLL herr_t H5F_vfd_swmr_writer_delay_write(H5F_shared_t *shared, uint64_t page, uint64_t *untilp); +H5_DLL herr_t H5F_vfd_swmr_writer_prep_for_flush_or_close(H5F_t *f); +H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(H5F_t *f); +H5_DLL herr_t H5F_vfd_swmr_writer_dump_index(H5F_shared_t *shared); +H5_DLL herr_t H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api); +H5_DLL herr_t H5F_vfd_swmr_remove_entry_eot(H5F_t *f); +H5_DLL herr_t H5F_vfd_swmr_insert_entry_eot(H5F_t *f); +H5_DLL void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *entry); +H5_DLL herr_t H5F_dump_eot_queue(void); +H5_DLL herr_t H5F_shadow_image_defer_free(H5F_shared_t *shared, const H5FD_vfd_swmr_idx_entry_t *entry); +H5_DLL H5FD_vfd_swmr_idx_entry_t *H5F_vfd_swmr_enlarge_shadow_index(H5F_t *f); /* File mounting routines */ H5_DLL herr_t H5F_mount(const struct H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 6d292bf..e9d3340 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -1820,14 +1820,6 @@ H5_DLL herr_t H5Fvfd_swmr_disable_end_of_tick(hid_t file_id); * \todo Add missing documentation */ H5_DLL herr_t H5Fvfd_swmr_enable_end_of_tick(hid_t file_id); -/** - * \todo Add missing documentation - */ -H5_DLL bool vfd_swmr_writer_may_increase_tick_to(uint64_t, bool); -/** - * \todo Add missing documentation - */ -H5_DLL void vfd_swmr_reader_did_increase_tick_to(uint64_t); #ifdef H5_HAVE_PARALLEL /** diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 2665505..acdf521 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -1344,18 +1344,15 @@ H5F_get_file_locking(const H5F_t *f) } /* end H5F_get_file_locking */ /*------------------------------------------------------------------------- - * Function: H5F_use_vfd_swmr + * Function: H5F_get_use_vfd_swmr * - * Purpose: Quick and dirty routine to determine if VFD SWMR is - * enabled for this file. - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) + * Purpose: Determine if VFD SWMR is enabled for this file. * - * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) + * Return: TRUE/FALSE *------------------------------------------------------------------------- */ hbool_t -H5F_use_vfd_swmr(const H5F_t *f) +H5F_get_use_vfd_swmr(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Ftest.c b/src/H5Ftest.c index f4a89fd..01c9706 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -416,9 +416,10 @@ H5F__vfd_swmr_decode_md_hdr(int md_fd, H5FD_vfd_swmr_md_header *md_hdr) UINT32DECODE(p, md_hdr->fs_page_size); UINT64DECODE(p, md_hdr->tick_num); UINT64DECODE(p, md_hdr->index_offset); - if ((index_length = uint64_decode(&p)) > SIZE_MAX) { + UINT64DECODE(p, index_length); + if (index_length > SIZE_MAX) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "index is too long") - } + md_hdr->index_length = (size_t)index_length; done: @@ -568,16 +569,27 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__vfd_swmr_verify_md_hdr_and_idx() */ +/*------------------------------------------------------------------------- + * Function: H5F__count_shadow_defrees + * + * Purpose: + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ static unsigned -count_shadow_defrees(shadow_defree_queue_t *shadow_defrees) +H5F__count_shadow_defrees(shadow_defree_queue_t *shadow_defrees) { shadow_defree_t *shadow_defree; unsigned count = 0; + FUNC_ENTER_STATIC_NOERR + TAILQ_FOREACH(shadow_defree, shadow_defrees, link) count++; - return count; + FUNC_LEAVE_NOAPI(count) } /*------------------------------------------------------------------------- @@ -618,7 +630,7 @@ H5F__vfd_swmr_writer_md_test(hid_t file_id, unsigned num_entries, H5FD_vfd_swmr_ HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "error updating the md file with the index") /* Verify the number of entries in the delayed list is as expected */ - if (count_shadow_defrees(&f->shared->shadow_defrees) == nshadow_defrees) + if (H5F__count_shadow_defrees(&f->shared->shadow_defrees) == nshadow_defrees) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect # of entries in the delayed list") /* Open the metadata file */ diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 06d0c0d..84beefc 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*------------------------------------------------------------------------- + * Created: H5Fvfd_swmr.c * - * Created: H5Fvfd_swmr.c - * Oct 10 2019 - * - * Purpose: Functions for VFD SWMR. - * + * Purpose: File functions for VFD SWMR *------------------------------------------------------------------------- */ @@ -52,8 +49,8 @@ /* Local Macros */ /****************/ -#define nanosecs_per_second 1000000000 /* nanoseconds per second */ -#define nanosecs_per_tenth_sec 100000000 /* nanoseconds per 0.1 second */ +#define NANOSECS_PER_SECOND 1000000000 /* nanoseconds per second */ +#define NANOSECS_PER_TENTH_SEC 100000000 /* nanoseconds per 0.1 second */ /* Declare an array of string to identify the VFD SMWR Log tags. * Note this array is used to generate the entry tag by the log reporting macro @@ -103,7 +100,7 @@ static herr_t H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *, uint32_t, struct H5FD_vfd_swmr_idx_entry_t[], uint8_t *); static herr_t H5F__idx_entry_cmp(const void *_entry1, const void *_entry2); static herr_t H5F__vfd_swmr_create_index(H5F_shared_t *); -static herr_t H5F__vfd_swmr_writer__wait_a_tick(H5F_t *); +static herr_t H5F__vfd_swmr_writer_wait_a_tick(H5F_t *); static herr_t H5F__vfd_swmr_construct_ud_hdr(H5F_vfd_swmr_updater_t *updater); static herr_t H5F__vfd_swmr_construct_ud_cl(H5F_vfd_swmr_updater_t *updater); @@ -116,20 +113,15 @@ static herr_t H5F__generate_updater_file(H5F_t *f, uint32_t num_entries, uint16_ /* Package Variables */ /*********************/ -/* - * Globals for VFD SWMR +/* Globals for VFD SWMR */ + +/* Times the library was entered and re-entered minus the times it was exited. + * We only perform the end-of-tick processing on the 0->1 and 1->0 transitions. */ +unsigned int vfd_swmr_api_entries_g = 0; -unsigned int vfd_swmr_api_entries_g = 0; /* Times the library was entered - * and re-entered minus the times - * it was exited. We only perform - * the end-of-tick processing - * on the 0->1 and 1->0 - * transitions. - */ -/* - * The head of the end of tick queue (EOT queue) for files opened in either - * VFD SWMR write or VFD SWMR read mode +/* The head of the end of tick queue (EOT queue) for files opened in either + * VFD SWMR write or VFD SWMR read mode */ eot_queue_t eot_queue_g = TAILQ_HEAD_INITIALIZER(eot_queue_g); @@ -144,7 +136,6 @@ H5FL_DEFINE(shadow_defree_t); H5FL_DEFINE(eot_queue_entry_t); /*------------------------------------------------------------------------- - * * Function: H5F_vfd_swmr_init * * Purpose: Initialize globals and the corresponding fields in @@ -168,11 +159,6 @@ H5FL_DEFINE(eot_queue_entry_t); * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Vailin Choi -- 10/??/18 - * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -208,9 +194,9 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) md_size = (hsize_t)shared->vfd_swmr_config.md_pages_reserved * shared->fs_page_size; - if ((hdr_addr = H5MV_alloc(f, md_size)) == HADDR_UNDEF) { - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error allocating shadow-file header"); - } + if ((hdr_addr = H5MV_alloc(f, md_size)) == HADDR_UNDEF) + HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error allocating shadow-file header") + HDassert(H5F_addr_eq(hdr_addr, H5FD_MD_HEADER_OFF)); shared->writer_index_offset = H5FD_MD_HEADER_SIZE; @@ -222,10 +208,10 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) if (!file_create) { if (H5F__vfd_swmr_construct_write_md_idx(shared, 0, NULL, md_idx_image) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create index in md"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create index in md") if (H5F__vfd_swmr_construct_write_md_hdr(shared, 0, md_hdr_image) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create header in md"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create header in md") } /* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */ @@ -274,28 +260,18 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) /* allocate an index to save the initial index */ if (H5F__vfd_swmr_create_index(shared) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate metadata file index"); + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate metadata file index") /* Set tick_num to the current tick read from the metadata file */ shared->mdf_idx_entries_used = shared->mdf_idx_len; if (H5FD_vfd_swmr_get_tick_and_idx(shared->lf, FALSE, &shared->tick_num, &(shared->mdf_idx_entries_used), shared->mdf_idx) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "unable to load/decode metadata file"); - - vfd_swmr_reader_did_increase_tick_to(shared->tick_num); - -#if 0 /* JRM */ - HDfprintf(stderr, - "##### initialized index: tick/used/len = %lld/%d/%d #####\n", - shared->tick_num, shared->mdf_idx_entries_used, - shared->mdf_idx_len); -#endif /* JRM */ + HGOTO_ERROR(H5E_FILE, H5E_CANTLOAD, FAIL, "unable to load/decode metadata file") } /* Update end_of_tick */ - if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, FALSE) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick"); - } + if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick") done: @@ -304,7 +280,6 @@ done: } /* H5F_vfd_swmr_init() */ /*------------------------------------------------------------------------- - * * Function: H5F_vfd_swmr_close_or_flush * * Purpose: Used by the VFD SWMR writer when the HDF5 file is closed @@ -325,11 +300,6 @@ done: * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Vailin Choi -- 11/??/18 - * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -348,17 +318,17 @@ H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing) /* Write empty index to the md file */ if (H5F__vfd_swmr_construct_write_md_idx(shared, 0, NULL, md_idx_image) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create index in md"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create index in md") /* Write header to the md file */ if (H5F__vfd_swmr_construct_write_md_hdr(shared, 0, md_hdr_image) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create header in md"); + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "fail to create header in md") if (closing) { /* For file close */ /* Close the md file */ if (HDclose(shared->vfd_swmr_md_fd) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close the metadata file"); + HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close the metadata file") shared->vfd_swmr_md_fd = -1; /* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */ @@ -369,12 +339,12 @@ H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing) /* Unlink the md file */ if (HDunlink(shared->vfd_swmr_config.md_file_path) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "unable to unlink the metadata file"); + HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "unable to unlink the metadata file") /* Close the free-space manager for the metadata file */ if (H5MV_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, - "unable to close the free-space manager for the metadata file"); + "unable to close the free-space manager for the metadata file") /* Free the delayed list */ while ((curr = TAILQ_FIRST(&shared->shadow_defrees)) != NULL) { @@ -394,51 +364,68 @@ H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing) else { /* For file flush */ /* Update end_of_tick */ if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, TRUE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick"); + HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick") } -#if 1 /*Kent Save the end of close info. to the log file, subject to comment out. */ +#if 1 /* Save the end of close info. to the log file, subject to comment out. */ if (closing) H5F_POST_VFD_SWMR_LOG_ENTRY(f, FILE_CLOSE, "VFD SWMR File close ends"); #endif done: - /* Kent: Stop the timer and close the VFD SWMR log file if it is turned on. - * Please REVIEW to ensure this is the right place to + /* Stop the timer and close the VFD SWMR log file if it is turned on. + * TODO: Please REVIEW to ensure this is the right place to * close the log file. */ if (shared->vfd_swmr_log_on && closing) { H5_timer_stop(&(shared->vfd_swmr_log_start_time)); HDfclose(shared->vfd_swmr_log_file_ptr); } - /* Kent */ + FUNC_LEAVE_NOAPI(ret_value) } -static int -shadow_range_defer_free(H5F_shared_t *shared, uint64_t offset, uint32_t length) +/*------------------------------------------------------------------------- + * Function: H5F__shadow_image_defer_free + * + * Purpose: + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +static herr_t +H5F__shadow_range_defer_free(H5F_shared_t *shared, uint64_t offset, uint32_t length) { shadow_defree_t *shadow_defree; if (NULL == (shadow_defree = H5FL_CALLOC(shadow_defree_t))) - return -1; + return FAIL; shadow_defree->offset = offset; shadow_defree->length = length; shadow_defree->tick_num = shared->tick_num; TAILQ_INSERT_HEAD(&shared->shadow_defrees, shadow_defree, link); - return 0; + + return SUCCEED; } -int -shadow_image_defer_free(H5F_shared_t *shared, const H5FD_vfd_swmr_idx_entry_t *entry) +/*------------------------------------------------------------------------- + * Function: H5F_shadow_image_defer_free + * + * Purpose: + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5F_shadow_image_defer_free(H5F_shared_t *shared, const H5FD_vfd_swmr_idx_entry_t *entry) { - return shadow_range_defer_free(shared, entry->md_file_page_offset * shared->fs_page_size, entry->length); + return H5F__shadow_range_defer_free(shared, entry->md_file_page_offset * shared->fs_page_size, + entry->length); } /*------------------------------------------------------------------------- - * - * Function: H5F_update_vfd_swmr_metadata_file() + * Function: H5F_update_vfd_swmr_metadata_file * * Purpose: Update the metadata file with the input index * @@ -462,12 +449,6 @@ shadow_image_defer_free(H5F_shared_t *shared, const H5FD_vfd_swmr_idx_entry_t *e * free-space manager * * Return: SUCCEED/FAIL - * - * Programmer: Vailin Choi 11/??/18 - * - * Changes: None. - * - * *------------------------------------------------------------------------- */ herr_t @@ -513,7 +494,7 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, H5FD_vfd_swmr_ /* Prepend previous image of the entry to the delayed list */ if (index[i].md_file_page_offset) { - if (shadow_image_defer_free(shared, &index[i]) == -1) { + if (H5F_shadow_image_defer_free(shared, &index[i]) == -1) { HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate the delayed entry") } } @@ -528,22 +509,6 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, H5FD_vfd_swmr_ index[i].md_file_page_offset = md_addr / shared->fs_page_size; index[i].checksum = H5_checksum_metadata(index[i].entry_ptr, index[i].length, 0); -#if 0 /* JRM */ - HDfprintf(stderr, - "writing index[%d] fo/mdfo/l/checksum/fc/lc = %lld/%lld/%ld/%lx/%lx/%lx\n", - i, - index[i].hdf5_page_offset, - index[i].md_file_page_offset, - index[i].length, - index[i].checksum, - (((char*)(index[i].entry_ptr))[0]), - (((char*)(index[i].entry_ptr))[4095])); - - HDassert(md_addr == index[i].md_file_page_offset * - shared->fs_page_size); - HDassert(shared->fs_page_size == 4096); -#endif /* JRM */ - if (shared->vfd_swmr_config.maintain_metadata_file) { /* Seek and write the entry to the metadata file */ @@ -594,13 +559,11 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, H5FD_vfd_swmr_ TAILQ_FOREACH_REVERSE_SAFE(shadow_defree, &shared->shadow_defrees, shadow_defree_queue, link, prev) { - if (shadow_defree->tick_num + shared->vfd_swmr_config.max_lag > shared->tick_num) { + if (shadow_defree->tick_num + shared->vfd_swmr_config.max_lag > shared->tick_num) break; // No more entries are due for reclamation. - } - if (H5MV_free(f, shadow_defree->offset, shadow_defree->length) < 0) { - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry"); - } + if (H5MV_free(f, shadow_defree->offset, shadow_defree->length) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") TAILQ_REMOVE(&shared->shadow_defrees, shadow_defree, link); @@ -622,16 +585,14 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, H5FD_vfd_swmr_ done: - if (md_idx_image) - HDfree(md_idx_image); + HDfree(md_idx_image); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_update_vfd_swmr_metadata_file() */ /*------------------------------------------------------------------------- - * - * Function: H5F_vfd_swmr_writer__delay_write + * Function: H5F_vfd_swmr_writer_delay_write * * Purpose: Given the base address of a page of metadata, or of a multi- * page metadata entry, determine whether the write must be @@ -662,15 +623,10 @@ done: * or equal to the current tick, or zero otherwise. * * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer 11/4/18 - * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t -H5F_vfd_swmr_writer__delay_write(H5F_shared_t *shared, uint64_t page, uint64_t *untilp) +H5F_vfd_swmr_writer_delay_write(H5F_shared_t *shared, uint64_t page, uint64_t *untilp) { uint64_t until; H5FD_vfd_swmr_idx_entry_t *ie_ptr; @@ -687,16 +643,14 @@ H5F_vfd_swmr_writer__delay_write(H5F_shared_t *shared, uint64_t page, uint64_t * HDassert(idx != NULL || shared->tick_num <= 1); - /* do a binary search on the metadata file index to see if - * it already contains an entry for `page`. + /* Do a binary search on the metadata file index to see if + * it already contains an entry for `page` */ - if (idx == NULL) { + if (idx == NULL) ie_ptr = NULL; - } - else { - ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, shared->mdf_idx_entries_used, page, FALSE); - } + else + ie_ptr = H5FD_vfd_swmr_pageno_to_mdf_idx_entry(idx, shared->mdf_idx_entries_used, page, FALSE); if (ie_ptr == NULL) until = shared->tick_num + shared->vfd_swmr_config.max_lag; @@ -715,11 +669,10 @@ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5F_vfd_swmr_writer__delay_write() */ +} /* H5F_vfd_swmr_writer_delay_write() */ /*------------------------------------------------------------------------- - * - * Function: H5F_vfd_swmr_writer__prep_for_flush_or_close + * Function: H5F_vfd_swmr_writer_prep_for_flush_or_close * * Purpose: In the context of the VFD SWMR writer, two issues must be * addressed before the page buffer can be flushed -- as is @@ -735,15 +688,10 @@ done: * This function manages these details. * * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer 11/27/18 - * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t -H5F_vfd_swmr_writer__prep_for_flush_or_close(H5F_t *f) +H5F_vfd_swmr_writer_prep_for_flush_or_close(H5F_t *f) { herr_t ret_value = SUCCEED; /* Return value */ H5F_shared_t *shared = f->shared; @@ -758,14 +706,11 @@ H5F_vfd_swmr_writer__prep_for_flush_or_close(H5F_t *f) * tick so as to avoid attempts to flush entries on the page buffer * tick list that were modified during the current tick. */ - if (H5F_vfd_swmr_writer_end_of_tick(f, TRUE) < 0) - + if (H5F_vfd_swmr_writer_end_of_tick(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "H5F_vfd_swmr_writer_end_of_tick() failed.") while (shared->page_buf->dwl_len > 0) { - - if (H5F__vfd_swmr_writer__wait_a_tick(f) < 0) - + if (H5F__vfd_swmr_writer_wait_a_tick(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "wait a tick failed.") } @@ -773,10 +718,10 @@ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5F_vfd_swmr_writer__prep_for_flush_or_close() */ +} /* H5F_vfd_swmr_writer_prep_for_flush_or_close() */ static int -clean_shadow_index(H5F_t *f, uint32_t nentries, H5FD_vfd_swmr_idx_entry_t *idx, uint32_t *ndeletedp) +H5F__clean_shadow_index(H5F_t *f, uint32_t nentries, H5FD_vfd_swmr_idx_entry_t *idx, uint32_t *ndeletedp) { H5F_shared_t * shared = f->shared; uint32_t i, j, ndeleted, max_lag = shared->vfd_swmr_config.max_lag; @@ -792,7 +737,7 @@ clean_shadow_index(H5F_t *f, uint32_t nentries, H5FD_vfd_swmr_idx_entry_t *idx, HDassert(ie->entry_ptr == NULL); if (ie->md_file_page_offset != 0) { - if (shadow_image_defer_free(shared, ie) == -1) + if (H5F_shadow_image_defer_free(shared, ie) == -1) return -1; ie->md_file_page_offset = 0; } @@ -808,7 +753,6 @@ clean_shadow_index(H5F_t *f, uint32_t nentries, H5FD_vfd_swmr_idx_entry_t *idx, } /*------------------------------------------------------------------------- - * * Function: H5F_vfd_swmr_writer_end_of_tick * * Purpose: Main routine for managing the end of tick for the VFD @@ -858,15 +802,10 @@ clean_shadow_index(H5F_t *f, uint32_t nentries, H5FD_vfd_swmr_idx_entry_t *idx, * In passing, generate log entries as appropriate. * * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer 11/4/18 - * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t -H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) +H5F_vfd_swmr_writer_end_of_tick(H5F_t *f) { H5F_shared_t *shared = f->shared; uint32_t idx_entries_added = 0; @@ -877,10 +816,10 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) herr_t ret_value = SUCCEED; /* Return value */ hbool_t incr_tick = FALSE; - /* Kent: define the local variables to calculate the EOT time - and write them to the log file. */ + /* Local variables to calculate the EOT time and write to the log file */ H5_timevals_t current_time; - double start_elapsed_time, end_elapsed_time; + double start_elapsed_time = 0.0; + double end_elapsed_time = 0.0; unsigned int temp_time; char * log_msg; @@ -890,17 +829,12 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) HDassert(shared->page_buf); HDassert(shared->vfd_swmr_writer); - /* Kent */ /* Obtain the starting time for the logging info: the processing time of this function. */ - if (shared->vfd_swmr_log_on == true) { + if (shared->vfd_swmr_log_on == TRUE) { if (H5_timer_get_times(shared->vfd_swmr_log_start_time, ¤t_time) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time from H5_timer_get_times") start_elapsed_time = current_time.elapsed; } - /* Kent */ - - if (!vfd_swmr_writer_may_increase_tick_to(shared->tick_num + 1, wait_for_reader)) - goto update_eot; incr_tick = TRUE; @@ -966,8 +900,8 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) * to the HDF5 file more than max_lag ticks ago, and haven't * been modified since. */ - if (clean_shadow_index(f, shared->mdf_idx_entries_used + idx_entries_added, shared->mdf_idx, - &idx_entries_removed) < 0) + if (H5F__clean_shadow_index(f, shared->mdf_idx_entries_used + idx_entries_added, shared->mdf_idx, + &idx_entries_removed) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't clean shadow file index") /* 6) Update the metadata file. Must do this before we @@ -989,27 +923,18 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader) HDassert(shared->mdf_idx_entries_used <= shared->mdf_idx_len); -#if 0 /* JRM */ - H5F__vfd_swmr_writer__dump_index(f); -#endif /* JRM */ - /* 7) Release the page buffer tick list. */ if (H5PB_vfd_swmr__release_tick_list(shared) < 0) - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't release tick list") /* 8) Release any delayed writes whose delay has expired */ if (H5PB_vfd_swmr__release_delayed_writes(shared) < 0) - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't release delayed writes") -update_eot: - /* 9) Increment the tick, and update the end of tick. */ /* Update end_of_tick */ if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, incr_tick) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick") /* Remove the entry from the EOT queue */ @@ -1021,8 +946,8 @@ update_eot: HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") done: - /* Kent: Calculate the processing time and write the time info to the log file */ - if (shared->vfd_swmr_log_on == true) { + /* Calculate the processing time and write the time info to the log file */ + if (shared->vfd_swmr_log_on == TRUE) { if (H5_timer_get_times(shared->vfd_swmr_log_start_time, ¤t_time) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time from H5_timer_get_times") end_elapsed_time = current_time.elapsed; @@ -1033,26 +958,20 @@ done: HDfree(log_msg); } } - /* Kent */ + FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- - * - * Function: H5F_vfd_swmr_writer__dump_index + * Function: H5F_vfd_swmr_writer_dump_index * * Purpose: Dump a summary of the metadata file index. * * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer 12/14/19 - * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t -H5F_vfd_swmr_writer__dump_index(H5F_shared_t *shared) +H5F_vfd_swmr_writer_dump_index(H5F_shared_t *shared) { unsigned int i; uint32_t mdf_idx_len; @@ -1074,15 +993,13 @@ H5F_vfd_swmr_writer__dump_index(H5F_shared_t *shared) HDfprintf(stderr, "index len / entries used = %" PRIu32 " / %" PRIu32 "\n\n", mdf_idx_len, mdf_idx_entries_used); - for (i = 0; i < mdf_idx_entries_used; i++) { - + for (i = 0; i < mdf_idx_entries_used; i++) HDfprintf(stderr, "%u: %" PRIu64 " %" PRIu64 " %" PRIu32 "\n", i, index[i].hdf5_page_offset, index[i].md_file_page_offset, index[i].length); - } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_vfd_swmr_writer__dump_index() */ +} /* end H5F_vfd_swmr_writer_dump_index() */ /*------------------------------------------------------------------------- * Function: H5F_vfd_swmr_reader_end_of_tick @@ -1116,11 +1033,6 @@ H5F_vfd_swmr_writer__dump_index(H5F_shared_t *shared) * 9) Increment the tick, and update the end of tick. * * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer 12/29/18 - * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -1168,23 +1080,17 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) /* This is ok if we're entering the API, but it should * not happen if we're exiting the API. */ - /* JRM review this */ + /* TODO: review this */ /* The following line is added for more meaningful error message when * the long running API on the reader side exceeds the max_lag of ticks. - * KY 2021-09-02 - * */ + */ if (!entering_api && tmp_tick_num >= shared->tick_num + shared->vfd_swmr_config.max_lag) { HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "Reader's API time exceeds max_lag ticks, suggest to increase the value of max_lag."); } -#if 0 /* Kent */ - /* The original code */ - HDassert(entering_api || tmp_tick_num < shared->tick_num + shared->vfd_swmr_config.max_lag); -#endif - if (!entering_api) { + if (!entering_api) H5FD_vfd_swmr_record_elapsed_ticks(shared->lf, tmp_tick_num - shared->tick_num); - } if (tmp_tick_num != shared->tick_num) { const H5FD_vfd_swmr_idx_entry_t *new_mdf_idx; @@ -1239,11 +1145,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) mdf_idx_entries_used = shared->mdf_idx_len; -#if 0 /* JRM */ - HDfprintf(stderr, "--- reader EOT mdf_idx_entries_used = %d ---\n", - mdf_idx_entries_used); -#endif /* JRM */ - if (H5FD_vfd_swmr_get_tick_and_idx(file, FALSE, NULL, &mdf_idx_entries_used, shared->mdf_idx) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver"); @@ -1251,18 +1152,12 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) shared->mdf_idx_entries_used = mdf_idx_entries_used; -#if 0 /* JRM */ - HDfprintf(stderr, - "--- reader EOT index used / len = %" PRIu32 "/%" PRIu32 " ---\n", - shared->mdf_idx_entries_used, shared->mdf_idx_len); -#endif /* JRM */ - new_mdf_idx = shared->mdf_idx; old_mdf_idx = shared->old_mdf_idx; new_mdf_idx_entries_used = shared->mdf_idx_entries_used; old_mdf_idx_entries_used = shared->old_mdf_idx_entries_used; - change = malloc(sizeof(change[0]) * (old_mdf_idx_entries_used + new_mdf_idx_entries_used)); + change = HDmalloc(sizeof(change[0]) * (old_mdf_idx_entries_used + new_mdf_idx_entries_used)); if (change == NULL) { HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate removed pages list"); @@ -1296,13 +1191,7 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) * extension could overlap with a second entry. */ - /* JRM review this */ - /* Kent: need to comment out the line to make reader iterate - * a large number of groups - * */ -#if 0 /*Kent*/ - HDassert(oent->length == nent->length); -#endif + /* TODO: review this */ /* This is a bug uncovered by issue #1 of the * group test failures. See Kent's documentation * "Designed to Fail Tests and Issues". @@ -1386,11 +1275,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) } } -#if 0 /* JRM */ - HDfprintf(stderr, "--- reader EOT pre new tick index " - "used/len = %" PRIu32 "/ %" PRIu32 " ---\n", - shared->mdf_idx_entries_used, shared->mdf_idx_len); -#endif /* JRM */ shared->max_jump_ticks = MAX(shared->max_jump_ticks, (tmp_tick_num - shared->tick_num)); /* At this point, we should have evicted or refreshed all stale @@ -1400,8 +1284,6 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) */ shared->tick_num = tmp_tick_num; - vfd_swmr_reader_did_increase_tick_to(tmp_tick_num); - /* Update end_of_tick */ if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(shared, FALSE) < 0) { HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update end of tick"); @@ -1409,29 +1291,37 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) } /* Remove the entry from the EOT queue */ - if (H5F_vfd_swmr_remove_entry_eot(f) < 0) { + if (H5F_vfd_swmr_remove_entry_eot(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") - } /* Re-insert the entry that corresponds to f onto the EOT queue */ - if (H5F_vfd_swmr_insert_entry_eot(f) < 0) { + if (H5F_vfd_swmr_insert_entry_eot(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") - } done: if (change != NULL) - free(change); + HDfree(change); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_vfd_swmr_reader_end_of_tick() */ +/*------------------------------------------------------------------------- + * Function: H5F__vfd_swmr_insert_eot_entry + * + * Purpose: Insert an entry in the EOT queue + * + * Return: void + *------------------------------------------------------------------------- + */ static void -insert_eot_entry(eot_queue_entry_t *entry_ptr) +H5F__vfd_swmr_insert_eot_entry(eot_queue_entry_t *entry_ptr) { eot_queue_entry_t *prec_ptr; /* The predecessor entry on the EOT end of tick queue */ + FUNC_ENTER_STATIC_NOERR + /* Find the insertion point for the entry on the EOT queue */ TAILQ_FOREACH_REVERSE(prec_ptr, &eot_queue_g, eot_queue, link) { @@ -1444,9 +1334,17 @@ insert_eot_entry(eot_queue_entry_t *entry_ptr) TAILQ_INSERT_AFTER(&eot_queue_g, prec_ptr, entry_ptr, link); else TAILQ_INSERT_HEAD(&eot_queue_g, entry_ptr, link); -} -/* Update an entry on the EOT queue and move it to its proper place. + FUNC_LEAVE_NOAPI_VOID +} /* end H5F__vfd_swmr_insert_eot_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5F_vfd_swmr_update_entry_eot + * + * Purpose: Update an entry on the EOT queue and move it to its proper place + * + * Return: void + *------------------------------------------------------------------------- */ void H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *entry) @@ -1454,6 +1352,8 @@ H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *entry) H5F_t * f = entry->vfd_swmr_file; H5F_shared_t *shared = f->shared; + FUNC_ENTER_NOAPI_NOERR + /* Free the entry on the EOT queue that corresponds to f */ TAILQ_REMOVE(&eot_queue_g, entry, link); @@ -1462,20 +1362,17 @@ H5F_vfd_swmr_update_entry_eot(eot_queue_entry_t *entry) entry->tick_num = shared->tick_num; entry->end_of_tick = shared->end_of_tick; - insert_eot_entry(entry); -} + H5F__vfd_swmr_insert_eot_entry(entry); + + FUNC_LEAVE_NOAPI_VOID +} /* end H5F_vfd_swmr_update_entry_eot() */ /*------------------------------------------------------------------------- - * * Function: H5F__vfd_swmr_remove_entry_eot * * Purpose: Remove an entry from the EOT queue * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 11/18/2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1499,19 +1396,14 @@ H5F_vfd_swmr_remove_entry_eot(H5F_t *f) } FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5F_vfd_swmr_remove_entry_eot() */ +} /* end H5F_vfd_swmr_remove_entry_eot() */ /*------------------------------------------------------------------------- - * * Function: H5F_vfd_swmr_insert_entry_eot * * Purpose: Insert an entry onto the EOT queue * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 11/18/2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1533,24 +1425,18 @@ H5F_vfd_swmr_insert_entry_eot(H5F_t *f) entry_ptr->end_of_tick = shared->end_of_tick; entry_ptr->vfd_swmr_file = f; - insert_eot_entry(entry_ptr); + H5F__vfd_swmr_insert_eot_entry(entry_ptr); done: FUNC_LEAVE_NOAPI(ret_value) - -} /* H5F_vfd_swmr_insert_entry_eot() */ +} /* end H5F_vfd_swmr_insert_entry_eot() */ /*------------------------------------------------------------------------- - * * Function: H5F_dump_eot_queue() * * Purpose: Dump the contents of the EOT queue * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 11/18/2019 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1571,27 +1457,15 @@ H5F_dump_eot_queue(void) HDfprintf(stderr, "EOT head is null\n"); FUNC_LEAVE_NOAPI(SUCCEED) - -} /* H5F_dump_eot_queue() */ - -/* - * Beginning of static functions - */ +} /* end H5F_dump_eot_queue() */ /*------------------------------------------------------------------------- - * * Function: H5F__vfd_swmr_update_end_of_tick_and_tick_num * * Purpose: Update end_of_tick (shared->end_of_tick) * Update tick_num (shared->tick_num) * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 11/??/18 - * - * Changes: None. - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -1608,7 +1482,7 @@ H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, hbool_t incr /* Get current time in struct timespec */ #ifdef H5_HAVE_WIN32_API - if (timespec_get(&curr, TIME_UTC) != TIME_UTC) + if (HDtimespec_get(&curr, TIME_UTC) != TIME_UTC) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get"); #else if (HDclock_gettime(CLOCK_MONOTONIC, &curr) < 0) { @@ -1617,20 +1491,17 @@ H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, hbool_t incr #endif /* Convert curr to nsecs */ - curr_nsecs = curr.tv_sec * nanosecs_per_second + curr.tv_nsec; + curr_nsecs = curr.tv_sec * NANOSECS_PER_SECOND + curr.tv_nsec; /* Convert tick_len to nanosecs */ - tlen_nsecs = shared->vfd_swmr_config.tick_len * nanosecs_per_tenth_sec; + tlen_nsecs = shared->vfd_swmr_config.tick_len * NANOSECS_PER_TENTH_SEC; - /* - * Update shared->tick_num - */ + /* Update shared->tick_num */ if (incr_tick_num) { shared->tick_num++; if (H5PB_vfd_swmr__set_tick(shared) < 0) - HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "Can't update page buffer current tick") } @@ -1641,13 +1512,11 @@ H5F__vfd_swmr_update_end_of_tick_and_tick_num(H5F_shared_t *shared, hbool_t incr /* TODO: The modulo operation is very expensive on most machines -- * re-work this code so as to avoid it. - * - * JRM -- 11/12/18 */ new_end_nsecs = curr_nsecs + tlen_nsecs; - new_end_of_tick.tv_nsec = (long)(new_end_nsecs % nanosecs_per_second); - new_end_of_tick.tv_sec = new_end_nsecs / nanosecs_per_second; + new_end_of_tick.tv_nsec = (long)(new_end_nsecs % NANOSECS_PER_SECOND); + new_end_of_tick.tv_sec = new_end_nsecs / NANOSECS_PER_SECOND; shared->end_of_tick = new_end_of_tick; @@ -1658,7 +1527,6 @@ done: } /* H5F__vfd_swmr_update_end_of_tick_and_tick_num() */ /*------------------------------------------------------------------------- - * * Function: H5F__vfd_swmr_construct_write_md_hdr * * Purpose: Encode and write header to the metadata file. @@ -1670,13 +1538,7 @@ done: * --after flushing an HDF5 file * --when updating the metadata file * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 11/??/18 - * - * Changes: None. - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -1691,9 +1553,7 @@ H5F__vfd_swmr_construct_write_md_hdr(H5F_shared_t *shared, uint32_t num_entries, FUNC_ENTER_STATIC - /* - * Encode metadata file header - */ + /* Encode metadata file header */ p = image; /* Encode magic for header */ @@ -1718,24 +1578,20 @@ H5F__vfd_swmr_construct_write_md_hdr(H5F_shared_t *shared, uint32_t num_entries, if (shared->vfd_swmr_config.maintain_metadata_file) { /* Set to beginning of the file */ if (HDlseek(shared->vfd_swmr_md_fd, H5FD_MD_HEADER_OFF, SEEK_SET) < 0) - HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") nwritten = HDwrite(shared->vfd_swmr_md_fd, image, hdr_size); + /* Write header to the metadata file */ - if (nwritten != (ssize_t)hdr_size) { + if (nwritten != (ssize_t)hdr_size) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing header to metadata file") - } } done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5F__vfd_swmr_construct_write_md_hdr() */ /*------------------------------------------------------------------------- - * Function: H5F__vfd_swmr_construct_write_md_idx * * Purpose: Encode and write index to the metadata file. @@ -1747,13 +1603,7 @@ done: * --after flushing an HDF5 file * --when updating the metadata file * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 11/??/18 - * - * Changes: None. - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -1772,9 +1622,7 @@ H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *shared, uint32_t num_entries, HDassert(num_entries == 0 || index != NULL); - /* - * Encode metadata file index - */ + /* Encode metadata file index */ p = image; /* Encode magic for index */ @@ -1813,27 +1661,24 @@ H5F__vfd_swmr_construct_write_md_idx(H5F_shared_t *shared, uint32_t num_entries, HGOTO_ERROR(H5E_VFL, H5E_SEEKERROR, FAIL, "unable to seek in metadata file") nwritten = HDwrite(shared->vfd_swmr_md_fd, image, idx_size); + /* Write index to the metadata file */ - if (nwritten != (ssize_t)idx_size) { + if (nwritten != (ssize_t)idx_size) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing index to metadata file") - } } done: - FUNC_LEAVE_NOAPI(ret_value) - -} /* H5F__vfd_swmr_construct_write_idx() */ +} /* end H5F__vfd_swmr_construct_write_idx() */ /*------------------------------------------------------------------------- - * Function: H5F__idx_entry_cmp() - * - * Purpose: Callback used by HDqsort to sort entries in the index + * Function: H5F__idx_entry_cmp() * - * Return: 0 if the entries are the same - * -1 if entry1's offset is less than that of entry2 - * 1 if entry1's offset is greater than that of entry2 + * Purpose: Callback used by HDqsort to sort entries in the index * + * Return: 0 if the entries are the same + * -1 if entry1's offset is less than that of entry2 + * 1 if entry1's offset is greater than that of entry2 *------------------------------------------------------------------------- */ static herr_t @@ -1856,21 +1701,15 @@ H5F__idx_entry_cmp(const void *_entry1, const void *_entry2) ret_value = 1; FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__idx_entry_cmp() */ +} /* end H5F__idx_entry_cmp() */ /*------------------------------------------------------------------------- + * Function: H5F__vfd_swmr_create_index * - * Function: H5F__vfd_swmr_create_index - * - * Purpose: Allocate and initialize the index for the VFD SWMR metadata - * file. - * - * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer 11/5/18 - * - * Changes: None. + * Purpose: Allocate and initialize the index for the VFD SWMR metadata + * file. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -1898,29 +1737,37 @@ H5F__vfd_swmr_create_index(H5F_shared_t *shared) index = H5MM_calloc(entries_in_index * sizeof(index[0])); - if (index == NULL) { + if (index == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for md index") - } HDassert(entries_in_index <= UINT32_MAX); shared->mdf_idx = index; shared->mdf_idx_len = (uint32_t)entries_in_index; shared->mdf_idx_entries_used = 0; + done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5F__vfd_swmr_create_index() */ +/*------------------------------------------------------------------------- + * Function: H5F_vfd_swmr_enlarge_shadow_index + * + * Purpose: Enlarge the shadow index + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ H5FD_vfd_swmr_idx_entry_t * -vfd_swmr_enlarge_shadow_index(H5F_t *f) +H5F_vfd_swmr_enlarge_shadow_index(H5F_t *f) { - H5F_shared_t * shared = f->shared; - H5FD_vfd_swmr_idx_entry_t *ret_value = NULL; + H5F_shared_t * shared = f->shared; haddr_t idx_addr; haddr_t old_writer_index_offset; hsize_t idx_size; H5FD_vfd_swmr_idx_entry_t *new_mdf_idx = NULL, *old_mdf_idx; uint32_t new_mdf_idx_len, old_mdf_idx_len; + H5FD_vfd_swmr_idx_entry_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -1937,9 +1784,8 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) idx_addr = H5MV_alloc(f, idx_size); - if (idx_addr == HADDR_UNDEF) { + if (idx_addr == HADDR_UNDEF) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "shadow-file allocation failed for index") - } new_mdf_idx = H5MM_calloc(new_mdf_idx_len * sizeof(new_mdf_idx[0])); @@ -1972,35 +1818,30 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) * trade-off for simplicity. */ /* Fix: use the saved old_writer_index_offset not the current one */ - if (shadow_range_defer_free(shared, old_writer_index_offset, H5FD_MD_INDEX_SIZE(old_mdf_idx_len)) == -1) { + if (H5F__shadow_range_defer_free(shared, old_writer_index_offset, H5FD_MD_INDEX_SIZE(old_mdf_idx_len)) == + -1) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "could not schedule index reclamation"); } done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5F_vfd_swmr_enlarge_shadow_index() */ /*------------------------------------------------------------------------- + * Function: H5F__vfd_swmr_writer_wait_a_tick * - * Function: H5F__vfd_swmr_writer__wait_a_tick - * - * Purpose: Before a file that has been opened by a VFD SWMR writer, - * all pending delayed writes must be allowed drain. + * Purpose: Before a file that has been opened by a VFD SWMR writer, + * all pending delayed writes must be allowed drain. * - * This function facilitates this by sleeping for a tick, and - * then running the writer end of tick function. + * This function facilitates this by sleeping for a tick, and + * then running the writer end of tick function. * - * It should only be called as part the flush or close operations. - * - * Return: SUCCEED/FAIL - * - * Programmer: John Mainzer 11/23/18 - * - * Changes: None. + * It should only be called as part the flush or close operations. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t -H5F__vfd_swmr_writer__wait_a_tick(H5F_t *f) +H5F__vfd_swmr_writer_wait_a_tick(H5F_t *f) { uint64_t tick_in_nsec; H5F_shared_t *shared; @@ -2013,17 +1854,25 @@ H5F__vfd_swmr_writer__wait_a_tick(H5F_t *f) HDassert(shared->vfd_swmr); HDassert(shared->vfd_swmr_writer); - tick_in_nsec = shared->vfd_swmr_config.tick_len * nanosecs_per_tenth_sec; + tick_in_nsec = shared->vfd_swmr_config.tick_len * NANOSECS_PER_TENTH_SEC; H5_nanosleep(tick_in_nsec); - if (H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0) + if (H5F_vfd_swmr_writer_end_of_tick(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "H5F_vfd_swmr_writer_end_of_tick() failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__vfd_swmr_writer__wait_a_tick() */ +} /* H5F__vfd_swmr_writer_wait_a_tick() */ +/*------------------------------------------------------------------------- + * Function: H5F_vfd_swmr_process_eot_queue + * + * Purpose: Process end-of-tick queue + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ herr_t H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) { @@ -2040,12 +1889,11 @@ H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) H5F_shared_t *shared = f->shared; #ifdef H5_HAVE_WIN32_API - if (timespec_get(&now, TIME_UTC) != TIME_UTC) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get"); + if (HDtimespec_get(&now, TIME_UTC) != TIME_UTC) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via timespec_get") #else - if (HDclock_gettime(CLOCK_MONOTONIC, &now) < 0) { - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime"); - } + if (HDclock_gettime(CLOCK_MONOTONIC, &now) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get time via clock_gettime") #endif if (HDtimespeccmp(&now, &head->end_of_tick, <)) break; @@ -2059,21 +1907,20 @@ H5F_vfd_swmr_process_eot_queue(hbool_t entering_api) H5F_vfd_swmr_update_entry_eot(head); } else if (shared->vfd_swmr_writer) { - if (H5F_vfd_swmr_writer_end_of_tick(f, FALSE) < 0) - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR writer"); + if (H5F_vfd_swmr_writer_end_of_tick(f) < 0) + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR writer") } else if (H5F_vfd_swmr_reader_end_of_tick(f, entering_api) < 0) { - HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR reader"); + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR reader") } } while ((head = TAILQ_FIRST(&eot_queue_g)) != NULL && head != first_head); done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5F_vfd_swmr_process_eot_queue() */ /*------------------------------------------------------------------------- - * - * Function: H5F_post_vfd_swmr_log_entry + * Function: H5F__post_vfd_swmr_log_entry * * Purpose: Write the log information to the log file. * @@ -2083,22 +1930,22 @@ done: * log entry tag. * char *log_info IN: The information to be stored in the * log file. - * Return: None - * + * Return: void *------------------------------------------------------------------------- */ - void H5F__post_vfd_swmr_log_entry(H5F_t *f, int entry_type_code, const char *log_info) { double temp_time; H5_timevals_t current_time; - char * gettime_error; + char * gettime_error = NULL; - /* Obtain the current time. - If failed, write an error message to the log file. - else obtain the elapsed time in seconds since the log file - was created and write the time to the log file. */ + FUNC_ENTER_PACKAGE_NOERR + + /* Obtain the current time. If failed, write an error message to the log + * file, else obtain the elapsed time in seconds since the log file was + * created and write the time to the log file. + */ if (H5_timer_get_times(f->shared->vfd_swmr_log_start_time, ¤t_time) < 0) { if (NULL != (gettime_error = HDmalloc(log_err_mesg_length * sizeof(char)))) { HDsprintf(gettime_error, "gettime_error"); @@ -2112,22 +1959,16 @@ H5F__post_vfd_swmr_log_entry(H5F_t *f, int entry_type_code, const char *log_info HDfprintf(f->shared->vfd_swmr_log_file_ptr, log_fmt_str, H5Fvfd_swmr_log_tags[entry_type_code], temp_time, log_info); } - return; -} + + FUNC_LEAVE_NOAPI_VOID +} /* end H5F__post_vfd_swmr_log_entry() */ /*------------------------------------------------------------------------- - * * Function: H5F__vfd_swmr_construct_ud_hdr * * Purpose: Encode updater header in the buffer updater->header_image_ptr * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 10/2021 - * - * Changes: None. - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -2140,17 +1981,16 @@ H5F__vfd_swmr_construct_ud_hdr(H5F_vfd_swmr_updater_t *updater) FUNC_ENTER_STATIC_NOERR - /* - * Encode metadata file header - */ + /* Encode metadata file header */ p = image; /* Encode magic for header */ HDmemcpy(p, H5F_UD_HEADER_MAGIC, (size_t)H5_SIZEOF_MAGIC); p += H5_SIZEOF_MAGIC; - /* Encode version number, flags, page size, sequence number, tick number, change list offset, change list - * length */ + /* Encode version number, flags, page size, sequence number, tick number, + * change list offset, change list length + */ UINT16ENCODE(p, H5F_UD_VERSION); UINT16ENCODE(p, updater->flags); UINT32ENCODE(p, updater->page_size); @@ -2171,22 +2011,15 @@ H5F__vfd_swmr_construct_ud_hdr(H5F_vfd_swmr_updater_t *updater) FUNC_LEAVE_NOAPI(ret_value) -} /* H5F__vfd_swmr_construct_ud_hdr() */ +} /* end H5F__vfd_swmr_construct_ud_hdr() */ /*------------------------------------------------------------------------- - * * Function: H5F__vfd_swmr_construct_ud_cl * * Purpose: Encode updater change list in the buffer * updater->change_list_image_ptr * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi -- 10/2021 - * - * Changes: None. - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -2200,9 +2033,7 @@ H5F__vfd_swmr_construct_ud_cl(H5F_vfd_swmr_updater_t *updater) FUNC_ENTER_STATIC_NOERR - /* - * Encode ud cl - */ + /* Encode ud cl */ p = image; /* Encode magic for ud cl */ @@ -2262,37 +2093,14 @@ H5F__vfd_swmr_construct_ud_cl(H5F_vfd_swmr_updater_t *updater) HDassert(p - image == (ptrdiff_t)updater->change_list_len); FUNC_LEAVE_NOAPI(ret_value) - -} /* H5F__vfd_swmr_construct_ud_cl() */ +} /* end H5F__vfd_swmr_construct_ud_cl() */ /*------------------------------------------------------------------------- + * Function: H5F__generate_updater_file * - * Function: H5F_generate_updater_file() - * - * Purpose: Generate updater file: - * --assemble and initialize data in the updater struct - * --determine num_change_list entries - * --allocate buffers - * --construct on disk image (serialize) of the updater header and change list - * --create updater file using a temporary file name: - * --<shared->vfd_swmr_config.updater_file_path>.ud_tmp - * --allocate space and write the following to the updater file - * --updater file header - * --updater file change list - * --metadata entries - * --metadata file index - * --metadata file header - * --close the updater file - * --rename the updater file with the correct name: - * <shared->vfd_swmr_config.updater_file_path>.<shared->updater_seq_num> - * - * --increment shared->updater_seq_num - * --free buffers - * - * Return: SUCCEED/FAIL - * - * Programmer: Vailin Choi 8/24/2021 + * Purpose: Generate updater file * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -2308,9 +2116,10 @@ H5F__generate_updater_file(H5F_t *f, uint32_t num_entries, uint16_t flags, uint8 char newname[H5F__MAX_VFD_SWMR_FILE_NAME_LEN]; unsigned i, j; hsize_t alloc_size; + int sz; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Updater file header fields */ updater.version = H5F_UD_VERSION; @@ -2357,7 +2166,13 @@ H5F__generate_updater_file(H5F_t *f, uint32_t num_entries, uint16_t flags, uint8 } /* Create the updater file with a temporary file name */ - HDsprintf(namebuf, "%s.ud_tmp", shared->vfd_swmr_config.updater_file_path); + sz = HDsnprintf(namebuf, H5F__MAX_VFD_SWMR_FILE_NAME_LEN, "%s.ud_tmp", + shared->vfd_swmr_config.updater_file_path); + if (sz < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "error processing snprintf format string") + if (sz > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "string passed to snprintf would be truncated") + namebuf[H5F__MAX_VFD_SWMR_FILE_NAME_LEN - 1] = '\0'; if ((ud_file = H5FD_open(namebuf, H5F_ACC_TRUNC | H5F_ACC_RDWR | H5F_ACC_CREAT, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF)) == NULL) @@ -2485,7 +2300,13 @@ H5F__generate_updater_file(H5F_t *f, uint32_t num_entries, uint16_t flags, uint8 /* Close the updater file and rename the file */ if (H5FD_close(ud_file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close updater file") - HDsprintf(newname, "%s.%lu", shared->vfd_swmr_config.updater_file_path, shared->updater_seq_num); + sz = HDsnprintf(newname, H5F__MAX_VFD_SWMR_FILE_NAME_LEN, "%s.%lu", + shared->vfd_swmr_config.updater_file_path, shared->updater_seq_num); + if (sz < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "error processing snprintf format string") + if (sz > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "string passed to snprintf would be truncated") + newname[H5F__MAX_VFD_SWMR_FILE_NAME_LEN - 1] = '\0'; HDrename(namebuf, newname); ++shared->updater_seq_num; @@ -2499,5 +2320,143 @@ done: HDfree(updater.change_list); FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__generate_updater_file() */ + +/*------------------------------------------------------------------------- + * Function: H5F__vfd_swmr_end_tick() + * + * Purpose: To trigger end of tick processing + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5F__vfd_swmr_end_tick(H5F_t *f) +{ + eot_queue_entry_t *curr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + + /* The file should be opened with VFD SWMR configured.*/ + if (!(H5F_USE_VFD_SWMR(f))) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") + + /* Search EOT queue */ + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == f) + break; + } + + /* If the file does not exist on the EOT queue, flag an error */ + if (curr == NULL) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has been disabled") + + if (f->shared->vfd_swmr_writer) { + if (H5F_vfd_swmr_writer_end_of_tick(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR writer") + } + else if (H5F_vfd_swmr_reader_end_of_tick(f, TRUE) < 0) { + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "end of tick error for VFD SWMR reader") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F__vfd_swmr_end_tick() */ + +/*------------------------------------------------------------------------- + * Function: H5F__vfd_swmr_disable_end_of_tick() + * + * Purpose: To disable end of tick processing + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5F__vfd_swmr_disable_end_of_tick(H5F_t *f) +{ + eot_queue_entry_t *curr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + + /* The file should be opened with VFD SWMR configured.*/ + if (!(H5F_USE_VFD_SWMR(f))) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") + + /* Search EOT queue */ + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == f) + break; + } + + /* If the file does not exist on the EOT queue, flag an error */ + if (curr == NULL) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has already been disabled") + + /* Remove the entry that corresponds to "f" from the EOT queue */ + if (H5F_vfd_swmr_remove_entry_eot(f) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F__vfd_swmr_disable_end_of_tick() */ + +/*------------------------------------------------------------------------- + * Function: H5F__vfd_swmr_enable_end_of_tick() + * + * Purpose: To enable end of tick processing + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5F__vfd_swmr_enable_end_of_tick(H5F_t *f) +{ + eot_queue_entry_t *curr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + + /* The file should be opened with VFD SWMR configured.*/ + if (!(H5F_USE_VFD_SWMR(f))) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine") -} /* H5F__generate_updater_file() */ + /* Search EOT queue */ + TAILQ_FOREACH(curr, &eot_queue_g, link) + { + if (curr->vfd_swmr_file == f) + break; + } + + /* If the file already exists on the EOT queue, flag an error */ + if (curr != NULL) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "EOT for the file has already been enabled") + + /* Insert the entry that corresponds to "f" onto the EOT queue */ + if (H5F_vfd_swmr_insert_entry_eot(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue") + + /* Check if the tick has expired, if so call end of tick processing */ + if (H5F_vfd_swmr_process_eot_queue(TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "error processing EOT queue") + + /* FUNC_LEAVE_API could do the check, but not so for reader_end_of_tick() */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F__vfd_swmr_enable_end_of_tick() */ @@ -129,7 +129,7 @@ H5HG__create(H5F_t *f, size_t size) size_t n; haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__GLOBALHEAP_TAG) + FUNC_ENTER_STATIC /* Check args */ HDassert(f); @@ -218,7 +218,7 @@ done: } /* end if */ } /* end if */ - FUNC_LEAVE_NOAPI_TAG(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5HG__create() */ /*------------------------------------------------------------------------- @@ -445,7 +445,7 @@ H5MF__create_fstype(H5F_t *f, H5F_mem_page_t type) H5AC_ring_t fsm_ring; /* Ring of FSM */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC /* * Check arguments. @@ -498,7 +498,7 @@ done: if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__create_fstype() */ /*------------------------------------------------------------------------- @@ -520,7 +520,7 @@ H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -547,7 +547,7 @@ H5MF__start_fstype(H5F_t *f, H5F_mem_page_t type) } /* end else */ done: - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__start_fstype() */ /*------------------------------------------------------------------------- @@ -571,7 +571,7 @@ H5MF__delete_fstype(H5F_t *f, H5F_mem_page_t type) haddr_t tmp_fs_addr; /* Temporary holder for free space manager address */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC /* check args */ HDassert(f); @@ -618,7 +618,7 @@ done: if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__delete_fstype() */ /*------------------------------------------------------------------------- @@ -639,7 +639,7 @@ H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC /* * Check arguments. @@ -664,7 +664,7 @@ H5MF__close_fstype(H5F_t *f, H5F_mem_page_t type) f->shared->fs_state[type] = H5F_FS_STATE_CLOSED; done: - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_fstype() */ /*------------------------------------------------------------------------- @@ -688,7 +688,7 @@ H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_sectio H5F_mem_page_t fs_type; /* Free space type (mapped from allocation type) */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_PACKAGE HDassert(f); HDassert(fspace); @@ -724,7 +724,7 @@ done: if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__add_sect() */ /*------------------------------------------------------------------------- @@ -748,7 +748,7 @@ H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, h H5MF_free_section_t *node; /* Free space section pointer */ htri_t ret_value = FAIL; /* Whether an existing free list node was found */ - FUNC_ENTER_PACKAGE_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_PACKAGE HDassert(f); HDassert(fspace); @@ -808,7 +808,7 @@ done: if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__find_sect() */ /*------------------------------------------------------------------------- @@ -953,7 +953,7 @@ H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) H5MF_free_section_t *node = NULL; /* Free space section pointer */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: alloc_type = %u, size = %" PRIuHSIZE "\n", __func__, (unsigned)alloc_type, size); @@ -1065,7 +1065,7 @@ done: if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free section node") - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__alloc_pagefs() */ /*------------------------------------------------------------------------- @@ -1720,7 +1720,7 @@ H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Entering\n", __func__); #endif /* H5MF_ALLOC_DEBUG */ @@ -1759,7 +1759,7 @@ done: #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Leaving\n", __func__); #endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* H5MF__close_delete() */ /*------------------------------------------------------------------------- @@ -1891,7 +1891,7 @@ H5MF__close_aggrfs(H5F_t *f) H5FD_mem_t type; /* Memory type for iteration */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Entering\n", __func__); #endif /* H5MF_ALLOC_DEBUG */ @@ -2033,7 +2033,7 @@ done: #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Leaving\n", __func__); #endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_aggrfs() */ /*------------------------------------------------------------------------- @@ -2057,7 +2057,7 @@ H5MF__close_pagefs(H5F_t *f) H5O_fsinfo_t fsinfo; /* File space info message */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Entering\n", __func__); #endif /* H5MF_ALLOC_DEBUG */ @@ -2208,7 +2208,7 @@ done: #ifdef H5MF_ALLOC_DEBUG HDfprintf(stderr, "%s: Leaving\n", __func__); #endif /* H5MF_ALLOC_DEBUG */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_pagefs() */ /*------------------------------------------------------------------------- @@ -2236,7 +2236,7 @@ H5MF__close_shrink_eoa(H5F_t *f) H5MF_sect_ud_t udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__FREESPACE_TAG) + FUNC_ENTER_STATIC /* check args */ HDassert(f); @@ -2317,7 +2317,7 @@ done: if (orig_ring != H5AC_RING_INV) H5AC_set_ring(orig_ring, NULL); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__close_shrink_eoa() */ /*------------------------------------------------------------------------- diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index c4f8b27..b83b57e 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1679,7 +1679,7 @@ H5O__attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE_TAG(oh->cache_info.addr) + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -1712,7 +1712,7 @@ H5O__attr_count_real(H5F_t *f, H5O_t *oh, hsize_t *nattrs) } /* end else */ done: - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_count_real */ /*------------------------------------------------------------------------- diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 84e68a1..ccaf004 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -348,7 +348,7 @@ H5O__cache_deserialize(const void *image, size_t len, void *_udata, hbool_t *dir done: /* Release the [possibly partially initialized] object header on errors */ if (!ret_value && oh) - if (H5O__free(oh) < 0) + if (H5O__free(oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) @@ -641,7 +641,7 @@ H5O__cache_free_icr(void *_thing) HDassert(oh->cache_info.type == H5AC_OHDR); /* Destroy object header */ - if (H5O__free(oh) < 0) + if (H5O__free(oh, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") done: @@ -1244,7 +1244,7 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) /* Save the object header for later use in 'deserialize' callback */ udata->oh = oh; - if (H5O__free(saved_oh) < 0) + if (H5O__free(saved_oh, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") udata->free_oh = FALSE; } @@ -1257,7 +1257,7 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) done: /* Release the [possibly partially initialized] object header on errors */ if (ret_value < 0 && oh) - if (H5O__free(oh) < 0) + if (H5O__free(oh, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header data") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 8367b93..0b0bb55 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -771,7 +771,7 @@ done: /* Free destination object header on failure */ if (ret_value < 0) { if (oh_dst && !inserted) { - if (H5O__free(oh_dst) < 0) + if (H5O__free(oh_dst, TRUE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") if (H5O_loc_reset(oloc_dst) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") diff --git a/src/H5Oflush.c b/src/H5Oflush.c index f2eacd6..ba1fa3e 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -239,7 +239,7 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) case H5I_DATASET: ds = (H5D_t *)vol_obj->data; state.dapl_id = ds->shared->dapl_id; - if (H5I_inc_ref(state.dapl_id, false) < 0) + if (H5I_inc_ref(state.dapl_id, FALSE) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not increase refcnt"); break; default: @@ -405,6 +405,7 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, const H5O_refresh_sta break; case H5I_DATASET: + /* Re-open the dataset */ object = H5D_open(obj_loc, (state == NULL) ? H5P_DATASET_ACCESS_DEFAULT : state->dapl_id); if (NULL == object) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") diff --git a/src/H5Oint.c b/src/H5Oint.c index ee79b0c..2348790 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -289,7 +289,7 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't apply object header to file") done: - if ((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + if ((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh, TRUE) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "can't delete object header") FUNC_LEAVE_NOAPI(ret_value) @@ -353,7 +353,7 @@ H5O_create_ohdr(H5F_t *f, hid_t ocpl_id) ret_value = oh; done: - if ((NULL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + if ((NULL == ret_value) && (NULL != oh) && (H5O__free(oh, TRUE) < 0)) HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "can't delete object header") FUNC_LEAVE_NOAPI(ret_value) @@ -3014,7 +3014,7 @@ H5O_get_proxy(const H5O_t *oh) *------------------------------------------------------------------------- */ herr_t -H5O__free(H5O_t *oh) +H5O__free(H5O_t *oh, hbool_t force) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3038,10 +3038,12 @@ H5O__free(H5O_t *oh) for (u = 0; u < oh->nmesgs; u++) { #ifndef NDEBUG /* Verify that message is clean, unless it could have been marked - * dirty by decoding */ + * dirty by decoding, or if this is a forced free (in case of + * failure during creation of the object some messages may be dirty) + */ if (oh->ndecode_dirtied && oh->mesg[u].dirty) oh->ndecode_dirtied--; - else + else if (!force) HDassert(oh->mesg[u].dirty == 0); #endif /* NDEBUG */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index ebfe636..1fe918d 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -551,7 +551,7 @@ H5_DLL herr_t H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_ty H5O_iterate2_t op, void *op_data, unsigned fields); H5_DLL herr_t H5O__inc_rc(H5O_t *oh); H5_DLL herr_t H5O__dec_rc(H5O_t *oh); -H5_DLL herr_t H5O__free(H5O_t *oh); +H5_DLL herr_t H5O__free(H5O_t *oh, hbool_t force); /* Object header message routines */ H5_DLL herr_t H5O__msg_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned *mesg_flags, @@ -50,14 +50,14 @@ /* Round _x down to nearest _size. */ /* not used at present */ /* -#ifndef rounddown -#define rounddown(_x, _size) (((_x) / (_size)) * (_size)) +#ifndef H5PB_ROUNDDOWN +#define H5PB_ROUNDDOWN(_x, _size) (((_x) / (_size)) * (_size)) #endif */ /* Round _x up to nearest _size. */ -#ifndef roundup -#define roundup(_x, _size) ((((_x) + (_size)-1) / (_size)) * (_size)) +#ifndef H5PB_ROUNDUP +#define H5PB_ROUNDUP(_x, _size) ((((_x) + (_size)-1) / (_size)) * (_size)) #endif /******************/ @@ -1358,18 +1358,18 @@ done: * this routine performs an O(n) copy of index entries. */ static int -shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) +H5PB__shadow_idx_entry_remove(H5F_shared_t *shared, uint64_t page, hbool_t only_mark) { ptrdiff_t i; H5FD_vfd_swmr_idx_entry_t *entry; - entry = vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, FALSE); + entry = H5FD_vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, FALSE); if (entry == NULL) return 0; if (shared->vfd_swmr_writer && entry->md_file_page_offset != 0) { - if (shadow_image_defer_free(shared, entry) != 0) + if (H5F_shadow_image_defer_free(shared, entry) != 0) return -1; entry->md_file_page_offset = 0; } @@ -1492,8 +1492,8 @@ H5PB_remove_entry(H5F_shared_t *shared, haddr_t addr) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "forced eviction failed") HDassert(!shared->vfd_swmr_writer || - vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, - FALSE) == NULL); + H5FD_vfd_swmr_pageno_to_mdf_idx_entry(shared->mdf_idx, shared->mdf_idx_entries_used, page, + FALSE) == NULL); } done: @@ -2098,7 +2098,7 @@ H5PB_vfd_swmr__update_index(H5F_t *f, uint32_t *idx_ent_added_ptr, uint32_t *idx /* see if the shadow index already contains an entry for *entry. */ - ie_ptr = vfd_swmr_pageno_to_mdf_idx_entry(idx, shared->mdf_idx_entries_used, target_page, FALSE); + ie_ptr = H5FD_vfd_swmr_pageno_to_mdf_idx_entry(idx, shared->mdf_idx_entries_used, target_page, FALSE); if (ie_ptr == NULL) { /* alloc new entry in the metadata file index*/ uint32_t new_index_entry_index; @@ -2106,7 +2106,7 @@ H5PB_vfd_swmr__update_index(H5F_t *f, uint32_t *idx_ent_added_ptr, uint32_t *idx new_index_entry_index = shared->mdf_idx_entries_used + idx_ent_added++; if (new_index_entry_index >= shared->mdf_idx_len && - (idx = vfd_swmr_enlarge_shadow_index(f)) == NULL) { + (idx = H5F_vfd_swmr_enlarge_shadow_index(f)) == NULL) { HDfprintf(stderr, "\n\nmax mdf index len (%" PRIu32 ") exceeded.\n\n", shared->mdf_idx_len); HDfprintf(stderr, "tick = %" PRIu64 ".\n", tick_num); HDexit(EXIT_FAILURE); @@ -2136,7 +2136,7 @@ H5PB_vfd_swmr__update_index(H5F_t *f, uint32_t *idx_ent_added_ptr, uint32_t *idx if (ie_ptr->length != (uint32_t)entry->size) { int ret; - ret = shadow_image_defer_free(shared, ie_ptr); + ret = H5F_shadow_image_defer_free(shared, ie_ptr); HDassert(ret == 0); ie_ptr->md_file_page_offset = 0; @@ -2714,7 +2714,7 @@ H5PB__allocate_page(H5PB_t *page_buf, size_t size, hbool_t clean_image) void * image_ptr = NULL; H5PB_entry_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_STATIC /* sanity checks */ HDassert(page_buf); @@ -2786,7 +2786,7 @@ done: image_ptr = H5MM_xfree(image_ptr); } - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) @@ -2922,7 +2922,7 @@ done: static void H5PB__deallocate_page(H5PB_entry_t *entry_ptr) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* sanity checks */ HDassert(entry_ptr); @@ -2989,7 +2989,7 @@ H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, H5PB_t *page_buf = shared->page_buf; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* sanity checks */ HDassert(page_buf); @@ -3063,7 +3063,7 @@ H5PB__evict_entry(H5F_shared_t *shared, H5PB_entry_t *entry_ptr, hbool_t force, * the image will be bigger. So the shadow file will never see the * entire image written, just the first page of the image. */ - if (shared->vfd_swmr_writer && shadow_idx_entry_remove(shared, entry_ptr->page, only_mark) == -1) { + if (shared->vfd_swmr_writer && H5PB__shadow_idx_entry_remove(shared, entry_ptr->page, only_mark) == -1) { HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "failed to remove shadow index entry") } @@ -3108,7 +3108,7 @@ H5PB__flush_entry(H5F_shared_t *shared, H5PB_t *page_buf, H5PB_entry_t *const en haddr_t eoa; /* Current EOA for the file */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* sanity checks */ HDassert(shared); @@ -3215,7 +3215,7 @@ H5PB__load_page(H5F_shared_t *shared, H5PB_t *page_buf, haddr_t addr, H5FD_mem_t void * image_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* sanity checks */ HDassert(shared); @@ -3224,18 +3224,6 @@ H5PB__load_page(H5F_shared_t *shared, H5PB_t *page_buf, haddr_t addr, H5FD_mem_t HDassert(page_buf->magic == H5PB__H5PB_T_MAGIC); HDassert((entry_ptr_ptr == NULL) || (*entry_ptr_ptr == NULL)); -#if 0 /* JRM */ - haddr_t eoa; - /* Retrieve the 'eoa' for the file */ - if ( HADDR_UNDEF == (eoa = H5FD_get_eoa(shared->lf, type))) - - HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, \ - "driver get_eoa request failed") - if ( addr + ((haddr_t)(page_buf->page_size)) > eoa ) - - HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, \ - "Attempt to load page that extends past EOA") -#endif /* JRM */ if (HADDR_UNDEF == (eof = H5FD_get_eof(shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTGET, FAIL, "driver get_eof request failed") @@ -3384,7 +3372,7 @@ H5PB__make_space(H5F_shared_t *shared, H5PB_t *page_buf, H5FD_mem_t inserted_typ H5PB_entry_t *evict_ptr; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* sanity checks */ HDassert(page_buf); @@ -3498,7 +3486,7 @@ H5PB__mark_entry_clean(H5PB_t *page_buf, H5PB_entry_t *entry_ptr) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* sanity checks */ HDassert(page_buf); @@ -3558,7 +3546,7 @@ H5PB__mark_entry_dirty(H5F_shared_t *shared, H5PB_t *page_buf, H5PB_entry_t *ent { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* sanity checks */ HDassert(page_buf); @@ -3582,7 +3570,7 @@ H5PB__mark_entry_dirty(H5F_shared_t *shared, H5PB_t *page_buf, H5PB_entry_t *ent HDassert(entry_ptr->delay_write_until == 0); if ((page_buf->vfd_swmr_writer) && (entry_ptr->loaded) && (entry_ptr->mem_type != H5FD_MEM_DRAW) && - (H5F_vfd_swmr_writer__delay_write(shared, entry_ptr->page, &(entry_ptr->delay_write_until)) < 0)) + (H5F_vfd_swmr_writer_delay_write(shared, entry_ptr->page, &(entry_ptr->delay_write_until)) < 0)) HGOTO_ERROR(H5E_PAGEBUF, H5E_SYSTEM, FAIL, "get delayed write request failed") @@ -3774,7 +3762,7 @@ H5PB__read_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size size_t clipped_size; /* possibley clipped size */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(shared); @@ -4082,7 +4070,7 @@ H5PB__read_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size, hsize_t i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(shared); @@ -4375,7 +4363,7 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t siz size_t offset; /* offset of write in page */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(shared); @@ -4432,7 +4420,7 @@ H5PB__write_meta(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t siz H5PB_entry_t *overlap; void * new_image = H5MM_malloc(size); uint64_t iter_page; - uint64_t last_page = page + roundup(size, page_buf->page_size) / page_buf->page_size; + uint64_t last_page = page + H5PB_ROUNDUP(size, page_buf->page_size) / page_buf->page_size; for (iter_page = page + 1; iter_page < last_page; iter_page++) { H5PB__SEARCH_INDEX(page_buf, iter_page, overlap, FAIL) @@ -4592,7 +4580,7 @@ H5PB__write_raw(H5F_shared_t *shared, H5FD_mem_t type, haddr_t addr, size_t size size_t offset; /* offset of write in a page */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(shared); diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 65d426b..a9f21d1 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1290,8 +1290,8 @@ H5P_set_driver_by_name(H5P_genplist_t *plist, const char *driver_name, const cha FUNC_ENTER_NOAPI(FAIL) - assert(plist); - assert(driver_name); + HDassert(plist); + HDassert(driver_name); /* Register the driver */ if ((new_driver_id = H5FD_register_driver_by_name(driver_name, app_ref)) < 0) @@ -1378,8 +1378,8 @@ H5P_set_driver_by_value(H5P_genplist_t *plist, H5FD_class_value_t driver_value, FUNC_ENTER_NOAPI(FAIL) - assert(plist); - assert(driver_value >= 0); + HDassert(plist); + HDassert(driver_value >= 0); /* Register the driver */ if ((new_driver_id = H5FD_register_driver_by_value(driver_value, app_ref)) < 0) @@ -626,7 +626,7 @@ H5SM__create_list(H5F_t *f, H5SM_index_header_t *header) haddr_t addr = HADDR_UNDEF; /* Address of the list on disk */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC HDassert(f); HDassert(header); @@ -668,7 +668,7 @@ done: H5MF_xfree(f, H5FD_MEM_SOHM_INDEX, addr, (hsize_t)header->list_size); } /* end if */ - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__create_list */ /*------------------------------------------------------------------------- @@ -848,7 +848,7 @@ H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header) haddr_t btree_addr; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC /* Remember the address of the old B-tree, but change the header over to be * a list.. @@ -882,7 +882,7 @@ done: if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to unprotect SOHM index") - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__convert_btree_to_list() */ /*------------------------------------------------------------------------- @@ -1271,7 +1271,7 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t size_t empty_pos = SIZE_MAX; /* Empty entry in list */ herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(header); @@ -1535,7 +1535,7 @@ done: if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__write_mesg() */ /*------------------------------------------------------------------------- @@ -1782,7 +1782,7 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c unsigned type_id; /* Message type to operate on */ herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -1948,7 +1948,7 @@ done: *mesg_size = 0; } - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__delete_from_index() */ /*------------------------------------------------------------------------- @@ -2384,7 +2384,7 @@ H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, H5O_t *open_oh H5O_t * oh = NULL; /* Object header for message in object header */ herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC_TAG(H5AC__SOHM_TAG) + FUNC_ENTER_STATIC HDassert(f); HDassert(mesg); @@ -2458,7 +2458,7 @@ done: if (ret_value < 0 && udata.encoding_buf) udata.encoding_buf = H5MM_xfree(udata.encoding_buf); - FUNC_LEAVE_NOAPI_TAG(ret_value) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__read_mesg */ /*------------------------------------------------------------------------- @@ -192,10 +192,10 @@ H5TS_tid_destructor(void *_v) return; /* TBD use an atomic CAS */ - HDpthread_mutex_lock(&H5TS_tid_mtx); + pthread_mutex_lock(&H5TS_tid_mtx); tid->next = H5TS_tid_next_free; H5TS_tid_next_free = tid; - HDpthread_mutex_unlock(&H5TS_tid_mtx); + pthread_mutex_unlock(&H5TS_tid_mtx); } /*-------------------------------------------------------------------------- @@ -215,8 +215,8 @@ H5TS_tid_destructor(void *_v) static void H5TS_tid_init(void) { - HDpthread_mutex_init(&H5TS_tid_mtx, NULL); - HDpthread_key_create(&H5TS_tid_key, H5TS_tid_destructor); + pthread_mutex_init(&H5TS_tid_mtx, NULL); + pthread_key_create(&H5TS_tid_key, H5TS_tid_destructor); } /*-------------------------------------------------------------------------- @@ -246,7 +246,7 @@ H5TS_tid_init(void) uint64_t H5TS_thread_id(void) { - H5TS_tid_t *tid = HDpthread_getspecific(H5TS_tid_key); + H5TS_tid_t *tid = pthread_getspecific(H5TS_tid_key); H5TS_tid_t proto_tid; /* An ID is already assigned. */ @@ -260,14 +260,14 @@ H5TS_thread_id(void) * point `tid` at `proto_tid` if we need to allocate some * memory. */ - HDpthread_mutex_lock(&H5TS_tid_mtx); + pthread_mutex_lock(&H5TS_tid_mtx); if ((tid = H5TS_tid_next_free) != NULL) H5TS_tid_next_free = tid->next; else if (H5TS_tid_next_id != UINT64_MAX) { tid = &proto_tid; tid->id = ++H5TS_tid_next_id; } - HDpthread_mutex_unlock(&H5TS_tid_mtx); + pthread_mutex_unlock(&H5TS_tid_mtx); /* If a prototype ID record was established, copy it to the heap. */ if (tid == &proto_tid) @@ -281,7 +281,7 @@ H5TS_thread_id(void) * to it. */ tid->next = NULL; - if (HDpthread_setspecific(H5TS_tid_key, tid) != 0) { + if (pthread_setspecific(H5TS_tid_key, tid) != 0) { H5TS_tid_destructor(tid); return 0; } @@ -323,29 +323,29 @@ H5TS_pthread_first_thread_init(void) #endif /* initialize global API mutex lock */ - HDpthread_mutex_init(&H5_g.init_lock.atomic_lock, NULL); - HDpthread_cond_init(&H5_g.init_lock.cond_var, NULL); + pthread_mutex_init(&H5_g.init_lock.atomic_lock, NULL); + pthread_cond_init(&H5_g.init_lock.cond_var, NULL); H5_g.init_lock.lock_count = 0; - HDpthread_mutex_init(&H5_g.init_lock.atomic_lock2, NULL); + pthread_mutex_init(&H5_g.init_lock.atomic_lock2, NULL); H5_g.init_lock.attempt_lock_count = 0; /* Initialize integer thread identifiers. */ H5TS_tid_init(); /* initialize key for thread-specific error stacks */ - HDpthread_key_create(&H5TS_errstk_key_g, H5TS__key_destructor); + pthread_key_create(&H5TS_errstk_key_g, H5TS__key_destructor); #ifdef H5_HAVE_CODESTACK /* initialize key for thread-specific function stacks */ - HDpthread_key_create(&H5TS_funcstk_key_g, H5TS__key_destructor); + pthread_key_create(&H5TS_funcstk_key_g, H5TS__key_destructor); #endif /* H5_HAVE_CODESTACK */ /* initialize key for thread-specific API contexts */ - HDpthread_key_create(&H5TS_apictx_key_g, H5TS__key_destructor); + pthread_key_create(&H5TS_apictx_key_g, H5TS__key_destructor); /* initialize key for thread cancellability mechanism */ - HDpthread_key_create(&H5TS_cancel_key_s, H5TS__key_destructor); + pthread_key_create(&H5TS_cancel_key_s, H5TS__key_destructor); FUNC_LEAVE_NOAPI_VOID_NAMECHECK_ONLY } /* end H5TS_pthread_first_thread_init() */ @@ -380,13 +380,13 @@ H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, hbool_t *acqui *acquired = TRUE; #else /* H5_HAVE_WIN_THREADS */ /* Attempt to acquire the mutex lock */ - if (0 == HDpthread_mutex_lock(&mutex->atomic_lock)) { - pthread_t my_thread_id = HDpthread_self(); + if (0 == pthread_mutex_lock(&mutex->atomic_lock)) { + pthread_t my_thread_id = pthread_self(); /* Check if locked already */ if (mutex->lock_count) { /* Check for this thread already owning the lock */ - if (HDpthread_equal(my_thread_id, mutex->owner_thread)) { + if (pthread_equal(my_thread_id, mutex->owner_thread)) { /* Already owned by self - increment count */ mutex->lock_count += lock_count; *acquired = TRUE; @@ -401,7 +401,7 @@ H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, hbool_t *acqui *acquired = TRUE; } /* end else */ - if (0 != HDpthread_mutex_unlock(&mutex->atomic_lock)) + if (0 != pthread_mutex_unlock(&mutex->atomic_lock)) ret_value = -1; } /* end if */ else @@ -463,35 +463,35 @@ herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex) EnterCriticalSection(&mutex->CriticalSection); #else /* H5_HAVE_WIN_THREADS */ /* Acquire the "attempt" lock, increment the attempt lock count, release the lock */ - ret_value = HDpthread_mutex_lock(&mutex->atomic_lock2); + ret_value = pthread_mutex_lock(&mutex->atomic_lock2); if (ret_value) HGOTO_DONE(ret_value); mutex->attempt_lock_count++; - ret_value = HDpthread_mutex_unlock(&mutex->atomic_lock2); + ret_value = pthread_mutex_unlock(&mutex->atomic_lock2); if (ret_value) HGOTO_DONE(ret_value); /* Acquire the library lock */ - ret_value = HDpthread_mutex_lock(&mutex->atomic_lock); + ret_value = pthread_mutex_lock(&mutex->atomic_lock); if (ret_value) HGOTO_DONE(ret_value); /* Check if this thread already owns the lock */ - if (mutex->lock_count && HDpthread_equal(HDpthread_self(), mutex->owner_thread)) + if (mutex->lock_count && pthread_equal(pthread_self(), mutex->owner_thread)) /* already owned by self - increment count */ mutex->lock_count++; else { /* Wait until the lock is released by current owner thread */ while (mutex->lock_count) - HDpthread_cond_wait(&mutex->cond_var, &mutex->atomic_lock); + pthread_cond_wait(&mutex->cond_var, &mutex->atomic_lock); /* After we've received the signal, take ownership of the mutex */ - mutex->owner_thread = HDpthread_self(); + mutex->owner_thread = pthread_self(); mutex->lock_count = 1; } /* end else */ /* Release the library lock */ - ret_value = HDpthread_mutex_unlock(&mutex->atomic_lock); + ret_value = pthread_mutex_unlock(&mutex->atomic_lock); done: #endif /* H5_HAVE_WIN_THREADS */ @@ -530,12 +530,12 @@ H5TS__mutex_unlock(H5TS_mutex_t *mutex, unsigned int *lock_count) #else /* H5_HAVE_WIN_THREADS */ /* Reset the lock count for this thread */ - ret_value = HDpthread_mutex_lock(&mutex->atomic_lock); + ret_value = pthread_mutex_lock(&mutex->atomic_lock); if (ret_value) HGOTO_DONE(ret_value); *lock_count = mutex->lock_count; mutex->lock_count = 0; - ret_value = HDpthread_mutex_unlock(&mutex->atomic_lock); + ret_value = pthread_mutex_unlock(&mutex->atomic_lock); /* If the lock count drops to zero, signal the condition variable, to * wake another thread. @@ -543,7 +543,7 @@ H5TS__mutex_unlock(H5TS_mutex_t *mutex, unsigned int *lock_count) if (mutex->lock_count == 0) { int err; - err = HDpthread_cond_signal(&mutex->cond_var); + err = pthread_cond_signal(&mutex->cond_var); if (err != 0) ret_value = err; } /* end if */ @@ -586,11 +586,11 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) #else /* H5_HAVE_WIN_THREADS */ /* Decrement the lock count for this thread */ - ret_value = HDpthread_mutex_lock(&mutex->atomic_lock); + ret_value = pthread_mutex_lock(&mutex->atomic_lock); if (ret_value) HGOTO_DONE(ret_value); mutex->lock_count--; - ret_value = HDpthread_mutex_unlock(&mutex->atomic_lock); + ret_value = pthread_mutex_unlock(&mutex->atomic_lock); /* If the lock count drops to zero, signal the condition variable, to * wake another thread. @@ -598,7 +598,7 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) if (mutex->lock_count == 0) { int err; - err = HDpthread_cond_signal(&mutex->cond_var); + err = pthread_cond_signal(&mutex->cond_var); if (err != 0) ret_value = err; } /* end if */ @@ -630,13 +630,13 @@ H5TSmutex_get_attempt_count(unsigned int *count) #ifdef H5_HAVE_WIN_THREADS /* Add Win32 equivalent here when async is supported */ #else /* H5_HAVE_WIN_THREADS */ - ret_value = HDpthread_mutex_lock(&H5_g.init_lock.atomic_lock2); + ret_value = pthread_mutex_lock(&H5_g.init_lock.atomic_lock2); if (ret_value) HGOTO_DONE(ret_value); *count = H5_g.init_lock.attempt_lock_count; - ret_value = HDpthread_mutex_unlock(&H5_g.init_lock.atomic_lock2); + ret_value = pthread_mutex_unlock(&H5_g.init_lock.atomic_lock2); if (ret_value) HGOTO_DONE(ret_value); @@ -725,7 +725,7 @@ H5TS_cancel_count_inc(void) HGOTO_DONE(FAIL); /* Set the thread's cancellation counter with the new object */ - ret_value = HDpthread_setspecific(H5TS_cancel_key_s, (void *)cancel_counter); + ret_value = pthread_setspecific(H5TS_cancel_key_s, (void *)cancel_counter); if (ret_value) { HDfree(cancel_counter); HGOTO_DONE(FAIL); @@ -735,7 +735,7 @@ H5TS_cancel_count_inc(void) /* Check if thread entering library */ if (cancel_counter->cancel_count == 0) /* Set cancellation state to 'disable', and remember previous state */ - ret_value = HDpthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_counter->previous_state); + ret_value = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_counter->previous_state); /* Increment # of times the library API was re-entered, to avoid resetting * previous cancellation state until the final API routine is returning. @@ -788,7 +788,7 @@ H5TS_cancel_count_dec(void) /* Check for leaving last API routine */ if (cancel_counter->cancel_count == 1) /* Reset to previous thread cancellation state, if last API */ - ret_value = HDpthread_setcancelstate(cancel_counter->previous_state, NULL); + ret_value = pthread_setcancelstate(cancel_counter->previous_state, NULL); /* Decrement cancellation counter */ --cancel_counter->cancel_count; @@ -995,7 +995,7 @@ H5TS_create_thread(H5TS_thread_cb_t func, H5TS_attr_t *attr, void *udata) #else /* H5_HAVE_WIN_THREADS */ - HDpthread_create(&ret_value, attr, (void *(*)(void *))func, udata); + pthread_create(&ret_value, attr, (void *(*)(void *))func, udata); #endif /* H5_HAVE_WIN_THREADS */ diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 0d3bd0f..e773bae 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -393,8 +393,8 @@ static const unsigned char LogTable256[] = { static inline unsigned H5_ATTR_UNUSED H5VM_log2_gen(uint64_t n) { - unsigned r; /* r will be log2(n) */ - register unsigned int t, tt, ttt; /* temporaries */ + unsigned r; /* r will be log2(n) */ + unsigned int t, tt, ttt; /* temporaries */ if ((ttt = (unsigned)(n >> 32))) if ((tt = (unsigned)(n >> 48))) diff --git a/src/H5private.h b/src/H5private.h index da20a1b..bee2afc 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1164,57 +1164,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDprintf #define HDprintf printf /*varargs*/ #endif -#ifndef HDpthread_attr_destroy -#define HDpthread_attr_destroy(A) pthread_attr_destroy(A) -#endif -#ifndef HDpthread_attr_init -#define HDpthread_attr_init(A) pthread_attr_init(A) -#endif -#ifndef HDpthread_attr_setscope -#define HDpthread_attr_setscope(A, S) pthread_attr_setscope(A, S) -#endif -#ifndef HDpthread_cond_init -#define HDpthread_cond_init(C, A) pthread_cond_init(C, A) -#endif -#ifndef HDpthread_cond_signal -#define HDpthread_cond_signal(C) pthread_cond_signal(C) -#endif -#ifndef HDpthread_cond_wait -#define HDpthread_cond_wait(C, M) pthread_cond_wait(C, M) -#endif -#ifndef HDpthread_create -#define HDpthread_create(R, A, F, U) pthread_create(R, A, F, U) -#endif -#ifndef HDpthread_equal -#define HDpthread_equal(T1, T2) pthread_equal(T1, T2) -#endif -#ifndef HDpthread_getspecific -#define HDpthread_getspecific(K) pthread_getspecific(K) -#endif -#ifndef HDpthread_join -#define HDpthread_join(T, V) pthread_join(T, V) -#endif -#ifndef HDpthread_key_create -#define HDpthread_key_create(K, D) pthread_key_create(K, D) -#endif -#ifndef HDpthread_mutex_init -#define HDpthread_mutex_init(M, A) pthread_mutex_init(M, A) -#endif -#ifndef HDpthread_mutex_lock -#define HDpthread_mutex_lock(M) pthread_mutex_lock(M) -#endif -#ifndef HDpthread_mutex_unlock -#define HDpthread_mutex_unlock(M) pthread_mutex_unlock(M) -#endif -#ifndef HDpthread_self -#define HDpthread_self() pthread_self() -#endif -#ifndef HDpthread_setcancelstate -#define HDpthread_setcancelstate(N, O) pthread_setcancelstate(N, O) -#endif -#ifndef HDpthread_setspecific -#define HDpthread_setspecific(K, V) pthread_setspecific(K, V) -#endif #ifndef HDputc #define HDputc(C, F) putc(C, F) #endif @@ -1537,6 +1486,9 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDtimes #define HDtimes(T) times(T) #endif +#ifndef HDtimespec_get +#define HDtimespec_get(T, B) timespec_get(T, B) +#endif #ifndef HDtimespeccmp #ifdef H5_HAVE_TIMESPECCMP @@ -2066,6 +2018,16 @@ extern hbool_t H5_libterm_g; /* Is the library being shutdown? */ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ #endif +/* Typedef for the VFD SWMR end-of-tick queue */ +typedef TAILQ_HEAD(eot_queue, eot_queue_entry) eot_queue_t; + +/* VFD SWMR globals used in FUNC macros */ +H5_DLLVAR unsigned int vfd_swmr_api_entries_g; +H5_DLLVAR eot_queue_t eot_queue_g; + +/* Forward declaration of H5F_vfd_swmr_process_eot_queue() */ +H5_DLL herr_t H5F_vfd_swmr_process_eot_queue(hbool_t entering_api); + /* Forward declaration of H5CXpush() / H5CXpop() */ /* (Including H5CXprivate.h creates bad circular dependencies - QAK, 3/18/2018) */ H5_DLL herr_t H5CX_push(void); @@ -2135,8 +2097,6 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); \ BEGIN_MPE_LOG -#include "H5FDvfd_swmr_private.h" - #define VFD_SWMR_ENTER(err) \ do { \ /* TBD assert that the API lock is held. The API lock */ \ @@ -2161,7 +2121,7 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); ; /* Do nothing: an error occurred. */ \ else if (TAILQ_EMPTY(&eot_queue_g)) \ ; /* Nothing to do. */ \ - else if (H5F_vfd_swmr_process_eot_queue(false) < 0) { \ + else if (H5F_vfd_swmr_process_eot_queue(FALSE) < 0) { \ /* Report error instead of "err" */ \ HDONE_ERROR(H5E_FUNC, H5E_CANTSET, FALSE, "error processing EOT queue") \ } \ diff --git a/src/H5retry_private.h b/src/H5retry_private.h index 057c402..768211d 100644 --- a/src/H5retry_private.h +++ b/src/H5retry_private.h @@ -39,13 +39,13 @@ typedef struct h5_retry_t { * * XXX This is not part of the API. XXX */ -static inline bool -h5_retry_decrement(struct h5_retry_t *r) +static inline hbool_t +H5__retry_decrement(struct h5_retry_t *r) { if (r->tries == 0) - return false; + return FALSE; --r->tries; - return true; + return TRUE; } /* Establish state for a retry loop in `r`. The loop will retry no @@ -69,28 +69,28 @@ h5_retry_decrement(struct h5_retry_t *r) * Note well: the program will enter the body of the loop, above, no more * than 101 times: once for an initial try, and then 100 times for retries. */ -static inline bool -h5_retry_init(struct h5_retry_t *r, unsigned int maxtries, uint64_t minival, uint64_t maxival) +static inline hbool_t +H5_retry_init(h5_retry_t *r, unsigned int maxtries, uint64_t minival, uint64_t maxival) { - memset(r, '\0', sizeof(*r)); - assert(0 < maxtries); - assert(0 < minival && minival <= maxival); + HDmemset(r, '\0', sizeof(*r)); + HDassert(0 < maxtries); + HDassert(0 < minival && minival <= maxival); r->tries = r->maxtries = maxtries; r->ival = minival; r->maxival = maxival; - return h5_retry_decrement(r); + return H5__retry_decrement(r); } /* If any tries remain, sleep for the minimum interval, or twice the * previous sleep time, and return true. If no tries remain, return false. */ -static inline bool -h5_retry_next(struct h5_retry_t *r) +static inline hbool_t +H5_retry_next(h5_retry_t *r) { uint64_t ival; - if (!h5_retry_decrement(r)) - return false; + if (!H5__retry_decrement(r)) + return FALSE; ival = r->ival; if (r->maxival < ival) ival = r->maxival; @@ -99,14 +99,14 @@ h5_retry_next(struct h5_retry_t *r) H5_nanosleep(ival); - return true; + return TRUE; } /* Return the number of tries performed since `h5_retry_init()` * was called on `r`. */ static inline unsigned -h5_retry_tries(struct h5_retry_t *r) +H5_retry_tries(h5_retry_t *r) { return r->maxtries - r->tries; } diff --git a/src/H5system.c b/src/H5system.c index b280c84..1104f3b 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -862,7 +862,7 @@ H5_nanosleep(uint64_t nanosec) #else - const uint64_t nanosec_per_sec = 1000 * 1000 * 1000; + const uint64_t nanosec_per_sec = 1000 * 1000L * 1000; struct timespec sleeptime; /* Struct to hold time to sleep */ /* Set up time to sleep @@ -1173,7 +1173,7 @@ H5_get_option(int argc, const char *const *argv, const char *opts, const struct HDfree(arg); } else { - register char *cp; /* pointer into current token */ + char *cp; /* pointer into current token */ /* short command line option */ optchar = argv[H5_optind][sp]; diff --git a/src/Makefile.am b/src/Makefile.am index 3baf833..f39afc7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,8 +64,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5FAint.c H5FAstat.c H5FAtest.c \ H5FD.c H5FDcore.c H5FDfamily.c H5FDint.c H5FDlog.c \ H5FDmulti.c H5FDperform.c H5FDsec2.c H5FDspace.c \ - H5FDsplitter.c H5FDstdio.c H5FDtest.c \ - H5FDvfd_swmr.c H5FDvfd_swmr_instr.c \ + H5FDsplitter.c H5FDstdio.c H5FDtest.c H5FDvfd_swmr.c \ H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSint.c H5FSsection.c \ H5FSstat.c H5FStest.c \ H5G.c H5Gbtree2.c H5Gcache.c H5Gcompact.c H5Gdense.c H5Gdeprec.c \ |