From 8ddf2706f7e0cde59fad6624e2863960e62f6544 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri, 28 Jul 2023 12:33:16 -0700 Subject: Sync of src w/ develop (#3307) --- config/cmake/ConfigureChecks.cmake | 10 - config/cmake/H5pubconf.h.in | 27 - configure.ac | 9 +- src/CMakeLists.txt | 15 +- src/H5.c | 28 +- src/H5A.c | 16 +- src/H5AC.c | 87 +- src/H5ACmpio.c | 41 +- src/H5ACpkg.h | 30 +- src/H5Abtree2.c | 12 +- src/H5Adense.c | 74 +- src/H5Adeprec.c | 6 +- src/H5Aint.c | 72 +- src/H5Atest.c | 2 +- src/H5B.c | 53 +- src/H5B2.c | 46 +- src/H5B2cache.c | 31 +- src/H5B2dbg.c | 14 +- src/H5B2hdr.c | 20 +- src/H5B2int.c | 134 +- src/H5B2internal.c | 24 +- src/H5B2leaf.c | 44 +- src/H5B2test.c | 25 +- src/H5Bcache.c | 14 +- src/H5Bdbg.c | 2 +- src/H5C.c | 7797 ++------------------------------ src/H5CS.c | 2 +- src/H5CX.c | 4 +- src/H5Cdbg.c | 534 ++- src/H5Centry.c | 4214 +++++++++++++++++ src/H5Cepoch.c | 17 +- src/H5Cimage.c | 783 +--- src/H5Cint.c | 2508 ++++++++++ src/H5Clog.c | 4 +- src/H5Clog.h | 4 +- src/H5Clog_json.c | 10 +- src/H5Clog_trace.c | 10 +- src/H5Cmpio.c | 47 +- src/H5Cpkg.h | 4471 +++++++----------- src/H5Cprefetched.c | 24 +- src/H5Cprivate.h | 34 - src/H5Cquery.c | 27 +- src/H5Ctag.c | 141 +- src/H5D.c | 29 +- src/H5Dbtree.c | 10 +- src/H5Dbtree2.c | 14 +- src/H5Dchunk.c | 108 +- src/H5Dcompact.c | 10 +- src/H5Dcontig.c | 20 +- src/H5Ddeprec.c | 6 +- src/H5Dearray.c | 14 +- src/H5Dfarray.c | 14 +- src/H5Dfill.c | 16 +- src/H5Dint.c | 113 +- src/H5Dio.c | 36 +- src/H5Dlayout.c | 10 +- src/H5Dmpio.c | 64 +- src/H5Dnone.c | 2 +- src/H5Doh.c | 14 +- src/H5Dscatgath.c | 34 +- src/H5Dselect.c | 19 +- src/H5Dsingle.c | 2 +- src/H5Dvirtual.c | 52 +- src/H5E.c | 4 +- src/H5EA.c | 37 +- src/H5EAcache.c | 43 +- src/H5EAdbg.c | 26 +- src/H5EAdblkpage.c | 8 +- src/H5EAdblock.c | 12 +- src/H5EAhdr.c | 8 +- src/H5EAiblock.c | 12 +- src/H5EAsblock.c | 12 +- src/H5EAtest.c | 24 +- src/H5ES.c | 2 +- src/H5ESevent.c | 4 +- src/H5ESint.c | 4 +- src/H5Eint.c | 20 +- src/H5Eprivate.h | 34 +- src/H5F.c | 16 +- src/H5FA.c | 22 +- src/H5FAcache.c | 15 +- src/H5FAdbg.c | 10 +- src/H5FAdblkpage.c | 8 +- src/H5FAdblock.c | 12 +- src/H5FAhdr.c | 10 +- src/H5FAtest.c | 4 +- src/H5FD.c | 18 +- src/H5FDcore.c | 34 +- src/H5FDdirect.c | 34 +- src/H5FDfamily.c | 18 +- src/H5FDhdfs.c | 14 +- src/H5FDint.c | 55 +- src/H5FDlog.c | 26 +- src/H5FDmirror.c | 28 +- src/H5FDmpio.c | 16 +- src/H5FDmulti.c | 94 +- src/H5FDonion.c | 72 +- src/H5FDonion_header.c | 27 +- src/H5FDonion_history.c | 27 +- src/H5FDonion_index.c | 71 +- src/H5FDros3.c | 29 +- src/H5FDsec2.c | 24 +- src/H5FDspace.c | 2 +- src/H5FDsplitter.c | 8 +- src/H5FDsubfiling/H5FDioc.c | 4 +- src/H5FDsubfiling/H5FDsubfiling.c | 2 +- src/H5FDsubfiling/H5subfiling_common.c | 34 +- src/H5FDtest.c | 6 - src/H5FL.c | 4 +- src/H5FS.c | 5 +- src/H5FScache.c | 34 +- src/H5FSdbg.c | 6 +- src/H5FSsection.c | 26 +- src/H5FStest.c | 20 +- src/H5Faccum.c | 12 +- src/H5Fcwfs.c | 6 +- src/H5Fefc.c | 18 +- src/H5Fint.c | 148 +- src/H5Fio.c | 31 +- src/H5Fmount.c | 20 +- src/H5Fmpi.c | 12 +- src/H5Fprivate.h | 302 +- src/H5Fsfile.c | 18 +- src/H5Fsuper.c | 50 +- src/H5Fsuper_cache.c | 49 +- src/H5Ftest.c | 4 +- src/H5G.c | 12 +- src/H5Gbtree2.c | 8 +- src/H5Gcache.c | 9 +- src/H5Gcompact.c | 12 +- src/H5Gdense.c | 50 +- src/H5Gdeprec.c | 18 +- src/H5Gent.c | 15 +- src/H5Gint.c | 24 +- src/H5Glink.c | 10 +- src/H5Gloc.c | 2 +- src/H5Gname.c | 16 +- src/H5Gnode.c | 40 +- src/H5Gobj.c | 10 +- src/H5Goh.c | 10 +- src/H5Groot.c | 4 +- src/H5Gstab.c | 22 +- src/H5Gtest.c | 62 +- src/H5Gtraverse.c | 14 +- src/H5HF.c | 10 +- src/H5HFbtree2.c | 61 +- src/H5HFcache.c | 85 +- src/H5HFdbg.c | 18 +- src/H5HFdblock.c | 4 +- src/H5HFhdr.c | 4 +- src/H5HFhuge.c | 68 +- src/H5HFiblock.c | 6 +- src/H5HFiter.c | 2 +- src/H5HFman.c | 10 +- src/H5HFpkg.h | 8 +- src/H5HFsection.c | 36 +- src/H5HFstat.c | 2 +- src/H5HFtest.c | 54 +- src/H5HG.c | 39 +- src/H5HGcache.c | 10 +- src/H5HGdbg.c | 2 +- src/H5HL.c | 25 +- src/H5HLcache.c | 50 +- src/H5HLdbg.c | 4 +- src/H5HLdblk.c | 2 +- src/H5HLint.c | 2 +- src/H5Iint.c | 26 +- src/H5Itest.c | 4 +- src/H5Lexternal.c | 6 +- src/H5Lint.c | 18 +- src/H5M.c | 12 +- src/H5MF.c | 14 +- src/H5MFaggr.c | 2 +- src/H5MFpkg.h | 4 +- src/H5MFsection.c | 12 +- src/H5MMprivate.h | 2 +- src/H5O.c | 20 +- src/H5Oainfo.c | 18 +- src/H5Oalloc.c | 82 +- src/H5Oattr.c | 4 +- src/H5Oattribute.c | 36 +- src/H5Ocache.c | 28 +- src/H5Ocache_image.c | 6 +- src/H5Ochunk.c | 8 +- src/H5Ocont.c | 4 +- src/H5Ocopy.c | 22 +- src/H5Ocopy_ref.c | 17 +- src/H5Odbg.c | 2 +- src/H5Odeprec.c | 7 +- src/H5Odtype.c | 20 +- src/H5Oefl.c | 9 +- src/H5Ofill.c | 6 +- src/H5Oflush.c | 10 +- src/H5Ofsinfo.c | 22 +- src/H5Oginfo.c | 16 +- src/H5Oint.c | 64 +- src/H5Olayout.c | 28 +- src/H5Olinfo.c | 22 +- src/H5Olink.c | 18 +- src/H5Omessage.c | 30 +- src/H5Omtime.c | 2 +- src/H5Opline.c | 2 +- src/H5Orefcount.c | 2 +- src/H5Oshared.c | 15 +- src/H5Oshared.h | 2 +- src/H5Oshmesg.c | 4 +- src/H5Ostab.c | 14 +- src/H5Otest.c | 62 +- src/H5PB.c | 10 +- src/H5PLint.c | 10 +- src/H5PLpath.c | 14 +- src/H5Pdapl.c | 15 +- src/H5Pdcpl.c | 66 +- src/H5Pdxpl.c | 39 +- src/H5Pencdec.c | 10 +- src/H5Pfapl.c | 42 +- src/H5Pfcpl.c | 12 +- src/H5Pgcpl.c | 24 +- src/H5Pint.c | 14 +- src/H5Plapl.c | 15 +- src/H5Pocpl.c | 29 +- src/H5Pocpypl.c | 10 +- src/H5Ppublic.h | 4 +- src/H5R.c | 14 +- src/H5Rdeprec.c | 7 +- src/H5Rint.c | 6 +- src/H5S.c | 22 +- src/H5SL.c | 10 +- src/H5SM.c | 82 +- src/H5SMcache.c | 24 +- src/H5SMmessage.c | 4 +- src/H5SMtest.c | 2 +- src/H5Sall.c | 6 +- src/H5Shyper.c | 130 +- src/H5Smpio.c | 20 +- src/H5Snone.c | 2 +- src/H5Spoint.c | 12 +- src/H5Sselect.c | 44 +- src/H5T.c | 1 + src/H5TS.c | 70 +- src/H5TSdevelop.h | 2 +- src/H5Tarray.c | 4 +- src/H5Tbit.c | 2 +- src/H5Tcommit.c | 24 +- src/H5Tcompound.c | 4 +- src/H5Tconv.c | 29 +- src/H5Tdeprec.c | 2 +- src/H5Tenum.c | 2 +- src/H5Tfields.c | 4 +- src/H5Tnative.c | 6 +- src/H5Toh.c | 2 +- src/H5Tref.c | 23 +- src/H5Tvlen.c | 2 +- src/H5VL.c | 4 +- src/H5VLcallback.c | 120 +- src/H5VLint.c | 30 +- src/H5VLnative.c | 6 +- src/H5VLnative_attr.c | 2 +- src/H5VLnative_blob.c | 10 +- src/H5VLnative_dataset.c | 13 +- src/H5VLnative_file.c | 4 +- src/H5VLnative_group.c | 4 +- src/H5VLpassthru.c | 2 +- src/H5VM.c | 10 +- src/H5VMprivate.h | 50 +- src/H5WB.c | 2 +- src/H5Z.c | 26 +- src/H5Znbit.c | 10 +- src/H5Zscaleoffset.c | 149 +- src/H5Ztrans.c | 70 +- src/H5checksum.c | 8 +- src/H5dbg.c | 2 +- src/H5detect.c | 54 +- src/H5encode.h | 287 ++ src/H5make_libsettings.c | 38 +- src/H5mpi.c | 6 +- src/H5private.h | 595 +-- src/H5timer.c | 6 +- src/H5trace.c | 12 +- src/H5win32defs.h | 50 +- src/Makefile.am | 3 +- src/libhdf5.settings.in | 4 +- test/cache_common.h | 56 +- test/cache_image.c | 8 +- test/hdfs.c | 43 +- test/ros3.c | 6 +- testpar/t_cache_image.c | 4 +- testpar/t_subfiling_vfd.c | 52 +- utils/Makefile.am | 2 + 289 files changed, 12802 insertions(+), 15173 deletions(-) create mode 100644 src/H5Centry.c create mode 100644 src/H5Cint.c create mode 100644 src/H5encode.h diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index e518b85..e5192f5 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -122,9 +122,6 @@ CHECK_INCLUDE_FILE_CONCAT ("globus/common.h" ${HDF_PREFIX}_HAVE_GLOBUS_COMMON_H) CHECK_INCLUDE_FILE_CONCAT ("pdb.h" ${HDF_PREFIX}_HAVE_PDB_H) CHECK_INCLUDE_FILE_CONCAT ("pthread.h" ${HDF_PREFIX}_HAVE_PTHREAD_H) CHECK_INCLUDE_FILE_CONCAT ("srbclient.h" ${HDF_PREFIX}_HAVE_SRBCLIENT_H) -CHECK_INCLUDE_FILE_CONCAT ("string.h" ${HDF_PREFIX}_HAVE_STRING_H) -CHECK_INCLUDE_FILE_CONCAT ("strings.h" ${HDF_PREFIX}_HAVE_STRINGS_H) -CHECK_INCLUDE_FILE_CONCAT ("stdlib.h" ${HDF_PREFIX}_HAVE_STDLIB_H) CHECK_INCLUDE_FILE_CONCAT ("dlfcn.h" ${HDF_PREFIX}_HAVE_DLFCN_H) CHECK_INCLUDE_FILE_CONCAT ("netinet/in.h" ${HDF_PREFIX}_HAVE_NETINET_IN_H) CHECK_INCLUDE_FILE_CONCAT ("netdb.h" ${HDF_PREFIX}_HAVE_NETDB_H) @@ -447,19 +444,12 @@ CHECK_FUNCTION_EXISTS (fork ${HDF_PREFIX}_HAVE_FORK) CHECK_FUNCTION_EXISTS (gethostname ${HDF_PREFIX}_HAVE_GETHOSTNAME) CHECK_FUNCTION_EXISTS (getrusage ${HDF_PREFIX}_HAVE_GETRUSAGE) -CHECK_FUNCTION_EXISTS (lstat ${HDF_PREFIX}_HAVE_LSTAT) CHECK_FUNCTION_EXISTS (pread ${HDF_PREFIX}_HAVE_PREAD) CHECK_FUNCTION_EXISTS (pwrite ${HDF_PREFIX}_HAVE_PWRITE) CHECK_FUNCTION_EXISTS (rand_r ${HDF_PREFIX}_HAVE_RAND_R) CHECK_FUNCTION_EXISTS (random ${HDF_PREFIX}_HAVE_RANDOM) -CHECK_FUNCTION_EXISTS (setsysinfo ${HDF_PREFIX}_HAVE_SETSYSINFO) -CHECK_FUNCTION_EXISTS (siglongjmp ${HDF_PREFIX}_HAVE_SIGLONGJMP) -CHECK_FUNCTION_EXISTS (sigsetjmp ${HDF_PREFIX}_HAVE_SIGSETJMP) -CHECK_FUNCTION_EXISTS (sigprocmask ${HDF_PREFIX}_HAVE_SIGPROCMASK) - -CHECK_FUNCTION_EXISTS (srandom ${HDF_PREFIX}_HAVE_SRANDOM) CHECK_FUNCTION_EXISTS (strcasestr ${HDF_PREFIX}_HAVE_STRCASESTR) CHECK_FUNCTION_EXISTS (strdup ${HDF_PREFIX}_HAVE_STRDUP) CHECK_FUNCTION_EXISTS (symlink ${HDF_PREFIX}_HAVE_SYMLINK) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index ca26447..ae56d2c 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -216,9 +216,6 @@ /* Define to 1 if you have the `lseek64' function. */ #cmakedefine H5_HAVE_LSEEK64 @H5_HAVE_LSEEK64@ -/* Define to 1 if you have the `lstat' function. */ -#cmakedefine H5_HAVE_LSTAT @H5_HAVE_LSTAT@ - /* Define if the map API (H5M) should be compiled */ #cmakedefine H5_HAVE_MAP_API @H5_HAVE_MAP_API@ @@ -280,42 +277,18 @@ compiled */ #cmakedefine H5_HAVE_ROS3_VFD @H5_HAVE_ROS3_VFD@ -/* Define to 1 if you have the `setsysinfo' function. */ -#cmakedefine H5_HAVE_SETSYSINFO @H5_HAVE_SETSYSINFO@ - -/* Define to 1 if you have the `siglongjmp' function. */ -#cmakedefine H5_HAVE_SIGLONGJMP @H5_HAVE_SIGLONGJMP@ - -/* Define to 1 if you have the `sigprocmask' function. */ -#cmakedefine H5_HAVE_SIGPROCMASK @H5_HAVE_SIGPROCMASK@ - -/* Define to 1 if you have the `sigsetjmp' function. */ -#cmakedefine H5_HAVE_SIGSETJMP @H5_HAVE_SIGSETJMP@ - -/* Define to 1 if you have the `srandom' function. */ -#cmakedefine H5_HAVE_SRANDOM @H5_HAVE_SRANDOM@ - /* Define to 1 if you have the `stat64' function. */ #cmakedefine H5_HAVE_STAT64 @H5_HAVE_STAT64@ /* Define if struct stat has the st_blocks field */ #cmakedefine H5_HAVE_STAT_ST_BLOCKS @H5_HAVE_STAT_ST_BLOCKS@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_STDLIB_H @H5_HAVE_STDLIB_H@ - /* Define to 1 if you have the `strcasestr' function. */ #cmakedefine H5_HAVE_STRCASESTR @H5_HAVE_STRCASESTR@ /* Define to 1 if you have the `strdup' function. */ #cmakedefine H5_HAVE_STRDUP @H5_HAVE_STRDUP@ -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_STRINGS_H @H5_HAVE_STRINGS_H@ - -/* Define to 1 if you have the header file. */ -#cmakedefine H5_HAVE_STRING_H @H5_HAVE_STRING_H@ - /* Define if struct text_info is defined */ #cmakedefine H5_HAVE_STRUCT_TEXT_INFO @H5_HAVE_STRUCT_TEXT_INFO@ diff --git a/configure.ac b/configure.ac index a212825..e7cb8aa 100644 --- a/configure.ac +++ b/configure.ac @@ -2068,9 +2068,8 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ AC_SEARCH_LIBS([clock_gettime], [rt posix4]) AC_CHECK_FUNCS([alarm asprintf clock_gettime fcntl flock fork]) AC_CHECK_FUNCS([gethostname getrusage gettimeofday]) -AC_CHECK_FUNCS([lstat rand_r random setsysinfo]) -AC_CHECK_FUNCS([siglongjmp sigsetjmp sigprocmask]) -AC_CHECK_FUNCS([srandom strcasestr strdup symlink]) +AC_CHECK_FUNCS([rand_r random]) +AC_CHECK_FUNCS([strcasestr strdup symlink]) AC_CHECK_FUNCS([tmpfile vasprintf waitpid]) ## ---------------------------------------------------------------------- @@ -4045,10 +4044,10 @@ fi ## AM_CONDITIONAL([HAVE_SHARED_CONDITIONAL], [test "X$enable_shared" = "Xyes"]) -AC_CONFIG_FILES([src/libhdf5.settings - Makefile +AC_CONFIG_FILES([Makefile doxygen/Doxyfile src/Makefile + src/libhdf5.settings test/Makefile test/H5srcdir_str.h test/test_abort_fail.sh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7187147..92c74f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,7 @@ set (H5_SOURCES set (H5_HDRS ${HDF5_SRC_DIR}/hdf5.h ${HDF5_SRC_DIR}/H5api_adpt.h + ${HDF5_SRC_DIR}/H5encode.h ${HDF5_SRC_DIR}/H5public.h #${HDF5_SRC_DIR}/H5version.h #${HDF5_SRC_DIR}/H5overflow.h @@ -78,8 +79,10 @@ IDE_GENERATED_PROPERTIES ("H5B2" "${H5B2_HDRS}" "${H5B2_SOURCES}" ) set (H5C_SOURCES ${HDF5_SRC_DIR}/H5C.c ${HDF5_SRC_DIR}/H5Cdbg.c + ${HDF5_SRC_DIR}/H5Centry.c ${HDF5_SRC_DIR}/H5Cepoch.c ${HDF5_SRC_DIR}/H5Cimage.c + ${HDF5_SRC_DIR}/H5Cint.c ${HDF5_SRC_DIR}/H5Clog.c ${HDF5_SRC_DIR}/H5Clog_json.c ${HDF5_SRC_DIR}/H5Clog_trace.c @@ -1409,17 +1412,7 @@ endif () # Option to build documentation #----------------------------------------------------------------------------- if (DOXYGEN_FOUND) -# This cmake function requires that the non-default doxyfile settings are provided with set (DOXYGEN_xxx) commands -# In addition the doxyfile aliases @INCLUDE option is not supported and would need to be provided in a set (DOXYGEN_ALIASES) command. -# doxygen_add_docs (hdf5lib_doc -## ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${HDF5_DOXYGEN_DIR}/dox -# ${DOXYGEN_INPUT_DIRECTORY} -# ALL -# WORKING_DIRECTORY ${HDF5_SRC_DIR} -# COMMENT "Generating HDF5 library Source Documentation" -# ) - -# This custom target and doxygen/configure work together + # This custom target and doxygen/configure work together # Replace variables inside @@ with the current values add_custom_target (hdf5lib_doc ALL COMMAND ${DOXYGEN_EXECUTABLE} ${HDF5_BINARY_DIR}/Doxyfile diff --git a/src/H5.c b/src/H5.c index 10d3115..56beb8a 100644 --- a/src/H5.c +++ b/src/H5.c @@ -70,8 +70,8 @@ static int H5__mpi_delete_cb(MPI_Comm comm, int keyval, void *attr_val, int *fla /*****************************/ /* Library incompatible release versions, develop releases are incompatible by design */ -const unsigned VERS_RELEASE_EXCEPTIONS[] = {0}; -const unsigned VERS_RELEASE_EXCEPTIONS_SIZE = 0; +static const unsigned VERS_RELEASE_EXCEPTIONS[] = {0}; +static const unsigned VERS_RELEASE_EXCEPTIONS_SIZE = 0; /* statically initialize block for pthread_once call used in initializing */ /* the first global mutex */ @@ -145,7 +145,7 @@ H5_init_library(void) /* Run the library initialization routine, if it hasn't already run */ if (H5_INIT_GLOBAL || H5_TERM_GLOBAL) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Set the 'library initialized' flag as early as possible, to avoid * possible re-entrancy. @@ -218,11 +218,11 @@ H5_init_library(void) * This must be entered before the library cleanup code so it's * executed in LIFO order (i.e., last). */ - (void)HDatexit(H5TS_win32_process_exit); + (void)atexit(H5TS_win32_process_exit); #endif /* H5_HAVE_THREADSAFE && H5_HAVE_WIN_THREADS */ /* Normal library termination code */ - (void)HDatexit(H5_term_library); + (void)atexit(H5_term_library); H5_dont_atexit_g = TRUE; } /* end if */ @@ -492,7 +492,7 @@ H5_term_library(void) H5_debug_open_stream_t *tmp_open_stream; tmp_open_stream = H5_debug_g.open_stream; - (void)HDfclose(H5_debug_g.open_stream->stream); + (void)fclose(H5_debug_g.open_stream->stream); H5_debug_g.open_stream = H5_debug_g.open_stream->next; (void)H5MM_free(tmp_open_stream); } /* end while */ @@ -697,7 +697,7 @@ H5__debug_mask(const char *s) while (s && *s) { - if (HDisalpha(*s) || '-' == *s || '+' == *s) { + if (isalpha(*s) || '-' == *s || '+' == *s) { /* Enable or Disable debugging? */ if ('-' == *s) { @@ -713,7 +713,7 @@ H5__debug_mask(const char *s) } /* end if */ /* Get the name */ - for (i = 0; HDisalpha(*s); i++, s++) + for (i = 0; isalpha(*s); i++, s++) if (i < sizeof pkg_name) pkg_name[i] = *s; pkg_name[MIN(sizeof(pkg_name) - 1, i)] = '\0'; @@ -745,8 +745,8 @@ H5__debug_mask(const char *s) fprintf(stderr, "HDF5_DEBUG: ignored %s\n", pkg_name); } /* end if-else */ } - else if (HDisdigit(*s)) { - int fd = (int)HDstrtol(s, &rest, 0); + else if (isdigit(*s)) { + int fd = (int)strtol(s, &rest, 0); H5_debug_open_stream_t *open_stream; if ((stream = HDfdopen(fd, "w")) != NULL) { @@ -754,7 +754,7 @@ H5__debug_mask(const char *s) if (NULL == (open_stream = (H5_debug_open_stream_t *)H5MM_malloc(sizeof(H5_debug_open_stream_t)))) { - (void)HDfclose(stream); + (void)fclose(stream); return; } /* end if */ @@ -881,7 +881,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) /* Don't check again, if we already have */ if (checked) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); { const char *s; /* Environment string for disabling version check */ @@ -889,8 +889,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) /* Allow different versions of the header files and library? */ s = HDgetenv("HDF5_DISABLE_VERSION_CHECK"); - if (s && HDisdigit(*s)) - disable_version_check = (unsigned int)HDstrtol(s, NULL, 0); + if (s && isdigit(*s)) + disable_version_check = (unsigned int)strtol(s, NULL, 0); } /* H5_VERS_MAJOR and H5_VERS_MINOR must match */ diff --git a/src/H5A.c b/src/H5A.c index 4bbd799..5f394dd 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -136,7 +136,7 @@ done: /* Cleanup on failure */ if (H5I_INVALID_HID == ret_value) if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__create_common() */ @@ -278,7 +278,7 @@ H5Acreate_async(const char *app_file, const char *app_func, unsigned app_line, h H5ARG_TRACE10(__func__, "*s*sIui*siiiii", app_file, app_func, app_line, loc_id, attr_name, type_id, space_id, acpl_id, aapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID"); HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -427,7 +427,7 @@ H5Acreate_by_name_async(const char *app_file, const char *app_func, unsigned app H5ARG_TRACE12(__func__, "*s*sIui*s*siiiiii", app_file, app_func, app_line, loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID"); HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -471,7 +471,7 @@ done: /* Cleanup on failure */ if (H5I_INVALID_HID == ret_value) if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_common() */ @@ -590,7 +590,7 @@ H5Aopen_async(const char *app_file, const char *app_func, unsigned app_line, hid H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, attr_name, aapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID"); HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -721,7 +721,7 @@ H5Aopen_by_name_async(const char *app_file, const char *app_func, unsigned app_l H5ARG_TRACE9(__func__, "*s*sIui*s*siii", app_file, app_func, app_line, loc_id, obj_name, attr_name, aapl_id, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID"); HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -861,7 +861,7 @@ H5Aopen_by_idx_async(const char *app_file, const char *app_func, unsigned app_li H5ARG_TRACE11(__func__, "*s*sIui*sIiIohiii", app_file, app_func, app_line, loc_id, obj_name, idx_type, order, n, aapl_id, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on attribute ID"); HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -2288,7 +2288,7 @@ H5Aclose_async(const char *app_file, const char *app_func, unsigned app_line, hi done: if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't decrement ref count on connector") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); FUNC_LEAVE_API(ret_value) } /* H5Aclose_async() */ diff --git a/src/H5AC.c b/src/H5AC.c index 39b9502..09b6835 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -144,8 +144,8 @@ H5AC_init(void) const char *s; /* String for environment variables */ s = HDgetenv("H5_COLL_API_SANITY_CHECK"); - if (s && HDisdigit(*s)) { - long env_val = HDstrtol(s, NULL, 0); + if (s && isdigit(*s)) { + long env_val = strtol(s, NULL, 0); H5_coll_api_sanity_check_g = (0 == env_val) ? FALSE : TRUE; } } @@ -265,7 +265,6 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co if (NULL == (aux_ptr = H5FL_CALLOC(H5AC_aux_t))) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate H5AC auxiliary structure") - aux_ptr->magic = H5AC__H5AC_AUX_T_MAGIC; aux_ptr->mpi_comm = mpi_comm; aux_ptr->mpi_rank = mpi_rank; aux_ptr->mpi_size = mpi_size; @@ -367,7 +366,7 @@ done: /* If currently logging, generate a message */ if (f->shared->cache->log_info->logging) if (H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); #ifdef H5_HAVE_PARALLEL /* if there is a failure, try to tidy up the auxiliary structure */ @@ -379,8 +378,7 @@ done: H5SL_close(aux_ptr->c_slist_ptr); if (aux_ptr->candidate_slist_ptr != NULL) H5SL_close(aux_ptr->candidate_slist_ptr); - aux_ptr->magic = 0; - aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); + aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); } /* end if */ } /* end if */ #endif /* H5_HAVE_PARALLEL */ @@ -442,9 +440,6 @@ H5AC_dest(H5F_t *f) aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); if (aux_ptr) { - /* Sanity check */ - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - /* If the file was opened R/W, attempt to flush all entries * from rank 0 & Bcast clean list to other ranks. * @@ -500,8 +495,7 @@ H5AC_dest(H5F_t *f) H5SL_close(aux_ptr->candidate_slist_ptr); } /* end if */ - aux_ptr->magic = 0; - aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); + aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); } /* end if */ #endif /* H5_HAVE_PARALLEL */ @@ -539,7 +533,7 @@ done: /* If currently logging, generate a message */ if (f->shared->cache->log_info->logging) if (H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_evict() */ @@ -577,7 +571,7 @@ done: /* If currently logging, generate a message */ if (f->shared->cache->log_info->logging) if (H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_expunge_entry() */ @@ -629,7 +623,7 @@ done: /* If currently logging, generate a message */ if (f->shared->cache->log_info->logging) if (H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush() */ @@ -760,7 +754,7 @@ done: if (f->shared->cache->log_info->logging) if (H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags, ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_insert_entry() */ @@ -841,7 +835,7 @@ done: if (cache_ptr != NULL && cache_ptr->log_info != NULL) if (cache_ptr->log_info->logging) if (H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_dirty() */ @@ -891,7 +885,7 @@ done: if (cache_ptr != NULL && cache_ptr->log_info != NULL) if (cache_ptr->log_info->logging) if (H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_clean() */ @@ -930,7 +924,7 @@ done: if (cache_ptr != NULL && cache_ptr->log_info != NULL) if (cache_ptr->log_info->logging) if (H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_unserialized() */ @@ -968,7 +962,7 @@ done: if (cache_ptr != NULL && cache_ptr->log_info != NULL) if (cache_ptr->log_info->logging) if (H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_serialized() */ @@ -1022,7 +1016,7 @@ done: /* If currently logging, generate a message */ if (f->shared->cache->log_info->logging) if (H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_move_entry() */ @@ -1062,7 +1056,7 @@ done: if (cache_ptr != NULL && cache_ptr->log_info != NULL) if (cache_ptr->log_info->logging) if (H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_pin_protected_entry() */ @@ -1219,7 +1213,7 @@ done: if (cache_ptr->log_info->logging) if (H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create_flush_dependency() */ @@ -1293,7 +1287,7 @@ done: if (f->shared->cache->log_info->logging) if (H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, fake_ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message"); } FUNC_LEAVE_NOAPI(ret_value) @@ -1387,7 +1381,7 @@ done: if (cache_ptr != NULL && cache_ptr->log_info != NULL) if (cache_ptr->log_info->logging) if (H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_resize_entry() */ @@ -1427,7 +1421,7 @@ done: if (cache_ptr != NULL && cache_ptr->log_info != NULL) if (cache_ptr->log_info->logging) if (H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unpin_entry() */ @@ -1468,7 +1462,7 @@ done: if (cache_ptr->log_info->logging) if (H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_destroy_flush_dependency() */ @@ -1559,7 +1553,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, un /* If we fail to log the deleted entry, push an error but still * participate in a possible sync point ahead */ - HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5AC__log_deleted_entry() failed") + HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5AC__log_deleted_entry() failed"); } } } /* end if */ @@ -1579,7 +1573,7 @@ done: /* If currently logging, generate a message */ if (f->shared->cache->log_info->logging) if (H5C_log_write_unprotect_entry_msg(f->shared->cache, addr, type->id, flags, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unprotect() */ @@ -1606,15 +1600,6 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, H5AC_cache_config_t * if ((cache_ptr == NULL) || (config_ptr == NULL) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or config_ptr on entry") -#ifdef H5_HAVE_PARALLEL - { - H5AC_aux_t *aux_ptr; - - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if ((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr on entry") - } -#endif /* H5_HAVE_PARALLEL */ /* Retrieve the configuration */ if (H5C_get_cache_auto_resize_config((const H5C_t *)cache_ptr, &internal_config) < 0) @@ -1791,15 +1776,6 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, const H5AC_cache_config_t * if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad cache_ptr on entry") -#ifdef H5_HAVE_PARALLEL - { - H5AC_aux_t *aux_ptr; - - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if ((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr on entry") - } -#endif /* H5_HAVE_PARALLEL */ /* Validate external configuration */ if (H5AC_validate_config(config_ptr) != SUCCEED) @@ -1852,7 +1828,7 @@ done: /* If currently logging, generate a message */ if (cache_ptr->log_info->logging) if (H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set_cache_auto_resize_config() */ @@ -2019,8 +1995,6 @@ H5AC__check_if_write_permitted(const H5F_t assert(f->shared->cache != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); if (aux_ptr != NULL) { - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); - if ((aux_ptr->mpi_rank == 0) || (aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)) write_permitted = aux_ptr->write_permitted; @@ -2215,14 +2189,15 @@ done: /*------------------------------------------------------------------------------ * Function: H5AC_evict_tagged_metadata() * - * Purpose: Wrapper for cache level function which flushes all metadata + * Purpose: Wrapper for cache level function which evicts all metadata * that contains the specific tag. * - * Return: SUCCEED on success, FAIL otherwise. - * - * Programmer: Mike McGreevy - * May 19, 2010 + * The match_global parameter determines if the global file + * data (e.g., global heaps, shared object header messages) + * should be checked. This is false when closing objects + * and true when flushing. * + * Return: SUCCEED on success, FAIL otherwise. *------------------------------------------------------------------------------ */ herr_t @@ -2339,7 +2314,7 @@ H5AC_cork(H5F_t *f, haddr_t obj_addr, unsigned action, hbool_t *corked) assert(corked); if (H5C_get_num_objs_corked(f->shared->cache) == 0) { *corked = FALSE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } } @@ -2557,7 +2532,7 @@ done: if (cache != NULL && cache->log_info != NULL) if (cache->log_info->logging) if (H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message"); FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_remove_entry() */ diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index d2d67be..3be2bc6 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -141,7 +141,6 @@ H5AC__set_sync_point_done_callback(H5C_t *cache_ptr, H5AC_sync_point_done_cb_t s assert(cache_ptr); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); aux_ptr->sync_point_done = sync_point_done; @@ -170,7 +169,6 @@ H5AC__set_write_done_callback(H5C_t *cache_ptr, H5AC_write_done_cb_t write_done) assert(cache_ptr); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); aux_ptr->write_done = write_done; @@ -205,7 +203,6 @@ H5AC_add_candidate(H5AC_t *cache_ptr, haddr_t addr) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); assert(aux_ptr->candidate_slist_ptr != NULL); @@ -265,7 +262,6 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, had assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->mpi_rank == 0); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); assert(aux_ptr->candidate_slist_ptr != NULL); @@ -292,7 +288,7 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, had */ if (H5AC__copy_candidate_list_to_buffer(cache_ptr, &chk_num_entries, &haddr_buf_ptr) < 0) { /* Push an error, but still participate in following MPI_Bcast */ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate buffer.") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate buffer."); } assert(chk_num_entries == num_entries); assert(haddr_buf_ptr != NULL); @@ -394,7 +390,6 @@ H5AC__broadcast_clean_list(H5AC_t *cache_ptr) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->mpi_rank == 0); assert(aux_ptr->c_slist_ptr != NULL); @@ -414,7 +409,7 @@ H5AC__broadcast_clean_list(H5AC_t *cache_ptr) buf_size = sizeof(haddr_t) * num_entries; if (NULL == (addr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) { /* Push an error, but still participate in following MPI_Bcast */ - HDONE_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for addr buffer") + HDONE_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for addr buffer"); } else { /* Set up user data for callback */ @@ -426,7 +421,7 @@ H5AC__broadcast_clean_list(H5AC_t *cache_ptr) /* (Callback also removes the matching entries from the dirtied list) */ if (H5SL_free(aux_ptr->c_slist_ptr, H5AC__broadcast_clean_list_cb, &udata) < 0) { /* Push an error, but still participate in following MPI_Bcast */ - HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "Can't build address list for clean entries") + HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "Can't build address list for clean entries"); } } @@ -477,7 +472,6 @@ H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_NDEBUG_UNUS /* Sanity checks */ assert(cache_ptr != NULL); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); assert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_CACHE) || (aux_ptr->mpi_rank == 0)); assert(aux_ptr->d_slist_ptr != NULL); @@ -588,7 +582,6 @@ H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entri assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); assert(aux_ptr->candidate_slist_ptr != NULL); assert(H5SL_count(aux_ptr->candidate_slist_ptr) > 0); @@ -661,7 +654,6 @@ H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->mpi_rank == 0); assert(aux_ptr->d_slist_ptr != NULL); assert(aux_ptr->c_slist_ptr != NULL); @@ -712,7 +704,6 @@ H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; @@ -786,7 +777,6 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; @@ -845,7 +835,6 @@ H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsig assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->mpi_rank == 0); assert(aux_ptr->c_slist_ptr != NULL); @@ -912,7 +901,6 @@ H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); if (aux_ptr->mpi_rank == 0) { H5AC_slist_entry_t *slist_entry_ptr; @@ -1012,7 +1000,6 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) assert(cache_ptr); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); /* get entry status, size, etc here */ if (H5C_get_entry_status(f, old_addr, &entry_size, &entry_in_cache, &entry_dirty, NULL, NULL, NULL, NULL, @@ -1188,7 +1175,6 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); /* to prevent "messages from the future" we must synchronize all @@ -1348,7 +1334,6 @@ H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); if (aux_ptr->mpi_rank == 0) { @@ -1411,7 +1396,7 @@ H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, haddr_t * buf_size = sizeof(haddr_t) * num_entries; if (NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) { /* Push an error, but still participate in following MPI_Bcast */ - HDONE_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer") + HDONE_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer"); } /* Now receive the list of candidate entries */ @@ -1467,7 +1452,6 @@ H5AC__receive_and_apply_clean_list(H5F_t *f) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->mpi_rank != 0); /* Retrieve the clean list from process 0 */ @@ -1523,7 +1507,6 @@ H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->mpi_rank != 0); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); assert(num_entries_ptr != NULL); @@ -1603,7 +1586,6 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); /* first construct the candidate list -- initially, this will be in the @@ -1744,7 +1726,6 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); /* Query if evictions are allowed */ @@ -1759,7 +1740,7 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) */ if (H5AC__construct_candidate_list(cache_ptr, aux_ptr, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate list.") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate list."); } /* propagate and apply candidate list -- all processes */ @@ -1820,7 +1801,6 @@ H5AC__rsp__p0_only__flush(H5F_t *f) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); /* To prevent "messages from the future" we must @@ -1853,7 +1833,7 @@ H5AC__rsp__p0_only__flush(H5F_t *f) * in collective operations during following cache entry * propagation */ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush.") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush."); } else { /* this code exists primarily for the test bed -- it allows us to @@ -1928,7 +1908,6 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); /* Query if evictions are allowed */ @@ -1976,7 +1955,7 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) * in collective operations during following cache entry * propagation */ - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_flush_to_min_clean() failed.") + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_flush_to_min_clean() failed."); } else { /* this call exists primarily for the test code -- it is used @@ -2039,13 +2018,12 @@ H5AC__run_sync_point(H5F_t *f, int sync_point_op) assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || (sync_point_op == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)); #ifdef H5AC_DEBUG_DIRTY_BYTES_CREATION - fprintf(stdout, "%d:%s...:%u: (u/uu/i/iu/m/mu) = %zu/%u/%zu/%u/%zu/%u\n", aux_ptr->mpi_rank, __func__, - aux_ptr->dirty_bytes_propagations, aux_ptr->unprotect_dirty_bytes, + fprintf(stdout, "%d:%s...:%u: (u/uu/i/iu/m/mu) = %zu/%u/%zu/%u/%zu/%u\n", aux_ptr->mpi_rank, + __func__ aux_ptr->dirty_bytes_propagations, aux_ptr->unprotect_dirty_bytes, aux_ptr->unprotect_dirty_bytes_updates, aux_ptr->insert_dirty_bytes, aux_ptr->insert_dirty_bytes_updates, aux_ptr->move_dirty_bytes, aux_ptr->move_dirty_bytes_updates); @@ -2165,7 +2143,6 @@ H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, unsigned num_candidates, haddr_t *ca assert(cache_ptr != NULL); aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); assert(aux_ptr != NULL); - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); assert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); assert(aux_ptr->mpi_rank == 0); assert(num_candidates > 0); diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index beb7ba7..535eabd 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -165,10 +165,6 @@ H5FL_EXTERN(H5AC_aux_t); * * JRM -- 1/6/15 * - * magic: Unsigned 32 bit integer always set to - * H5AC__H5AC_AUX_T_MAGIC. This field is used to validate - * pointers to instances of H5AC_aux_t. - * * mpi_comm: MPI communicator associated with the file for which the * cache has been created. * @@ -350,52 +346,34 @@ H5FL_EXTERN(H5AC_aux_t); #ifdef H5_HAVE_PARALLEL -#define H5AC__H5AC_AUX_T_MAGIC (unsigned)0x00D0A01 - typedef struct H5AC_aux_t { - uint32_t magic; - MPI_Comm mpi_comm; - - int mpi_rank; - - int mpi_size; + int mpi_rank; + int mpi_size; hbool_t write_permitted; - - size_t dirty_bytes_threshold; - - size_t dirty_bytes; - + size_t dirty_bytes_threshold; + size_t dirty_bytes; int32_t metadata_write_strategy; #ifdef H5AC_DEBUG_DIRTY_BYTES_CREATION - unsigned dirty_bytes_propagations; - size_t unprotect_dirty_bytes; unsigned unprotect_dirty_bytes_updates; - size_t insert_dirty_bytes; unsigned insert_dirty_bytes_updates; - size_t move_dirty_bytes; unsigned move_dirty_bytes_updates; - #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ H5SL_t *d_slist_ptr; - H5SL_t *c_slist_ptr; - H5SL_t *candidate_slist_ptr; void (*write_done)(void); - void (*sync_point_done)(unsigned num_writes, haddr_t *written_entries_tbl); unsigned p0_image_len; - } H5AC_aux_t; /* struct H5AC_aux_t */ /* Typedefs for debugging function pointers */ diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 2468a98..1de8a27 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -292,8 +292,8 @@ H5A__dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_U H5MM_memcpy(raw, nrecord->id.id, (size_t)H5O_FHEAP_ID_LEN); raw += H5O_FHEAP_ID_LEN; *raw++ = nrecord->flags; - UINT32ENCODE(raw, nrecord->corder) - UINT32ENCODE(raw, nrecord->hash) + UINT32ENCODE(raw, nrecord->corder); + UINT32ENCODE(raw, nrecord->hash); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_encode() */ @@ -319,8 +319,8 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U H5MM_memcpy(nrecord->id.id, raw, (size_t)H5O_FHEAP_ID_LEN); raw += H5O_FHEAP_ID_LEN; nrecord->flags = *raw++; - UINT32DECODE(raw, nrecord->corder) - UINT32DECODE(raw, nrecord->hash) + UINT32DECODE(raw, nrecord->corder); + UINT32DECODE(raw, nrecord->hash); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_name_decode() */ @@ -430,7 +430,7 @@ H5A__dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR H5MM_memcpy(raw, nrecord->id.id, (size_t)H5O_FHEAP_ID_LEN); raw += H5O_FHEAP_ID_LEN; *raw++ = nrecord->flags; - UINT32ENCODE(raw, nrecord->corder) + UINT32ENCODE(raw, nrecord->corder); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_encode() */ @@ -456,7 +456,7 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR H5MM_memcpy(nrecord->id.id, raw, (size_t)H5O_FHEAP_ID_LEN); raw += H5O_FHEAP_ID_LEN; nrecord->flags = *raw++; - UINT32DECODE(raw, nrecord->corder) + UINT32DECODE(raw, nrecord->corder); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5A__dense_btree2_corder_decode() */ diff --git a/src/H5Adense.c b/src/H5Adense.c index 248f5a7..0f8924e 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -244,11 +244,11 @@ H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo) done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_create() */ @@ -385,11 +385,11 @@ H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, NULL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_open() */ @@ -533,15 +533,15 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); if (wb && H5WB_unwrap(wb) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_insert() */ @@ -679,9 +679,9 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) done: /* Release resources */ if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); if (wb && H5WB_unwrap(wb) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write_bt2_cb() */ @@ -768,11 +768,11 @@ H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_write() */ @@ -983,13 +983,13 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, cons done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); if (attr_copy) H5O_msg_free(H5O_ATTR_ID, attr_copy); @@ -1208,13 +1208,13 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index"); if (atable.attrs && H5A__attr_release_table(&atable) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_iterate() */ @@ -1274,7 +1274,7 @@ H5A__dense_remove_bt2_cb(const void *_record, void *_udata) done: /* Release resources */ if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_bt2_cb() */ @@ -1351,11 +1351,11 @@ H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); if (attr_copy) H5O_msg_free_real(H5O_MSG_ATTR, attr_copy); @@ -1477,7 +1477,7 @@ H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) done: /* Release resources */ if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index"); if (fh_udata.attr) H5O_msg_free(H5O_ATTR_ID, fh_udata.attr); @@ -1596,13 +1596,13 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index"); if (atable.attrs && H5A__attr_release_table(&atable) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_remove_by_idx() */ @@ -1681,11 +1681,11 @@ H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name, hbool_t done: /* Release resources */ if (shared_fheap && H5HF_close(shared_fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_exists() */ @@ -1812,7 +1812,7 @@ H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo) done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_delete() */ diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 2aa5205..f996774 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -147,7 +147,7 @@ done: /* Clean up on failure */ if (H5I_INVALID_HID == ret_value) if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute"); FUNC_LEAVE_API(ret_value) } /* end H5Acreate1() */ @@ -212,7 +212,7 @@ done: /* Clean up on failure */ if (H5I_INVALID_HID == ret_value) if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute"); FUNC_LEAVE_API(ret_value) } /* H5Aopen_name() */ @@ -280,7 +280,7 @@ done: /* Clean up on failure */ if (H5I_INVALID_HID == ret_value) if (attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute"); FUNC_LEAVE_API(ret_value) } /* H5Aopen_idx() */ diff --git a/src/H5Aint.c b/src/H5Aint.c index 62a9592..6a78e0c 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -381,7 +381,7 @@ H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, cons done: /* Cleanup on failure */ if (NULL == ret_value && attr && H5A__close(attr)) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5A__create() */ @@ -433,12 +433,12 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location"); /* Cleanup on failure */ if (ret_value == NULL) if (attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__create_by_name() */ @@ -532,7 +532,7 @@ done: /* Cleanup on failure */ if (ret_value == NULL) if (attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open() */ @@ -587,12 +587,12 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location"); /* Cleanup on failure */ if (ret_value == NULL) if (attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_idx() */ @@ -647,12 +647,12 @@ H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_n done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location"); /* Cleanup on failure */ if (ret_value == NULL) if (attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__open_by_name() */ @@ -769,9 +769,9 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) done: /* Release resources */ if (src_id >= 0 && H5I_dec_ref(src_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); if (tconv_buf) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); if (bkg_buf) @@ -907,9 +907,9 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) done: /* Release resources */ if (src_id >= 0 && H5I_dec_ref(src_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); if (tconv_buf) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); if (bkg_buf) @@ -996,7 +996,7 @@ H5A_get_space(H5A_t *attr) done: if (H5I_INVALID_HID == ret_value && ds && H5S_close(ds) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataspace") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_get_space() */ @@ -1057,7 +1057,7 @@ H5A__get_type(H5A_t *attr) done: if (H5I_INVALID_HID == ret_value) if (dt && H5T_close(dt) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_type() */ @@ -1193,7 +1193,7 @@ H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) done: if (ret_value == NULL) if (allocated_attr && new_attr && H5A__close(new_attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__copy() */ @@ -1229,12 +1229,12 @@ H5A__shared_free(H5A_t *attr) } if (attr->shared->dt) { if (H5T_close_real(attr->shared->dt) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info"); attr->shared->dt = NULL; } if (attr->shared->ds) { if (H5S_close(attr->shared->ds) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info"); attr->shared->ds = NULL; } if (attr->shared->data) @@ -1445,7 +1445,7 @@ H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name, done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__exists_by_name() */ @@ -1675,7 +1675,7 @@ H5A__dense_build_table(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, done: /* Release resources */ if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_build_table() */ @@ -1808,18 +1808,18 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, H5_iter_orde /* Pick appropriate comparison routine */ if (idx_type == H5_INDEX_NAME) { if (order == H5_ITER_INC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_inc); + qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_inc); else if (order == H5_ITER_DEC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_dec); + qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_name_dec); else assert(order == H5_ITER_NATIVE); } /* end if */ else { assert(idx_type == H5_INDEX_CRT_ORDER); if (order == H5_ITER_INC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_inc); + qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_inc); else if (order == H5_ITER_DEC) - HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_dec); + qsort(atable->attrs, atable->nattrs, sizeof(H5A_t *), H5A__attr_cmp_corder_dec); else assert(order == H5_ITER_NATIVE); } /* end else */ @@ -1855,7 +1855,7 @@ H5A__attr_iterate_table(const H5A_attr_table_t *atable, hsize_t skip, hsize_t *l *last_attr = skip; /* Iterate over attribute messages */ - H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t) + H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t); for (; u < atable->nattrs && !ret_value; u++) { /* Check which type of callback to make */ switch (attr_op->op_type) { @@ -1993,7 +1993,7 @@ H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo) done: /* Release resources */ if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5A__get_ainfo() */ @@ -2313,19 +2313,19 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s done: if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID"); if (tid_src > 0) /* Don't decrement ID, we want to keep underlying datatype */ if (NULL == H5I_remove(tid_src)) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID"); if (tid_dst > 0) /* Don't decrement ID, we want to keep underlying datatype */ if (NULL == H5I_remove(tid_dst)) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID"); if (tid_mem > 0) /* Decrement the memory datatype ID, it's transient */ if (H5I_dec_ref(tid_mem) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID"); if (buf) buf = H5FL_BLK_FREE(attr_buf, buf); if (reclaim_buf) @@ -2335,7 +2335,7 @@ done: /* Release destination attribute information on failure */ if (!ret_value && attr_dst && H5A__close(attr_dst) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__attr_copy_file() */ @@ -2468,18 +2468,18 @@ H5A__dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to reset attribute sharing") /* Set COPIED tag for destination object's metadata */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Insert attribute into dense storage */ if (H5A__dense_insert(udata->file, udata->ainfo, attr_dst) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage"); /* Reset metadata tag */ H5_END_TAG done: if (attr_dst && H5A__close(attr_dst) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close destination attribute") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close destination attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_post_copy_file_cb() */ @@ -2566,7 +2566,7 @@ H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_na done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__rename_by_name() */ @@ -2742,7 +2742,7 @@ H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__delete_by_name() */ @@ -2785,7 +2785,7 @@ H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_ty done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* H5A__delete_by_idx() */ diff --git a/src/H5Atest.c b/src/H5Atest.c index 92e199f..fdaf8bd 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -130,7 +130,7 @@ H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__get_shared_rc_test() */ diff --git a/src/H5B.c b/src/H5B.c index 16ae4f1..4c87f11 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -249,7 +249,7 @@ done: if (bt) /* Destroy B-tree node */ if (H5B__node_dest(bt) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -344,7 +344,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, hbool_t *found, void * done: if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_find() */ @@ -498,7 +498,7 @@ done: if (ret_value < 0) { if (split_bt_ud->bt && H5AC_unprotect(f, H5AC_BT, split_bt_ud->addr, split_bt_ud->bt, split_bt_ud->cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node"); split_bt_ud->bt = NULL; split_bt_ud->addr = HADDR_UNDEF; split_bt_ud->cache_flags = H5AC__NO_FLAGS_SET; @@ -570,7 +570,7 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) if (H5B_INS_NOOP == my_ins) { /* The root node did not split - just return */ assert(!split_bt_ud.bt); - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ assert(H5B_INS_RIGHT == my_ins); assert(split_bt_ud.bt); @@ -643,11 +643,11 @@ done: if (bt_ud.bt) if (H5AC_unprotect(f, H5AC_BT, bt_ud.addr, bt_ud.bt, bt_ud.cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect old root") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect old root"); if (split_bt_ud.bt) if (H5AC_unprotect(f, H5AC_BT, split_bt_ud.addr, split_bt_ud.bt, split_bt_ud.cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect new child") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect new child"); #ifdef H5B_DEBUG if (ret_value >= 0) @@ -703,7 +703,7 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, haddr_t child, H5 } /* end if */ else { /* Make room for the new key */ - HDmemmove(base + shared->type->sizeof_nkey, base, (bt->nchildren - idx) * shared->type->sizeof_nkey); + memmove(base + shared->type->sizeof_nkey, base, (bt->nchildren - idx) * shared->type->sizeof_nkey); H5MM_memcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ @@ -711,7 +711,7 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, haddr_t child, H5 idx++; /* Make room for the new child address */ - HDmemmove(bt->child + idx + 1, bt->child + idx, (bt->nchildren - idx) * sizeof(haddr_t)); + memmove(bt->child + idx + 1, bt->child + idx, (bt->nchildren - idx) * sizeof(haddr_t)); } /* end if */ bt->child[idx] = child; @@ -1066,12 +1066,12 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8 done: if (child_bt_ud.bt) if (H5AC_unprotect(f, H5AC_BT, child_bt_ud.addr, child_bt_ud.bt, child_bt_ud.cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect child") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect child"); if (new_child_bt_ud.bt) if (H5AC_unprotect(f, H5AC_BT, new_child_bt_ud.addr, new_child_bt_ud.bt, new_child_bt_ud.cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect new child") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect new child"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_insert_helper() */ @@ -1132,7 +1132,7 @@ H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operato done: if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__iterate_helper() */ @@ -1401,8 +1401,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, u */ if (type->critical_key == H5B_LEFT) { /* Slide all keys down 1, update lt_key */ - HDmemmove(H5B_NKEY(bt, shared, 0), H5B_NKEY(bt, shared, 1), - bt->nchildren * type->sizeof_nkey); + memmove(H5B_NKEY(bt, shared, 0), H5B_NKEY(bt, shared, 1), bt->nchildren * type->sizeof_nkey); H5MM_memcpy(lt_key, H5B_NKEY(bt, shared, 0), type->sizeof_nkey); *lt_key_changed = TRUE; } @@ -1410,10 +1409,10 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, u /* Slide all but the leftmost 2 keys down, leaving the leftmost * key intact (the right key of the leftmost child is * overwritten) */ - HDmemmove(H5B_NKEY(bt, shared, 1), H5B_NKEY(bt, shared, 2), - (bt->nchildren - 1) * type->sizeof_nkey); + memmove(H5B_NKEY(bt, shared, 1), H5B_NKEY(bt, shared, 2), + (bt->nchildren - 1) * type->sizeof_nkey); - HDmemmove(bt->child, bt->child + 1, (bt->nchildren - 1) * sizeof(haddr_t)); + memmove(bt->child, bt->child + 1, (bt->nchildren - 1) * sizeof(haddr_t)); bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; @@ -1428,8 +1427,8 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, u if (type->critical_key == H5B_LEFT) /* Slide the rightmost key down one, overwriting the left key of * the deleted (rightmost) child */ - HDmemmove(H5B_NKEY(bt, shared, bt->nchildren - 1), H5B_NKEY(bt, shared, bt->nchildren), - type->sizeof_nkey); + memmove(H5B_NKEY(bt, shared, bt->nchildren - 1), H5B_NKEY(bt, shared, bt->nchildren), + type->sizeof_nkey); else { /* Just update rt_key */ H5MM_memcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren - 1), type->sizeof_nkey); @@ -1449,13 +1448,13 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, u * Return H5B_INS_NOOP. */ if (type->critical_key == H5B_LEFT) - HDmemmove(H5B_NKEY(bt, shared, idx), H5B_NKEY(bt, shared, idx + 1), - (bt->nchildren - idx) * type->sizeof_nkey); + memmove(H5B_NKEY(bt, shared, idx), H5B_NKEY(bt, shared, idx + 1), + (bt->nchildren - idx) * type->sizeof_nkey); else - HDmemmove(H5B_NKEY(bt, shared, idx + 1), H5B_NKEY(bt, shared, idx + 2), - (bt->nchildren - 1 - idx) * type->sizeof_nkey); + memmove(H5B_NKEY(bt, shared, idx + 1), H5B_NKEY(bt, shared, idx + 2), + (bt->nchildren - 1 - idx) * type->sizeof_nkey); - HDmemmove(bt->child + idx, bt->child + idx + 1, (bt->nchildren - 1 - idx) * sizeof(haddr_t)); + memmove(bt->child + idx, bt->child + idx + 1, (bt->nchildren - 1 - idx) * sizeof(haddr_t)); bt->nchildren -= 1; bt_flags |= H5AC__DIRTIED_FLAG; @@ -1499,7 +1498,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, u done: if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, bt_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__remove_helper() */ @@ -1613,7 +1612,7 @@ H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) done: if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node in cache") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node in cache"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_delete() */ @@ -1874,7 +1873,7 @@ H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, const H5B_ done: if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__get_info_helper() */ @@ -1972,7 +1971,7 @@ H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr) done: /* Release the node */ if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_valid() */ diff --git a/src/H5B2.c b/src/H5B2.c index ebbde9b..63ca28c 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -164,10 +164,10 @@ H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) done: if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header"); if (!ret_value && bt2) if (H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree") + HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_create() */ @@ -226,10 +226,10 @@ H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) done: if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header"); if (!ret_value && bt2) if (H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree") + HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close v2 B-tree"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_open() */ @@ -455,7 +455,7 @@ H5B2_find(H5B2_t *bt2, void *udata, hbool_t *found, H5B2_found_t op, void *op_da /* Check for empty tree */ if (curr_node_ptr.node_nrec == 0) { *found = FALSE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* Check record against min & max records in tree, to attempt to quickly @@ -466,14 +466,14 @@ H5B2_find(H5B2_t *bt2, void *udata, hbool_t *found, H5B2_found_t op, void *op_da HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") if (cmp < 0) { *found = FALSE; /* Less than the least record--not found */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } else if (cmp == 0) { /* Record is found */ if (op && (op)(hdr->min_native_rec, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") *found = TRUE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ } /* end if */ if (hdr->max_native_rec != NULL) { @@ -481,14 +481,14 @@ H5B2_find(H5B2_t *bt2, void *udata, hbool_t *found, H5B2_found_t op, void *op_da HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") if (cmp > 0) { *found = FALSE; /* Greater than the largest record--not found */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } else if (cmp == 0) { /* Record is found */ if (op && (op)(hdr->max_native_rec, op_data) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "'found' callback failed for B-tree find operation") *found = TRUE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ } /* end if */ @@ -580,7 +580,7 @@ H5B2_find(H5B2_t *bt2, void *udata, hbool_t *found, H5B2_found_t op, void *op_da /* Indicate record found */ *found = TRUE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end else */ /* Decrement depth we're at in B-tree */ @@ -616,7 +616,7 @@ H5B2_find(H5B2_t *bt2, void *udata, hbool_t *found, H5B2_found_t op, void *op_da /* Record not found */ *found = FALSE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ else { /* Make callback for current record */ @@ -665,7 +665,7 @@ done: if (parent) { assert(ret_value < 0); if (parent != hdr && H5AC_unpin_entry(parent) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -861,7 +861,7 @@ done: if (parent) { assert(ret_value < 0); if (parent != hdr && H5AC_unpin_entry(parent) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1276,16 +1276,12 @@ H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - /* Note: don't push error on stack, leave that to next higher level, - * since many times the B-tree is searched in order to determine - * if an object exists in the B-tree or not. -QAK - */ -#ifdef OLD_WAY - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node") -#else /* OLD_WAY */ - HGOTO_DONE(FAIL) -#endif /* OLD_WAY */ - } /* end if */ + /* Note: don't push error on stack, leave that to next higher level, + * since many times the B-tree is searched in order to determine + * if an object exists in the B-tree or not. + */ + HGOTO_DONE(FAIL); + } else { /* Make callback for current record */ if ((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { @@ -1336,7 +1332,7 @@ done: if (parent) { assert(ret_value < 0); if (parent != hdr && H5AC_unpin_entry(parent) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1495,7 +1491,7 @@ H5B2_delete(H5F_t *f, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_ done: /* Unprotect the header, if an error occurred */ if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_delete() */ diff --git a/src/H5B2cache.c b/src/H5B2cache.c index d63baa1..2c749ff 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -13,10 +13,8 @@ /*------------------------------------------------------------------------- * * Created: H5B2cache.c - * Jan 31 2005 - * Quincey Koziol * - * Purpose: Implement v2 B-tree metadata cache methods. + * Purpose: Implement v2 B-tree metadata cache methods * *------------------------------------------------------------------------- */ @@ -30,10 +28,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5B2pkg.h" /* B-Trees (Version 2) */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory Management */ /****************/ /* Local Macros */ @@ -268,7 +269,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void cparam.merge_percent = *image++; /* Root node pointer */ - H5_addr_decode(udata->f, (const uint8_t **)&image, &(hdr->root.addr)); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &(hdr->root.addr)); UINT16DECODE(image, hdr->root.node_nrec); H5F_DECODE_LENGTH(udata->f, image, hdr->root.all_nrec); @@ -297,7 +298,7 @@ H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void done: if (!ret_value && hdr) if (H5B2__hdr_free(hdr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, NULL, "can't release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, NULL, "can't release v2 B-tree header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__cache_hdr_deserialize() */ @@ -378,7 +379,7 @@ H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le *image++ = (uint8_t)hdr->merge_percent; /* Root node pointer */ - H5_addr_encode(f, &image, hdr->root.addr); + H5F_addr_encode(f, &image, hdr->root.addr); UINT16ENCODE(image, hdr->root.node_nrec); H5F_ENCODE_LENGTH(f, image, hdr->root.all_nrec); @@ -663,12 +664,12 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void int_node_ptr = internal->node_ptrs; for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Decode node pointer */ - H5_addr_decode(udata->f, (const uint8_t **)&image, &(int_node_ptr->addr)); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &(int_node_ptr->addr)); UINT64DECODE_VAR(image, node_nrec, udata->hdr->max_nrec_size); H5_CHECKED_ASSIGN(int_node_ptr->node_nrec, uint16_t, node_nrec, int); if (udata->depth > 1) UINT64DECODE_VAR(image, int_node_ptr->all_nrec, - udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size) + udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size); else int_node_ptr->all_nrec = int_node_ptr->node_nrec; @@ -690,7 +691,7 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void done: if (!ret_value && internal) if (H5B2__internal_free(internal) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_int_deserialize() */ @@ -779,7 +780,7 @@ H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le int_node_ptr = internal->node_ptrs; for (u = 0; u < (unsigned)(internal->nrec + 1); u++) { /* Encode node pointer */ - H5_addr_encode(f, &image, int_node_ptr->addr); + H5F_addr_encode(f, &image, int_node_ptr->addr); UINT64ENCODE_VAR(image, int_node_ptr->node_nrec, internal->hdr->max_nrec_size); if (internal->depth > 1) UINT64ENCODE_VAR(image, int_node_ptr->all_nrec, @@ -1063,7 +1064,7 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void done: if (!ret_value && leaf) if (H5B2__leaf_free(leaf) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__cache_leaf_deserialize() */ diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 0f498a8..f246e97 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -131,7 +131,7 @@ H5B2__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, done: if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_debug() */ @@ -183,7 +183,7 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, co */ H5_CHECK_OVERFLOW(depth, unsigned, uint16_t); node_ptr.addr = addr; - H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) + H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned); if (NULL == (internal = H5B2__protect_internal(hdr, NULL, &node_ptr, (uint16_t)depth, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node") @@ -227,9 +227,9 @@ H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, co done: if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header"); if (internal && H5AC_unprotect(f, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__int_debug() */ @@ -281,7 +281,7 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, c */ H5_CHECK_OVERFLOW(nrec, unsigned, uint16_t); node_ptr.addr = addr; - H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned) + H5_CHECKED_ASSIGN(node_ptr.node_nrec, uint16_t, nrec, unsigned); if (NULL == (leaf = H5B2__protect_leaf(hdr, NULL, &node_ptr, FALSE, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") @@ -312,9 +312,9 @@ H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, c done: if (hdr && H5B2__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header"); if (leaf && H5AC_unprotect(f, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__leaf_debug() */ diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 671cdc3..49d5593 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -137,7 +137,7 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, ui /* Initialize leaf node info */ sz_max_nrec = H5B2_NUM_LEAF_REC(hdr->node_size, hdr->rrec_size); - H5_CHECKED_ASSIGN(hdr->node_info[0].max_nrec, unsigned, sz_max_nrec, size_t) + H5_CHECKED_ASSIGN(hdr->node_info[0].max_nrec, unsigned, sz_max_nrec, size_t); hdr->node_info[0].split_nrec = (hdr->node_info[0].max_nrec * hdr->split_percent) / 100; hdr->node_info[0].merge_nrec = (hdr->node_info[0].max_nrec * hdr->merge_percent) / 100; hdr->node_info[0].cum_max_nrec = hdr->node_info[0].max_nrec; @@ -160,14 +160,14 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, ui /* Compute size to store # of records in each node */ /* (uses leaf # of records because its the largest) */ u_max_nrec_size = H5VM_limit_enc_size((uint64_t)hdr->node_info[0].max_nrec); - H5_CHECKED_ASSIGN(hdr->max_nrec_size, uint8_t, u_max_nrec_size, unsigned) + H5_CHECKED_ASSIGN(hdr->max_nrec_size, uint8_t, u_max_nrec_size, unsigned); assert(hdr->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE); /* Initialize internal node info */ if (depth > 0) { for (u = 1; u < (unsigned)(depth + 1); u++) { sz_max_nrec = H5B2_NUM_INT_REC(hdr, u); - H5_CHECKED_ASSIGN(hdr->node_info[u].max_nrec, unsigned, sz_max_nrec, size_t) + H5_CHECKED_ASSIGN(hdr->node_info[u].max_nrec, unsigned, sz_max_nrec, size_t); assert(hdr->node_info[u].max_nrec <= hdr->node_info[u - 1].max_nrec); hdr->node_info[u].split_nrec = (hdr->node_info[u].max_nrec * hdr->split_percent) / 100; @@ -177,7 +177,7 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, ui ((hdr->node_info[u].max_nrec + 1) * hdr->node_info[u - 1].cum_max_nrec) + hdr->node_info[u].max_nrec; u_max_nrec_size = H5VM_limit_enc_size((uint64_t)hdr->node_info[u].cum_max_nrec); - H5_CHECKED_ASSIGN(hdr->node_info[u].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned) + H5_CHECKED_ASSIGN(hdr->node_info[u].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned); if (NULL == (hdr->node_info[u].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[u].max_nrec))) @@ -204,7 +204,7 @@ H5B2__hdr_init(H5B2_hdr_t *hdr, const H5B2_create_t *cparam, void *ctx_udata, ui done: if (ret_value < 0) if (H5B2__hdr_free(hdr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free shared v2 B-tree info") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free shared v2 B-tree info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_init() */ @@ -312,16 +312,16 @@ done: if (inserted) if (H5AC_remove_entry(hdr) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, HADDR_UNDEF, - "unable to remove v2 B-tree header from cache") + "unable to remove v2 B-tree header from cache"); /* Release header's disk space */ if (H5_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_BTREE, hdr->addr, (hsize_t)hdr->hdr_size) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free v2 B-tree header"); /* Destroy header */ if (H5B2__hdr_free(hdr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release v2 B-tree header"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -520,7 +520,7 @@ done: /* Release the header, if it was protected */ if (hdr && H5AC_unprotect(hdr->f, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, - "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) + "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr_addr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -674,7 +674,7 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr) done: /* Unprotect the header with appropriate flags */ if (H5B2__hdr_unprotect(hdr, cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_delete() */ diff --git a/src/H5B2int.c b/src/H5B2int.c index 766157b..a514078 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -151,10 +151,10 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Slide records in parent node up one space, to make room for promoted record */ if (idx < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx + 1), H5B2_INT_NREC(internal, hdr, idx), - hdr->cls->nrec_size * (internal->nrec - idx)); - HDmemmove(&(internal->node_ptrs[idx + 2]), &(internal->node_ptrs[idx + 1]), - sizeof(H5B2_node_ptr_t) * (internal->nrec - idx)); + memmove(H5B2_INT_NREC(internal, hdr, idx + 1), H5B2_INT_NREC(internal, hdr, idx), + hdr->cls->nrec_size * (internal->nrec - idx)); + memmove(&(internal->node_ptrs[idx + 2]), &(internal->node_ptrs[idx + 1]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - idx)); } /* end if */ /* Check for the kind of B-tree node to split */ @@ -309,9 +309,9 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, done: /* Release child nodes (marked as dirty) */ if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node"); if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__split1() */ @@ -351,14 +351,14 @@ H5B2__split_root(H5B2_hdr_t *hdr) /* Update node info for new depth of tree */ sz_max_nrec = H5B2_NUM_INT_REC(hdr, hdr->depth); - H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].max_nrec, unsigned, sz_max_nrec, size_t) + H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].max_nrec, unsigned, sz_max_nrec, size_t); hdr->node_info[hdr->depth].split_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->split_percent) / 100; hdr->node_info[hdr->depth].merge_nrec = (hdr->node_info[hdr->depth].max_nrec * hdr->merge_percent) / 100; hdr->node_info[hdr->depth].cum_max_nrec = ((hdr->node_info[hdr->depth].max_nrec + 1) * hdr->node_info[hdr->depth - 1].cum_max_nrec) + hdr->node_info[hdr->depth].max_nrec; u_max_nrec_size = H5VM_limit_enc_size((uint64_t)hdr->node_info[hdr->depth].cum_max_nrec); - H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned) + H5_CHECKED_ASSIGN(hdr->node_info[hdr->depth].cum_max_nrec_size, uint8_t, u_max_nrec_size, unsigned); if (NULL == (hdr->node_info[hdr->depth].nat_rec_fac = H5FL_fac_init(hdr->cls->nrec_size * hdr->node_info[hdr->depth].max_nrec))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory") @@ -390,7 +390,7 @@ H5B2__split_root(H5B2_hdr_t *hdr) done: /* Release new root node (marked as dirty) */ if (new_root && H5AC_unprotect(hdr->f, H5AC_BT2_INT, hdr->root.addr, new_root, new_root_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree internal node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree internal node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__split_root() */ @@ -521,8 +521,8 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, hdr->cls->nrec_size); /* Slide records in right node down */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, move_nrec), - hdr->cls->nrec_size * new_right_nrec); + memmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, move_nrec), + hdr->cls->nrec_size * new_right_nrec); /* Handle node pointers, if we have an internal node */ if (depth > 1) { @@ -532,7 +532,7 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, /* Count the number of records being moved */ for (u = 0; u < move_nrec; u++) moved_nrec += right_node_ptrs[u].all_nrec; - H5_CHECKED_ASSIGN(left_moved_nrec, hssize_t, moved_nrec, hsize_t) + H5_CHECKED_ASSIGN(left_moved_nrec, hssize_t, moved_nrec, hsize_t); right_moved_nrec -= (hssize_t)moved_nrec; /* Copy node pointers from right node to left */ @@ -540,8 +540,8 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, sizeof(H5B2_node_ptr_t) * move_nrec); /* Slide node pointers in right node down */ - HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[move_nrec]), - sizeof(H5B2_node_ptr_t) * (new_right_nrec + (unsigned)1)); + memmove(&(right_node_ptrs[0]), &(right_node_ptrs[move_nrec]), + sizeof(H5B2_node_ptr_t) * (new_right_nrec + (unsigned)1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ @@ -571,8 +571,8 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, assert(*left_nrec > *right_nrec); /* Slide records in right node up */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, move_nrec), H5B2_NAT_NREC(right_native, hdr, 0), - hdr->cls->nrec_size * (*right_nrec)); + memmove(H5B2_NAT_NREC(right_native, hdr, move_nrec), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Copy record from parent node down into right child */ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, (move_nrec - 1)), H5B2_INT_NREC(internal, hdr, idx), @@ -594,8 +594,8 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned u; /* Local index variable */ /* Slide node pointers in right node up */ - HDmemmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), - sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + memmove(&(right_node_ptrs[move_nrec]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Copy node pointers from left node to right */ H5MM_memcpy(&(right_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), @@ -605,7 +605,7 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, for (u = 0; u < move_nrec; u++) moved_nrec += right_node_ptrs[u].all_nrec; left_moved_nrec -= (hssize_t)moved_nrec; - H5_CHECKED_ASSIGN(right_moved_nrec, hssize_t, moved_nrec, hsize_t) + H5_CHECKED_ASSIGN(right_moved_nrec, hssize_t, moved_nrec, hsize_t); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ @@ -656,9 +656,9 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, done: /* Release child nodes (marked as dirty) */ if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__redistribute2() */ @@ -813,9 +813,9 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, moved_middle_nrec++; /* Slide records in middle node down */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), - H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), - hdr->cls->nrec_size * (size_t)(*middle_nrec - moved_middle_nrec)); + memmove(H5B2_NAT_NREC(middle_native, hdr, 0), + H5B2_NAT_NREC(middle_native, hdr, moved_middle_nrec), + hdr->cls->nrec_size * (size_t)(*middle_nrec - moved_middle_nrec)); /* Move node pointers also if this is an internal node */ if (depth > 1) { @@ -835,8 +835,8 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, middle_moved_nrec -= (hssize_t)(moved_nrec + move_nptrs); /* Slide the node pointers in middle node down */ - HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[move_nptrs]), - sizeof(H5B2_node_ptr_t) * ((*middle_nrec - move_nptrs) + 1)); + memmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[move_nptrs]), + sizeof(H5B2_node_ptr_t) * ((*middle_nrec - move_nptrs) + 1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ @@ -860,8 +860,8 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, (unsigned)(new_right_nrec - *right_nrec); /* Number of records to move out of right node */ /* Slide records in right node up */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), - hdr->cls->nrec_size * (*right_nrec)); + memmove(H5B2_NAT_NREC(right_native, hdr, right_nrec_move), H5B2_NAT_NREC(right_native, hdr, 0), + hdr->cls->nrec_size * (*right_nrec)); /* Move right parent record down to right node */ H5MM_memcpy(H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), @@ -884,8 +884,8 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned u; /* Local index variable */ /* Slide the node pointers in right node up */ - HDmemmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), - sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); + memmove(&(right_node_ptrs[right_nrec_move]), &(right_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(*right_nrec + 1)); /* Move middle node pointers into right node */ H5MM_memcpy(&(right_node_ptrs[0]), @@ -920,8 +920,8 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, (unsigned)(*left_nrec - new_left_nrec); /* Number of records to move out of left node */ /* Slide middle records up */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), - hdr->cls->nrec_size * curr_middle_nrec); + memmove(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move), H5B2_NAT_NREC(middle_native, hdr, 0), + hdr->cls->nrec_size * curr_middle_nrec); /* Move left parent record down to middle node */ H5MM_memcpy(H5B2_NAT_NREC(middle_native, hdr, left_nrec_move - 1), @@ -929,9 +929,9 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, /* Move left records to middle node */ if (left_nrec_move > 1) - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), - H5B2_NAT_NREC(left_native, hdr, new_left_nrec + 1), - hdr->cls->nrec_size * (left_nrec_move - 1)); + memmove(H5B2_NAT_NREC(middle_native, hdr, 0), + H5B2_NAT_NREC(left_native, hdr, new_left_nrec + 1), + hdr->cls->nrec_size * (left_nrec_move - 1)); /* Move left parent record up from left node */ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx - 1), H5B2_NAT_NREC(left_native, hdr, new_left_nrec), @@ -943,8 +943,8 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsigned u; /* Local index variable */ /* Slide the node pointers in middle node up */ - HDmemmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), - sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1)); + memmove(&(middle_node_ptrs[left_nrec_move]), &(middle_node_ptrs[0]), + sizeof(H5B2_node_ptr_t) * (size_t)(curr_middle_nrec + 1)); /* Move left node pointers into middle node */ H5MM_memcpy(&(middle_node_ptrs[0]), &(left_node_ptrs[new_left_nrec + 1]), @@ -981,16 +981,16 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, H5B2_INT_NREC(internal, hdr, idx), hdr->cls->nrec_size); /* Move right records to middle node */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec + 1)), - H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (right_nrec_move - 1)); + memmove(H5B2_NAT_NREC(middle_native, hdr, (curr_middle_nrec + 1)), + H5B2_NAT_NREC(right_native, hdr, 0), hdr->cls->nrec_size * (right_nrec_move - 1)); /* Move right parent record up from right node */ H5MM_memcpy(H5B2_INT_NREC(internal, hdr, idx), H5B2_NAT_NREC(right_native, hdr, right_nrec_move - 1), hdr->cls->nrec_size); /* Slide right records down */ - HDmemmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, right_nrec_move), - hdr->cls->nrec_size * new_right_nrec); + memmove(H5B2_NAT_NREC(right_native, hdr, 0), H5B2_NAT_NREC(right_native, hdr, right_nrec_move), + hdr->cls->nrec_size * new_right_nrec); /* Move node pointers also if this is an internal node */ if (depth > 1) { @@ -1008,8 +1008,8 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, middle_moved_nrec += (hssize_t)(moved_nrec + right_nrec_move); /* Slide the node pointers in right node down */ - HDmemmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), - sizeof(H5B2_node_ptr_t) * (size_t)(new_right_nrec + 1)); + memmove(&(right_node_ptrs[0]), &(right_node_ptrs[right_nrec_move]), + sizeof(H5B2_node_ptr_t) * (size_t)(new_right_nrec + 1)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ @@ -1075,12 +1075,12 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, done: /* Unlock child nodes (marked as dirty) */ if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); if (middle_child && H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__redistribute3() */ @@ -1218,10 +1218,10 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Slide records in parent node down, to eliminate demoted record */ if ((idx + 1) < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), - hdr->cls->nrec_size * (internal->nrec - (idx + 1))); - HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), - sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); + memmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), + hdr->cls->nrec_size * (internal->nrec - (idx + 1))); + memmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); } /* end if */ /* Update # of records in parent node */ @@ -1248,11 +1248,11 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, done: /* Unlock left node (marked as dirty) */ if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); /* Delete right node & remove from cache (marked as dirty) */ if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__merge2() */ @@ -1396,8 +1396,8 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, H5B2_NAT_NREC(middle_native, hdr, (middle_nrec_move - 1)), hdr->cls->nrec_size); /* Slide records in middle node down */ - HDmemmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, middle_nrec_move), - hdr->cls->nrec_size * (*middle_nrec - middle_nrec_move)); + memmove(H5B2_NAT_NREC(middle_native, hdr, 0), H5B2_NAT_NREC(middle_native, hdr, middle_nrec_move), + hdr->cls->nrec_size * (*middle_nrec - middle_nrec_move)); /* Move node pointers also if this is an internal node */ if (depth > 1) { @@ -1412,8 +1412,8 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, middle_moved_nrec += middle_node_ptrs[u].all_nrec; /* Slide the node pointers in middle node down */ - HDmemmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), - sizeof(H5B2_node_ptr_t) * (size_t)((unsigned)(*middle_nrec + 1) - middle_nrec_move)); + memmove(&(middle_node_ptrs[0]), &(middle_node_ptrs[middle_nrec_move]), + sizeof(H5B2_node_ptr_t) * (size_t)((unsigned)(*middle_nrec + 1) - middle_nrec_move)); } /* end if */ /* Update flush dependencies for grandchildren, if using SWMR */ @@ -1475,10 +1475,10 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, /* Slide records in parent node down, to eliminate demoted record */ if ((idx + 1) < internal->nrec) { - HDmemmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), - hdr->cls->nrec_size * (internal->nrec - (idx + 1))); - HDmemmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), - sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); + memmove(H5B2_INT_NREC(internal, hdr, idx), H5B2_INT_NREC(internal, hdr, idx + 1), + hdr->cls->nrec_size * (internal->nrec - (idx + 1))); + memmove(&(internal->node_ptrs[idx + 1]), &(internal->node_ptrs[idx + 2]), + sizeof(H5B2_node_ptr_t) * (internal->nrec - (idx + 1))); } /* end if */ /* Update # of records in parent node */ @@ -1510,14 +1510,14 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, done: /* Unlock left & middle nodes (marked as dirty) */ if (left_child && H5AC_unprotect(hdr->f, child_class, left_addr, left_child, left_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); if (middle_child && H5AC_unprotect(hdr->f, child_class, middle_addr, middle_child, middle_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); /* Delete right node & remove from cache (marked as dirty) */ if (right_child && H5AC_unprotect(hdr->f, child_class, right_addr, right_child, right_child_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__merge3() */ @@ -1683,7 +1683,7 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, done: /* Unpin the node if it was pinned */ if (node_pinned && H5AC_unpin_entry(node) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "can't unpin node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "can't unpin node"); /* Release the node pointers & native records, if they were copied */ if (node_ptrs) @@ -1770,7 +1770,7 @@ done: if (node && H5AC_unprotect( hdr->f, curr_node_class, curr_node->addr, node, (unsigned)(H5AC__DELETED_FLAG | (hdr->swmr_write ? 0 : H5AC__FREE_FILE_SPACE_FLAG))) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__delete_node() */ @@ -1823,7 +1823,7 @@ H5B2__node_size(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node, voi done: if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__node_size() */ @@ -1946,7 +1946,7 @@ done: /* Unprotect the child */ if (child) if (H5AC_unprotect(hdr->f, child_class, node_ptr->addr, child, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__update_flush_depend() */ diff --git a/src/H5B2internal.c b/src/H5B2internal.c index e3f1cf9..e8405de 100644 --- a/src/H5B2internal.c +++ b/src/H5B2internal.c @@ -145,17 +145,17 @@ done: if (inserted) if (H5AC_remove_entry(internal) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, - "unable to remove v2 B-tree internal node from cache") + "unable to remove v2 B-tree internal node from cache"); /* Release internal node's disk space */ if (H5_addr_defined(node_ptr->addr) && H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, - "unable to release file space for v2 B-tree internal node") + "unable to release file space for v2 B-tree internal node"); /* Destroy internal node */ if (H5B2__internal_free(internal) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree internal node"); } /* end if */ } /* end if */ @@ -229,7 +229,7 @@ done: if (H5AC_proxy_entry_remove_child(internal->top_proxy, internal) < 0) HDONE_ERROR( H5E_BTREE, H5E_CANTUNDEPEND, NULL, - "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy") + "unable to destroy flush dependency between internal node and v2 B-tree 'top' proxy"); internal->top_proxy = NULL; } /* end if */ @@ -237,7 +237,7 @@ done: if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree internal node, address = %llu", - (unsigned long long)node_ptr->addr) + (unsigned long long)node_ptr->addr); } /* end if */ } /* end if */ @@ -325,7 +325,7 @@ done: /* Release the B-tree internal node */ if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__neighbor_internal() */ @@ -483,11 +483,11 @@ done: /* Shadow the node if doing SWMR writes */ if (hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node"); /* Unprotect node */ if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -686,7 +686,7 @@ done: if (hdr->swmr_write && (internal_flags & H5AC__DIRTIED_FLAG)) { /* Attempt to shadow the node if doing SWMR writes */ if (H5B2__shadow_internal(internal, curr_node_ptr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow internal B-tree node"); /* Change the state to "shadowed" if only modified currently */ /* (Triggers parent to be marked dirty) */ @@ -696,7 +696,7 @@ done: /* Unprotect node */ if (H5AC_unprotect(hdr->f, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1002,7 +1002,7 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, done: /* Release the B-tree internal node */ if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_internal() */ @@ -1294,7 +1294,7 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *sw done: /* Release the B-tree internal node */ if (internal && H5AC_unprotect(hdr->f, H5AC_BT2_INT, internal_addr, internal, internal_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_internal_by_idx() */ diff --git a/src/H5B2leaf.c b/src/H5B2leaf.c index 4f1e566..062528b 100644 --- a/src/H5B2leaf.c +++ b/src/H5B2leaf.c @@ -134,17 +134,17 @@ done: if (inserted) if (H5AC_remove_entry(leaf) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTREMOVE, FAIL, - "unable to remove v2 B-tree leaf node from cache") + "unable to remove v2 B-tree leaf node from cache"); /* Release leaf node's disk space */ if (H5_addr_defined(node_ptr->addr) && H5MF_xfree(hdr->f, H5FD_MEM_BTREE, node_ptr->addr, (hsize_t)hdr->node_size) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, - "unable to release file space for v2 B-tree leaf node") + "unable to release file space for v2 B-tree leaf node"); /* Destroy leaf node */ if (H5B2__leaf_free(leaf) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree leaf node") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to release v2 B-tree leaf node"); } /* end if */ } /* end if */ @@ -213,7 +213,7 @@ done: if (H5AC_proxy_entry_remove_child(leaf->top_proxy, leaf) < 0) HDONE_ERROR( H5E_BTREE, H5E_CANTUNDEPEND, NULL, - "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy") + "unable to destroy flush dependency between leaf node and v2 B-tree 'top' proxy"); leaf->top_proxy = NULL; } /* end if */ @@ -221,7 +221,7 @@ done: if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to unprotect v2 B-tree leaf node, address = %llu", - (unsigned long long)node_ptr->addr) + (unsigned long long)node_ptr->addr); } /* end if */ } /* end if */ @@ -304,7 +304,7 @@ H5B2__neighbor_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *neigh done: /* Release the B-tree leaf node */ if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree leaf node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__neighbor_leaf() */ @@ -360,8 +360,8 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_ /* Make room for new record */ if (idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), - hdr->cls->nrec_size * (leaf->nrec - idx)); + memmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), + hdr->cls->nrec_size * (leaf->nrec - idx)); } /* end else */ /* Make callback to store record in native form */ @@ -407,11 +407,11 @@ done: /* Shadow the node if doing SWMR writes */ if (hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node"); /* Unprotect leaf node */ if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -470,7 +470,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_update_s *status = H5B2_UPDATE_INSERT_CHILD_FULL; /* Let calling routine handle insertion */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Adjust index to leave room for record to insert */ @@ -479,8 +479,8 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_update_s /* Make room for new record */ if (idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), - hdr->cls->nrec_size * (leaf->nrec - idx)); + memmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), + hdr->cls->nrec_size * (leaf->nrec - idx)); } /* end if */ } /* end else */ @@ -555,7 +555,7 @@ done: if (hdr->swmr_write && (leaf_flags & H5AC__DIRTIED_FLAG)) { /* Attempt to shadow the node if doing SWMR writes */ if (H5B2__shadow_leaf(leaf, curr_node_ptr) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTCOPY, FAIL, "unable to shadow leaf B-tree node"); /* Change the state to "shadowed" if only modified currently */ /* (Triggers parent to be marked dirty) */ @@ -565,7 +565,7 @@ done: /* Unprotect leaf node */ if (H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -654,7 +654,7 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsi done: /* Unlock child node */ if (child && H5AC_unprotect(hdr->f, child_class, child_addr, child, H5AC__DIRTIED_FLAG) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree child node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__swap_leaf() */ @@ -801,8 +801,8 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_ /* Pack record out of leaf */ if (idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), - hdr->cls->nrec_size * (leaf->nrec - idx)); + memmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), + hdr->cls->nrec_size * (leaf->nrec - idx)); /* Mark leaf node as dirty also */ leaf_flags |= H5AC__DIRTIED_FLAG; @@ -823,7 +823,7 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_ done: /* Release the B-tree leaf node */ if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_leaf() */ @@ -899,8 +899,8 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_n /* Pack record out of leaf */ if (idx < leaf->nrec) - HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), - hdr->cls->nrec_size * (leaf->nrec - idx)); + memmove(H5B2_LEAF_NREC(leaf, hdr, idx), H5B2_LEAF_NREC(leaf, hdr, (idx + 1)), + hdr->cls->nrec_size * (leaf->nrec - idx)); /* Mark leaf node as dirty also */ leaf_flags |= H5AC__DIRTIED_FLAG; @@ -921,7 +921,7 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, H5B2_n done: /* Release the B-tree leaf node */ if (leaf && H5AC_unprotect(hdr->f, H5AC_BT2_LEAF, leaf_addr, leaf, leaf_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2__remove_leaf_by_idx() */ diff --git a/src/H5B2test.c b/src/H5B2test.c index e1558cc..face2e0 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -25,9 +25,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5B2pkg.h" /* v2 B-trees */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5B2pkg.h" /* B-Trees (Version 2) */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ /****************/ /* Local Macros */ @@ -234,7 +237,7 @@ H5B2__test_encode(uint8_t *raw, const void *nrecord, void *_ctx) /* Sanity check */ assert(ctx); - H5F_ENCODE_LENGTH_LEN(raw, *(const hsize_t *)nrecord, ctx->sizeof_size); + H5_ENCODE_LENGTH_LEN(raw, *(const hsize_t *)nrecord, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_encode() */ @@ -259,7 +262,7 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) /* Sanity check */ assert(ctx); - H5F_DECODE_LENGTH_LEN(raw, *(hsize_t *)nrecord, ctx->sizeof_size); + H5_DECODE_LENGTH_LEN(raw, *(hsize_t *)nrecord, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test_decode() */ @@ -347,8 +350,8 @@ H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) /* Sanity check */ assert(ctx); - H5F_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); - H5F_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); + H5_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); + H5_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_encode() */ @@ -373,8 +376,8 @@ H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) /* Sanity check */ assert(ctx); - H5F_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); - H5F_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); + H5_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); + H5_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B2__test2_decode() */ @@ -523,7 +526,7 @@ H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) ninfo->nrec = curr_node_ptr.node_nrec; /* Indicate success */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end else */ /* Decrement depth we're at in B-tree */ @@ -565,7 +568,7 @@ done: if (parent) { assert(ret_value < 0); if (parent != hdr && H5AC_unpin_entry(parent) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPIN, FAIL, "unable to unpin parent entry"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 939d8aa..8f0e1c8 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -181,11 +181,11 @@ H5B__cache_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ /* Sibling pointers */ if (H5_IS_BUFFER_OVERFLOW(image, H5F_sizeof_addr(udata->f), p_end)) HGOTO_ERROR(H5E_BTREE, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(udata->f, (const uint8_t **)&image, &(bt->left)); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &(bt->left)); if (H5_IS_BUFFER_OVERFLOW(image, H5F_sizeof_addr(udata->f), p_end)) HGOTO_ERROR(H5E_BTREE, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(udata->f, (const uint8_t **)&image, &(bt->right)); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &(bt->right)); /* Child/key pairs */ native = bt->native; @@ -201,7 +201,7 @@ H5B__cache_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ /* Decode address value */ if (H5_IS_BUFFER_OVERFLOW(image, H5F_sizeof_addr(udata->f), p_end)) HGOTO_ERROR(H5E_BTREE, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(udata->f, (const uint8_t **)&image, bt->child + u); + H5F_addr_decode(udata->f, (const uint8_t **)&image, bt->child + u); } /* Final key */ @@ -217,7 +217,7 @@ H5B__cache_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ done: if (!ret_value && bt) if (H5B__node_dest(bt) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B__cache_deserialize() */ @@ -299,8 +299,8 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, vo UINT16ENCODE(image, bt->nchildren); /* sibling pointers */ - H5_addr_encode(f, &image, bt->left); - H5_addr_encode(f, &image, bt->right); + H5F_addr_encode(f, &image, bt->left); + H5F_addr_encode(f, &image, bt->right); /* child keys and pointers */ native = bt->native; @@ -312,7 +312,7 @@ H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, vo native += shared->type->sizeof_nkey; /* encode the child address */ - H5_addr_encode(f, &image, bt->child[u]); + H5F_addr_encode(f, &image, bt->child[u]); } /* end for */ if (bt->nchildren > 0) { /* Encode the final key */ diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index d54e041..93d44d0 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -124,7 +124,7 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5 done: if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_debug() */ diff --git a/src/H5C.c b/src/H5C.c index 00c4563..8cff6fe 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -59,74 +59,26 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ #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 */ /****************/ /* Local Macros */ /****************/ -#if H5C_DO_MEMORY_SANITY_CHECKS -#define H5C_IMAGE_EXTRA_SPACE 8 -#define H5C_IMAGE_SANITY_VALUE "DeadBeef" -#else /* H5C_DO_MEMORY_SANITY_CHECKS */ -#define H5C_IMAGE_EXTRA_SPACE 0 -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /******************/ /* Local Typedefs */ /******************/ -/* Alias for pointer to cache entry, for use when allocating sequences of them */ -typedef H5C_cache_entry_t *H5C_cache_entry_ptr_t; - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5C__pin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); -static herr_t H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); -static herr_t H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); -static herr_t H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *status_ptr, - size_t *new_max_cache_size_ptr, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted); -static herr_t H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr); -static herr_t H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr); -static herr_t H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t new_entry_size); -static herr_t H5C__flush_invalidate_cache(H5F_t *f, unsigned flags); -static herr_t H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags); -static herr_t H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags); -static void *H5C__load_entry(H5F_t *f, -#ifdef H5_HAVE_PARALLEL - hbool_t coll_access, -#endif /* H5_HAVE_PARALLEL */ - const H5C_class_t *type, haddr_t addr, void *udata); - -static herr_t H5C__mark_flush_dep_dirty(H5C_cache_entry_t *entry); -static herr_t H5C__mark_flush_dep_clean(H5C_cache_entry_t *entry); -static herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry); -static herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry); - -static herr_t H5C__serialize_ring(H5F_t *f, H5C_ring_t ring); -static herr_t H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); -static herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); -static herr_t H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, size_t *len, - hbool_t actual); - -#ifndef NDEBUG -static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, - const H5C_cache_entry_t *base_entry); -#endif /* NDEBUG */ - /*********************/ /* Package Variables */ /*********************/ @@ -145,9 +97,6 @@ H5FL_DEFINE(H5C_tag_info_t); /* Declare a free list to manage the H5C_t struct */ H5FL_DEFINE_STATIC(H5C_t); -/* Declare a free list to manage arrays of cache entries */ -H5FL_SEQ_DEFINE_STATIC(H5C_cache_entry_ptr_t); - /*------------------------------------------------------------------------- * Function: H5C_create * @@ -204,8 +153,6 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, * the fields. */ - cache_ptr->magic = H5C__H5C_T_MAGIC; - cache_ptr->flush_in_progress = FALSE; if (NULL == (cache_ptr->log_info = (H5C_log_info_t *)H5MM_calloc(sizeof(H5C_log_info_t)))) @@ -359,9 +306,8 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, /* Set non-zero/FALSE/NULL fields for epoch markers */ for (i = 0; i < H5C__MAX_EPOCH_MARKERS; i++) { - ((cache_ptr->epoch_markers)[i]).magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - ((cache_ptr->epoch_markers)[i]).addr = (haddr_t)i; - ((cache_ptr->epoch_markers)[i]).type = H5AC_EPOCH_MARKER; + ((cache_ptr->epoch_markers)[i]).addr = (haddr_t)i; + ((cache_ptr->epoch_markers)[i]).type = H5AC_EPOCH_MARKER; } /* Initialize cache image generation on file close related fields. @@ -405,7 +351,7 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, #ifndef NDEBUG cache_ptr->get_entry_ptr_from_addr_counter = 0; -#endif /* NDEBUG */ +#endif /* Set return value */ ret_value = cache_ptr; @@ -422,8 +368,7 @@ done: if (cache_ptr->log_info != NULL) H5MM_xfree(cache_ptr->log_info); - cache_ptr->magic = 0; - cache_ptr = H5FL_FREE(H5C_t, cache_ptr); + cache_ptr = H5FL_FREE(H5C_t, cache_ptr); } } @@ -431,137 +376,6 @@ done: } /* H5C_create() */ /*------------------------------------------------------------------------- - * Function: H5C_def_auto_resize_rpt_fcn - * - * Purpose: Print results of a automatic cache resize. - * - * This function should only be used where printf() behaves - * well -- i.e. not on Windows. - * - * Return: void - * - * Programmer: John Mainzer - * 10/27/04 - * - *------------------------------------------------------------------------- - */ -void -H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, -#ifndef NDEBUG - int32_t version, -#else /* NDEBUG */ - int32_t H5_ATTR_UNUSED version, -#endif /* NDEBUG */ - double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, - size_t new_max_cache_size, size_t old_min_clean_size, size_t new_min_clean_size) -{ - assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(version == H5C__CURR_AUTO_RESIZE_RPT_FCN_VER); - - switch (status) { - case in_spec: - fprintf(stdout, "%sAuto cache resize -- no change. (hit rate = %lf)\n", cache_ptr->prefix, - hit_rate); - break; - - case increase: - assert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); - assert(old_max_cache_size < new_max_cache_size); - - fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); - fprintf(stdout, "%scache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, - old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); - break; - - case flash_increase: - assert(old_max_cache_size < new_max_cache_size); - - fprintf(stdout, "%sflash cache resize(%d) -- size threshold = %zu.\n", cache_ptr->prefix, - (int)(cache_ptr->resize_ctl.flash_incr_mode), cache_ptr->flash_size_increase_threshold); - fprintf(stdout, "%s cache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, - old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); - break; - - case decrease: - assert(old_max_cache_size > new_max_cache_size); - - switch (cache_ptr->resize_ctl.decr_mode) { - case H5C_decr__off: - fprintf(stdout, "%sAuto cache resize -- decrease off. HR = %lf\n", cache_ptr->prefix, - hit_rate); - break; - - case H5C_decr__threshold: - assert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); - - fprintf(stdout, "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", - cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); - fprintf(stdout, "%sout of bounds high (%6.5lf).\n", cache_ptr->prefix, - cache_ptr->resize_ctl.upper_hr_threshold); - break; - - case H5C_decr__age_out: - fprintf(stdout, "%sAuto cache resize -- decrease by ageout. HR = %lf\n", - cache_ptr->prefix, hit_rate); - break; - - case H5C_decr__age_out_with_threshold: - assert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); - - fprintf(stdout, - "%sAuto cache resize -- decrease by ageout with threshold. HR = %lf > %6.5lf\n", - cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); - break; - - default: - fprintf(stdout, "%sAuto cache resize -- decrease by unknown mode. HR = %lf\n", - cache_ptr->prefix, hit_rate); - } - - fprintf(stdout, "%s cache size decreased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, - old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); - break; - - case at_max_size: - fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); - fprintf(stdout, "%s cache already at maximum size so no change.\n", cache_ptr->prefix); - break; - - case at_min_size: - fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) -- can't decrease.\n", cache_ptr->prefix, - hit_rate); - fprintf(stdout, "%s cache already at minimum size.\n", cache_ptr->prefix); - break; - - case increase_disabled: - fprintf(stdout, "%sAuto cache resize -- increase disabled -- HR = %lf.", cache_ptr->prefix, - hit_rate); - break; - - case decrease_disabled: - fprintf(stdout, "%sAuto cache resize -- decrease disabled -- HR = %lf.\n", cache_ptr->prefix, - hit_rate); - break; - - case not_full: - assert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); - - fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", - cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); - fprintf(stdout, "%s cache not full so no increase in size.\n", cache_ptr->prefix); - break; - - default: - fprintf(stdout, "%sAuto cache resize -- unknown status code.\n", cache_ptr->prefix); - break; - } -} /* H5C_def_auto_resize_rpt_fcn() */ - -/*------------------------------------------------------------------------- - * * Function: H5C_prep_for_file_close * * Purpose: This function should be called just prior to the cache @@ -587,11 +401,10 @@ H5C_prep_for_file_close(H5F_t *f) assert(f->shared->cache); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* It is possible to receive the close warning more than once */ if (cache_ptr->close_warning_received) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); cache_ptr->close_warning_received = TRUE; /* Make certain there aren't any protected entries */ @@ -672,11 +485,10 @@ H5C_dest(H5F_t *f) /* Sanity check */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); #if H5AC_DUMP_IMAGE_STATS_ON_CLOSE - if (H5C_image_stats(cache_ptr, TRUE) < 0) + if (H5C__image_stats(cache_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't display cache image stats") #endif /* H5AC_DUMP_IMAGE_STATS_ON_CLOSE */ @@ -713,16 +525,12 @@ H5C_dest(H5F_t *f) if (cache_ptr->log_info != NULL) H5MM_xfree(cache_ptr->log_info); -#ifndef NDEBUG #ifdef H5C_DO_SANITY_CHECKS if (cache_ptr->get_entry_ptr_from_addr_counter > 0) fprintf(stdout, "*** %" PRId64 " calls to H5C_get_entry_ptr_from_add(). ***\n", cache_ptr->get_entry_ptr_from_addr_counter); #endif /* H5C_DO_SANITY_CHECKS */ - cache_ptr->magic = 0; -#endif /* NDEBUG */ - cache_ptr = H5FL_FREE(H5C_t, cache_ptr); done: @@ -734,7 +542,7 @@ done: * and the cache still exist. JRM -- 5/15/20 */ if (H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist on flush dest failure failed") + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist on flush dest failure failed"); FUNC_LEAVE_NOAPI(ret_value) } /* H5C_dest() */ @@ -775,81 +583,6 @@ done: } /* H5C_evict() */ /*------------------------------------------------------------------------- - * Function: H5C_expunge_entry - * - * Purpose: Expunge an entry from the cache without writing it to disk - * even if it is dirty. The entry may not be either pinned or - * protected. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 6/29/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flags) -{ - H5C_t *cache_ptr; - H5C_cache_entry_t *entry_ptr = NULL; - unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - assert(f); - assert(f->shared); - cache_ptr = f->shared->cache; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(type); - assert(H5_addr_defined(addr)); - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - /* Look for entry in cache */ - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - if ((entry_ptr == NULL) || (entry_ptr->type != type)) - /* the target doesn't exist in the cache, so we are done. */ - HGOTO_DONE(SUCCEED) - - assert(entry_ptr->addr == addr); - assert(entry_ptr->type == type); - - /* Check for entry being pinned or protected */ - if (entry_ptr->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is protected") - if (entry_ptr->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is pinned") - - /* If we get this far, call H5C__flush_single_entry() with the - * H5C__FLUSH_INVALIDATE_FLAG and the H5C__FLUSH_CLEAR_ONLY_FLAG. - * This will clear the entry, and then delete it from the cache. - */ - - /* Pass along 'free file space' flag */ - flush_flags |= (flags & H5C__FREE_FILE_SPACE_FLAG); - - /* Delete the entry from the skip list on destroy */ - flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - - if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't flush entry") - -done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_expunge_entry() */ - -/*------------------------------------------------------------------------- * Function: H5C_flush_cache * * Purpose: Flush (and possibly destroy) the entries contained in the @@ -888,7 +621,6 @@ H5C_flush_cache(H5F_t *f, unsigned flags) assert(f->shared); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->slist_ptr); #ifdef H5C_DO_SANITY_CHECKS @@ -1015,11 +747,8 @@ H5C_flush_to_min_clean(H5F_t *f) assert(f); assert(f->shared); - cache_ptr = f->shared->cache; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); if (cache_ptr->check_write_permitted != NULL) { if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) @@ -1039,7216 +768,672 @@ done: } /* H5C_flush_to_min_clean() */ /*------------------------------------------------------------------------- - * Function: H5C_insert_entry - * - * Purpose: Adds the specified thing to the cache. The thing need not - * exist on disk yet, but it must have an address and disk - * space reserved. + * Function: H5C_reset_cache_hit_rate_stats() * - * Return: Non-negative on success/Negative on failure + * Purpose: Reset the cache hit rate computation fields. * - * Programmer: John Mainzer - * 6/2/04 + * Return: SUCCEED on success, and FAIL on failure. * *------------------------------------------------------------------------- */ herr_t -H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags) +H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr) { - H5C_t *cache_ptr; - H5AC_ring_t ring = H5C_RING_UNDEFINED; - hbool_t insert_pinned; - hbool_t flush_last; -#ifdef H5_HAVE_PARALLEL - hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ -#endif /* H5_HAVE_PARALLEL */ - hbool_t set_flush_marker; - hbool_t write_permitted = TRUE; - size_t empty_space; - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *test_entry_ptr; - hbool_t entry_tagged = FALSE; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - assert(f); - assert(f->shared); - - cache_ptr = f->shared->cache; - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(type); - assert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); - assert(type->image_len); - assert(H5_addr_defined(addr)); - assert(thing); - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - /* no need to verify that entry is not already in the index as */ - /* we already make that check below. */ - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); - insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0); - flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); - - /* Get the ring type from the API context */ - ring = H5CX_get_ring(); - - entry_ptr = (H5C_cache_entry_t *)thing; - - /* verify that the new entry isn't already in the hash table -- scream - * and die if it is. - */ - - H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - - if (test_entry_ptr != NULL) { - if (test_entry_ptr == entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "entry already in cache") - else - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "duplicate entry in cache") - } /* end if */ - - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - entry_ptr->cache_ptr = cache_ptr; - entry_ptr->addr = addr; - entry_ptr->type = type; - - entry_ptr->image_ptr = NULL; - entry_ptr->image_up_to_date = FALSE; - - entry_ptr->is_protected = FALSE; - entry_ptr->is_read_only = FALSE; - entry_ptr->ro_ref_count = 0; - - entry_ptr->is_pinned = insert_pinned; - entry_ptr->pinned_from_client = insert_pinned; - entry_ptr->pinned_from_cache = FALSE; - entry_ptr->flush_me_last = flush_last; - - /* newly inserted entries are assumed to be dirty */ - entry_ptr->is_dirty = TRUE; - - /* not protected, so can't be dirtied */ - entry_ptr->dirtied = FALSE; - - /* Retrieve the size of the thing */ - if ((type->image_len)(thing, &(entry_ptr->size)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGETSIZE, FAIL, "can't get size of thing") - assert(entry_ptr->size > 0 && entry_ptr->size < H5C_MAX_ENTRY_SIZE); - - entry_ptr->in_slist = FALSE; - -#ifdef H5_HAVE_PARALLEL - entry_ptr->clear_on_unprotect = FALSE; - entry_ptr->flush_immediately = FALSE; -#endif /* H5_HAVE_PARALLEL */ - - entry_ptr->flush_in_progress = FALSE; - entry_ptr->destroy_in_progress = FALSE; - - entry_ptr->ring = ring; - - /* Initialize flush dependency fields */ - entry_ptr->flush_dep_parent = NULL; - entry_ptr->flush_dep_nparents = 0; - entry_ptr->flush_dep_parent_nalloc = 0; - entry_ptr->flush_dep_nchildren = 0; - entry_ptr->flush_dep_ndirty_children = 0; - entry_ptr->flush_dep_nunser_children = 0; - - entry_ptr->ht_next = NULL; - entry_ptr->ht_prev = NULL; - entry_ptr->il_next = NULL; - entry_ptr->il_prev = NULL; - - entry_ptr->next = NULL; - entry_ptr->prev = NULL; - -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - entry_ptr->aux_next = NULL; - entry_ptr->aux_prev = NULL; -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#ifdef H5_HAVE_PARALLEL - entry_ptr->coll_next = NULL; - entry_ptr->coll_prev = NULL; -#endif /* H5_HAVE_PARALLEL */ - - /* initialize cache image related fields */ - entry_ptr->include_in_image = FALSE; - entry_ptr->lru_rank = 0; - entry_ptr->image_dirty = FALSE; - entry_ptr->fd_parent_count = 0; - entry_ptr->fd_parent_addrs = NULL; - entry_ptr->fd_child_count = 0; - entry_ptr->fd_dirty_child_count = 0; - entry_ptr->image_fd_height = 0; - entry_ptr->prefetched = FALSE; - entry_ptr->prefetch_type_id = 0; - entry_ptr->age = 0; - entry_ptr->prefetched_dirty = FALSE; -#ifndef NDEBUG /* debugging field */ - entry_ptr->serialization_count = 0; -#endif /* NDEBUG */ - - /* initialize tag list fields */ - entry_ptr->tl_next = NULL; - entry_ptr->tl_prev = NULL; - entry_ptr->tag_info = NULL; - - /* Apply tag to newly inserted entry */ - if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") - entry_tagged = TRUE; - - H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) - - if (cache_ptr->flash_size_increase_possible && - (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) - if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__flash_increase_cache_size failed") - - if (cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; - else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - - if (cache_ptr->evictions_enabled && - (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || - (((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)))) { - size_t space_needed; - - if (empty_space <= entry_ptr->size) - cache_ptr->cache_full = TRUE; - - if (cache_ptr->check_write_permitted != NULL) { - if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "Can't get write_permitted") - } /* end if */ - else - write_permitted = cache_ptr->write_permitted; - - assert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); - space_needed = entry_ptr->size; - if (space_needed > cache_ptr->max_cache_size) - space_needed = cache_ptr->max_cache_size; - - /* Note that space_needed is just the amount of space that - * needed to insert the new entry without exceeding the cache - * size limit. The subsequent call to H5C__make_space_in_cache() - * may evict the entries required to free more or less space - * depending on conditions. It MAY be less if the cache is - * currently undersized, or more if the cache is oversized. - * - * The cache can exceed its maximum size limit via the following - * mechanisms: - * - * First, it is possible for the cache to grow without - * bound as long as entries are protected and not unprotected. - * - * Second, when writes are not permitted it is also possible - * for the cache to grow without bound. - * - * Finally, we usually don't check to see if the cache is - * oversized at the end of an unprotect. As a result, it is - * possible to have a vastly oversized cache with no protected - * entries as long as all the protects precede the unprotects. - */ - - if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__make_space_in_cache failed") - } /* end if */ - - H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL) - - /* New entries are presumed to be dirty */ - assert(entry_ptr->is_dirty); - entry_ptr->flush_marker = set_flush_marker; - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, FAIL) - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed just before done") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - /* If the entry's type has a 'notify' callback send a 'after insertion' - * notice now that the entry is fully integrated into the cache. - */ - if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry inserted into cache") - - H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) + if (cache_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") -#ifdef H5_HAVE_PARALLEL - if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - coll_access = H5F_get_coll_metadata_reads(f); - - entry_ptr->coll_access = coll_access; - if (coll_access) { - H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, FAIL) - - /* Make sure the size of the collective entries in the cache remain in check */ - if (H5P_USER_TRUE == H5F_COLL_MD_READ(f)) { - if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) { - if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") - } /* end if */ - } /* end if */ - else { - if (cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) { - if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") - } /* end if */ - } /* end else */ - } /* end if */ -#endif + cache_ptr->cache_hits = 0; + cache_ptr->cache_accesses = 0; done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - if (ret_value < 0 && entry_tagged) - if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_insert_entry() */ +} /* H5C_reset_cache_hit_rate_stats() */ /*------------------------------------------------------------------------- - * Function: H5C_mark_entry_dirty - * - * Purpose: Mark a pinned or protected entry as dirty. The target entry - * MUST be either pinned or protected, and MAY be both. - * - * In the protected case, this call is the functional - * equivalent of setting the H5C__DIRTIED_FLAG on an unprotect - * call. + * Function: H5C_set_cache_auto_resize_config * - * In the pinned but not protected case, if the entry is not - * already dirty, the function places function marks the entry - * dirty and places it on the skip list. + * Purpose: Set the cache automatic resize configuration to the + * provided values if they are in range, and fail if they + * are not. * - * Return: Non-negative on success/Negative on failure + * If the new configuration enables automatic cache resizing, + * coerce the cache max size and min clean size into agreement + * with the new policy and re-set the full cache hit rate + * stats. * - * Programmer: John Mainzer - * 5/15/06 + * Return: SUCCEED on success, and FAIL on failure. * *------------------------------------------------------------------------- */ herr_t -H5C_mark_entry_dirty(void *thing) +H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr) { - H5C_t *cache_ptr; - H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ + size_t new_max_cache_size; + size_t new_min_clean_size; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Sanity checks */ - assert(entry_ptr); - assert(H5_addr_defined(entry_ptr->addr)); - cache_ptr = entry_ptr->cache_ptr; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - if (entry_ptr->is_protected) { - assert(!((entry_ptr)->is_read_only)); + if (cache_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") + if (config_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") + if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown config version") - /* set the dirtied flag */ - entry_ptr->dirtied = TRUE; + /* check general configuration section of the config: */ + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_GENERAL) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in general configuration fields of new config") - /* reset image_up_to_date */ - if (entry_ptr->image_up_to_date) { - entry_ptr->image_up_to_date = FALSE; + /* check size increase control fields of the config: */ + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INCREMENT) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size increase control fields of new config") - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "Can't propagate serialization status to fd parents") - } /* end if */ - } /* end if */ - else if (entry_ptr->is_pinned) { - hbool_t was_clean; /* Whether the entry was previously clean */ - hbool_t image_was_up_to_date; + /* check size decrease control fields of the config: */ + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_DECREMENT) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size decrease control fields of new config") - /* Remember previous dirty status */ - was_clean = !entry_ptr->is_dirty; + /* check for conflicts between size increase and size decrease controls: */ + if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "conflicting threshold fields in new config") - /* Check if image is up to date */ - image_was_up_to_date = entry_ptr->image_up_to_date; + /* will set the increase possible fields to FALSE later if needed */ + cache_ptr->size_increase_possible = TRUE; + cache_ptr->flash_size_increase_possible = TRUE; + cache_ptr->size_decrease_possible = TRUE; - /* Mark the entry as dirty if it isn't already */ - entry_ptr->is_dirty = TRUE; - entry_ptr->image_up_to_date = FALSE; + switch (config_ptr->incr_mode) { + case H5C_incr__off: + cache_ptr->size_increase_possible = FALSE; + break; - /* Modify cache data structures */ - if (was_clean) - H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr, FAIL) - if (!entry_ptr->in_slist) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) + case H5C_incr__threshold: + if ((config_ptr->lower_hr_threshold <= 0.0) || (config_ptr->increment <= 1.0) || + ((config_ptr->apply_max_increment) && (config_ptr->max_increment <= 0))) + cache_ptr->size_increase_possible = FALSE; + break; - /* Update stats for entry being marked dirty */ - H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown incr_mode?!?!?") + } /* end switch */ - /* Check for entry changing status and do notifications, etc. */ - if (was_clean) { - /* If the entry's type has a 'notify' callback send a 'entry dirtied' - * notice now that the entry is fully integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") - - /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") - } /* end if */ - if (image_was_up_to_date) - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "Can't propagate serialization status to fd parents") - } /* end if */ - else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Entry is neither pinned nor protected??") + /* logically, this is where configuration for flash cache size increases + * should go. However, this configuration depends on max_cache_size, so + * we wait until the end of the function, when this field is set. + */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_mark_entry_dirty() */ + switch (config_ptr->decr_mode) { + case H5C_decr__off: + cache_ptr->size_decrease_possible = FALSE; + break; -/*------------------------------------------------------------------------- - * Function: H5C_mark_entry_clean - * - * Purpose: Mark a pinned entry as clean. The target entry MUST be pinned. - * - * If the entry is not - * already clean, the function places function marks the entry - * clean and removes it from the skip list. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 7/23/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_mark_entry_clean(void *_thing) -{ - H5C_t *cache_ptr; - H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(entry_ptr); - assert(H5_addr_defined(entry_ptr->addr)); - cache_ptr = entry_ptr->cache_ptr; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* Operate on pinned entry */ - if (entry_ptr->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "entry is protected") - else if (entry_ptr->is_pinned) { - hbool_t was_dirty; /* Whether the entry was previously dirty */ - - /* Remember previous dirty status */ - was_dirty = entry_ptr->is_dirty; - - /* Mark the entry as clean if it isn't already */ - entry_ptr->is_dirty = FALSE; - - /* Also reset the 'flush_marker' flag, since the entry shouldn't be flushed now */ - entry_ptr->flush_marker = FALSE; - - /* Modify cache data structures */ - if (was_dirty) - H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr, FAIL) - if (entry_ptr->in_slist) - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE) - - /* Update stats for entry being marked clean */ - H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) - - /* Check for entry changing status and do notifications, etc. */ - if (was_dirty) { - /* If the entry's type has a 'notify' callback send a 'entry cleaned' - * notice now that the entry is fully integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify client about entry dirty flag cleared") - - /* Propagate the clean up the flush dependency chain, if appropriate */ - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_clean(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean") - } /* end if */ - } /* end if */ - else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Entry is not pinned??") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_mark_entry_clean() */ - -/*------------------------------------------------------------------------- - * Function: H5C_mark_entry_unserialized - * - * Purpose: Mark a pinned or protected entry as unserialized. The target - * entry MUST be either pinned or protected, and MAY be both. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 12/23/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_mark_entry_unserialized(void *thing) -{ - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(entry); - assert(H5_addr_defined(entry->addr)); - - if (entry->is_protected || entry->is_pinned) { - assert(!entry->is_read_only); - - /* Reset image_up_to_date */ - if (entry->image_up_to_date) { - entry->image_up_to_date = FALSE; - - if (entry->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_unserialized(entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, - "Can't propagate serialization status to fd parents") - } /* end if */ - } /* end if */ - else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, - "Entry to unserialize is neither pinned nor protected??") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_mark_entry_unserialized() */ - -/*------------------------------------------------------------------------- - * Function: H5C_mark_entry_serialized - * - * Purpose: Mark a pinned entry as serialized. The target entry MUST be - * pinned. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 12/23/16 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_mark_entry_serialized(void *_thing) -{ - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_thing; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(entry); - assert(H5_addr_defined(entry->addr)); - - /* Operate on pinned entry */ - if (entry->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "entry is protected") - else if (entry->is_pinned) { - /* Check for entry changing status and do notifications, etc. */ - if (!entry->image_up_to_date) { - /* Set the image_up_to_date flag */ - entry->image_up_to_date = TRUE; - - /* Propagate the serialize up the flush dependency chain, if appropriate */ - if (entry->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_serialized(entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, - "Can't propagate flush dep serialize") - } /* end if */ - } /* end if */ - else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "Entry is not pinned??") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_mark_entry_serialized() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_move_entry - * - * Purpose: Use this function to notify the cache that an entry's - * file address changed. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 6/2/04 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, haddr_t new_addr) -{ - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *test_entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(type); - assert(H5_addr_defined(old_addr)); - assert(H5_addr_defined(new_addr)); - assert(H5_addr_ne(old_addr, new_addr)); + case H5C_decr__threshold: + if (config_ptr->upper_hr_threshold >= 1.0 || config_ptr->decrement >= 1.0 || + (config_ptr->apply_max_decrement && config_ptr->max_decrement <= 0)) + cache_ptr->size_decrease_possible = FALSE; + break; -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + case H5C_decr__age_out: + if ((config_ptr->apply_empty_reserve && config_ptr->empty_reserve >= 1.0) || + (config_ptr->apply_max_decrement && config_ptr->max_decrement <= 0)) + cache_ptr->size_decrease_possible = FALSE; + break; - H5C__SEARCH_INDEX(cache_ptr, old_addr, entry_ptr, FAIL) + case H5C_decr__age_out_with_threshold: + if ((config_ptr->apply_empty_reserve && config_ptr->empty_reserve >= 1.0) || + (config_ptr->apply_max_decrement && config_ptr->max_decrement <= 0) || + config_ptr->upper_hr_threshold >= 1.0) + cache_ptr->size_decrease_possible = FALSE; + break; - if (entry_ptr == NULL || entry_ptr->type != type) - /* the old item doesn't exist in the cache, so we are done. */ - HGOTO_DONE(SUCCEED) + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown decr_mode?!?!?") + } /* end switch */ - assert(entry_ptr->addr == old_addr); - assert(entry_ptr->type == type); + if (config_ptr->max_size == config_ptr->min_size) { + cache_ptr->size_increase_possible = FALSE; + cache_ptr->flash_size_increase_possible = FALSE; + cache_ptr->size_decrease_possible = FALSE; + } /* end if */ - /* Check for R/W status, otherwise error */ - /* (Moving a R/O entry would mark it dirty, which shouldn't - * happen. QAK - 2016/12/02) + /* flash_size_increase_possible is intentionally omitted from the + * following: */ - if (entry_ptr->is_read_only) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "can't move R/O entry") + cache_ptr->resize_enabled = cache_ptr->size_increase_possible || cache_ptr->size_decrease_possible; + cache_ptr->resize_ctl = *config_ptr; - H5C__SEARCH_INDEX(cache_ptr, new_addr, test_entry_ptr, FAIL) + /* Resize the cache to the supplied initial value if requested, or as + * necessary to force it within the bounds of the current automatic + * cache resizing configuration. + * + * Note that the min_clean_fraction may have changed, so we + * go through the exercise even if the current size is within + * range and an initial size has not been provided. + */ + if (cache_ptr->resize_ctl.set_initial_size) + new_max_cache_size = cache_ptr->resize_ctl.initial_size; + else if (cache_ptr->max_cache_size > cache_ptr->resize_ctl.max_size) + new_max_cache_size = cache_ptr->resize_ctl.max_size; + else if (cache_ptr->max_cache_size < cache_ptr->resize_ctl.min_size) + new_max_cache_size = cache_ptr->resize_ctl.min_size; + else + new_max_cache_size = cache_ptr->max_cache_size; - if (test_entry_ptr != NULL) { /* we are hosed */ - if (test_entry_ptr->type == type) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "target already moved & reinserted???") - else - HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "new address already in use?") - } /* end if */ + new_min_clean_size = (size_t)((double)new_max_cache_size * (cache_ptr->resize_ctl.min_clean_fraction)); - /* If we get this far we have work to do. Remove *entry_ptr from - * the hash table (and skip list if necessary), change its address to the - * new address, mark it as dirty (if it isn't already) and then re-insert. - * - * Update the replacement policy for a hit to avoid an eviction before - * the moved entry is touched. Update stats for a move. + /* since new_min_clean_size is of type size_t, we have * - * Note that we do not check the size of the cache, or evict anything. - * Since this is a simple re-name, cache size should be unaffected. + * ( 0 <= new_min_clean_size ) * - * Check to see if the target entry is in the process of being destroyed - * before we delete from the index, etc. If it is, all we do is - * change the addr. If the entry is only in the process of being flushed, - * don't mark it as dirty either, lest we confuse the flush call back. + * by definition. */ - if (!entry_ptr->destroy_in_progress) { - H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) - - if (entry_ptr->in_slist) { - assert(cache_ptr->slist_ptr); - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE) - } /* end if */ - } /* end if */ - - entry_ptr->addr = new_addr; - - if (!entry_ptr->destroy_in_progress) { - hbool_t was_dirty; /* Whether the entry was previously dirty */ - - /* Remember previous dirty status */ - was_dirty = entry_ptr->is_dirty; - - /* Mark the entry as dirty if it isn't already */ - entry_ptr->is_dirty = TRUE; - - /* This shouldn't be needed, but it keeps the test code happy */ - if (entry_ptr->image_up_to_date) { - entry_ptr->image_up_to_date = FALSE; - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "Can't propagate serialization status to fd parents") - } /* end if */ - - /* Modify cache data structures */ - H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - - /* Skip some actions if we're in the middle of flushing the entry */ - if (!entry_ptr->flush_in_progress) { - /* Update the replacement policy for the entry */ - H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, FAIL) - - /* Check for entry changing status and do notifications, etc. */ - if (!was_dirty) { - /* If the entry's type has a 'notify' callback send a 'entry dirtied' - * notice now that the entry is fully integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify client about entry dirty flag set") - - /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, - "Can't propagate flush dep dirty flag") - } /* end if */ - } /* end if */ - } /* end if */ - - H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) - -done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_move_entry() */ - -/*------------------------------------------------------------------------- - * Function: H5C_resize_entry - * - * Purpose: Resize a pinned or protected entry. - * - * Resizing an entry dirties it, so if the entry is not - * already dirty, the function places the entry on the - * skip list. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 7/5/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_resize_entry(void *thing, size_t new_size) -{ - H5C_t *cache_ptr; - H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(entry_ptr); - assert(H5_addr_defined(entry_ptr->addr)); - cache_ptr = entry_ptr->cache_ptr; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* Check for usage errors */ - if (new_size <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "New size is non-positive") - if (!(entry_ptr->is_pinned || entry_ptr->is_protected)) - HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, FAIL, "Entry isn't pinned or protected??") - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - /* update for change in entry size if necessary */ - if (entry_ptr->size != new_size) { - hbool_t was_clean; - - /* make note of whether the entry was clean to begin with */ - was_clean = !entry_ptr->is_dirty; - - /* mark the entry as dirty if it isn't already */ - entry_ptr->is_dirty = TRUE; - - /* Reset the image up-to-date status */ - if (entry_ptr->image_up_to_date) { - entry_ptr->image_up_to_date = FALSE; - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "Can't propagate serialization status to fd parents") - } /* end if */ - - /* Release the current image */ - if (entry_ptr->image_ptr) - entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); - - /* do a flash cache size increase if appropriate */ - if (cache_ptr->flash_size_increase_possible) { - if (new_size > entry_ptr->size) { - size_t size_increase; - - size_increase = new_size - entry_ptr->size; - if (size_increase >= cache_ptr->flash_size_increase_threshold) - if (H5C__flash_increase_cache_size(cache_ptr, entry_ptr->size, new_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "flash cache increase failed") - } - } - - /* update the pinned and/or protected entry list */ - if (entry_ptr->is_pinned) - H5C__DLL_UPDATE_FOR_SIZE_CHANGE(cache_ptr->pel_len, cache_ptr->pel_size, entry_ptr->size, - new_size, FAIL) - if (entry_ptr->is_protected) - H5C__DLL_UPDATE_FOR_SIZE_CHANGE(cache_ptr->pl_len, cache_ptr->pl_size, entry_ptr->size, new_size, - FAIL) - -#ifdef H5_HAVE_PARALLEL - 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, FAIL) -#endif /* H5_HAVE_PARALLEL */ - - /* update statistics just before changing the entry size */ - H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size); - - /* update the hash table */ - H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size, entry_ptr, was_clean, FAIL); - - /* if the entry is in the skip list, update that too */ - if (entry_ptr->in_slist) - H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size); - - /* finally, update the entry size proper */ - entry_ptr->size = new_size; - - if (!entry_ptr->in_slist) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - - if (entry_ptr->is_pinned) - H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) + assert(new_min_clean_size <= new_max_cache_size); + assert(cache_ptr->resize_ctl.min_size <= new_max_cache_size); + assert(new_max_cache_size <= cache_ptr->resize_ctl.max_size); - /* Check for entry changing status and do notifications, etc. */ - if (was_clean) { - /* If the entry's type has a 'notify' callback send a 'entry dirtied' - * notice now that the entry is fully integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") - - /* Propagate the dirty flag up the flush dependency chain if appropriate */ - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") - } /* end if */ - } /* end if */ + if (new_max_cache_size < cache_ptr->max_cache_size) + cache_ptr->size_decreased = TRUE; -done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + cache_ptr->max_cache_size = new_max_cache_size; + cache_ptr->min_clean_size = new_min_clean_size; - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_resize_entry() */ + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + /* this should be impossible... */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") -/*------------------------------------------------------------------------- - * Function: H5C_pin_protected_entry() - * - * Purpose: Pin a protected cache entry. The entry must be protected - * at the time of call, and must be unpinned. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 4/26/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_pin_protected_entry(void *thing) -{ - H5C_t *cache_ptr; - H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; /* Pointer to entry to pin */ - herr_t ret_value = SUCCEED; /* Return value */ + /* remove excess epoch markers if any */ + if ((config_ptr->decr_mode == H5C_decr__age_out_with_threshold) || + (config_ptr->decr_mode == H5C_decr__age_out)) { + if (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) + if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") + } /* end if */ + else if (cache_ptr->epoch_markers_active > 0) { + if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") + } - FUNC_ENTER_NOAPI(FAIL) + /* configure flash size increase facility. We wait until the + * end of the function, as we need the max_cache_size set before + * we start to keep things simple. + * + * If we haven't already ruled out flash cache size increases above, + * go ahead and configure it. + */ + if (cache_ptr->flash_size_increase_possible) { + switch (config_ptr->flash_incr_mode) { + case H5C_flash_incr__off: + cache_ptr->flash_size_increase_possible = FALSE; + break; - /* Sanity checks */ - assert(entry_ptr); - assert(H5_addr_defined(entry_ptr->addr)); - cache_ptr = entry_ptr->cache_ptr; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); + case H5C_flash_incr__add_space: + cache_ptr->flash_size_increase_possible = TRUE; + cache_ptr->flash_size_increase_threshold = + (size_t)(((double)(cache_ptr->max_cache_size)) * (cache_ptr->resize_ctl.flash_threshold)); + break; -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - /* Only protected entries can be pinned */ - if (!entry_ptr->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Entry isn't protected") - - /* Pin the entry from a client */ - if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") - -done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_pin_protected_entry() */ - -/*------------------------------------------------------------------------- - * Function: H5C_protect - * - * Purpose: If the target entry is not in the cache, load it. If - * necessary, attempt to evict one or more entries to keep - * the cache within its maximum size. - * - * Mark the target entry as protected, and return its address - * to the caller. The caller must call H5C_unprotect() when - * finished with the entry. - * - * While it is protected, the entry may not be either evicted - * or flushed -- nor may it be accessed by another call to - * H5C_protect. Any attempt to do so will result in a failure. - * - * Return: Success: Ptr to the desired entry - * Failure: NULL - * - * Programmer: John Mainzer - 6/2/04 - * - *------------------------------------------------------------------------- - */ -void * -H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags) -{ - H5C_t *cache_ptr; - H5AC_ring_t ring = H5C_RING_UNDEFINED; - hbool_t hit; - hbool_t have_write_permitted = FALSE; - hbool_t read_only = FALSE; - hbool_t flush_last; -#ifdef H5_HAVE_PARALLEL - hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ -#endif /* H5_HAVE_PARALLEL */ - hbool_t write_permitted = FALSE; - hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */ - size_t empty_space; - void *thing; - H5C_cache_entry_t *entry_ptr; - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check args */ - assert(f); - assert(f->shared); - - cache_ptr = f->shared->cache; - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(type); - assert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); - assert(H5_addr_defined(addr)); - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - /* 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, NULL, "Can't load cache image") - } /* end if */ - - read_only = ((flags & H5C__READ_ONLY_FLAG) != 0); - flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); - - /* Get the ring type from the API context */ - ring = H5CX_get_ring(); - -#ifdef H5_HAVE_PARALLEL - if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - coll_access = H5F_get_coll_metadata_reads(f); -#endif /* H5_HAVE_PARALLEL */ - - /* first check to see if the target is in cache */ - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, NULL) - - if (entry_ptr != NULL) { - if (entry_ptr->ring != ring) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "ring type mismatch occurred for cache entry") - - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - - if (entry_ptr->prefetched) { - /* This call removes the prefetched entry from the cache, - * and replaces it with an entry deserialized from the - * image of the prefetched entry. - */ - if (H5C__deserialize_prefetched_entry(f, cache_ptr, &entry_ptr, type, addr, udata) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't deserialize prefetched entry") - - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(!entry_ptr->prefetched); - assert(entry_ptr->addr == addr); - } /* end if */ - - /* Check for trying to load the wrong type of entry from an address */ - if (entry_ptr->type != type) - HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") - -#ifdef H5_HAVE_PARALLEL - /* If this is a collective metadata read, the entry is not marked as - * collective, and is clean, it is possible that other processes will - * not have it in its cache and will expect a bcast of the entry from - * process 0. So process 0 will bcast the entry to all other ranks. - * Ranks that _do_ have the entry in their cache still have to - * participate in the bcast. - */ - if (coll_access) { - if (!entry_ptr->is_dirty && !entry_ptr->coll_access) { - MPI_Comm comm; /* File MPI Communicator */ - int mpi_code; /* MPI error code */ - int buf_size; - - if (MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") - - if (entry_ptr->image_ptr == NULL) { - int mpi_rank; - - if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") - - if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, - "memory allocation failed for on disk image buffer") -#if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - if (0 == mpi_rank && H5C__generate_image(f, cache_ptr, entry_ptr) < 0) - /* If image generation fails, push an error but - * still participate in the following MPI_Bcast - */ - HDONE_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't generate entry's image") - } /* end if */ - assert(entry_ptr->image_ptr); - - H5_CHECKED_ASSIGN(buf_size, int, entry_ptr->size, size_t); - if (MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) - - /* Mark the entry as collective and insert into the collective list */ - entry_ptr->coll_access = TRUE; - H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) - } /* end if */ - else if (entry_ptr->coll_access) - H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - -#ifdef H5C_DO_TAGGING_SANITY_CHECKS - { - /* Verify tag value */ - if (cache_ptr->ignore_tags != TRUE) { - haddr_t tag; /* Tag value */ - - /* The entry is already in the cache, but make sure that the tag value - * is still legal. This will ensure that had the entry NOT been in the - * cache, tagging was still set up correctly and it would have received - * a legal tag value after getting loaded from disk. - */ - - /* Get the tag */ - tag = H5CX_get_tag(); - - if (H5C_verify_tag(entry_ptr->type->id, tag) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "tag verification failed") - } /* end if */ - } -#endif - - hit = TRUE; - thing = (void *)entry_ptr; - } - else { - /* must try to load the entry from disk. */ - hit = FALSE; - if (NULL == (thing = H5C__load_entry(f, -#ifdef H5_HAVE_PARALLEL - coll_access, -#endif /* H5_HAVE_PARALLEL */ - type, addr, udata))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't load entry") - - entry_ptr = (H5C_cache_entry_t *)thing; - cache_ptr->entries_loaded_counter++; - - entry_ptr->ring = ring; -#ifdef H5_HAVE_PARALLEL - if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && entry_ptr->coll_access) - H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) -#endif /* H5_HAVE_PARALLEL */ - - /* Apply tag to newly protected entry */ - if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Cannot tag metadata entry") - - /* If the entry is very large, and we are configured to allow it, - * we may wish to perform a flash cache size increase. - */ - if (cache_ptr->flash_size_increase_possible && - (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) - if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__flash_increase_cache_size failed") - - if (cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; - else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - - /* try to free up if necceary and if evictions are permitted. Note - * that if evictions are enabled, we will call H5C__make_space_in_cache() - * regardless if the min_free_space requirement is not met. - */ - if (cache_ptr->evictions_enabled && - (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || - ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size))) { - - size_t space_needed; - - if (empty_space <= entry_ptr->size) - cache_ptr->cache_full = TRUE; - - if (cache_ptr->check_write_permitted != NULL) { - if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted 1") - else - have_write_permitted = TRUE; - } /* end if */ - else { - write_permitted = cache_ptr->write_permitted; - have_write_permitted = TRUE; - } /* end else */ - - assert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); - space_needed = entry_ptr->size; - if (space_needed > cache_ptr->max_cache_size) - space_needed = cache_ptr->max_cache_size; - - /* Note that space_needed is just the amount of space that - * needed to insert the new entry without exceeding the cache - * size limit. The subsequent call to H5C__make_space_in_cache() - * may evict the entries required to free more or less space - * depending on conditions. It MAY be less if the cache is - * currently undersized, or more if the cache is oversized. - * - * The cache can exceed its maximum size limit via the following - * mechanisms: - * - * First, it is possible for the cache to grow without - * bound as long as entries are protected and not unprotected. - * - * Second, when writes are not permitted it is also possible - * for the cache to grow without bound. - * - * Third, the user may choose to disable evictions -- causing - * the cache to grow without bound until evictions are - * re-enabled. - * - * Finally, we usually don't check to see if the cache is - * oversized at the end of an unprotect. As a result, it is - * possible to have a vastly oversized cache with no protected - * entries as long as all the protects precede the unprotects. - */ - if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") - } /* end if */ - - /* Insert the entry in the hash table. - * - * ******************************************* - * - * Set the flush_me_last field - * of the newly loaded entry before inserting it into the - * index. Must do this, as the index tracked the number of - * entries with the flush_last field set, but assumes that - * the field will not change after insertion into the index. - * - * Note that this means that the H5C__FLUSH_LAST_FLAG flag - * is ignored if the entry is already in cache. - */ - entry_ptr->flush_me_last = flush_last; - - H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, NULL) - if (entry_ptr->is_dirty && !entry_ptr->in_slist) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, NULL) - - /* insert the entry in the data structures used by the replacement - * policy. We are just going to take it out again when we update - * the replacement policy for a protect, but this simplifies the - * code. If we do this often enough, we may want to optimize this. - */ - H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, NULL) - - /* Record that the entry was loaded, to trigger a notify callback later */ - /* (After the entry is fully added to the cache) */ - was_loaded = TRUE; - } /* end else */ - - assert(entry_ptr->addr == addr); - assert(entry_ptr->type == type); - - if (entry_ptr->is_protected) { - if (read_only && entry_ptr->is_read_only) { - assert(entry_ptr->ro_ref_count > 0); - (entry_ptr->ro_ref_count)++; - } /* end if */ - else - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Target already protected & not read only?!?") - } /* end if */ - else { - H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, NULL) - - entry_ptr->is_protected = TRUE; - if (read_only) { - entry_ptr->is_read_only = TRUE; - entry_ptr->ro_ref_count = 1; - } /* end if */ - entry_ptr->dirtied = FALSE; - } /* end else */ - - H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) - H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) - - ret_value = thing; - - if (cache_ptr->evictions_enabled && - (cache_ptr->size_decreased || - (cache_ptr->resize_enabled && (cache_ptr->cache_accesses >= cache_ptr->resize_ctl.epoch_length)))) { - - if (!have_write_permitted) { - if (cache_ptr->check_write_permitted != NULL) { - if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted") - else - have_write_permitted = TRUE; - } - else { - write_permitted = cache_ptr->write_permitted; - have_write_permitted = TRUE; - } - } - - if (cache_ptr->resize_enabled && (cache_ptr->cache_accesses >= cache_ptr->resize_ctl.epoch_length)) - if (H5C__auto_adjust_cache_size(f, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Cache auto-resize failed") - - if (cache_ptr->size_decreased) { - cache_ptr->size_decreased = FALSE; - - /* check to see if the cache is now oversized due to the cache - * size reduction. If it is, try to evict enough entries to - * bring the cache size down to the current maximum cache size. - * - * Also, if the min_clean_size requirement is not met, we - * should also call H5C__make_space_in_cache() to bring us - * into compliance. - */ - if (cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; - else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - - if ((cache_ptr->index_size > cache_ptr->max_cache_size) || - ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)) { - - if (cache_ptr->index_size > cache_ptr->max_cache_size) - cache_ptr->cache_full = TRUE; - - if (H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") - } - } /* end if */ - } - - /* If we loaded the entry and the entry's type has a 'notify' callback, send - * an 'after load' notice now that the entry is fully integrated into - * the cache and protected. We must wait until it is protected so it is not - * evicted during the notify callback. - */ - if (was_loaded) - /* If the entry's type has a 'notify' callback send a 'after load' - * notice now that the entry is fully integrated into the cache. - */ - if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, NULL, - "can't notify client about entry inserted into cache") - -#ifdef H5_HAVE_PARALLEL - /* Make sure the size of the collective entries in the cache remain in check */ - if (coll_access) { - if (H5P_USER_TRUE == H5F_COLL_MD_READ(f)) { - if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) - if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") - } /* end if */ - else { - if (cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) - if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") - } /* end else */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - -done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_protect() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_reset_cache_hit_rate_stats() - * - * Purpose: Reset the cache hit rate computation fields. - * - * Return: SUCCEED on success, and FAIL on failure. - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - - cache_ptr->cache_hits = 0; - cache_ptr->cache_accesses = 0; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_reset_cache_hit_rate_stats() */ - -/*------------------------------------------------------------------------- - * Function: H5C_set_cache_auto_resize_config - * - * Purpose: Set the cache automatic resize configuration to the - * provided values if they are in range, and fail if they - * are not. - * - * If the new configuration enables automatic cache resizing, - * coerce the cache max size and min clean size into agreement - * with the new policy and re-set the full cache hit rate - * stats. - * - * Return: SUCCEED on success, and FAIL on failure. - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr) -{ - size_t new_max_cache_size; - size_t new_min_clean_size; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - if (config_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") - if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "unknown config version") - - /* check general configuration section of the config: */ - if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_GENERAL) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in general configuration fields of new config") - - /* check size increase control fields of the config: */ - if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INCREMENT) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size increase control fields of new config") - - /* check size decrease control fields of the config: */ - if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_DECREMENT) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "error in the size decrease control fields of new config") - - /* check for conflicts between size increase and size decrease controls: */ - if (H5C_validate_resize_config(config_ptr, H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "conflicting threshold fields in new config") - - /* will set the increase possible fields to FALSE later if needed */ - cache_ptr->size_increase_possible = TRUE; - cache_ptr->flash_size_increase_possible = TRUE; - cache_ptr->size_decrease_possible = TRUE; - - switch (config_ptr->incr_mode) { - case H5C_incr__off: - cache_ptr->size_increase_possible = FALSE; - break; - - case H5C_incr__threshold: - if ((config_ptr->lower_hr_threshold <= 0.0) || (config_ptr->increment <= 1.0) || - ((config_ptr->apply_max_increment) && (config_ptr->max_increment <= 0))) - cache_ptr->size_increase_possible = FALSE; - break; - - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown incr_mode?!?!?") - } /* end switch */ - - /* logically, this is where configuration for flash cache size increases - * should go. However, this configuration depends on max_cache_size, so - * we wait until the end of the function, when this field is set. - */ - - switch (config_ptr->decr_mode) { - case H5C_decr__off: - cache_ptr->size_decrease_possible = FALSE; - break; - - case H5C_decr__threshold: - if (config_ptr->upper_hr_threshold >= 1.0 || config_ptr->decrement >= 1.0 || - (config_ptr->apply_max_decrement && config_ptr->max_decrement <= 0)) - cache_ptr->size_decrease_possible = FALSE; - break; - - case H5C_decr__age_out: - if ((config_ptr->apply_empty_reserve && config_ptr->empty_reserve >= 1.0) || - (config_ptr->apply_max_decrement && config_ptr->max_decrement <= 0)) - cache_ptr->size_decrease_possible = FALSE; - break; - - case H5C_decr__age_out_with_threshold: - if ((config_ptr->apply_empty_reserve && config_ptr->empty_reserve >= 1.0) || - (config_ptr->apply_max_decrement && config_ptr->max_decrement <= 0) || - config_ptr->upper_hr_threshold >= 1.0) - cache_ptr->size_decrease_possible = FALSE; - break; - - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown decr_mode?!?!?") - } /* end switch */ - - if (config_ptr->max_size == config_ptr->min_size) { - cache_ptr->size_increase_possible = FALSE; - cache_ptr->flash_size_increase_possible = FALSE; - cache_ptr->size_decrease_possible = FALSE; - } /* end if */ - - /* flash_size_increase_possible is intentionally omitted from the - * following: - */ - cache_ptr->resize_enabled = cache_ptr->size_increase_possible || cache_ptr->size_decrease_possible; - cache_ptr->resize_ctl = *config_ptr; - - /* Resize the cache to the supplied initial value if requested, or as - * necessary to force it within the bounds of the current automatic - * cache resizing configuration. - * - * Note that the min_clean_fraction may have changed, so we - * go through the exercise even if the current size is within - * range and an initial size has not been provided. - */ - if (cache_ptr->resize_ctl.set_initial_size) - new_max_cache_size = cache_ptr->resize_ctl.initial_size; - else if (cache_ptr->max_cache_size > cache_ptr->resize_ctl.max_size) - new_max_cache_size = cache_ptr->resize_ctl.max_size; - else if (cache_ptr->max_cache_size < cache_ptr->resize_ctl.min_size) - new_max_cache_size = cache_ptr->resize_ctl.min_size; - else - new_max_cache_size = cache_ptr->max_cache_size; - - new_min_clean_size = (size_t)((double)new_max_cache_size * (cache_ptr->resize_ctl.min_clean_fraction)); - - /* since new_min_clean_size is of type size_t, we have - * - * ( 0 <= new_min_clean_size ) - * - * by definition. - */ - assert(new_min_clean_size <= new_max_cache_size); - assert(cache_ptr->resize_ctl.min_size <= new_max_cache_size); - assert(new_max_cache_size <= cache_ptr->resize_ctl.max_size); - - if (new_max_cache_size < cache_ptr->max_cache_size) - cache_ptr->size_decreased = TRUE; - - cache_ptr->max_cache_size = new_max_cache_size; - cache_ptr->min_clean_size = new_min_clean_size; - - if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) - /* this should be impossible... */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") - - /* remove excess epoch markers if any */ - if ((config_ptr->decr_mode == H5C_decr__age_out_with_threshold) || - (config_ptr->decr_mode == H5C_decr__age_out)) { - if (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) - if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") - } /* end if */ - else if (cache_ptr->epoch_markers_active > 0) { - if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") - } - - /* configure flash size increase facility. We wait until the - * end of the function, as we need the max_cache_size set before - * we start to keep things simple. - * - * If we haven't already ruled out flash cache size increases above, - * go ahead and configure it. - */ - if (cache_ptr->flash_size_increase_possible) { - switch (config_ptr->flash_incr_mode) { - case H5C_flash_incr__off: - cache_ptr->flash_size_increase_possible = FALSE; - break; - - case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_possible = TRUE; - cache_ptr->flash_size_increase_threshold = - (size_t)(((double)(cache_ptr->max_cache_size)) * (cache_ptr->resize_ctl.flash_threshold)); - break; - - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; - } /* end switch */ - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_set_cache_auto_resize_config() */ - -/*------------------------------------------------------------------------- - * Function: H5C_set_evictions_enabled() - * - * Purpose: Set cache_ptr->evictions_enabled to the value of the - * evictions enabled parameter. - * - * Return: SUCCEED on success, and FAIL on failure. - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") - - /* There is no fundamental reason why we should not permit - * evictions to be disabled while automatic resize is enabled. - * However, allowing it would greatly complicate testing - * the feature. Hence the following: - */ - if ((evictions_enabled != TRUE) && ((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || - (cache_ptr->resize_ctl.decr_mode != H5C_decr__off))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't disable evictions when auto resize enabled") - - cache_ptr->evictions_enabled = evictions_enabled; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_set_evictions_enabled() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_set_slist_enabled() - * - * Purpose: Enable or disable the slist as directed. - * - * The slist (skip list) is an address ordered list of - * dirty entries in the metadata cache. However, this - * list is only needed during flush and close, where we - * use it to write entries in more or less increasing - * address order. - * - * This function sets up and enables further operations - * on the slist, or disable the slist. This in turn - * allows us to avoid the overhead of maintaining the - * slist when it is not needed. - * - * - * If the slist_enabled parameter is TRUE, the function - * - * 1) Verifies that the slist is empty. - * - * 2) Scans the index list, and inserts all dirty entries - * into the slist. - * - * 3) Sets cache_ptr->slist_enabled = TRUE. - * - * Note that the clear_slist parameter is ignored if - * the slist_enabed parameter is TRUE. - * - * - * If the slist_enabled_parameter is FALSE, the function - * shuts down the slist. - * - * Normally the slist will be empty at this point, however - * that need not be the case if H5C_flush_cache() has been - * called with the H5C__FLUSH_MARKED_ENTRIES_FLAG. - * - * Thus shutdown proceeds as follows: - * - * 1) Test to see if the slist is empty. If it is, proceed - * to step 3. - * - * 2) Test to see if the clear_slist parameter is TRUE. - * - * If it is, remove all entries from the slist. - * - * If it isn't, throw an error. - * - * 3) set cache_ptr->slist_enabled = FALSE. - * - * Return: SUCCEED on success, and FAIL on failure. - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_slist) -{ - H5C_cache_entry_t *entry_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") - - if (slist_enabled) { - if (cache_ptr->slist_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist already enabled?") - if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty?") - - /* set cache_ptr->slist_enabled to TRUE so that the slist - * maintenance macros will be enabled. - */ - cache_ptr->slist_enabled = TRUE; - - /* scan the index list and insert all dirty entries in the slist */ - entry_ptr = cache_ptr->il_head; - while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if (entry_ptr->is_dirty) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - entry_ptr = entry_ptr->il_next; - } - - /* we don't maintain a dirty index len, so we can't do a cross - * check against it. Note that there is no point in cross checking - * against the dirty LRU size, as the dirty LRU may not be maintained, - * and in any case, there is no requirement that all dirty entries - * will reside on the dirty LRU. - */ - assert(cache_ptr->dirty_index_size == cache_ptr->slist_size); - } - else { /* take down the skip list */ - if (!cache_ptr->slist_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist already disabled?") - - if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) { - if (clear_slist) { - H5SL_node_t *node_ptr; - - node_ptr = H5SL_first(cache_ptr->slist_ptr); - while (node_ptr != NULL) { - entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE); - node_ptr = H5SL_first(cache_ptr->slist_ptr); - } - } - else - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty?") - } - - cache_ptr->slist_enabled = FALSE; - - assert(0 == cache_ptr->slist_len); - assert(0 == cache_ptr->slist_size); - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_set_slist_enabled() */ - -/*------------------------------------------------------------------------- - * Function: H5C_unpin_entry() - * - * Purpose: Unpin a cache entry. The entry can be either protected or - * unprotected at the time of call, but must be pinned. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 3/22/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_unpin_entry(void *_entry_ptr) -{ - H5C_t *cache_ptr; - H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_entry_ptr; /* Pointer to entry to unpin */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - assert(entry_ptr); - cache_ptr = entry_ptr->cache_ptr; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - /* Unpin the entry */ - if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry from client") - -done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_unpin_entry() */ - -/*------------------------------------------------------------------------- - * Function: H5C_unprotect - * - * Purpose: Undo an H5C_protect() call -- specifically, mark the - * entry as unprotected, remove it from the protected list, - * and give it back to the replacement policy. - * - * The TYPE and ADDR arguments must be the same as those in - * the corresponding call to H5C_protect() and the THING - * argument must be the value returned by that call to - * H5C_protect(). - * - * Return: Non-negative on success/Negative on failure - * - * If the deleted flag is TRUE, simply remove the target entry - * from the cache, clear it, and free it without writing it to - * disk. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 6/2/04 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) -{ - H5C_t *cache_ptr; - hbool_t deleted; - hbool_t dirtied; - hbool_t set_flush_marker; - hbool_t pin_entry; - hbool_t unpin_entry; - hbool_t free_file_space; - hbool_t take_ownership; - hbool_t was_clean; -#ifdef H5_HAVE_PARALLEL - hbool_t clear_entry = FALSE; -#endif /* H5_HAVE_PARALLEL */ - H5C_cache_entry_t *entry_ptr; - H5C_cache_entry_t *test_entry_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - deleted = ((flags & H5C__DELETED_FLAG) != 0); - dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); - set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); - pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); - unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); - free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); - take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); - - assert(f); - assert(f->shared); - - cache_ptr = f->shared->cache; - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(H5_addr_defined(addr)); - assert(thing); - assert(!(pin_entry && unpin_entry)); - - /* deleted flag must accompany free_file_space */ - assert((!free_file_space) || (deleted)); - - /* deleted flag must accompany take_ownership */ - assert((!take_ownership) || (deleted)); - - /* can't have both free_file_space & take_ownership */ - assert(!(free_file_space && take_ownership)); - - entry_ptr = (H5C_cache_entry_t *)thing; - assert(entry_ptr->addr == addr); - - /* also set the dirtied variable if the dirtied field is set in - * the entry. - */ - dirtied |= entry_ptr->dirtied; - was_clean = !(entry_ptr->is_dirty); - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - /* if the entry has multiple read only protects, just decrement - * the ro_ref_counter. Don't actually unprotect until the ref count - * drops to zero. - */ - if (entry_ptr->ro_ref_count > 1) { - /* Sanity check */ - assert(entry_ptr->is_protected); - assert(entry_ptr->is_read_only); - - if (dirtied) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") - - /* Reduce the RO ref count */ - (entry_ptr->ro_ref_count)--; - - /* Pin or unpin the entry as requested. */ - if (pin_entry) { - /* Pin the entry from a client */ - if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") - } - else if (unpin_entry) { - /* Unpin the entry from a client */ - if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") - } /* end if */ - } - else { - if (entry_ptr->is_read_only) { - /* Sanity check */ - assert(entry_ptr->ro_ref_count == 1); - - if (dirtied) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") - - entry_ptr->is_read_only = FALSE; - entry_ptr->ro_ref_count = 0; - } /* end if */ - -#ifdef H5_HAVE_PARALLEL - /* When the H5C code is used to implement the metadata cache in the - * PHDF5 case, only the cache on process 0 is allowed to write to file. - * All the other metadata caches must hold dirty entries until they - * are told that the entries are clean. - * - * The clear_on_unprotect flag in the H5C_cache_entry_t structure - * exists to deal with the case in which an entry is protected when - * its cache receives word that the entry is now clean. In this case, - * the clear_on_unprotect flag is set, and the entry is flushed with - * the H5C__FLUSH_CLEAR_ONLY_FLAG. - * - * All this is a bit awkward, but until the metadata cache entries - * are contiguous, with only one dirty flag, we have to let the supplied - * functions deal with the resetting the is_dirty flag. - */ - if (entry_ptr->clear_on_unprotect) { - /* Sanity check */ - assert(entry_ptr->is_dirty); - - entry_ptr->clear_on_unprotect = FALSE; - if (!dirtied) - clear_entry = TRUE; - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - - if (!entry_ptr->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Entry already unprotected??") - - /* Mark the entry as dirty if appropriate */ - entry_ptr->is_dirty = (entry_ptr->is_dirty || dirtied); - if (dirtied && entry_ptr->image_up_to_date) { - entry_ptr->image_up_to_date = FALSE; - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "Can't propagate serialization status to fd parents") - } /* end if */ - - /* Check for newly dirtied entry */ - if (was_clean && entry_ptr->is_dirty) { - /* Update index for newly dirtied entry */ - H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr, FAIL) - - /* If the entry's type has a 'notify' callback send a - * 'entry dirtied' notice now that the entry is fully - * integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") - - /* Propagate the flush dep dirty flag up the flush dependency chain - * if appropriate - */ - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") - } /* end if */ - /* Check for newly clean entry */ - else if (!was_clean && !entry_ptr->is_dirty) { - - /* If the entry's type has a 'notify' callback send a - * 'entry cleaned' notice now that the entry is fully - * integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify client about entry dirty flag cleared") - - /* Propagate the flush dep clean flag up the flush dependency chain - * if appropriate - */ - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_clean(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") - } /* end else-if */ - - /* Pin or unpin the entry as requested. */ - if (pin_entry) { - /* Pin the entry from a client */ - if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") - } - else if (unpin_entry) { - /* Unpin the entry from a client */ - if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") - } /* end if */ - - /* H5C__UPDATE_RP_FOR_UNPROTECT will place the unprotected entry on - * the pinned entry list if entry_ptr->is_pinned is TRUE. - */ - H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, FAIL) - - entry_ptr->is_protected = FALSE; - - /* if the entry is dirty, 'or' its flush_marker with the set flush flag, - * and then add it to the skip list if it isn't there already. - */ - if (entry_ptr->is_dirty) { - entry_ptr->flush_marker |= set_flush_marker; - if (!entry_ptr->in_slist) - /* this is a no-op if cache_ptr->slist_enabled is FALSE */ - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - } /* end if */ - - /* This implementation of the "deleted" option is a bit inefficient, as - * we re-insert the entry to be deleted into the replacement policy - * data structures, only to remove them again. Depending on how often - * we do this, we may want to optimize a bit. - */ - if (deleted) { - unsigned flush_flags = (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_INVALIDATE_FLAG); - - /* verify that the target entry is in the cache. */ - H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - - if (test_entry_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") - else if (test_entry_ptr != entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, - "hash table contains multiple entries for addr?!?") - - /* Set the 'free file space' flag for the flush, if needed */ - if (free_file_space) - flush_flags |= H5C__FREE_FILE_SPACE_FLAG; - - /* Set the "take ownership" flag for the flush, if needed */ - if (take_ownership) - flush_flags |= H5C__TAKE_OWNERSHIP_FLAG; - - /* Delete the entry from the skip list on destroy */ - flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - - assert((!cache_ptr->slist_enabled) || (((!was_clean) || dirtied) == (entry_ptr->in_slist))); - - if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't flush entry") - } /* end if */ -#ifdef H5_HAVE_PARALLEL - else if (clear_entry) { - /* Verify that the target entry is in the cache. */ - H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - - if (test_entry_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") - else if (test_entry_ptr != entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, - "hash table contains multiple entries for addr?!?") - - if (H5C__flush_single_entry(f, entry_ptr, - H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't clear entry") - } /* end else if */ -#endif /* H5_HAVE_PARALLEL */ - } - - H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) - -done: -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_unprotect() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_unsettle_entry_ring - * - * Purpose: Advise the metadata cache that the specified entry's free space - * manager ring is no longer settled (if it was on entry). - * - * If the target free space manager ring is already - * unsettled, do nothing, and return SUCCEED. - * - * If the target free space manager ring is settled, and - * we are not in the process of a file shutdown, mark - * the ring as unsettled, and return SUCCEED. - * - * If the target free space manager is settled, and we - * are in the process of a file shutdown, post an error - * message, and return FAIL. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * January 3, 2017 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_unsettle_entry_ring(void *_entry) -{ - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry whose ring to unsettle */ - H5C_t *cache; /* Cache for file */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(entry); - assert(entry->ring != H5C_RING_UNDEFINED); - assert((H5C_RING_USER == entry->ring) || (H5C_RING_RDFSM == entry->ring) || - (H5C_RING_MDFSM == entry->ring)); - cache = entry->cache_ptr; - assert(cache); - assert(cache->magic == H5C__H5C_T_MAGIC); - - switch (entry->ring) { - case H5C_RING_USER: - /* Do nothing */ - break; - - case H5C_RING_RDFSM: - if (cache->rdfsm_settled) { - if (cache->flush_in_progress || cache->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") - cache->rdfsm_settled = FALSE; - } /* end if */ - break; - - case H5C_RING_MDFSM: - if (cache->mdfsm_settled) { - if (cache->flush_in_progress || cache->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") - cache->mdfsm_settled = FALSE; - } /* end if */ - break; - - default: - assert(FALSE); /* this should be un-reachable */ - break; - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_unsettle_entry_ring() */ - -/*------------------------------------------------------------------------- - * Function: H5C_unsettle_ring() - * - * Purpose: Advise the metadata cache that the specified free space - * manager ring is no longer settled (if it was on entry). - * - * If the target free space manager ring is already - * unsettled, do nothing, and return SUCCEED. - * - * If the target free space manager ring is settled, and - * we are not in the process of a file shutdown, mark - * the ring as unsettled, and return SUCCEED. - * - * If the target free space manager is settled, and we - * are in the process of a file shutdown, post an error - * message, and return FAIL. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_unsettle_ring(H5F_t *f, H5C_ring_t ring) -{ - H5C_t *cache_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(f); - assert(f->shared); - assert(f->shared->cache); - assert((H5C_RING_RDFSM == ring) || (H5C_RING_MDFSM == ring)); - cache_ptr = f->shared->cache; - assert(H5C__H5C_T_MAGIC == cache_ptr->magic); - - switch (ring) { - case H5C_RING_RDFSM: - if (cache_ptr->rdfsm_settled) { - if (cache_ptr->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") - cache_ptr->rdfsm_settled = FALSE; - } /* end if */ - break; - - case H5C_RING_MDFSM: - if (cache_ptr->mdfsm_settled) { - if (cache_ptr->close_warning_received) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") - cache_ptr->mdfsm_settled = FALSE; - } /* end if */ - break; - - default: - assert(FALSE); /* this should be un-reachable */ - break; - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_unsettle_ring() */ - -/*------------------------------------------------------------------------- - * Function: H5C_validate_resize_config() - * - * Purpose: Run a sanity check on the specified sections of the - * provided instance of struct H5C_auto_size_ctl_t. - * - * Do nothing and return SUCCEED if no errors are detected, - * and flag an error and return FAIL otherwise. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if (config_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") - - if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown config version") - - if ((tests & H5C_RESIZE_CFG__VALIDATE_GENERAL) != 0) { - if (config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "max_size too big") - if (config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size too small") - if (config_ptr->min_size > config_ptr->max_size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size > max_size") - if (config_ptr->set_initial_size && ((config_ptr->initial_size < config_ptr->min_size) || - (config_ptr->initial_size > config_ptr->max_size))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "initial_size must be in the interval [min_size, max_size]") - if ((config_ptr->min_clean_fraction < 0.0) || (config_ptr->min_clean_fraction > 1.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_clean_fraction must be in the interval [0.0, 1.0]") - if (config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too small") - if (config_ptr->epoch_length > H5C__MAX_AR_EPOCH_LENGTH) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too big") - } /* H5C_RESIZE_CFG__VALIDATE_GENERAL */ - - if ((tests & H5C_RESIZE_CFG__VALIDATE_INCREMENT) != 0) { - if ((config_ptr->incr_mode != H5C_incr__off) && (config_ptr->incr_mode != H5C_incr__threshold)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid incr_mode") - - if (config_ptr->incr_mode == H5C_incr__threshold) { - if ((config_ptr->lower_hr_threshold < 0.0) || (config_ptr->lower_hr_threshold > 1.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "lower_hr_threshold must be in the range [0.0, 1.0]") - if (config_ptr->increment < 1.0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "increment must be greater than or equal to 1.0") - - /* no need to check max_increment, as it is a size_t, - * and thus must be non-negative. - */ - } /* H5C_incr__threshold */ - - switch (config_ptr->flash_incr_mode) { - case H5C_flash_incr__off: - /* nothing to do here */ - break; - - case H5C_flash_incr__add_space: - if ((config_ptr->flash_multiple < 0.1) || (config_ptr->flash_multiple > 10.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "flash_multiple must be in the range [0.1, 10.0]") - if ((config_ptr->flash_threshold < 0.1) || (config_ptr->flash_threshold > 1.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "flash_threshold must be in the range [0.1, 1.0]") - break; - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid flash_incr_mode") - break; - } /* end switch */ - } /* H5C_RESIZE_CFG__VALIDATE_INCREMENT */ - - if ((tests & H5C_RESIZE_CFG__VALIDATE_DECREMENT) != 0) { - if ((config_ptr->decr_mode != H5C_decr__off) && (config_ptr->decr_mode != H5C_decr__threshold) && - (config_ptr->decr_mode != H5C_decr__age_out) && - (config_ptr->decr_mode != H5C_decr__age_out_with_threshold)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid decr_mode") - - if (config_ptr->decr_mode == H5C_decr__threshold) { - if (config_ptr->upper_hr_threshold > 1.0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") - if ((config_ptr->decrement > 1.0) || (config_ptr->decrement < 0.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") - - /* no need to check max_decrement as it is a size_t - * and thus must be non-negative. - */ - } /* H5C_decr__threshold */ - - if ((config_ptr->decr_mode == H5C_decr__age_out) || - (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) { - if (config_ptr->epochs_before_eviction < 1) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction must be positive") - if (config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") - if (config_ptr->apply_empty_reserve && - (config_ptr->empty_reserve > 1.0 || config_ptr->empty_reserve < 0.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty_reserve must be in the interval [0.0, 1.0]") - - /* no need to check max_decrement as it is a size_t - * and thus must be non-negative. - */ - } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ - - if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) - if ((config_ptr->upper_hr_threshold > 1.0) || (config_ptr->upper_hr_threshold < 0.0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "upper_hr_threshold must be in the interval [0.0, 1.0]") - } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ - - if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { - if ((config_ptr->incr_mode == H5C_incr__threshold) && - ((config_ptr->decr_mode == H5C_decr__threshold) || - (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && - (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") - } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_resize_config() */ - -/*------------------------------------------------------------------------- - * Function: H5C_create_flush_dependency() - * - * Purpose: Initiates a parent<->child entry flush dependency. The parent - * entry must be pinned or protected at the time of call, and must - * have all dependencies removed before the cache can shut down. - * - * Note: Flush dependencies in the cache indicate that a child entry - * must be flushed to the file before its parent. (This is - * currently used to implement Single-Writer/Multiple-Reader (SWMR) - * I/O access for data structures in the file). - * - * Creating a flush dependency between two entries will also pin - * the parent entry. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 3/05/09 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_create_flush_dependency(void *parent_thing, void *child_thing) -{ - H5C_t *cache_ptr; - H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent thing's entry */ - H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child thing's entry */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(parent_entry); - assert(parent_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(H5_addr_defined(parent_entry->addr)); - assert(child_entry); - assert(child_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(H5_addr_defined(child_entry->addr)); - cache_ptr = parent_entry->cache_ptr; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr == child_entry->cache_ptr); -#ifndef NDEBUG - /* Make sure the parent is not already a parent */ - { - unsigned u; - - for (u = 0; u < child_entry->flush_dep_nparents; u++) - assert(child_entry->flush_dep_parent[u] != parent_entry); - } /* end block */ -#endif /* NDEBUG */ - - /* More sanity checks */ - if (child_entry == parent_entry) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Child entry flush dependency parent can't be itself") - if (!(parent_entry->is_protected || parent_entry->is_pinned)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry isn't pinned or protected") - - /* Check for parent not pinned */ - if (!parent_entry->is_pinned) { - /* Sanity check */ - assert(parent_entry->flush_dep_nchildren == 0); - assert(!parent_entry->pinned_from_client); - assert(!parent_entry->pinned_from_cache); - - /* Pin the parent entry */ - parent_entry->is_pinned = TRUE; - H5C__UPDATE_STATS_FOR_PIN(cache_ptr, parent_entry) - } /* end else */ - - /* Mark the entry as pinned from the cache's action (possibly redundantly) */ - parent_entry->pinned_from_cache = TRUE; - - /* Check if we need to resize the child's parent array */ - if (child_entry->flush_dep_nparents >= child_entry->flush_dep_parent_nalloc) { - if (child_entry->flush_dep_parent_nalloc == 0) { - /* Array does not exist yet, allocate it */ - assert(!child_entry->flush_dep_parent); - - if (NULL == (child_entry->flush_dep_parent = - H5FL_SEQ_MALLOC(H5C_cache_entry_ptr_t, H5C_FLUSH_DEP_PARENT_INIT))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for flush dependency parent list") - child_entry->flush_dep_parent_nalloc = H5C_FLUSH_DEP_PARENT_INIT; - } /* end if */ - else { - /* Resize existing array */ - assert(child_entry->flush_dep_parent); - - if (NULL == (child_entry->flush_dep_parent = - H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, - 2 * child_entry->flush_dep_parent_nalloc))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for flush dependency parent list") - child_entry->flush_dep_parent_nalloc *= 2; - } /* end else */ - cache_ptr->entry_fd_height_change_counter++; - } /* end if */ - - /* Add the dependency to the child's parent array */ - child_entry->flush_dep_parent[child_entry->flush_dep_nparents] = parent_entry; - child_entry->flush_dep_nparents++; - - /* Increment parent's number of children */ - parent_entry->flush_dep_nchildren++; - - /* Adjust the number of dirty children */ - if (child_entry->is_dirty) { - /* Sanity check */ - assert(parent_entry->flush_dep_ndirty_children < parent_entry->flush_dep_nchildren); - - parent_entry->flush_dep_ndirty_children++; - - /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ - if (parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry dirty flag set") - } /* end if */ - - /* adjust the parent's number of unserialized children. Note - * that it is possible for and entry to be clean and unserialized. - */ - if (!child_entry->image_up_to_date) { - assert(parent_entry->flush_dep_nunser_children < parent_entry->flush_dep_nchildren); - - parent_entry->flush_dep_nunser_children++; - - /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ - if (parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry serialized flag reset") - } /* end if */ - - /* Post-conditions, for successful operation */ - assert(parent_entry->is_pinned); - assert(parent_entry->flush_dep_nchildren > 0); - assert(child_entry->flush_dep_parent); - assert(child_entry->flush_dep_nparents > 0); - assert(child_entry->flush_dep_parent_nalloc > 0); -#ifndef NDEBUG - H5C__assert_flush_dep_nocycle(parent_entry, child_entry); -#endif /* NDEBUG */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_create_flush_dependency() */ - -/*------------------------------------------------------------------------- - * Function: H5C_destroy_flush_dependency() - * - * Purpose: Terminates a parent<-> child entry flush dependency. The - * parent entry must be pinned. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 3/05/09 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_destroy_flush_dependency(void *parent_thing, void *child_thing) -{ - H5C_t *cache_ptr; - H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent entry */ - H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child entry */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(parent_entry); - assert(parent_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(H5_addr_defined(parent_entry->addr)); - assert(child_entry); - assert(child_entry->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(H5_addr_defined(child_entry->addr)); - cache_ptr = parent_entry->cache_ptr; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr == child_entry->cache_ptr); - - /* Usage checks */ - if (!parent_entry->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry isn't pinned") - if (NULL == child_entry->flush_dep_parent) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, - "Child entry doesn't have a flush dependency parent array") - if (0 == parent_entry->flush_dep_nchildren) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, - "Parent entry flush dependency ref. count has no child dependencies") - - /* Search for parent in child's parent array. This is a linear search - * because we do not expect large numbers of parents. If this changes, we - * may wish to change the parent array to a skip list */ - for (u = 0; u < child_entry->flush_dep_nparents; u++) - if (child_entry->flush_dep_parent[u] == parent_entry) - break; - if (u == child_entry->flush_dep_nparents) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, - "Parent entry isn't a flush dependency parent for child entry") - - /* Remove parent entry from child's parent array */ - if (u < (child_entry->flush_dep_nparents - 1)) - HDmemmove(&child_entry->flush_dep_parent[u], &child_entry->flush_dep_parent[u + 1], - (child_entry->flush_dep_nparents - u - 1) * sizeof(child_entry->flush_dep_parent[0])); - child_entry->flush_dep_nparents--; - - /* Adjust parent entry's nchildren and unpin parent if it goes to zero */ - parent_entry->flush_dep_nchildren--; - if (0 == parent_entry->flush_dep_nchildren) { - /* Sanity check */ - assert(parent_entry->pinned_from_cache); - - /* Check if we should unpin parent entry now */ - if (!parent_entry->pinned_from_client) - if (H5C__unpin_entry_real(cache_ptr, parent_entry, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry") - - /* Mark the entry as unpinned from the cache's action */ - parent_entry->pinned_from_cache = FALSE; - } /* end if */ - - /* Adjust parent entry's ndirty_children */ - if (child_entry->is_dirty) { - /* Sanity check */ - assert(parent_entry->flush_dep_ndirty_children > 0); - - parent_entry->flush_dep_ndirty_children--; - - /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ - if (parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry dirty flag reset") - } /* end if */ - - /* adjust parent entry's number of unserialized children */ - if (!child_entry->image_up_to_date) { - assert(parent_entry->flush_dep_nunser_children > 0); - - parent_entry->flush_dep_nunser_children--; - - /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ - if (parent_entry->type->notify && - (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, parent_entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry serialized flag set") - } /* end if */ - - /* Shrink or free the parent array if appropriate */ - if (child_entry->flush_dep_nparents == 0) { - child_entry->flush_dep_parent = H5FL_SEQ_FREE(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent); - child_entry->flush_dep_parent_nalloc = 0; - } /* end if */ - else if (child_entry->flush_dep_parent_nalloc > H5C_FLUSH_DEP_PARENT_INIT && - child_entry->flush_dep_nparents <= (child_entry->flush_dep_parent_nalloc / 4)) { - if (NULL == (child_entry->flush_dep_parent = - H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, - child_entry->flush_dep_parent_nalloc / 4))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for flush dependency parent list") - child_entry->flush_dep_parent_nalloc /= 4; - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_destroy_flush_dependency() */ - -/*************************************************************************/ -/**************************** Private Functions: *************************/ -/*************************************************************************/ - -/*------------------------------------------------------------------------- - * Function: H5C__pin_entry_from_client() - * - * Purpose: Internal routine to pin a cache entry from a client action. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 3/26/09 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__pin_entry_from_client(H5C_t -#if !H5C_COLLECT_CACHE_STATS - H5_ATTR_UNUSED -#endif - *cache_ptr, - H5C_cache_entry_t *entry_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(cache_ptr); - assert(entry_ptr); - assert(entry_ptr->is_protected); - - /* Check if the entry is already pinned */ - if (entry_ptr->is_pinned) { - /* Check if the entry was pinned through an explicit pin from a client */ - if (entry_ptr->pinned_from_client) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "entry is already pinned") - } /* end if */ - else { - entry_ptr->is_pinned = TRUE; - - H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) - } /* end else */ - - /* Mark that the entry was pinned through an explicit pin from a client */ - entry_ptr->pinned_from_client = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__pin_entry_from_client() */ - -/*------------------------------------------------------------------------- - * Function: H5C__unpin_entry_real() - * - * Purpose: Internal routine to unpin a cache entry. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 1/6/18 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp) -{ - herr_t ret_value = SUCCEED; /* Return value */ - -#ifdef H5C_DO_SANITY_CHECKS - FUNC_ENTER_PACKAGE -#else - FUNC_ENTER_PACKAGE_NOERR -#endif - - /* Sanity checking */ - assert(cache_ptr); - assert(entry_ptr); - assert(entry_ptr->is_pinned); - - /* If requested, update the replacement policy if the entry is not protected */ - if (update_rp && !entry_ptr->is_protected) - H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, FAIL) - - /* Unpin the entry now */ - entry_ptr->is_pinned = FALSE; - - /* Update the stats for an unpin operation */ - H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) - -#ifdef H5C_DO_SANITY_CHECKS -done: -#endif - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__unpin_entry_real() */ - -/*------------------------------------------------------------------------- - * Function: H5C__unpin_entry_from_client() - * - * Purpose: Internal routine to unpin a cache entry from a client action. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * 3/24/09 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checking */ - assert(cache_ptr); - assert(entry_ptr); - - /* Error checking (should be sanity checks?) */ - if (!entry_ptr->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry isn't pinned") - if (!entry_ptr->pinned_from_client) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry wasn't pinned by cache client") - - /* Check if the entry is not pinned from a flush dependency */ - if (!entry_ptr->pinned_from_cache) - if (H5C__unpin_entry_real(cache_ptr, entry_ptr, update_rp) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") - - /* Mark the entry as explicitly unpinned by the client */ - entry_ptr->pinned_from_client = FALSE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__unpin_entry_from_client() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__auto_adjust_cache_size - * - * Purpose: Obtain the current full cache hit rate, and compare it - * with the hit rate thresholds for modifying cache size. - * If one of the thresholds has been crossed, adjusts the - * size of the cache accordingly. - * - * The function then resets the full cache hit rate - * statistics, and exits. - * - * Return: Non-negative on success/Negative on failure or if there was - * an attempt to flush a protected item. - * - * - * Programmer: John Mainzer, 10/7/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) -{ - H5C_t *cache_ptr = f->shared->cache; - hbool_t reentrant_call = FALSE; - hbool_t inserted_epoch_marker = FALSE; - size_t new_max_cache_size = 0; - size_t old_max_cache_size = 0; - size_t new_min_clean_size = 0; - size_t old_min_clean_size = 0; - double hit_rate; - enum H5C_resize_status status = in_spec; /* will change if needed */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(f); - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->cache_accesses >= cache_ptr->resize_ctl.epoch_length); - assert(0.0 <= cache_ptr->resize_ctl.min_clean_fraction); - assert(cache_ptr->resize_ctl.min_clean_fraction <= 100.0); - - /* check to see if cache_ptr->resize_in_progress is TRUE. If it, this - * is a re-entrant call via a client callback called in the resize - * process. To avoid an infinite recursion, set reentrant_call to - * TRUE, and goto done. - */ - if (cache_ptr->resize_in_progress) { - reentrant_call = TRUE; - HGOTO_DONE(SUCCEED) - } /* end if */ - - cache_ptr->resize_in_progress = TRUE; - - if (!cache_ptr->resize_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Auto cache resize disabled") - - assert((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || - (cache_ptr->resize_ctl.decr_mode != H5C_decr__off)); - - if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") - - assert((0.0 <= hit_rate) && (hit_rate <= 1.0)); - - switch (cache_ptr->resize_ctl.incr_mode) { - case H5C_incr__off: - if (cache_ptr->size_increase_possible) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "size_increase_possible but H5C_incr__off?!?!?") - break; - - case H5C_incr__threshold: - if (hit_rate < cache_ptr->resize_ctl.lower_hr_threshold) { - if (!cache_ptr->size_increase_possible) - status = increase_disabled; - else if (cache_ptr->max_cache_size >= cache_ptr->resize_ctl.max_size) { - assert(cache_ptr->max_cache_size == cache_ptr->resize_ctl.max_size); - status = at_max_size; - } - else if (!cache_ptr->cache_full) - status = not_full; - else { - new_max_cache_size = - (size_t)(((double)(cache_ptr->max_cache_size)) * cache_ptr->resize_ctl.increment); - - /* clip to max size if necessary */ - if (new_max_cache_size > cache_ptr->resize_ctl.max_size) - new_max_cache_size = cache_ptr->resize_ctl.max_size; - - /* clip to max increment if necessary */ - if (cache_ptr->resize_ctl.apply_max_increment && - ((cache_ptr->max_cache_size + cache_ptr->resize_ctl.max_increment) < - new_max_cache_size)) - new_max_cache_size = cache_ptr->max_cache_size + cache_ptr->resize_ctl.max_increment; - - status = increase; - } - } - break; - - default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") - } - - /* If the decr_mode is either age out or age out with threshold, we - * must run the marker maintenance code, whether we run the size - * reduction code or not. We do this in two places -- here we - * insert a new marker if the number of active epoch markers is - * is less than the current epochs before eviction, and after - * the ageout call, we cycle the markers. - * - * However, we can't call the ageout code or cycle the markers - * unless there was a full complement of markers in place on - * entry. The inserted_epoch_marker flag is used to track this. - */ - - if (((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out) || - (cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out_with_threshold)) && - (cache_ptr->epoch_markers_active < cache_ptr->resize_ctl.epochs_before_eviction)) { - - if (H5C__autoadjust__ageout__insert_new_marker(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't insert new epoch marker") - - inserted_epoch_marker = TRUE; - } - - /* don't run the cache size decrease code unless the cache size - * increase code is disabled, or the size increase code sees no need - * for action. In either case, status == in_spec at this point. - */ - - if (status == in_spec) { - switch (cache_ptr->resize_ctl.decr_mode) { - case H5C_decr__off: - break; - - case H5C_decr__threshold: - if (hit_rate > cache_ptr->resize_ctl.upper_hr_threshold) { - if (!cache_ptr->size_decrease_possible) - status = decrease_disabled; - else if (cache_ptr->max_cache_size <= cache_ptr->resize_ctl.min_size) { - assert(cache_ptr->max_cache_size == cache_ptr->resize_ctl.min_size); - status = at_min_size; - } - else { - new_max_cache_size = - (size_t)(((double)(cache_ptr->max_cache_size)) * cache_ptr->resize_ctl.decrement); - - /* clip to min size if necessary */ - if (new_max_cache_size < cache_ptr->resize_ctl.min_size) - new_max_cache_size = cache_ptr->resize_ctl.min_size; - - /* clip to max decrement if necessary */ - if (cache_ptr->resize_ctl.apply_max_decrement && - ((cache_ptr->resize_ctl.max_decrement + new_max_cache_size) < - cache_ptr->max_cache_size)) - new_max_cache_size = - cache_ptr->max_cache_size - cache_ptr->resize_ctl.max_decrement; - - status = decrease; - } - } - break; - - case H5C_decr__age_out_with_threshold: - case H5C_decr__age_out: - if (!inserted_epoch_marker) { - if (!cache_ptr->size_decrease_possible) - status = decrease_disabled; - else { - if (H5C__autoadjust__ageout(f, hit_rate, &status, &new_max_cache_size, - write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ageout code failed") - } /* end else */ - } /* end if */ - break; - - default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") - } - } - - /* cycle the epoch markers here if appropriate */ - if (((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out) || - (cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out_with_threshold)) && - !inserted_epoch_marker) - /* move last epoch marker to the head of the LRU list */ - if (H5C__autoadjust__ageout__cycle_epoch_marker(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error cycling epoch marker") - - if ((status == increase) || (status == decrease)) { - old_max_cache_size = cache_ptr->max_cache_size; - old_min_clean_size = cache_ptr->min_clean_size; - - new_min_clean_size = - (size_t)((double)new_max_cache_size * (cache_ptr->resize_ctl.min_clean_fraction)); - - /* new_min_clean_size is of size_t, and thus must be non-negative. - * Hence we have - * - * ( 0 <= new_min_clean_size ). - * - * by definition. - */ - assert(new_min_clean_size <= new_max_cache_size); - assert(cache_ptr->resize_ctl.min_size <= new_max_cache_size); - assert(new_max_cache_size <= cache_ptr->resize_ctl.max_size); - - cache_ptr->max_cache_size = new_max_cache_size; - cache_ptr->min_clean_size = new_min_clean_size; - - if (status == increase) - cache_ptr->cache_full = FALSE; - else if (status == decrease) - cache_ptr->size_decreased = TRUE; - - /* update flash cache size increase fields as appropriate */ - if (cache_ptr->flash_size_increase_possible) { - switch (cache_ptr->resize_ctl.flash_incr_mode) { - case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, - "flash_size_increase_possible but H5C_flash_incr__off?!") - break; - - case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_threshold = - (size_t)(((double)(cache_ptr->max_cache_size)) * - (cache_ptr->resize_ctl.flash_threshold)); - break; - - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; - } - } - } - - if (cache_ptr->resize_ctl.rpt_fcn != NULL) - (cache_ptr->resize_ctl.rpt_fcn)(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, status, - old_max_cache_size, new_max_cache_size, old_min_clean_size, - new_min_clean_size); - - if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) - /* this should be impossible... */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") - -done: - /* Sanity checks */ - assert(cache_ptr->resize_in_progress); - if (!reentrant_call) - cache_ptr->resize_in_progress = FALSE; - assert((!reentrant_call) || (cache_ptr->resize_in_progress)); - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__auto_adjust_cache_size() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout - * - * Purpose: Implement the ageout automatic cache size decrement - * algorithm. Note that while this code evicts aged out - * entries, the code does not change the maximum cache size. - * Instead, the function simply computes the new value (if - * any change is indicated) and reports this value in - * *new_max_cache_size_ptr. - * - * Return: Non-negative on success/Negative on failure or if there was - * an attempt to flush a protected item. - * - * - * Programmer: John Mainzer, 11/18/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *status_ptr, - size_t *new_max_cache_size_ptr, hbool_t write_permitted) -{ - H5C_t *cache_ptr = f->shared->cache; - size_t test_size; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(f); - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert((status_ptr) && (*status_ptr == in_spec)); - assert((new_max_cache_size_ptr) && (*new_max_cache_size_ptr == 0)); - - /* remove excess epoch markers if any */ - if (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) - if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") - - if ((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out) || - ((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out_with_threshold) && - (hit_rate >= cache_ptr->resize_ctl.upper_hr_threshold))) { - - if (cache_ptr->max_cache_size > cache_ptr->resize_ctl.min_size) { - /* evict aged out cache entries if appropriate... */ - if (H5C__autoadjust__ageout__evict_aged_out_entries(f, write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error flushing aged out entries") - - /* ... and then reduce cache size if appropriate */ - if (cache_ptr->index_size < cache_ptr->max_cache_size) { - if (cache_ptr->resize_ctl.apply_empty_reserve) { - test_size = - (size_t)(((double)cache_ptr->index_size) / (1 - cache_ptr->resize_ctl.empty_reserve)); - if (test_size < cache_ptr->max_cache_size) { - *status_ptr = decrease; - *new_max_cache_size_ptr = test_size; - } - } - else { - *status_ptr = decrease; - *new_max_cache_size_ptr = cache_ptr->index_size; - } - - if (*status_ptr == decrease) { - /* clip to min size if necessary */ - if (*new_max_cache_size_ptr < cache_ptr->resize_ctl.min_size) - *new_max_cache_size_ptr = cache_ptr->resize_ctl.min_size; - - /* clip to max decrement if necessary */ - if ((cache_ptr->resize_ctl.apply_max_decrement) && - ((cache_ptr->resize_ctl.max_decrement + *new_max_cache_size_ptr) < - cache_ptr->max_cache_size)) - *new_max_cache_size_ptr = - cache_ptr->max_cache_size - cache_ptr->resize_ctl.max_decrement; - } - } - } - else - *status_ptr = at_min_size; - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__cycle_epoch_marker - * - * Purpose: Remove the oldest epoch marker from the LRU list, - * and reinsert it at the head of the LRU list. Also - * remove the epoch marker's index from the head of the - * ring buffer, and re-insert it at the tail of the ring - * buffer. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/22/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) -{ - int i; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - if (cache_ptr->epoch_markers_active <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "No active epoch markers on entry?!?!?") - - /* remove the last marker from both the ring buffer and the LRU list */ - i = cache_ptr->epoch_marker_ringbuf[cache_ptr->epoch_marker_ringbuf_first]; - cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - if (cache_ptr->epoch_marker_ringbuf_size <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") - - cache_ptr->epoch_marker_ringbuf_size -= 1; - if (cache_ptr->epoch_marker_active[i] != TRUE) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") - - H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, - (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (FAIL)) - - /* now, re-insert it at the head of the LRU list, and at the tail of - * the ring buffer. - */ - assert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); - assert(cache_ptr->epoch_markers[i].next == NULL); - assert(cache_ptr->epoch_markers[i].prev == NULL); - - cache_ptr->epoch_marker_ringbuf_last = - (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - cache_ptr->epoch_marker_ringbuf[cache_ptr->epoch_marker_ringbuf_last] = i; - if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") - - cache_ptr->epoch_marker_ringbuf_size += 1; - - H5C__DLL_PREPEND(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, - cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) -done: - - FUNC_LEAVE_NOAPI(ret_value) - -} /* H5C__autoadjust__ageout__cycle_epoch_marker() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__evict_aged_out_entries - * - * Purpose: Evict clean entries in the cache that haven't - * been accessed for at least - * cache_ptr->resize_ctl.epochs_before_eviction epochs, - * and flush dirty entries that haven't been accessed for - * that amount of time. - * - * Depending on configuration, the function will either - * flush or evict all such entries, or all such entries it - * encounters until it has freed the maximum amount of space - * allowed under the maximum decrement. - * - * If we are running in parallel mode, writes may not be - * permitted. If so, the function simply skips any dirty - * entries it may encounter. - * - * The function makes no attempt to maintain the minimum - * clean size, as there is no guarantee that the cache size - * will be changed. - * - * If there is no cache size change, the minimum clean size - * constraint will be met through a combination of clean - * entries and free space in the cache. - * - * If there is a cache size reduction, the minimum clean size - * will be re-calculated, and will be enforced the next time - * we have to make space in the cache. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 11/22/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted) -{ - H5C_t *cache_ptr = f->shared->cache; - size_t eviction_size_limit; - size_t bytes_evicted = 0; - hbool_t prev_is_dirty = FALSE; - hbool_t restart_scan; - H5C_cache_entry_t *entry_ptr; - H5C_cache_entry_t *next_ptr; - H5C_cache_entry_t *prev_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(f); - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* if there is a limit on the amount that the cache size can be decrease - * in any one round of the cache size reduction algorithm, load that - * limit into eviction_size_limit. Otherwise, set eviction_size_limit - * to the equivalent of infinity. The current size of the index will - * do nicely. - */ - if (cache_ptr->resize_ctl.apply_max_decrement) - eviction_size_limit = cache_ptr->resize_ctl.max_decrement; - else - eviction_size_limit = cache_ptr->index_size; /* i.e. infinity */ - - if (write_permitted) { - restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; - while (entry_ptr != NULL && entry_ptr->type->id != H5AC_EPOCH_MARKER_ID && - bytes_evicted < eviction_size_limit) { - hbool_t skipping_entry = FALSE; - - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(!(entry_ptr->is_protected)); - assert(!(entry_ptr->is_read_only)); - assert((entry_ptr->ro_ref_count) == 0); - - next_ptr = entry_ptr->next; - prev_ptr = entry_ptr->prev; - - if (prev_ptr != NULL) - prev_is_dirty = prev_ptr->is_dirty; - - if (entry_ptr->is_dirty) { - assert(!entry_ptr->prefetched_dirty); - - /* dirty corked entry is skipped */ - if (entry_ptr->tag_info && entry_ptr->tag_info->corked) - skipping_entry = TRUE; - else { - /* reset entries_removed_counter and - * last_entry_removed_ptr prior to the call to - * H5C__flush_single_entry() so that we can spot - * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry - * that is no longer in the cache. - */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; - - if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - - if (cache_ptr->entries_removed_counter > 1 || - cache_ptr->last_entry_removed_ptr == prev_ptr) - restart_scan = TRUE; - } /* end else */ - } /* end if */ - else if (!entry_ptr->prefetched_dirty) { - bytes_evicted += entry_ptr->size; - - if (H5C__flush_single_entry( - f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } /* end else-if */ - else { - assert(!entry_ptr->is_dirty); - assert(entry_ptr->prefetched_dirty); - - skipping_entry = TRUE; - } /* end else */ - - if (prev_ptr != NULL) { - if (skipping_entry) - entry_ptr = prev_ptr; - else if (restart_scan || (prev_ptr->is_dirty != prev_is_dirty) || - (prev_ptr->next != next_ptr) || (prev_ptr->is_protected) || (prev_ptr->is_pinned)) { - /* Something has happened to the LRU -- start over - * from the tail. - */ - restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; - - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) - } /* end else-if */ - else - entry_ptr = prev_ptr; - } /* end if */ - else - entry_ptr = NULL; - } /* end while */ - - /* for now at least, don't bother to maintain the minimum clean size, - * as the cache should now be less than its maximum size. Due to - * the vaguries of the cache size reduction algorithm, we may not - * reduce the size of the cache. - * - * If we do, we will calculate a new minimum clean size, which will - * be enforced the next time we try to make space in the cache. - * - * If we don't, no action is necessary, as we have just evicted and/or - * or flushed a bunch of entries and therefore the sum of the clean - * and free space in the cache must be greater than or equal to the - * min clean space requirement (assuming that requirement was met on - * entry). - */ - } /* end if */ - else /* ! write_permitted */ { - /* Since we are not allowed to write, all we can do is evict - * any clean entries that we may encounter before we either - * hit the eviction size limit, or encounter the epoch marker. - * - * If we are operating read only, this isn't an issue, as there - * will not be any dirty entries. - * - * If we are operating in R/W mode, all the dirty entries we - * skip will be flushed the next time we attempt to make space - * when writes are permitted. This may have some local - * performance implications, but it shouldn't cause any net - * slowdown. - */ - assert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); - entry_ptr = cache_ptr->LRU_tail_ptr; - while (entry_ptr != NULL && ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && - (bytes_evicted < eviction_size_limit)) { - assert(!(entry_ptr->is_protected)); - - prev_ptr = entry_ptr->prev; - - if (!(entry_ptr->is_dirty) && !(entry_ptr->prefetched_dirty)) - if (H5C__flush_single_entry( - f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") - - /* just skip the entry if it is dirty, as we can't do - * anything with it now since we can't write. - * - * Since all entries are clean, serialize() will not be called, - * and thus we needn't test to see if the LRU has been changed - * out from under us. - */ - entry_ptr = prev_ptr; - } /* end while */ - } /* end else */ - - if (cache_ptr->index_size < cache_ptr->max_cache_size) - cache_ptr->cache_full = FALSE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__evict_aged_out_entries() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__insert_new_marker - * - * Purpose: Find an unused marker cache entry, mark it as used, and - * insert it at the head of the LRU list. Also add the - * marker's index in the epoch_markers array. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/19/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr) -{ - int i; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - if (cache_ptr->epoch_markers_active >= cache_ptr->resize_ctl.epochs_before_eviction) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Already have a full complement of markers") - - /* find an unused marker */ - i = 0; - while ((cache_ptr->epoch_marker_active)[i] && i < H5C__MAX_EPOCH_MARKERS) - i++; - if (i >= H5C__MAX_EPOCH_MARKERS) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't find unused marker") - - assert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); - assert(((cache_ptr->epoch_markers)[i]).next == NULL); - assert(((cache_ptr->epoch_markers)[i]).prev == NULL); - - (cache_ptr->epoch_marker_active)[i] = TRUE; - - cache_ptr->epoch_marker_ringbuf_last = - (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; - if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") - - cache_ptr->epoch_marker_ringbuf_size += 1; - - H5C__DLL_PREPEND(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, - cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) - - cache_ptr->epoch_markers_active += 1; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__insert_new_marker() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__remove_all_markers - * - * Purpose: Remove all epoch markers from the LRU list and mark them - * as inactive. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/22/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr) -{ - int ring_buf_index; - int i; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - while (cache_ptr->epoch_markers_active > 0) { - /* get the index of the last epoch marker in the LRU list - * and remove it from the ring buffer. - */ - - ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; - i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; - - cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - - if (cache_ptr->epoch_marker_ringbuf_size <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") - cache_ptr->epoch_marker_ringbuf_size -= 1; - - if (cache_ptr->epoch_marker_active[i] != TRUE) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") - - /* remove the epoch marker from the LRU list */ - H5C__DLL_REMOVE(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, - cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) - - /* mark the epoch marker as unused. */ - cache_ptr->epoch_marker_active[i] = FALSE; - - assert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); - assert(cache_ptr->epoch_markers[i].next == NULL); - assert(cache_ptr->epoch_markers[i].prev == NULL); - - /* decrement the number of active epoch markers */ - cache_ptr->epoch_markers_active -= 1; - - assert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__remove_all_markers() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__autoadjust__ageout__remove_excess_markers - * - * Purpose: Remove epoch markers from the end of the LRU list and - * mark them as inactive until the number of active markers - * equals the current value of - * cache_ptr->resize_ctl.epochs_before_eviction. - * - * Return: SUCCEED on success/FAIL on failure. - * - * Programmer: John Mainzer, 11/19/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr) -{ - int ring_buf_index; - int i; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - if (cache_ptr->epoch_markers_active <= cache_ptr->resize_ctl.epochs_before_eviction) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "no excess markers on entry") - - while (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) { - /* get the index of the last epoch marker in the LRU list - * and remove it from the ring buffer. - */ - ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; - i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; - - cache_ptr->epoch_marker_ringbuf_first = - (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - - if (cache_ptr->epoch_marker_ringbuf_size <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") - cache_ptr->epoch_marker_ringbuf_size -= 1; - - if (cache_ptr->epoch_marker_active[i] != TRUE) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") - - /* remove the epoch marker from the LRU list */ - H5C__DLL_REMOVE(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, - cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) - - /* mark the epoch marker as unused. */ - cache_ptr->epoch_marker_active[i] = FALSE; - - assert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); - assert(cache_ptr->epoch_markers[i].next == NULL); - assert(cache_ptr->epoch_markers[i].prev == NULL); - - /* decrement the number of active epoch markers */ - cache_ptr->epoch_markers_active -= 1; - - assert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__autoadjust__ageout__remove_excess_markers() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__flash_increase_cache_size - * - * Purpose: If there is not at least new_entry_size - old_entry_size - * bytes of free space in the cache and the current - * max_cache_size is less than cache_ptr->resize_ctl.max_size, - * perform a flash increase in the cache size and then reset - * the full cache hit rate statistics, and exit. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 12/31/07 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t new_entry_size) -{ - size_t new_max_cache_size = 0; - size_t old_max_cache_size = 0; - size_t new_min_clean_size = 0; - size_t old_min_clean_size = 0; - size_t space_needed; - enum H5C_resize_status status = flash_increase; /* may change */ - double hit_rate; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->flash_size_increase_possible); - assert(new_entry_size > cache_ptr->flash_size_increase_threshold); - assert(old_entry_size < new_entry_size); - - if (old_entry_size >= new_entry_size) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "old_entry_size >= new_entry_size") - - space_needed = new_entry_size - old_entry_size; - if (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && - (cache_ptr->max_cache_size < cache_ptr->resize_ctl.max_size)) { - switch (cache_ptr->resize_ctl.flash_incr_mode) { - case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, - "flash_size_increase_possible but H5C_flash_incr__off?!") - break; - - case H5C_flash_incr__add_space: - if (cache_ptr->index_size < cache_ptr->max_cache_size) { - assert((cache_ptr->max_cache_size - cache_ptr->index_size) < space_needed); - space_needed -= cache_ptr->max_cache_size - cache_ptr->index_size; - } - space_needed = (size_t)(((double)space_needed) * cache_ptr->resize_ctl.flash_multiple); - new_max_cache_size = cache_ptr->max_cache_size + space_needed; - break; - - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; - } - - if (new_max_cache_size > cache_ptr->resize_ctl.max_size) - new_max_cache_size = cache_ptr->resize_ctl.max_size; - assert(new_max_cache_size > cache_ptr->max_cache_size); - - new_min_clean_size = (size_t)((double)new_max_cache_size * cache_ptr->resize_ctl.min_clean_fraction); - assert(new_min_clean_size <= new_max_cache_size); - - old_max_cache_size = cache_ptr->max_cache_size; - old_min_clean_size = cache_ptr->min_clean_size; - - cache_ptr->max_cache_size = new_max_cache_size; - cache_ptr->min_clean_size = new_min_clean_size; - - /* update flash cache size increase fields as appropriate */ - assert(cache_ptr->flash_size_increase_possible); - - switch (cache_ptr->resize_ctl.flash_incr_mode) { - case H5C_flash_incr__off: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, - "flash_size_increase_possible but H5C_flash_incr__off?!") - break; - - case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_threshold = - (size_t)((double)cache_ptr->max_cache_size * cache_ptr->resize_ctl.flash_threshold); - break; - - default: /* should be unreachable */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") - break; - } - - /* note that we don't cycle the epoch markers. We can - * argue either way as to whether we should, but for now - * we don't. - */ - - if (cache_ptr->resize_ctl.rpt_fcn != NULL) { - /* get the hit rate for the reporting function. Should still - * be good as we haven't reset the hit rate statistics. - */ - if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") - - (cache_ptr->resize_ctl.rpt_fcn)(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, status, - old_max_cache_size, new_max_cache_size, old_min_clean_size, - new_min_clean_size); - } - - if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) - /* this should be impossible... */ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flash_increase_cache_size() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__flush_invalidate_cache - * - * Purpose: Flush and destroy the entries contained in the target - * cache. - * - * If the cache contains protected entries, the function will - * fail, as protected entries cannot be either flushed or - * destroyed. However all unprotected entries should be - * flushed and destroyed before the function returns failure. - * - * While pinned entries can usually be flushed, they cannot - * be destroyed. However, they should be unpinned when all - * the entries that reference them have been destroyed (thus - * reduding the pinned entry's reference count to 0, allowing - * it to be unpinned). - * - * If pinned entries are present, the function makes repeated - * passes through the cache, flushing all dirty entries - * (including the pinned dirty entries where permitted) and - * destroying all unpinned entries. This process is repeated - * until either the cache is empty, or the number of pinned - * entries stops decreasing on each pass. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 3/24/05 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) -{ - H5C_t *cache_ptr; - H5C_ring_t ring; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_PACKAGE - - assert(f); - assert(f->shared); - cache_ptr = f->shared->cache; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->slist_ptr); - assert(cache_ptr->slist_enabled); - -#ifdef H5C_DO_SANITY_CHECKS - { - int32_t i; - uint32_t index_len = 0; - uint32_t slist_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - - assert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); - assert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - assert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - assert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - assert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); - assert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - - for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { - index_len += cache_ptr->index_ring_len[i]; - index_size += cache_ptr->index_ring_size[i]; - clean_index_size += cache_ptr->clean_index_ring_size[i]; - dirty_index_size += cache_ptr->dirty_index_ring_size[i]; - - slist_len += cache_ptr->slist_ring_len[i]; - slist_size += cache_ptr->slist_ring_size[i]; - } /* end for */ - - assert(cache_ptr->index_len == index_len); - assert(cache_ptr->index_size == index_size); - assert(cache_ptr->clean_index_size == clean_index_size); - assert(cache_ptr->dirty_index_size == dirty_index_size); - assert(cache_ptr->slist_len == slist_len); - assert(cache_ptr->slist_size == slist_size); - } -#endif /* H5C_DO_SANITY_CHECKS */ - - /* remove ageout markers if present */ - if (cache_ptr->epoch_markers_active > 0) - if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") - - /* flush invalidate each ring, starting from the outermost ring and - * working inward. - */ - ring = H5C_RING_USER; - while (ring < H5C_RING_NTYPES) { - if (H5C__flush_invalidate_ring(f, ring, flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush invalidate ring failed") - ring++; - } /* end while */ - -#ifndef NDEBUG - /* Invariants, after destroying all entries in the hash table */ - if (!(flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG)) { - assert(cache_ptr->index_size == 0); - assert(cache_ptr->clean_index_size == 0); - assert(cache_ptr->pel_len == 0); - assert(cache_ptr->pel_size == 0); - } /* end if */ - else { - H5C_cache_entry_t *entry_ptr; /* Cache entry */ - unsigned u; /* Local index variable */ - - /* All rings except ring 4 should be empty now */ - /* (Ring 4 has the superblock) */ - for (u = H5C_RING_USER; u < H5C_RING_SB; u++) { - assert(cache_ptr->index_ring_len[u] == 0); - assert(cache_ptr->index_ring_size[u] == 0); - assert(cache_ptr->clean_index_ring_size[u] == 0); - } /* end for */ - - /* Check that any remaining pinned entries are in the superblock ring */ - entry_ptr = cache_ptr->pel_head_ptr; - while (entry_ptr) { - /* Check ring */ - assert(entry_ptr->ring == H5C_RING_SB); - - /* Advance to next entry in pinned entry list */ - entry_ptr = entry_ptr->next; - } /* end while */ - } /* end else */ - - assert(cache_ptr->dirty_index_size == 0); - assert(cache_ptr->slist_len == 0); - assert(cache_ptr->slist_size == 0); - assert(cache_ptr->pl_len == 0); - assert(cache_ptr->pl_size == 0); - assert(cache_ptr->LRU_list_len == 0); - assert(cache_ptr->LRU_list_size == 0); -#endif /* NDEBUG */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_invalidate_cache() */ - -/*------------------------------------------------------------------------- - * Function: H5C__flush_invalidate_ring - * - * Purpose: Flush and destroy the entries contained in the target - * cache and ring. - * - * If the ring contains protected entries, the function will - * fail, as protected entries cannot be either flushed or - * destroyed. However all unprotected entries should be - * flushed and destroyed before the function returns failure. - * - * While pinned entries can usually be flushed, they cannot - * be destroyed. However, they should be unpinned when all - * the entries that reference them have been destroyed (thus - * reduding the pinned entry's reference count to 0, allowing - * it to be unpinned). - * - * If pinned entries are present, the function makes repeated - * passes through the cache, flushing all dirty entries - * (including the pinned dirty entries where permitted) and - * destroying all unpinned entries. This process is repeated - * until either the cache is empty, or the number of pinned - * entries stops decreasing on each pass. - * - * If flush dependencies appear in the target ring, the - * function makes repeated passes through the cache flushing - * entries in flush dependency order. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 9/1/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) -{ - H5C_t *cache_ptr; - hbool_t restart_slist_scan; - uint32_t protected_entries = 0; - int32_t i; - uint32_t cur_ring_pel_len; - uint32_t old_ring_pel_len; - unsigned cooked_flags; - unsigned evict_flags; - H5SL_node_t *node_ptr = NULL; - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *next_entry_ptr = NULL; -#ifdef H5C_DO_SANITY_CHECKS - uint32_t initial_slist_len = 0; - size_t initial_slist_size = 0; -#endif /* H5C_DO_SANITY_CHECKS */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_PACKAGE - - assert(f); - assert(f->shared); - - cache_ptr = f->shared->cache; - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->slist_enabled); - assert(cache_ptr->slist_ptr); - assert(ring > H5C_RING_UNDEFINED); - assert(ring < H5C_RING_NTYPES); - - assert(cache_ptr->epoch_markers_active == 0); - - /* Filter out the flags that are not relevant to the flush/invalidate. - */ - cooked_flags = flags & H5C__FLUSH_CLEAR_ONLY_FLAG; - evict_flags = flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG; - - /* The flush procedure here is a bit strange. - * - * In the outer while loop we make at least one pass through the - * cache, and then repeat until either all the pinned entries in - * the ring unpin themselves, or until the number of pinned entries - * in the ring stops declining. In this later case, we scream and die. - * - * Since the fractal heap can dirty, resize, and/or move entries - * in is flush callback, it is possible that the cache will still - * contain dirty entries at this point. If so, we must make more - * passes through the skip list to allow it to empty. - * - * Further, since clean entries can be dirtied, resized, and/or moved - * as the result of a flush call back (either the entries own, or that - * for some other cache entry), we can no longer promise to flush - * the cache entries in increasing address order. - * - * Instead, we make a pass through - * the skip list, and then a pass through the "clean" entries, and - * then repeating as needed. Thus it is quite possible that an - * entry will be evicted from the cache only to be re-loaded later - * in the flush process. - * - * The bottom line is that entries will probably be flushed in close - * to increasing address order, but there are no guarantees. - */ - - /* compute the number of pinned entries in this ring */ - entry_ptr = cache_ptr->pel_head_ptr; - cur_ring_pel_len = 0; - while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->ring >= ring); - if (entry_ptr->ring == ring) - cur_ring_pel_len++; - - entry_ptr = entry_ptr->next; - } /* end while */ - old_ring_pel_len = cur_ring_pel_len; - - while (cache_ptr->index_ring_len[ring] > 0) { - /* first, try to flush-destroy any dirty entries. Do this by - * making a scan through the slist. Note that new dirty entries - * may be created by the flush call backs. Thus it is possible - * that the slist will not be empty after we finish the scan. - */ - -#ifdef H5C_DO_SANITY_CHECKS - /* Depending on circumstances, H5C__flush_single_entry() will - * remove dirty entries from the slist as it flushes them. - * Thus for sanity checks we must make note of the initial - * slist length and size before we do any flushes. - */ - initial_slist_len = cache_ptr->slist_len; - initial_slist_size = cache_ptr->slist_size; - - /* There is also the possibility that entries will be - * dirtied, resized, moved, and/or removed from the cache - * as the result of calls to the flush callbacks. We use - * the slist_len_increase and slist_size_increase increase - * fields in struct H5C_t to track these changes for purpose - * of sanity checking. - * - * To this end, we must zero these fields before we start - * the pass through the slist. - */ - cache_ptr->slist_len_increase = 0; - cache_ptr->slist_size_increase = 0; -#endif /* H5C_DO_SANITY_CHECKS */ - - /* Set the cache_ptr->slist_changed to false. - * - * This flag is set to TRUE by H5C__flush_single_entry if the slist - * is modified by a pre_serialize, serialize, or notify callback. - * - * H5C__flush_invalidate_ring() uses this flag to detect any - * modifications to the slist that might corrupt the scan of - * the slist -- and restart the scan in this event. - */ - cache_ptr->slist_changed = FALSE; - - /* this done, start the scan of the slist */ - restart_slist_scan = TRUE; - while (restart_slist_scan || (node_ptr != NULL)) { - if (restart_slist_scan) { - restart_slist_scan = FALSE; - - /* Start at beginning of skip list */ - node_ptr = H5SL_first(cache_ptr->slist_ptr); - if (node_ptr == NULL) - /* the slist is empty -- break out of inner loop */ - break; - - /* Get cache entry for this node */ - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - - assert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(next_entry_ptr->is_dirty); - assert(next_entry_ptr->in_slist); - assert(next_entry_ptr->ring >= ring); - } /* end if */ - - entry_ptr = next_entry_ptr; - - /* It is possible that entries will be dirtied, resized, - * flushed, or removed from the cache via the take ownership - * flag as the result of pre_serialize or serialized callbacks. - * - * This in turn can corrupt the scan through the slist. - * - * We test for slist modifications in the pre_serialize - * and serialize callbacks, and restart the scan of the - * slist if we find them. However, best we do some extra - * sanity checking just in case. - */ - assert(entry_ptr != NULL); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->in_slist); - assert(entry_ptr->is_dirty); - assert(entry_ptr->ring >= ring); - - /* increment node pointer now, before we delete its target - * from the slist. - */ - node_ptr = H5SL_next(node_ptr); - if (node_ptr != NULL) { - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - - assert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(next_entry_ptr->is_dirty); - assert(next_entry_ptr->in_slist); - assert(next_entry_ptr->ring >= ring); - assert(entry_ptr != next_entry_ptr); - } /* end if */ - else - next_entry_ptr = NULL; - - /* Note that we now remove nodes from the slist as we flush - * the associated entries, instead of leaving them there - * until we are done, and then destroying all nodes in - * the slist. - * - * While this optimization used to be easy, with the possibility - * of new entries being added to the slist in the midst of the - * flush, we must keep the slist in canonical form at all - * times. - */ - if (((!entry_ptr->flush_me_last) || - ((entry_ptr->flush_me_last) && (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && - (entry_ptr->flush_dep_nchildren == 0) && (entry_ptr->ring == ring)) { - if (entry_ptr->is_protected) { - /* We have major problems -- but lets flush - * everything we can before we flag an error. - */ - protected_entries++; - } /* end if */ - else if (entry_ptr->is_pinned) { - if (H5C__flush_single_entry(f, entry_ptr, H5C__DURING_FLUSH_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty pinned entry flush failed") - - if (cache_ptr->slist_changed) { - /* The slist has been modified by something - * other than the simple removal of the - * of the flushed entry after the flush. - * - * This has the potential to corrupt the - * scan through the slist, so restart it. - */ - restart_slist_scan = TRUE; - cache_ptr->slist_changed = FALSE; - H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr); - } /* end if */ - } /* end else-if */ - else { - if (H5C__flush_single_entry(f, entry_ptr, - (cooked_flags | H5C__DURING_FLUSH_FLAG | - H5C__FLUSH_INVALIDATE_FLAG | - H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty entry flush destroy failed") - - if (cache_ptr->slist_changed) { - /* The slist has been modified by something - * other than the simple removal of the - * of the flushed entry after the flush. - * - * This has the potential to corrupt the - * scan through the slist, so restart it. - */ - restart_slist_scan = TRUE; - cache_ptr->slist_changed = FALSE; - H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) - } /* end if */ - } /* end else */ - } /* end if */ - } /* end while loop scanning skip list */ - -#ifdef H5C_DO_SANITY_CHECKS - /* It is possible that entries were added to the slist during - * the scan, either before or after scan pointer. The following - * asserts take this into account. - * - * Don't bother with the sanity checks if node_ptr != NULL, as - * in this case we broke out of the loop because it got changed - * out from under us. - */ - - if (node_ptr == NULL) { - assert(cache_ptr->slist_len == - (uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase)); - assert(cache_ptr->slist_size == - (size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase)); - } /* end if */ -#endif /* H5C_DO_SANITY_CHECKS */ - - /* Since we are doing a destroy, we must make a pass through - * the hash table and try to flush - destroy all entries that - * remain. - * - * It used to be that all entries remaining in the cache at - * this point had to be clean, but with the fractal heap mods - * this may not be the case. If so, we will flush entries out - * in increasing address order. - * - * Writes to disk are possible here. - */ - - /* Reset the counters so that we can detect insertions, loads, - * and moves caused by the pre_serialize and serialize calls. - */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; - - next_entry_ptr = cache_ptr->il_head; - while (next_entry_ptr != NULL) { - entry_ptr = next_entry_ptr; - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->ring >= ring); - - next_entry_ptr = entry_ptr->il_next; - assert((next_entry_ptr == NULL) || (next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC)); - - if (((!entry_ptr->flush_me_last) || - (entry_ptr->flush_me_last && (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && - (entry_ptr->flush_dep_nchildren == 0) && (entry_ptr->ring == ring)) { - - if (entry_ptr->is_protected) { - /* we have major problems -- but lets flush and - * destroy everything we can before we flag an - * error. - */ - protected_entries++; - - if (!entry_ptr->in_slist) - assert(!(entry_ptr->is_dirty)); - } /* end if */ - else if (!entry_ptr->is_pinned) { - /* if *entry_ptr is dirty, it is possible - * that one or more other entries may be - * either removed from the cache, loaded - * into the cache, or moved to a new location - * in the file as a side effect of the flush. - * - * It's also possible that removing a clean - * entry will remove the last child of a proxy - * entry, allowing it to be removed also and - * invalidating the next_entry_ptr. - * - * If either of these happen, and one of the target - * or proxy entries happens to be the next entry in - * the hash bucket, we could either find ourselves - * either scanning a non-existent entry, scanning - * through a different bucket, or skipping an entry. - * - * Neither of these are good, so restart the - * the scan at the head of the hash bucket - * after the flush if we detect that the next_entry_ptr - * becomes invalid. - * - * This is not as inefficient at it might seem, - * as hash buckets typically have at most two - * or three entries. - */ - cache_ptr->entry_watched_for_removal = next_entry_ptr; - if (H5C__flush_single_entry(f, entry_ptr, - (cooked_flags | H5C__DURING_FLUSH_FLAG | - H5C__FLUSH_INVALIDATE_FLAG | - H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Entry flush destroy failed") - - /* Restart the index list scan if necessary. Must - * do this if the next entry is evicted, and also if - * one or more entries are inserted, loaded, or moved - * as these operations can result in part of the scan - * being skipped -- which can cause a spurious failure - * if this results in the size of the pinned entry - * failing to decline during the pass. - */ - if (((NULL != next_entry_ptr) && (NULL == cache_ptr->entry_watched_for_removal)) || - (cache_ptr->entries_loaded_counter > 0) || - (cache_ptr->entries_inserted_counter > 0) || - (cache_ptr->entries_relocated_counter > 0)) { - - next_entry_ptr = cache_ptr->il_head; - - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; - - H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) - } /* end if */ - else - cache_ptr->entry_watched_for_removal = NULL; - } /* end if */ - } /* end if */ - } /* end for loop scanning hash table */ - - /* We can't do anything if entries are pinned. The - * hope is that the entries will be unpinned as the - * result of destroys of entries that reference them. - * - * We detect this by noting the change in the number - * of pinned entries from pass to pass. If it stops - * shrinking before it hits zero, we scream and die. - */ - old_ring_pel_len = cur_ring_pel_len; - entry_ptr = cache_ptr->pel_head_ptr; - cur_ring_pel_len = 0; - - while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->ring >= ring); - - if (entry_ptr->ring == ring) - cur_ring_pel_len++; - - entry_ptr = entry_ptr->next; - } /* end while */ - - /* Check if the number of pinned entries in the ring is positive, and - * it is not declining. Scream and die if so. - */ - if ((cur_ring_pel_len > 0) && (cur_ring_pel_len >= old_ring_pel_len)) { - /* Don't error if allowed to have pinned entries remaining */ - if (evict_flags) - HGOTO_DONE(TRUE) - - HGOTO_ERROR( - H5E_CACHE, H5E_CANTFLUSH, FAIL, - "Pinned entry count not decreasing, cur_ring_pel_len = %d, old_ring_pel_len = %d, ring = %d", - (int)cur_ring_pel_len, (int)old_ring_pel_len, (int)ring) - } /* end if */ - - assert(protected_entries == cache_ptr->pl_len); - - if ((protected_entries > 0) && (protected_entries == cache_ptr->index_len)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, - "Only protected entries left in cache, protected_entries = %d", - (int)protected_entries) - } /* main while loop */ - - /* Invariants, after destroying all entries in the ring */ - for (i = (int)H5C_RING_UNDEFINED; i <= (int)ring; i++) { - assert(cache_ptr->index_ring_len[i] == 0); - assert(cache_ptr->index_ring_size[i] == (size_t)0); - assert(cache_ptr->clean_index_ring_size[i] == (size_t)0); - assert(cache_ptr->dirty_index_ring_size[i] == (size_t)0); - - assert(cache_ptr->slist_ring_len[i] == 0); - assert(cache_ptr->slist_ring_size[i] == (size_t)0); - } /* end for */ - - assert(protected_entries <= cache_ptr->pl_len); - - if (protected_entries > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cache has protected entries") - else if (cur_ring_pel_len > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't unpin all pinned entries in ring") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_invalidate_ring() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__flush_ring - * - * Purpose: Flush the entries contained in the specified cache and - * ring. All entries in rings outside the specified ring - * must have been flushed on entry. - * - * If the cache contains protected entries in the specified - * ring, the function will fail, as protected entries cannot - * be flushed. However all unprotected entries in the target - * ring should be flushed before the function returns failure. - * - * If flush dependencies appear in the target ring, the - * function makes repeated passes through the slist flushing - * entries in flush dependency order. - * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. - * - * Programmer: John Mainzer - * 9/1/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) -{ - H5C_t *cache_ptr = f->shared->cache; - hbool_t flushed_entries_last_pass; - hbool_t flush_marked_entries; - hbool_t ignore_protected; - hbool_t tried_to_flush_protected_entry = FALSE; - hbool_t restart_slist_scan; - uint32_t protected_entries = 0; - H5SL_node_t *node_ptr = NULL; - H5C_cache_entry_t *entry_ptr = NULL; - H5C_cache_entry_t *next_entry_ptr = NULL; -#ifdef H5C_DO_SANITY_CHECKS - uint32_t initial_slist_len = 0; - size_t initial_slist_size = 0; -#endif /* H5C_DO_SANITY_CHECKS */ - int i; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->slist_enabled); - assert(cache_ptr->slist_ptr); - assert((flags & H5C__FLUSH_INVALIDATE_FLAG) == 0); - assert(ring > H5C_RING_UNDEFINED); - assert(ring < H5C_RING_NTYPES); - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - - ignore_protected = ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0); - flush_marked_entries = ((flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0); - - if (!flush_marked_entries) - for (i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) - assert(cache_ptr->slist_ring_len[i] == 0); - - assert(cache_ptr->flush_in_progress); - - /* When we are only flushing marked entries, the slist will usually - * still contain entries when we have flushed everything we should. - * Thus we track whether we have flushed any entries in the last - * pass, and terminate if we haven't. - */ - flushed_entries_last_pass = TRUE; - - /* Set the cache_ptr->slist_changed to false. - * - * This flag is set to TRUE by H5C__flush_single_entry if the - * slist is modified by a pre_serialize, serialize, or notify callback. - * H5C_flush_cache uses this flag to detect any modifications - * to the slist that might corrupt the scan of the slist -- and - * restart the scan in this event. - */ - cache_ptr->slist_changed = FALSE; - - while ((cache_ptr->slist_ring_len[ring] > 0) && (protected_entries == 0) && (flushed_entries_last_pass)) { - flushed_entries_last_pass = FALSE; - -#ifdef H5C_DO_SANITY_CHECKS - /* For sanity checking, try to verify that the skip list has - * the expected size and number of entries at the end of each - * internal while loop (see below). - * - * Doing this get a bit tricky, as depending on flags, we may - * or may not flush all the entries in the slist. - * - * To make things more entertaining, with the advent of the - * fractal heap, the entry serialize callback can cause entries - * to be dirtied, resized, and/or moved. Also, the - * pre_serialize callback can result in an entry being - * removed from the cache via the take ownership flag. - * - * To deal with this, we first make note of the initial - * skip list length and size: - */ - initial_slist_len = cache_ptr->slist_len; - initial_slist_size = cache_ptr->slist_size; - - /* As mentioned above, there is the possibility that - * entries will be dirtied, resized, flushed, or removed - * from the cache via the take ownership flag during - * our pass through the skip list. To capture the number - * of entries added, and the skip list size delta, - * zero the slist_len_increase and slist_size_increase of - * the cache's instance of H5C_t. These fields will be - * updated elsewhere to account for slist insertions and/or - * dirty entry size changes. - */ - cache_ptr->slist_len_increase = 0; - cache_ptr->slist_size_increase = 0; - - /* at the end of the loop, use these values to compute the - * expected slist length and size and compare this with the - * value recorded in the cache's instance of H5C_t. - */ -#endif /* H5C_DO_SANITY_CHECKS */ - - restart_slist_scan = TRUE; - while ((restart_slist_scan) || (node_ptr != NULL)) { - if (restart_slist_scan) { - restart_slist_scan = FALSE; - - /* Start at beginning of skip list */ - node_ptr = H5SL_first(cache_ptr->slist_ptr); - if (node_ptr == NULL) - /* the slist is empty -- break out of inner loop */ - break; - - /* Get cache entry for this node */ - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - - assert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(next_entry_ptr->is_dirty); - assert(next_entry_ptr->in_slist); - } /* end if */ - - entry_ptr = next_entry_ptr; - - /* With the advent of the fractal heap, the free space - * manager, and the version 3 cache, it is possible - * that the pre-serialize or serialize callback will - * dirty, resize, or take ownership of other entries - * in the cache. - * - * To deal with this, there is code to detect any - * change in the skip list not directly under the control - * of this function. If such modifications are detected, - * we must re-start the scan of the skip list to avoid - * the possibility that the target of the next_entry_ptr - * may have been flushed or deleted from the cache. - * - * To verify that all such possibilities have been dealt - * with, we do a bit of extra sanity checking on - * entry_ptr. - */ - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->in_slist); - assert(entry_ptr->is_dirty); - - if (!flush_marked_entries || entry_ptr->flush_marker) - assert(entry_ptr->ring >= ring); - - /* Advance node pointer now, before we delete its target - * from the slist. - */ - node_ptr = H5SL_next(node_ptr); - if (node_ptr != NULL) { - next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if (NULL == next_entry_ptr) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") - - assert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(next_entry_ptr->is_dirty); - assert(next_entry_ptr->in_slist); - - if (!flush_marked_entries || next_entry_ptr->flush_marker) - assert(next_entry_ptr->ring >= ring); - - assert(entry_ptr != next_entry_ptr); - } /* end if */ - else - next_entry_ptr = NULL; - - if ((!flush_marked_entries || entry_ptr->flush_marker) && - ((!entry_ptr->flush_me_last) || - ((entry_ptr->flush_me_last) && ((cache_ptr->num_last_entries >= cache_ptr->slist_len) || - (flush_marked_entries && entry_ptr->flush_marker)))) && - ((entry_ptr->flush_dep_nchildren == 0) || (entry_ptr->flush_dep_ndirty_children == 0)) && - (entry_ptr->ring == ring)) { - - assert(entry_ptr->flush_dep_nunser_children == 0); - - if (entry_ptr->is_protected) { - /* we probably have major problems -- but lets - * flush everything we can before we decide - * whether to flag an error. - */ - tried_to_flush_protected_entry = TRUE; - protected_entries++; - } /* end if */ - else { - if (H5C__flush_single_entry(f, entry_ptr, (flags | H5C__DURING_FLUSH_FLAG)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry") - - if (cache_ptr->slist_changed) { - /* The slist has been modified by something - * other than the simple removal of the - * of the flushed entry after the flush. - * - * This has the potential to corrupt the - * scan through the slist, so restart it. - */ - restart_slist_scan = TRUE; - cache_ptr->slist_changed = FALSE; - H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) - } /* end if */ - - flushed_entries_last_pass = TRUE; - } /* end else */ - } /* end if */ - } /* while ( ( restart_slist_scan ) || ( node_ptr != NULL ) ) */ - -#ifdef H5C_DO_SANITY_CHECKS - /* Verify that the slist size and length are as expected. */ - assert((uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase) == - cache_ptr->slist_len); - assert((size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase) == - cache_ptr->slist_size); -#endif /* H5C_DO_SANITY_CHECKS */ - } /* while */ - - assert(protected_entries <= cache_ptr->pl_len); - - if (((cache_ptr->pl_len > 0) && !ignore_protected) || tried_to_flush_protected_entry) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "cache has protected items") - -#ifdef H5C_DO_SANITY_CHECKS - if (!flush_marked_entries) { - assert(cache_ptr->slist_ring_len[ring] == 0); - assert(cache_ptr->slist_ring_size[ring] == 0); - } /* end if */ -#endif /* H5C_DO_SANITY_CHECKS */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_ring() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__flush_single_entry - * - * Purpose: Flush or clear (and evict if requested) the cache entry - * with the specified address and type. If the type is NULL, - * any unprotected entry at the specified address will be - * flushed (and possibly evicted). - * - * Attempts to flush a protected entry will result in an - * error. - * - * If the H5C__FLUSH_INVALIDATE_FLAG flag is set, the entry will - * be cleared and not flushed, and the call can't be part of a - * sequence of flushes. - * - * The function does nothing silently if there is no entry - * at the supplied address, or if the entry found has the - * wrong type. - * - * Return: Non-negative on success/Negative on failure or if there was - * an attempt to flush a protected item. - * - * Programmer: John Mainzer, 5/5/04 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) -{ - H5C_t *cache_ptr; /* Cache for file */ - hbool_t destroy; /* external flag */ - hbool_t clear_only; /* external flag */ - hbool_t free_file_space; /* external flag */ - hbool_t take_ownership; /* external flag */ - hbool_t del_from_slist_on_destroy; /* external flag */ - hbool_t during_flush; /* external flag */ - hbool_t write_entry; /* internal flag */ - hbool_t destroy_entry; /* internal flag */ - hbool_t generate_image; /* internal flag */ - hbool_t update_page_buffer; /* internal flag */ - hbool_t was_dirty; - hbool_t suppress_image_entry_writes = FALSE; - hbool_t suppress_image_entry_frees = FALSE; - haddr_t entry_addr = HADDR_UNDEF; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(f); - cache_ptr = f->shared->cache; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(entry_ptr); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->ring != H5C_RING_UNDEFINED); - assert(entry_ptr->type); - - /* setup external flags from the flags parameter */ - destroy = ((flags & H5C__FLUSH_INVALIDATE_FLAG) != 0); - clear_only = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); - free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); - take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); - del_from_slist_on_destroy = ((flags & H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) != 0); - during_flush = ((flags & H5C__DURING_FLUSH_FLAG) != 0); - generate_image = ((flags & H5C__GENERATE_IMAGE_FLAG) != 0); - update_page_buffer = ((flags & H5C__UPDATE_PAGE_BUFFER_FLAG) != 0); - - /* Set the flag for destroying the entry, based on the 'take ownership' - * and 'destroy' flags - */ - if (take_ownership) - destroy_entry = FALSE; - else - destroy_entry = destroy; - - /* we will write the entry to disk if it exists, is dirty, and if the - * clear only flag is not set. - */ - if (entry_ptr->is_dirty && !clear_only) - write_entry = TRUE; - else - write_entry = FALSE; - - /* if we have received close warning, and we have been instructed to - * generate a metadata cache image, and we have actually constructed - * the entry images, set suppress_image_entry_frees to TRUE. - * - * Set suppress_image_entry_writes to TRUE if indicated by the - * image_ctl flags. - */ - if (cache_ptr->close_warning_received && cache_ptr->image_ctl.generate_image && - cache_ptr->num_entries_in_image > 0 && cache_ptr->image_entries != NULL) { - - /* Sanity checks */ - assert(entry_ptr->image_up_to_date || !(entry_ptr->include_in_image)); - assert(entry_ptr->image_ptr || !(entry_ptr->include_in_image)); - assert((!clear_only) || !(entry_ptr->include_in_image)); - assert((!take_ownership) || !(entry_ptr->include_in_image)); - assert((!free_file_space) || !(entry_ptr->include_in_image)); - - suppress_image_entry_frees = TRUE; - - if (cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES) - suppress_image_entry_writes = TRUE; - } /* end if */ - - /* run initial sanity checks */ -#ifdef H5C_DO_SANITY_CHECKS - if (cache_ptr->slist_enabled) { - if (entry_ptr->in_slist) { - assert(entry_ptr->is_dirty); - if (entry_ptr->flush_marker && !entry_ptr->is_dirty) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry in slist failed sanity checks") - } /* end if */ - else { - assert(!entry_ptr->is_dirty); - assert(!entry_ptr->flush_marker); - if (entry_ptr->is_dirty || entry_ptr->flush_marker) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry failed sanity checks") - } /* end else */ - } - else { /* slist is disabled */ - assert(!entry_ptr->in_slist); - if (!entry_ptr->is_dirty) - if (entry_ptr->flush_marker) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flush marked clean entry?") - } -#endif /* H5C_DO_SANITY_CHECKS */ - - if (entry_ptr->is_protected) - /* Attempt to flush a protected entry -- scream and die. */ - HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "Attempt to flush a protected entry") - - /* Set entry_ptr->flush_in_progress = TRUE and set - * entry_ptr->flush_marker = FALSE - * - * We will set flush_in_progress back to FALSE at the end if the - * entry still exists at that point. - */ - entry_ptr->flush_in_progress = TRUE; - entry_ptr->flush_marker = FALSE; - - /* Preserve current dirty state for later */ - was_dirty = entry_ptr->is_dirty; - - /* The entry is dirty, and we are doing a flush, a flush destroy or have - * been requested to generate an image. In those cases, serialize the - * entry. - */ - if (write_entry || generate_image) { - assert(entry_ptr->is_dirty); - if (NULL == entry_ptr->image_ptr) { - if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, - "memory allocation failed for on disk image buffer") - -#if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - - } /* end if */ - - if (!entry_ptr->image_up_to_date) { - /* Sanity check */ - assert(!entry_ptr->prefetched); - - /* Generate the entry's image */ - if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't generate entry's image") - } /* end if ( ! (entry_ptr->image_up_to_date) ) */ - } /* end if */ - - /* Finally, write the image to disk. - * - * Note that if the H5AC__CLASS_SKIP_WRITES flag is set in the - * in the entry's type, we silently skip the write. This - * flag should only be used in test code. - */ - if (write_entry) { - assert(entry_ptr->is_dirty); - -#ifdef H5C_DO_SANITY_CHECKS - if (cache_ptr->check_write_permitted && !cache_ptr->write_permitted) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Write when writes are always forbidden!?!?!") -#endif /* H5C_DO_SANITY_CHECKS */ - - /* Write the image to disk unless the write is suppressed. - * - * This happens if both suppress_image_entry_writes and - * entry_ptr->include_in_image are TRUE, or if the - * H5AC__CLASS_SKIP_WRITES is set in the entry's type. This - * flag should only be used in test code - */ - if ((!suppress_image_entry_writes || !entry_ptr->include_in_image) && - ((entry_ptr->type->flags & H5C__CLASS_SKIP_WRITES) == 0)) { - H5FD_mem_t mem_type = H5FD_MEM_DEFAULT; - -#ifdef H5_HAVE_PARALLEL - if (cache_ptr->coll_write_list) { - if (H5SL_insert(cache_ptr->coll_write_list, entry_ptr, &entry_ptr->addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item") - } /* end if */ - else { -#endif /* H5_HAVE_PARALLEL */ - if (entry_ptr->prefetched) { - assert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - mem_type = cache_ptr->class_table_ptr[entry_ptr->prefetch_type_id]->mem_type; - } /* end if */ - else - mem_type = entry_ptr->type->mem_type; - - if (H5F_block_write(f, mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't write image to file") -#ifdef H5_HAVE_PARALLEL - } -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ - - /* if the entry has a notify callback, notify it that we have - * just flushed the entry. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_FLUSH, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client of entry flush") - } /* if ( write_entry ) */ - - /* At this point, all pre-serialize and serialize calls have been - * made if it was appropriate to make them. Similarly, the entry - * has been written to disk if desired. - * - * Thus it is now safe to update the cache data structures for the - * flush. - */ - - /* start by updating the statistics */ - if (clear_only) { - /* only log a clear if the entry was dirty */ - if (was_dirty) - H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) - } - else if (write_entry) { - assert(was_dirty); - - /* only log a flush if we actually wrote to disk */ - H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) - } /* end else if */ - - /* Note that the algorithm below is (very) similar to the set of operations - * in H5C_remove_entry() and should be kept in sync with changes - * to that code. - QAK, 2016/11/30 - */ - - /* Update the cache internal data structures. */ - if (destroy) { - /* Sanity checks */ - if (take_ownership) - assert(!destroy_entry); - else - assert(destroy_entry); - - assert(!entry_ptr->is_pinned); - - /* Update stats, while entry is still in the cache */ - H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) - - /* If the entry's type has a 'notify' callback and the entry is about - * to be removed from the cache, send a 'before eviction' notice while - * the entry is still fully integrated in the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") - - /* Update the cache internal data structures as appropriate - * for a destroy. Specifically: - * - * 1) Delete it from the index - * - * 2) Delete it from the skip list if requested. - * - * 3) Delete it from the collective read access list. - * - * 4) Update the replacement policy for eviction - * - * 5) Remove it from the tag list for this object - * - * Finally, if the destroy_entry flag is set, discard the - * entry. - */ - H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) - - if (entry_ptr->in_slist && del_from_slist_on_destroy) - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) - -#ifdef H5_HAVE_PARALLEL - /* Check for collective read access flag */ - if (entry_ptr->coll_access) { - entry_ptr->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - - H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, FAIL) - - /* Remove entry from tag list */ - if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") - - /* verify that the entry is no longer part of any flush dependencies */ - assert(entry_ptr->flush_dep_nparents == 0); - assert(entry_ptr->flush_dep_nchildren == 0); - } /* end if */ - else { - assert(clear_only || write_entry); - assert(entry_ptr->is_dirty); - assert((!cache_ptr->slist_enabled) || (entry_ptr->in_slist)); - - /* We are either doing a flush or a clear. - * - * A clear and a flush are the same from the point of - * view of the replacement policy and the slist. - * Hence no differentiation between them. - */ - H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, FAIL) - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) - - /* mark the entry as clean and update the index for - * entry clean. Also, call the clear callback - * if defined. - */ - entry_ptr->is_dirty = FALSE; - - H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr, FAIL); - - /* Check for entry changing status and do notifications, etc. */ - if (was_dirty) { - /* If the entry's type has a 'notify' callback send a - * 'entry cleaned' notice now that the entry is fully - * integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify client about entry dirty flag cleared") - - /* Propagate the clean flag up the flush dependency chain - * if appropriate - */ - if (entry_ptr->flush_dep_ndirty_children != 0) - assert(entry_ptr->flush_dep_ndirty_children == 0); - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_clean(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean flag") - } /* end if */ - } /* end else */ - - /* reset the flush_in progress flag */ - entry_ptr->flush_in_progress = FALSE; - - /* capture the cache entry address for the log_flush call at the - * end before the entry_ptr gets freed - */ - entry_addr = entry_ptr->addr; - - /* Internal cache data structures should now be up to date, and - * consistent with the status of the entry. - * - * Now discard the entry if appropriate. - */ - if (destroy) { - /* Sanity check */ - assert(0 == entry_ptr->flush_dep_nparents); - - /* if both suppress_image_entry_frees and entry_ptr->include_in_image - * are true, simply set entry_ptr->image_ptr to NULL, as we have - * another pointer to the buffer in an instance of H5C_image_entry_t - * in cache_ptr->image_entries. - * - * Otherwise, free the buffer if it exists. - */ - if (suppress_image_entry_frees && entry_ptr->include_in_image) - entry_ptr->image_ptr = NULL; - else if (entry_ptr->image_ptr != NULL) - entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); - - /* If the entry is not a prefetched entry, verify that the flush - * dependency parents addresses array has been transferred. - * - * If the entry is prefetched, the free_isr routine will dispose of - * the flush dependency parents addresses array if necessary. - */ - if (!entry_ptr->prefetched) { - assert(0 == entry_ptr->fd_parent_count); - assert(NULL == entry_ptr->fd_parent_addrs); - } /* end if */ - - /* Check whether we should free the space in the file that - * the entry occupies - */ - if (free_file_space) { - hsize_t fsf_size; - - /* Sanity checks */ - assert(H5_addr_defined(entry_ptr->addr)); - assert(!H5F_IS_TMP_ADDR(f, entry_ptr->addr)); -#ifndef NDEBUG - { - size_t curr_len; - - /* Get the actual image size for the thing again */ - entry_ptr->type->image_len((void *)entry_ptr, &curr_len); - assert(curr_len == entry_ptr->size); - } -#endif /* NDEBUG */ - - /* If the file space free size callback is defined, use - * it to get the size of the block of file space to free. - * Otherwise use entry_ptr->size. - */ - if (entry_ptr->type->fsf_size) { - if ((entry_ptr->type->fsf_size)((void *)entry_ptr, &fsf_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to get file space free size") - } /* end if */ - else /* no file space free size callback -- use entry size */ - fsf_size = entry_ptr->size; - - /* Release the space on disk */ - if (H5MF_xfree(f, entry_ptr->type->mem_type, entry_ptr->addr, fsf_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to free file space for cache entry") - } /* end if ( free_file_space ) */ - - /* Reset the pointer to the cache the entry is within. -QAK */ - entry_ptr->cache_ptr = NULL; - - /* increment entries_removed_counter and set - * last_entry_removed_ptr. As we are likely abuut to - * free the entry, recall that last_entry_removed_ptr - * must NEVER be dereferenced. - * - * Recall that these fields are maintained to allow functions - * that perform scans of lists of entries to detect the - * unexpected removal of entries (via expunge, eviction, - * or take ownership at present), so that they can re-start - * their scans if necessary. - * - * Also check if the entry we are watching for removal is being - * removed (usually the 'next' entry for an iteration) and reset - * it to indicate that it was removed. - */ - cache_ptr->entries_removed_counter++; - cache_ptr->last_entry_removed_ptr = entry_ptr; - - if (entry_ptr == cache_ptr->entry_watched_for_removal) - cache_ptr->entry_watched_for_removal = NULL; - - /* Check for actually destroying the entry in memory */ - /* (As opposed to taking ownership of it) */ - if (destroy_entry) { - if (entry_ptr->is_dirty) { - /* Reset dirty flag */ - entry_ptr->is_dirty = FALSE; - - /* If the entry's type has a 'notify' callback send a - * 'entry cleaned' notice now that the entry is fully - * integrated into the cache. - */ - if (entry_ptr->type->notify && - (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify client about entry dirty flag cleared") - } /* end if */ - - /* we are about to discard the in core representation -- - * set the magic field to bad magic so we can detect a - * freed entry if we see one. - */ - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; - - /* verify that the image has been freed */ - assert(entry_ptr->image_ptr == NULL); - - if (entry_ptr->type->free_icr((void *)entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") - } /* end if */ - else { - assert(take_ownership); - - /* Client is taking ownership of the entry. Set bad magic here too - * so the cache will choke unless the entry is re-inserted properly - */ - entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; - } /* end else */ - } /* if (destroy) */ - - /* Check if we have to update the page buffer with cleared entries - * so it doesn't go out of date - */ - if (update_page_buffer) { - /* Sanity check */ - assert(!destroy); - assert(entry_ptr->image_ptr); - - if (f->shared->page_buf && (f->shared->page_buf->page_size >= entry_ptr->size)) - if (H5PB_update_entry(f->shared->page_buf, entry_ptr->addr, entry_ptr->size, - entry_ptr->image_ptr) > 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Failed to update PB with metadata cache") - } /* end if */ - - if (cache_ptr->log_flush) - if ((cache_ptr->log_flush)(cache_ptr, entry_addr, was_dirty, flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "log_flush callback failed") - -done: - assert((ret_value != SUCCEED) || (destroy_entry) || (!entry_ptr->flush_in_progress)); - assert((ret_value != SUCCEED) || (destroy_entry) || (take_ownership) || (!entry_ptr->is_dirty)); - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_single_entry() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__verify_len_eoa - * - * Purpose: Verify that 'len' does not exceed eoa when 'actual' is - * false i.e. 'len" is the initial speculative length from - * get_load_size callback with null image pointer. - * If exceed, adjust 'len' accordingly. - * - * Verify that 'len' should not exceed eoa when 'actual' is - * true i.e. 'len' is the actual length from get_load_size - * callback with non-null image pointer. - * If exceed, return error. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Vailin Choi - * 9/6/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, size_t *len, hbool_t actual) -{ - H5FD_mem_t cooked_type; /* Modified type, accounting for switching global heaps */ - haddr_t eoa; /* End-of-allocation in the file */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* if type == H5FD_MEM_GHEAP, H5F_block_read() forces - * type to H5FD_MEM_DRAW via its call to H5F__accum_read(). - * Thus we do the same for purposes of computing the EOA - * for sanity checks. - */ - cooked_type = (type->mem_type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type->mem_type; - - /* Get the file's end-of-allocation value */ - eoa = H5F_get_eoa(f, cooked_type); - if (!H5_addr_defined(eoa)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid EOA address for file") - - /* Check for bad address in general */ - if (H5_addr_gt(addr, eoa)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "address of object past end of allocation") - - /* Check if the amount of data to read will be past the EOA */ - if (H5_addr_gt((addr + *len), eoa)) { - if (actual) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "actual len exceeds EOA") - else - /* Trim down the length of the metadata */ - *len = (size_t)(eoa - addr); - } /* end if */ - - if (*len <= 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "len not positive after adjustment for EOA") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__verify_len_eoa() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__load_entry - * - * Purpose: Attempt to load the entry at the specified disk address - * and with the specified type into memory. If successful. - * return the in memory address of the entry. Return NULL - * on failure. - * - * Note that this function simply loads the entry into - * core. It does not insert it into the cache. - * - * Return: Non-NULL on success / NULL on failure. - * - * Programmer: John Mainzer, 5/18/04 - * - *------------------------------------------------------------------------- - */ -static void * -H5C__load_entry(H5F_t *f, -#ifdef H5_HAVE_PARALLEL - hbool_t coll_access, -#endif /* H5_HAVE_PARALLEL */ - const H5C_class_t *type, haddr_t addr, void *udata) -{ - hbool_t dirty = FALSE; /* Flag indicating whether thing was dirtied during deserialize */ - uint8_t *image = NULL; /* Buffer for disk image */ - void *thing = NULL; /* Pointer to thing loaded */ - H5C_cache_entry_t *entry = NULL; /* Alias for thing loaded, as cache entry */ - size_t len; /* Size of image in file */ -#ifdef H5_HAVE_PARALLEL - int mpi_rank = 0; /* MPI process rank */ - MPI_Comm comm = MPI_COMM_NULL; /* File MPI Communicator */ - int mpi_code; /* MPI error code */ -#endif /* H5_HAVE_PARALLEL */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(f); - assert(f->shared); - assert(f->shared->cache); - assert(type); - assert(H5_addr_defined(addr)); - assert(type->get_initial_load_size); - if (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) - assert(type->get_final_load_size); - else - assert(NULL == type->get_final_load_size); - assert(type->deserialize); - - /* Can't see how skip reads could be usefully combined with - * the speculative read flag. Hence disallow. - */ - assert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); - - /* Call the get_initial_load_size callback, to retrieve the initial size of image */ - if (type->get_initial_load_size(udata, &len) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image size") - assert(len > 0); - - /* 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) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid len with respect to EOA") - - /* Allocate the buffer for reading the on-disk entry image */ - if (NULL == (image = (uint8_t *)H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") -#if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - -#ifdef H5_HAVE_PARALLEL - if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") - if ((comm = H5F_mpi_get_comm(f)) == MPI_COMM_NULL) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - - /* Get the on-disk entry image */ - if (0 == (type->flags & H5C__CLASS_SKIP_READS)) { - unsigned tries, max_tries; /* The # of read attempts */ - unsigned retries; /* The # of retries */ - htri_t chk_ret; /* return from verify_chksum callback */ - size_t actual_len = len; /* The actual length, after speculative reads have been resolved */ - uint64_t nanosec = 1; /* # of nanoseconds to sleep between retries */ - void *new_image; /* Pointer to image */ - hbool_t len_changed = TRUE; /* Whether to re-check speculative entries */ - - /* Get the # of read attempts */ - max_tries = tries = H5F_GET_READ_ATTEMPTS(f); - - /* - * This do/while loop performs the following till the metadata checksum - * is correct or the file's number of allowed read attempts are reached. - * --read the metadata - * --determine the actual size of the metadata - * --perform checksum verification - */ - do { - 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()") - image = (uint8_t *)new_image; -#if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - } /* end if */ - -#ifdef H5_HAVE_PARALLEL - if (!coll_access || 0 == mpi_rank) { -#endif /* H5_HAVE_PARALLEL */ - if (H5F_block_read(f, type->mem_type, addr, len, image) < 0) { -#ifdef H5_HAVE_PARALLEL - if (coll_access) { - /* Push an error, but still participate in following MPI_Bcast */ - memset(image, 0, len); - HDONE_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") - } - else -#endif - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") - } - -#ifdef H5_HAVE_PARALLEL - } /* end if */ - /* if the collective metadata read optimization is turned on, - * bcast the metadata read from process 0 to all ranks in the file - * communicator - */ - if (coll_access) { - int buf_size; - - H5_CHECKED_ASSIGN(buf_size, int, len, size_t); - if (MPI_SUCCESS != (mpi_code = MPI_Bcast(image, buf_size, MPI_BYTE, 0, comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - - /* If the entry could be read speculatively and the length is still - * changing, check for updating the actual size - */ - if ((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && len_changed) { - /* Retrieve the actual length */ - actual_len = len; - if (type->get_final_load_size(image, len, udata, &actual_len) < 0) - continue; /* Transfer control to while() and count towards retries */ - - /* Check for the length changing */ - if (actual_len != len) { - /* Verify that the length isn't past the EOA for the file */ - if (H5C__verify_len_eoa(f, type, addr, &actual_len, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "actual_len exceeds EOA") - - /* Expand buffer to new size */ - if (NULL == (new_image = H5MM_realloc(image, actual_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") - image = (uint8_t *)new_image; -#if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(image + actual_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - - if (actual_len > len) { -#ifdef H5_HAVE_PARALLEL - if (!coll_access || 0 == mpi_rank) { -#endif /* H5_HAVE_PARALLEL */ - /* 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) { -#ifdef H5_HAVE_PARALLEL - if (coll_access) { - /* Push an error, but still participate in following MPI_Bcast */ - memset(image + len, 0, actual_len - len); - HDONE_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") - } - else -#endif - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") - } - -#ifdef H5_HAVE_PARALLEL - } - /* If the collective metadata read optimization is turned on, - * Bcast the metadata read from process 0 to all ranks in the file - * communicator */ - if (coll_access) { - int buf_size; - - H5_CHECKED_ASSIGN(buf_size, int, actual_len - len, size_t); - if (MPI_SUCCESS != - (mpi_code = MPI_Bcast(image + len, buf_size, MPI_BYTE, 0, comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - } /* end if */ - } /* end if (actual_len != len) */ - else { - /* The length has stabilized */ - len_changed = FALSE; - - /* Set the final length */ - len = actual_len; - } /* else */ - } /* end if */ - - /* If there's no way to verify the checksum for a piece of metadata - * (usually because there's no checksum in the file), leave now - */ - if (type->verify_chksum == NULL) - break; - - /* Verify the checksum for the metadata image */ - if ((chk_ret = type->verify_chksum(image, actual_len, udata)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "failure from verify_chksum callback") - if (chk_ret == TRUE) - break; - - /* Sleep for some time */ - H5_nanosleep(nanosec); - nanosec *= 2; /* Double the sleep time next time */ - } while (--tries); - - /* Check for too many tries */ - if (tries == 0) - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "incorrect metadata checksum after all read attempts") - - /* Calculate and track the # of retries */ - retries = max_tries - tries; - if (retries) /* Does not track 0 retry */ - if (H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, retries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "cannot track read tries = %u ", retries) - - /* Set the final length (in case it wasn't set earlier) */ - len = actual_len; - } /* end if !H5C__CLASS_SKIP_READS */ - - /* Deserialize the on-disk image into the native memory form */ - if (NULL == (thing = type->deserialize(image, len, udata, &dirty))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't deserialize image") - - entry = (H5C_cache_entry_t *)thing; - - /* In general, an entry should be clean just after it is loaded. - * - * However, when this code is used in the metadata cache, it is - * possible that object headers will be dirty at this point, as - * the deserialize function will alter object headers if necessary to - * fix an old bug. - * - * In the following assert: - * - * assert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); - * - * note that type ids 5 & 6 are associated with object headers in the - * metadata cache. - * - * When we get to using H5C for other purposes, we may wish to - * tighten up the assert so that the loophole only applies to the - * metadata cache. - */ - - assert((dirty == FALSE) || (type->id == 5 || type->id == 6)); - - entry->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - entry->cache_ptr = f->shared->cache; - entry->addr = addr; - entry->size = len; - assert(entry->size < H5C_MAX_ENTRY_SIZE); - entry->image_ptr = image; - entry->image_up_to_date = !dirty; - entry->type = type; - entry->is_dirty = dirty; - entry->dirtied = FALSE; - entry->is_protected = FALSE; - entry->is_read_only = FALSE; - entry->ro_ref_count = 0; - entry->is_pinned = FALSE; - entry->in_slist = FALSE; - entry->flush_marker = FALSE; -#ifdef H5_HAVE_PARALLEL - entry->clear_on_unprotect = FALSE; - entry->flush_immediately = FALSE; - entry->coll_access = coll_access; -#endif /* H5_HAVE_PARALLEL */ - entry->flush_in_progress = FALSE; - entry->destroy_in_progress = FALSE; - - entry->ring = H5C_RING_UNDEFINED; - - /* Initialize flush dependency fields */ - entry->flush_dep_parent = NULL; - entry->flush_dep_nparents = 0; - entry->flush_dep_parent_nalloc = 0; - entry->flush_dep_nchildren = 0; - entry->flush_dep_ndirty_children = 0; - entry->flush_dep_nunser_children = 0; - entry->ht_next = NULL; - entry->ht_prev = NULL; - entry->il_next = NULL; - entry->il_prev = NULL; - - entry->next = NULL; - entry->prev = NULL; - -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - entry->aux_next = NULL; - entry->aux_prev = NULL; -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#ifdef H5_HAVE_PARALLEL - entry->coll_next = NULL; - entry->coll_prev = NULL; -#endif /* H5_HAVE_PARALLEL */ - - /* initialize cache image related fields */ - entry->include_in_image = FALSE; - entry->lru_rank = 0; - entry->image_dirty = FALSE; - entry->fd_parent_count = 0; - entry->fd_parent_addrs = NULL; - entry->fd_child_count = 0; - entry->fd_dirty_child_count = 0; - entry->image_fd_height = 0; - entry->prefetched = FALSE; - entry->prefetch_type_id = 0; - entry->age = 0; - entry->prefetched_dirty = FALSE; -#ifndef NDEBUG /* debugging field */ - entry->serialization_count = 0; -#endif /* NDEBUG */ - - /* initialize tag list fields */ - entry->tl_next = NULL; - entry->tl_prev = NULL; - entry->tag_info = NULL; - - H5C__RESET_CACHE_ENTRY_STATS(entry); - - ret_value = thing; - -done: - /* Cleanup on error */ - if (NULL == ret_value) { - /* Release resources */ - if (thing && type->free_icr(thing) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed") - if (image) - image = (uint8_t *)H5MM_xfree(image); - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__load_entry() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__make_space_in_cache - * - * Purpose: Attempt to evict cache entries until the index_size - * is at least needed_space below max_cache_size. - * - * In passing, also attempt to bring cLRU_list_size to a - * value greater than min_clean_size. - * - * Depending on circumstances, both of these goals may - * be impossible, as in parallel mode, we must avoid generating - * a write as part of a read (to avoid deadlock in collective - * I/O), and in all cases, it is possible (though hopefully - * highly unlikely) that the protected list may exceed the - * maximum size of the cache. - * - * Thus the function simply does its best, returning success - * unless an error is encountered. - * - * Observe that this function cannot occasion a read. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 5/14/04 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) -{ - H5C_t *cache_ptr = f->shared->cache; -#if H5C_COLLECT_CACHE_STATS - int32_t clean_entries_skipped = 0; - int32_t dirty_pf_entries_skipped = 0; - int32_t total_entries_scanned = 0; -#endif /* H5C_COLLECT_CACHE_STATS */ - uint32_t entries_examined = 0; - uint32_t initial_list_len; - size_t empty_space; - hbool_t reentrant_call = FALSE; - hbool_t prev_is_dirty = FALSE; - hbool_t didnt_flush_entry = FALSE; - hbool_t restart_scan; - H5C_cache_entry_t *entry_ptr; - H5C_cache_entry_t *prev_ptr; - H5C_cache_entry_t *next_ptr; - uint32_t num_corked_entries = 0; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(f); - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); - - /* check to see if cache_ptr->msic_in_progress is TRUE. If it, this - * is a re-entrant call via a client callback called in the make - * space in cache process. To avoid an infinite recursion, set - * reentrant_call to TRUE, and goto done. - */ - if (cache_ptr->msic_in_progress) { - reentrant_call = TRUE; - HGOTO_DONE(SUCCEED); - } /* end if */ - - cache_ptr->msic_in_progress = TRUE; - - if (write_permitted) { - restart_scan = FALSE; - initial_list_len = cache_ptr->LRU_list_len; - entry_ptr = cache_ptr->LRU_tail_ptr; - - if (cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; - else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - - while ((((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) || - ((empty_space + cache_ptr->clean_index_size) < (cache_ptr->min_clean_size))) && - (entries_examined <= (2 * initial_list_len)) && (entry_ptr != NULL)) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(!(entry_ptr->is_protected)); - assert(!(entry_ptr->is_read_only)); - assert((entry_ptr->ro_ref_count) == 0); - - next_ptr = entry_ptr->next; - prev_ptr = entry_ptr->prev; - - if (prev_ptr != NULL) - prev_is_dirty = prev_ptr->is_dirty; - - if (entry_ptr->is_dirty && (entry_ptr->tag_info && entry_ptr->tag_info->corked)) { - /* Skip "dirty" corked entries. */ - ++num_corked_entries; - didnt_flush_entry = TRUE; - } - else if ((entry_ptr->type->id != H5AC_EPOCH_MARKER_ID) && !entry_ptr->flush_in_progress && - !entry_ptr->prefetched_dirty) { - didnt_flush_entry = FALSE; - if (entry_ptr->is_dirty) { -#if H5C_COLLECT_CACHE_STATS - if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) - cache_ptr->entries_scanned_to_make_space++; -#endif /* H5C_COLLECT_CACHE_STATS */ - - /* reset entries_removed_counter and - * last_entry_removed_ptr prior to the call to - * H5C__flush_single_entry() so that we can spot - * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry - * that is no longer in the cache. - */ - cache_ptr->entries_removed_counter = 0; - cache_ptr->last_entry_removed_ptr = NULL; - - if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - - if ((cache_ptr->entries_removed_counter > 1) || - (cache_ptr->last_entry_removed_ptr == prev_ptr)) - - restart_scan = TRUE; - } - else if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size -#ifdef H5_HAVE_PARALLEL - && !(entry_ptr->coll_access) -#endif /* H5_HAVE_PARALLEL */ - ) { -#if H5C_COLLECT_CACHE_STATS - cache_ptr->entries_scanned_to_make_space++; -#endif /* H5C_COLLECT_CACHE_STATS */ - - if (H5C__flush_single_entry(f, entry_ptr, - H5C__FLUSH_INVALIDATE_FLAG | - H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } - else { - /* We have enough space so don't flush clean entry. */ -#if H5C_COLLECT_CACHE_STATS - clean_entries_skipped++; -#endif /* H5C_COLLECT_CACHE_STATS */ - didnt_flush_entry = TRUE; - } - -#if H5C_COLLECT_CACHE_STATS - total_entries_scanned++; -#endif /* H5C_COLLECT_CACHE_STATS */ - } - else { - - /* Skip epoch markers, entries that are in the process - * of being flushed, and entries marked as prefetched_dirty - * (occurs in the R/O case only). - */ - didnt_flush_entry = TRUE; - -#if H5C_COLLECT_CACHE_STATS - if (entry_ptr->prefetched_dirty) - dirty_pf_entries_skipped++; -#endif /* H5C_COLLECT_CACHE_STATS */ - } - - if (prev_ptr != NULL) { - if (didnt_flush_entry) - /* epoch markers don't get flushed, and we don't touch - * entries that are in the process of being flushed. - * Hence no need for sanity checks, as we haven't - * flushed anything. Thus just set entry_ptr to prev_ptr - * and go on. - */ - entry_ptr = prev_ptr; - else if (restart_scan || prev_ptr->is_dirty != prev_is_dirty || prev_ptr->next != next_ptr || - prev_ptr->is_protected || prev_ptr->is_pinned) { - /* something has happened to the LRU -- start over - * from the tail. - */ - restart_scan = FALSE; - entry_ptr = cache_ptr->LRU_tail_ptr; - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) - } - else - entry_ptr = prev_ptr; - } - else - entry_ptr = NULL; - - entries_examined++; - - if (cache_ptr->index_size >= cache_ptr->max_cache_size) - empty_space = 0; - else - empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - - assert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); - } - -#if H5C_COLLECT_CACHE_STATS - cache_ptr->calls_to_msic++; - - cache_ptr->total_entries_skipped_in_msic += clean_entries_skipped; - cache_ptr->total_dirty_pf_entries_skipped_in_msic += dirty_pf_entries_skipped; - cache_ptr->total_entries_scanned_in_msic += total_entries_scanned; - - if (clean_entries_skipped > cache_ptr->max_entries_skipped_in_msic) - cache_ptr->max_entries_skipped_in_msic = clean_entries_skipped; - - if (dirty_pf_entries_skipped > cache_ptr->max_dirty_pf_entries_skipped_in_msic) - cache_ptr->max_dirty_pf_entries_skipped_in_msic = dirty_pf_entries_skipped; - - if (total_entries_scanned > cache_ptr->max_entries_scanned_in_msic) - cache_ptr->max_entries_scanned_in_msic = total_entries_scanned; -#endif /* H5C_COLLECT_CACHE_STATS */ - - /* NEED: work on a better assert for corked entries */ - assert((entries_examined > (2 * initial_list_len)) || - ((cache_ptr->pl_size + cache_ptr->pel_size + cache_ptr->min_clean_size) > - cache_ptr->max_cache_size) || - ((cache_ptr->clean_index_size + empty_space) >= cache_ptr->min_clean_size) || - ((num_corked_entries))); -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - - assert((entries_examined > (2 * initial_list_len)) || - (cache_ptr->cLRU_list_size <= cache_ptr->clean_index_size)); - assert((entries_examined > (2 * initial_list_len)) || - (cache_ptr->dLRU_list_size <= cache_ptr->dirty_index_size)); - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - } - else { - assert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); - -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - initial_list_len = cache_ptr->cLRU_list_len; - entry_ptr = cache_ptr->cLRU_tail_ptr; - - while (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && - (entries_examined <= initial_list_len) && (entry_ptr != NULL)) { - assert(!(entry_ptr->is_protected)); - assert(!(entry_ptr->is_read_only)); - assert((entry_ptr->ro_ref_count) == 0); - assert(!(entry_ptr->is_dirty)); - - prev_ptr = entry_ptr->aux_prev; - - if (!entry_ptr->prefetched_dirty -#ifdef H5_HAVE_PARALLEL - && !entry_ptr->coll_access -#endif /* H5_HAVE_PARALLEL */ - ) { - if (H5C__flush_single_entry( - f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } /* end if */ - - /* we are scanning the clean LRU, so the serialize function - * will not be called on any entry -- thus there is no - * concern about the list being modified out from under - * this function. - */ - - entry_ptr = prev_ptr; - entries_examined++; - } -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - } - -done: - /* Sanity checks */ - assert(cache_ptr->msic_in_progress); - if (!reentrant_call) - cache_ptr->msic_in_progress = FALSE; - assert((!reentrant_call) || (cache_ptr->msic_in_progress)); - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__make_space_in_cache() */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__validate_lru_list - * - * Purpose: Debugging function that scans the LRU list for errors. - * - * If an error is detected, the function generates a - * diagnostic and returns FAIL. If no error is detected, - * the function returns SUCCEED. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: John Mainzer, 7/14/05 - * - *------------------------------------------------------------------------- - */ -#ifdef H5C_DO_EXTREME_SANITY_CHECKS -herr_t -H5C__validate_lru_list(H5C_t *cache_ptr) -{ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - if (((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_tail_ptr == NULL)) && - (cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list head/tail check failed") - - if ((cache_ptr->LRU_list_len == 1) && - ((cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr) || (cache_ptr->LRU_head_ptr == NULL) || - (cache_ptr->LRU_head_ptr->size != cache_ptr->LRU_list_size))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list sanity check failed") - - if ((cache_ptr->LRU_list_len >= 1) && - ((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_head_ptr->prev != NULL) || - (cache_ptr->LRU_tail_ptr == NULL) || (cache_ptr->LRU_tail_ptr->next != NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list sanity check failed") - - entry_ptr = cache_ptr->LRU_head_ptr; - while (entry_ptr != NULL) { - if ((entry_ptr != cache_ptr->LRU_head_ptr) && - ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") - - if ((entry_ptr != cache_ptr->LRU_tail_ptr) && - ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") - - if (entry_ptr->is_pinned || entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "invalid entry 'pin origin' fields") - - len++; - size += entry_ptr->size; - entry_ptr = entry_ptr->next; - } - - if ((cache_ptr->LRU_list_len != (uint32_t)len) || (cache_ptr->LRU_list_size != size)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list length/size check failed") - -done: - if (ret_value != SUCCEED) - assert(0); - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__validate_lru_list() */ -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__validate_pinned_entry_list - * - * Purpose: Debugging function that scans the pinned entry list for - * errors. - * - * If an error is detected, the function generates a - * diagnostic and returns FAIL. If no error is detected, - * the function returns SUCCEED. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: John Mainzer, 4/25/14 - * - *------------------------------------------------------------------------- - */ -#ifdef H5C_DO_EXTREME_SANITY_CHECKS -herr_t -H5C__validate_pinned_entry_list(H5C_t *cache_ptr) -{ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - if (((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_tail_ptr == NULL)) && - (cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list head/tail check failed") - - if ((cache_ptr->pel_len == 1) && - ((cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr) || (cache_ptr->pel_head_ptr == NULL) || - (cache_ptr->pel_head_ptr->size != cache_ptr->pel_size))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list sanity check failed") - - if ((cache_ptr->pel_len >= 1) && - ((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_head_ptr->prev != NULL) || - (cache_ptr->pel_tail_ptr == NULL) || (cache_ptr->pel_tail_ptr->next != NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list sanity check failed") - - entry_ptr = cache_ptr->pel_head_ptr; - while (entry_ptr != NULL) { - if ((entry_ptr != cache_ptr->pel_head_ptr) && - ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") - - if ((entry_ptr != cache_ptr->pel_tail_ptr) && - ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") - - if (!entry_ptr->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list contains unpinned entry") - - if (!(entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "invalid entry 'pin origin' fields") - - len++; - size += entry_ptr->size; - entry_ptr = entry_ptr->next; - } - - if ((cache_ptr->pel_len != (uint32_t)len) || (cache_ptr->pel_size != size)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list length/size check failed") - -done: - if (ret_value != SUCCEED) - assert(0); - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__validate_pinned_entry_list() */ -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__validate_protected_entry_list - * - * Purpose: Debugging function that scans the protected entry list for - * errors. - * - * If an error is detected, the function generates a - * diagnostic and returns FAIL. If no error is detected, - * the function returns SUCCEED. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: John Mainzer, 4/25/14 - * - *------------------------------------------------------------------------- - */ -#ifdef H5C_DO_EXTREME_SANITY_CHECKS -herr_t -H5C__validate_protected_entry_list(H5C_t *cache_ptr) -{ - int32_t len = 0; - size_t size = 0; - H5C_cache_entry_t *entry_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - if (((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) && - (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list head/tail check failed") - - if ((cache_ptr->pl_len == 1) && - ((cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr) || (cache_ptr->pl_head_ptr == NULL) || - (cache_ptr->pl_head_ptr->size != cache_ptr->pl_size))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list sanity check failed") - - if ((cache_ptr->pl_len >= 1) && - ((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_head_ptr->prev != NULL) || - (cache_ptr->pl_tail_ptr == NULL) || (cache_ptr->pl_tail_ptr->next != NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list sanity check failed") - - entry_ptr = cache_ptr->pl_head_ptr; - while (entry_ptr != NULL) { - if ((entry_ptr != cache_ptr->pl_head_ptr) && - ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") - - if ((entry_ptr != cache_ptr->pl_tail_ptr) && - ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") - - if (!entry_ptr->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list contains unprotected entry") - - if (entry_ptr->is_read_only && (entry_ptr->ro_ref_count <= 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "read-only entry has non-positive ref count") - - len++; - size += entry_ptr->size; - entry_ptr = entry_ptr->next; - } - - if ((cache_ptr->pl_len != (uint32_t)len) || (cache_ptr->pl_size != size)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list length/size check failed") - -done: - if (ret_value != SUCCEED) - assert(0); - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__validate_protected_entry_list() */ -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__entry_in_skip_list - * - * Purpose: Debugging function that scans skip list to see if it - * is in present. We need this, as it is possible for - * an entry to be in the skip list twice. - * - * Return: FALSE if the entry is not in the skip list, and TRUE - * if it is. - * - * Programmer: John Mainzer, 11/1/14 - * - *------------------------------------------------------------------------- - */ -#ifdef H5C_DO_SLIST_SANITY_CHECKS -hbool_t -H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) -{ - H5SL_node_t *node_ptr; - hbool_t in_slist; - hbool_t ret_value; - - FUNC_ENTER_PACKAGE - - /* Assertions */ - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->slist_ptr); - - node_ptr = H5SL_first(cache_ptr->slist_ptr); - in_slist = FALSE; - while ((node_ptr != NULL) && (!in_slist)) { - H5C_cache_entry_t *entry_ptr; - - entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - - assert(entry_ptr); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->is_dirty); - assert(entry_ptr->in_slist); - - if (entry_ptr == target_ptr) - in_slist = TRUE; - else - node_ptr = H5SL_next(node_ptr); - } - - /* Set return value */ - ret_value = in_slist; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__entry_in_skip_list() */ -#endif /* H5C_DO_SLIST_SANITY_CHECKS */ - -/*------------------------------------------------------------------------- - * - * Function: H5C__flush_marked_entries - * - * Purpose: Flushes all marked entries in the cache. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Mike McGreevy - * November 3, 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__flush_marked_entries(H5F_t *f) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_PACKAGE - - /* Assertions */ - assert(f != NULL); - - /* Enable the slist, as it is needed in the flush */ - if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed") - - /* Flush all marked entries */ - if (H5C_flush_cache(f, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") - - /* Disable the slist. Set the clear_slist parameter to TRUE - * since we called H5C_flush_cache() with the - * H5C__FLUSH_MARKED_ENTRIES_FLAG. - */ - if (H5C_set_slist_enabled(f->shared->cache, FALSE, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_marked_entries */ - -/*------------------------------------------------------------------------- - * - * Function: H5C_cork - * - * Purpose: To cork/uncork/get cork status of an object depending on "action": - * H5C__SET_CORK: - * To cork the object - * Return error if the object is already corked - * H5C__UNCORK: - * To uncork the object - * Return error if the object is not corked - * H5C__GET_CORKED: - * To retrieve the cork status of an object in - * the parameter "corked" - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) -{ - H5C_tag_info_t *tag_info = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Assertions */ - assert(cache_ptr != NULL); - assert(H5_addr_defined(obj_addr)); - assert(action == H5C__SET_CORK || action == H5C__UNCORK || action == H5C__GET_CORKED); - - /* Search the list of corked object addresses in the cache */ - HASH_FIND(hh, cache_ptr->tag_list, &obj_addr, sizeof(haddr_t), tag_info); - - if (H5C__GET_CORKED == action) { - assert(corked); - if (tag_info != NULL && tag_info->corked) - *corked = TRUE; - else - *corked = FALSE; - } - else { - /* Sanity check */ - assert(H5C__SET_CORK == action || H5C__UNCORK == action); - - /* Perform appropriate action */ - if (H5C__SET_CORK == action) { - /* Check if this is the first entry for this tagged object */ - if (NULL == tag_info) { - /* Allocate new tag info struct */ - if (NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate tag info for cache entry") - - /* Set the tag for all entries */ - tag_info->tag = obj_addr; - - /* Insert tag info into hash table */ - HASH_ADD(hh, cache_ptr->tag_list, tag, sizeof(haddr_t), tag_info); - } - else { - /* Check for object already corked */ - if (tag_info->corked) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCORK, FAIL, "object already corked") - assert(tag_info->entry_cnt > 0 && tag_info->head); - } - - /* Set the corked status for the entire object */ - tag_info->corked = TRUE; - cache_ptr->num_objs_corked++; - } - else { - /* Sanity check */ - if (NULL == tag_info) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "tag info pointer is NULL") - - /* Check for already uncorked */ - if (!tag_info->corked) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "object already uncorked") - - /* Set the corked status for the entire object */ - tag_info->corked = FALSE; - cache_ptr->num_objs_corked--; - - /* Remove the tag info from the tag list, if there's no more entries with this tag */ - if (0 == tag_info->entry_cnt) { - /* Sanity check */ - assert(NULL == tag_info->head); - - HASH_DELETE(hh, cache_ptr->tag_list, tag_info); - - /* Release the tag info */ - tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); - } - else - assert(NULL != tag_info->head); - } - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_cork() */ - -/*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_dirty() - * - * Purpose: Recursively propagate the flush_dep_ndirty_children flag - * up the dependency chain in response to entry either - * becoming dirty or having its flush_dep_ndirty_children - * increased from 0. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 11/13/12 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__mark_flush_dep_dirty(H5C_cache_entry_t *entry) -{ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(entry); - - /* Iterate over the parent entries, if any */ - for (u = 0; u < entry->flush_dep_nparents; u++) { - /* Sanity check */ - assert(entry->flush_dep_parent[u]->flush_dep_ndirty_children < - entry->flush_dep_parent[u]->flush_dep_nchildren); - - /* Adjust the parent's number of dirty children */ - entry->flush_dep_parent[u]->flush_dep_ndirty_children++; - - /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ - if (entry->flush_dep_parent[u]->type->notify && - (entry->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, - entry->flush_dep_parent[u]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry dirty flag set") - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_dirty() */ - -/*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_clean() - * - * Purpose: Recursively propagate the flush_dep_ndirty_children flag - * up the dependency chain in response to entry either - * becoming clean or having its flush_dep_ndirty_children - * reduced to 0. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 11/13/12 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__mark_flush_dep_clean(H5C_cache_entry_t *entry) -{ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(entry); - - /* Iterate over the parent entries, if any */ - /* Note reverse iteration order, in case the callback removes the flush - * dependency - QAK, 2017/08/12 - */ - for (i = ((int)entry->flush_dep_nparents) - 1; i >= 0; i--) { - /* Sanity check */ - assert(entry->flush_dep_parent[i]->flush_dep_ndirty_children > 0); - - /* Adjust the parent's number of dirty children */ - entry->flush_dep_parent[i]->flush_dep_ndirty_children--; - - /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ - if (entry->flush_dep_parent[i]->type->notify && - (entry->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, - entry->flush_dep_parent[i]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry dirty flag reset") - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_clean() */ - -/*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_serialized() - * - * Purpose: Decrement the flush_dep_nunser_children fields of all the - * target entry's flush dependency parents in response to - * the target entry becoming serialized. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 8/30/16 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry_ptr) -{ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(entry_ptr); - - /* Iterate over the parent entries, if any */ - /* Note reverse iteration order, in case the callback removes the flush - * dependency - QAK, 2017/08/12 - */ - for (i = ((int)entry_ptr->flush_dep_nparents) - 1; i >= 0; i--) { - /* Sanity checks */ - assert(entry_ptr->flush_dep_parent); - assert(entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children > 0); - - /* decrement the parents number of unserialized children */ - entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children--; - - /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ - if (entry_ptr->flush_dep_parent[i]->type->notify && - (entry_ptr->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, - entry_ptr->flush_dep_parent[i]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry serialized flag set") - } /* end for */ + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; + } /* end switch */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_serialized() */ +} /* H5C_set_cache_auto_resize_config() */ /*------------------------------------------------------------------------- - * Function: H5C__mark_flush_dep_unserialized() - * - * Purpose: Increment the flush_dep_nunser_children fields of all the - * target entry's flush dependency parents in response to - * the target entry becoming unserialized. + * Function: H5C_set_evictions_enabled() * - * Return: Non-negative on success/Negative on failure + * Purpose: Set cache_ptr->evictions_enabled to the value of the + * evictions enabled parameter. * - * Programmer: John Mainzer - * 8/30/16 + * Return: SUCCEED on success, and FAIL on failure. * *------------------------------------------------------------------------- */ -static herr_t -H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry_ptr) +herr_t +H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) - /* Sanity checks */ - assert(entry_ptr); + if (cache_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") - /* Iterate over the parent entries, if any */ - for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { - /* Sanity check */ - assert(entry_ptr->flush_dep_parent); - assert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children < - entry_ptr->flush_dep_parent[u]->flush_dep_nchildren); - - /* increment parents number of usserialized children */ - entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children++; - - /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ - if (entry_ptr->flush_dep_parent[u]->type->notify && - (entry_ptr->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, - entry_ptr->flush_dep_parent[u]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, - "can't notify parent about child entry serialized flag reset") - } /* end for */ + /* There is no fundamental reason why we should not permit + * evictions to be disabled while automatic resize is enabled. + * However, allowing it would greatly complicate testing + * the feature. Hence the following: + */ + if ((evictions_enabled != TRUE) && ((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || + (cache_ptr->resize_ctl.decr_mode != H5C_decr__off))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't disable evictions when auto resize enabled") + + cache_ptr->evictions_enabled = evictions_enabled; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_flush_dep_unserialized() */ +} /* H5C_set_evictions_enabled() */ -#ifndef NDEBUG /*------------------------------------------------------------------------- - * Function: H5C__assert_flush_dep_nocycle() + * Function: H5C_set_slist_enabled() * - * Purpose: Assert recursively that base_entry is not the same as - * entry, and perform the same assertion on all of entry's - * flush dependency parents. This is used to detect cycles - * created by flush dependencies. + * Purpose: Enable or disable the slist as directed. * - * Return: void + * The slist (skip list) is an address ordered list of + * dirty entries in the metadata cache. However, this + * list is only needed during flush and close, where we + * use it to write entries in more or less increasing + * address order. * - * Programmer: Neil Fortner - * 12/10/12 + * This function sets up and enables further operations + * on the slist, or disable the slist. This in turn + * allows us to avoid the overhead of maintaining the + * slist when it is not needed. * - *------------------------------------------------------------------------- - */ -static void -H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, const H5C_cache_entry_t *base_entry) -{ - unsigned u; /* Local index variable */ - - FUNC_ENTER_PACKAGE_NOERR - - /* Sanity checks */ - assert(entry); - assert(base_entry); - - /* Make sure the entries are not the same */ - assert(base_entry != entry); - - /* Iterate over entry's parents (if any) */ - for (u = 0; u < entry->flush_dep_nparents; u++) - H5C__assert_flush_dep_nocycle(entry->flush_dep_parent[u], base_entry); - - FUNC_LEAVE_NOAPI_VOID -} /* H5C__assert_flush_dep_nocycle() */ -#endif /* NDEBUG */ - -/*------------------------------------------------------------------------- - * Function: H5C__serialize_cache * - * Purpose: Serialize (i.e. construct an on disk image) for all entries - * in the metadata cache including clean entries. + * If the slist_enabled parameter is TRUE, the function * - * Note that flush dependencies and "flush me last" flags - * must be observed in the serialization process. + * 1) Verifies that the slist is empty. * - * Note also that entries may be loaded, flushed, evicted, - * expunged, relocated, resized, or removed from the cache - * during this process, just as these actions may occur during - * a regular flush. + * 2) Scans the index list, and inserts all dirty entries + * into the slist. * - * However, we are given that the cache will contain no protected - * entries on entry to this routine (although entries may be - * briefly protected and then unprotected during the serialize - * process). + * 3) Sets cache_ptr->slist_enabled = TRUE. * - * The objective of this routine is serialize all entries and - * to force all entries into their actual locations on disk. + * Note that the clear_slist parameter is ignored if + * the slist_enabed parameter is TRUE. * - * The initial need for this routine is to settle all entries - * in the cache prior to construction of the metadata cache - * image so that the size of the cache image can be calculated. * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. + * If the slist_enabled_parameter is FALSE, the function + * shuts down the slist. * - * Programmer: John Mainzer - * 7/22/15 + * Normally the slist will be empty at this point, however + * that need not be the case if H5C_flush_cache() has been + * called with the H5C__FLUSH_MARKED_ENTRIES_FLAG. * - *------------------------------------------------------------------------- - */ -herr_t -H5C__serialize_cache(H5F_t *f) -{ -#ifdef H5C_DO_SANITY_CHECKS - int i; - uint32_t index_len = 0; - size_t index_size = (size_t)0; - size_t clean_index_size = (size_t)0; - size_t dirty_index_size = (size_t)0; - size_t slist_size = (size_t)0; - uint32_t slist_len = 0; -#endif /* H5C_DO_SANITY_CHECKS */ - H5C_ring_t ring; - H5C_t *cache_ptr; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(f); - assert(f->shared); - cache_ptr = f->shared->cache; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(cache_ptr->slist_ptr); - -#ifdef H5C_DO_SANITY_CHECKS - assert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); - assert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - assert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - assert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - assert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); - assert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); - - for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { - index_len += cache_ptr->index_ring_len[i]; - index_size += cache_ptr->index_ring_size[i]; - clean_index_size += cache_ptr->clean_index_ring_size[i]; - dirty_index_size += cache_ptr->dirty_index_ring_size[i]; - - slist_len += cache_ptr->slist_ring_len[i]; - slist_size += cache_ptr->slist_ring_size[i]; - } /* end for */ - - assert(cache_ptr->index_len == index_len); - assert(cache_ptr->index_size == index_size); - assert(cache_ptr->clean_index_size == clean_index_size); - assert(cache_ptr->dirty_index_size == dirty_index_size); - assert(cache_ptr->slist_len == slist_len); - assert(cache_ptr->slist_size == slist_size); -#endif /* H5C_DO_SANITY_CHECKS */ - -#ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || - H5C__validate_lru_list(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - -#ifndef NDEBUG - /* if this is a debug build, set the serialization_count field of - * each entry in the cache to zero before we start the serialization. - * This allows us to detect the case in which any entry is serialized - * more than once (a performance issues), and more importantly, the - * case is which any flush dependency parent is serializes more than - * once (a correctness issue). - */ - { - H5C_cache_entry_t *scan_ptr = NULL; - - scan_ptr = cache_ptr->il_head; - while (scan_ptr != NULL) { - assert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - scan_ptr->serialization_count = 0; - scan_ptr = scan_ptr->il_next; - } /* end while */ - } /* end block */ -#endif /* NDEBUG */ - - /* set cache_ptr->serialization_in_progress to TRUE, and back - * to FALSE at the end of the function. Must maintain this flag - * to support H5C_get_serialization_in_progress(), which is in - * turn required to support sanity checking in some cache - * clients. - */ - assert(!cache_ptr->serialization_in_progress); - cache_ptr->serialization_in_progress = TRUE; - - /* Serialize each ring, starting from the outermost ring and - * working inward. - */ - ring = H5C_RING_USER; - while (ring < H5C_RING_NTYPES) { - assert(cache_ptr->close_warning_received); - switch (ring) { - case H5C_RING_USER: - break; - - case H5C_RING_RDFSM: - /* Settle raw data FSM */ - if (!cache_ptr->rdfsm_settled) - if (H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "RD FSM settle failed") - break; - - case H5C_RING_MDFSM: - /* Settle metadata FSM */ - if (!cache_ptr->mdfsm_settled) - if (H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "MD FSM settle failed") - break; - - case H5C_RING_SBE: - case H5C_RING_SB: - break; - - default: - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown ring?!?!") - break; - } /* end switch */ - - if (H5C__serialize_ring(f, ring) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialize ring failed") - - ring++; - } /* end while */ - -#ifndef NDEBUG - /* Verify that no entry has been serialized more than once. - * FD parents with multiple serializations should have been caught - * elsewhere, so no specific check for them here. - */ - { - H5C_cache_entry_t *scan_ptr = NULL; - - scan_ptr = cache_ptr->il_head; - while (scan_ptr != NULL) { - assert(scan_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(scan_ptr->serialization_count <= 1); - - scan_ptr = scan_ptr->il_next; - } /* end while */ - } /* end block */ -#endif /* NDEBUG */ - -done: - cache_ptr->serialization_in_progress = FALSE; - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__serialize_cache() */ - -/*------------------------------------------------------------------------- - * Function: H5C__serialize_ring + * Thus shutdown proceeds as follows: * - * Purpose: Serialize the entries contained in the specified cache and - * ring. All entries in rings outside the specified ring - * must have been serialized on entry. + * 1) Test to see if the slist is empty. If it is, proceed + * to step 3. * - * If the cache contains protected entries in the specified - * ring, the function will fail, as protected entries cannot - * be serialized. However all unprotected entries in the - * target ring should be serialized before the function - * returns failure. + * 2) Test to see if the clear_slist parameter is TRUE. * - * If flush dependencies appear in the target ring, the - * function makes repeated passes through the index list - * serializing entries in flush dependency order. + * If it is, remove all entries from the slist. * - * All entries outside the H5C_RING_SBE are marked for - * inclusion in the cache image. Entries in H5C_RING_SBE - * and below are marked for exclusion from the image. + * If it isn't, throw an error. * - * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. + * 3) set cache_ptr->slist_enabled = FALSE. * - * Programmer: John Mainzer - * 9/11/15 + * Return: SUCCEED on success, and FAIL on failure. * *------------------------------------------------------------------------- */ -static herr_t -H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) +herr_t +H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_slist) { - hbool_t done = FALSE; - H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) - /* Sanity checks */ - assert(f); - assert(f->shared); - cache_ptr = f->shared->cache; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(ring > H5C_RING_UNDEFINED); - assert(ring < H5C_RING_NTYPES); + if (cache_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry") - assert(cache_ptr->serialization_in_progress); + if (slist_enabled) { + if (cache_ptr->slist_enabled) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist already enabled?") + if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty?") - /* The objective here is to serialize all entries in the cache ring - * in flush dependency order. - * - * The basic algorithm is to scan the cache index list looking for - * unserialized entries that are either not in a flush dependency - * relationship, or which have no unserialized children. Any such - * entry is serialized and its flush dependency parents (if any) are - * informed -- allowing them to decrement their userialized child counts. - * - * However, this algorithm is complicated by the ability - * of client serialization callbacks to perform operations on - * on the cache which can result in the insertion, deletion, - * relocation, resize, dirty, flush, eviction, or removal (via the - * take ownership flag) of entries. Changes in the flush dependency - * structure are also possible. - * - * On the other hand, the algorithm is simplified by the fact that - * we are serializing, not flushing. Thus, as long as all entries - * are serialized correctly, it doesn't matter if we have to go back - * and serialize an entry a second time. - * - * These possible actions result in the following modifications to - * the basic algorithm: - * - * 1) In the event of an entry expunge, eviction or removal, we must - * restart the scan as it is possible that the next entry in our - * scan is no longer in the cache. Were we to examine this entry, - * we would be accessing deallocated memory. - * - * 2) A resize, dirty, or insertion of an entry may result in the - * the increment of a flush dependency parent's dirty and/or - * unserialized child count. In the context of serializing the - * the cache, this is a non-issue, as even if we have already - * serialized the parent, it will be marked dirty and its image - * marked out of date if appropriate when the child is serialized. - * - * However, this is a major issue for a flush, as were this to happen - * in a flush, it would violate the invariant that the flush dependency - * feature is intended to enforce. As the metadata cache has no - * control over the behavior of cache clients, it has no way of - * preventing this behaviour. However, it should detect it if at all - * possible. - * - * Do this by maintaining a count of the number of times each entry is - * serialized during a cache serialization. If any flush dependency - * parent is serialized more than once, throw an assertion failure. - * - * 3) An entry relocation will typically change the location of the - * entry in the index list. This shouldn't cause problems as we - * will scan the index list until we make a complete pass without - * finding anything to serialize -- making relocations of either - * the current or next entries irrelevant. - * - * Note that since a relocation may result in our skipping part of - * the index list, we must always do at least one more pass through - * the index list after an entry relocation. - * - * 4) Changes in the flush dependency structure are possible on - * entry insertion, load, expunge, evict, or remove. Destruction - * of a flush dependency has no effect, as it can only relax the - * flush dependencies. Creation of a flush dependency can create - * an unserialized child of a flush dependency parent where all - * flush dependency children were previously serialized. Should - * this child dirty the flush dependency parent when it is serialized, - * the parent will be re-serialized. - * - * Per the discussion of 2) above, this is a non issue for cache - * serialization, and a major problem for cache flush. Using the - * same detection mechanism, throw an assertion failure if this - * condition appears. - * - * Observe that either eviction or removal of entries as a result of - * a serialization is not a problem as long as the flush dependency - * tree does not change beyond the removal of a leaf. - */ - while (!done) { - /* Reset the counters so that we can detect insertions, loads, - * moves, and flush dependency height changes caused by the pre_serialize - * and serialize callbacks. + /* set cache_ptr->slist_enabled to TRUE so that the slist + * maintenance macros will be enabled. */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + cache_ptr->slist_enabled = TRUE; - done = TRUE; /* set to FALSE if any activity in inner loop */ + /* scan the index list and insert all dirty entries in the slist */ entry_ptr = cache_ptr->il_head; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - - /* Verify that either the entry is already serialized, or - * that it is assigned to either the target or an inner - * ring. - */ - assert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); - - /* Skip flush me last entries or inner ring entries */ - if (!entry_ptr->flush_me_last && entry_ptr->ring == ring) { - - /* if we encounter an unserialized entry in the current - * ring that is not marked flush me last, we are not done. - */ - if (!entry_ptr->image_up_to_date) - done = FALSE; - - /* Serialize the entry if its image is not up to date - * and it has no unserialized flush dependency children. - */ - if (!entry_ptr->image_up_to_date && entry_ptr->flush_dep_nunser_children == 0) { - assert(entry_ptr->serialization_count == 0); - - /* Serialize the entry */ - if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") - - assert(entry_ptr->flush_dep_nunser_children == 0); - assert(entry_ptr->serialization_count == 0); - -#ifndef NDEBUG - /* Increment serialization counter (to detect multiple serializations) */ - entry_ptr->serialization_count++; -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ - - /* Check for the cache being perturbed during the entry serialize */ - if ((cache_ptr->entries_loaded_counter > 0) || (cache_ptr->entries_inserted_counter > 0) || - (cache_ptr->entries_relocated_counter > 0)) { + if (entry_ptr->is_dirty) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + entry_ptr = entry_ptr->il_next; + } -#if H5C_COLLECT_CACHE_STATS - H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr); -#endif /* H5C_COLLECT_CACHE_STATS */ + /* we don't maintain a dirty index len, so we can't do a cross + * check against it. Note that there is no point in cross checking + * against the dirty LRU size, as the dirty LRU may not be maintained, + * and in any case, there is no requirement that all dirty entries + * will reside on the dirty LRU. + */ + assert(cache_ptr->dirty_index_size == cache_ptr->slist_size); + } + else { /* take down the skip list */ + if (!cache_ptr->slist_enabled) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist already disabled?") - /* Reset the counters */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; + if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) { + if (clear_slist) { + H5SL_node_t *node_ptr; - /* Restart scan */ - entry_ptr = cache_ptr->il_head; - } /* end if */ + node_ptr = H5SL_first(cache_ptr->slist_ptr); + while (node_ptr != NULL) { + entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE, FAIL); + node_ptr = H5SL_first(cache_ptr->slist_ptr); + } + } else - /* Advance to next entry */ - entry_ptr = entry_ptr->il_next; - } /* while ( entry_ptr != NULL ) */ - } /* while ( ! done ) */ - - /* Reset the counters so that we can detect insertions, loads, - * moves, and flush dependency height changes caused by the pre_serialize - * and serialize callbacks. - */ - cache_ptr->entries_loaded_counter = 0; - cache_ptr->entries_inserted_counter = 0; - cache_ptr->entries_relocated_counter = 0; - - /* At this point, all entries not marked "flush me last" and in - * the current ring or outside it should be serialized and have up - * to date images. Scan the index list again to serialize the - * "flush me last" entries (if they are in the current ring) and to - * verify that all other entries have up to date images. - */ - entry_ptr = cache_ptr->il_head; - while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(entry_ptr->ring > H5C_RING_UNDEFINED); - assert(entry_ptr->ring < H5C_RING_NTYPES); - assert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); - - if (entry_ptr->ring == ring) { - if (entry_ptr->flush_me_last) { - if (!entry_ptr->image_up_to_date) { - assert(entry_ptr->serialization_count == 0); - assert(entry_ptr->flush_dep_nunser_children == 0); - - /* Serialize the entry */ - if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") - - /* Check for the cache changing */ - if ((cache_ptr->entries_loaded_counter > 0) || - (cache_ptr->entries_inserted_counter > 0) || - (cache_ptr->entries_relocated_counter > 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, - "flush_me_last entry serialization triggered restart") - - assert(entry_ptr->flush_dep_nunser_children == 0); - assert(entry_ptr->serialization_count == 0); -#ifndef NDEBUG - /* Increment serialization counter (to detect multiple serializations) */ - entry_ptr->serialization_count++; -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ - else { - assert(entry_ptr->image_up_to_date); - assert(entry_ptr->serialization_count <= 1); - assert(entry_ptr->flush_dep_nunser_children == 0); - } /* end else */ - } /* if ( entry_ptr->ring == ring ) */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty?") + } + + cache_ptr->slist_enabled = FALSE; - entry_ptr = entry_ptr->il_next; - } /* while ( entry_ptr != NULL ) */ + assert(0 == cache_ptr->slist_len); + assert(0 == cache_ptr->slist_size); + } done: - assert(cache_ptr->serialization_in_progress); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__serialize_ring() */ +} /* H5C_set_slist_enabled() */ /*------------------------------------------------------------------------- - * Function: H5C__serialize_single_entry + * Function: H5C_unsettle_ring() + * + * Purpose: Advise the metadata cache that the specified free space + * manager ring is no longer settled (if it was on entry). + * + * If the target free space manager ring is already + * unsettled, do nothing, and return SUCCEED. + * + * If the target free space manager ring is settled, and + * we are not in the process of a file shutdown, mark + * the ring as unsettled, and return SUCCEED. * - * Purpose: Serialize the cache entry pointed to by the entry_ptr - * parameter. + * If the target free space manager is settled, and we + * are in the process of a file shutdown, post an error + * message, and return FAIL. * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer, 7/24/15 - * *------------------------------------------------------------------------- */ -static herr_t -H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) +herr_t +H5C_unsettle_ring(H5F_t *f, H5C_ring_t ring) { + H5C_t *cache_ptr; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ assert(f); - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(entry_ptr); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(!entry_ptr->prefetched); - assert(!entry_ptr->image_up_to_date); - assert(entry_ptr->is_dirty); - assert(!entry_ptr->is_protected); - assert(!entry_ptr->flush_in_progress); - assert(entry_ptr->type); - - /* Set entry_ptr->flush_in_progress to TRUE so the target entry - * will not be evicted out from under us. Must set it back to FALSE - * when we are done. - */ - entry_ptr->flush_in_progress = TRUE; - - /* Allocate buffer for the entry image if required. */ - if (NULL == entry_ptr->image_ptr) { - assert(entry_ptr->size > 0); - if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") -#if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - } /* end if */ + assert(f->shared); + assert(f->shared->cache); + assert((H5C_RING_RDFSM == ring) || (H5C_RING_MDFSM == ring)); + cache_ptr = f->shared->cache; + + switch (ring) { + case H5C_RING_RDFSM: + if (cache_ptr->rdfsm_settled) { + if (cache_ptr->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") + cache_ptr->rdfsm_settled = FALSE; + } /* end if */ + break; - /* Generate image for entry */ - if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "Can't generate image for cache entry") + case H5C_RING_MDFSM: + if (cache_ptr->mdfsm_settled) { + if (cache_ptr->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") + cache_ptr->mdfsm_settled = FALSE; + } /* end if */ + break; - /* Reset the flush_in progress flag */ - entry_ptr->flush_in_progress = FALSE; + default: + assert(FALSE); /* this should be un-reachable */ + break; + } /* end switch */ done: - assert((ret_value != SUCCEED) || (!entry_ptr->flush_in_progress)); - assert((ret_value != SUCCEED) || (entry_ptr->image_up_to_date)); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__serialize_single_entry() */ +} /* H5C_unsettle_ring() */ /*------------------------------------------------------------------------- - * Function: H5C__generate_image - * - * Purpose: Serialize an entry and generate its image. + * Function: H5C_validate_resize_config() * - * Note: This may cause the entry to be re-sized and/or moved in - * the cache. + * Purpose: Run a sanity check on the specified sections of the + * provided instance of struct H5C_auto_size_ctl_t. * - * As we will not update the metadata cache's data structures - * until we we finish the write, we must touch up these - * data structures for size and location changes even if we - * are about to delete the entry from the cache (i.e. on a - * flush destroy). + * Do nothing and return SUCCEED if no errors are detected, + * and flag an error and return FAIL otherwise. * * Return: Non-negative on success/Negative on failure * - * Programmer: Mohamad Chaarawi - * 2/10/16 - * *------------------------------------------------------------------------- */ -static herr_t -H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) +herr_t +H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) { - haddr_t new_addr = HADDR_UNDEF; - haddr_t old_addr = HADDR_UNDEF; - size_t new_len = 0; - unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(FAIL) - /* Sanity check */ - assert(f); - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(entry_ptr); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(!entry_ptr->image_up_to_date); - assert(entry_ptr->is_dirty); - assert(!entry_ptr->is_protected); - assert(entry_ptr->type); - - /* make note of the entry's current address */ - old_addr = entry_ptr->addr; - - /* Call client's pre-serialize callback, if there's one */ - if ((entry_ptr->type->pre_serialize) && - ((entry_ptr->type->pre_serialize)(f, (void *)entry_ptr, entry_ptr->addr, entry_ptr->size, &new_addr, - &new_len, &serialize_flags) < 0)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to pre-serialize entry") - - /* Check for any flags set in the pre-serialize callback */ - if (serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) { - /* Check for unexpected flags from serialize callback */ - if (serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG | H5C__SERIALIZE_MOVED_FLAG)) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unknown serialize flag(s)") + if (config_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "NULL config_ptr on entry") -#ifdef H5_HAVE_PARALLEL - /* In the parallel case, resizes and moves in - * the serialize operation can cause problems. - * If they occur, scream and die. - * - * At present, in the parallel case, the aux_ptr - * will only be set if there is more than one - * process. Thus we can use this to detect - * the parallel case. - * - * This works for now, but if we start using the - * aux_ptr for other purposes, we will have to - * change this test accordingly. - * - * NB: While this test detects entryies that attempt - * to resize or move themselves during a flush - * in the parallel case, it will not detect an - * entry that dirties, resizes, and/or moves - * other entries during its flush. - */ - if (cache_ptr->aux_ptr != NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "resize/move in serialize occurred in parallel case") -#endif + if (config_ptr->version != H5C__CURR_AUTO_SIZE_CTL_VER) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown config version") - /* If required, resize the buffer and update the entry and the cache - * data structures - */ - if (serialize_flags & H5C__SERIALIZE_RESIZED_FLAG) { - /* Sanity check */ - assert(new_len > 0); - - /* Allocate a new image buffer */ - if (NULL == - (entry_ptr->image_ptr = H5MM_realloc(entry_ptr->image_ptr, new_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, - "memory allocation failed for on disk image buffer") - -#if H5C_DO_MEMORY_SANITY_CHECKS - H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - - /* Update statistics for resizing the entry */ - H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_len); - - /* Update the hash table for the size change */ - H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len, entry_ptr, - !entry_ptr->is_dirty, FAIL); - - /* The entry can't be protected since we are in the process of - * flushing it. Thus we must update the replacement policy data - * structures for the size change. The macro deals with the pinned - * case. - */ - H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_len, FAIL); + if ((tests & H5C_RESIZE_CFG__VALIDATE_GENERAL) != 0) { + if (config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "max_size too big") + if (config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size too small") + if (config_ptr->min_size > config_ptr->max_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size > max_size") + if (config_ptr->set_initial_size && ((config_ptr->initial_size < config_ptr->min_size) || + (config_ptr->initial_size > config_ptr->max_size))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "initial_size must be in the interval [min_size, max_size]") + if ((config_ptr->min_clean_fraction < 0.0) || (config_ptr->min_clean_fraction > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_clean_fraction must be in the interval [0.0, 1.0]") + if (config_ptr->epoch_length < H5C__MIN_AR_EPOCH_LENGTH) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too small") + if (config_ptr->epoch_length > H5C__MAX_AR_EPOCH_LENGTH) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epoch_length too big") + } /* H5C_RESIZE_CFG__VALIDATE_GENERAL */ + + if ((tests & H5C_RESIZE_CFG__VALIDATE_INCREMENT) != 0) { + if ((config_ptr->incr_mode != H5C_incr__off) && (config_ptr->incr_mode != H5C_incr__threshold)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid incr_mode") + + if (config_ptr->incr_mode == H5C_incr__threshold) { + if ((config_ptr->lower_hr_threshold < 0.0) || (config_ptr->lower_hr_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "lower_hr_threshold must be in the range [0.0, 1.0]") + if (config_ptr->increment < 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "increment must be greater than or equal to 1.0") - /* As we haven't updated the cache data structures for - * for the flush or flush destroy yet, the entry should - * be in the slist if the slist is enabled. Since - * H5C__UPDATE_SLIST_FOR_SIZE_CHANGE() is a no-op if the - * slist is enabled, call it un-conditionally. + /* no need to check max_increment, as it is a size_t, + * and thus must be non-negative. */ - assert(entry_ptr->is_dirty); - assert((entry_ptr->in_slist) || (!cache_ptr->slist_enabled)); + } /* H5C_incr__threshold */ - H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len); + switch (config_ptr->flash_incr_mode) { + case H5C_flash_incr__off: + /* nothing to do here */ + break; - /* Finally, update the entry for its new size */ - entry_ptr->size = new_len; - } /* end if */ + case H5C_flash_incr__add_space: + if ((config_ptr->flash_multiple < 0.1) || (config_ptr->flash_multiple > 10.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_multiple must be in the range [0.1, 10.0]") + if ((config_ptr->flash_threshold < 0.1) || (config_ptr->flash_threshold > 1.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "flash_threshold must be in the range [0.1, 1.0]") + break; - /* If required, udate the entry and the cache data structures - * for a move - */ - if (serialize_flags & H5C__SERIALIZE_MOVED_FLAG) { - /* Update stats and entries relocated counter */ - H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid flash_incr_mode") + break; + } /* end switch */ + } /* H5C_RESIZE_CFG__VALIDATE_INCREMENT */ - /* We must update cache data structures for the change in address */ - if (entry_ptr->addr == old_addr) { - /* Delete the entry from the hash table and the slist */ - H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL); - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE); + if ((tests & H5C_RESIZE_CFG__VALIDATE_DECREMENT) != 0) { + if ((config_ptr->decr_mode != H5C_decr__off) && (config_ptr->decr_mode != H5C_decr__threshold) && + (config_ptr->decr_mode != H5C_decr__age_out) && + (config_ptr->decr_mode != H5C_decr__age_out_with_threshold)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid decr_mode") - /* Update the entry for its new address */ - entry_ptr->addr = new_addr; + if (config_ptr->decr_mode == H5C_decr__threshold) { + if (config_ptr->upper_hr_threshold > 1.0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "upper_hr_threshold must be <= 1.0") + if ((config_ptr->decrement > 1.0) || (config_ptr->decrement < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "decrement must be in the interval [0.0, 1.0]") - /* And then reinsert in the index and slist */ - H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); - } /* end if */ - else /* move is already done for us -- just do sanity checks */ - assert(entry_ptr->addr == new_addr); - } /* end if */ - } /* end if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) */ - - /* Serialize object into buffer */ - if (entry_ptr->type->serialize(f, entry_ptr->image_ptr, entry_ptr->size, (void *)entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to serialize entry") - -#if H5C_DO_MEMORY_SANITY_CHECKS - assert(0 == memcmp(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, - H5C_IMAGE_EXTRA_SPACE)); -#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - - entry_ptr->image_up_to_date = TRUE; - - /* Propagate the fact that the entry is serialized up the - * flush dependency chain if appropriate. Since the image must - * have been out of date for this function to have been called - * (see assertion on entry), no need to check that -- only check - * for flush dependency parents. - */ - assert(entry_ptr->flush_dep_nunser_children == 0); + /* no need to check max_decrement as it is a size_t + * and thus must be non-negative. + */ + } /* H5C_decr__threshold */ + + if ((config_ptr->decr_mode == H5C_decr__age_out) || + (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) { + if (config_ptr->epochs_before_eviction < 1) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction must be positive") + if (config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") + if (config_ptr->apply_empty_reserve && + (config_ptr->empty_reserve > 1.0 || config_ptr->empty_reserve < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty_reserve must be in the interval [0.0, 1.0]") + + /* no need to check max_decrement as it is a size_t + * and thus must be non-negative. + */ + } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ + + if (config_ptr->decr_mode == H5C_decr__age_out_with_threshold) + if ((config_ptr->upper_hr_threshold > 1.0) || (config_ptr->upper_hr_threshold < 0.0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "upper_hr_threshold must be in the interval [0.0, 1.0]") + } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ - if (entry_ptr->flush_dep_nparents > 0) - if (H5C__mark_flush_dep_serialized(entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { + if ((config_ptr->incr_mode == H5C_incr__threshold) && + ((config_ptr->decr_mode == H5C_decr__threshold) || + (config_ptr->decr_mode == H5C_decr__age_out_with_threshold)) && + (config_ptr->lower_hr_threshold >= config_ptr->upper_hr_threshold)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "conflicting threshold fields in config") + } /* H5C_RESIZE_CFG__VALIDATE_INTERACTIONS */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__generate_image */ +} /* H5C_validate_resize_config() */ /*------------------------------------------------------------------------- + * Function: H5C_cork * - * Function: H5C_remove_entry - * - * Purpose: Remove an entry from the cache. Must be not protected, pinned, - * dirty, involved in flush dependencies, etc. - * - * Return: Non-negative on success/Negative on failure + * Purpose: To cork/uncork/get cork status of an object depending on "action": + * H5C__SET_CORK: + * To cork the object + * Return error if the object is already corked + * H5C__UNCORK: + * To uncork the object + * Return error if the object is not corked + * H5C__GET_CORKED: + * To retrieve the cork status of an object in + * the parameter "corked" * - * Programmer: Quincey Koziol - * September 17, 2016 + * Return: Success: Non-negative + * Failure: Negative * *------------------------------------------------------------------------- */ herr_t -H5C_remove_entry(void *_entry) +H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) { - H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry to remove */ - H5C_t *cache; /* Cache for file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_tag_info_t *tag_info = NULL; + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOINIT - /* Sanity checks */ - assert(entry); - assert(entry->ring != H5C_RING_UNDEFINED); - cache = entry->cache_ptr; - assert(cache); - assert(cache->magic == H5C__H5C_T_MAGIC); - - /* Check for error conditions */ - if (entry->is_dirty) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove dirty entry from cache") - if (entry->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove protected entry from cache") - if (entry->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove pinned entry from cache") - /* NOTE: If these two errors are getting tripped because the entry is - * in a flush dependency with a freedspace entry, move the checks - * after the "before evict" message is sent, and add the - * "child being evicted" message to the "before evict" notify - * section below. QAK - 2017/08/03 - */ - if (entry->flush_dep_nparents > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, - "can't remove entry with flush dependency parents from cache") - if (entry->flush_dep_nchildren > 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, - "can't remove entry with flush dependency children from cache") - - /* Additional internal cache consistency checks */ - assert(!entry->in_slist); - assert(!entry->flush_marker); - assert(!entry->flush_in_progress); - - /* Note that the algorithm below is (very) similar to the set of operations - * in H5C__flush_single_entry() and should be kept in sync with changes - * to that code. - QAK, 2016/11/30 - */ + /* Assertions */ + assert(cache_ptr != NULL); + assert(H5_addr_defined(obj_addr)); + assert(action == H5C__SET_CORK || action == H5C__UNCORK || action == H5C__GET_CORKED); - /* Update stats, as if we are "destroying" and taking ownership of the entry */ - H5C__UPDATE_STATS_FOR_EVICTION(cache, entry, TRUE) + /* Search the list of corked object addresses in the cache */ + HASH_FIND(hh, cache_ptr->tag_list, &obj_addr, sizeof(haddr_t), tag_info); - /* If the entry's type has a 'notify' callback, send a 'before eviction' - * notice while the entry is still fully integrated in the cache. - */ - if (entry->type->notify && (entry->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") - - /* Update the cache internal data structures as appropriate for a destroy. - * Specifically: - * 1) Delete it from the index - * 2) Delete it from the collective read access list - * 3) Update the replacement policy for eviction - * 4) Remove it from the tag list for this object - */ + if (H5C__GET_CORKED == action) { + assert(corked); + if (tag_info != NULL && tag_info->corked) + *corked = TRUE; + else + *corked = FALSE; + } + else { + /* Sanity check */ + assert(H5C__SET_CORK == action || H5C__UNCORK == action); - H5C__DELETE_FROM_INDEX(cache, entry, FAIL) + /* Perform appropriate action */ + if (H5C__SET_CORK == action) { + /* Check if this is the first entry for this tagged object */ + if (NULL == tag_info) { + /* Allocate new tag info struct */ + if (NULL == (tag_info = H5FL_CALLOC(H5C_tag_info_t))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate tag info for cache entry") -#ifdef H5_HAVE_PARALLEL - /* Check for collective read access flag */ - if (entry->coll_access) { - entry->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache, entry, FAIL) - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + /* Set the tag for all entries */ + tag_info->tag = obj_addr; - H5C__UPDATE_RP_FOR_EVICTION(cache, entry, FAIL) + /* Insert tag info into hash table */ + HASH_ADD(hh, cache_ptr->tag_list, tag, sizeof(haddr_t), tag_info); + } + else { + /* Check for object already corked */ + if (tag_info->corked) + HGOTO_ERROR(H5E_CACHE, H5E_CANTCORK, FAIL, "object already corked") + assert(tag_info->entry_cnt > 0 && tag_info->head); + } - /* Remove entry from tag list */ - if (H5C__untag_entry(cache, entry) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") + /* Set the corked status for the entire object */ + tag_info->corked = TRUE; + cache_ptr->num_objs_corked++; + } + else { + /* Sanity check */ + if (NULL == tag_info) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "tag info pointer is NULL") - /* Increment entries_removed_counter and set last_entry_removed_ptr. - * As we me be about to free the entry, recall that last_entry_removed_ptr - * must NEVER be dereferenced. - * - * Recall that these fields are maintained to allow functions that perform - * scans of lists of entries to detect the unexpected removal of entries - * (via expunge, eviction, or take ownership at present), so that they can - * re-start their scans if necessary. - * - * Also check if the entry we are watching for removal is being - * removed (usually the 'next' entry for an iteration) and reset - * it to indicate that it was removed. - */ - cache->entries_removed_counter++; - cache->last_entry_removed_ptr = entry; - if (entry == cache->entry_watched_for_removal) - cache->entry_watched_for_removal = NULL; + /* Check for already uncorked */ + if (!tag_info->corked) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "object already uncorked") - /* Internal cache data structures should now be up to date, and - * consistent with the status of the entry. - * - * Now clean up internal cache fields if appropriate. - */ + /* Set the corked status for the entire object */ + tag_info->corked = FALSE; + cache_ptr->num_objs_corked--; - /* Free the buffer for the on disk image */ - if (entry->image_ptr != NULL) - entry->image_ptr = H5MM_xfree(entry->image_ptr); + /* Remove the tag info from the tag list, if there's no more entries with this tag */ + if (0 == tag_info->entry_cnt) { + /* Sanity check */ + assert(NULL == tag_info->head); - /* Reset the pointer to the cache the entry is within */ - entry->cache_ptr = NULL; + HASH_DELETE(hh, cache_ptr->tag_list, tag_info); - /* Client is taking ownership of the entry. Set bad magic here so the - * cache will choke unless the entry is re-inserted properly - */ - entry->magic = H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC; + /* Release the tag info */ + tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); + } + else + assert(NULL != tag_info->head); + } + } done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__remove_entry() */ +} /* H5C_cork() */ diff --git a/src/H5CS.c b/src/H5CS.c index bb2a1ea..66ac0d7 100644 --- a/src/H5CS.c +++ b/src/H5CS.c @@ -213,7 +213,7 @@ H5CS_pop(void) /* Pop the function. */ fstack->nused--; - FUNC_LEAVE_NOAPI_NOFS(SUCCEED); + FUNC_LEAVE_NOAPI_NOFS(SUCCEED) } /* end H5CS_pop() */ /*------------------------------------------------------------------------- diff --git a/src/H5CX.c b/src/H5CX.c index b2ddbc1..d2bd1ba 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -972,7 +972,7 @@ done: if (*api_state) { /* Release the (possibly partially allocated) API state struct */ if (H5CX_free_state(*api_state) < 0) - HDONE_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release API state") + HDONE_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release API state"); *api_state = NULL; } /* end if */ } /* end if */ @@ -1095,7 +1095,7 @@ H5CX_free_state(H5CX_state_t *api_state) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") /* Decrement connector ID */ if (H5I_dec_ref(api_state->vol_connector_prop.connector_id) < 0) - HDONE_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't close VOL connector ID") + HDONE_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't close VOL connector ID"); } /* end if */ /* Free the state */ diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 0411e8e..19d31f1 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -13,8 +13,6 @@ /*------------------------------------------------------------------------- * * Created: H5Cdbg.c - * July 8 2016 - * Quincey Koziol * * Purpose: Debugging Routines for the generic cache structure or entries. * @@ -69,9 +67,6 @@ * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 10/10/10 - * *------------------------------------------------------------------------- */ herr_t @@ -86,7 +81,6 @@ H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) /* Sanity check */ assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_name != NULL); /* First, create a skip list */ @@ -101,7 +95,6 @@ H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) entry_ptr = cache_ptr->index[i]; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); if (H5SL_insert(slist_ptr, entry_ptr, &(entry_ptr->addr)) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't insert entry in skip list") @@ -131,8 +124,6 @@ H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) i = 0; entry_ptr = (H5C_cache_entry_t *)H5SL_remove_first(slist_ptr); while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Print entry */ fprintf(stdout, "%s%5d ", cache_ptr->prefix, i); fprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); @@ -178,9 +169,6 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 10/10/10 - * *------------------------------------------------------------------------- */ herr_t @@ -193,7 +181,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) /* Sanity check */ assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_name != NULL); fprintf(stdout, "\n\nDump of metadata cache LRU \"%s\"\n", cache_name); @@ -218,8 +205,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) entry_ptr = cache_ptr->LRU_head_ptr; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Print entry */ fprintf(stdout, "%s%5d ", cache_ptr->prefix, i); fprintf(stdout, " 0x%16llx ", (long long)(entry_ptr->addr)); @@ -247,7 +232,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_dump_cache_skip_list * * Purpose: Debugging routine that prints a summary of the contents of @@ -256,9 +240,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 11/15/14 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -273,7 +254,6 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) FUNC_ENTER_NOAPI_NOERR assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(calling_fcn != NULL); fprintf(stdout, "\n\nDumping metadata cache skip list from %s.\n", calling_fcn); @@ -297,7 +277,6 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) entry_ptr = NULL; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); fprintf(stdout, "%s%d 0x%016llx %4lld %d/%d %d %s\n", cache_ptr->prefix, i, (long long)(entry_ptr->addr), (long long)(entry_ptr->size), (int)(entry_ptr->is_protected), (int)(entry_ptr->is_pinned), (int)(entry_ptr->is_dirty), @@ -329,9 +308,6 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 1/20/06 - * *------------------------------------------------------------------------- */ herr_t @@ -341,8 +317,7 @@ H5C_set_prefix(H5C_t *cache_ptr, char *prefix) FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (prefix == NULL) || - (HDstrlen(prefix) >= H5C__PREFIX_LEN)) + if (cache_ptr == NULL || prefix == NULL || HDstrlen(prefix) >= H5C__PREFIX_LEN) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry") HDstrncpy(&(cache_ptr->prefix[0]), prefix, (size_t)(H5C__PREFIX_LEN)); @@ -360,9 +335,6 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: John Mainzer - * 6/2/04 - * *------------------------------------------------------------------------- */ herr_t @@ -416,12 +388,7 @@ H5C_stats(H5C_t *cache_ptr, const char *cache_name, FUNC_ENTER_NOAPI(FAIL) - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* This would normally be an assert, but we need to use an HGOTO_ERROR - * call to shut up the compiler. - */ - if ((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC) || (NULL == cache_name)) + if (NULL == cache_ptr || NULL == cache_name) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr or cache_name") #if H5C_COLLECT_CACHE_STATS @@ -694,15 +661,12 @@ done: } /* H5C_stats() */ /*------------------------------------------------------------------------- - * * Function: H5C_stats__reset * * Purpose: Reset the stats fields to their initial values. * * Return: void * - * Programmer: John Mainzer, 4/28/04 - * *------------------------------------------------------------------------- */ void @@ -710,7 +674,7 @@ void H5C_stats__reset(H5C_t *cache_ptr) #else /* NDEBUG */ #if H5C_COLLECT_CACHE_STATS -H5C_stats__reset(H5C_t *cache_ptr) +H5C_stats__reset(H5C_t *cache_ptr) #else /* H5C_COLLECT_CACHE_STATS */ H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ @@ -721,7 +685,6 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_COLLECT_CACHE_STATS for (i = 0; i <= cache_ptr->max_type_id; i++) { @@ -827,9 +790,6 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) * Return: SUCCEED on success/FAIL on failure. Note that * *fd_exists_ptr is undefined on failure. * - * Programmer: John Mainzer - * 9/28/16 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -845,18 +805,14 @@ H5C_flush_dependency_exists(H5C_t *cache_ptr, haddr_t parent_addr, haddr_t child /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(parent_addr)); assert(H5_addr_defined(child_addr)); assert(fd_exists_ptr); - H5C__SEARCH_INDEX(cache_ptr, parent_addr, parent_ptr, FAIL) - H5C__SEARCH_INDEX(cache_ptr, child_addr, child_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, parent_addr, parent_ptr, FAIL); + H5C__SEARCH_INDEX(cache_ptr, child_addr, child_ptr, FAIL); if (parent_ptr && child_ptr) { - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(child_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if (child_ptr->flush_dep_nparents > 0) { unsigned u; /* Local index variable */ @@ -881,7 +837,6 @@ done: #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_validate_index_list * * Purpose: Debugging function that scans the index list for errors. @@ -892,8 +847,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: John Mainzer, 9/16/16 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -916,7 +869,6 @@ H5C_validate_index_list(H5C_t *cache_ptr) /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); for (i = 0; i < H5C_RING_NTYPES; i++) { index_ring_len[i] = 0; @@ -997,7 +949,6 @@ done: #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_get_entry_ptr_from_addr() * * Purpose: Debugging function that attempts to look up an entry in the @@ -1028,8 +979,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: John Mainzer, 5/30/14 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1043,11 +992,10 @@ H5C_get_entry_ptr_from_addr(H5C_t *cache_ptr, haddr_t addr, void **entry_ptr_ptr /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(addr)); assert(entry_ptr_ptr); - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this @@ -1074,9 +1022,6 @@ done: * * Return: Current value of cache_ptr->serialization_in_progress. * - * Programmer: John Mainzer - * 8/24/15 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1087,14 +1032,12 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) /* Sanity check */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); FUNC_LEAVE_NOAPI(cache_ptr->serialization_in_progress) } /* H5C_get_serialization_in_progress() */ #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_cache_is_clean() * * Purpose: Debugging function that verifies that all rings in the @@ -1106,8 +1049,6 @@ H5C_get_serialization_in_progress(const H5C_t *cache_ptr) * * Return: TRUE if the indicated ring(s) are clean, and FALSE otherwise. * - * Programmer: John Mainzer, 6/18/16 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1121,13 +1062,12 @@ H5C_cache_is_clean(const H5C_t *cache_ptr, H5C_ring_t inner_ring) /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(inner_ring >= H5C_RING_USER); assert(inner_ring <= H5C_RING_SB); while (ring <= inner_ring) { if (cache_ptr->dirty_index_ring_size[ring] > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); ring++; } /* end while */ @@ -1138,7 +1078,6 @@ done: #endif /* NDEBUG */ /*------------------------------------------------------------------------- - * * Function: H5C_verify_entry_type() * * Purpose: Debugging function that attempts to look up an entry in the @@ -1158,8 +1097,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: John Mainzer, 5/30/14 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -1174,13 +1111,12 @@ H5C_verify_entry_type(H5C_t *cache_ptr, haddr_t addr, const H5C_class_t *expecte /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(addr)); assert(expected_type); assert(in_cache_ptr); assert(type_ok_ptr); - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) /* the entry doesn't exist in the cache -- report this @@ -1200,3 +1136,457 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_verify_entry_type() */ #endif /* NDEBUG */ + +/*------------------------------------------------------------------------- + * Function: H5C_def_auto_resize_rpt_fcn + * + * Purpose: Print results of a automatic cache resize. + * + * This function should only be used where printf() behaves + * well -- i.e. not on Windows. + * + * Return: void + * + *------------------------------------------------------------------------- + */ +void +H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, +#ifndef NDEBUG + int32_t version, +#else + int32_t H5_ATTR_UNUSED version, +#endif + double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, + size_t new_max_cache_size, size_t old_min_clean_size, size_t new_min_clean_size) +{ + assert(cache_ptr != NULL); + assert(version == H5C__CURR_AUTO_RESIZE_RPT_FCN_VER); + + switch (status) { + case in_spec: + fprintf(stdout, "%sAuto cache resize -- no change. (hit rate = %lf)\n", cache_ptr->prefix, + hit_rate); + break; + + case increase: + assert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); + assert(old_max_cache_size < new_max_cache_size); + + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); + fprintf(stdout, "%scache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; + + case flash_increase: + assert(old_max_cache_size < new_max_cache_size); + + fprintf(stdout, "%sflash cache resize(%d) -- size threshold = %zu.\n", cache_ptr->prefix, + (int)(cache_ptr->resize_ctl.flash_incr_mode), cache_ptr->flash_size_increase_threshold); + fprintf(stdout, "%s cache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; + + case decrease: + assert(old_max_cache_size > new_max_cache_size); + + switch (cache_ptr->resize_ctl.decr_mode) { + case H5C_decr__off: + fprintf(stdout, "%sAuto cache resize -- decrease off. HR = %lf\n", cache_ptr->prefix, + hit_rate); + break; + + case H5C_decr__threshold: + assert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); + + fprintf(stdout, "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); + fprintf(stdout, "%sout of bounds high (%6.5lf).\n", cache_ptr->prefix, + cache_ptr->resize_ctl.upper_hr_threshold); + break; + + case H5C_decr__age_out: + fprintf(stdout, "%sAuto cache resize -- decrease by ageout. HR = %lf\n", + cache_ptr->prefix, hit_rate); + break; + + case H5C_decr__age_out_with_threshold: + assert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); + + fprintf(stdout, + "%sAuto cache resize -- decrease by ageout with threshold. HR = %lf > %6.5lf\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); + break; + + default: + fprintf(stdout, "%sAuto cache resize -- decrease by unknown mode. HR = %lf\n", + cache_ptr->prefix, hit_rate); + } + + fprintf(stdout, "%s cache size decreased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, + old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); + break; + + case at_max_size: + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); + fprintf(stdout, "%s cache already at maximum size so no change.\n", cache_ptr->prefix); + break; + + case at_min_size: + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) -- can't decrease.\n", cache_ptr->prefix, + hit_rate); + fprintf(stdout, "%s cache already at minimum size.\n", cache_ptr->prefix); + break; + + case increase_disabled: + fprintf(stdout, "%sAuto cache resize -- increase disabled -- HR = %lf.", cache_ptr->prefix, + hit_rate); + break; + + case decrease_disabled: + fprintf(stdout, "%sAuto cache resize -- decrease disabled -- HR = %lf.\n", cache_ptr->prefix, + hit_rate); + break; + + case not_full: + assert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); + + fprintf(stdout, "%sAuto cache resize -- hit rate (%lf) out of bounds low (%6.5lf).\n", + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); + fprintf(stdout, "%s cache not full so no increase in size.\n", cache_ptr->prefix); + break; + + default: + fprintf(stdout, "%sAuto cache resize -- unknown status code.\n", cache_ptr->prefix); + break; + } +} /* H5C_def_auto_resize_rpt_fcn() */ + +/*------------------------------------------------------------------------- + * Function: H5C__validate_lru_list + * + * Purpose: Debugging function that scans the LRU list for errors. + * + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_EXTREME_SANITY_CHECKS +herr_t +H5C__validate_lru_list(H5C_t *cache_ptr) +{ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_tail_ptr == NULL)) && + (cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list head/tail check failed") + + if ((cache_ptr->LRU_list_len == 1) && + ((cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr) || (cache_ptr->LRU_head_ptr == NULL) || + (cache_ptr->LRU_head_ptr->size != cache_ptr->LRU_list_size))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list sanity check failed") + + if ((cache_ptr->LRU_list_len >= 1) && + ((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_head_ptr->prev != NULL) || + (cache_ptr->LRU_tail_ptr == NULL) || (cache_ptr->LRU_tail_ptr->next != NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list sanity check failed") + + entry_ptr = cache_ptr->LRU_head_ptr; + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->LRU_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if ((entry_ptr != cache_ptr->LRU_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if (entry_ptr->is_pinned || entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "invalid entry 'pin origin' fields") + + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } + + if ((cache_ptr->LRU_list_len != (uint32_t)len) || (cache_ptr->LRU_list_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU list length/size check failed") + +done: + if (ret_value != SUCCEED) + assert(0); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__validate_lru_list() */ +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__validate_pinned_entry_list + * + * Purpose: Debugging function that scans the pinned entry list for + * errors. + * + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_EXTREME_SANITY_CHECKS +herr_t +H5C__validate_pinned_entry_list(H5C_t *cache_ptr) +{ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_tail_ptr == NULL)) && + (cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list head/tail check failed") + + if ((cache_ptr->pel_len == 1) && + ((cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr) || (cache_ptr->pel_head_ptr == NULL) || + (cache_ptr->pel_head_ptr->size != cache_ptr->pel_size))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list sanity check failed") + + if ((cache_ptr->pel_len >= 1) && + ((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_head_ptr->prev != NULL) || + (cache_ptr->pel_tail_ptr == NULL) || (cache_ptr->pel_tail_ptr->next != NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list sanity check failed") + + entry_ptr = cache_ptr->pel_head_ptr; + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->pel_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if ((entry_ptr != cache_ptr->pel_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if (!entry_ptr->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list contains unpinned entry") + + if (!(entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "invalid entry 'pin origin' fields") + + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } + + if ((cache_ptr->pel_len != (uint32_t)len) || (cache_ptr->pel_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pinned list length/size check failed") + +done: + if (ret_value != SUCCEED) + assert(0); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__validate_pinned_entry_list() */ +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__validate_protected_entry_list + * + * Purpose: Debugging function that scans the protected entry list for + * errors. + * + * If an error is detected, the function generates a + * diagnostic and returns FAIL. If no error is detected, + * the function returns SUCCEED. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_EXTREME_SANITY_CHECKS +herr_t +H5C__validate_protected_entry_list(H5C_t *cache_ptr) +{ + int32_t len = 0; + size_t size = 0; + H5C_cache_entry_t *entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) && + (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list head/tail check failed") + + if ((cache_ptr->pl_len == 1) && + ((cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr) || (cache_ptr->pl_head_ptr == NULL) || + (cache_ptr->pl_head_ptr->size != cache_ptr->pl_size))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list sanity check failed") + + if ((cache_ptr->pl_len >= 1) && + ((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_head_ptr->prev != NULL) || + (cache_ptr->pl_tail_ptr == NULL) || (cache_ptr->pl_tail_ptr->next != NULL))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list sanity check failed") + + entry_ptr = cache_ptr->pl_head_ptr; + while (entry_ptr != NULL) { + if ((entry_ptr != cache_ptr->pl_head_ptr) && + ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if ((entry_ptr != cache_ptr->pl_tail_ptr) && + ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry has bad prev/next pointers") + + if (!entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list contains unprotected entry") + + if (entry_ptr->is_read_only && (entry_ptr->ro_ref_count <= 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "read-only entry has non-positive ref count") + + len++; + size += entry_ptr->size; + entry_ptr = entry_ptr->next; + } + + if ((cache_ptr->pl_len != (uint32_t)len) || (cache_ptr->pl_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "protected list length/size check failed") + +done: + if (ret_value != SUCCEED) + assert(0); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__validate_protected_entry_list() */ +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__entry_in_skip_list + * + * Purpose: Debugging function that scans skip list to see if it + * is in present. We need this, as it is possible for + * an entry to be in the skip list twice. + * + * Return: FALSE if the entry is not in the skip list, and TRUE + * if it is. + * + *------------------------------------------------------------------------- + */ +#ifdef H5C_DO_SLIST_SANITY_CHECKS +hbool_t +H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) +{ + H5SL_node_t *node_ptr; + hbool_t in_slist; + hbool_t ret_value; + + FUNC_ENTER_PACKAGE + + /* Assertions */ + assert(cache_ptr); + assert(cache_ptr->slist_ptr); + + node_ptr = H5SL_first(cache_ptr->slist_ptr); + in_slist = FALSE; + while ((node_ptr != NULL) && (!in_slist)) { + H5C_cache_entry_t *entry_ptr; + + entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + + assert(entry_ptr); + assert(entry_ptr->is_dirty); + assert(entry_ptr->in_slist); + + if (entry_ptr == target_ptr) + in_slist = TRUE; + else + node_ptr = H5SL_next(node_ptr); + } + + /* Set return value */ + ret_value = in_slist; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__entry_in_skip_list() */ +#endif /* H5C_DO_SLIST_SANITY_CHECKS */ + +/*------------------------------------------------------------------------- + * Function: H5C__image_stats + * + * Purpose: Prints statistics specific to the cache image. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +#if H5C_COLLECT_CACHE_STATS +H5C__image_stats(H5C_t *cache_ptr, hbool_t print_header) +#else /* H5C_COLLECT_CACHE_STATS */ +H5C__image_stats(H5C_t *cache_ptr, hbool_t H5_ATTR_UNUSED print_header) +#endif /* H5C_COLLECT_CACHE_STATS */ +{ +#if H5C_COLLECT_CACHE_STATS + int i; + int64_t total_hits = 0; + int64_t total_misses = 0; + double hit_rate; + double prefetch_use_rate; +#endif /* H5C_COLLECT_CACHE_STATS */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if (NULL == cache_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") + +#if H5C_COLLECT_CACHE_STATS + for (i = 0; i <= cache_ptr->max_type_id; i++) { + total_hits += cache_ptr->hits[i]; + total_misses += cache_ptr->misses[i]; + } /* end for */ + + if ((total_hits > 0) || (total_misses > 0)) + hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); + else + hit_rate = 0.0; + + if (cache_ptr->prefetches > 0) + prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); + else + prefetch_use_rate = 0.0; + + if (print_header) { + fprintf(stdout, "\nhit prefetches prefetch image pf hit\n"); + fprintf(stdout, "rate: total: dirty: hits: flshs: evct: size: rate:\n"); + } /* end if */ + + fprintf(stdout, "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", hit_rate, + (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches), + (long long)(cache_ptr->prefetch_hits), (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]), + (long long)(cache_ptr->last_image_size), prefetch_use_rate); +#endif /* H5C_COLLECT_CACHE_STATS */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__image_stats() */ diff --git a/src/H5Centry.c b/src/H5Centry.c new file mode 100644 index 0000000..18f9689 --- /dev/null +++ b/src/H5Centry.c @@ -0,0 +1,4214 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Centry.c + * + * Purpose: Routines which operate on cache entries. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /* suppress error about including H5Fpkg */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ + +/****************/ +/* Local Macros */ +/****************/ +#if H5C_DO_MEMORY_SANITY_CHECKS +#define H5C_IMAGE_EXTRA_SPACE 8 +#define H5C_IMAGE_SANITY_VALUE "DeadBeef" +#else /* H5C_DO_MEMORY_SANITY_CHECKS */ +#define H5C_IMAGE_EXTRA_SPACE 0 +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Alias for pointer to cache entry, for use when allocating sequences of them */ +typedef H5C_cache_entry_t *H5C_cache_entry_ptr_t; + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5C__pin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); +static herr_t H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); +static herr_t H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp); +static herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); +static herr_t H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, size_t *len, + hbool_t actual); +static void *H5C__load_entry(H5F_t *f, +#ifdef H5_HAVE_PARALLEL + hbool_t coll_access, +#endif /* H5_HAVE_PARALLEL */ + const H5C_class_t *type, haddr_t addr, void *udata); +static herr_t H5C__mark_flush_dep_dirty(H5C_cache_entry_t *entry); +static herr_t H5C__mark_flush_dep_clean(H5C_cache_entry_t *entry); +static herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry); +static herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry); +#ifndef NDEBUG +static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, + const H5C_cache_entry_t *base_entry); +#endif +static herr_t H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, + H5C_cache_entry_t **fd_children); +static herr_t H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr, + const H5C_class_t *type, haddr_t addr, void *udata); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Declare a free list to manage arrays of cache entries */ +H5FL_SEQ_DEFINE_STATIC(H5C_cache_entry_ptr_t); + +/*------------------------------------------------------------------------- + * Function: H5C__pin_entry_from_client() + * + * Purpose: Internal routine to pin a cache entry from a client action. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__pin_entry_from_client(H5C_t +#if !H5C_COLLECT_CACHE_STATS + H5_ATTR_UNUSED +#endif + *cache_ptr, + H5C_cache_entry_t *entry_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(cache_ptr); + assert(entry_ptr); + assert(entry_ptr->is_protected); + + /* Check if the entry is already pinned */ + if (entry_ptr->is_pinned) { + /* Check if the entry was pinned through an explicit pin from a client */ + if (entry_ptr->pinned_from_client) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "entry is already pinned") + } /* end if */ + else { + entry_ptr->is_pinned = TRUE; + + H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr); + } /* end else */ + + /* Mark that the entry was pinned through an explicit pin from a client */ + entry_ptr->pinned_from_client = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__pin_entry_from_client() */ + +/*------------------------------------------------------------------------- + * Function: H5C__unpin_entry_real() + * + * Purpose: Internal routine to unpin a cache entry. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__unpin_entry_real(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp) +{ + herr_t ret_value = SUCCEED; /* Return value */ + +#ifdef H5C_DO_SANITY_CHECKS + FUNC_ENTER_PACKAGE +#else + FUNC_ENTER_PACKAGE_NOERR +#endif + + /* Sanity checking */ + assert(cache_ptr); + assert(entry_ptr); + assert(entry_ptr->is_pinned); + + /* If requested, update the replacement policy if the entry is not protected */ + if (update_rp && !entry_ptr->is_protected) + H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, FAIL); + + /* Unpin the entry now */ + entry_ptr->is_pinned = FALSE; + + /* Update the stats for an unpin operation */ + H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr); + +#ifdef H5C_DO_SANITY_CHECKS +done: +#endif + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__unpin_entry_real() */ + +/*------------------------------------------------------------------------- + * Function: H5C__unpin_entry_from_client() + * + * Purpose: Internal routine to unpin a cache entry from a client action. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbool_t update_rp) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checking */ + assert(cache_ptr); + assert(entry_ptr); + + /* Error checking (should be sanity checks?) */ + if (!entry_ptr->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry isn't pinned") + if (!entry_ptr->pinned_from_client) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "entry wasn't pinned by cache client") + + /* Check if the entry is not pinned from a flush dependency */ + if (!entry_ptr->pinned_from_cache) + if (H5C__unpin_entry_real(cache_ptr, entry_ptr, update_rp) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") + + /* Mark the entry as explicitly unpinned by the client */ + entry_ptr->pinned_from_client = FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__unpin_entry_from_client() */ + +/*------------------------------------------------------------------------- + * Function: H5C__generate_image + * + * Purpose: Serialize an entry and generate its image. + * + * Note: This may cause the entry to be re-sized and/or moved in + * the cache. + * + * As we will not update the metadata cache's data structures + * until we we finish the write, we must touch up these + * data structures for size and location changes even if we + * are about to delete the entry from the cache (i.e. on a + * flush destroy). + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) +{ + haddr_t new_addr = HADDR_UNDEF; + haddr_t old_addr = HADDR_UNDEF; + size_t new_len = 0; + unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + assert(f); + assert(cache_ptr); + assert(entry_ptr); + assert(!entry_ptr->image_up_to_date); + assert(entry_ptr->is_dirty); + assert(!entry_ptr->is_protected); + assert(entry_ptr->type); + + /* make note of the entry's current address */ + old_addr = entry_ptr->addr; + + /* Call client's pre-serialize callback, if there's one */ + if ((entry_ptr->type->pre_serialize) && + ((entry_ptr->type->pre_serialize)(f, (void *)entry_ptr, entry_ptr->addr, entry_ptr->size, &new_addr, + &new_len, &serialize_flags) < 0)) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to pre-serialize entry") + + /* Check for any flags set in the pre-serialize callback */ + if (serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) { + /* Check for unexpected flags from serialize callback */ + if (serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG | H5C__SERIALIZE_MOVED_FLAG)) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unknown serialize flag(s)") + +#ifdef H5_HAVE_PARALLEL + /* In the parallel case, resizes and moves in + * the serialize operation can cause problems. + * If they occur, scream and die. + * + * At present, in the parallel case, the aux_ptr + * will only be set if there is more than one + * process. Thus we can use this to detect + * the parallel case. + * + * This works for now, but if we start using the + * aux_ptr for other purposes, we will have to + * change this test accordingly. + * + * NB: While this test detects entryies that attempt + * to resize or move themselves during a flush + * in the parallel case, it will not detect an + * entry that dirties, resizes, and/or moves + * other entries during its flush. + */ + if (cache_ptr->aux_ptr != NULL) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "resize/move in serialize occurred in parallel case") +#endif + + /* If required, resize the buffer and update the entry and the cache + * data structures + */ + if (serialize_flags & H5C__SERIALIZE_RESIZED_FLAG) { + /* Sanity check */ + assert(new_len > 0); + + /* Allocate a new image buffer */ + if (NULL == + (entry_ptr->image_ptr = H5MM_realloc(entry_ptr->image_ptr, new_len + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for on disk image buffer") + +#if H5C_DO_MEMORY_SANITY_CHECKS + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + new_len, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + + /* Update statistics for resizing the entry */ + H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_len); + + /* Update the hash table for the size change */ + H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len, entry_ptr, + !entry_ptr->is_dirty, FAIL); + + /* The entry can't be protected since we are in the process of + * flushing it. Thus we must update the replacement policy data + * structures for the size change. The macro deals with the pinned + * case. + */ + H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_len, FAIL); + + /* As we haven't updated the cache data structures for + * for the flush or flush destroy yet, the entry should + * be in the slist if the slist is enabled. Since + * H5C__UPDATE_SLIST_FOR_SIZE_CHANGE() is a no-op if the + * slist is enabled, call it un-conditionally. + */ + assert(entry_ptr->is_dirty); + assert((entry_ptr->in_slist) || (!cache_ptr->slist_enabled)); + + H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len); + + /* Finally, update the entry for its new size */ + entry_ptr->size = new_len; + } /* end if */ + + /* If required, udate the entry and the cache data structures + * for a move + */ + if (serialize_flags & H5C__SERIALIZE_MOVED_FLAG) { + /* Update stats and entries relocated counter */ + H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr); + + /* We must update cache data structures for the change in address */ + if (entry_ptr->addr == old_addr) { + /* Delete the entry from the hash table and the slist */ + H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL); + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE, FAIL); + + /* Update the entry for its new address */ + entry_ptr->addr = new_addr; + + /* And then reinsert in the index and slist */ + H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + } /* end if */ + else /* move is already done for us -- just do sanity checks */ + assert(entry_ptr->addr == new_addr); + } /* end if */ + } /* end if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) */ + + /* Serialize object into buffer */ + if (entry_ptr->type->serialize(f, entry_ptr->image_ptr, entry_ptr->size, (void *)entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to serialize entry") + +#if H5C_DO_MEMORY_SANITY_CHECKS + assert(0 == memcmp(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE)); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + + entry_ptr->image_up_to_date = TRUE; + + /* Propagate the fact that the entry is serialized up the + * flush dependency chain if appropriate. Since the image must + * have been out of date for this function to have been called + * (see assertion on entry), no need to check that -- only check + * for flush dependency parents. + */ + assert(entry_ptr->flush_dep_nunser_children == 0); + + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_serialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "Can't propagate serialization status to fd parents") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__generate_image */ + +/*------------------------------------------------------------------------- + * Function: H5C__flush_single_entry + * + * Purpose: Flush or clear (and evict if requested) the cache entry + * with the specified address and type. If the type is NULL, + * any unprotected entry at the specified address will be + * flushed (and possibly evicted). + * + * Attempts to flush a protected entry will result in an + * error. + * + * If the H5C__FLUSH_INVALIDATE_FLAG flag is set, the entry will + * be cleared and not flushed, and the call can't be part of a + * sequence of flushes. + * + * The function does nothing silently if there is no entry + * at the supplied address, or if the entry found has the + * wrong type. + * + * Return: Non-negative on success/Negative on failure or if there was + * an attempt to flush a protected item. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) +{ + H5C_t *cache_ptr; /* Cache for file */ + hbool_t destroy; /* external flag */ + hbool_t clear_only; /* external flag */ + hbool_t free_file_space; /* external flag */ + hbool_t take_ownership; /* external flag */ + hbool_t del_from_slist_on_destroy; /* external flag */ + hbool_t during_flush; /* external flag */ + hbool_t write_entry; /* internal flag */ + hbool_t destroy_entry; /* internal flag */ + hbool_t generate_image; /* internal flag */ + hbool_t update_page_buffer; /* internal flag */ + hbool_t was_dirty; + hbool_t suppress_image_entry_writes = FALSE; + hbool_t suppress_image_entry_frees = FALSE; + haddr_t entry_addr = HADDR_UNDEF; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(f); + cache_ptr = f->shared->cache; + assert(cache_ptr); + assert(entry_ptr); + assert(entry_ptr->ring != H5C_RING_UNDEFINED); + assert(entry_ptr->type); + + /* setup external flags from the flags parameter */ + destroy = ((flags & H5C__FLUSH_INVALIDATE_FLAG) != 0); + clear_only = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); + free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); + del_from_slist_on_destroy = ((flags & H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) != 0); + during_flush = ((flags & H5C__DURING_FLUSH_FLAG) != 0); + generate_image = ((flags & H5C__GENERATE_IMAGE_FLAG) != 0); + update_page_buffer = ((flags & H5C__UPDATE_PAGE_BUFFER_FLAG) != 0); + + /* Set the flag for destroying the entry, based on the 'take ownership' + * and 'destroy' flags + */ + if (take_ownership) + destroy_entry = FALSE; + else + destroy_entry = destroy; + + /* we will write the entry to disk if it exists, is dirty, and if the + * clear only flag is not set. + */ + if (entry_ptr->is_dirty && !clear_only) + write_entry = TRUE; + else + write_entry = FALSE; + + /* if we have received close warning, and we have been instructed to + * generate a metadata cache image, and we have actually constructed + * the entry images, set suppress_image_entry_frees to TRUE. + * + * Set suppress_image_entry_writes to TRUE if indicated by the + * image_ctl flags. + */ + if (cache_ptr->close_warning_received && cache_ptr->image_ctl.generate_image && + cache_ptr->num_entries_in_image > 0 && cache_ptr->image_entries != NULL) { + + /* Sanity checks */ + assert(entry_ptr->image_up_to_date || !(entry_ptr->include_in_image)); + assert(entry_ptr->image_ptr || !(entry_ptr->include_in_image)); + assert((!clear_only) || !(entry_ptr->include_in_image)); + assert((!take_ownership) || !(entry_ptr->include_in_image)); + assert((!free_file_space) || !(entry_ptr->include_in_image)); + + suppress_image_entry_frees = TRUE; + + if (cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES) + suppress_image_entry_writes = TRUE; + } /* end if */ + + /* run initial sanity checks */ +#ifdef H5C_DO_SANITY_CHECKS + if (cache_ptr->slist_enabled) { + if (entry_ptr->in_slist) { + assert(entry_ptr->is_dirty); + if (entry_ptr->flush_marker && !entry_ptr->is_dirty) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry in slist failed sanity checks") + } /* end if */ + else { + assert(!entry_ptr->is_dirty); + assert(!entry_ptr->flush_marker); + if (entry_ptr->is_dirty || entry_ptr->flush_marker) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry failed sanity checks") + } /* end else */ + } + else { /* slist is disabled */ + assert(!entry_ptr->in_slist); + if (!entry_ptr->is_dirty) + if (entry_ptr->flush_marker) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flush marked clean entry?") + } +#endif /* H5C_DO_SANITY_CHECKS */ + + if (entry_ptr->is_protected) + /* Attempt to flush a protected entry -- scream and die. */ + HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "Attempt to flush a protected entry") + + /* Set entry_ptr->flush_in_progress = TRUE and set + * entry_ptr->flush_marker = FALSE + * + * We will set flush_in_progress back to FALSE at the end if the + * entry still exists at that point. + */ + entry_ptr->flush_in_progress = TRUE; + entry_ptr->flush_marker = FALSE; + + /* Preserve current dirty state for later */ + was_dirty = entry_ptr->is_dirty; + + /* The entry is dirty, and we are doing a flush, a flush destroy or have + * been requested to generate an image. In those cases, serialize the + * entry. + */ + if (write_entry || generate_image) { + assert(entry_ptr->is_dirty); + if (NULL == entry_ptr->image_ptr) { + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, + "memory allocation failed for on disk image buffer") + +#if H5C_DO_MEMORY_SANITY_CHECKS + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + + } /* end if */ + + if (!entry_ptr->image_up_to_date) { + /* Sanity check */ + assert(!entry_ptr->prefetched); + + /* Generate the entry's image */ + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't generate entry's image") + } /* end if ( ! (entry_ptr->image_up_to_date) ) */ + } /* end if */ + + /* Finally, write the image to disk. + * + * Note that if the H5AC__CLASS_SKIP_WRITES flag is set in the + * in the entry's type, we silently skip the write. This + * flag should only be used in test code. + */ + if (write_entry) { + assert(entry_ptr->is_dirty); + +#ifdef H5C_DO_SANITY_CHECKS + if (cache_ptr->check_write_permitted && !cache_ptr->write_permitted) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Write when writes are always forbidden!?!?!") +#endif /* H5C_DO_SANITY_CHECKS */ + + /* Write the image to disk unless the write is suppressed. + * + * This happens if both suppress_image_entry_writes and + * entry_ptr->include_in_image are TRUE, or if the + * H5AC__CLASS_SKIP_WRITES is set in the entry's type. This + * flag should only be used in test code + */ + if ((!suppress_image_entry_writes || !entry_ptr->include_in_image) && + ((entry_ptr->type->flags & H5C__CLASS_SKIP_WRITES) == 0)) { + H5FD_mem_t mem_type = H5FD_MEM_DEFAULT; + +#ifdef H5_HAVE_PARALLEL + if (cache_ptr->coll_write_list) { + if (H5SL_insert(cache_ptr->coll_write_list, entry_ptr, &entry_ptr->addr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item") + } /* end if */ + else { +#endif /* H5_HAVE_PARALLEL */ + if (entry_ptr->prefetched) { + assert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); + mem_type = cache_ptr->class_table_ptr[entry_ptr->prefetch_type_id]->mem_type; + } /* end if */ + else + mem_type = entry_ptr->type->mem_type; + + if (H5F_block_write(f, mem_type, entry_ptr->addr, entry_ptr->size, entry_ptr->image_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't write image to file") +#ifdef H5_HAVE_PARALLEL + } +#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + + /* if the entry has a notify callback, notify it that we have + * just flushed the entry. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_FLUSH, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client of entry flush") + } /* if ( write_entry ) */ + + /* At this point, all pre-serialize and serialize calls have been + * made if it was appropriate to make them. Similarly, the entry + * has been written to disk if desired. + * + * Thus it is now safe to update the cache data structures for the + * flush. + */ + + /* start by updating the statistics */ + if (clear_only) { + /* only log a clear if the entry was dirty */ + if (was_dirty) + H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr); + } + else if (write_entry) { + assert(was_dirty); + + /* only log a flush if we actually wrote to disk */ + H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr); + } /* end else if */ + + /* Note that the algorithm below is (very) similar to the set of operations + * in H5C_remove_entry() and should be kept in sync with changes + * to that code. - QAK, 2016/11/30 + */ + + /* Update the cache internal data structures. */ + if (destroy) { + /* Sanity checks */ + if (take_ownership) + assert(!destroy_entry); + else + assert(destroy_entry); + + assert(!entry_ptr->is_pinned); + + /* Update stats, while entry is still in the cache */ + H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership); + + /* If the entry's type has a 'notify' callback and the entry is about + * to be removed from the cache, send a 'before eviction' notice while + * the entry is still fully integrated in the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") + + /* Update the cache internal data structures as appropriate + * for a destroy. Specifically: + * + * 1) Delete it from the index + * + * 2) Delete it from the skip list if requested. + * + * 3) Delete it from the collective read access list. + * + * 4) Update the replacement policy for eviction + * + * 5) Remove it from the tag list for this object + * + * Finally, if the destroy_entry flag is set, discard the + * entry. + */ + H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL); + + if (entry_ptr->in_slist && del_from_slist_on_destroy) + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush, FAIL); + +#ifdef H5_HAVE_PARALLEL + /* Check for collective read access flag */ + if (entry_ptr->coll_access) { + entry_ptr->coll_access = FALSE; + H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL); + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + + H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, FAIL); + + /* Remove entry from tag list */ + if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list") + + /* verify that the entry is no longer part of any flush dependencies */ + assert(entry_ptr->flush_dep_nparents == 0); + assert(entry_ptr->flush_dep_nchildren == 0); + } /* end if */ + else { + assert(clear_only || write_entry); + assert(entry_ptr->is_dirty); + assert((!cache_ptr->slist_enabled) || (entry_ptr->in_slist)); + + /* We are either doing a flush or a clear. + * + * A clear and a flush are the same from the point of + * view of the replacement policy and the slist. + * Hence no differentiation between them. + */ + H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, FAIL); + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush, FAIL); + + /* mark the entry as clean and update the index for + * entry clean. Also, call the clear callback + * if defined. + */ + entry_ptr->is_dirty = FALSE; + + H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr, FAIL); + + /* Check for entry changing status and do notifications, etc. */ + if (was_dirty) { + /* If the entry's type has a 'notify' callback send a + * 'entry cleaned' notice now that the entry is fully + * integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") + + /* Propagate the clean flag up the flush dependency chain + * if appropriate + */ + if (entry_ptr->flush_dep_ndirty_children != 0) + assert(entry_ptr->flush_dep_ndirty_children == 0); + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean flag") + } /* end if */ + } /* end else */ + + /* reset the flush_in progress flag */ + entry_ptr->flush_in_progress = FALSE; + + /* capture the cache entry address for the log_flush call at the + * end before the entry_ptr gets freed + */ + entry_addr = entry_ptr->addr; + + /* Internal cache data structures should now be up to date, and + * consistent with the status of the entry. + * + * Now discard the entry if appropriate. + */ + if (destroy) { + /* Sanity check */ + assert(0 == entry_ptr->flush_dep_nparents); + + /* if both suppress_image_entry_frees and entry_ptr->include_in_image + * are true, simply set entry_ptr->image_ptr to NULL, as we have + * another pointer to the buffer in an instance of H5C_image_entry_t + * in cache_ptr->image_entries. + * + * Otherwise, free the buffer if it exists. + */ + if (suppress_image_entry_frees && entry_ptr->include_in_image) + entry_ptr->image_ptr = NULL; + else if (entry_ptr->image_ptr != NULL) + entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); + + /* If the entry is not a prefetched entry, verify that the flush + * dependency parents addresses array has been transferred. + * + * If the entry is prefetched, the free_isr routine will dispose of + * the flush dependency parents addresses array if necessary. + */ + if (!entry_ptr->prefetched) { + assert(0 == entry_ptr->fd_parent_count); + assert(NULL == entry_ptr->fd_parent_addrs); + } /* end if */ + + /* Check whether we should free the space in the file that + * the entry occupies + */ + if (free_file_space) { + hsize_t fsf_size; + + /* Sanity checks */ + assert(H5_addr_defined(entry_ptr->addr)); + assert(!H5F_IS_TMP_ADDR(f, entry_ptr->addr)); +#ifndef NDEBUG + { + size_t curr_len; + + /* Get the actual image size for the thing again */ + entry_ptr->type->image_len((void *)entry_ptr, &curr_len); + assert(curr_len == entry_ptr->size); + } +#endif + + /* If the file space free size callback is defined, use + * it to get the size of the block of file space to free. + * Otherwise use entry_ptr->size. + */ + if (entry_ptr->type->fsf_size) { + if ((entry_ptr->type->fsf_size)((void *)entry_ptr, &fsf_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to get file space free size") + } /* end if */ + else /* no file space free size callback -- use entry size */ + fsf_size = entry_ptr->size; + + /* Release the space on disk */ + if (H5MF_xfree(f, entry_ptr->type->mem_type, entry_ptr->addr, fsf_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "unable to free file space for cache entry") + } /* end if ( free_file_space ) */ + + /* Reset the pointer to the cache the entry is within. -QAK */ + entry_ptr->cache_ptr = NULL; + + /* increment entries_removed_counter and set + * last_entry_removed_ptr. As we are likely abuut to + * free the entry, recall that last_entry_removed_ptr + * must NEVER be dereferenced. + * + * Recall that these fields are maintained to allow functions + * that perform scans of lists of entries to detect the + * unexpected removal of entries (via expunge, eviction, + * or take ownership at present), so that they can re-start + * their scans if necessary. + * + * Also check if the entry we are watching for removal is being + * removed (usually the 'next' entry for an iteration) and reset + * it to indicate that it was removed. + */ + cache_ptr->entries_removed_counter++; + cache_ptr->last_entry_removed_ptr = entry_ptr; + + if (entry_ptr == cache_ptr->entry_watched_for_removal) + cache_ptr->entry_watched_for_removal = NULL; + + /* Check for actually destroying the entry in memory */ + /* (As opposed to taking ownership of it) */ + if (destroy_entry) { + if (entry_ptr->is_dirty) { + /* Reset dirty flag */ + entry_ptr->is_dirty = FALSE; + + /* If the entry's type has a 'notify' callback send a + * 'entry cleaned' notice now that the entry is fully + * integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") + } /* end if */ + + /* verify that the image has been freed */ + assert(entry_ptr->image_ptr == NULL); + + if (entry_ptr->type->free_icr((void *)entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") + } /* end if */ + else { + assert(take_ownership); + } /* end else */ + } /* if (destroy) */ + + /* Check if we have to update the page buffer with cleared entries + * so it doesn't go out of date + */ + if (update_page_buffer) { + /* Sanity check */ + assert(!destroy); + assert(entry_ptr->image_ptr); + + if (f->shared->page_buf && (f->shared->page_buf->page_size >= entry_ptr->size)) + if (H5PB_update_entry(f->shared->page_buf, entry_ptr->addr, entry_ptr->size, + entry_ptr->image_ptr) > 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Failed to update PB with metadata cache") + } /* end if */ + + if (cache_ptr->log_flush) + if ((cache_ptr->log_flush)(cache_ptr, entry_addr, was_dirty, flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "log_flush callback failed") + +done: + assert((ret_value != SUCCEED) || (destroy_entry) || (!entry_ptr->flush_in_progress)); + assert((ret_value != SUCCEED) || (destroy_entry) || (take_ownership) || (!entry_ptr->is_dirty)); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_single_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C__verify_len_eoa + * + * Purpose: Verify that 'len' does not exceed eoa when 'actual' is + * false i.e. 'len" is the initial speculative length from + * get_load_size callback with null image pointer. + * If exceed, adjust 'len' accordingly. + * + * Verify that 'len' should not exceed eoa when 'actual' is + * true i.e. 'len' is the actual length from get_load_size + * callback with non-null image pointer. + * If exceed, return error. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, size_t *len, hbool_t actual) +{ + H5FD_mem_t cooked_type; /* Modified type, accounting for switching global heaps */ + haddr_t eoa; /* End-of-allocation in the file */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* if type == H5FD_MEM_GHEAP, H5F_block_read() forces + * type to H5FD_MEM_DRAW via its call to H5F__accum_read(). + * Thus we do the same for purposes of computing the EOA + * for sanity checks. + */ + cooked_type = (type->mem_type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type->mem_type; + + /* Get the file's end-of-allocation value */ + eoa = H5F_get_eoa(f, cooked_type); + if (!H5_addr_defined(eoa)) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid EOA address for file") + + /* Check for bad address in general */ + if (H5_addr_gt(addr, eoa)) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "address of object past end of allocation") + + /* Check if the amount of data to read will be past the EOA */ + if (H5_addr_gt((addr + *len), eoa)) { + if (actual) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "actual len exceeds EOA") + else + /* Trim down the length of the metadata */ + *len = (size_t)(eoa - addr); + } /* end if */ + + if (*len <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "len not positive after adjustment for EOA") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__verify_len_eoa() */ + +/*------------------------------------------------------------------------- + * Function: H5C__load_entry + * + * Purpose: Attempt to load the entry at the specified disk address + * and with the specified type into memory. If successful. + * return the in memory address of the entry. Return NULL + * on failure. + * + * Note that this function simply loads the entry into + * core. It does not insert it into the cache. + * + * Return: Non-NULL on success / NULL on failure. + * + *------------------------------------------------------------------------- + */ +void * +H5C__load_entry(H5F_t *f, +#ifdef H5_HAVE_PARALLEL + hbool_t coll_access, +#endif /* H5_HAVE_PARALLEL */ + const H5C_class_t *type, haddr_t addr, void *udata) +{ + hbool_t dirty = FALSE; /* Flag indicating whether thing was dirtied during deserialize */ + uint8_t *image = NULL; /* Buffer for disk image */ + void *thing = NULL; /* Pointer to thing loaded */ + H5C_cache_entry_t *entry = NULL; /* Alias for thing loaded, as cache entry */ + size_t len; /* Size of image in file */ +#ifdef H5_HAVE_PARALLEL + int mpi_rank = 0; /* MPI process rank */ + MPI_Comm comm = MPI_COMM_NULL; /* File MPI Communicator */ + int mpi_code; /* MPI error code */ +#endif /* H5_HAVE_PARALLEL */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(f); + assert(f->shared); + assert(f->shared->cache); + assert(type); + assert(H5_addr_defined(addr)); + assert(type->get_initial_load_size); + if (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) + assert(type->get_final_load_size); + else + assert(NULL == type->get_final_load_size); + assert(type->deserialize); + + /* Can't see how skip reads could be usefully combined with + * the speculative read flag. Hence disallow. + */ + assert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); + + /* Call the get_initial_load_size callback, to retrieve the initial size of image */ + if (type->get_initial_load_size(udata, &len) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image size") + assert(len > 0); + + /* 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) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid len with respect to EOA") + + /* Allocate the buffer for reading the on-disk entry image */ + if (NULL == (image = (uint8_t *)H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer") +#if H5C_DO_MEMORY_SANITY_CHECKS + H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + +#ifdef H5_HAVE_PARALLEL + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") + if ((comm = H5F_mpi_get_comm(f)) == MPI_COMM_NULL) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + + /* Get the on-disk entry image */ + if (0 == (type->flags & H5C__CLASS_SKIP_READS)) { + unsigned tries, max_tries; /* The # of read attempts */ + unsigned retries; /* The # of retries */ + htri_t chk_ret; /* return from verify_chksum callback */ + size_t actual_len = len; /* The actual length, after speculative reads have been resolved */ + uint64_t nanosec = 1; /* # of nanoseconds to sleep between retries */ + void *new_image; /* Pointer to image */ + hbool_t len_changed = TRUE; /* Whether to re-check speculative entries */ + + /* Get the # of read attempts */ + max_tries = tries = H5F_GET_READ_ATTEMPTS(f); + + /* + * This do/while loop performs the following till the metadata checksum + * is correct or the file's number of allowed read attempts are reached. + * --read the metadata + * --determine the actual size of the metadata + * --perform checksum verification + */ + do { + 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()") + image = (uint8_t *)new_image; +#if H5C_DO_MEMORY_SANITY_CHECKS + H5MM_memcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + } /* end if */ + +#ifdef H5_HAVE_PARALLEL + if (!coll_access || 0 == mpi_rank) { +#endif /* H5_HAVE_PARALLEL */ + if (H5F_block_read(f, type->mem_type, addr, len, image) < 0) { +#ifdef H5_HAVE_PARALLEL + if (coll_access) { + /* Push an error, but still participate in following MPI_Bcast */ + memset(image, 0, len); + HDONE_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*"); + } + else +#endif + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") + } + +#ifdef H5_HAVE_PARALLEL + } /* end if */ + /* if the collective metadata read optimization is turned on, + * bcast the metadata read from process 0 to all ranks in the file + * communicator + */ + if (coll_access) { + int buf_size; + + H5_CHECKED_ASSIGN(buf_size, int, len, size_t); + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(image, buf_size, MPI_BYTE, 0, comm))) + HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + + /* If the entry could be read speculatively and the length is still + * changing, check for updating the actual size + */ + if ((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && len_changed) { + /* Retrieve the actual length */ + actual_len = len; + if (type->get_final_load_size(image, len, udata, &actual_len) < 0) + continue; /* Transfer control to while() and count towards retries */ + + /* Check for the length changing */ + if (actual_len != len) { + /* Verify that the length isn't past the EOA for the file */ + if (H5C__verify_len_eoa(f, type, addr, &actual_len, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "actual_len exceeds EOA") + + /* Expand buffer to new size */ + if (NULL == (new_image = H5MM_realloc(image, actual_len + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") + image = (uint8_t *)new_image; +#if H5C_DO_MEMORY_SANITY_CHECKS + H5MM_memcpy(image + actual_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + + if (actual_len > len) { +#ifdef H5_HAVE_PARALLEL + if (!coll_access || 0 == mpi_rank) { +#endif /* H5_HAVE_PARALLEL */ + /* 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) { +#ifdef H5_HAVE_PARALLEL + if (coll_access) { + /* Push an error, but still participate in following MPI_Bcast */ + memset(image + len, 0, actual_len - len); + HDONE_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image"); + } + else +#endif + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") + } + +#ifdef H5_HAVE_PARALLEL + } + /* If the collective metadata read optimization is turned on, + * Bcast the metadata read from process 0 to all ranks in the file + * communicator */ + if (coll_access) { + int buf_size; + + H5_CHECKED_ASSIGN(buf_size, int, actual_len - len, size_t); + if (MPI_SUCCESS != + (mpi_code = MPI_Bcast(image + len, buf_size, MPI_BYTE, 0, comm))) + HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + } /* end if */ + } /* end if (actual_len != len) */ + else { + /* The length has stabilized */ + len_changed = FALSE; + + /* Set the final length */ + len = actual_len; + } /* else */ + } /* end if */ + + /* If there's no way to verify the checksum for a piece of metadata + * (usually because there's no checksum in the file), leave now + */ + if (type->verify_chksum == NULL) + break; + + /* Verify the checksum for the metadata image */ + if ((chk_ret = type->verify_chksum(image, actual_len, udata)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "failure from verify_chksum callback") + if (chk_ret == TRUE) + break; + + /* Sleep for some time */ + H5_nanosleep(nanosec); + nanosec *= 2; /* Double the sleep time next time */ + } while (--tries); + + /* Check for too many tries */ + if (tries == 0) + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "incorrect metadata checksum after all read attempts") + + /* Calculate and track the # of retries */ + retries = max_tries - tries; + if (retries) /* Does not track 0 retry */ + if (H5F_track_metadata_read_retries(f, (unsigned)type->mem_type, retries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "cannot track read tries = %u ", retries) + + /* Set the final length (in case it wasn't set earlier) */ + len = actual_len; + } /* end if !H5C__CLASS_SKIP_READS */ + + /* Deserialize the on-disk image into the native memory form */ + if (NULL == (thing = type->deserialize(image, len, udata, &dirty))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't deserialize image") + + entry = (H5C_cache_entry_t *)thing; + + /* In general, an entry should be clean just after it is loaded. + * + * However, when this code is used in the metadata cache, it is + * possible that object headers will be dirty at this point, as + * the deserialize function will alter object headers if necessary to + * fix an old bug. + * + * In the following assert: + * + * assert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); + * + * note that type ids 5 & 6 are associated with object headers in the + * metadata cache. + * + * When we get to using H5C for other purposes, we may wish to + * tighten up the assert so that the loophole only applies to the + * metadata cache. + */ + + assert((dirty == FALSE) || (type->id == 5 || type->id == 6)); + + entry->cache_ptr = f->shared->cache; + entry->addr = addr; + entry->size = len; + assert(entry->size < H5C_MAX_ENTRY_SIZE); + entry->image_ptr = image; + entry->image_up_to_date = !dirty; + entry->type = type; + entry->is_dirty = dirty; + entry->dirtied = FALSE; + entry->is_protected = FALSE; + entry->is_read_only = FALSE; + entry->ro_ref_count = 0; + entry->is_pinned = FALSE; + entry->in_slist = FALSE; + entry->flush_marker = FALSE; +#ifdef H5_HAVE_PARALLEL + entry->clear_on_unprotect = FALSE; + entry->flush_immediately = FALSE; + entry->coll_access = coll_access; +#endif /* H5_HAVE_PARALLEL */ + entry->flush_in_progress = FALSE; + entry->destroy_in_progress = FALSE; + + entry->ring = H5C_RING_UNDEFINED; + + /* Initialize flush dependency fields */ + entry->flush_dep_parent = NULL; + entry->flush_dep_nparents = 0; + entry->flush_dep_parent_nalloc = 0; + entry->flush_dep_nchildren = 0; + entry->flush_dep_ndirty_children = 0; + entry->flush_dep_nunser_children = 0; + entry->ht_next = NULL; + entry->ht_prev = NULL; + entry->il_next = NULL; + entry->il_prev = NULL; + + entry->next = NULL; + entry->prev = NULL; + +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + entry->aux_next = NULL; + entry->aux_prev = NULL; +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + +#ifdef H5_HAVE_PARALLEL + entry->coll_next = NULL; + entry->coll_prev = NULL; +#endif /* H5_HAVE_PARALLEL */ + + /* initialize cache image related fields */ + entry->include_in_image = FALSE; + entry->lru_rank = 0; + entry->image_dirty = FALSE; + entry->fd_parent_count = 0; + entry->fd_parent_addrs = NULL; + entry->fd_child_count = 0; + entry->fd_dirty_child_count = 0; + entry->image_fd_height = 0; + entry->prefetched = FALSE; + entry->prefetch_type_id = 0; + entry->age = 0; + entry->prefetched_dirty = FALSE; +#ifndef NDEBUG /* debugging field */ + entry->serialization_count = 0; +#endif + + /* initialize tag list fields */ + entry->tl_next = NULL; + entry->tl_prev = NULL; + entry->tag_info = NULL; + + H5C__RESET_CACHE_ENTRY_STATS(entry); + + ret_value = thing; + +done: + /* Cleanup on error */ + if (NULL == ret_value) { + /* Release resources */ + if (thing && type->free_icr(thing) < 0) + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed"); + if (image) + image = (uint8_t *)H5MM_xfree(image); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__load_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_dirty() + * + * Purpose: Recursively propagate the flush_dep_ndirty_children flag + * up the dependency chain in response to entry either + * becoming dirty or having its flush_dep_ndirty_children + * increased from 0. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__mark_flush_dep_dirty(H5C_cache_entry_t *entry) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(entry); + + /* Iterate over the parent entries, if any */ + for (u = 0; u < entry->flush_dep_nparents; u++) { + /* Sanity check */ + assert(entry->flush_dep_parent[u]->flush_dep_ndirty_children < + entry->flush_dep_parent[u]->flush_dep_nchildren); + + /* Adjust the parent's number of dirty children */ + entry->flush_dep_parent[u]->flush_dep_ndirty_children++; + + /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ + if (entry->flush_dep_parent[u]->type->notify && + (entry->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, + entry->flush_dep_parent[u]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag set") + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__mark_flush_dep_dirty() */ + +/*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_clean() + * + * Purpose: Recursively propagate the flush_dep_ndirty_children flag + * up the dependency chain in response to entry either + * becoming clean or having its flush_dep_ndirty_children + * reduced to 0. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__mark_flush_dep_clean(H5C_cache_entry_t *entry) +{ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(entry); + + /* Iterate over the parent entries, if any */ + /* Note reverse iteration order, in case the callback removes the flush + * dependency - QAK, 2017/08/12 + */ + for (i = ((int)entry->flush_dep_nparents) - 1; i >= 0; i--) { + /* Sanity check */ + assert(entry->flush_dep_parent[i]->flush_dep_ndirty_children > 0); + + /* Adjust the parent's number of dirty children */ + entry->flush_dep_parent[i]->flush_dep_ndirty_children--; + + /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ + if (entry->flush_dep_parent[i]->type->notify && + (entry->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, + entry->flush_dep_parent[i]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag reset") + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__mark_flush_dep_clean() */ + +/*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_serialized() + * + * Purpose: Decrement the flush_dep_nunser_children fields of all the + * target entry's flush dependency parents in response to + * the target entry becoming serialized. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry_ptr) +{ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(entry_ptr); + + /* Iterate over the parent entries, if any */ + /* Note reverse iteration order, in case the callback removes the flush + * dependency - QAK, 2017/08/12 + */ + for (i = ((int)entry_ptr->flush_dep_nparents) - 1; i >= 0; i--) { + /* Sanity checks */ + assert(entry_ptr->flush_dep_parent); + assert(entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children > 0); + + /* decrement the parents number of unserialized children */ + entry_ptr->flush_dep_parent[i]->flush_dep_nunser_children--; + + /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ + if (entry_ptr->flush_dep_parent[i]->type->notify && + (entry_ptr->flush_dep_parent[i]->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, + entry_ptr->flush_dep_parent[i]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag set") + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__mark_flush_dep_serialized() */ + +/*------------------------------------------------------------------------- + * Function: H5C__mark_flush_dep_unserialized() + * + * Purpose: Increment the flush_dep_nunser_children fields of all the + * target entry's flush dependency parents in response to + * the target entry becoming unserialized. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry_ptr) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(entry_ptr); + + /* Iterate over the parent entries, if any */ + for (u = 0; u < entry_ptr->flush_dep_nparents; u++) { + /* Sanity check */ + assert(entry_ptr->flush_dep_parent); + assert(entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children < + entry_ptr->flush_dep_parent[u]->flush_dep_nchildren); + + /* increment parents number of usserialized children */ + entry_ptr->flush_dep_parent[u]->flush_dep_nunser_children++; + + /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ + if (entry_ptr->flush_dep_parent[u]->type->notify && + (entry_ptr->flush_dep_parent[u]->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, + entry_ptr->flush_dep_parent[u]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag reset") + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__mark_flush_dep_unserialized() */ + +#ifndef NDEBUG +/*------------------------------------------------------------------------- + * Function: H5C__assert_flush_dep_nocycle() + * + * Purpose: Assert recursively that base_entry is not the same as + * entry, and perform the same assertion on all of entry's + * flush dependency parents. This is used to detect cycles + * created by flush dependencies. + * + * Return: void + * + *------------------------------------------------------------------------- + */ +static void +H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, const H5C_cache_entry_t *base_entry) +{ + unsigned u; /* Local index variable */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity checks */ + assert(entry); + assert(base_entry); + + /* Make sure the entries are not the same */ + assert(base_entry != entry); + + /* Iterate over entry's parents (if any) */ + for (u = 0; u < entry->flush_dep_nparents; u++) + H5C__assert_flush_dep_nocycle(entry->flush_dep_parent[u], base_entry); + + FUNC_LEAVE_NOAPI_VOID +} /* H5C__assert_flush_dep_nocycle() */ +#endif + +/*------------------------------------------------------------------------- + * Function: H5C__serialize_single_entry + * + * Purpose: Serialize the cache entry pointed to by the entry_ptr + * parameter. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(f); + assert(cache_ptr); + assert(entry_ptr); + assert(!entry_ptr->prefetched); + assert(!entry_ptr->image_up_to_date); + assert(entry_ptr->is_dirty); + assert(!entry_ptr->is_protected); + assert(!entry_ptr->flush_in_progress); + assert(entry_ptr->type); + + /* Set entry_ptr->flush_in_progress to TRUE so the target entry + * will not be evicted out from under us. Must set it back to FALSE + * when we are done. + */ + entry_ptr->flush_in_progress = TRUE; + + /* Allocate buffer for the entry image if required. */ + if (NULL == entry_ptr->image_ptr) { + assert(entry_ptr->size > 0); + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer") +#if H5C_DO_MEMORY_SANITY_CHECKS + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + image_size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + } /* end if */ + + /* Generate image for entry */ + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "Can't generate image for cache entry") + + /* Reset the flush_in progress flag */ + entry_ptr->flush_in_progress = FALSE; + +done: + assert((ret_value != SUCCEED) || (!entry_ptr->flush_in_progress)); + assert((ret_value != SUCCEED) || (entry_ptr->image_up_to_date)); + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__serialize_single_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C__destroy_pf_entry_child_flush_deps() + * + * Purpose: Destroy all flush dependencies in this the supplied + * prefetched entry is the parent. Note that the children + * in these flush dependencies must be prefetched entries as + * well. + * + * As this action is part of the process of transferring all + * such flush dependencies to the deserialized version of the + * prefetched entry, ensure that the data necessary to complete + * the transfer is retained. + * + * Note: The current implementation of this function is + * quite inefficient -- mostly due to the current + * implementation of flush dependencies. This should + * be fixed at some point. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, + H5C_cache_entry_t **fd_children) +{ + H5C_cache_entry_t *entry_ptr; +#ifndef NDEBUG + unsigned entries_visited = 0; +#endif + int fd_children_found = 0; + hbool_t found; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(cache_ptr); + assert(pf_entry_ptr); + assert(pf_entry_ptr->type); + assert(pf_entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); + assert(pf_entry_ptr->prefetched); + assert(pf_entry_ptr->fd_child_count > 0); + assert(fd_children); + + /* Scan each entry on the index list */ + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + /* Here we look at entry_ptr->flush_dep_nparents and not + * entry_ptr->fd_parent_count as it is possible that some + * or all of the prefetched flush dependency child relationships + * have already been destroyed. + */ + if (entry_ptr->prefetched && (entry_ptr->flush_dep_nparents > 0)) { + unsigned u; /* Local index variable */ + + /* Re-init */ + u = 0; + found = FALSE; + + /* Sanity checks */ + assert(entry_ptr->type); + assert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); + assert(entry_ptr->fd_parent_count >= entry_ptr->flush_dep_nparents); + assert(entry_ptr->fd_parent_addrs); + assert(entry_ptr->flush_dep_parent); + + /* Look for correct entry */ + while (!found && (u < entry_ptr->fd_parent_count)) { + /* Sanity check entry */ + assert(entry_ptr->flush_dep_parent[u]); + + /* Correct entry? */ + if (pf_entry_ptr == entry_ptr->flush_dep_parent[u]) + found = TRUE; + + u++; + } /* end while */ + + if (found) { + assert(NULL == fd_children[fd_children_found]); + + /* Remove flush dependency */ + fd_children[fd_children_found] = entry_ptr; + fd_children_found++; + if (H5C_destroy_flush_dependency(pf_entry_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "can't destroy pf entry child flush dependency") + +#ifndef NDEBUG + /* Sanity check -- verify that the address of the parent + * appears in entry_ptr->fd_parent_addrs. Must do a search, + * as with flush dependency creates and destroys, + * entry_ptr->fd_parent_addrs and entry_ptr->flush_dep_parent + * can list parents in different order. + */ + found = FALSE; + u = 0; + while (!found && u < entry_ptr->fd_parent_count) { + if (pf_entry_ptr->addr == entry_ptr->fd_parent_addrs[u]) + found = TRUE; + u++; + } /* end while */ + assert(found); +#endif + } /* end if */ + } /* end if */ + +#ifndef NDEBUG + entries_visited++; +#endif + entry_ptr = entry_ptr->il_next; + } /* end while */ + + /* Post-op sanity checks */ + assert(NULL == fd_children[fd_children_found]); + assert((unsigned)fd_children_found == pf_entry_ptr->fd_child_count); + assert(entries_visited == cache_ptr->index_len); + assert(!pf_entry_ptr->is_pinned); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__destroy_pf_entry_child_flush_deps() */ + +/*------------------------------------------------------------------------- + * Function: H5C__deserialize_prefetched_entry() + * + * Purpose: Deserialize the supplied prefetched entry entry, and return + * a pointer to the deserialized entry in *entry_ptr_ptr. + * If successful, remove the prefetched entry from the cache, + * and free it. Insert the deserialized entry into the cache. + * + * Note that the on disk image of the entry is not freed -- + * a pointer to it is stored in the deserialized entries' + * image_ptr field, and its image_up_to_date field is set to + * TRUE unless the entry is dirtied by the deserialize call. + * + * If the prefetched entry is a flush dependency child, + * destroy that flush dependency prior to calling the + * deserialize callback. If appropriate, the flush dependency + * relationship will be recreated by the cache client. + * + * If the prefetched entry is a flush dependency parent, + * destroy the flush dependency relationship with all its + * children. As all these children must be prefetched entries, + * recreate these flush dependency relationships with + * deserialized entry after it is inserted in the cache. + * + * Since deserializing a prefetched entry is semantically + * equivalent to a load, issue an entry loaded nofification + * if the notify callback is defined. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Note that *entry_ptr_ptr is undefined on failure. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr, + const H5C_class_t *type, haddr_t addr, void *udata) +{ + hbool_t dirty = FALSE; /* Flag indicating whether thing was + * dirtied during deserialize + */ + size_t len; /* Size of image in file */ + void *thing = NULL; /* Pointer to thing loaded */ + H5C_cache_entry_t *pf_entry_ptr; /* pointer to the prefetched entry */ + /* supplied in *entry_ptr_ptr. */ + H5C_cache_entry_t *ds_entry_ptr; /* Alias for thing loaded, as cache + * entry + */ + H5C_cache_entry_t **fd_children = NULL; /* Pointer to a dynamically */ + /* allocated array of pointers to */ + /* the flush dependency children of */ + /* the prefetched entry, or NULL if */ + /* that array does not exist. */ + unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); + int i; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* sanity checks */ + assert(f); + assert(f->shared); + assert(f->shared->cache); + assert(f->shared->cache == cache_ptr); + assert(entry_ptr_ptr); + assert(*entry_ptr_ptr); + pf_entry_ptr = *entry_ptr_ptr; + assert(pf_entry_ptr->type); + assert(pf_entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); + assert(pf_entry_ptr->prefetched); + assert(pf_entry_ptr->image_up_to_date); + assert(pf_entry_ptr->image_ptr); + assert(pf_entry_ptr->size > 0); + assert(pf_entry_ptr->addr == addr); + assert(type); + assert(type->id == pf_entry_ptr->prefetch_type_id); + assert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); + + /* verify absence of prohibited or unsupported type flag combinations */ + assert(!(type->flags & H5C__CLASS_SKIP_READS)); + + /* Can't see how skip reads could be usefully combined with + * either the speculative read flag. Hence disallow. + */ + assert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); + assert(H5_addr_defined(addr)); + assert(type->get_initial_load_size); + assert(type->deserialize); + + /* if *pf_entry_ptr is a flush dependency child, destroy all such + * relationships now. The client will restore the relationship(s) with + * the deserialized entry if appropriate. + */ + assert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents); + for (i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) { + assert(pf_entry_ptr->flush_dep_parent); + assert(pf_entry_ptr->flush_dep_parent[i]); + assert(pf_entry_ptr->flush_dep_parent[i]->flush_dep_nchildren > 0); + assert(pf_entry_ptr->fd_parent_addrs); + assert(pf_entry_ptr->flush_dep_parent[i]->addr == pf_entry_ptr->fd_parent_addrs[i]); + + if (H5C_destroy_flush_dependency(pf_entry_ptr->flush_dep_parent[i], pf_entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry parent flush dependency") + + pf_entry_ptr->fd_parent_addrs[i] = HADDR_UNDEF; + } /* end for */ + assert(pf_entry_ptr->flush_dep_nparents == 0); + + /* If *pf_entry_ptr is a flush dependency parent, destroy its flush + * dependency relationships with all its children (which must be + * prefetched entries as well). + * + * These flush dependency relationships will have to be restored + * after the deserialized entry is inserted into the cache in order + * to transfer these relationships to the new entry. Hence save the + * pointers to the flush dependency children of *pf_enty_ptr for later + * use. + */ + if (pf_entry_ptr->fd_child_count > 0) { + if (NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc( + sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd child ptr array") + + if (H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "can't destroy pf entry child flush dependency(s).") + } /* end if */ + + /* Since the size of the on disk image is known exactly, there is + * no need for either a call to the get_initial_load_size() callback, + * or retries if the H5C__CLASS_SPECULATIVE_LOAD_FLAG flag is set. + * Similarly, there is no need to clamp possible reads beyond + * EOF. + */ + len = pf_entry_ptr->size; + + /* Deserialize the prefetched on-disk image of the entry into the + * native memory form + */ + if (NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't deserialize image") + ds_entry_ptr = (H5C_cache_entry_t *)thing; + + /* In general, an entry should be clean just after it is loaded. + * + * However, when this code is used in the metadata cache, it is + * possible that object headers will be dirty at this point, as + * the deserialize function will alter object headers if necessary to + * fix an old bug. + * + * In the following assert: + * + * assert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); + * + * note that type ids 5 & 6 are associated with object headers in the + * metadata cache. + * + * When we get to using H5C for other purposes, we may wish to + * tighten up the assert so that the loophole only applies to the + * metadata cache. + * + * Note that at present, dirty can't be set to true with prefetched + * entries. However this may change, so include this functionality + * against that possibility. + * + * Also, note that it is possible for a prefetched entry to be dirty -- + * hence the value assigned to ds_entry_ptr->is_dirty below. + */ + + assert((dirty == FALSE) || (type->id == 5 || type->id == 6)); + + ds_entry_ptr->cache_ptr = f->shared->cache; + ds_entry_ptr->addr = addr; + ds_entry_ptr->size = len; + assert(ds_entry_ptr->size < H5C_MAX_ENTRY_SIZE); + ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr; + ds_entry_ptr->image_up_to_date = !dirty; + ds_entry_ptr->type = type; + ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty; + ds_entry_ptr->dirtied = FALSE; + ds_entry_ptr->is_protected = FALSE; + ds_entry_ptr->is_read_only = FALSE; + ds_entry_ptr->ro_ref_count = 0; + ds_entry_ptr->is_pinned = FALSE; + ds_entry_ptr->in_slist = FALSE; + ds_entry_ptr->flush_marker = FALSE; +#ifdef H5_HAVE_PARALLEL + ds_entry_ptr->clear_on_unprotect = FALSE; + ds_entry_ptr->flush_immediately = FALSE; + ds_entry_ptr->coll_access = FALSE; +#endif /* H5_HAVE_PARALLEL */ + ds_entry_ptr->flush_in_progress = FALSE; + ds_entry_ptr->destroy_in_progress = FALSE; + + ds_entry_ptr->ring = pf_entry_ptr->ring; + + /* Initialize flush dependency height fields */ + ds_entry_ptr->flush_dep_parent = NULL; + ds_entry_ptr->flush_dep_nparents = 0; + ds_entry_ptr->flush_dep_parent_nalloc = 0; + ds_entry_ptr->flush_dep_nchildren = 0; + ds_entry_ptr->flush_dep_ndirty_children = 0; + ds_entry_ptr->flush_dep_nunser_children = 0; + + /* Initialize fields supporting the hash table: */ + ds_entry_ptr->ht_next = NULL; + ds_entry_ptr->ht_prev = NULL; + ds_entry_ptr->il_next = NULL; + ds_entry_ptr->il_prev = NULL; + + /* Initialize fields supporting replacement policies: */ + ds_entry_ptr->next = NULL; + ds_entry_ptr->prev = NULL; +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + ds_entry_ptr->aux_next = NULL; + ds_entry_ptr->aux_prev = NULL; +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ +#ifdef H5_HAVE_PARALLEL + pf_entry_ptr->coll_next = NULL; + pf_entry_ptr->coll_prev = NULL; +#endif /* H5_HAVE_PARALLEL */ + + /* Initialize cache image related fields */ + ds_entry_ptr->include_in_image = FALSE; + ds_entry_ptr->lru_rank = 0; + ds_entry_ptr->image_dirty = FALSE; + ds_entry_ptr->fd_parent_count = 0; + ds_entry_ptr->fd_parent_addrs = NULL; + ds_entry_ptr->fd_child_count = pf_entry_ptr->fd_child_count; + ds_entry_ptr->fd_dirty_child_count = 0; + ds_entry_ptr->image_fd_height = 0; + ds_entry_ptr->prefetched = FALSE; + ds_entry_ptr->prefetch_type_id = 0; + ds_entry_ptr->age = 0; + ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; +#ifndef NDEBUG /* debugging field */ + ds_entry_ptr->serialization_count = 0; +#endif + + H5C__RESET_CACHE_ENTRY_STATS(ds_entry_ptr); + + /* Apply to to the newly deserialized entry */ + if (H5C__tag_entry(cache_ptr, ds_entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") + + /* We have successfully deserialized the prefetched entry. + * + * Before we return a pointer to the deserialized entry, we must remove + * the prefetched entry from the cache, discard it, and replace it with + * the deserialized entry. Note that we do not free the prefetched + * entries image, as that has been transferred to the deserialized + * entry. + * + * Also note that we have not yet restored any flush dependencies. This + * must wait until the deserialized entry is inserted in the cache. + * + * To delete the prefetched entry from the cache: + * + * 1) Set pf_entry_ptr->image_ptr to NULL. Since we have already + * transferred the buffer containing the image to *ds_entry_ptr, + * this is not a memory leak. + * + * 2) Call H5C__flush_single_entry() with the H5C__FLUSH_INVALIDATE_FLAG + * and H5C__FLUSH_CLEAR_ONLY_FLAG flags set. + */ + pf_entry_ptr->image_ptr = NULL; + + if (pf_entry_ptr->is_dirty) { + assert(((cache_ptr->slist_enabled) && (pf_entry_ptr->in_slist)) || + ((!cache_ptr->slist_enabled) && (!pf_entry_ptr->in_slist))); + + flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; + } /* end if */ + + if (H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't expunge prefetched entry") + +#ifndef NDEGUG /* verify deletion */ + H5C__SEARCH_INDEX(cache_ptr, addr, pf_entry_ptr, FAIL); + + assert(NULL == pf_entry_ptr); +#endif + + /* Insert the deserialized entry into the cache. */ + H5C__INSERT_IN_INDEX(cache_ptr, ds_entry_ptr, FAIL); + + assert(!ds_entry_ptr->in_slist); + if (ds_entry_ptr->is_dirty) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, ds_entry_ptr, FAIL); + + H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, ds_entry_ptr, FAIL); + + /* Deserializing a prefetched entry is the conceptual equivalent of + * loading it from file. If the deserialized entry has a notify callback, + * send an "after load" notice now that the deserialized entry is fully + * integrated into the cache. + */ + if (ds_entry_ptr->type->notify && + (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry loaded into cache") + + /* Restore flush dependencies with the flush dependency children of + * of the prefetched entry. Note that we must protect *ds_entry_ptr + * before the call to avoid triggering sanity check failures, and + * then unprotect it afterwards. + */ + i = 0; + if (fd_children != NULL) { + H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, ds_entry_ptr, FAIL); + ds_entry_ptr->is_protected = TRUE; + while (fd_children[i] != NULL) { + /* Sanity checks */ + assert((fd_children[i])->prefetched); + assert((fd_children[i])->fd_parent_count > 0); + assert((fd_children[i])->fd_parent_addrs); + +#ifndef NDEBUG + { + int j; + hbool_t found; + + j = 0; + found = FALSE; + while ((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { + if ((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) + found = TRUE; + + j++; + } /* end while */ + assert(found); + } +#endif + + if (H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore child flush dependency") + + i++; + } /* end while */ + + H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, ds_entry_ptr, FAIL); + ds_entry_ptr->is_protected = FALSE; + } /* end if ( fd_children != NULL ) */ + assert((unsigned)i == ds_entry_ptr->fd_child_count); + + ds_entry_ptr->fd_child_count = 0; + H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr); + + /* finally, pass ds_entry_ptr back to the caller */ + *entry_ptr_ptr = ds_entry_ptr; + +done: + if (fd_children) + fd_children = (H5C_cache_entry_t **)H5MM_xfree((void *)fd_children); + + /* Release resources on error */ + if (FAIL == ret_value) + if (thing && type->free_icr(thing) < 0) + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed"); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__deserialize_prefetched_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C_insert_entry + * + * Purpose: Adds the specified thing to the cache. The thing need not + * exist on disk yet, but it must have an address and disk + * space reserved. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags) +{ + H5C_t *cache_ptr; + H5AC_ring_t ring = H5C_RING_UNDEFINED; + hbool_t insert_pinned; + hbool_t flush_last; +#ifdef H5_HAVE_PARALLEL + hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ +#endif /* H5_HAVE_PARALLEL */ + hbool_t set_flush_marker; + hbool_t write_permitted = TRUE; + size_t empty_space; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *test_entry_ptr; + hbool_t entry_tagged = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + assert(f); + assert(f->shared); + + cache_ptr = f->shared->cache; + + assert(cache_ptr); + assert(type); + assert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); + assert(type->image_len); + assert(H5_addr_defined(addr)); + assert(thing); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + /* no need to verify that entry is not already in the index as */ + /* we already make that check below. */ + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); + insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); + + /* Get the ring type from the API context */ + ring = H5CX_get_ring(); + + entry_ptr = (H5C_cache_entry_t *)thing; + + /* verify that the new entry isn't already in the hash table -- scream + * and die if it is. + */ + + H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL); + + if (test_entry_ptr != NULL) { + if (test_entry_ptr == entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "entry already in cache") + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "duplicate entry in cache") + } /* end if */ + + entry_ptr->cache_ptr = cache_ptr; + entry_ptr->addr = addr; + entry_ptr->type = type; + + entry_ptr->image_ptr = NULL; + entry_ptr->image_up_to_date = FALSE; + + entry_ptr->is_protected = FALSE; + entry_ptr->is_read_only = FALSE; + entry_ptr->ro_ref_count = 0; + + entry_ptr->is_pinned = insert_pinned; + entry_ptr->pinned_from_client = insert_pinned; + entry_ptr->pinned_from_cache = FALSE; + entry_ptr->flush_me_last = flush_last; + + /* newly inserted entries are assumed to be dirty */ + entry_ptr->is_dirty = TRUE; + + /* not protected, so can't be dirtied */ + entry_ptr->dirtied = FALSE; + + /* Retrieve the size of the thing */ + if ((type->image_len)(thing, &(entry_ptr->size)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGETSIZE, FAIL, "can't get size of thing") + assert(entry_ptr->size > 0 && entry_ptr->size < H5C_MAX_ENTRY_SIZE); + + entry_ptr->in_slist = FALSE; + +#ifdef H5_HAVE_PARALLEL + entry_ptr->clear_on_unprotect = FALSE; + entry_ptr->flush_immediately = FALSE; +#endif /* H5_HAVE_PARALLEL */ + + entry_ptr->flush_in_progress = FALSE; + entry_ptr->destroy_in_progress = FALSE; + + entry_ptr->ring = ring; + + /* Initialize flush dependency fields */ + entry_ptr->flush_dep_parent = NULL; + entry_ptr->flush_dep_nparents = 0; + entry_ptr->flush_dep_parent_nalloc = 0; + entry_ptr->flush_dep_nchildren = 0; + entry_ptr->flush_dep_ndirty_children = 0; + entry_ptr->flush_dep_nunser_children = 0; + + entry_ptr->ht_next = NULL; + entry_ptr->ht_prev = NULL; + entry_ptr->il_next = NULL; + entry_ptr->il_prev = NULL; + + entry_ptr->next = NULL; + entry_ptr->prev = NULL; + +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + entry_ptr->aux_next = NULL; + entry_ptr->aux_prev = NULL; +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + +#ifdef H5_HAVE_PARALLEL + entry_ptr->coll_next = NULL; + entry_ptr->coll_prev = NULL; +#endif /* H5_HAVE_PARALLEL */ + + /* initialize cache image related fields */ + entry_ptr->include_in_image = FALSE; + entry_ptr->lru_rank = 0; + entry_ptr->image_dirty = FALSE; + entry_ptr->fd_parent_count = 0; + entry_ptr->fd_parent_addrs = NULL; + entry_ptr->fd_child_count = 0; + entry_ptr->fd_dirty_child_count = 0; + entry_ptr->image_fd_height = 0; + entry_ptr->prefetched = FALSE; + entry_ptr->prefetch_type_id = 0; + entry_ptr->age = 0; + entry_ptr->prefetched_dirty = FALSE; +#ifndef NDEBUG /* debugging field */ + entry_ptr->serialization_count = 0; +#endif + + /* initialize tag list fields */ + entry_ptr->tl_next = NULL; + entry_ptr->tl_prev = NULL; + entry_ptr->tag_info = NULL; + + /* Apply tag to newly inserted entry */ + if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") + entry_tagged = TRUE; + + H5C__RESET_CACHE_ENTRY_STATS(entry_ptr); + + if (cache_ptr->flash_size_increase_possible && + (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) + if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__flash_increase_cache_size failed") + + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; + else + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + + if (cache_ptr->evictions_enabled && + (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || + (((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)))) { + size_t space_needed; + + if (empty_space <= entry_ptr->size) + cache_ptr->cache_full = TRUE; + + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "Can't get write_permitted") + } /* end if */ + else + write_permitted = cache_ptr->write_permitted; + + assert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); + space_needed = entry_ptr->size; + if (space_needed > cache_ptr->max_cache_size) + space_needed = cache_ptr->max_cache_size; + + /* Note that space_needed is just the amount of space that + * needed to insert the new entry without exceeding the cache + * size limit. The subsequent call to H5C__make_space_in_cache() + * may evict the entries required to free more or less space + * depending on conditions. It MAY be less if the cache is + * currently undersized, or more if the cache is oversized. + * + * The cache can exceed its maximum size limit via the following + * mechanisms: + * + * First, it is possible for the cache to grow without + * bound as long as entries are protected and not unprotected. + * + * Second, when writes are not permitted it is also possible + * for the cache to grow without bound. + * + * Finally, we usually don't check to see if the cache is + * oversized at the end of an unprotect. As a result, it is + * possible to have a vastly oversized cache with no protected + * entries as long as all the protects precede the unprotects. + */ + + if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C__make_space_in_cache failed") + } /* end if */ + + H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); + + /* New entries are presumed to be dirty */ + assert(entry_ptr->is_dirty); + entry_ptr->flush_marker = set_flush_marker; + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, FAIL); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed just before done") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + /* If the entry's type has a 'notify' callback send a 'after insertion' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_INSERT, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry inserted into cache") + + H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr); + +#ifdef H5_HAVE_PARALLEL + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + coll_access = H5F_get_coll_metadata_reads(f); + + entry_ptr->coll_access = coll_access; + if (coll_access) { + H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, FAIL); + + /* Make sure the size of the collective entries in the cache remain in check */ + if (H5P_USER_TRUE == H5F_COLL_MD_READ(f)) { + if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) { + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") + } /* end if */ + } /* end if */ + else { + if (cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) { + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") + } /* end if */ + } /* end else */ + } /* end if */ +#endif + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + if (ret_value < 0 && entry_tagged) + if (H5C__untag_entry(cache_ptr, entry_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list"); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_insert_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C_mark_entry_dirty + * + * Purpose: Mark a pinned or protected entry as dirty. The target entry + * MUST be either pinned or protected, and MAY be both. + * + * In the protected case, this call is the functional + * equivalent of setting the H5C__DIRTIED_FLAG on an unprotect + * call. + * + * In the pinned but not protected case, if the entry is not + * already dirty, the function places function marks the entry + * dirty and places it on the skip list. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_mark_entry_dirty(void *thing) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry_ptr); + assert(H5_addr_defined(entry_ptr->addr)); + cache_ptr = entry_ptr->cache_ptr; + assert(cache_ptr); + + if (entry_ptr->is_protected) { + assert(!((entry_ptr)->is_read_only)); + + /* set the dirtied flag */ + entry_ptr->dirtied = TRUE; + + /* reset image_up_to_date */ + if (entry_ptr->image_up_to_date) { + entry_ptr->image_up_to_date = FALSE; + + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + } /* end if */ + else if (entry_ptr->is_pinned) { + hbool_t was_clean; /* Whether the entry was previously clean */ + hbool_t image_was_up_to_date; + + /* Remember previous dirty status */ + was_clean = !entry_ptr->is_dirty; + + /* Check if image is up to date */ + image_was_up_to_date = entry_ptr->image_up_to_date; + + /* Mark the entry as dirty if it isn't already */ + entry_ptr->is_dirty = TRUE; + entry_ptr->image_up_to_date = FALSE; + + /* Modify cache data structures */ + if (was_clean) + H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr, FAIL); + if (!entry_ptr->in_slist) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + + /* Update stats for entry being marked dirty */ + H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr); + + /* Check for entry changing status and do notifications, etc. */ + if (was_clean) { + /* If the entry's type has a 'notify' callback send a 'entry dirtied' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") + + /* Propagate the dirty flag up the flush dependency chain if appropriate */ + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") + } /* end if */ + if (image_was_up_to_date) + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Entry is neither pinned nor protected??") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_mark_entry_dirty() */ + +/*------------------------------------------------------------------------- + * Function: H5C_mark_entry_clean + * + * Purpose: Mark a pinned entry as clean. The target entry MUST be pinned. + * + * If the entry is not + * already clean, the function places function marks the entry + * clean and removes it from the skip list. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_mark_entry_clean(void *_thing) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry_ptr); + assert(H5_addr_defined(entry_ptr->addr)); + cache_ptr = entry_ptr->cache_ptr; + assert(cache_ptr); + + /* Operate on pinned entry */ + if (entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "entry is protected") + else if (entry_ptr->is_pinned) { + hbool_t was_dirty; /* Whether the entry was previously dirty */ + + /* Remember previous dirty status */ + was_dirty = entry_ptr->is_dirty; + + /* Mark the entry as clean if it isn't already */ + entry_ptr->is_dirty = FALSE; + + /* Also reset the 'flush_marker' flag, since the entry shouldn't be flushed now */ + entry_ptr->flush_marker = FALSE; + + /* Modify cache data structures */ + if (was_dirty) + H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr, FAIL); + if (entry_ptr->in_slist) + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE, FAIL); + + /* Update stats for entry being marked clean */ + H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr); + + /* Check for entry changing status and do notifications, etc. */ + if (was_dirty) { + /* If the entry's type has a 'notify' callback send a 'entry cleaned' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") + + /* Propagate the clean up the flush dependency chain, if appropriate */ + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Can't propagate flush dep clean") + } /* end if */ + } /* end if */ + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "Entry is not pinned??") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_mark_entry_clean() */ + +/*------------------------------------------------------------------------- + * Function: H5C_mark_entry_unserialized + * + * Purpose: Mark a pinned or protected entry as unserialized. The target + * entry MUST be either pinned or protected, and MAY be both. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_mark_entry_unserialized(void *thing) +{ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry); + assert(H5_addr_defined(entry->addr)); + + if (entry->is_protected || entry->is_pinned) { + assert(!entry->is_read_only); + + /* Reset image_up_to_date */ + if (entry->image_up_to_date) { + entry->image_up_to_date = FALSE; + + if (entry->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + } /* end if */ + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, + "Entry to unserialize is neither pinned nor protected??") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_mark_entry_unserialized() */ + +/*------------------------------------------------------------------------- + * Function: H5C_mark_entry_serialized + * + * Purpose: Mark a pinned entry as serialized. The target entry MUST be + * pinned. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_mark_entry_serialized(void *_thing) +{ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry); + assert(H5_addr_defined(entry->addr)); + + /* Operate on pinned entry */ + if (entry->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "entry is protected") + else if (entry->is_pinned) { + /* Check for entry changing status and do notifications, etc. */ + if (!entry->image_up_to_date) { + /* Set the image_up_to_date flag */ + entry->image_up_to_date = TRUE; + + /* Propagate the serialize up the flush dependency chain, if appropriate */ + if (entry->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_serialized(entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, + "Can't propagate flush dep serialize") + } /* end if */ + } /* end if */ + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "Entry is not pinned??") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_mark_entry_serialized() */ + +/*------------------------------------------------------------------------- + * Function: H5C_move_entry + * + * Purpose: Use this function to notify the cache that an entry's + * file address changed. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, haddr_t new_addr) +{ + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *test_entry_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + assert(cache_ptr); + assert(type); + assert(H5_addr_defined(old_addr)); + assert(H5_addr_defined(new_addr)); + assert(H5_addr_ne(old_addr, new_addr)); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + H5C__SEARCH_INDEX(cache_ptr, old_addr, entry_ptr, FAIL); + + if (entry_ptr == NULL || entry_ptr->type != type) + /* the old item doesn't exist in the cache, so we are done. */ + HGOTO_DONE(SUCCEED); + + assert(entry_ptr->addr == old_addr); + assert(entry_ptr->type == type); + + /* Check for R/W status, otherwise error */ + /* (Moving a R/O entry would mark it dirty, which shouldn't + * happen. QAK - 2016/12/02) + */ + if (entry_ptr->is_read_only) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "can't move R/O entry") + + H5C__SEARCH_INDEX(cache_ptr, new_addr, test_entry_ptr, FAIL); + + if (test_entry_ptr != NULL) { /* we are hosed */ + if (test_entry_ptr->type == type) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "target already moved & reinserted???") + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTMOVE, FAIL, "new address already in use?") + } /* end if */ + + /* If we get this far we have work to do. Remove *entry_ptr from + * the hash table (and skip list if necessary), change its address to the + * new address, mark it as dirty (if it isn't already) and then re-insert. + * + * Update the replacement policy for a hit to avoid an eviction before + * the moved entry is touched. Update stats for a move. + * + * Note that we do not check the size of the cache, or evict anything. + * Since this is a simple re-name, cache size should be unaffected. + * + * Check to see if the target entry is in the process of being destroyed + * before we delete from the index, etc. If it is, all we do is + * change the addr. If the entry is only in the process of being flushed, + * don't mark it as dirty either, lest we confuse the flush call back. + */ + if (!entry_ptr->destroy_in_progress) { + H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL); + + if (entry_ptr->in_slist) { + assert(cache_ptr->slist_ptr); + H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, FALSE, FAIL); + } /* end if */ + } /* end if */ + + entry_ptr->addr = new_addr; + + if (!entry_ptr->destroy_in_progress) { + hbool_t was_dirty; /* Whether the entry was previously dirty */ + + /* Remember previous dirty status */ + was_dirty = entry_ptr->is_dirty; + + /* Mark the entry as dirty if it isn't already */ + entry_ptr->is_dirty = TRUE; + + /* This shouldn't be needed, but it keeps the test code happy */ + if (entry_ptr->image_up_to_date) { + entry_ptr->image_up_to_date = FALSE; + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + + /* Modify cache data structures */ + H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL); + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + + /* Skip some actions if we're in the middle of flushing the entry */ + if (!entry_ptr->flush_in_progress) { + /* Update the replacement policy for the entry */ + H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, FAIL); + + /* Check for entry changing status and do notifications, etc. */ + if (!was_dirty) { + /* If the entry's type has a 'notify' callback send a 'entry dirtied' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag set") + + /* Propagate the dirty flag up the flush dependency chain if appropriate */ + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, + "Can't propagate flush dep dirty flag") + } /* end if */ + } /* end if */ + } /* end if */ + + H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr); + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_move_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C_resize_entry + * + * Purpose: Resize a pinned or protected entry. + * + * Resizing an entry dirties it, so if the entry is not + * already dirty, the function places the entry on the + * skip list. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_resize_entry(void *thing, size_t new_size) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry_ptr); + assert(H5_addr_defined(entry_ptr->addr)); + cache_ptr = entry_ptr->cache_ptr; + assert(cache_ptr); + + /* Check for usage errors */ + if (new_size <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "New size is non-positive") + if (!(entry_ptr->is_pinned || entry_ptr->is_protected)) + HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, FAIL, "Entry isn't pinned or protected??") + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + /* update for change in entry size if necessary */ + if (entry_ptr->size != new_size) { + hbool_t was_clean; + + /* make note of whether the entry was clean to begin with */ + was_clean = !entry_ptr->is_dirty; + + /* mark the entry as dirty if it isn't already */ + entry_ptr->is_dirty = TRUE; + + /* Reset the image up-to-date status */ + if (entry_ptr->image_up_to_date) { + entry_ptr->image_up_to_date = FALSE; + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + + /* Release the current image */ + if (entry_ptr->image_ptr) + entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr); + + /* do a flash cache size increase if appropriate */ + if (cache_ptr->flash_size_increase_possible) { + if (new_size > entry_ptr->size) { + size_t size_increase; + + size_increase = new_size - entry_ptr->size; + if (size_increase >= cache_ptr->flash_size_increase_threshold) + if (H5C__flash_increase_cache_size(cache_ptr, entry_ptr->size, new_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "flash cache increase failed") + } + } + + /* update the pinned and/or protected entry list */ + if (entry_ptr->is_pinned) + H5C__DLL_UPDATE_FOR_SIZE_CHANGE(cache_ptr->pel_len, cache_ptr->pel_size, entry_ptr->size, + new_size, FAIL) + if (entry_ptr->is_protected) + H5C__DLL_UPDATE_FOR_SIZE_CHANGE(cache_ptr->pl_len, cache_ptr->pl_size, entry_ptr->size, new_size, + FAIL) + +#ifdef H5_HAVE_PARALLEL + 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, FAIL) +#endif /* H5_HAVE_PARALLEL */ + + /* update statistics just before changing the entry size */ + H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size); + + /* update the hash table */ + H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size, entry_ptr, was_clean, FAIL); + + /* if the entry is in the skip list, update that too */ + if (entry_ptr->in_slist) + H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_size); + + /* finally, update the entry size proper */ + entry_ptr->size = new_size; + + if (!entry_ptr->in_slist) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + + if (entry_ptr->is_pinned) + H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr); + + /* Check for entry changing status and do notifications, etc. */ + if (was_clean) { + /* If the entry's type has a 'notify' callback send a 'entry dirtied' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") + + /* Propagate the dirty flag up the flush dependency chain if appropriate */ + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") + } /* end if */ + } /* end if */ + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_resize_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C_pin_protected_entry() + * + * Purpose: Pin a protected cache entry. The entry must be protected + * at the time of call, and must be unpinned. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_pin_protected_entry(void *thing) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; /* Pointer to entry to pin */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry_ptr); + assert(H5_addr_defined(entry_ptr->addr)); + cache_ptr = entry_ptr->cache_ptr; + assert(cache_ptr); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + /* Only protected entries can be pinned */ + if (!entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Entry isn't protected") + + /* Pin the entry from a client */ + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_pin_protected_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C_protect + * + * Purpose: If the target entry is not in the cache, load it. If + * necessary, attempt to evict one or more entries to keep + * the cache within its maximum size. + * + * Mark the target entry as protected, and return its address + * to the caller. The caller must call H5C_unprotect() when + * finished with the entry. + * + * While it is protected, the entry may not be either evicted + * or flushed -- nor may it be accessed by another call to + * H5C_protect. Any attempt to do so will result in a failure. + * + * Return: Success: Ptr to the desired entry + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags) +{ + H5C_t *cache_ptr; + H5AC_ring_t ring = H5C_RING_UNDEFINED; + hbool_t hit; + hbool_t have_write_permitted = FALSE; + hbool_t read_only = FALSE; + hbool_t flush_last; +#ifdef H5_HAVE_PARALLEL + hbool_t coll_access = FALSE; /* whether access to the cache entry is done collectively */ +#endif /* H5_HAVE_PARALLEL */ + hbool_t write_permitted = FALSE; + hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */ + size_t empty_space; + void *thing; + H5C_cache_entry_t *entry_ptr; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check args */ + assert(f); + assert(f->shared); + cache_ptr = f->shared->cache; + assert(cache_ptr); + assert(type); + assert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); + assert(H5_addr_defined(addr)); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + /* 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, NULL, "Can't load cache image") + } /* end if */ + + read_only = ((flags & H5C__READ_ONLY_FLAG) != 0); + flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); + + /* Get the ring type from the API context */ + ring = H5CX_get_ring(); + +#ifdef H5_HAVE_PARALLEL + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) + coll_access = H5F_get_coll_metadata_reads(f); +#endif /* H5_HAVE_PARALLEL */ + + /* first check to see if the target is in cache */ + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, NULL); + + if (entry_ptr != NULL) { + if (entry_ptr->ring != ring) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "ring type mismatch occurred for cache entry") + + if (entry_ptr->prefetched) { + /* This call removes the prefetched entry from the cache, + * and replaces it with an entry deserialized from the + * image of the prefetched entry. + */ + if (H5C__deserialize_prefetched_entry(f, cache_ptr, &entry_ptr, type, addr, udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't deserialize prefetched entry") + + assert(!entry_ptr->prefetched); + assert(entry_ptr->addr == addr); + } /* end if */ + + /* Check for trying to load the wrong type of entry from an address */ + if (entry_ptr->type != type) + HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") + +#ifdef H5_HAVE_PARALLEL + /* If this is a collective metadata read, the entry is not marked as + * collective, and is clean, it is possible that other processes will + * not have it in its cache and will expect a bcast of the entry from + * process 0. So process 0 will bcast the entry to all other ranks. + * Ranks that _do_ have the entry in their cache still have to + * participate in the bcast. + */ + if (coll_access) { + if (!entry_ptr->is_dirty && !entry_ptr->coll_access) { + MPI_Comm comm; /* File MPI Communicator */ + int mpi_code; /* MPI error code */ + int buf_size; + + if (MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed") + + if (entry_ptr->image_ptr == NULL) { + int mpi_rank; + + if ((mpi_rank = H5F_mpi_get_rank(f)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank") + + if (NULL == (entry_ptr->image_ptr = H5MM_malloc(entry_ptr->size + H5C_IMAGE_EXTRA_SPACE))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, + "memory allocation failed for on disk image buffer") +#if H5C_DO_MEMORY_SANITY_CHECKS + H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, + H5C_IMAGE_EXTRA_SPACE); +#endif /* H5C_DO_MEMORY_SANITY_CHECKS */ + if (0 == mpi_rank && H5C__generate_image(f, cache_ptr, entry_ptr) < 0) + /* If image generation fails, push an error but + * still participate in the following MPI_Bcast + */ + HDONE_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't generate entry's image"); + } /* end if */ + assert(entry_ptr->image_ptr); + + H5_CHECKED_ASSIGN(buf_size, int, entry_ptr->size, size_t); + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm))) + HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) + + /* Mark the entry as collective and insert into the collective list */ + entry_ptr->coll_access = TRUE; + H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL); + } /* end if */ + else if (entry_ptr->coll_access) + H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, NULL); + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + +#ifdef H5C_DO_TAGGING_SANITY_CHECKS + { + /* Verify tag value */ + if (cache_ptr->ignore_tags != TRUE) { + haddr_t tag; /* Tag value */ + + /* The entry is already in the cache, but make sure that the tag value + * is still legal. This will ensure that had the entry NOT been in the + * cache, tagging was still set up correctly and it would have received + * a legal tag value after getting loaded from disk. + */ + + /* Get the tag */ + tag = H5CX_get_tag(); + + if (H5C_verify_tag(entry_ptr->type->id, tag) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "tag verification failed") + } /* end if */ + } +#endif + + hit = TRUE; + thing = (void *)entry_ptr; + } + else { + /* must try to load the entry from disk. */ + hit = FALSE; + if (NULL == (thing = H5C__load_entry(f, +#ifdef H5_HAVE_PARALLEL + coll_access, +#endif /* H5_HAVE_PARALLEL */ + type, addr, udata))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't load entry") + + entry_ptr = (H5C_cache_entry_t *)thing; + cache_ptr->entries_loaded_counter++; + + entry_ptr->ring = ring; +#ifdef H5_HAVE_PARALLEL + if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && entry_ptr->coll_access) + H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL); +#endif /* H5_HAVE_PARALLEL */ + + /* Apply tag to newly protected entry */ + if (H5C__tag_entry(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Cannot tag metadata entry") + + /* If the entry is very large, and we are configured to allow it, + * we may wish to perform a flash cache size increase. + */ + if (cache_ptr->flash_size_increase_possible && + (entry_ptr->size > cache_ptr->flash_size_increase_threshold)) + if (H5C__flash_increase_cache_size(cache_ptr, 0, entry_ptr->size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__flash_increase_cache_size failed") + + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; + else + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + + /* try to free up if necceary and if evictions are permitted. Note + * that if evictions are enabled, we will call H5C__make_space_in_cache() + * regardless if the min_free_space requirement is not met. + */ + if (cache_ptr->evictions_enabled && + (((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size))) { + + size_t space_needed; + + if (empty_space <= entry_ptr->size) + cache_ptr->cache_full = TRUE; + + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted 1") + else + have_write_permitted = TRUE; + } /* end if */ + else { + write_permitted = cache_ptr->write_permitted; + have_write_permitted = TRUE; + } /* end else */ + + assert(entry_ptr->size <= H5C_MAX_ENTRY_SIZE); + space_needed = entry_ptr->size; + if (space_needed > cache_ptr->max_cache_size) + space_needed = cache_ptr->max_cache_size; + + /* Note that space_needed is just the amount of space that + * needed to insert the new entry without exceeding the cache + * size limit. The subsequent call to H5C__make_space_in_cache() + * may evict the entries required to free more or less space + * depending on conditions. It MAY be less if the cache is + * currently undersized, or more if the cache is oversized. + * + * The cache can exceed its maximum size limit via the following + * mechanisms: + * + * First, it is possible for the cache to grow without + * bound as long as entries are protected and not unprotected. + * + * Second, when writes are not permitted it is also possible + * for the cache to grow without bound. + * + * Third, the user may choose to disable evictions -- causing + * the cache to grow without bound until evictions are + * re-enabled. + * + * Finally, we usually don't check to see if the cache is + * oversized at the end of an unprotect. As a result, it is + * possible to have a vastly oversized cache with no protected + * entries as long as all the protects precede the unprotects. + */ + if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") + } /* end if */ + + /* Insert the entry in the hash table. + * + * ******************************************* + * + * Set the flush_me_last field + * of the newly loaded entry before inserting it into the + * index. Must do this, as the index tracked the number of + * entries with the flush_last field set, but assumes that + * the field will not change after insertion into the index. + * + * Note that this means that the H5C__FLUSH_LAST_FLAG flag + * is ignored if the entry is already in cache. + */ + entry_ptr->flush_me_last = flush_last; + + H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, NULL); + if (entry_ptr->is_dirty && !entry_ptr->in_slist) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, NULL); + + /* insert the entry in the data structures used by the replacement + * policy. We are just going to take it out again when we update + * the replacement policy for a protect, but this simplifies the + * code. If we do this often enough, we may want to optimize this. + */ + H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, NULL); + + /* Record that the entry was loaded, to trigger a notify callback later */ + /* (After the entry is fully added to the cache) */ + was_loaded = TRUE; + } /* end else */ + + assert(entry_ptr->addr == addr); + assert(entry_ptr->type == type); + + if (entry_ptr->is_protected) { + if (read_only && entry_ptr->is_read_only) { + assert(entry_ptr->ro_ref_count > 0); + (entry_ptr->ro_ref_count)++; + } /* end if */ + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Target already protected & not read only?!?") + } /* end if */ + else { + H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, NULL); + + entry_ptr->is_protected = TRUE; + if (read_only) { + entry_ptr->is_read_only = TRUE; + entry_ptr->ro_ref_count = 1; + } /* end if */ + entry_ptr->dirtied = FALSE; + } /* end else */ + + H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit); + H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit); + + ret_value = thing; + + if (cache_ptr->evictions_enabled && + (cache_ptr->size_decreased || + (cache_ptr->resize_enabled && (cache_ptr->cache_accesses >= cache_ptr->resize_ctl.epoch_length)))) { + + if (!have_write_permitted) { + if (cache_ptr->check_write_permitted != NULL) { + if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Can't get write_permitted") + else + have_write_permitted = TRUE; + } + else { + write_permitted = cache_ptr->write_permitted; + have_write_permitted = TRUE; + } + } + + if (cache_ptr->resize_enabled && (cache_ptr->cache_accesses >= cache_ptr->resize_ctl.epoch_length)) + if (H5C__auto_adjust_cache_size(f, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "Cache auto-resize failed") + + if (cache_ptr->size_decreased) { + cache_ptr->size_decreased = FALSE; + + /* check to see if the cache is now oversized due to the cache + * size reduction. If it is, try to evict enough entries to + * bring the cache size down to the current maximum cache size. + * + * Also, if the min_clean_size requirement is not met, we + * should also call H5C__make_space_in_cache() to bring us + * into compliance. + */ + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; + else + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + + if ((cache_ptr->index_size > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < cache_ptr->min_clean_size)) { + + if (cache_ptr->index_size > cache_ptr->max_cache_size) + cache_ptr->cache_full = TRUE; + + if (H5C__make_space_in_cache(f, (size_t)0, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C__make_space_in_cache failed") + } + } /* end if */ + } + + /* If we loaded the entry and the entry's type has a 'notify' callback, send + * an 'after load' notice now that the entry is fully integrated into + * the cache and protected. We must wait until it is protected so it is not + * evicted during the notify callback. + */ + if (was_loaded) + /* If the entry's type has a 'notify' callback send a 'after load' + * notice now that the entry is fully integrated into the cache. + */ + if (entry_ptr->type->notify && (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, NULL, + "can't notify client about entry inserted into cache") + +#ifdef H5_HAVE_PARALLEL + /* Make sure the size of the collective entries in the cache remain in check */ + if (coll_access) { + if (H5P_USER_TRUE == H5F_COLL_MD_READ(f)) { + if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") + } /* end if */ + else { + if (cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") + } /* end else */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_protect() */ + +/*------------------------------------------------------------------------- + * Function: H5C_unpin_entry() + * + * Purpose: Unpin a cache entry. The entry can be either protected or + * unprotected at the time of call, but must be pinned. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_unpin_entry(void *_entry_ptr) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_entry_ptr; /* Pointer to entry to unpin */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + assert(entry_ptr); + cache_ptr = entry_ptr->cache_ptr; + assert(cache_ptr); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + /* Unpin the entry */ + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry from client") + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_unpin_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C_unprotect + * + * Purpose: Undo an H5C_protect() call -- specifically, mark the + * entry as unprotected, remove it from the protected list, + * and give it back to the replacement policy. + * + * The TYPE and ADDR arguments must be the same as those in + * the corresponding call to H5C_protect() and the THING + * argument must be the value returned by that call to + * H5C_protect(). + * + * Return: Non-negative on success/Negative on failure + * + * If the deleted flag is TRUE, simply remove the target entry + * from the cache, clear it, and free it without writing it to + * disk. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) +{ + H5C_t *cache_ptr; + hbool_t deleted; + hbool_t dirtied; + hbool_t set_flush_marker; + hbool_t pin_entry; + hbool_t unpin_entry; + hbool_t free_file_space; + hbool_t take_ownership; + hbool_t was_clean; +#ifdef H5_HAVE_PARALLEL + hbool_t clear_entry = FALSE; +#endif /* H5_HAVE_PARALLEL */ + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *test_entry_ptr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + deleted = ((flags & H5C__DELETED_FLAG) != 0); + dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); + set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); + pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); + free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); + + assert(f); + assert(f->shared); + + cache_ptr = f->shared->cache; + + assert(cache_ptr); + assert(H5_addr_defined(addr)); + assert(thing); + assert(!(pin_entry && unpin_entry)); + + /* deleted flag must accompany free_file_space */ + assert((!free_file_space) || (deleted)); + + /* deleted flag must accompany take_ownership */ + assert((!take_ownership) || (deleted)); + + /* can't have both free_file_space & take_ownership */ + assert(!(free_file_space && take_ownership)); + + entry_ptr = (H5C_cache_entry_t *)thing; + assert(entry_ptr->addr == addr); + + /* also set the dirtied variable if the dirtied field is set in + * the entry. + */ + dirtied |= entry_ptr->dirtied; + was_clean = !(entry_ptr->is_dirty); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + /* if the entry has multiple read only protects, just decrement + * the ro_ref_counter. Don't actually unprotect until the ref count + * drops to zero. + */ + if (entry_ptr->ro_ref_count > 1) { + /* Sanity check */ + assert(entry_ptr->is_protected); + assert(entry_ptr->is_read_only); + + if (dirtied) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") + + /* Reduce the RO ref count */ + (entry_ptr->ro_ref_count)--; + + /* Pin or unpin the entry as requested. */ + if (pin_entry) { + /* Pin the entry from a client */ + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") + } + else if (unpin_entry) { + /* Unpin the entry from a client */ + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") + } /* end if */ + } + else { + if (entry_ptr->is_read_only) { + /* Sanity check */ + assert(entry_ptr->ro_ref_count == 1); + + if (dirtied) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") + + entry_ptr->is_read_only = FALSE; + entry_ptr->ro_ref_count = 0; + } /* end if */ + +#ifdef H5_HAVE_PARALLEL + /* When the H5C code is used to implement the metadata cache in the + * PHDF5 case, only the cache on process 0 is allowed to write to file. + * All the other metadata caches must hold dirty entries until they + * are told that the entries are clean. + * + * The clear_on_unprotect flag in the H5C_cache_entry_t structure + * exists to deal with the case in which an entry is protected when + * its cache receives word that the entry is now clean. In this case, + * the clear_on_unprotect flag is set, and the entry is flushed with + * the H5C__FLUSH_CLEAR_ONLY_FLAG. + * + * All this is a bit awkward, but until the metadata cache entries + * are contiguous, with only one dirty flag, we have to let the supplied + * functions deal with the resetting the is_dirty flag. + */ + if (entry_ptr->clear_on_unprotect) { + /* Sanity check */ + assert(entry_ptr->is_dirty); + + entry_ptr->clear_on_unprotect = FALSE; + if (!dirtied) + clear_entry = TRUE; + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + + if (!entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Entry already unprotected??") + + /* Mark the entry as dirty if appropriate */ + entry_ptr->is_dirty = (entry_ptr->is_dirty || dirtied); + if (dirtied && entry_ptr->image_up_to_date) { + entry_ptr->image_up_to_date = FALSE; + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_unserialized(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "Can't propagate serialization status to fd parents") + } /* end if */ + + /* Check for newly dirtied entry */ + if (was_clean && entry_ptr->is_dirty) { + /* Update index for newly dirtied entry */ + H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr, FAIL); + + /* If the entry's type has a 'notify' callback send a + * 'entry dirtied' notice now that the entry is fully + * integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_DIRTIED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry dirty flag set") + + /* Propagate the flush dep dirty flag up the flush dependency chain + * if appropriate + */ + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_dirty(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") + } /* end if */ + /* Check for newly clean entry */ + else if (!was_clean && !entry_ptr->is_dirty) { + + /* If the entry's type has a 'notify' callback send a + * 'entry cleaned' notice now that the entry is fully + * integrated into the cache. + */ + if (entry_ptr->type->notify && + (entry_ptr->type->notify)(H5C_NOTIFY_ACTION_ENTRY_CLEANED, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify client about entry dirty flag cleared") + + /* Propagate the flush dep clean flag up the flush dependency chain + * if appropriate + */ + if (entry_ptr->flush_dep_nparents > 0) + if (H5C__mark_flush_dep_clean(entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "Can't propagate flush dep dirty flag") + } /* end else-if */ + + /* Pin or unpin the entry as requested. */ + if (pin_entry) { + /* Pin the entry from a client */ + if (H5C__pin_entry_from_client(cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "Can't pin entry by client") + } + else if (unpin_entry) { + /* Unpin the entry from a client */ + if (H5C__unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") + } /* end if */ + + /* H5C__UPDATE_RP_FOR_UNPROTECT will place the unprotected entry on + * the pinned entry list if entry_ptr->is_pinned is TRUE. + */ + H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, FAIL); + + entry_ptr->is_protected = FALSE; + + /* if the entry is dirty, 'or' its flush_marker with the set flush flag, + * and then add it to the skip list if it isn't there already. + */ + if (entry_ptr->is_dirty) { + entry_ptr->flush_marker |= set_flush_marker; + if (!entry_ptr->in_slist) + /* this is a no-op if cache_ptr->slist_enabled is FALSE */ + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + } /* end if */ + + /* This implementation of the "deleted" option is a bit inefficient, as + * we re-insert the entry to be deleted into the replacement policy + * data structures, only to remove them again. Depending on how often + * we do this, we may want to optimize a bit. + */ + if (deleted) { + unsigned flush_flags = (H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_INVALIDATE_FLAG); + + /* verify that the target entry is in the cache. */ + H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL); + + if (test_entry_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") + else if (test_entry_ptr != entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, + "hash table contains multiple entries for addr?!?") + + /* Set the 'free file space' flag for the flush, if needed */ + if (free_file_space) + flush_flags |= H5C__FREE_FILE_SPACE_FLAG; + + /* Set the "take ownership" flag for the flush, if needed */ + if (take_ownership) + flush_flags |= H5C__TAKE_OWNERSHIP_FLAG; + + /* Delete the entry from the skip list on destroy */ + flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; + + assert((!cache_ptr->slist_enabled) || (((!was_clean) || dirtied) == (entry_ptr->in_slist))); + + if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't flush entry") + } /* end if */ +#ifdef H5_HAVE_PARALLEL + else if (clear_entry) { + /* Verify that the target entry is in the cache. */ + H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL); + + if (test_entry_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "entry not in hash table?!?") + else if (test_entry_ptr != entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, + "hash table contains multiple entries for addr?!?") + + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't clear entry") + } /* end else if */ +#endif /* H5_HAVE_PARALLEL */ + } + + H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr); + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_unprotect() */ + +/*------------------------------------------------------------------------- + * Function: H5C_unsettle_entry_ring + * + * Purpose: Advise the metadata cache that the specified entry's free space + * manager ring is no longer settled (if it was on entry). + * + * If the target free space manager ring is already + * unsettled, do nothing, and return SUCCEED. + * + * If the target free space manager ring is settled, and + * we are not in the process of a file shutdown, mark + * the ring as unsettled, and return SUCCEED. + * + * If the target free space manager is settled, and we + * are in the process of a file shutdown, post an error + * message, and return FAIL. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_unsettle_entry_ring(void *_entry) +{ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry whose ring to unsettle */ + H5C_t *cache; /* Cache for file */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry); + assert(entry->ring != H5C_RING_UNDEFINED); + assert((H5C_RING_USER == entry->ring) || (H5C_RING_RDFSM == entry->ring) || + (H5C_RING_MDFSM == entry->ring)); + cache = entry->cache_ptr; + assert(cache); + + switch (entry->ring) { + case H5C_RING_USER: + /* Do nothing */ + break; + + case H5C_RING_RDFSM: + if (cache->rdfsm_settled) { + if (cache->flush_in_progress || cache->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected rdfsm ring unsettle") + cache->rdfsm_settled = FALSE; + } /* end if */ + break; + + case H5C_RING_MDFSM: + if (cache->mdfsm_settled) { + if (cache->flush_in_progress || cache->close_warning_received) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unexpected mdfsm ring unsettle") + cache->mdfsm_settled = FALSE; + } /* end if */ + break; + + default: + assert(FALSE); /* this should be un-reachable */ + break; + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_unsettle_entry_ring() */ + +/*------------------------------------------------------------------------- + * Function: H5C_create_flush_dependency() + * + * Purpose: Initiates a parent<->child entry flush dependency. The parent + * entry must be pinned or protected at the time of call, and must + * have all dependencies removed before the cache can shut down. + * + * Note: Flush dependencies in the cache indicate that a child entry + * must be flushed to the file before its parent. (This is + * currently used to implement Single-Writer/Multiple-Reader (SWMR) + * I/O access for data structures in the file). + * + * Creating a flush dependency between two entries will also pin + * the parent entry. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_create_flush_dependency(void *parent_thing, void *child_thing) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent thing's entry */ + H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child thing's entry */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(parent_entry); + assert(H5_addr_defined(parent_entry->addr)); + assert(child_entry); + assert(H5_addr_defined(child_entry->addr)); + cache_ptr = parent_entry->cache_ptr; + assert(cache_ptr); + assert(cache_ptr == child_entry->cache_ptr); +#ifndef NDEBUG + /* Make sure the parent is not already a parent */ + { + unsigned u; + + for (u = 0; u < child_entry->flush_dep_nparents; u++) + assert(child_entry->flush_dep_parent[u] != parent_entry); + } /* end block */ +#endif + + /* More sanity checks */ + if (child_entry == parent_entry) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Child entry flush dependency parent can't be itself") + if (!(parent_entry->is_protected || parent_entry->is_pinned)) + HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Parent entry isn't pinned or protected") + + /* Check for parent not pinned */ + if (!parent_entry->is_pinned) { + /* Sanity check */ + assert(parent_entry->flush_dep_nchildren == 0); + assert(!parent_entry->pinned_from_client); + assert(!parent_entry->pinned_from_cache); + + /* Pin the parent entry */ + parent_entry->is_pinned = TRUE; + H5C__UPDATE_STATS_FOR_PIN(cache_ptr, parent_entry); + } /* end else */ + + /* Mark the entry as pinned from the cache's action (possibly redundantly) */ + parent_entry->pinned_from_cache = TRUE; + + /* Check if we need to resize the child's parent array */ + if (child_entry->flush_dep_nparents >= child_entry->flush_dep_parent_nalloc) { + if (child_entry->flush_dep_parent_nalloc == 0) { + /* Array does not exist yet, allocate it */ + assert(!child_entry->flush_dep_parent); + + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_MALLOC(H5C_cache_entry_ptr_t, H5C_FLUSH_DEP_PARENT_INIT))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") + child_entry->flush_dep_parent_nalloc = H5C_FLUSH_DEP_PARENT_INIT; + } /* end if */ + else { + /* Resize existing array */ + assert(child_entry->flush_dep_parent); + + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, + 2 * child_entry->flush_dep_parent_nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") + child_entry->flush_dep_parent_nalloc *= 2; + } /* end else */ + cache_ptr->entry_fd_height_change_counter++; + } /* end if */ + + /* Add the dependency to the child's parent array */ + child_entry->flush_dep_parent[child_entry->flush_dep_nparents] = parent_entry; + child_entry->flush_dep_nparents++; + + /* Increment parent's number of children */ + parent_entry->flush_dep_nchildren++; + + /* Adjust the number of dirty children */ + if (child_entry->is_dirty) { + /* Sanity check */ + assert(parent_entry->flush_dep_ndirty_children < parent_entry->flush_dep_nchildren); + + parent_entry->flush_dep_ndirty_children++; + + /* If the parent has a 'notify' callback, send a 'child entry dirtied' notice */ + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_DIRTIED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag set") + } /* end if */ + + /* adjust the parent's number of unserialized children. Note + * that it is possible for and entry to be clean and unserialized. + */ + if (!child_entry->image_up_to_date) { + assert(parent_entry->flush_dep_nunser_children < parent_entry->flush_dep_nchildren); + + parent_entry->flush_dep_nunser_children++; + + /* If the parent has a 'notify' callback, send a 'child entry unserialized' notice */ + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_UNSERIALIZED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag reset") + } /* end if */ + + /* Post-conditions, for successful operation */ + assert(parent_entry->is_pinned); + assert(parent_entry->flush_dep_nchildren > 0); + assert(child_entry->flush_dep_parent); + assert(child_entry->flush_dep_nparents > 0); + assert(child_entry->flush_dep_parent_nalloc > 0); +#ifndef NDEBUG + H5C__assert_flush_dep_nocycle(parent_entry, child_entry); +#endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_create_flush_dependency() */ + +/*------------------------------------------------------------------------- + * Function: H5C_destroy_flush_dependency() + * + * Purpose: Terminates a parent<-> child entry flush dependency. The + * parent entry must be pinned. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_destroy_flush_dependency(void *parent_thing, void *child_thing) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent entry */ + H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child entry */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(parent_entry); + assert(H5_addr_defined(parent_entry->addr)); + assert(child_entry); + assert(H5_addr_defined(child_entry->addr)); + cache_ptr = parent_entry->cache_ptr; + assert(cache_ptr); + assert(cache_ptr == child_entry->cache_ptr); + + /* Usage checks */ + if (!parent_entry->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "Parent entry isn't pinned") + if (NULL == child_entry->flush_dep_parent) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Child entry doesn't have a flush dependency parent array") + if (0 == parent_entry->flush_dep_nchildren) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Parent entry flush dependency ref. count has no child dependencies") + + /* Search for parent in child's parent array. This is a linear search + * because we do not expect large numbers of parents. If this changes, we + * may wish to change the parent array to a skip list */ + for (u = 0; u < child_entry->flush_dep_nparents; u++) + if (child_entry->flush_dep_parent[u] == parent_entry) + break; + if (u == child_entry->flush_dep_nparents) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, + "Parent entry isn't a flush dependency parent for child entry") + + /* Remove parent entry from child's parent array */ + if (u < (child_entry->flush_dep_nparents - 1)) + memmove(&child_entry->flush_dep_parent[u], &child_entry->flush_dep_parent[u + 1], + (child_entry->flush_dep_nparents - u - 1) * sizeof(child_entry->flush_dep_parent[0])); + child_entry->flush_dep_nparents--; + + /* Adjust parent entry's nchildren and unpin parent if it goes to zero */ + parent_entry->flush_dep_nchildren--; + if (0 == parent_entry->flush_dep_nchildren) { + /* Sanity check */ + assert(parent_entry->pinned_from_cache); + + /* Check if we should unpin parent entry now */ + if (!parent_entry->pinned_from_client) + if (H5C__unpin_entry_real(cache_ptr, parent_entry, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry") + + /* Mark the entry as unpinned from the cache's action */ + parent_entry->pinned_from_cache = FALSE; + } /* end if */ + + /* Adjust parent entry's ndirty_children */ + if (child_entry->is_dirty) { + /* Sanity check */ + assert(parent_entry->flush_dep_ndirty_children > 0); + + parent_entry->flush_dep_ndirty_children--; + + /* If the parent has a 'notify' callback, send a 'child entry cleaned' notice */ + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_CLEANED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry dirty flag reset") + } /* end if */ + + /* adjust parent entry's number of unserialized children */ + if (!child_entry->image_up_to_date) { + assert(parent_entry->flush_dep_nunser_children > 0); + + parent_entry->flush_dep_nunser_children--; + + /* If the parent has a 'notify' callback, send a 'child entry serialized' notice */ + if (parent_entry->type->notify && + (parent_entry->type->notify)(H5C_NOTIFY_ACTION_CHILD_SERIALIZED, parent_entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, + "can't notify parent about child entry serialized flag set") + } /* end if */ + + /* Shrink or free the parent array if appropriate */ + if (child_entry->flush_dep_nparents == 0) { + child_entry->flush_dep_parent = H5FL_SEQ_FREE(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent); + child_entry->flush_dep_parent_nalloc = 0; + } /* end if */ + else if (child_entry->flush_dep_parent_nalloc > H5C_FLUSH_DEP_PARENT_INIT && + child_entry->flush_dep_nparents <= (child_entry->flush_dep_parent_nalloc / 4)) { + if (NULL == (child_entry->flush_dep_parent = + H5FL_SEQ_REALLOC(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent, + child_entry->flush_dep_parent_nalloc / 4))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for flush dependency parent list") + child_entry->flush_dep_parent_nalloc /= 4; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_destroy_flush_dependency() */ + +/*------------------------------------------------------------------------- + * Function: H5C_expunge_entry + * + * Purpose: Expunge an entry from the cache without writing it to disk + * even if it is dirty. The entry may not be either pinned or + * protected. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flags) +{ + H5C_t *cache_ptr; + H5C_cache_entry_t *entry_ptr = NULL; + unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + assert(f); + assert(f->shared); + cache_ptr = f->shared->cache; + assert(cache_ptr); + assert(type); + assert(H5_addr_defined(addr)); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + /* Look for entry in cache */ + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); + if ((entry_ptr == NULL) || (entry_ptr->type != type)) + /* the target doesn't exist in the cache, so we are done. */ + HGOTO_DONE(SUCCEED); + + assert(entry_ptr->addr == addr); + assert(entry_ptr->type == type); + + /* Check for entry being pinned or protected */ + if (entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is protected") + if (entry_ptr->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is pinned") + + /* If we get this far, call H5C__flush_single_entry() with the + * H5C__FLUSH_INVALIDATE_FLAG and the H5C__FLUSH_CLEAR_ONLY_FLAG. + * This will clear the entry, and then delete it from the cache. + */ + + /* Pass along 'free file space' flag */ + flush_flags |= (flags & H5C__FREE_FILE_SPACE_FLAG); + + /* Delete the entry from the skip list on destroy */ + flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; + + if (H5C__flush_single_entry(f, entry_ptr, flush_flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't flush entry") + +done: +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_lru_list(cache_ptr) < 0) + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on exit"); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_expunge_entry() */ + +/*------------------------------------------------------------------------- + * Function: H5C_remove_entry + * + * Purpose: Remove an entry from the cache. Must be not protected, pinned, + * dirty, involved in flush dependencies, etc. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_remove_entry(void *_entry) +{ + H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry to remove */ + H5C_t *cache; /* Cache for file */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + assert(entry); + assert(entry->ring != H5C_RING_UNDEFINED); + cache = entry->cache_ptr; + assert(cache); + + /* Check for error conditions */ + if (entry->is_dirty) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove dirty entry from cache") + if (entry->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove protected entry from cache") + if (entry->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove pinned entry from cache") + /* NOTE: If these two errors are getting tripped because the entry is + * in a flush dependency with a freedspace entry, move the checks + * after the "before evict" message is sent, and add the + * "child being evicted" message to the "before evict" notify + * section below. QAK - 2017/08/03 + */ + if (entry->flush_dep_nparents > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove entry with flush dependency parents from cache") + if (entry->flush_dep_nchildren > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, + "can't remove entry with flush dependency children from cache") + + /* Additional internal cache consistency checks */ + assert(!entry->in_slist); + assert(!entry->flush_marker); + assert(!entry->flush_in_progress); + + /* Note that the algorithm below is (very) similar to the set of operations + * in H5C__flush_single_entry() and should be kept in sync with changes + * to that code. - QAK, 2016/11/30 + */ + + /* Update stats, as if we are "destroying" and taking ownership of the entry */ + H5C__UPDATE_STATS_FOR_EVICTION(cache, entry, TRUE); + + /* If the entry's type has a 'notify' callback, send a 'before eviction' + * notice while the entry is still fully integrated in the cache. + */ + if (entry->type->notify && (entry->type->notify)(H5C_NOTIFY_ACTION_BEFORE_EVICT, entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry to evict") + + /* Update the cache internal data structures as appropriate for a destroy. + * Specifically: + * 1) Delete it from the index + * 2) Delete it from the collective read access list + * 3) Update the replacement policy for eviction + * 4) Remove it from the tag list for this object + */ + + H5C__DELETE_FROM_INDEX(cache, entry, FAIL); + +#ifdef H5_HAVE_PARALLEL + /* Check for collective read access flag */ + if (entry->coll_access) { + entry->coll_access = FALSE; + H5C__REMOVE_FROM_COLL_LIST(cache, entry, FAIL); + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ + + H5C__UPDATE_RP_FOR_EVICTION(cache, entry, FAIL); + + /* Remove entry from tag list */ + if (H5C__untag_entry(cache, entry) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry from tag list"); + + /* Increment entries_removed_counter and set last_entry_removed_ptr. + * As we me be about to free the entry, recall that last_entry_removed_ptr + * must NEVER be dereferenced. + * + * Recall that these fields are maintained to allow functions that perform + * scans of lists of entries to detect the unexpected removal of entries + * (via expunge, eviction, or take ownership at present), so that they can + * re-start their scans if necessary. + * + * Also check if the entry we are watching for removal is being + * removed (usually the 'next' entry for an iteration) and reset + * it to indicate that it was removed. + */ + cache->entries_removed_counter++; + cache->last_entry_removed_ptr = entry; + if (entry == cache->entry_watched_for_removal) + cache->entry_watched_for_removal = NULL; + + /* Internal cache data structures should now be up to date, and + * consistent with the status of the entry. + * + * Now clean up internal cache fields if appropriate. + */ + + /* Free the buffer for the on disk image */ + if (entry->image_ptr != NULL) + entry->image_ptr = H5MM_xfree(entry->image_ptr); + + /* Reset the pointer to the cache the entry is within */ + entry->cache_ptr = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__remove_entry() */ diff --git a/src/H5Cepoch.c b/src/H5Cepoch.c index 1b55080..ed161e8 100644 --- a/src/H5Cepoch.c +++ b/src/H5Cepoch.c @@ -13,19 +13,26 @@ /*------------------------------------------------------------------------- * * Created: H5Cepoch.c - * June 5 2004 - * Quincey Koziol * - * Purpose: Metadata cache epoch callbacks. + * Purpose: Metadata cache epoch callbacks * *------------------------------------------------------------------------- */ +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ + /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fprivate.h" /* Files */ /****************/ /* Local Macros */ diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 0d0e42b..96d22d7 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -71,10 +71,6 @@ #define H5C__MDCI_MAX_FD_CHILDREN USHRT_MAX #define H5C__MDCI_MAX_FD_PARENTS USHRT_MAX -/* Values for image entry magic field */ -#define H5C_IMAGE_ENTRY_T_MAGIC 0x005CAC08 -#define H5C_IMAGE_ENTRY_T_BAD_MAGIC 0xBeefDead - /* Maximum ring allowed in image */ #define H5C_MAX_RING_IN_IMAGE H5C_RING_MDFSM @@ -89,35 +85,27 @@ #if H5C_COLLECT_CACHE_STATS /* clang-format off */ #define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ - (cache_ptr)->images_created++; +do { \ + (cache_ptr)->images_created++; \ +} while (0) #define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \ -{ \ +do { \ /* make sure image len is still good */ \ assert((cache_ptr)->image_len > 0); \ (cache_ptr)->images_read++; \ -} +} while (0) #define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \ -{ \ +do { \ /* make sure image len is still good */ \ assert((cache_ptr)->image_len > 0); \ (cache_ptr)->images_loaded++; \ (cache_ptr)->last_image_size = (cache_ptr)->image_len; \ -} -#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) \ -{ \ - (cache_ptr)->prefetches++; \ - if (dirty) \ - (cache_ptr)->dirty_prefetches++; \ -} -#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) \ - (cache_ptr)->prefetch_hits++; +} while (0) /* clang-format on */ #else /* H5C_COLLECT_CACHE_STATS */ #define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) #define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) #define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) -#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) -#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ /******************/ @@ -135,9 +123,7 @@ static herr_t H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, c #ifndef NDEBUG /* only used in assertions */ static herr_t H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint8_t **buf, unsigned entry_num); -#endif /* NDEBUG */ /* only used in assertions */ -static herr_t H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, - H5C_cache_entry_t **fd_children); +#endif static herr_t H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t **buf); static herr_t H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigned entry_num); static herr_t H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr); @@ -169,7 +155,6 @@ H5FL_DEFINE(H5C_cache_entry_t); /*******************/ /*------------------------------------------------------------------------- - * * Function: H5C_cache_image_pending() * * Purpose: Tests to see if the load of a metadata cache image @@ -192,7 +177,6 @@ H5C_cache_image_pending(const H5C_t *cache_ptr) /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); ret_value = (cache_ptr->load_image && !cache_ptr->image_loaded); @@ -230,7 +214,6 @@ H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr) assert(f->shared); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(load_ci_ptr); assert(write_ci_ptr); @@ -268,7 +251,6 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) assert(f->shared); assert(cache_ptr == f->shared->cache); assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); assert(cache_ptr->image_ctl.generate_image); assert(cache_ptr->num_entries_in_image > 0); @@ -314,7 +296,6 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) fake_cache_ptr = (H5C_t *)H5MM_malloc(sizeof(H5C_t)); assert(fake_cache_ptr); - fake_cache_ptr->magic = H5C__H5C_T_MAGIC; /* needed for sanity checks */ fake_cache_ptr->image_len = cache_ptr->image_len; @@ -330,7 +311,6 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) assert(fake_cache_ptr->image_entries); for (u = 0; u < fake_cache_ptr->num_entries_in_image; u++) { - fake_cache_ptr->image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; fake_cache_ptr->image_entries[u].image_ptr = NULL; /* touch up f->shared->cache to satisfy sanity checks... */ @@ -391,8 +371,8 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(fake_cache_ptr->image_entries); fake_cache_ptr = (H5C_t *)H5MM_xfree(fake_cache_ptr); - } /* end block */ -#endif /* NDEBUG */ + } /* end block */ +#endif done: FUNC_LEAVE_NOAPI(ret_value) @@ -420,7 +400,6 @@ H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) assert(f->shared); assert(cache_ptr == f->shared->cache); assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Construct cache image */ if (H5C__construct_cache_image_buffer(f, cache_ptr) < 0) @@ -447,375 +426,6 @@ done: } /* H5C__generate_cache_image() */ /*------------------------------------------------------------------------- - * Function: H5C__deserialize_prefetched_entry() - * - * Purpose: Deserialize the supplied prefetched entry entry, and return - * a pointer to the deserialized entry in *entry_ptr_ptr. - * If successful, remove the prefetched entry from the cache, - * and free it. Insert the deserialized entry into the cache. - * - * Note that the on disk image of the entry is not freed -- - * a pointer to it is stored in the deserialized entries' - * image_ptr field, and its image_up_to_date field is set to - * TRUE unless the entry is dirtied by the deserialize call. - * - * If the prefetched entry is a flush dependency child, - * destroy that flush dependency prior to calling the - * deserialize callback. If appropriate, the flush dependency - * relationship will be recreated by the cache client. - * - * If the prefetched entry is a flush dependency parent, - * destroy the flush dependency relationship with all its - * children. As all these children must be prefetched entries, - * recreate these flush dependency relationships with - * deserialized entry after it is inserted in the cache. - * - * Since deserializing a prefetched entry is semantically - * equivalent to a load, issue an entry loaded nofification - * if the notify callback is defined. - * - * Return: SUCCEED on success, and FAIL on failure. - * - * Note that *entry_ptr_ptr is undefined on failure. - * - * Programmer: John Mainzer, 8/10/15 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr, - const H5C_class_t *type, haddr_t addr, void *udata) -{ - hbool_t dirty = FALSE; /* Flag indicating whether thing was - * dirtied during deserialize - */ - size_t len; /* Size of image in file */ - void *thing = NULL; /* Pointer to thing loaded */ - H5C_cache_entry_t *pf_entry_ptr; /* pointer to the prefetched entry */ - /* supplied in *entry_ptr_ptr. */ - H5C_cache_entry_t *ds_entry_ptr; /* Alias for thing loaded, as cache - * entry - */ - H5C_cache_entry_t **fd_children = NULL; /* Pointer to a dynamically */ - /* allocated array of pointers to */ - /* the flush dependency children of */ - /* the prefetched entry, or NULL if */ - /* that array does not exist. */ - unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); - int i; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* sanity checks */ - assert(f); - assert(f->shared); - assert(f->shared->cache); - assert(f->shared->cache == cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(entry_ptr_ptr); - assert(*entry_ptr_ptr); - pf_entry_ptr = *entry_ptr_ptr; - assert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(pf_entry_ptr->type); - assert(pf_entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - assert(pf_entry_ptr->prefetched); - assert(pf_entry_ptr->image_up_to_date); - assert(pf_entry_ptr->image_ptr); - assert(pf_entry_ptr->size > 0); - assert(pf_entry_ptr->addr == addr); - assert(type); - assert(type->id == pf_entry_ptr->prefetch_type_id); - assert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type); - - /* verify absence of prohibited or unsupported type flag combinations */ - assert(!(type->flags & H5C__CLASS_SKIP_READS)); - - /* Can't see how skip reads could be usefully combined with - * either the speculative read flag. Hence disallow. - */ - assert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG))); - assert(H5_addr_defined(addr)); - assert(type->get_initial_load_size); - assert(type->deserialize); - - /* if *pf_entry_ptr is a flush dependency child, destroy all such - * relationships now. The client will restore the relationship(s) with - * the deserialized entry if appropriate. - */ - assert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents); - for (i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) { - assert(pf_entry_ptr->flush_dep_parent); - assert(pf_entry_ptr->flush_dep_parent[i]); - assert(pf_entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(pf_entry_ptr->flush_dep_parent[i]->flush_dep_nchildren > 0); - assert(pf_entry_ptr->fd_parent_addrs); - assert(pf_entry_ptr->flush_dep_parent[i]->addr == pf_entry_ptr->fd_parent_addrs[i]); - - if (H5C_destroy_flush_dependency(pf_entry_ptr->flush_dep_parent[i], pf_entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry parent flush dependency") - - pf_entry_ptr->fd_parent_addrs[i] = HADDR_UNDEF; - } /* end for */ - assert(pf_entry_ptr->flush_dep_nparents == 0); - - /* If *pf_entry_ptr is a flush dependency parent, destroy its flush - * dependency relationships with all its children (which must be - * prefetched entries as well). - * - * These flush dependency relationships will have to be restored - * after the deserialized entry is inserted into the cache in order - * to transfer these relationships to the new entry. Hence save the - * pointers to the flush dependency children of *pf_enty_ptr for later - * use. - */ - if (pf_entry_ptr->fd_child_count > 0) { - if (NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc( - sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1)))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd child ptr array") - - if (H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, - "can't destroy pf entry child flush dependency(s).") - } /* end if */ - - /* Since the size of the on disk image is known exactly, there is - * no need for either a call to the get_initial_load_size() callback, - * or retries if the H5C__CLASS_SPECULATIVE_LOAD_FLAG flag is set. - * Similarly, there is no need to clamp possible reads beyond - * EOF. - */ - len = pf_entry_ptr->size; - - /* Deserialize the prefetched on-disk image of the entry into the - * native memory form - */ - if (NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't deserialize image") - ds_entry_ptr = (H5C_cache_entry_t *)thing; - - /* In general, an entry should be clean just after it is loaded. - * - * However, when this code is used in the metadata cache, it is - * possible that object headers will be dirty at this point, as - * the deserialize function will alter object headers if necessary to - * fix an old bug. - * - * In the following assert: - * - * assert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); - * - * note that type ids 5 & 6 are associated with object headers in the - * metadata cache. - * - * When we get to using H5C for other purposes, we may wish to - * tighten up the assert so that the loophole only applies to the - * metadata cache. - * - * Note that at present, dirty can't be set to true with prefetched - * entries. However this may change, so include this functionality - * against that possibility. - * - * Also, note that it is possible for a prefetched entry to be dirty -- - * hence the value assigned to ds_entry_ptr->is_dirty below. - */ - - assert((dirty == FALSE) || (type->id == 5 || type->id == 6)); - - ds_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; - ds_entry_ptr->cache_ptr = f->shared->cache; - ds_entry_ptr->addr = addr; - ds_entry_ptr->size = len; - assert(ds_entry_ptr->size < H5C_MAX_ENTRY_SIZE); - ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr; - ds_entry_ptr->image_up_to_date = !dirty; - ds_entry_ptr->type = type; - ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty; - ds_entry_ptr->dirtied = FALSE; - ds_entry_ptr->is_protected = FALSE; - ds_entry_ptr->is_read_only = FALSE; - ds_entry_ptr->ro_ref_count = 0; - ds_entry_ptr->is_pinned = FALSE; - ds_entry_ptr->in_slist = FALSE; - ds_entry_ptr->flush_marker = FALSE; -#ifdef H5_HAVE_PARALLEL - ds_entry_ptr->clear_on_unprotect = FALSE; - ds_entry_ptr->flush_immediately = FALSE; - ds_entry_ptr->coll_access = FALSE; -#endif /* H5_HAVE_PARALLEL */ - ds_entry_ptr->flush_in_progress = FALSE; - ds_entry_ptr->destroy_in_progress = FALSE; - - ds_entry_ptr->ring = pf_entry_ptr->ring; - - /* Initialize flush dependency height fields */ - ds_entry_ptr->flush_dep_parent = NULL; - ds_entry_ptr->flush_dep_nparents = 0; - ds_entry_ptr->flush_dep_parent_nalloc = 0; - ds_entry_ptr->flush_dep_nchildren = 0; - ds_entry_ptr->flush_dep_ndirty_children = 0; - ds_entry_ptr->flush_dep_nunser_children = 0; - - /* Initialize fields supporting the hash table: */ - ds_entry_ptr->ht_next = NULL; - ds_entry_ptr->ht_prev = NULL; - ds_entry_ptr->il_next = NULL; - ds_entry_ptr->il_prev = NULL; - - /* Initialize fields supporting replacement policies: */ - ds_entry_ptr->next = NULL; - ds_entry_ptr->prev = NULL; -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - ds_entry_ptr->aux_next = NULL; - ds_entry_ptr->aux_prev = NULL; -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#ifdef H5_HAVE_PARALLEL - pf_entry_ptr->coll_next = NULL; - pf_entry_ptr->coll_prev = NULL; -#endif /* H5_HAVE_PARALLEL */ - - /* Initialize cache image related fields */ - ds_entry_ptr->include_in_image = FALSE; - ds_entry_ptr->lru_rank = 0; - ds_entry_ptr->image_dirty = FALSE; - ds_entry_ptr->fd_parent_count = 0; - ds_entry_ptr->fd_parent_addrs = NULL; - ds_entry_ptr->fd_child_count = pf_entry_ptr->fd_child_count; - ds_entry_ptr->fd_dirty_child_count = 0; - ds_entry_ptr->image_fd_height = 0; - ds_entry_ptr->prefetched = FALSE; - ds_entry_ptr->prefetch_type_id = 0; - ds_entry_ptr->age = 0; - ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty; -#ifndef NDEBUG /* debugging field */ - ds_entry_ptr->serialization_count = 0; -#endif /* NDEBUG */ - - H5C__RESET_CACHE_ENTRY_STATS(ds_entry_ptr); - - /* Apply to to the newly deserialized entry */ - if (H5C__tag_entry(cache_ptr, ds_entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") - - /* We have successfully deserialized the prefetched entry. - * - * Before we return a pointer to the deserialized entry, we must remove - * the prefetched entry from the cache, discard it, and replace it with - * the deserialized entry. Note that we do not free the prefetched - * entries image, as that has been transferred to the deserialized - * entry. - * - * Also note that we have not yet restored any flush dependencies. This - * must wait until the deserialized entry is inserted in the cache. - * - * To delete the prefetched entry from the cache: - * - * 1) Set pf_entry_ptr->image_ptr to NULL. Since we have already - * transferred the buffer containing the image to *ds_entry_ptr, - * this is not a memory leak. - * - * 2) Call H5C__flush_single_entry() with the H5C__FLUSH_INVALIDATE_FLAG - * and H5C__FLUSH_CLEAR_ONLY_FLAG flags set. - */ - pf_entry_ptr->image_ptr = NULL; - - if (pf_entry_ptr->is_dirty) { - assert(((cache_ptr->slist_enabled) && (pf_entry_ptr->in_slist)) || - ((!cache_ptr->slist_enabled) && (!pf_entry_ptr->in_slist))); - - flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - } /* end if */ - - if (H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't expunge prefetched entry") - -#ifndef NDEGUG /* verify deletion */ - H5C__SEARCH_INDEX(cache_ptr, addr, pf_entry_ptr, FAIL); - - assert(NULL == pf_entry_ptr); -#endif /* NDEBUG */ - - /* Insert the deserialized entry into the cache. */ - H5C__INSERT_IN_INDEX(cache_ptr, ds_entry_ptr, FAIL) - - assert(!ds_entry_ptr->in_slist); - if (ds_entry_ptr->is_dirty) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, ds_entry_ptr, FAIL) - - H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, ds_entry_ptr, FAIL) - - /* Deserializing a prefetched entry is the conceptual equivalent of - * loading it from file. If the deserialized entry has a notify callback, - * send an "after load" notice now that the deserialized entry is fully - * integrated into the cache. - */ - if (ds_entry_ptr->type->notify && - (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry loaded into cache") - - /* Restore flush dependencies with the flush dependency children of - * of the prefetched entry. Note that we must protect *ds_entry_ptr - * before the call to avoid triggering sanity check failures, and - * then unprotect it afterwards. - */ - i = 0; - if (fd_children != NULL) { - H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, ds_entry_ptr, FAIL) - ds_entry_ptr->is_protected = TRUE; - while (fd_children[i] != NULL) { - /* Sanity checks */ - assert((fd_children[i])->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert((fd_children[i])->prefetched); - assert((fd_children[i])->fd_parent_count > 0); - assert((fd_children[i])->fd_parent_addrs); - -#ifndef NDEBUG - { - int j; - hbool_t found; - - j = 0; - found = FALSE; - while ((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) { - if ((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr) - found = TRUE; - - j++; - } /* end while */ - assert(found); - } -#endif /* NDEBUG */ - - if (H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore child flush dependency") - - i++; - } /* end while */ - - H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, ds_entry_ptr, FAIL); - ds_entry_ptr->is_protected = FALSE; - } /* end if ( fd_children != NULL ) */ - assert((unsigned)i == ds_entry_ptr->fd_child_count); - - ds_entry_ptr->fd_child_count = 0; - H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) - - /* finally, pass ds_entry_ptr back to the caller */ - *entry_ptr_ptr = ds_entry_ptr; - -done: - if (fd_children) - fd_children = (H5C_cache_entry_t **)H5MM_xfree((void *)fd_children); - - /* Release resources on error */ - if (FAIL == ret_value) - if (thing && type->free_icr(thing) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed") - - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__deserialize_prefetched_entry() */ - -/*------------------------------------------------------------------------- * Function: H5C__free_image_entries_array * * Purpose: If the image entries array exists, free the image @@ -836,7 +446,6 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); assert(cache_ptr->image_ctl.generate_image); assert(cache_ptr->index_len == 0); @@ -853,7 +462,6 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) /* Sanity checks */ assert(ie_ptr); - assert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); assert(ie_ptr->image_ptr); /* Free the parent addrs array if appropriate */ @@ -867,9 +475,6 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) /* Free the image */ ie_ptr->image_ptr = H5MM_xfree(ie_ptr->image_ptr); - - /* Set magic field to bad magic so we can detect freed entries */ - ie_ptr->magic = H5C_IMAGE_ENTRY_T_BAD_MAGIC; } /* end for */ /* Free the image entries array */ @@ -880,7 +485,7 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) } /* H5C__free_image_entries_array() */ /*------------------------------------------------------------------------- - * Function: H5C_get_cache_image_config + * Function: H5C__get_cache_image_config * * Purpose: Copy the current configuration for cache image generation * on file close into the instance of H5C_cache_image_ctl_t @@ -891,13 +496,13 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr) +H5C__get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry") if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad config_ptr on entry") @@ -906,72 +511,7 @@ H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_get_cache_image_config() */ - -/*------------------------------------------------------------------------- - * Function: H5C_image_stats - * - * Purpose: Prints statistics specific to the cache image. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 10/26/15 - * - *------------------------------------------------------------------------- - */ -herr_t -#if H5C_COLLECT_CACHE_STATS -H5C_image_stats(H5C_t *cache_ptr, hbool_t print_header) -#else /* H5C_COLLECT_CACHE_STATS */ -H5C_image_stats(H5C_t *cache_ptr, hbool_t H5_ATTR_UNUSED print_header) -#endif /* H5C_COLLECT_CACHE_STATS */ -{ -#if H5C_COLLECT_CACHE_STATS - int i; - int64_t total_hits = 0; - int64_t total_misses = 0; - double hit_rate; - double prefetch_use_rate; -#endif /* H5C_COLLECT_CACHE_STATS */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if (!cache_ptr || cache_ptr->magic != H5C__H5C_T_MAGIC) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") - -#if H5C_COLLECT_CACHE_STATS - for (i = 0; i <= cache_ptr->max_type_id; i++) { - total_hits += cache_ptr->hits[i]; - total_misses += cache_ptr->misses[i]; - } /* end for */ - - if ((total_hits > 0) || (total_misses > 0)) - hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses)); - else - hit_rate = 0.0; - - if (cache_ptr->prefetches > 0) - prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches)); - else - prefetch_use_rate = 0.0; - - if (print_header) { - fprintf(stdout, "\nhit prefetches prefetch image pf hit\n"); - fprintf(stdout, "rate: total: dirty: hits: flshs: evct: size: rate:\n"); - } /* end if */ - - fprintf(stdout, "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", hit_rate, - (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches), - (long long)(cache_ptr->prefetch_hits), (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]), - (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]), - (long long)(cache_ptr->last_image_size), prefetch_use_rate); -#endif /* H5C_COLLECT_CACHE_STATS */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_image_stats() */ +} /* H5C__get_cache_image_config() */ /*------------------------------------------------------------------------- * Function: H5C__read_cache_image @@ -1002,8 +542,7 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; int mpi_result; - if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - assert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); + if (NULL == aux_ptr || aux_ptr->mpi_rank == 0) { #endif /* H5_HAVE_PARALLEL */ /* Read the buffer (if serial access, or rank 0 of parallel access) */ @@ -1014,7 +553,7 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) cache_ptr->image_buffer) < 0) HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read metadata cache image block") - H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) + H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr); #ifdef H5_HAVE_PARALLEL if (aux_ptr) { @@ -1064,7 +603,6 @@ H5C__load_cache_image(H5F_t *f) assert(f->shared); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* If the image address is defined, load the image, decode it, * and insert its contents into the metadata cache. @@ -1098,7 +636,7 @@ H5C__load_cache_image(H5F_t *f) /* Update stats -- must do this now, as we are about * to discard the size of the cache image. */ - H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) + H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr); cache_ptr->image_loaded = TRUE; } /* end if */ @@ -1156,7 +694,6 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_ assert(f->shared); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Set information needed to load cache image */ cache_ptr->image_addr = addr; @@ -1279,7 +816,6 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) assert(f->shared->cache); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(image_generated); /* If the file is opened and closed without any access to @@ -1494,8 +1030,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "can't setup image entries array.") /* Sort the entries */ - HDqsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image, - sizeof(H5C_image_entry_t), H5C__image_entry_cmp); + qsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image, + sizeof(H5C_image_entry_t), H5C__image_entry_cmp); } /* end if */ else { /* cancel creation of metadata cache image */ assert(cache_ptr->image_entries == NULL); @@ -1559,7 +1095,7 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl assert(f->shared->cache == f->shared->cache); /* Check arguments */ - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry") /* Validate the config: */ @@ -1745,7 +1281,6 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t * /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(buf); assert(*buf); @@ -1842,13 +1377,11 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint assert(f->shared); assert(cache_ptr == f->shared->cache); assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(buf); assert(*buf); assert(entry_num < cache_ptr->num_entries_in_image); ie_ptr = &(cache_ptr->image_entries[entry_num]); assert(ie_ptr); - assert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); /* Get pointer to buffer */ p = *buf; @@ -1893,7 +1426,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint assert((in_lru && lru_rank >= 0) || (!in_lru && lru_rank == -1)); /* Decode entry offset */ - H5_addr_decode(f, &p, &addr); + H5F_addr_decode(f, &p, &addr); if (!H5_addr_defined(addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid entry offset") @@ -1916,7 +1449,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer") for (i = 0; i < fd_parent_count; i++) { - H5_addr_decode(f, &p, &(fd_parent_addrs[i])); + H5F_addr_decode(f, &p, &(fd_parent_addrs[i])); if (!H5_addr_defined(fd_parent_addrs[i])) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid flush dependency parent offset") } /* end for */ @@ -1954,135 +1487,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__decode_cache_image_entry() */ -#endif /* NDEBUG */ - -/*------------------------------------------------------------------------- - * Function: H5C__destroy_pf_entry_child_flush_deps() - * - * Purpose: Destroy all flush dependencies in this the supplied - * prefetched entry is the parent. Note that the children - * in these flush dependencies must be prefetched entries as - * well. - * - * As this action is part of the process of transferring all - * such flush dependencies to the deserialized version of the - * prefetched entry, ensure that the data necessary to complete - * the transfer is retained. - * - * Note: The current implementation of this function is - * quite inefficient -- mostly due to the current - * implementation of flush dependencies. This should - * be fixed at some point. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 8/11/15 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr, - H5C_cache_entry_t **fd_children) -{ - H5C_cache_entry_t *entry_ptr; - unsigned entries_visited = 0; - int fd_children_found = 0; - hbool_t found; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity checks */ - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); - assert(pf_entry_ptr); - assert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - assert(pf_entry_ptr->type); - assert(pf_entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - assert(pf_entry_ptr->prefetched); - assert(pf_entry_ptr->fd_child_count > 0); - assert(fd_children); - - /* Scan each entry on the index list */ - entry_ptr = cache_ptr->il_head; - while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - - /* Here we look at entry_ptr->flush_dep_nparents and not - * entry_ptr->fd_parent_count as it is possible that some - * or all of the prefetched flush dependency child relationships - * have already been destroyed. - */ - if (entry_ptr->prefetched && (entry_ptr->flush_dep_nparents > 0)) { - unsigned u; /* Local index variable */ - - /* Re-init */ - u = 0; - found = FALSE; - - /* Sanity checks */ - assert(entry_ptr->type); - assert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID); - assert(entry_ptr->fd_parent_count >= entry_ptr->flush_dep_nparents); - assert(entry_ptr->fd_parent_addrs); - assert(entry_ptr->flush_dep_parent); - - /* Look for correct entry */ - while (!found && (u < entry_ptr->fd_parent_count)) { - /* Sanity check entry */ - assert(entry_ptr->flush_dep_parent[u]); - assert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - - /* Correct entry? */ - if (pf_entry_ptr == entry_ptr->flush_dep_parent[u]) - found = TRUE; - - u++; - } /* end while */ - - if (found) { - assert(NULL == fd_children[fd_children_found]); - - /* Remove flush dependency */ - fd_children[fd_children_found] = entry_ptr; - fd_children_found++; - if (H5C_destroy_flush_dependency(pf_entry_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, - "can't destroy pf entry child flush dependency") - -#ifndef NDEBUG - /* Sanity check -- verify that the address of the parent - * appears in entry_ptr->fd_parent_addrs. Must do a search, - * as with flush dependency creates and destroys, - * entry_ptr->fd_parent_addrs and entry_ptr->flush_dep_parent - * can list parents in different order. - */ - found = FALSE; - u = 0; - while (!found && u < entry_ptr->fd_parent_count) { - if (pf_entry_ptr->addr == entry_ptr->fd_parent_addrs[u]) - found = TRUE; - u++; - } /* end while */ - assert(found); -#endif /* NDEBUG */ - } /* end if */ - } /* end if */ - - entries_visited++; - entry_ptr = entry_ptr->il_next; - } /* end while */ - - /* Post-op sanity checks */ - assert(NULL == fd_children[fd_children_found]); - assert((unsigned)fd_children_found == pf_entry_ptr->fd_child_count); - assert(entries_visited == cache_ptr->index_len); - assert(!pf_entry_ptr->is_pinned); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__destroy_pf_entry_child_flush_deps() */ +#endif /*------------------------------------------------------------------------- * Function: H5C__encode_cache_image_header() @@ -2108,7 +1513,6 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t * /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); assert(cache_ptr->image_ctl.generate_image); assert(cache_ptr->index_len == 0); @@ -2184,7 +1588,6 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne assert(f->shared); assert(cache_ptr == f->shared->cache); assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); assert(cache_ptr->image_ctl.generate_image); assert(cache_ptr->index_len == 0); @@ -2192,7 +1595,6 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne assert(*buf); assert(entry_num < cache_ptr->num_entries_in_image); ie_ptr = &(cache_ptr->image_entries[entry_num]); - assert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); /* Get pointer to buffer to encode into */ p = *buf; @@ -2238,7 +1640,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne INT32ENCODE(p, ie_ptr->lru_rank); /* Encode entry offset */ - H5_addr_encode(f, &p, ie_ptr->addr); + H5F_addr_encode(f, &p, ie_ptr->addr); /* Encode entry length */ H5F_ENCODE_LENGTH(f, p, ie_ptr->size); @@ -2249,7 +1651,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne /* Encode dependency parent offsets -- if any */ for (u = 0; u < ie_ptr->fd_parent_count; u++) - H5_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]); + H5F_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]); /* Copy entry image */ H5MM_memcpy(p, ie_ptr->image_ptr, ie_ptr->size); @@ -2312,18 +1714,19 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) { H5C_cache_entry_t *entry_ptr; H5C_cache_entry_t *parent_ptr; - unsigned entries_removed_from_image = 0; - unsigned external_parent_fd_refs_removed = 0; - unsigned external_child_fd_refs_removed = 0; - hbool_t done = FALSE; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; +#ifndef NDEBUG + unsigned entries_removed_from_image = 0; + unsigned external_parent_fd_refs_removed = 0; + unsigned external_child_fd_refs_removed = 0; +#endif + hbool_t done = FALSE; + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE /* sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* Remove from the cache image all dirty entries that are * flush dependency children of dirty entries that are not in the @@ -2337,8 +1740,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) done = TRUE; entry_ptr = cache_ptr->il_head; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Should this entry be in the image */ if (entry_ptr->image_dirty && entry_ptr->include_in_image && (entry_ptr->fd_parent_count > 0)) { assert(entry_ptr->flush_dep_parent != NULL); @@ -2346,14 +1747,15 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->ring == parent_ptr->ring); if (parent_ptr->is_dirty && !parent_ptr->include_in_image && entry_ptr->include_in_image) { /* Must remove child from image -- only do this once */ +#ifndef NDEBUG entries_removed_from_image++; +#endif entry_ptr->include_in_image = FALSE; } /* end if */ } /* for */ @@ -2383,7 +1785,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->ring == parent_ptr->ring); if (parent_ptr->include_in_image) { @@ -2396,7 +1797,9 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) parent_ptr->fd_dirty_child_count--; } /* end if */ +#ifndef NDEBUG external_child_fd_refs_removed++; +#endif } /* end if */ } /* for */ } /* end if */ @@ -2410,7 +1813,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) parent_ptr = entry_ptr->flush_dep_parent[u]; /* Sanity check parent */ - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->ring == parent_ptr->ring); if (!parent_ptr->include_in_image) { @@ -2421,7 +1823,9 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) assert(parent_ptr->addr == entry_ptr->fd_parent_addrs[u]); entry_ptr->fd_parent_addrs[u] = HADDR_UNDEF; +#ifndef NDEBUG external_parent_fd_refs_removed++; +#endif } /* end if */ } /* for */ @@ -2477,7 +1881,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) for (u = 0; u < entry_ptr->fd_parent_count; u++) { parent_ptr = entry_ptr->flush_dep_parent[u]; - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= 0) H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, 1); } /* end for */ @@ -2542,7 +1945,6 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, /* Sanity checks */ assert(entry_ptr); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->include_in_image); assert((entry_ptr->image_fd_height == 0) || (entry_ptr->image_fd_height < fd_height)); assert(((fd_height == 0) && (entry_ptr->fd_child_count == 0)) || @@ -2557,7 +1959,6 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr, H5C_cache_entry_t *parent_ptr; parent_ptr = entry_ptr->flush_dep_parent[u]; - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= fd_height) H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, fd_height + 1); @@ -2582,16 +1983,17 @@ static herr_t H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) { H5C_cache_entry_t *entry_ptr; - H5C_image_entry_t *image_entries = NULL; - uint32_t entries_visited = 0; - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_image_entry_t *image_entries = NULL; +#ifndef NDEBUG + uint32_t entries_visited = 0; +#endif + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); assert(cache_ptr->pl_len == 0); assert(cache_ptr->num_entries_in_image > 0); @@ -2604,7 +2006,6 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) /* Initialize (non-zero/NULL/FALSE) fields */ for (u = 0; u <= cache_ptr->num_entries_in_image; u++) { - image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; image_entries[u].addr = HADDR_UNDEF; image_entries[u].ring = H5C_RING_UNDEFINED; image_entries[u].type_id = -1; @@ -2614,8 +2015,6 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) u = 0; entry_ptr = cache_ptr->il_head; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if (entry_ptr->include_in_image) { /* Since we have already serialized the cache, the following * should hold. @@ -2668,7 +2067,9 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) assert(u <= cache_ptr->num_entries_in_image); } /* end if */ +#ifndef NDEBUG entries_visited++; +#endif entry_ptr = entry_ptr->il_next; } /* end while */ @@ -2718,14 +2119,16 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) { H5C_cache_entry_t *entry_ptr; hbool_t include_in_image; - unsigned entries_visited = 0; - int lru_rank = 1; - uint32_t num_entries_tentatively_in_image = 0; - uint32_t num_entries_in_image = 0; - size_t image_len; - size_t entry_header_len; - size_t fd_parents_list_len; - herr_t ret_value = SUCCEED; /* Return value */ + int lru_rank = 1; +#ifndef NDEBUG + unsigned entries_visited = 0; + uint32_t num_entries_tentatively_in_image = 0; +#endif + uint32_t num_entries_in_image = 0; + size_t image_len; + size_t entry_header_len; + size_t fd_parents_list_len; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2734,7 +2137,6 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) assert(f->shared); assert(f->shared->sblock); assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); assert(cache_ptr->pl_len == 0); @@ -2747,8 +2149,6 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) /* Scan each entry on the index list */ entry_ptr = cache_ptr->il_head; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - /* Since we have already serialized the cache, the following * should hold. */ @@ -2826,10 +2226,14 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) entry_ptr->fd_dirty_child_count = entry_ptr->flush_dep_ndirty_children; } /* end if */ +#ifndef NDEBUG num_entries_tentatively_in_image++; +#endif } /* end if */ +#ifndef NDEBUG entries_visited++; +#endif entry_ptr = entry_ptr->il_next; } /* end while */ assert(entries_visited == cache_ptr->index_len); @@ -2860,15 +2264,15 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) if (H5C__prep_for_file_close__compute_fd_heights(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "computation of flush dependency heights failed?!?") - /* At this point, all entries that will appear in the cache - * image should be marked correctly. Compute the size of the - * cache image. - */ + /* At this point, all entries that will appear in the cache + * image should be marked correctly. Compute the size of the + * cache image. + */ +#ifndef NDEBUG entries_visited = 0; - entry_ptr = cache_ptr->il_head; +#endif + entry_ptr = cache_ptr->il_head; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - if (entry_ptr->include_in_image) { if (entry_ptr->fd_parent_count > 0) fd_parents_list_len = (size_t)(H5F_SIZEOF_ADDR(f) * entry_ptr->fd_parent_count); @@ -2879,7 +2283,9 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) num_entries_in_image++; } /* end if */ +#ifndef NDEBUG entries_visited++; +#endif entry_ptr = entry_ptr->il_next; } /* end while */ assert(entries_visited == cache_ptr->index_len); @@ -2897,7 +2303,9 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) #endif cache_ptr->num_entries_in_image = num_entries_in_image; - entries_visited = 0; +#ifndef NDEBUG + entries_visited = 0; +#endif /* Now scan the LRU list to set the lru_rank fields of all entries * on the LRU. @@ -2911,7 +2319,6 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) */ entry_ptr = cache_ptr->LRU_head_ptr; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->type != NULL); /* to avoid confusion, don't set lru_rank on epoch markers. @@ -2930,7 +2337,9 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) lru_rank++; } /* end else-if */ +#ifndef NDEBUG entries_visited++; +#endif entry_ptr = entry_ptr->next; } /* end while */ assert(entries_visited == cache_ptr->LRU_list_len); @@ -2971,7 +2380,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) assert(f->shared); assert(cache_ptr == f->shared->cache); assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->image_buffer); assert(cache_ptr->image_len > 0); @@ -3003,16 +2411,16 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) */ /* Insert the prefetched entry in the index */ - H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL) + H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL); /* If dirty, insert the entry into the slist. */ if (pf_entry_ptr->is_dirty) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL); /* Append the entry to the LRU */ - H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL) + H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL); - H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty) + H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty); /* If the prefetched entry is the child in one or more flush * dependency relationships, recreate those flush dependencies. @@ -3024,19 +2432,18 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) /* Find the parent entry */ parent_ptr = NULL; - H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL); if (parent_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "fd parent not in cache?!?") /* Sanity checks */ - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(parent_ptr->addr == pf_entry_ptr->fd_parent_addrs[v]); assert(parent_ptr->lru_rank == -1); /* Must protect parent entry to set up a flush dependency. * Do this now, and then uprotect when done. */ - H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, parent_ptr, FAIL) + H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, parent_ptr, FAIL); parent_ptr->is_protected = TRUE; /* Setup the flush dependency */ @@ -3044,7 +2451,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore flush dependency") /* And now unprotect */ - H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL) + H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL); parent_ptr->is_protected = FALSE; } /* end for */ } /* end for */ @@ -3055,7 +2462,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) */ pf_entry_ptr = cache_ptr->il_head; while (pf_entry_ptr != NULL) { - assert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert((pf_entry_ptr->prefetched && pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) || (!pf_entry_ptr->prefetched && pf_entry_ptr->type != H5AC_PREFETCHED_ENTRY)); if (pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) @@ -3064,7 +2470,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) for (v = 0; v < pf_entry_ptr->fd_parent_count; v++) { parent_ptr = pf_entry_ptr->flush_dep_parent[v]; assert(parent_ptr); - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(pf_entry_ptr->fd_parent_addrs); assert(pf_entry_ptr->fd_parent_addrs[v] == parent_ptr->addr); assert(parent_ptr->flush_dep_nchildren > 0); @@ -3089,7 +2494,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) i = -1; entry_ptr = cache_ptr->LRU_head_ptr; while (entry_ptr != NULL) { - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->type != NULL); if (entry_ptr->prefetched) { @@ -3111,8 +2515,8 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) * we add code to store and restore adaptive resize status. */ assert(lru_rank_holes <= H5C__MAX_EPOCH_MARKERS); - } /* end block */ -#endif /* NDEBUG */ + } /* end block */ +#endif /* Check to see if the cache is oversize, and evict entries as * necessary to remain within limits. @@ -3160,7 +2564,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b hbool_t in_lru = FALSE; hbool_t is_fd_parent = FALSE; hbool_t is_fd_child = FALSE; -#endif /* NDEBUG */ /* only used in assertions */ +#endif const uint8_t *p; hbool_t file_is_rw; H5C_cache_entry_t *ret_value = NULL; /* Return value */ @@ -3169,7 +2573,6 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b /* Sanity checks */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->num_entries_in_image > 0); assert(buf && *buf); @@ -3197,7 +2600,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b is_fd_parent = TRUE; if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG) is_fd_child = TRUE; -#endif /* NDEBUG */ /* only used in assertions */ +#endif /* Force dirty entries to clean if the file read only -- must do * this as otherwise the cache will attempt to write them on file @@ -3243,7 +2646,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b assert((in_lru && pf_entry_ptr->lru_rank >= 0) || (!in_lru && pf_entry_ptr->lru_rank == -1)); /* Decode entry offset */ - H5_addr_decode(f, &p, &pf_entry_ptr->addr); + H5F_addr_decode(f, &p, &pf_entry_ptr->addr); if (!H5_addr_defined(pf_entry_ptr->addr)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid entry offset") @@ -3267,7 +2670,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for fd parent addrs buffer") for (u = 0; u < pf_entry_ptr->fd_parent_count; u++) { - H5_addr_decode(f, &p, &(pf_entry_ptr->fd_parent_addrs[u])); + H5F_addr_decode(f, &p, &(pf_entry_ptr->fd_parent_addrs[u])); if (!H5_addr_defined(pf_entry_ptr->fd_parent_addrs[u])) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid flush dependency parent offset") } /* end for */ @@ -3286,7 +2689,6 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b /* Initialize the rest of the fields in the prefetched entry */ /* (Only need to set non-zero/NULL/FALSE fields, due to calloc() above) */ - pf_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; pf_entry_ptr->cache_ptr = cache_ptr; pf_entry_ptr->image_up_to_date = TRUE; pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY; @@ -3341,7 +2743,6 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) assert(f->shared->cache); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->close_warning_received); /* Write data into the metadata cache image superblock extension message. @@ -3353,8 +2754,7 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) if (cache_ptr->aux_ptr) { /* we have multiple processes */ H5AC_aux_t *aux_ptr; - aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); + aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; mdci_msg.size = aux_ptr->p0_image_len; } /* end if */ else @@ -3398,8 +2798,7 @@ H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr) { H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr; - if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - assert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); + if (NULL == aux_ptr || aux_ptr->mpi_rank == 0) { #endif /* H5_HAVE_PARALLEL */ /* Write the buffer (if serial access, or rank 0 for parallel access) */ diff --git a/src/H5Cint.c b/src/H5Cint.c new file mode 100644 index 0000000..a2a4dcf --- /dev/null +++ b/src/H5Cint.c @@ -0,0 +1,2508 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Centry.c + * + * Purpose: Routines which operate on cache entries. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /* suppress error about including H5Fpkg */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5MFprivate.h" /* File memory management */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *status_ptr, + size_t *new_max_cache_size_ptr, hbool_t write_permitted); +static herr_t H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr); +static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted); +static herr_t H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr); +static herr_t H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags); +static herr_t H5C__serialize_ring(H5F_t *f, H5C_ring_t ring); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5C__auto_adjust_cache_size + * + * Purpose: Obtain the current full cache hit rate, and compare it + * with the hit rate thresholds for modifying cache size. + * If one of the thresholds has been crossed, adjusts the + * size of the cache accordingly. + * + * The function then resets the full cache hit rate + * statistics, and exits. + * + * Return: Non-negative on success/Negative on failure or if there was + * an attempt to flush a protected item. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) +{ + H5C_t *cache_ptr = f->shared->cache; + hbool_t reentrant_call = FALSE; + hbool_t inserted_epoch_marker = FALSE; + size_t new_max_cache_size = 0; + size_t old_max_cache_size = 0; + size_t new_min_clean_size = 0; + size_t old_min_clean_size = 0; + double hit_rate; + enum H5C_resize_status status = in_spec; /* will change if needed */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(f); + assert(cache_ptr); + assert(cache_ptr->cache_accesses >= cache_ptr->resize_ctl.epoch_length); + assert(0.0 <= cache_ptr->resize_ctl.min_clean_fraction); + assert(cache_ptr->resize_ctl.min_clean_fraction <= 100.0); + + /* check to see if cache_ptr->resize_in_progress is TRUE. If it, this + * is a re-entrant call via a client callback called in the resize + * process. To avoid an infinite recursion, set reentrant_call to + * TRUE, and goto done. + */ + if (cache_ptr->resize_in_progress) { + reentrant_call = TRUE; + HGOTO_DONE(SUCCEED); + } /* end if */ + + cache_ptr->resize_in_progress = TRUE; + + if (!cache_ptr->resize_enabled) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Auto cache resize disabled") + + assert((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || + (cache_ptr->resize_ctl.decr_mode != H5C_decr__off)); + + if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") + + assert((0.0 <= hit_rate) && (hit_rate <= 1.0)); + + switch (cache_ptr->resize_ctl.incr_mode) { + case H5C_incr__off: + if (cache_ptr->size_increase_possible) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "size_increase_possible but H5C_incr__off?!?!?") + break; + + case H5C_incr__threshold: + if (hit_rate < cache_ptr->resize_ctl.lower_hr_threshold) { + if (!cache_ptr->size_increase_possible) + status = increase_disabled; + else if (cache_ptr->max_cache_size >= cache_ptr->resize_ctl.max_size) { + assert(cache_ptr->max_cache_size == cache_ptr->resize_ctl.max_size); + status = at_max_size; + } + else if (!cache_ptr->cache_full) + status = not_full; + else { + new_max_cache_size = + (size_t)(((double)(cache_ptr->max_cache_size)) * cache_ptr->resize_ctl.increment); + + /* clip to max size if necessary */ + if (new_max_cache_size > cache_ptr->resize_ctl.max_size) + new_max_cache_size = cache_ptr->resize_ctl.max_size; + + /* clip to max increment if necessary */ + if (cache_ptr->resize_ctl.apply_max_increment && + ((cache_ptr->max_cache_size + cache_ptr->resize_ctl.max_increment) < + new_max_cache_size)) + new_max_cache_size = cache_ptr->max_cache_size + cache_ptr->resize_ctl.max_increment; + + status = increase; + } + } + break; + + default: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") + } + + /* If the decr_mode is either age out or age out with threshold, we + * must run the marker maintenance code, whether we run the size + * reduction code or not. We do this in two places -- here we + * insert a new marker if the number of active epoch markers is + * is less than the current epochs before eviction, and after + * the ageout call, we cycle the markers. + * + * However, we can't call the ageout code or cycle the markers + * unless there was a full complement of markers in place on + * entry. The inserted_epoch_marker flag is used to track this. + */ + + if (((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out) || + (cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out_with_threshold)) && + (cache_ptr->epoch_markers_active < cache_ptr->resize_ctl.epochs_before_eviction)) { + + if (H5C__autoadjust__ageout__insert_new_marker(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't insert new epoch marker") + + inserted_epoch_marker = TRUE; + } + + /* don't run the cache size decrease code unless the cache size + * increase code is disabled, or the size increase code sees no need + * for action. In either case, status == in_spec at this point. + */ + + if (status == in_spec) { + switch (cache_ptr->resize_ctl.decr_mode) { + case H5C_decr__off: + break; + + case H5C_decr__threshold: + if (hit_rate > cache_ptr->resize_ctl.upper_hr_threshold) { + if (!cache_ptr->size_decrease_possible) + status = decrease_disabled; + else if (cache_ptr->max_cache_size <= cache_ptr->resize_ctl.min_size) { + assert(cache_ptr->max_cache_size == cache_ptr->resize_ctl.min_size); + status = at_min_size; + } + else { + new_max_cache_size = + (size_t)(((double)(cache_ptr->max_cache_size)) * cache_ptr->resize_ctl.decrement); + + /* clip to min size if necessary */ + if (new_max_cache_size < cache_ptr->resize_ctl.min_size) + new_max_cache_size = cache_ptr->resize_ctl.min_size; + + /* clip to max decrement if necessary */ + if (cache_ptr->resize_ctl.apply_max_decrement && + ((cache_ptr->resize_ctl.max_decrement + new_max_cache_size) < + cache_ptr->max_cache_size)) + new_max_cache_size = + cache_ptr->max_cache_size - cache_ptr->resize_ctl.max_decrement; + + status = decrease; + } + } + break; + + case H5C_decr__age_out_with_threshold: + case H5C_decr__age_out: + if (!inserted_epoch_marker) { + if (!cache_ptr->size_decrease_possible) + status = decrease_disabled; + else { + if (H5C__autoadjust__ageout(f, hit_rate, &status, &new_max_cache_size, + write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ageout code failed") + } /* end else */ + } /* end if */ + break; + + default: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unknown incr_mode") + } + } + + /* cycle the epoch markers here if appropriate */ + if (((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out) || + (cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out_with_threshold)) && + !inserted_epoch_marker) + /* move last epoch marker to the head of the LRU list */ + if (H5C__autoadjust__ageout__cycle_epoch_marker(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error cycling epoch marker") + + if ((status == increase) || (status == decrease)) { + old_max_cache_size = cache_ptr->max_cache_size; + old_min_clean_size = cache_ptr->min_clean_size; + + new_min_clean_size = + (size_t)((double)new_max_cache_size * (cache_ptr->resize_ctl.min_clean_fraction)); + + /* new_min_clean_size is of size_t, and thus must be non-negative. + * Hence we have + * + * ( 0 <= new_min_clean_size ). + * + * by definition. + */ + assert(new_min_clean_size <= new_max_cache_size); + assert(cache_ptr->resize_ctl.min_size <= new_max_cache_size); + assert(new_max_cache_size <= cache_ptr->resize_ctl.max_size); + + cache_ptr->max_cache_size = new_max_cache_size; + cache_ptr->min_clean_size = new_min_clean_size; + + if (status == increase) + cache_ptr->cache_full = FALSE; + else if (status == decrease) + cache_ptr->size_decreased = TRUE; + + /* update flash cache size increase fields as appropriate */ + if (cache_ptr->flash_size_increase_possible) { + switch (cache_ptr->resize_ctl.flash_incr_mode) { + case H5C_flash_incr__off: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") + break; + + case H5C_flash_incr__add_space: + cache_ptr->flash_size_increase_threshold = + (size_t)(((double)(cache_ptr->max_cache_size)) * + (cache_ptr->resize_ctl.flash_threshold)); + break; + + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; + } + } + } + + if (cache_ptr->resize_ctl.rpt_fcn != NULL) + (cache_ptr->resize_ctl.rpt_fcn)(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, status, + old_max_cache_size, new_max_cache_size, old_min_clean_size, + new_min_clean_size); + + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + /* this should be impossible... */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") + +done: + /* Sanity checks */ + assert(cache_ptr->resize_in_progress); + if (!reentrant_call) + cache_ptr->resize_in_progress = FALSE; + assert((!reentrant_call) || (cache_ptr->resize_in_progress)); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__auto_adjust_cache_size() */ + +/*------------------------------------------------------------------------- + * Function: H5C__autoadjust__ageout + * + * Purpose: Implement the ageout automatic cache size decrement + * algorithm. Note that while this code evicts aged out + * entries, the code does not change the maximum cache size. + * Instead, the function simply computes the new value (if + * any change is indicated) and reports this value in + * *new_max_cache_size_ptr. + * + * Return: Non-negative on success/Negative on failure or if there was + * an attempt to flush a protected item. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *status_ptr, + size_t *new_max_cache_size_ptr, hbool_t write_permitted) +{ + H5C_t *cache_ptr = f->shared->cache; + size_t test_size; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(f); + assert(cache_ptr); + assert((status_ptr) && (*status_ptr == in_spec)); + assert((new_max_cache_size_ptr) && (*new_max_cache_size_ptr == 0)); + + /* remove excess epoch markers if any */ + if (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) + if (H5C__autoadjust__ageout__remove_excess_markers(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't remove excess epoch markers") + + if ((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out) || + ((cache_ptr->resize_ctl.decr_mode == H5C_decr__age_out_with_threshold) && + (hit_rate >= cache_ptr->resize_ctl.upper_hr_threshold))) { + + if (cache_ptr->max_cache_size > cache_ptr->resize_ctl.min_size) { + /* evict aged out cache entries if appropriate... */ + if (H5C__autoadjust__ageout__evict_aged_out_entries(f, write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error flushing aged out entries") + + /* ... and then reduce cache size if appropriate */ + if (cache_ptr->index_size < cache_ptr->max_cache_size) { + if (cache_ptr->resize_ctl.apply_empty_reserve) { + test_size = + (size_t)(((double)cache_ptr->index_size) / (1 - cache_ptr->resize_ctl.empty_reserve)); + if (test_size < cache_ptr->max_cache_size) { + *status_ptr = decrease; + *new_max_cache_size_ptr = test_size; + } + } + else { + *status_ptr = decrease; + *new_max_cache_size_ptr = cache_ptr->index_size; + } + + if (*status_ptr == decrease) { + /* clip to min size if necessary */ + if (*new_max_cache_size_ptr < cache_ptr->resize_ctl.min_size) + *new_max_cache_size_ptr = cache_ptr->resize_ctl.min_size; + + /* clip to max decrement if necessary */ + if ((cache_ptr->resize_ctl.apply_max_decrement) && + ((cache_ptr->resize_ctl.max_decrement + *new_max_cache_size_ptr) < + cache_ptr->max_cache_size)) + *new_max_cache_size_ptr = + cache_ptr->max_cache_size - cache_ptr->resize_ctl.max_decrement; + } + } + } + else + *status_ptr = at_min_size; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__autoadjust__ageout() */ + +/*------------------------------------------------------------------------- + * Function: H5C__autoadjust__ageout__cycle_epoch_marker + * + * Purpose: Remove the oldest epoch marker from the LRU list, + * and reinsert it at the head of the LRU list. Also + * remove the epoch marker's index from the head of the + * ring buffer, and re-insert it at the tail of the ring + * buffer. + * + * Return: SUCCEED on success/FAIL on failure. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) +{ + int i; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (cache_ptr->epoch_markers_active <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "No active epoch markers on entry?!?!?") + + /* remove the last marker from both the ring buffer and the LRU list */ + i = cache_ptr->epoch_marker_ringbuf[cache_ptr->epoch_marker_ringbuf_first]; + cache_ptr->epoch_marker_ringbuf_first = + (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); + if (cache_ptr->epoch_marker_ringbuf_size <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + + cache_ptr->epoch_marker_ringbuf_size -= 1; + if (cache_ptr->epoch_marker_active[i] != TRUE) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") + + H5C__DLL_REMOVE((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, + (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (FAIL)) + + /* now, re-insert it at the head of the LRU list, and at the tail of + * the ring buffer. + */ + assert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); + assert(cache_ptr->epoch_markers[i].next == NULL); + assert(cache_ptr->epoch_markers[i].prev == NULL); + + cache_ptr->epoch_marker_ringbuf_last = + (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); + cache_ptr->epoch_marker_ringbuf[cache_ptr->epoch_marker_ringbuf_last] = i; + if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") + + cache_ptr->epoch_marker_ringbuf_size += 1; + + H5C__DLL_PREPEND(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, + cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C__autoadjust__ageout__cycle_epoch_marker() */ + +/*------------------------------------------------------------------------- + * Function: H5C__autoadjust__ageout__evict_aged_out_entries + * + * Purpose: Evict clean entries in the cache that haven't + * been accessed for at least + * cache_ptr->resize_ctl.epochs_before_eviction epochs, + * and flush dirty entries that haven't been accessed for + * that amount of time. + * + * Depending on configuration, the function will either + * flush or evict all such entries, or all such entries it + * encounters until it has freed the maximum amount of space + * allowed under the maximum decrement. + * + * If we are running in parallel mode, writes may not be + * permitted. If so, the function simply skips any dirty + * entries it may encounter. + * + * The function makes no attempt to maintain the minimum + * clean size, as there is no guarantee that the cache size + * will be changed. + * + * If there is no cache size change, the minimum clean size + * constraint will be met through a combination of clean + * entries and free space in the cache. + * + * If there is a cache size reduction, the minimum clean size + * will be re-calculated, and will be enforced the next time + * we have to make space in the cache. + * + * Return: Non-negative on success/Negative on failure. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted) +{ + H5C_t *cache_ptr = f->shared->cache; + size_t eviction_size_limit; + size_t bytes_evicted = 0; + hbool_t prev_is_dirty = FALSE; + hbool_t restart_scan; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *next_ptr; + H5C_cache_entry_t *prev_ptr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(f); + assert(cache_ptr); + + /* if there is a limit on the amount that the cache size can be decrease + * in any one round of the cache size reduction algorithm, load that + * limit into eviction_size_limit. Otherwise, set eviction_size_limit + * to the equivalent of infinity. The current size of the index will + * do nicely. + */ + if (cache_ptr->resize_ctl.apply_max_decrement) + eviction_size_limit = cache_ptr->resize_ctl.max_decrement; + else + eviction_size_limit = cache_ptr->index_size; /* i.e. infinity */ + + if (write_permitted) { + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + while (entry_ptr != NULL && entry_ptr->type->id != H5AC_EPOCH_MARKER_ID && + bytes_evicted < eviction_size_limit) { + hbool_t skipping_entry = FALSE; + + assert(!(entry_ptr->is_protected)); + assert(!(entry_ptr->is_read_only)); + assert((entry_ptr->ro_ref_count) == 0); + + next_ptr = entry_ptr->next; + prev_ptr = entry_ptr->prev; + + if (prev_ptr != NULL) + prev_is_dirty = prev_ptr->is_dirty; + + if (entry_ptr->is_dirty) { + assert(!entry_ptr->prefetched_dirty); + + /* dirty corked entry is skipped */ + if (entry_ptr->tag_info && entry_ptr->tag_info->corked) + skipping_entry = TRUE; + else { + /* reset entries_removed_counter and + * last_entry_removed_ptr prior to the call to + * H5C__flush_single_entry() so that we can spot + * unexpected removals of entries from the cache, + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry + * that is no longer in the cache. + */ + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; + + if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + + if (cache_ptr->entries_removed_counter > 1 || + cache_ptr->last_entry_removed_ptr == prev_ptr) + restart_scan = TRUE; + } /* end else */ + } /* end if */ + else if (!entry_ptr->prefetched_dirty) { + bytes_evicted += entry_ptr->size; + + if (H5C__flush_single_entry( + f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + } /* end else-if */ + else { + assert(!entry_ptr->is_dirty); + assert(entry_ptr->prefetched_dirty); + + skipping_entry = TRUE; + } /* end else */ + + if (prev_ptr != NULL) { + if (skipping_entry) + entry_ptr = prev_ptr; + else if (restart_scan || (prev_ptr->is_dirty != prev_is_dirty) || + (prev_ptr->next != next_ptr) || (prev_ptr->is_protected) || (prev_ptr->is_pinned)) { + /* Something has happened to the LRU -- start over + * from the tail. + */ + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr); + } /* end else-if */ + else + entry_ptr = prev_ptr; + } /* end if */ + else + entry_ptr = NULL; + } /* end while */ + + /* for now at least, don't bother to maintain the minimum clean size, + * as the cache should now be less than its maximum size. Due to + * the vaguries of the cache size reduction algorithm, we may not + * reduce the size of the cache. + * + * If we do, we will calculate a new minimum clean size, which will + * be enforced the next time we try to make space in the cache. + * + * If we don't, no action is necessary, as we have just evicted and/or + * or flushed a bunch of entries and therefore the sum of the clean + * and free space in the cache must be greater than or equal to the + * min clean space requirement (assuming that requirement was met on + * entry). + */ + } /* end if */ + else /* ! write_permitted */ { + /* Since we are not allowed to write, all we can do is evict + * any clean entries that we may encounter before we either + * hit the eviction size limit, or encounter the epoch marker. + * + * If we are operating read only, this isn't an issue, as there + * will not be any dirty entries. + * + * If we are operating in R/W mode, all the dirty entries we + * skip will be flushed the next time we attempt to make space + * when writes are permitted. This may have some local + * performance implications, but it shouldn't cause any net + * slowdown. + */ + assert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); + entry_ptr = cache_ptr->LRU_tail_ptr; + while (entry_ptr != NULL && ((entry_ptr->type)->id != H5AC_EPOCH_MARKER_ID) && + (bytes_evicted < eviction_size_limit)) { + assert(!(entry_ptr->is_protected)); + + prev_ptr = entry_ptr->prev; + + if (!(entry_ptr->is_dirty) && !(entry_ptr->prefetched_dirty)) + if (H5C__flush_single_entry( + f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") + + /* just skip the entry if it is dirty, as we can't do + * anything with it now since we can't write. + * + * Since all entries are clean, serialize() will not be called, + * and thus we needn't test to see if the LRU has been changed + * out from under us. + */ + entry_ptr = prev_ptr; + } /* end while */ + } /* end else */ + + if (cache_ptr->index_size < cache_ptr->max_cache_size) + cache_ptr->cache_full = FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__autoadjust__ageout__evict_aged_out_entries() */ + +/*------------------------------------------------------------------------- + * Function: H5C__autoadjust__ageout__insert_new_marker + * + * Purpose: Find an unused marker cache entry, mark it as used, and + * insert it at the head of the LRU list. Also add the + * marker's index in the epoch_markers array. + * + * Return: SUCCEED on success/FAIL on failure. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr) +{ + int i; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (cache_ptr->epoch_markers_active >= cache_ptr->resize_ctl.epochs_before_eviction) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Already have a full complement of markers") + + /* find an unused marker */ + i = 0; + while ((cache_ptr->epoch_marker_active)[i] && i < H5C__MAX_EPOCH_MARKERS) + i++; + if (i >= H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't find unused marker") + + assert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); + assert(((cache_ptr->epoch_markers)[i]).next == NULL); + assert(((cache_ptr->epoch_markers)[i]).prev == NULL); + + (cache_ptr->epoch_marker_active)[i] = TRUE; + + cache_ptr->epoch_marker_ringbuf_last = + (cache_ptr->epoch_marker_ringbuf_last + 1) % (H5C__MAX_EPOCH_MARKERS + 1); + (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; + if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") + + cache_ptr->epoch_marker_ringbuf_size += 1; + + H5C__DLL_PREPEND(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, + cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) + + cache_ptr->epoch_markers_active += 1; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__autoadjust__ageout__insert_new_marker() */ + +/*------------------------------------------------------------------------- + * Function: H5C__autoadjust__ageout__remove_all_markers + * + * Purpose: Remove all epoch markers from the LRU list and mark them + * as inactive. + * + * Return: SUCCEED on success/FAIL on failure. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr) +{ + int ring_buf_index; + int i; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + while (cache_ptr->epoch_markers_active > 0) { + /* get the index of the last epoch marker in the LRU list + * and remove it from the ring buffer. + */ + + ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; + i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; + + cache_ptr->epoch_marker_ringbuf_first = + (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); + + if (cache_ptr->epoch_marker_ringbuf_size <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + cache_ptr->epoch_marker_ringbuf_size -= 1; + + if (cache_ptr->epoch_marker_active[i] != TRUE) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") + + /* remove the epoch marker from the LRU list */ + H5C__DLL_REMOVE(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, + cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) + + /* mark the epoch marker as unused. */ + cache_ptr->epoch_marker_active[i] = FALSE; + + assert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); + assert(cache_ptr->epoch_markers[i].next == NULL); + assert(cache_ptr->epoch_markers[i].prev == NULL); + + /* decrement the number of active epoch markers */ + cache_ptr->epoch_markers_active -= 1; + + assert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__autoadjust__ageout__remove_all_markers() */ + +/*------------------------------------------------------------------------- + * Function: H5C__autoadjust__ageout__remove_excess_markers + * + * Purpose: Remove epoch markers from the end of the LRU list and + * mark them as inactive until the number of active markers + * equals the current value of + * cache_ptr->resize_ctl.epochs_before_eviction. + * + * Return: SUCCEED on success/FAIL on failure. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr) +{ + int ring_buf_index; + int i; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + + if (cache_ptr->epoch_markers_active <= cache_ptr->resize_ctl.epochs_before_eviction) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "no excess markers on entry") + + while (cache_ptr->epoch_markers_active > cache_ptr->resize_ctl.epochs_before_eviction) { + /* get the index of the last epoch marker in the LRU list + * and remove it from the ring buffer. + */ + ring_buf_index = cache_ptr->epoch_marker_ringbuf_first; + i = (cache_ptr->epoch_marker_ringbuf)[ring_buf_index]; + + cache_ptr->epoch_marker_ringbuf_first = + (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); + + if (cache_ptr->epoch_marker_ringbuf_size <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + cache_ptr->epoch_marker_ringbuf_size -= 1; + + if (cache_ptr->epoch_marker_active[i] != TRUE) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") + + /* remove the epoch marker from the LRU list */ + H5C__DLL_REMOVE(&(cache_ptr->epoch_markers[i]), cache_ptr->LRU_head_ptr, cache_ptr->LRU_tail_ptr, + cache_ptr->LRU_list_len, cache_ptr->LRU_list_size, FAIL) + + /* mark the epoch marker as unused. */ + cache_ptr->epoch_marker_active[i] = FALSE; + + assert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); + assert(cache_ptr->epoch_markers[i].next == NULL); + assert(cache_ptr->epoch_markers[i].prev == NULL); + + /* decrement the number of active epoch markers */ + cache_ptr->epoch_markers_active -= 1; + + assert(cache_ptr->epoch_markers_active == cache_ptr->epoch_marker_ringbuf_size); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__autoadjust__ageout__remove_excess_markers() */ + +/*------------------------------------------------------------------------- + * Function: H5C__flash_increase_cache_size + * + * Purpose: If there is not at least new_entry_size - old_entry_size + * bytes of free space in the cache and the current + * max_cache_size is less than cache_ptr->resize_ctl.max_size, + * perform a flash increase in the cache size and then reset + * the full cache hit rate statistics, and exit. + * + * Return: Non-negative on success/Negative on failure. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t new_entry_size) +{ + size_t new_max_cache_size = 0; + size_t old_max_cache_size = 0; + size_t new_min_clean_size = 0; + size_t old_min_clean_size = 0; + size_t space_needed; + enum H5C_resize_status status = flash_increase; /* may change */ + double hit_rate; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + assert(cache_ptr->flash_size_increase_possible); + assert(new_entry_size > cache_ptr->flash_size_increase_threshold); + assert(old_entry_size < new_entry_size); + + if (old_entry_size >= new_entry_size) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "old_entry_size >= new_entry_size") + + space_needed = new_entry_size - old_entry_size; + if (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && + (cache_ptr->max_cache_size < cache_ptr->resize_ctl.max_size)) { + switch (cache_ptr->resize_ctl.flash_incr_mode) { + case H5C_flash_incr__off: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") + break; + + case H5C_flash_incr__add_space: + if (cache_ptr->index_size < cache_ptr->max_cache_size) { + assert((cache_ptr->max_cache_size - cache_ptr->index_size) < space_needed); + space_needed -= cache_ptr->max_cache_size - cache_ptr->index_size; + } + space_needed = (size_t)(((double)space_needed) * cache_ptr->resize_ctl.flash_multiple); + new_max_cache_size = cache_ptr->max_cache_size + space_needed; + break; + + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; + } + + if (new_max_cache_size > cache_ptr->resize_ctl.max_size) + new_max_cache_size = cache_ptr->resize_ctl.max_size; + assert(new_max_cache_size > cache_ptr->max_cache_size); + + new_min_clean_size = (size_t)((double)new_max_cache_size * cache_ptr->resize_ctl.min_clean_fraction); + assert(new_min_clean_size <= new_max_cache_size); + + old_max_cache_size = cache_ptr->max_cache_size; + old_min_clean_size = cache_ptr->min_clean_size; + + cache_ptr->max_cache_size = new_max_cache_size; + cache_ptr->min_clean_size = new_min_clean_size; + + /* update flash cache size increase fields as appropriate */ + assert(cache_ptr->flash_size_increase_possible); + + switch (cache_ptr->resize_ctl.flash_incr_mode) { + case H5C_flash_incr__off: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flash_size_increase_possible but H5C_flash_incr__off?!") + break; + + case H5C_flash_incr__add_space: + cache_ptr->flash_size_increase_threshold = + (size_t)((double)cache_ptr->max_cache_size * cache_ptr->resize_ctl.flash_threshold); + break; + + default: /* should be unreachable */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown flash_incr_mode?!?!?") + break; + } + + /* note that we don't cycle the epoch markers. We can + * argue either way as to whether we should, but for now + * we don't. + */ + + if (cache_ptr->resize_ctl.rpt_fcn != NULL) { + /* get the hit rate for the reporting function. Should still + * be good as we haven't reset the hit rate statistics. + */ + if (H5C_get_cache_hit_rate(cache_ptr, &hit_rate) != SUCCEED) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get hit rate") + + (cache_ptr->resize_ctl.rpt_fcn)(cache_ptr, H5C__CURR_AUTO_RESIZE_RPT_FCN_VER, hit_rate, status, + old_max_cache_size, new_max_cache_size, old_min_clean_size, + new_min_clean_size); + } + + if (H5C_reset_cache_hit_rate_stats(cache_ptr) < 0) + /* this should be impossible... */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_reset_cache_hit_rate_stats failed") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flash_increase_cache_size() */ + +/*------------------------------------------------------------------------- + * Function: H5C__flush_invalidate_cache + * + * Purpose: Flush and destroy the entries contained in the target + * cache. + * + * If the cache contains protected entries, the function will + * fail, as protected entries cannot be either flushed or + * destroyed. However all unprotected entries should be + * flushed and destroyed before the function returns failure. + * + * While pinned entries can usually be flushed, they cannot + * be destroyed. However, they should be unpinned when all + * the entries that reference them have been destroyed (thus + * reduding the pinned entry's reference count to 0, allowing + * it to be unpinned). + * + * If pinned entries are present, the function makes repeated + * passes through the cache, flushing all dirty entries + * (including the pinned dirty entries where permitted) and + * destroying all unpinned entries. This process is repeated + * until either the cache is empty, or the number of pinned + * entries stops decreasing on each pass. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) +{ + H5C_t *cache_ptr; + H5C_ring_t ring; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + assert(f); + assert(f->shared); + cache_ptr = f->shared->cache; + assert(cache_ptr); + assert(cache_ptr->slist_ptr); + assert(cache_ptr->slist_enabled); + +#ifdef H5C_DO_SANITY_CHECKS + { + int32_t i; + uint32_t index_len = 0; + uint32_t slist_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + + assert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); + assert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + assert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + assert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + assert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); + assert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + index_len += cache_ptr->index_ring_len[i]; + index_size += cache_ptr->index_ring_size[i]; + clean_index_size += cache_ptr->clean_index_ring_size[i]; + dirty_index_size += cache_ptr->dirty_index_ring_size[i]; + + slist_len += cache_ptr->slist_ring_len[i]; + slist_size += cache_ptr->slist_ring_size[i]; + } /* end for */ + + assert(cache_ptr->index_len == index_len); + assert(cache_ptr->index_size == index_size); + assert(cache_ptr->clean_index_size == clean_index_size); + assert(cache_ptr->dirty_index_size == dirty_index_size); + assert(cache_ptr->slist_len == slist_len); + assert(cache_ptr->slist_size == slist_size); + } +#endif /* H5C_DO_SANITY_CHECKS */ + + /* remove ageout markers if present */ + if (cache_ptr->epoch_markers_active > 0) + if (H5C__autoadjust__ageout__remove_all_markers(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "error removing all epoch markers") + + /* flush invalidate each ring, starting from the outermost ring and + * working inward. + */ + ring = H5C_RING_USER; + while (ring < H5C_RING_NTYPES) { + if (H5C__flush_invalidate_ring(f, ring, flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "flush invalidate ring failed") + ring++; + } /* end while */ + +#ifndef NDEBUG + /* Invariants, after destroying all entries in the hash table */ + if (!(flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG)) { + assert(cache_ptr->index_size == 0); + assert(cache_ptr->clean_index_size == 0); + assert(cache_ptr->pel_len == 0); + assert(cache_ptr->pel_size == 0); + } /* end if */ + else { + H5C_cache_entry_t *entry_ptr; /* Cache entry */ + unsigned u; /* Local index variable */ + + /* All rings except ring 4 should be empty now */ + /* (Ring 4 has the superblock) */ + for (u = H5C_RING_USER; u < H5C_RING_SB; u++) { + assert(cache_ptr->index_ring_len[u] == 0); + assert(cache_ptr->index_ring_size[u] == 0); + assert(cache_ptr->clean_index_ring_size[u] == 0); + } /* end for */ + + /* Check that any remaining pinned entries are in the superblock ring */ + entry_ptr = cache_ptr->pel_head_ptr; + while (entry_ptr) { + /* Check ring */ + assert(entry_ptr->ring == H5C_RING_SB); + + /* Advance to next entry in pinned entry list */ + entry_ptr = entry_ptr->next; + } /* end while */ + } /* end else */ + + assert(cache_ptr->dirty_index_size == 0); + assert(cache_ptr->slist_len == 0); + assert(cache_ptr->slist_size == 0); + assert(cache_ptr->pl_len == 0); + assert(cache_ptr->pl_size == 0); + assert(cache_ptr->LRU_list_len == 0); + assert(cache_ptr->LRU_list_size == 0); +#endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_invalidate_cache() */ + +/*------------------------------------------------------------------------- + * Function: H5C__flush_invalidate_ring + * + * Purpose: Flush and destroy the entries contained in the target + * cache and ring. + * + * If the ring contains protected entries, the function will + * fail, as protected entries cannot be either flushed or + * destroyed. However all unprotected entries should be + * flushed and destroyed before the function returns failure. + * + * While pinned entries can usually be flushed, they cannot + * be destroyed. However, they should be unpinned when all + * the entries that reference them have been destroyed (thus + * reduding the pinned entry's reference count to 0, allowing + * it to be unpinned). + * + * If pinned entries are present, the function makes repeated + * passes through the cache, flushing all dirty entries + * (including the pinned dirty entries where permitted) and + * destroying all unpinned entries. This process is repeated + * until either the cache is empty, or the number of pinned + * entries stops decreasing on each pass. + * + * If flush dependencies appear in the target ring, the + * function makes repeated passes through the cache flushing + * entries in flush dependency order. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) +{ + H5C_t *cache_ptr; + hbool_t restart_slist_scan; + uint32_t protected_entries = 0; + int32_t i; + uint32_t cur_ring_pel_len; + uint32_t old_ring_pel_len; + unsigned cooked_flags; + unsigned evict_flags; + H5SL_node_t *node_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *next_entry_ptr = NULL; +#ifdef H5C_DO_SANITY_CHECKS + uint32_t initial_slist_len = 0; + size_t initial_slist_size = 0; +#endif /* H5C_DO_SANITY_CHECKS */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + assert(f); + assert(f->shared); + cache_ptr = f->shared->cache; + assert(cache_ptr); + assert(cache_ptr->slist_enabled); + assert(cache_ptr->slist_ptr); + assert(ring > H5C_RING_UNDEFINED); + assert(ring < H5C_RING_NTYPES); + + assert(cache_ptr->epoch_markers_active == 0); + + /* Filter out the flags that are not relevant to the flush/invalidate. + */ + cooked_flags = flags & H5C__FLUSH_CLEAR_ONLY_FLAG; + evict_flags = flags & H5C__EVICT_ALLOW_LAST_PINS_FLAG; + + /* The flush procedure here is a bit strange. + * + * In the outer while loop we make at least one pass through the + * cache, and then repeat until either all the pinned entries in + * the ring unpin themselves, or until the number of pinned entries + * in the ring stops declining. In this later case, we scream and die. + * + * Since the fractal heap can dirty, resize, and/or move entries + * in is flush callback, it is possible that the cache will still + * contain dirty entries at this point. If so, we must make more + * passes through the skip list to allow it to empty. + * + * Further, since clean entries can be dirtied, resized, and/or moved + * as the result of a flush call back (either the entries own, or that + * for some other cache entry), we can no longer promise to flush + * the cache entries in increasing address order. + * + * Instead, we make a pass through + * the skip list, and then a pass through the "clean" entries, and + * then repeating as needed. Thus it is quite possible that an + * entry will be evicted from the cache only to be re-loaded later + * in the flush process. + * + * The bottom line is that entries will probably be flushed in close + * to increasing address order, but there are no guarantees. + */ + + /* compute the number of pinned entries in this ring */ + entry_ptr = cache_ptr->pel_head_ptr; + cur_ring_pel_len = 0; + while (entry_ptr != NULL) { + assert(entry_ptr->ring >= ring); + if (entry_ptr->ring == ring) + cur_ring_pel_len++; + + entry_ptr = entry_ptr->next; + } /* end while */ + old_ring_pel_len = cur_ring_pel_len; + + while (cache_ptr->index_ring_len[ring] > 0) { + /* first, try to flush-destroy any dirty entries. Do this by + * making a scan through the slist. Note that new dirty entries + * may be created by the flush call backs. Thus it is possible + * that the slist will not be empty after we finish the scan. + */ + +#ifdef H5C_DO_SANITY_CHECKS + /* Depending on circumstances, H5C__flush_single_entry() will + * remove dirty entries from the slist as it flushes them. + * Thus for sanity checks we must make note of the initial + * slist length and size before we do any flushes. + */ + initial_slist_len = cache_ptr->slist_len; + initial_slist_size = cache_ptr->slist_size; + + /* There is also the possibility that entries will be + * dirtied, resized, moved, and/or removed from the cache + * as the result of calls to the flush callbacks. We use + * the slist_len_increase and slist_size_increase increase + * fields in struct H5C_t to track these changes for purpose + * of sanity checking. + * + * To this end, we must zero these fields before we start + * the pass through the slist. + */ + cache_ptr->slist_len_increase = 0; + cache_ptr->slist_size_increase = 0; +#endif /* H5C_DO_SANITY_CHECKS */ + + /* Set the cache_ptr->slist_changed to false. + * + * This flag is set to TRUE by H5C__flush_single_entry if the slist + * is modified by a pre_serialize, serialize, or notify callback. + * + * H5C__flush_invalidate_ring() uses this flag to detect any + * modifications to the slist that might corrupt the scan of + * the slist -- and restart the scan in this event. + */ + cache_ptr->slist_changed = FALSE; + + /* this done, start the scan of the slist */ + restart_slist_scan = TRUE; + while (restart_slist_scan || (node_ptr != NULL)) { + if (restart_slist_scan) { + restart_slist_scan = FALSE; + + /* Start at beginning of skip list */ + node_ptr = H5SL_first(cache_ptr->slist_ptr); + if (node_ptr == NULL) + /* the slist is empty -- break out of inner loop */ + break; + + /* Get cache entry for this node */ + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + + assert(next_entry_ptr->is_dirty); + assert(next_entry_ptr->in_slist); + assert(next_entry_ptr->ring >= ring); + } /* end if */ + + entry_ptr = next_entry_ptr; + + /* It is possible that entries will be dirtied, resized, + * flushed, or removed from the cache via the take ownership + * flag as the result of pre_serialize or serialized callbacks. + * + * This in turn can corrupt the scan through the slist. + * + * We test for slist modifications in the pre_serialize + * and serialize callbacks, and restart the scan of the + * slist if we find them. However, best we do some extra + * sanity checking just in case. + */ + assert(entry_ptr != NULL); + assert(entry_ptr->in_slist); + assert(entry_ptr->is_dirty); + assert(entry_ptr->ring >= ring); + + /* increment node pointer now, before we delete its target + * from the slist. + */ + node_ptr = H5SL_next(node_ptr); + if (node_ptr != NULL) { + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + + assert(next_entry_ptr->is_dirty); + assert(next_entry_ptr->in_slist); + assert(next_entry_ptr->ring >= ring); + assert(entry_ptr != next_entry_ptr); + } /* end if */ + else + next_entry_ptr = NULL; + + /* Note that we now remove nodes from the slist as we flush + * the associated entries, instead of leaving them there + * until we are done, and then destroying all nodes in + * the slist. + * + * While this optimization used to be easy, with the possibility + * of new entries being added to the slist in the midst of the + * flush, we must keep the slist in canonical form at all + * times. + */ + if (((!entry_ptr->flush_me_last) || + ((entry_ptr->flush_me_last) && (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && + (entry_ptr->flush_dep_nchildren == 0) && (entry_ptr->ring == ring)) { + if (entry_ptr->is_protected) { + /* We have major problems -- but lets flush + * everything we can before we flag an error. + */ + protected_entries++; + } /* end if */ + else if (entry_ptr->is_pinned) { + if (H5C__flush_single_entry(f, entry_ptr, H5C__DURING_FLUSH_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty pinned entry flush failed") + + if (cache_ptr->slist_changed) { + /* The slist has been modified by something + * other than the simple removal of the + * of the flushed entry after the flush. + * + * This has the potential to corrupt the + * scan through the slist, so restart it. + */ + restart_slist_scan = TRUE; + cache_ptr->slist_changed = FALSE; + H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr); + } /* end if */ + } /* end else-if */ + else { + if (H5C__flush_single_entry(f, entry_ptr, + (cooked_flags | H5C__DURING_FLUSH_FLAG | + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "dirty entry flush destroy failed") + + if (cache_ptr->slist_changed) { + /* The slist has been modified by something + * other than the simple removal of the + * of the flushed entry after the flush. + * + * This has the potential to corrupt the + * scan through the slist, so restart it. + */ + restart_slist_scan = TRUE; + cache_ptr->slist_changed = FALSE; + H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr); + } /* end if */ + } /* end else */ + } /* end if */ + } /* end while loop scanning skip list */ + +#ifdef H5C_DO_SANITY_CHECKS + /* It is possible that entries were added to the slist during + * the scan, either before or after scan pointer. The following + * asserts take this into account. + * + * Don't bother with the sanity checks if node_ptr != NULL, as + * in this case we broke out of the loop because it got changed + * out from under us. + */ + + if (node_ptr == NULL) { + assert(cache_ptr->slist_len == + (uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase)); + assert(cache_ptr->slist_size == + (size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase)); + } /* end if */ +#endif /* H5C_DO_SANITY_CHECKS */ + + /* Since we are doing a destroy, we must make a pass through + * the hash table and try to flush - destroy all entries that + * remain. + * + * It used to be that all entries remaining in the cache at + * this point had to be clean, but with the fractal heap mods + * this may not be the case. If so, we will flush entries out + * in increasing address order. + * + * Writes to disk are possible here. + */ + + /* Reset the counters so that we can detect insertions, loads, + * and moves caused by the pre_serialize and serialize calls. + */ + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + next_entry_ptr = cache_ptr->il_head; + while (next_entry_ptr != NULL) { + entry_ptr = next_entry_ptr; + assert(entry_ptr->ring >= ring); + + next_entry_ptr = entry_ptr->il_next; + + if (((!entry_ptr->flush_me_last) || + (entry_ptr->flush_me_last && (cache_ptr->num_last_entries >= cache_ptr->slist_len))) && + (entry_ptr->flush_dep_nchildren == 0) && (entry_ptr->ring == ring)) { + + if (entry_ptr->is_protected) { + /* we have major problems -- but lets flush and + * destroy everything we can before we flag an + * error. + */ + protected_entries++; + + if (!entry_ptr->in_slist) + assert(!(entry_ptr->is_dirty)); + } /* end if */ + else if (!entry_ptr->is_pinned) { + /* if *entry_ptr is dirty, it is possible + * that one or more other entries may be + * either removed from the cache, loaded + * into the cache, or moved to a new location + * in the file as a side effect of the flush. + * + * It's also possible that removing a clean + * entry will remove the last child of a proxy + * entry, allowing it to be removed also and + * invalidating the next_entry_ptr. + * + * If either of these happen, and one of the target + * or proxy entries happens to be the next entry in + * the hash bucket, we could either find ourselves + * either scanning a non-existent entry, scanning + * through a different bucket, or skipping an entry. + * + * Neither of these are good, so restart the + * the scan at the head of the hash bucket + * after the flush if we detect that the next_entry_ptr + * becomes invalid. + * + * This is not as inefficient at it might seem, + * as hash buckets typically have at most two + * or three entries. + */ + cache_ptr->entry_watched_for_removal = next_entry_ptr; + if (H5C__flush_single_entry(f, entry_ptr, + (cooked_flags | H5C__DURING_FLUSH_FLAG | + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Entry flush destroy failed") + + /* Restart the index list scan if necessary. Must + * do this if the next entry is evicted, and also if + * one or more entries are inserted, loaded, or moved + * as these operations can result in part of the scan + * being skipped -- which can cause a spurious failure + * if this results in the size of the pinned entry + * failing to decline during the pass. + */ + if (((NULL != next_entry_ptr) && (NULL == cache_ptr->entry_watched_for_removal)) || + (cache_ptr->entries_loaded_counter > 0) || + (cache_ptr->entries_inserted_counter > 0) || + (cache_ptr->entries_relocated_counter > 0)) { + + next_entry_ptr = cache_ptr->il_head; + + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr); + } /* end if */ + else + cache_ptr->entry_watched_for_removal = NULL; + } /* end if */ + } /* end if */ + } /* end for loop scanning hash table */ + + /* We can't do anything if entries are pinned. The + * hope is that the entries will be unpinned as the + * result of destroys of entries that reference them. + * + * We detect this by noting the change in the number + * of pinned entries from pass to pass. If it stops + * shrinking before it hits zero, we scream and die. + */ + old_ring_pel_len = cur_ring_pel_len; + entry_ptr = cache_ptr->pel_head_ptr; + cur_ring_pel_len = 0; + + while (entry_ptr != NULL) { + assert(entry_ptr->ring >= ring); + + if (entry_ptr->ring == ring) + cur_ring_pel_len++; + + entry_ptr = entry_ptr->next; + } /* end while */ + + /* Check if the number of pinned entries in the ring is positive, and + * it is not declining. Scream and die if so. + */ + if ((cur_ring_pel_len > 0) && (cur_ring_pel_len >= old_ring_pel_len)) { + /* Don't error if allowed to have pinned entries remaining */ + if (evict_flags) + HGOTO_DONE(TRUE); + + HGOTO_ERROR( + H5E_CACHE, H5E_CANTFLUSH, FAIL, + "Pinned entry count not decreasing, cur_ring_pel_len = %d, old_ring_pel_len = %d, ring = %d", + (int)cur_ring_pel_len, (int)old_ring_pel_len, (int)ring) + } /* end if */ + + assert(protected_entries == cache_ptr->pl_len); + + if ((protected_entries > 0) && (protected_entries == cache_ptr->index_len)) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, + "Only protected entries left in cache, protected_entries = %d", + (int)protected_entries) + } /* main while loop */ + + /* Invariants, after destroying all entries in the ring */ + for (i = (int)H5C_RING_UNDEFINED; i <= (int)ring; i++) { + assert(cache_ptr->index_ring_len[i] == 0); + assert(cache_ptr->index_ring_size[i] == (size_t)0); + assert(cache_ptr->clean_index_ring_size[i] == (size_t)0); + assert(cache_ptr->dirty_index_ring_size[i] == (size_t)0); + + assert(cache_ptr->slist_ring_len[i] == 0); + assert(cache_ptr->slist_ring_size[i] == (size_t)0); + } /* end for */ + + assert(protected_entries <= cache_ptr->pl_len); + + if (protected_entries > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cache has protected entries") + else if (cur_ring_pel_len > 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't unpin all pinned entries in ring") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_invalidate_ring() */ + +/*------------------------------------------------------------------------- + * Function: H5C__flush_ring + * + * Purpose: Flush the entries contained in the specified cache and + * ring. All entries in rings outside the specified ring + * must have been flushed on entry. + * + * If the cache contains protected entries in the specified + * ring, the function will fail, as protected entries cannot + * be flushed. However all unprotected entries in the target + * ring should be flushed before the function returns failure. + * + * If flush dependencies appear in the target ring, the + * function makes repeated passes through the slist flushing + * entries in flush dependency order. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) +{ + H5C_t *cache_ptr = f->shared->cache; + hbool_t flushed_entries_last_pass; + hbool_t flush_marked_entries; + hbool_t ignore_protected; + hbool_t tried_to_flush_protected_entry = FALSE; + hbool_t restart_slist_scan; + uint32_t protected_entries = 0; + H5SL_node_t *node_ptr = NULL; + H5C_cache_entry_t *entry_ptr = NULL; + H5C_cache_entry_t *next_entry_ptr = NULL; +#ifdef H5C_DO_SANITY_CHECKS + uint32_t initial_slist_len = 0; + size_t initial_slist_size = 0; +#endif /* H5C_DO_SANITY_CHECKS */ + int i; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + assert(cache_ptr); + assert(cache_ptr->slist_enabled); + assert(cache_ptr->slist_ptr); + assert((flags & H5C__FLUSH_INVALIDATE_FLAG) == 0); + assert(ring > H5C_RING_UNDEFINED); + assert(ring < H5C_RING_NTYPES); + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + + ignore_protected = ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0); + flush_marked_entries = ((flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0); + + if (!flush_marked_entries) + for (i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) + assert(cache_ptr->slist_ring_len[i] == 0); + + assert(cache_ptr->flush_in_progress); + + /* When we are only flushing marked entries, the slist will usually + * still contain entries when we have flushed everything we should. + * Thus we track whether we have flushed any entries in the last + * pass, and terminate if we haven't. + */ + flushed_entries_last_pass = TRUE; + + /* Set the cache_ptr->slist_changed to false. + * + * This flag is set to TRUE by H5C__flush_single_entry if the + * slist is modified by a pre_serialize, serialize, or notify callback. + * H5C_flush_cache uses this flag to detect any modifications + * to the slist that might corrupt the scan of the slist -- and + * restart the scan in this event. + */ + cache_ptr->slist_changed = FALSE; + + while ((cache_ptr->slist_ring_len[ring] > 0) && (protected_entries == 0) && (flushed_entries_last_pass)) { + flushed_entries_last_pass = FALSE; + +#ifdef H5C_DO_SANITY_CHECKS + /* For sanity checking, try to verify that the skip list has + * the expected size and number of entries at the end of each + * internal while loop (see below). + * + * Doing this get a bit tricky, as depending on flags, we may + * or may not flush all the entries in the slist. + * + * To make things more entertaining, with the advent of the + * fractal heap, the entry serialize callback can cause entries + * to be dirtied, resized, and/or moved. Also, the + * pre_serialize callback can result in an entry being + * removed from the cache via the take ownership flag. + * + * To deal with this, we first make note of the initial + * skip list length and size: + */ + initial_slist_len = cache_ptr->slist_len; + initial_slist_size = cache_ptr->slist_size; + + /* As mentioned above, there is the possibility that + * entries will be dirtied, resized, flushed, or removed + * from the cache via the take ownership flag during + * our pass through the skip list. To capture the number + * of entries added, and the skip list size delta, + * zero the slist_len_increase and slist_size_increase of + * the cache's instance of H5C_t. These fields will be + * updated elsewhere to account for slist insertions and/or + * dirty entry size changes. + */ + cache_ptr->slist_len_increase = 0; + cache_ptr->slist_size_increase = 0; + + /* at the end of the loop, use these values to compute the + * expected slist length and size and compare this with the + * value recorded in the cache's instance of H5C_t. + */ +#endif /* H5C_DO_SANITY_CHECKS */ + + restart_slist_scan = TRUE; + while ((restart_slist_scan) || (node_ptr != NULL)) { + if (restart_slist_scan) { + restart_slist_scan = FALSE; + + /* Start at beginning of skip list */ + node_ptr = H5SL_first(cache_ptr->slist_ptr); + if (node_ptr == NULL) + /* the slist is empty -- break out of inner loop */ + break; + + /* Get cache entry for this node */ + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + + assert(next_entry_ptr->is_dirty); + assert(next_entry_ptr->in_slist); + } /* end if */ + + entry_ptr = next_entry_ptr; + + /* With the advent of the fractal heap, the free space + * manager, and the version 3 cache, it is possible + * that the pre-serialize or serialize callback will + * dirty, resize, or take ownership of other entries + * in the cache. + * + * To deal with this, there is code to detect any + * change in the skip list not directly under the control + * of this function. If such modifications are detected, + * we must re-start the scan of the skip list to avoid + * the possibility that the target of the next_entry_ptr + * may have been flushed or deleted from the cache. + * + * To verify that all such possibilities have been dealt + * with, we do a bit of extra sanity checking on + * entry_ptr. + */ + assert(entry_ptr->in_slist); + assert(entry_ptr->is_dirty); + + if (!flush_marked_entries || entry_ptr->flush_marker) + assert(entry_ptr->ring >= ring); + + /* Advance node pointer now, before we delete its target + * from the slist. + */ + node_ptr = H5SL_next(node_ptr); + if (node_ptr != NULL) { + next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); + if (NULL == next_entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") + + assert(next_entry_ptr->is_dirty); + assert(next_entry_ptr->in_slist); + + if (!flush_marked_entries || next_entry_ptr->flush_marker) + assert(next_entry_ptr->ring >= ring); + + assert(entry_ptr != next_entry_ptr); + } /* end if */ + else + next_entry_ptr = NULL; + + if ((!flush_marked_entries || entry_ptr->flush_marker) && + ((!entry_ptr->flush_me_last) || + ((entry_ptr->flush_me_last) && ((cache_ptr->num_last_entries >= cache_ptr->slist_len) || + (flush_marked_entries && entry_ptr->flush_marker)))) && + ((entry_ptr->flush_dep_nchildren == 0) || (entry_ptr->flush_dep_ndirty_children == 0)) && + (entry_ptr->ring == ring)) { + + assert(entry_ptr->flush_dep_nunser_children == 0); + + if (entry_ptr->is_protected) { + /* we probably have major problems -- but lets + * flush everything we can before we decide + * whether to flag an error. + */ + tried_to_flush_protected_entry = TRUE; + protected_entries++; + } /* end if */ + else { + if (H5C__flush_single_entry(f, entry_ptr, (flags | H5C__DURING_FLUSH_FLAG)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush entry") + + if (cache_ptr->slist_changed) { + /* The slist has been modified by something + * other than the simple removal of the + * of the flushed entry after the flush. + * + * This has the potential to corrupt the + * scan through the slist, so restart it. + */ + restart_slist_scan = TRUE; + cache_ptr->slist_changed = FALSE; + H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr); + } /* end if */ + + flushed_entries_last_pass = TRUE; + } /* end else */ + } /* end if */ + } /* while ( ( restart_slist_scan ) || ( node_ptr != NULL ) ) */ + +#ifdef H5C_DO_SANITY_CHECKS + /* Verify that the slist size and length are as expected. */ + assert((uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase) == + cache_ptr->slist_len); + assert((size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase) == + cache_ptr->slist_size); +#endif /* H5C_DO_SANITY_CHECKS */ + } /* while */ + + assert(protected_entries <= cache_ptr->pl_len); + + if (((cache_ptr->pl_len > 0) && !ignore_protected) || tried_to_flush_protected_entry) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "cache has protected items") + +#ifdef H5C_DO_SANITY_CHECKS + if (!flush_marked_entries) { + assert(cache_ptr->slist_ring_len[ring] == 0); + assert(cache_ptr->slist_ring_size[ring] == 0); + } /* end if */ +#endif /* H5C_DO_SANITY_CHECKS */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_ring() */ + +/*------------------------------------------------------------------------- + * Function: H5C__make_space_in_cache + * + * Purpose: Attempt to evict cache entries until the index_size + * is at least needed_space below max_cache_size. + * + * In passing, also attempt to bring cLRU_list_size to a + * value greater than min_clean_size. + * + * Depending on circumstances, both of these goals may + * be impossible, as in parallel mode, we must avoid generating + * a write as part of a read (to avoid deadlock in collective + * I/O), and in all cases, it is possible (though hopefully + * highly unlikely) that the protected list may exceed the + * maximum size of the cache. + * + * Thus the function simply does its best, returning success + * unless an error is encountered. + * + * Observe that this function cannot occasion a read. + * + * Return: Non-negative on success/Negative on failure. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) +{ + H5C_t *cache_ptr = f->shared->cache; +#if H5C_COLLECT_CACHE_STATS + int32_t clean_entries_skipped = 0; + int32_t dirty_pf_entries_skipped = 0; + int32_t total_entries_scanned = 0; +#endif /* H5C_COLLECT_CACHE_STATS */ + uint32_t entries_examined = 0; + uint32_t initial_list_len; + size_t empty_space; + hbool_t reentrant_call = FALSE; + hbool_t prev_is_dirty = FALSE; + hbool_t didnt_flush_entry = FALSE; + hbool_t restart_scan; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *prev_ptr; + H5C_cache_entry_t *next_ptr; +#ifndef NDEBUG + uint32_t num_corked_entries = 0; +#endif + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(f); + assert(cache_ptr); + assert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + + /* check to see if cache_ptr->msic_in_progress is TRUE. If it, this + * is a re-entrant call via a client callback called in the make + * space in cache process. To avoid an infinite recursion, set + * reentrant_call to TRUE, and goto done. + */ + if (cache_ptr->msic_in_progress) { + reentrant_call = TRUE; + HGOTO_DONE(SUCCEED); + } /* end if */ + + cache_ptr->msic_in_progress = TRUE; + + if (write_permitted) { + restart_scan = FALSE; + initial_list_len = cache_ptr->LRU_list_len; + entry_ptr = cache_ptr->LRU_tail_ptr; + + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; + else + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + + while ((((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) || + ((empty_space + cache_ptr->clean_index_size) < (cache_ptr->min_clean_size))) && + (entries_examined <= (2 * initial_list_len)) && (entry_ptr != NULL)) { + assert(!(entry_ptr->is_protected)); + assert(!(entry_ptr->is_read_only)); + assert((entry_ptr->ro_ref_count) == 0); + + next_ptr = entry_ptr->next; + prev_ptr = entry_ptr->prev; + + if (prev_ptr != NULL) + prev_is_dirty = prev_ptr->is_dirty; + + if (entry_ptr->is_dirty && (entry_ptr->tag_info && entry_ptr->tag_info->corked)) { + /* Skip "dirty" corked entries. */ +#ifndef NDEBUG + ++num_corked_entries; +#endif + didnt_flush_entry = TRUE; + } + else if ((entry_ptr->type->id != H5AC_EPOCH_MARKER_ID) && !entry_ptr->flush_in_progress && + !entry_ptr->prefetched_dirty) { + didnt_flush_entry = FALSE; + if (entry_ptr->is_dirty) { +#if H5C_COLLECT_CACHE_STATS + if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) + cache_ptr->entries_scanned_to_make_space++; +#endif /* H5C_COLLECT_CACHE_STATS */ + + /* reset entries_removed_counter and + * last_entry_removed_ptr prior to the call to + * H5C__flush_single_entry() so that we can spot + * unexpected removals of entries from the cache, + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry + * that is no longer in the cache. + */ + cache_ptr->entries_removed_counter = 0; + cache_ptr->last_entry_removed_ptr = NULL; + + if (H5C__flush_single_entry(f, entry_ptr, H5C__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + + if ((cache_ptr->entries_removed_counter > 1) || + (cache_ptr->last_entry_removed_ptr == prev_ptr)) + + restart_scan = TRUE; + } + else if ((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size +#ifdef H5_HAVE_PARALLEL + && !(entry_ptr->coll_access) +#endif /* H5_HAVE_PARALLEL */ + ) { +#if H5C_COLLECT_CACHE_STATS + cache_ptr->entries_scanned_to_make_space++; +#endif /* H5C_COLLECT_CACHE_STATS */ + + if (H5C__flush_single_entry(f, entry_ptr, + H5C__FLUSH_INVALIDATE_FLAG | + H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + } + else { + /* We have enough space so don't flush clean entry. */ +#if H5C_COLLECT_CACHE_STATS + clean_entries_skipped++; +#endif /* H5C_COLLECT_CACHE_STATS */ + didnt_flush_entry = TRUE; + } + +#if H5C_COLLECT_CACHE_STATS + total_entries_scanned++; +#endif /* H5C_COLLECT_CACHE_STATS */ + } + else { + + /* Skip epoch markers, entries that are in the process + * of being flushed, and entries marked as prefetched_dirty + * (occurs in the R/O case only). + */ + didnt_flush_entry = TRUE; + +#if H5C_COLLECT_CACHE_STATS + if (entry_ptr->prefetched_dirty) + dirty_pf_entries_skipped++; +#endif /* H5C_COLLECT_CACHE_STATS */ + } + + if (prev_ptr != NULL) { + if (didnt_flush_entry) + /* epoch markers don't get flushed, and we don't touch + * entries that are in the process of being flushed. + * Hence no need for sanity checks, as we haven't + * flushed anything. Thus just set entry_ptr to prev_ptr + * and go on. + */ + entry_ptr = prev_ptr; + else if (restart_scan || prev_ptr->is_dirty != prev_is_dirty || prev_ptr->next != next_ptr || + prev_ptr->is_protected || prev_ptr->is_pinned) { + /* something has happened to the LRU -- start over + * from the tail. + */ + restart_scan = FALSE; + entry_ptr = cache_ptr->LRU_tail_ptr; + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr); + } + else + entry_ptr = prev_ptr; + } + else + entry_ptr = NULL; + + entries_examined++; + + if (cache_ptr->index_size >= cache_ptr->max_cache_size) + empty_space = 0; + else + empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; + + assert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + } + +#if H5C_COLLECT_CACHE_STATS + cache_ptr->calls_to_msic++; + + cache_ptr->total_entries_skipped_in_msic += clean_entries_skipped; + cache_ptr->total_dirty_pf_entries_skipped_in_msic += dirty_pf_entries_skipped; + cache_ptr->total_entries_scanned_in_msic += total_entries_scanned; + + if (clean_entries_skipped > cache_ptr->max_entries_skipped_in_msic) + cache_ptr->max_entries_skipped_in_msic = clean_entries_skipped; + + if (dirty_pf_entries_skipped > cache_ptr->max_dirty_pf_entries_skipped_in_msic) + cache_ptr->max_dirty_pf_entries_skipped_in_msic = dirty_pf_entries_skipped; + + if (total_entries_scanned > cache_ptr->max_entries_scanned_in_msic) + cache_ptr->max_entries_scanned_in_msic = total_entries_scanned; +#endif /* H5C_COLLECT_CACHE_STATS */ + + /* NEED: work on a better assert for corked entries */ + assert((entries_examined > (2 * initial_list_len)) || + ((cache_ptr->pl_size + cache_ptr->pel_size + cache_ptr->min_clean_size) > + cache_ptr->max_cache_size) || + ((cache_ptr->clean_index_size + empty_space) >= cache_ptr->min_clean_size) || + ((num_corked_entries))); +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + + assert((entries_examined > (2 * initial_list_len)) || + (cache_ptr->cLRU_list_size <= cache_ptr->clean_index_size)); + assert((entries_examined > (2 * initial_list_len)) || + (cache_ptr->dLRU_list_size <= cache_ptr->dirty_index_size)); + +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + } + else { + assert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); + +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + initial_list_len = cache_ptr->cLRU_list_len; + entry_ptr = cache_ptr->cLRU_tail_ptr; + + while (((cache_ptr->index_size + space_needed) > cache_ptr->max_cache_size) && + (entries_examined <= initial_list_len) && (entry_ptr != NULL)) { + assert(!(entry_ptr->is_protected)); + assert(!(entry_ptr->is_read_only)); + assert((entry_ptr->ro_ref_count) == 0); + assert(!(entry_ptr->is_dirty)); + + prev_ptr = entry_ptr->aux_prev; + + if (!entry_ptr->prefetched_dirty +#ifdef H5_HAVE_PARALLEL + && !entry_ptr->coll_access +#endif /* H5_HAVE_PARALLEL */ + ) { + if (H5C__flush_single_entry( + f, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") + } /* end if */ + + /* we are scanning the clean LRU, so the serialize function + * will not be called on any entry -- thus there is no + * concern about the list being modified out from under + * this function. + */ + + entry_ptr = prev_ptr; + entries_examined++; + } +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + } + +done: + /* Sanity checks */ + assert(cache_ptr->msic_in_progress); + if (!reentrant_call) + cache_ptr->msic_in_progress = FALSE; + assert((!reentrant_call) || (cache_ptr->msic_in_progress)); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__make_space_in_cache() */ + +/*------------------------------------------------------------------------- + * Function: H5C__serialize_cache + * + * Purpose: Serialize (i.e. construct an on disk image) for all entries + * in the metadata cache including clean entries. + * + * Note that flush dependencies and "flush me last" flags + * must be observed in the serialization process. + * + * Note also that entries may be loaded, flushed, evicted, + * expunged, relocated, resized, or removed from the cache + * during this process, just as these actions may occur during + * a regular flush. + * + * However, we are given that the cache will contain no protected + * entries on entry to this routine (although entries may be + * briefly protected and then unprotected during the serialize + * process). + * + * The objective of this routine is serialize all entries and + * to force all entries into their actual locations on disk. + * + * The initial need for this routine is to settle all entries + * in the cache prior to construction of the metadata cache + * image so that the size of the cache image can be calculated. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__serialize_cache(H5F_t *f) +{ +#ifdef H5C_DO_SANITY_CHECKS + int i; + uint32_t index_len = 0; + size_t index_size = (size_t)0; + size_t clean_index_size = (size_t)0; + size_t dirty_index_size = (size_t)0; + size_t slist_size = (size_t)0; + uint32_t slist_len = 0; +#endif /* H5C_DO_SANITY_CHECKS */ + H5C_ring_t ring; + H5C_t *cache_ptr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(f); + assert(f->shared); + cache_ptr = f->shared->cache; + assert(cache_ptr); + assert(cache_ptr->slist_ptr); + +#ifdef H5C_DO_SANITY_CHECKS + assert(cache_ptr->index_ring_len[H5C_RING_UNDEFINED] == 0); + assert(cache_ptr->index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + assert(cache_ptr->clean_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + assert(cache_ptr->dirty_index_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + assert(cache_ptr->slist_ring_len[H5C_RING_UNDEFINED] == 0); + assert(cache_ptr->slist_ring_size[H5C_RING_UNDEFINED] == (size_t)0); + + for (i = H5C_RING_USER; i < H5C_RING_NTYPES; i++) { + index_len += cache_ptr->index_ring_len[i]; + index_size += cache_ptr->index_ring_size[i]; + clean_index_size += cache_ptr->clean_index_ring_size[i]; + dirty_index_size += cache_ptr->dirty_index_ring_size[i]; + + slist_len += cache_ptr->slist_ring_len[i]; + slist_size += cache_ptr->slist_ring_size[i]; + } /* end for */ + + assert(cache_ptr->index_len == index_len); + assert(cache_ptr->index_size == index_size); + assert(cache_ptr->clean_index_size == clean_index_size); + assert(cache_ptr->dirty_index_size == dirty_index_size); + assert(cache_ptr->slist_len == slist_len); + assert(cache_ptr->slist_size == slist_size); +#endif /* H5C_DO_SANITY_CHECKS */ + +#ifdef H5C_DO_EXTREME_SANITY_CHECKS + if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || + H5C__validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + +#ifndef NDEBUG + /* if this is a debug build, set the serialization_count field of + * each entry in the cache to zero before we start the serialization. + * This allows us to detect the case in which any entry is serialized + * more than once (a performance issues), and more importantly, the + * case is which any flush dependency parent is serializes more than + * once (a correctness issue). + */ + { + H5C_cache_entry_t *scan_ptr = NULL; + + scan_ptr = cache_ptr->il_head; + while (scan_ptr != NULL) { + scan_ptr->serialization_count = 0; + scan_ptr = scan_ptr->il_next; + } /* end while */ + } /* end block */ +#endif + + /* set cache_ptr->serialization_in_progress to TRUE, and back + * to FALSE at the end of the function. Must maintain this flag + * to support H5C_get_serialization_in_progress(), which is in + * turn required to support sanity checking in some cache + * clients. + */ + assert(!cache_ptr->serialization_in_progress); + cache_ptr->serialization_in_progress = TRUE; + + /* Serialize each ring, starting from the outermost ring and + * working inward. + */ + ring = H5C_RING_USER; + while (ring < H5C_RING_NTYPES) { + assert(cache_ptr->close_warning_received); + switch (ring) { + case H5C_RING_USER: + break; + + case H5C_RING_RDFSM: + /* Settle raw data FSM */ + if (!cache_ptr->rdfsm_settled) + if (H5MF_settle_raw_data_fsm(f, &cache_ptr->rdfsm_settled) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "RD FSM settle failed") + break; + + case H5C_RING_MDFSM: + /* Settle metadata FSM */ + if (!cache_ptr->mdfsm_settled) + if (H5MF_settle_meta_data_fsm(f, &cache_ptr->mdfsm_settled) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "MD FSM settle failed") + break; + + case H5C_RING_SBE: + case H5C_RING_SB: + break; + + default: + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown ring?!?!") + break; + } /* end switch */ + + if (H5C__serialize_ring(f, ring) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "serialize ring failed") + + ring++; + } /* end while */ + +#ifndef NDEBUG + /* Verify that no entry has been serialized more than once. + * FD parents with multiple serializations should have been caught + * elsewhere, so no specific check for them here. + */ + { + H5C_cache_entry_t *scan_ptr = NULL; + + scan_ptr = cache_ptr->il_head; + while (scan_ptr != NULL) { + assert(scan_ptr->serialization_count <= 1); + + scan_ptr = scan_ptr->il_next; + } /* end while */ + } /* end block */ +#endif + +done: + cache_ptr->serialization_in_progress = FALSE; + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__serialize_cache() */ + +/*------------------------------------------------------------------------- + * Function: H5C__serialize_ring + * + * Purpose: Serialize the entries contained in the specified cache and + * ring. All entries in rings outside the specified ring + * must have been serialized on entry. + * + * If the cache contains protected entries in the specified + * ring, the function will fail, as protected entries cannot + * be serialized. However all unprotected entries in the + * target ring should be serialized before the function + * returns failure. + * + * If flush dependencies appear in the target ring, the + * function makes repeated passes through the index list + * serializing entries in flush dependency order. + * + * All entries outside the H5C_RING_SBE are marked for + * inclusion in the cache image. Entries in H5C_RING_SBE + * and below are marked for exclusion from the image. + * + * Return: Non-negative on success/Negative on failure or if there was + * a request to flush all items and something was protected. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) +{ + hbool_t done = FALSE; + H5C_t *cache_ptr; + H5C_cache_entry_t *entry_ptr; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(f); + assert(f->shared); + cache_ptr = f->shared->cache; + assert(cache_ptr); + assert(ring > H5C_RING_UNDEFINED); + assert(ring < H5C_RING_NTYPES); + + assert(cache_ptr->serialization_in_progress); + + /* The objective here is to serialize all entries in the cache ring + * in flush dependency order. + * + * The basic algorithm is to scan the cache index list looking for + * unserialized entries that are either not in a flush dependency + * relationship, or which have no unserialized children. Any such + * entry is serialized and its flush dependency parents (if any) are + * informed -- allowing them to decrement their userialized child counts. + * + * However, this algorithm is complicated by the ability + * of client serialization callbacks to perform operations on + * on the cache which can result in the insertion, deletion, + * relocation, resize, dirty, flush, eviction, or removal (via the + * take ownership flag) of entries. Changes in the flush dependency + * structure are also possible. + * + * On the other hand, the algorithm is simplified by the fact that + * we are serializing, not flushing. Thus, as long as all entries + * are serialized correctly, it doesn't matter if we have to go back + * and serialize an entry a second time. + * + * These possible actions result in the following modifications to + * the basic algorithm: + * + * 1) In the event of an entry expunge, eviction or removal, we must + * restart the scan as it is possible that the next entry in our + * scan is no longer in the cache. Were we to examine this entry, + * we would be accessing deallocated memory. + * + * 2) A resize, dirty, or insertion of an entry may result in the + * the increment of a flush dependency parent's dirty and/or + * unserialized child count. In the context of serializing the + * the cache, this is a non-issue, as even if we have already + * serialized the parent, it will be marked dirty and its image + * marked out of date if appropriate when the child is serialized. + * + * However, this is a major issue for a flush, as were this to happen + * in a flush, it would violate the invariant that the flush dependency + * feature is intended to enforce. As the metadata cache has no + * control over the behavior of cache clients, it has no way of + * preventing this behaviour. However, it should detect it if at all + * possible. + * + * Do this by maintaining a count of the number of times each entry is + * serialized during a cache serialization. If any flush dependency + * parent is serialized more than once, throw an assertion failure. + * + * 3) An entry relocation will typically change the location of the + * entry in the index list. This shouldn't cause problems as we + * will scan the index list until we make a complete pass without + * finding anything to serialize -- making relocations of either + * the current or next entries irrelevant. + * + * Note that since a relocation may result in our skipping part of + * the index list, we must always do at least one more pass through + * the index list after an entry relocation. + * + * 4) Changes in the flush dependency structure are possible on + * entry insertion, load, expunge, evict, or remove. Destruction + * of a flush dependency has no effect, as it can only relax the + * flush dependencies. Creation of a flush dependency can create + * an unserialized child of a flush dependency parent where all + * flush dependency children were previously serialized. Should + * this child dirty the flush dependency parent when it is serialized, + * the parent will be re-serialized. + * + * Per the discussion of 2) above, this is a non issue for cache + * serialization, and a major problem for cache flush. Using the + * same detection mechanism, throw an assertion failure if this + * condition appears. + * + * Observe that either eviction or removal of entries as a result of + * a serialization is not a problem as long as the flush dependency + * tree does not change beyond the removal of a leaf. + */ + while (!done) { + /* Reset the counters so that we can detect insertions, loads, + * moves, and flush dependency height changes caused by the pre_serialize + * and serialize callbacks. + */ + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + done = TRUE; /* set to FALSE if any activity in inner loop */ + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + /* Verify that either the entry is already serialized, or + * that it is assigned to either the target or an inner + * ring. + */ + assert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); + + /* Skip flush me last entries or inner ring entries */ + if (!entry_ptr->flush_me_last && entry_ptr->ring == ring) { + + /* if we encounter an unserialized entry in the current + * ring that is not marked flush me last, we are not done. + */ + if (!entry_ptr->image_up_to_date) + done = FALSE; + + /* Serialize the entry if its image is not up to date + * and it has no unserialized flush dependency children. + */ + if (!entry_ptr->image_up_to_date && entry_ptr->flush_dep_nunser_children == 0) { + assert(entry_ptr->serialization_count == 0); + + /* Serialize the entry */ + if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") + + assert(entry_ptr->flush_dep_nunser_children == 0); + assert(entry_ptr->serialization_count == 0); + +#ifndef NDEBUG + /* Increment serialization counter (to detect multiple serializations) */ + entry_ptr->serialization_count++; +#endif + } /* end if */ + } /* end if */ + + /* Check for the cache being perturbed during the entry serialize */ + if ((cache_ptr->entries_loaded_counter > 0) || (cache_ptr->entries_inserted_counter > 0) || + (cache_ptr->entries_relocated_counter > 0)) { + +#if H5C_COLLECT_CACHE_STATS + H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr); +#endif /* H5C_COLLECT_CACHE_STATS */ + + /* Reset the counters */ + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + /* Restart scan */ + entry_ptr = cache_ptr->il_head; + } /* end if */ + else + /* Advance to next entry */ + entry_ptr = entry_ptr->il_next; + } /* while ( entry_ptr != NULL ) */ + } /* while ( ! done ) */ + + /* Reset the counters so that we can detect insertions, loads, + * moves, and flush dependency height changes caused by the pre_serialize + * and serialize callbacks. + */ + cache_ptr->entries_loaded_counter = 0; + cache_ptr->entries_inserted_counter = 0; + cache_ptr->entries_relocated_counter = 0; + + /* At this point, all entries not marked "flush me last" and in + * the current ring or outside it should be serialized and have up + * to date images. Scan the index list again to serialize the + * "flush me last" entries (if they are in the current ring) and to + * verify that all other entries have up to date images. + */ + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + assert(entry_ptr->ring > H5C_RING_UNDEFINED); + assert(entry_ptr->ring < H5C_RING_NTYPES); + assert((entry_ptr->ring >= ring) || (entry_ptr->image_up_to_date)); + + if (entry_ptr->ring == ring) { + if (entry_ptr->flush_me_last) { + if (!entry_ptr->image_up_to_date) { + assert(entry_ptr->serialization_count == 0); + assert(entry_ptr->flush_dep_nunser_children == 0); + + /* Serialize the entry */ + if (H5C__serialize_single_entry(f, cache_ptr, entry_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTSERIALIZE, FAIL, "entry serialization failed") + + /* Check for the cache changing */ + if ((cache_ptr->entries_loaded_counter > 0) || + (cache_ptr->entries_inserted_counter > 0) || + (cache_ptr->entries_relocated_counter > 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, + "flush_me_last entry serialization triggered restart") + + assert(entry_ptr->flush_dep_nunser_children == 0); + assert(entry_ptr->serialization_count == 0); +#ifndef NDEBUG + /* Increment serialization counter (to detect multiple serializations) */ + entry_ptr->serialization_count++; +#endif + } /* end if */ + } /* end if */ + else { + assert(entry_ptr->image_up_to_date); + assert(entry_ptr->serialization_count <= 1); + assert(entry_ptr->flush_dep_nunser_children == 0); + } /* end else */ + } /* if ( entry_ptr->ring == ring ) */ + + entry_ptr = entry_ptr->il_next; + } /* while ( entry_ptr != NULL ) */ + +done: + assert(cache_ptr->serialization_in_progress); + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__serialize_ring() */ diff --git a/src/H5Clog.c b/src/H5Clog.c index 24bec31..69ad8b3 100644 --- a/src/H5Clog.c +++ b/src/H5Clog.c @@ -97,11 +97,11 @@ H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, h /* Set up logging */ if (H5C_LOG_STYLE_JSON == style) { - if (H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) + if (H5C__log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up json logging") } else if (H5C_LOG_STYLE_TRACE == style) { - if (H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) + if (H5C__log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up trace logging") } else diff --git a/src/H5Clog.h b/src/H5Clog.h index b3636c6..b8ea5ed 100644 --- a/src/H5Clog.h +++ b/src/H5Clog.h @@ -132,7 +132,7 @@ H5_DLL herr_t H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry herr_t fxn_ret_value); /* Logging-specific setup functions */ -H5_DLL herr_t H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); -H5_DLL herr_t H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); +H5_DLL herr_t H5C__log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); +H5_DLL herr_t H5C__log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); #endif /* H5Clog_H */ diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c index f009f4f..64aa0a4 100644 --- a/src/H5Clog_json.c +++ b/src/H5Clog_json.c @@ -178,7 +178,7 @@ done: } /* H5C__json_write_log_message() */ /*------------------------------------------------------------------------- - * Function: H5C_log_json_set_up + * Function: H5C__log_json_set_up * * Purpose: Setup for metadata cache logging. * @@ -199,14 +199,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) +H5C__log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) { H5C_log_json_udata_t *json_udata = NULL; char *file_name = NULL; size_t n_chars; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Sanity checks */ assert(log_info); @@ -265,7 +265,7 @@ done: } FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_log_json_set_up() */ +} /* H5C__log_json_set_up() */ /*------------------------------------------------------------------------- * Function: H5C__json_tear_down_logging @@ -294,7 +294,7 @@ H5C__json_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(json_udata->message); /* Close log file */ - if (EOF == HDfclose(json_udata->outfile)) + if (EOF == fclose(json_udata->outfile)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") json_udata->outfile = NULL; diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c index 56cb05c..4d8e6a8 100644 --- a/src/H5Clog_trace.c +++ b/src/H5Clog_trace.c @@ -173,7 +173,7 @@ done: } /* H5C__trace_write_log_message() */ /*------------------------------------------------------------------------- - * Function: H5C_log_trace_set_up + * Function: H5C__log_trace_set_up * * Purpose: Setup for metadata cache logging. * @@ -194,14 +194,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) +H5C__log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) { H5C_log_trace_udata_t *trace_udata = NULL; char *file_name = NULL; size_t n_chars; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Sanity checks */ assert(log_info); @@ -263,7 +263,7 @@ done: } FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_log_trace_set_up() */ +} /* H5C__log_trace_set_up() */ /*------------------------------------------------------------------------- * Function: H5C__trace_tear_down_logging @@ -292,7 +292,7 @@ H5C__trace_tear_down_logging(H5C_log_info_t *log_info) H5MM_xfree(trace_udata->message); /* Close log file */ - if (EOF == HDfclose(trace_udata->outfile)) + if (EOF == fclose(trace_udata->outfile)) HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") trace_udata->outfile = NULL; diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 9d453b9..3d8afe6 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -154,10 +154,12 @@ herr_t H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr, int mpi_rank, int mpi_size) { - unsigned first_entry_to_flush; - unsigned last_entry_to_flush; - unsigned total_entries_to_clear = 0; - unsigned total_entries_to_flush = 0; + unsigned first_entry_to_flush; + unsigned last_entry_to_flush; +#ifndef NDEBUG + unsigned total_entries_to_clear = 0; + unsigned total_entries_to_flush = 0; +#endif unsigned *candidate_assignment_table = NULL; unsigned entries_to_flush[H5C_RING_NTYPES]; unsigned entries_to_clear[H5C_RING_NTYPES]; @@ -177,7 +179,6 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha /* Sanity checks */ assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(num_candidates > 0); assert((!cache_ptr->slist_enabled) || (num_candidates <= cache_ptr->slist_len)); assert(candidates_list_ptr != NULL); @@ -286,7 +287,7 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha last_addr = addr; #endif /* H5C_DO_SANITY_CHECKS */ - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "listed candidate entry not in cache?!?!?") if (!entry_ptr->is_dirty) @@ -299,7 +300,6 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Listed entry is protected?!?!?") /* Sanity checks */ - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->ring >= H5C_RING_USER); assert(entry_ptr->ring <= H5C_RING_SB); assert(!entry_ptr->flush_immediately); @@ -311,12 +311,16 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha * markings. */ if (u >= first_entry_to_flush && u <= last_entry_to_flush) { +#ifndef NDEBUG total_entries_to_flush++; +#endif entries_to_flush[entry_ptr->ring]++; entry_ptr->flush_immediately = TRUE; } /* end if */ else { +#ifndef NDEBUG total_entries_to_clear++; +#endif entries_to_clear[entry_ptr->ring]++; entry_ptr->clear_on_unprotect = TRUE; } /* end else */ @@ -329,7 +333,7 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha */ if (entry_ptr->coll_access) { entry_ptr->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) + H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL); } /* end if */ } /* end for */ @@ -378,7 +382,7 @@ done: candidate_assignment_table = (unsigned *)H5MM_xfree((void *)candidate_assignment_table); if (cache_ptr->coll_write_list) { if (H5SL_close(cache_ptr->coll_write_list) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list") + HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list"); cache_ptr->coll_write_list = NULL; } /* end if */ @@ -386,7 +390,6 @@ done: } /* H5C_apply_candidate_list() */ /*------------------------------------------------------------------------- - * * Function: H5C_construct_candidate_list__clean_cache * * Purpose: Construct the list of entries that should be flushed to @@ -409,7 +412,6 @@ H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) FUNC_ENTER_NOAPI(FAIL) assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* As a sanity check, set space needed to the dirty_index_size. This * should be the sum total of the sizes of all the dirty entries @@ -517,7 +519,6 @@ H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr) FUNC_ENTER_NOAPI(FAIL) assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); /* compute the number of bytes (if any) that must be flushed to get the * cache back within its min clean constraints. @@ -580,7 +581,6 @@ done: } /* H5C_construct_candidate_list__min_clean() */ /*------------------------------------------------------------------------- - * * Function: H5C_mark_entries_as_clean * * Purpose: When the H5C code is used to implement the metadata caches @@ -634,7 +634,6 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr assert(f->shared); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(ce_array_len > 0); assert(ce_array_ptr != NULL); @@ -667,7 +666,7 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr assert(H5_addr_defined(addr)); - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) { #ifdef H5C_DO_SANITY_CHECKS @@ -691,7 +690,7 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr it so it can be cleared */ if (TRUE == entry_ptr->coll_access) { entry_ptr->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) + H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL); } /* end if */ entry_ptr->clear_on_unprotect = TRUE; @@ -799,14 +798,13 @@ done: #ifdef H5C_DO_EXTREME_SANITY_CHECKS if (H5C__validate_protected_entry_list(cache_ptr) < 0 || H5C__validate_pinned_entry_list(cache_ptr) < 0 || H5C__validate_lru_list(cache_ptr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) } /* H5C_mark_entries_as_clean() */ /*------------------------------------------------------------------------- - * * Function: H5C_clear_coll_entries * * Purpose: Clear half or the entire list of collective entries and @@ -839,7 +837,7 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) /* Mark entry as independent */ entry_ptr->coll_access = FALSE; - H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL) + H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL); /* Decrement entry count */ clear_cnt--; @@ -855,7 +853,6 @@ done: } /* H5C_clear_coll_entries */ /*------------------------------------------------------------------------- - * * Function: H5C__collective_write * * Purpose: Perform a collective write of a list of metadata entries. @@ -970,9 +967,9 @@ done: /* Reset transfer mode in API context, if changed */ if (orig_xfer_mode != H5FD_MPIO_COLLECTIVE) if (H5CX_set_io_xfer_mode(orig_xfer_mode) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") + HDONE_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode"); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5C__collective_write() */ /*------------------------------------------------------------------------- @@ -1029,11 +1026,8 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES assert(f); assert(f->shared); - cache_ptr = f->shared->cache; - assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->slist_ptr); assert(entries_to_flush[H5C_RING_UNDEFINED] == 0); @@ -1149,7 +1143,6 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flu assert(f->shared); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(cache_ptr->slist_ptr); assert(ring > H5C_RING_UNDEFINED); assert(ring < H5C_RING_NTYPES); @@ -1290,7 +1283,7 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flu restart_scan = FALSE; entry_ptr = cache_ptr->LRU_tail_ptr; - H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) + H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr); } /* end if */ } /* end while */ diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index e337a88..fbde8a8 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -11,18 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: John Mainzer -- 10/12/04 - * - * Purpose: This file contains declarations which are normally visible - * only within the H5C package. - * - * Source files outside the H5C package should include - * H5Cprivate.h instead. - * - * The one exception to this rule is test/cache.c. The test - * code is easier to write if it can look at the cache's - * internal data structures. Indeed, this is the main - * reason why this file was created. + * Purpose: This file contains declarations which are visible only within + * the H5C package. Source files outside the H5C package should + * include H5Cprivate.h instead. */ /* clang-format off */ @@ -49,11 +40,8 @@ /* Number of epoch markers active */ #define H5C__MAX_EPOCH_MARKERS 10 - /* Cache configuration settings */ #define H5C__HASH_TABLE_LEN (64 * 1024) /* must be a power of 2 */ -#define H5C__H5C_T_MAGIC 0x005CAC0E - /* Initial allocated size of the "flush_dep_parent" array */ #define H5C_FLUSH_DEP_PARENT_INIT 8 @@ -82,424 +70,146 @@ #ifdef H5C_DO_SANITY_CHECKS -#define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( (head_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (list_size) < (entry_ptr)->size ) || \ - ( ( (entry_ptr)->prev == NULL ) && ( (head_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (head_ptr) == (entry_ptr) ) && \ - ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->next == NULL ) && \ - ( (entry_ptr)->prev == NULL ) && \ - ( (list_size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL pre remove SC failed") \ -} - -#define H5C__DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (list_size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL sanity check failed") \ -} - -#define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->next != NULL ) || \ - ( (entry_ptr)->prev != NULL ) || \ - ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->next != NULL ) \ - ) \ - ) \ +#define H5C__GEN_DLL_PRE_REMOVE_SC(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) \ +do { if ((head_ptr) == NULL || (tail_ptr) == NULL || \ + (entry_ptr) == NULL || (len) <= 0 || \ + (list_size) < (entry_ptr)->size || \ + ((entry_ptr)->list_prev == NULL && (head_ptr) != (entry_ptr)) || \ + ((entry_ptr)->list_next == NULL && (tail_ptr) != (entry_ptr)) || \ + ((len) == 1 && \ + !((head_ptr) == (entry_ptr) && (tail_ptr) == (entry_ptr) && \ + (entry_ptr)->list_next == NULL && (entry_ptr)->list_prev == NULL && \ + (list_size) == (entry_ptr)->size \ + ) \ + ) \ ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL pre insert SC failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL pre remove SC failed") \ +} } while (0) + +#define H5C__GEN_DLL_PRE_INSERT_SC(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) \ +if ((entry_ptr) == NULL || (entry_ptr)->list_next != NULL || (entry_ptr)->list_prev != NULL || \ + (((head_ptr) == NULL || (tail_ptr) == NULL) && (head_ptr) != (tail_ptr)) || \ + ((len) == 0 && \ + ((list_size) > 0 || (head_ptr) != NULL || (tail_ptr) != NULL) \ + ) || \ + ((len) == 1 && \ + ((head_ptr) != (tail_ptr) || (head_ptr) == NULL || \ + (head_ptr)->size != (list_size)) \ + ) || \ + ((len) >= 1 && \ + ((head_ptr) == NULL || (head_ptr)->list_prev != NULL || \ + (tail_ptr) == NULL || (tail_ptr)->list_next != NULL) \ + ) \ + ) { \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL pre insert SC failed") \ } -#define H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ -if ( ( (dll_len) <= 0 ) || \ - ( (dll_size) <= 0 ) || \ - ( (old_size) <= 0 ) || \ - ( (old_size) > (dll_size) ) || \ - ( (new_size) <= 0 ) || \ - ( ( (dll_len) == 1 ) && ( (old_size) != (dll_size) ) ) ) { \ +#define H5C__GEN_DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ +if ((dll_len) <= 0 || (dll_size) <= 0 || (old_size) <= 0 || \ + (old_size) > (dll_size) || (new_size) <= 0 || \ + ((dll_len) == 1 && (old_size) != (dll_size)) \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL pre size update SC failed") \ } -#define H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ -if ( ( (new_size) > (dll_size) ) || \ - ( ( (dll_len) == 1 ) && ( (new_size) != (dll_size) ) ) ) { \ +#define H5C__GEN_DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ +if ((new_size) > (dll_size) || ((dll_len) == 1 && (new_size) != (dll_size))) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL post size update SC failed") \ } - -#else /* H5C_DO_SANITY_CHECKS */ - -#define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) -#define H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) - -#endif /* H5C_DO_SANITY_CHECKS */ - - -#define H5C__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->next = (entry_ptr); \ - (entry_ptr)->prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (list_size) += (entry_ptr)->size; \ -} /* H5C__DLL_APPEND() */ - -#define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->prev = (entry_ptr); \ - (entry_ptr)->next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (list_size) += (entry_ptr)->size; \ -} /* H5C__DLL_PREPEND() */ - -#define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ - fail_val) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->prev = NULL; \ - } \ - else \ - (entry_ptr)->prev->next = (entry_ptr)->next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->next = NULL; \ - } \ - else \ - (entry_ptr)->next->prev = (entry_ptr)->prev; \ - (entry_ptr)->next = NULL; \ - (entry_ptr)->prev = NULL; \ - (len)--; \ - (list_size) -= (entry_ptr)->size; \ - } \ -} /* H5C__DLL_REMOVE() */ - -#define H5C__DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size, fail_val) \ -{ \ - H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ - (dll_size) -= (old_size); \ - (dll_size) += (new_size); \ - H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ -} /* H5C__DLL_UPDATE_FOR_SIZE_CHANGE() */ - -#ifdef H5C_DO_SANITY_CHECKS - -#define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (list_size) < (entry_ptr)->size ) || \ - ( ( (list_size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->aux_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->aux_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->aux_next == NULL ) && \ - ( (entry_ptr)->aux_prev == NULL ) && \ - ( (list_size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "aux DLL pre remove SC failed") \ -} - -#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (list_size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->aux_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "AUX DLL sanity check failed") \ -} - -#define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->aux_next != NULL ) || \ - ( (entry_ptr)->aux_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->aux_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->aux_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "AUX DLL pre insert SC failed") \ -} - #else /* H5C_DO_SANITY_CHECKS */ - -#define H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) - +#define H5C__GEN_DLL_PRE_REMOVE_SC(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__GEN_DLL_PRE_INSERT_SC(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__GEN_DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) +#define H5C__GEN_DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) #endif /* H5C_DO_SANITY_CHECKS */ - -#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val)\ +#define H5C__GEN_DLL_APPEND(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) \ { \ - H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ + H5C__GEN_DLL_PRE_INSERT_SC(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) \ + if ((head_ptr) == NULL) { \ (head_ptr) = (entry_ptr); \ (tail_ptr) = (entry_ptr); \ } \ - else \ - { \ - (tail_ptr)->aux_next = (entry_ptr); \ - (entry_ptr)->aux_prev = (tail_ptr); \ + else { \ + (tail_ptr)->list_next = (entry_ptr); \ + (entry_ptr)->list_prev = (tail_ptr); \ (tail_ptr) = (entry_ptr); \ } \ (len)++; \ - (list_size) += entry_ptr->size; \ -} /* H5C__AUX_DLL_APPEND() */ - -#define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->aux_prev = (entry_ptr); \ - (entry_ptr)->aux_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (list_size) += entry_ptr->size; \ -} /* H5C__AUX_DLL_PREPEND() */ - -#define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->aux_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->aux_prev = NULL; \ - } \ - else \ - (entry_ptr)->aux_prev->aux_next = (entry_ptr)->aux_next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->aux_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->aux_next = NULL; \ - } \ - else \ - (entry_ptr)->aux_next->aux_prev = (entry_ptr)->aux_prev; \ - entry_ptr->aux_next = NULL; \ - entry_ptr->aux_prev = NULL; \ - (len)--; \ - (list_size) -= entry_ptr->size; \ - } \ -} /* H5C__AUX_DLL_REMOVE() */ - -#ifdef H5C_DO_SANITY_CHECKS - -#define H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (list_size) < (entry_ptr)->size ) || \ - ( ( (list_size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->il_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->il_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ - ( ( (len) == 1 ) && \ - ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ - ( (entry_ptr)->il_next == NULL ) && \ - ( (entry_ptr)->il_prev == NULL ) && \ - ( (list_size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "il DLL pre remove SC failed") \ -} - -#define H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->il_next != NULL ) || \ - ( (entry_ptr)->il_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->il_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "IL DLL pre insert SC failed") \ -} - -#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->il_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->il_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "IL DLL sanity check failed") \ -} + (list_size) += (entry_ptr)->size; \ +} /* H5C__GEN_DLL_APPEND() */ -#else /* H5C_DO_SANITY_CHECKS */ +#define H5C__GEN_DLL_PREPEND(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) \ +{ \ + H5C__GEN_DLL_PRE_INSERT_SC(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) \ + if ((head_ptr) == NULL) { \ + (head_ptr) = (entry_ptr); \ + (tail_ptr) = (entry_ptr); \ + } \ + else { \ + (head_ptr)->list_prev = (entry_ptr); \ + (entry_ptr)->list_next = (head_ptr); \ + (head_ptr) = (entry_ptr); \ + } \ + (len)++; \ + (list_size) += (entry_ptr)->size; \ +} /* H5C__GEN_DLL_PREPEND() */ -#define H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__GEN_DLL_REMOVE(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val) \ +{ \ + H5C__GEN_DLL_PRE_REMOVE_SC(entry_ptr, list_next, list_prev, head_ptr, tail_ptr, len, list_size, fail_val); \ + if ((head_ptr) == (entry_ptr)) { \ + (head_ptr) = (entry_ptr)->list_next; \ + if ((head_ptr) != NULL) \ + (head_ptr)->list_prev = NULL; \ + } \ + else \ + (entry_ptr)->list_prev->list_next = (entry_ptr)->list_next; \ + if ((tail_ptr) == (entry_ptr)) { \ + (tail_ptr) = (entry_ptr)->list_prev; \ + if ((tail_ptr) != NULL) \ + (tail_ptr)->list_next = NULL; \ + } \ + else \ + (entry_ptr)->list_next->list_prev = (entry_ptr)->list_prev; \ + (entry_ptr)->list_next = NULL; \ + (entry_ptr)->list_prev = NULL; \ + (len)--; \ + (list_size) -= (entry_ptr)->size; \ +} /* H5C__GEN_DLL_REMOVE() */ + +#define H5C__GEN_DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size, fail_val) \ +{ \ + H5C__GEN_DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ + (dll_size) -= (old_size); \ + (dll_size) += (new_size); \ + H5C__GEN_DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size, fail_val) \ +} /* H5C__GEN_DLL_UPDATE_FOR_SIZE_CHANGE() */ -#endif /* H5C_DO_SANITY_CHECKS */ +/* Macros that modify the LRU/protected/pinned lists */ +#define H5C__DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_APPEND(entry_ptr, next, prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_PREPEND(entry_ptr, next, prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_REMOVE(entry_ptr, next, prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size, fail_val) \ + H5C__GEN_DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size, fail_val) -#define H5C__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val)\ -{ \ - H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->il_next = (entry_ptr); \ - (entry_ptr)->il_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (list_size) += entry_ptr->size; \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ -} /* H5C__IL_DLL_APPEND() */ +/* Macros that modify the "auxiliary" LRU list */ +#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_APPEND(entry_ptr, aux_next, aux_prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_PREPEND(entry_ptr, aux_next, aux_prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_REMOVE(entry_ptr, aux_next, aux_prev, head_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->il_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->il_prev = NULL; \ - } \ - else \ - (entry_ptr)->il_prev->il_next = (entry_ptr)->il_next; \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->il_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->il_next = NULL; \ - } \ - else \ - (entry_ptr)->il_next->il_prev = (entry_ptr)->il_prev; \ - entry_ptr->il_next = NULL; \ - entry_ptr->il_prev = NULL; \ - (len)--; \ - (list_size) -= entry_ptr->size; \ - } \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ -} /* H5C__IL_DLL_REMOVE() */ +/* Macros that modify the "index" list */ +#define H5C__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_APPEND(entry_ptr, il_next, il_prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_REMOVE(entry_ptr, il_next, il_prev, head_ptr, tail_ptr, len, list_size, fail_val) /*********************************************************************** @@ -516,24 +226,31 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ***********************************************************************/ #define H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) \ - (cache_ptr)->cache_accesses++; \ +do { \ + (cache_ptr)->cache_accesses++; \ if (hit) \ - (cache_ptr)->cache_hits++; + (cache_ptr)->cache_hits++; \ +} while (0) #if H5C_COLLECT_CACHE_STATS #define H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ +do { \ if ((cache_ptr)->index_size > (cache_ptr)->max_index_size) \ (cache_ptr)->max_index_size = (cache_ptr)->index_size; \ if ((cache_ptr)->clean_index_size > (cache_ptr)->max_clean_index_size) \ (cache_ptr)->max_clean_index_size = (cache_ptr)->clean_index_size; \ if ((cache_ptr)->dirty_index_size > (cache_ptr)->max_dirty_index_size) \ - (cache_ptr)->max_dirty_index_size = (cache_ptr)->dirty_index_size; + (cache_ptr)->max_dirty_index_size = (cache_ptr)->dirty_index_size; \ +} while (0) -#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ - (cache_ptr)->dirty_pins[(entry_ptr)->type->id]++; +#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ +do { \ + (cache_ptr)->dirty_pins[(entry_ptr)->type->id]++; \ +} while (0) #define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) \ +do { \ if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ @@ -541,90 +258,122 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ +} while (0) -#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ - if ((cache_ptr)->flush_in_progress) \ +#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ +do { \ + if ((cache_ptr)->flush_in_progress) \ (cache_ptr)->cache_flush_moves[(entry_ptr)->type->id]++; \ - if ((entry_ptr)->flush_in_progress) \ + if ((entry_ptr)->flush_in_progress) \ (cache_ptr)->entry_flush_moves[(entry_ptr)->type->id]++; \ (cache_ptr)->moves[(entry_ptr)->type->id]++; \ - (cache_ptr)->entries_relocated_counter++; + (cache_ptr)->entries_relocated_counter++; \ +} while (0) -#define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size)\ - if ((cache_ptr)->flush_in_progress) \ +#define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ +do { \ + if ((cache_ptr)->flush_in_progress) \ (cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id]++; \ - if ((entry_ptr)->flush_in_progress) \ + if ((entry_ptr)->flush_in_progress) \ (cache_ptr)->entry_flush_size_changes[(entry_ptr)->type->id]++; \ if ((entry_ptr)->size < (new_size)) { \ (cache_ptr)->size_increases[(entry_ptr)->type->id]++; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr); \ if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - } else if ((entry_ptr)->size > (new_size)) \ - (cache_ptr)->size_decreases[(entry_ptr)->type->id]++; + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ + } else if ((entry_ptr)->size > (new_size)) { \ + (cache_ptr)->size_decreases[(entry_ptr)->type->id]++; \ + } \ +} while (0) #define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ - (cache_ptr)->total_ht_insertions++; +do { \ + (cache_ptr)->total_ht_insertions++; \ +} while (0) #define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ - (cache_ptr)->total_ht_deletions++; - -#define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ - if (success) { \ - (cache_ptr)->successful_ht_searches++; \ - (cache_ptr)->total_successful_ht_search_depth += depth; \ - } else { \ - (cache_ptr)->failed_ht_searches++; \ - (cache_ptr)->total_failed_ht_search_depth += depth; \ - } +do { \ + (cache_ptr)->total_ht_deletions++; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ +do { \ + if (success) { \ + (cache_ptr)->successful_ht_searches++; \ + (cache_ptr)->total_successful_ht_search_depth += depth; \ + } else { \ + (cache_ptr)->failed_ht_searches++; \ + (cache_ptr)->total_failed_ht_search_depth += depth; \ + } \ +} while (0) #define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) \ - (cache_ptr)->unpins[(entry_ptr)->type->id]++; +do { \ + (cache_ptr)->unpins[(entry_ptr)->type->id]++; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) \ +do { \ + (cache_ptr)->prefetches++; \ + if (dirty) \ + (cache_ptr)->dirty_prefetches++; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) \ +do { \ + (cache_ptr)->prefetch_hits++; \ +} while (0) #define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) \ - (cache_ptr)->slist_scan_restarts++; +do { \ + (cache_ptr)->slist_scan_restarts++; \ +} while (0) #define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) \ - (cache_ptr)->LRU_scan_restarts++; +do { \ + (cache_ptr)->LRU_scan_restarts++; \ +} while (0) #define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) \ - (cache_ptr)->index_scan_restarts++; +do { \ + (cache_ptr)->index_scan_restarts++; \ +} while (0) #if H5C_COLLECT_CACHE_ENTRY_STATS #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) \ -{ \ - (entry_ptr)->accesses = 0; \ - (entry_ptr)->clears = 0; \ - (entry_ptr)->flushes = 0; \ - (entry_ptr)->pins = 0; \ -} - -#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ -{ \ +do { \ + (entry_ptr)->accesses = 0; \ + (entry_ptr)->clears = 0; \ + (entry_ptr)->flushes = 0; \ + (entry_ptr)->pins = 0; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ +do { \ (cache_ptr)->clears[(entry_ptr)->type->id]++; \ - if((entry_ptr)->is_pinned) \ + if((entry_ptr)->is_pinned) \ (cache_ptr)->pinned_clears[(entry_ptr)->type->id]++; \ - (entry_ptr)->clears++; \ -} + (entry_ptr)->clears++; \ +} while (0) -#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ -{ \ +#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ +do { \ (cache_ptr)->flushes[(entry_ptr)->type->id]++; \ - if((entry_ptr)->is_pinned) \ + if((entry_ptr)->is_pinned) \ (cache_ptr)->pinned_flushes[(entry_ptr)->type->id]++; \ - (entry_ptr)->flushes++; \ -} + (entry_ptr)->flushes++; \ +} while (0) #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ -{ \ - if (take_ownership) \ - (cache_ptr)->take_ownerships[(entry_ptr)->type->id]++; \ +do { \ + if (take_ownership) \ + (cache_ptr)->take_ownerships[(entry_ptr)->type->id]++; \ else \ - (cache_ptr)->evictions[(entry_ptr)->type->id]++; \ + (cache_ptr)->evictions[(entry_ptr)->type->id]++; \ if ((entry_ptr)->accesses > (cache_ptr)->max_accesses[(entry_ptr)->type->id]) \ (cache_ptr)->max_accesses[(entry_ptr)->type->id] = (entry_ptr)->accesses; \ if ((entry_ptr)->accesses < (cache_ptr)->min_accesses[(entry_ptr)->type->id]) \ @@ -633,157 +382,157 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ (cache_ptr)->max_clears[(entry_ptr)->type->id] = (entry_ptr)->clears; \ if ((entry_ptr)->flushes > (cache_ptr)->max_flushes[(entry_ptr)->type->id]) \ (cache_ptr)->max_flushes[(entry_ptr)->type->id] = (entry_ptr)->flushes; \ + if ((entry_ptr)->size > (cache_ptr)->max_size[(entry_ptr)->type->id]) \ + (cache_ptr)->max_size[(entry_ptr)->type->id] = (entry_ptr)->size; \ + if ((entry_ptr)->pins > (cache_ptr)->max_pins[(entry_ptr)->type->id]) \ + (cache_ptr)->max_pins[(entry_ptr)->type->id] = (entry_ptr)->pins; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ +do { \ + (cache_ptr)->insertions[(entry_ptr)->type->id]++; \ + if ((entry_ptr)->is_pinned) { \ + (cache_ptr)->pinned_insertions[(entry_ptr)->type->id]++; \ + (cache_ptr)->pins[(entry_ptr)->type->id]++; \ + (entry_ptr)->pins++; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } \ + if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr); \ + if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ if ((entry_ptr)->size > (cache_ptr)->max_size[(entry_ptr)->type->id]) \ (cache_ptr)->max_size[(entry_ptr)->type->id] = (entry_ptr)->size; \ - if ((entry_ptr)->pins > (cache_ptr)->max_pins[(entry_ptr)->type->id]) \ - (cache_ptr)->max_pins[(entry_ptr)->type->id] = (entry_ptr)->pins; \ -} - -#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ -{ \ - (cache_ptr)->insertions[(entry_ptr)->type->id]++; \ - if ((entry_ptr)->is_pinned) { \ - (cache_ptr)->pinned_insertions[(entry_ptr)->type->id]++; \ - (cache_ptr)->pins[(entry_ptr)->type->id]++; \ - (entry_ptr)->pins++; \ - if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } \ - if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - if ((entry_ptr)->size > (cache_ptr)->max_size[(entry_ptr)->type->id]) \ - (cache_ptr)->max_size[(entry_ptr)->type->id] = (entry_ptr)->size; \ - (cache_ptr)->entries_inserted_counter++; \ -} + (cache_ptr)->entries_inserted_counter++; \ +} while (0) -#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ -{ \ +#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ +do { \ if (hit) \ (cache_ptr)->hits[(entry_ptr)->type->id]++; \ - else \ + else \ (cache_ptr)->misses[(entry_ptr)->type->id]++; \ - if (!(entry_ptr)->is_read_only) \ + if (!(entry_ptr)->is_read_only) \ (cache_ptr)->write_protects[(entry_ptr)->type->id]++; \ else { \ (cache_ptr)->read_protects[(entry_ptr)->type->id]++; \ - if ((entry_ptr)->ro_ref_count > (cache_ptr)->max_read_protects[(entry_ptr)->type->id]) \ - (cache_ptr)->max_read_protects[(entry_ptr)->type->id] = (entry_ptr)->ro_ref_count; \ - } \ + if ((entry_ptr)->ro_ref_count > (cache_ptr)->max_read_protects[(entry_ptr)->type->id]) \ + (cache_ptr)->max_read_protects[(entry_ptr)->type->id] = (entry_ptr)->ro_ref_count; \ + } \ if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr); \ if ((cache_ptr)->pl_len > (cache_ptr)->max_pl_len) \ - (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ + (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ - if ((entry_ptr)->size > (cache_ptr)->max_size[(entry_ptr)->type->id]) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ + if ((entry_ptr)->size > (cache_ptr)->max_size[(entry_ptr)->type->id]) \ (cache_ptr)->max_size[(entry_ptr)->type->id] = (entry_ptr)->size; \ (entry_ptr)->accesses++; \ -} +} while (0) #define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ -{ \ - (cache_ptr)->pins[(entry_ptr)->type->id]++; \ +do { \ + (cache_ptr)->pins[(entry_ptr)->type->id]++; \ (entry_ptr)->pins++; \ - if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ -} +} while (0) #else /* H5C_COLLECT_CACHE_ENTRY_STATS */ #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) -#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ -{ \ +#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ +do { \ (cache_ptr)->clears[(entry_ptr)->type->id]++; \ - if((entry_ptr)->is_pinned) \ + if((entry_ptr)->is_pinned) \ (cache_ptr)->pinned_clears[(entry_ptr)->type->id]++; \ -} +} while (0) -#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ -{ \ +#define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ +do { \ (cache_ptr)->flushes[(entry_ptr)->type->id]++; \ - if ((entry_ptr)->is_pinned) \ + if ((entry_ptr)->is_pinned) \ (cache_ptr)->pinned_flushes[(entry_ptr)->type->id]++; \ -} +} while (0) #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ -{ \ - if (take_ownership) \ - (cache_ptr)->take_ownerships[(entry_ptr)->type->id]++; \ - else \ - (cache_ptr)->evictions[(entry_ptr)->type->id]++; \ -} - -#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ -{ \ - (((cache_ptr)->insertions)[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->is_pinned ) { \ - (((cache_ptr)->pinned_insertions)[(entry_ptr)->type->id])++; \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ - } \ - if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->slist_len > (cache_ptr)->max_slist_len ) \ - (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ - if ( (cache_ptr)->slist_size > (cache_ptr)->max_slist_size ) \ - (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ - (cache_ptr)->entries_inserted_counter++; \ -} - -#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ -{ \ - if ( hit ) \ - ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ - else \ - ((cache_ptr)->misses)[(entry_ptr)->type->id]++; \ - if ( ! ((entry_ptr)->is_read_only) ) \ - ((cache_ptr)->write_protects)[(entry_ptr)->type->id]++; \ - else { \ - ((cache_ptr)->read_protects)[(entry_ptr)->type->id]++; \ - if ( ((entry_ptr)->ro_ref_count) > \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] ) \ - ((cache_ptr)->max_read_protects)[(entry_ptr)->type->id] = \ - ((entry_ptr)->ro_ref_count); \ - } \ - if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ - (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ - H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - if ( (cache_ptr)->pl_len > (cache_ptr)->max_pl_len ) \ - (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ - if ( (cache_ptr)->pl_size > (cache_ptr)->max_pl_size ) \ - (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ -} - -#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ -{ \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ - if ( (cache_ptr)->pel_len > (cache_ptr)->max_pel_len ) \ - (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ - if ( (cache_ptr)->pel_size > (cache_ptr)->max_pel_size ) \ - (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ -} +do { \ + if (take_ownership) \ + (cache_ptr)->take_ownerships[(entry_ptr)->type->id]++; \ + else \ + (cache_ptr)->evictions[(entry_ptr)->type->id]++; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ +do { \ + (cache_ptr)->insertions[(entry_ptr)->type->id]++; \ + if ((entry_ptr)->is_pinned) { \ + (cache_ptr)->pinned_insertions[(entry_ptr)->type->id]++; \ + (cache_ptr)->pins[(entry_ptr)->type->id]++; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ + } \ + if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->slist_len > (cache_ptr)->max_slist_len) \ + (cache_ptr)->max_slist_len = (cache_ptr)->slist_len; \ + if ((cache_ptr)->slist_size > (cache_ptr)->max_slist_size) \ + (cache_ptr)->max_slist_size = (cache_ptr)->slist_size; \ + (cache_ptr)->entries_inserted_counter++; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ +do { \ + if (hit) \ + (cache_ptr)->hits[(entry_ptr)->type->id]++; \ + else \ + (cache_ptr)->misses[(entry_ptr)->type->id]++; \ + if (!(entry_ptr)->is_read_only) \ + (cache_ptr)->write_protects[(entry_ptr)->type->id]++; \ + else { \ + (cache_ptr)->read_protects[(entry_ptr)->type->id]++; \ + if ((entry_ptr)->ro_ref_count > \ + (cache_ptr)->max_read_protects[(entry_ptr)->type->id]) \ + (cache_ptr)->max_read_protects[(entry_ptr)->type->id] = \ + (entry_ptr)->ro_ref_count; \ + } \ + if ((cache_ptr)->index_len > (cache_ptr)->max_index_len) \ + (cache_ptr)->max_index_len = (cache_ptr)->index_len; \ + H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ + if ((cache_ptr)->pl_len > (cache_ptr)->max_pl_len) \ + (cache_ptr)->max_pl_len = (cache_ptr)->pl_len; \ + if ((cache_ptr)->pl_size > (cache_ptr)->max_pl_size) \ + (cache_ptr)->max_pl_size = (cache_ptr)->pl_size; \ +} while (0) + +#define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ +do { \ + (cache_ptr)->pins[(entry_ptr)->type->id]++; \ + if ((cache_ptr)->pel_len > (cache_ptr)->max_pel_len) \ + (cache_ptr)->max_pel_len = (cache_ptr)->pel_len; \ + if ((cache_ptr)->pel_size > (cache_ptr)->max_pel_size) \ + (cache_ptr)->max_pel_size = (cache_ptr)->pel_size; \ +} while (0) #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #else /* H5C_COLLECT_CACHE_STATS */ #define H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) -#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) +#define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) {} #define H5C__UPDATE_STATS_FOR_UNPROTECT(cache_ptr) #define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) @@ -797,6 +546,8 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) #define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) +#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) +#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) #define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) #define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) #define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) @@ -811,318 +562,263 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ * The following macros handle searches, insertions, and deletion in * the hash table. * - * When modifying these macros, remember to modify the similar macros - * in tst/cache.c - * ***********************************************************************/ -/* H5C__HASH_TABLE_LEN is defined in H5Cpkg.h. It mut be a power of two. */ - -#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) - +#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) #define H5C__HASH_FCN(x) (int)((unsigned)((x) & H5C__HASH_MASK) >> 3) +#define H5C__POST_HT_SHIFT_TO_FRONT_SC_CMP(cache_ptr, entry_ptr, k) \ +((cache_ptr) == NULL || (cache_ptr)->index[k] != (entry_ptr) || \ + (entry_ptr)->ht_prev != NULL \ +) +#define H5C__PRE_HT_SEARCH_SC_CMP(cache_ptr, entry_addr) \ +((cache_ptr) == NULL || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + !H5_addr_defined(entry_addr) || \ + H5C__HASH_FCN(entry_addr) < 0 || \ + H5C__HASH_FCN(entry_addr) >= H5C__HASH_TABLE_LEN \ +) +#define H5C__POST_SUC_HT_SEARCH_SC_CMP(cache_ptr, entry_ptr, k) \ +((cache_ptr) == NULL || (cache_ptr)->index_len < 1 || \ + (entry_ptr) == NULL || \ + (cache_ptr)->index_size < (entry_ptr)->size || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (entry_ptr)->size <= 0 || \ + (cache_ptr)->index[k] == NULL || \ + ((cache_ptr)->index[k] != (entry_ptr) && (entry_ptr)->ht_prev == NULL) || \ + ((cache_ptr)->index[k] == (entry_ptr) && (entry_ptr)->ht_prev != NULL) || \ + ((entry_ptr)->ht_prev != NULL && (entry_ptr)->ht_prev->ht_next != (entry_ptr)) || \ + ((entry_ptr)->ht_next != NULL && (entry_ptr)->ht_next->ht_prev != (entry_ptr)) \ +) + #ifdef H5C_DO_SANITY_CHECKS #define H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (entry_ptr) == NULL ) || \ - ( ! H5_addr_defined((entry_ptr)->addr) ) || \ - ( (entry_ptr)->ht_next != NULL ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) < 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ +if ((cache_ptr) == NULL || \ + (entry_ptr) == NULL || !H5_addr_defined((entry_ptr)->addr) || \ + (entry_ptr)->ht_next != NULL || (entry_ptr)->ht_prev != NULL || \ + (entry_ptr)->size <= 0 || \ + H5C__HASH_FCN((entry_ptr)->addr) < 0 || \ + H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + (entry_ptr)->ring <= H5C_RING_UNDEFINED || \ + (entry_ptr)->ring >= H5C_RING_NTYPES || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) || \ + (cache_ptr)->index_len != (cache_ptr)->il_len || \ + (cache_ptr)->index_size != (cache_ptr)->il_size \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ } #define H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] == 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ +if ((cache_ptr) == NULL || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] == 0 || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size) ) { \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) || \ + (cache_ptr)->index_len != (cache_ptr)->il_len || \ + (cache_ptr)->index_size != (cache_ptr)->il_size \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ } -#define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len < 1 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( ! H5_addr_defined((entry_ptr)->addr) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) < 0 ) || \ - ( H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN ) || \ - ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] \ - == NULL ) || \ - ( ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] \ - != (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev == NULL ) ) || \ - ( ( ((cache_ptr)->index)[(H5C__HASH_FCN((entry_ptr)->addr))] == \ - (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev != NULL ) ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] < \ - (entry_ptr)->size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ +#define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ +if ( (cache_ptr) == NULL || (cache_ptr)->index_len < 1 || \ + (entry_ptr) == NULL || \ + (cache_ptr)->index_size < (entry_ptr)->size || \ + !H5_addr_defined((entry_ptr)->addr) || \ + (entry_ptr)->size <= 0 || \ + H5C__HASH_FCN((entry_ptr)->addr) < 0 || \ + H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN || \ + (cache_ptr)->index[H5C__HASH_FCN((entry_ptr)->addr)] == NULL || \ + ((cache_ptr)->index[H5C__HASH_FCN((entry_ptr)->addr)] != (entry_ptr) && \ + (entry_ptr)->ht_prev == NULL) || \ + ((cache_ptr)->index[H5C__HASH_FCN((entry_ptr)->addr)] == (entry_ptr) && \ + (entry_ptr)->ht_prev != NULL) || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + (entry_ptr)->ring <= H5C_RING_UNDEFINED || \ + (entry_ptr)->ring >= H5C_RING_NTYPES || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] < (entry_ptr)->size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) || \ + (cache_ptr)->index_len != (cache_ptr)->il_len || \ + (cache_ptr)->index_size != (cache_ptr)->il_size \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "pre HT remove SC failed") \ } -#define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (entry_ptr) == NULL ) || \ - ( ! H5_addr_defined((entry_ptr)->addr) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (entry_ptr)->ht_prev != NULL ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ +#define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ +if ((cache_ptr) == NULL || \ + (entry_ptr) == NULL || !H5_addr_defined((entry_ptr)->addr) || \ + (entry_ptr)->size <= 0 || \ + (entry_ptr)->ht_next != NULL || \ + (entry_ptr)->ht_prev != NULL || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) || \ + (cache_ptr)->index_len != (cache_ptr)->il_len || \ + (cache_ptr)->index_size != (cache_ptr)->il_size \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "post HT remove SC failed") \ } -/* (Keep in sync w/H5C_TEST__PRE_HT_SEARCH_SC macro in test/cache_common.h -QAK) */ -#define H5C__PRE_HT_SEARCH_SC(cache_ptr, entry_addr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( ! H5_addr_defined(entry_addr) ) || \ - ( H5C__HASH_FCN(entry_addr) < 0 ) || \ - ( H5C__HASH_FCN(entry_addr) >= H5C__HASH_TABLE_LEN ) ) { \ +#define H5C__PRE_HT_SEARCH_SC(cache_ptr, entry_addr, fail_val) \ +if (H5C__PRE_HT_SEARCH_SC_CMP(cache_ptr, entry_addr)) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "pre HT search SC failed") \ } -/* (Keep in sync w/H5C_TEST__POST_SUC_HT_SEARCH_SC macro in test/cache_common.h -QAK) */ #define H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len < 1 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->size <= 0 ) || \ - ( ((cache_ptr)->index)[k] == NULL ) || \ - ( ( ((cache_ptr)->index)[k] != (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev == NULL ) ) || \ - ( ( ((cache_ptr)->index)[k] == (entry_ptr) ) && \ - ( (entry_ptr)->ht_prev != NULL ) ) || \ - ( ( (entry_ptr)->ht_prev != NULL ) && \ - ( (entry_ptr)->ht_prev->ht_next != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->ht_next != NULL ) && \ - ( (entry_ptr)->ht_next->ht_prev != (entry_ptr) ) ) ) { \ +if(H5C__POST_SUC_HT_SEARCH_SC_CMP(cache_ptr, entry_ptr, k)) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "post successful HT search SC failed") \ } -/* (Keep in sync w/H5C_TEST__POST_HT_SHIFT_TO_FRONT macro in test/cache_common.h -QAK) */ -#define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( ((cache_ptr)->index)[k] != (entry_ptr) ) || \ - ( (entry_ptr)->ht_prev != NULL ) ) { \ +#define H5C__POST_HT_SHIFT_TO_FRONT_SC(cache_ptr, entry_ptr, k, fail_val) \ +if(H5C__POST_HT_SHIFT_TO_FRONT_SC_CMP(cache_ptr, entry_ptr, k)) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "post HT shift to front SC failed") \ } -#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (cache_ptr)->index_size <= 0 ) || \ - ( (new_size) <= 0 ) || \ - ( (old_size) > (cache_ptr)->index_size ) || \ - ( ( (cache_ptr)->index_len == 1 ) && \ - ( (cache_ptr)->index_size != (old_size) ) ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( ( !( was_clean ) || \ - ( (cache_ptr)->clean_index_size < (old_size) ) ) && \ - ( ( (was_clean) ) || \ - ( (cache_ptr)->dirty_index_size < (old_size) ) ) ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ +#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ + entry_ptr, was_clean, fail_val) \ +if ((cache_ptr) == NULL || \ + (cache_ptr)->index_len <= 0 || (cache_ptr)->index_size <= 0 || \ + (new_size) <= 0 || (old_size) > (cache_ptr)->index_size || \ + ((cache_ptr)->index_len == 1 && (cache_ptr)->index_size != (old_size)) || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + ((!(was_clean) || (cache_ptr)->clean_index_size < (old_size)) && \ + ((was_clean) || (cache_ptr)->dirty_index_size < (old_size))) || \ + (entry_ptr) == NULL || \ + (entry_ptr)->ring <= H5C_RING_UNDEFINED || \ + (entry_ptr)->ring >= H5C_RING_NTYPES || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) || \ + (cache_ptr)->index_len != (cache_ptr)->il_len || \ + (cache_ptr)->index_size != (cache_ptr)->il_size \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "pre HT entry size change SC failed") \ } -#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, fail_val) \ -if ( ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (cache_ptr)->index_size <= 0 ) || \ - ( (new_size) > (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( ( !((entry_ptr)->is_dirty ) || \ - ( (cache_ptr)->dirty_index_size < (new_size) ) ) && \ - ( ( ((entry_ptr)->is_dirty) ) || \ - ( (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] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) || \ - ( (cache_ptr)->index_len != (cache_ptr)->il_len ) || \ - ( (cache_ptr)->index_size != (cache_ptr)->il_size ) ) { \ +#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ + entry_ptr, fail_val) \ +if ((cache_ptr) == NULL || \ + (cache_ptr)->index_len <= 0 || (cache_ptr)->index_size <= 0 || \ + (new_size) > (cache_ptr)->index_size || \ + (cache_ptr)->index_size != \ + ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + ((!((entry_ptr)->is_dirty ) || (cache_ptr)->dirty_index_size < (new_size)) && \ + ((entry_ptr)->is_dirty || (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] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) || \ + (cache_ptr)->index_len != (cache_ptr)->il_len || \ + (cache_ptr)->index_size != (cache_ptr)->il_size \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "post HT entry size change SC failed") \ } -#define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) \ -if ( \ - ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->is_dirty != FALSE ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->dirty_index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ +#define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) \ +if ((cache_ptr) == NULL || (cache_ptr)->index_len <= 0 || \ + (entry_ptr) == NULL || (entry_ptr)->is_dirty != FALSE || \ + (cache_ptr)->index_size < (entry_ptr)->size || \ + (cache_ptr)->dirty_index_size < (entry_ptr)->size || \ + (cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) || \ + (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) || \ + (entry_ptr)->ring <= H5C_RING_UNDEFINED || \ + (entry_ptr)->ring >= H5C_RING_NTYPES || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "pre HT update for entry clean SC failed") \ } -#define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) \ -if ( \ - ( (cache_ptr) == NULL ) || \ - ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ - ( (cache_ptr)->index_len <= 0 ) || \ - ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->is_dirty != TRUE ) || \ - ( (cache_ptr)->index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->clean_index_size < (entry_ptr)->size ) || \ - ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ - ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ +#define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) \ +if ((cache_ptr) == NULL || (cache_ptr)->index_len <= 0 || \ + (entry_ptr) == NULL || (entry_ptr)->is_dirty != TRUE || \ + (cache_ptr)->index_size < (entry_ptr)->size || \ + (cache_ptr)->clean_index_size < (entry_ptr)->size || \ + (cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + (entry_ptr)->ring <= H5C_RING_UNDEFINED || \ + (entry_ptr)->ring >= H5C_RING_NTYPES || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] <= 0 || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "pre HT update for entry dirty SC failed") \ } -#define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ +#define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) \ +if ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "post HT update for entry clean SC failed") \ } -#define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) \ -if ( ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ - ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ - ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ - (cache_ptr)->index_len ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] > \ - (cache_ptr)->index_size ) || \ - ( (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ - (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) ) ) { \ +#define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) \ +if ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) || \ + (cache_ptr)->index_size < (cache_ptr)->clean_index_size || \ + (cache_ptr)->index_size < (cache_ptr)->dirty_index_size || \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring] > (cache_ptr)->index_len || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] > (cache_ptr)->index_size || \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] != \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] + \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ + ) { \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "post HT update for entry dirty SC failed") \ } @@ -1134,13 +830,11 @@ if ( ( (cache_ptr)->index_size != \ #define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) #define H5C__PRE_HT_SEARCH_SC(cache_ptr, entry_addr, fail_val) #define H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) -#define H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) +#define H5C__POST_HT_SHIFT_TO_FRONT_SC(cache_ptr, entry_ptr, k, fail_val) #define H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) #define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) -#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean, fail_val) -#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, fail_val) +#define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, was_clean, fail_val) +#define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, entry_ptr, fail_val) #define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) #define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) @@ -1148,28 +842,25 @@ if ( ( (cache_ptr)->index_size != \ #define H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, fail_val) \ -{ \ +do { \ int k; \ H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ k = H5C__HASH_FCN((entry_ptr)->addr); \ - if(((cache_ptr)->index)[k] != NULL) { \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ + if((cache_ptr)->index[k] != NULL) { \ + (entry_ptr)->ht_next = (cache_ptr)->index[k]; \ (entry_ptr)->ht_next->ht_prev = (entry_ptr); \ } \ - ((cache_ptr)->index)[k] = (entry_ptr); \ + (cache_ptr)->index[k] = (entry_ptr); \ (cache_ptr)->index_len++; \ (cache_ptr)->index_size += (entry_ptr)->size; \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring])++; \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring]) \ - += (entry_ptr)->size; \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring]++; \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] += (entry_ptr)->size; \ if((entry_ptr)->is_dirty) { \ (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ - += (entry_ptr)->size; \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring] += (entry_ptr)->size; \ } else { \ (cache_ptr)->clean_index_size += (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring]) \ - += (entry_ptr)->size; \ + (cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] += (entry_ptr)->size; \ } \ if((entry_ptr)->flush_me_last) { \ (cache_ptr)->num_last_entries++; \ @@ -1177,37 +868,34 @@ if ( ( (cache_ptr)->index_size != \ } \ H5C__IL_DLL_APPEND((entry_ptr), (cache_ptr)->il_head, \ (cache_ptr)->il_tail, (cache_ptr)->il_len, \ - (cache_ptr)->il_size, fail_val) \ - H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ - H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) \ -} + (cache_ptr)->il_size, fail_val); \ + H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr); \ + H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val); \ +} while (0) #define H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, fail_val) \ -{ \ +do { \ int k; \ - H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ + H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ k = H5C__HASH_FCN((entry_ptr)->addr); \ if((entry_ptr)->ht_next) \ (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ if((entry_ptr)->ht_prev) \ (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - if(((cache_ptr)->index)[k] == (entry_ptr)) \ - ((cache_ptr)->index)[k] = (entry_ptr)->ht_next; \ + if((cache_ptr)->index[k] == (entry_ptr)) \ + (cache_ptr)->index[k] = (entry_ptr)->ht_next; \ (entry_ptr)->ht_next = NULL; \ (entry_ptr)->ht_prev = NULL; \ (cache_ptr)->index_len--; \ (cache_ptr)->index_size -= (entry_ptr)->size; \ - ((cache_ptr)->index_ring_len[(entry_ptr)->ring])--; \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring]) \ - -= (entry_ptr)->size; \ + (cache_ptr)->index_ring_len[(entry_ptr)->ring]--; \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] -= (entry_ptr)->size; \ if((entry_ptr)->is_dirty) { \ (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ - -= (entry_ptr)->size; \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring] -= (entry_ptr)->size; \ } else { \ (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring]) \ - -= (entry_ptr)->size; \ + (cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] -= (entry_ptr)->size; \ } \ if((entry_ptr)->flush_me_last) { \ (cache_ptr)->num_last_entries--; \ @@ -1215,211 +903,169 @@ if ( ( (cache_ptr)->index_size != \ } \ H5C__IL_DLL_REMOVE((entry_ptr), (cache_ptr)->il_head, \ (cache_ptr)->il_tail, (cache_ptr)->il_len, \ - (cache_ptr)->il_size, fail_val) \ - H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) \ - H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ -} - -#define H5C__SEARCH_INDEX(cache_ptr, entry_addr, entry_ptr, fail_val) \ -{ \ - int k; \ - int depth = 0; \ - H5C__PRE_HT_SEARCH_SC(cache_ptr, entry_addr, fail_val) \ - k = H5C__HASH_FCN(entry_addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ - while(entry_ptr) { \ - if(H5_addr_eq(entry_addr, (entry_ptr)->addr)) { \ - H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val) \ - if(entry_ptr != ((cache_ptr)->index)[k]) { \ - if((entry_ptr)->ht_next) \ - (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ - assert((entry_ptr)->ht_prev != NULL); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - H5C__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k, fail_val) \ - } \ - break; \ - } \ - (entry_ptr) = (entry_ptr)->ht_next; \ - (depth)++; \ - } \ - H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, (entry_ptr != NULL), depth) \ -} - -#define H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr, fail_val) \ -{ \ - H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) \ - (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ - -= (entry_ptr)->size; \ - (cache_ptr)->clean_index_size += (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring]) \ - += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) \ -} + (cache_ptr)->il_size, fail_val); \ + H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr); \ + H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val); \ +} while (0) -#define H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr, fail_val) \ -{ \ - H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) \ - (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring]) \ - -= (entry_ptr)->size; \ - (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ - ((cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ - += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) \ -} +#define H5C__SEARCH_INDEX(cache_ptr, entry_addr, entry_ptr, fail_val) \ +do { \ + int k; \ + int depth = 0; \ + H5C__PRE_HT_SEARCH_SC(cache_ptr, entry_addr, fail_val); \ + k = H5C__HASH_FCN(entry_addr); \ + (entry_ptr) = (cache_ptr)->index[k]; \ + while(entry_ptr) { \ + if(H5_addr_eq(entry_addr, (entry_ptr)->addr)) { \ + H5C__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k, fail_val); \ + if((entry_ptr) != (cache_ptr)->index[k]) { \ + if((entry_ptr)->ht_next) \ + (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ + assert((entry_ptr)->ht_prev != NULL); \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + (cache_ptr)->index[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = (cache_ptr)->index[k]; \ + (entry_ptr)->ht_prev = NULL; \ + (cache_ptr)->index[k] = (entry_ptr); \ + H5C__POST_HT_SHIFT_TO_FRONT_SC(cache_ptr, entry_ptr, k, fail_val); \ + } \ + break; \ + } \ + (entry_ptr) = (entry_ptr)->ht_next; \ + (depth)++; \ + } \ + H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, ((entry_ptr) != NULL), depth); \ +} while (0) + +#define H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr, fail_val) \ +do { \ + H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val); \ + (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring] -= (entry_ptr)->size; \ + (cache_ptr)->clean_index_size += (entry_ptr)->size; \ + (cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] += (entry_ptr)->size; \ + H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val); \ +} while (0) + +#define H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr, fail_val) \ +do { \ + H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val); \ + (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ + (cache_ptr)->clean_index_ring_size[(entry_ptr)->ring] -= (entry_ptr)->size; \ + (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring] += (entry_ptr)->size; \ + H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val); \ +} while (0) #define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean, fail_val) \ -{ \ + entry_ptr, was_clean, fail_val) \ +do { \ H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean, fail_val) \ + entry_ptr, was_clean, fail_val); \ (cache_ptr)->index_size -= (old_size); \ (cache_ptr)->index_size += (new_size); \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring]) -= (old_size); \ - ((cache_ptr)->index_ring_size[(entry_ptr)->ring]) += (new_size); \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] -= (old_size); \ + (cache_ptr)->index_ring_size[(entry_ptr)->ring] += (new_size); \ if(was_clean) { \ (cache_ptr)->clean_index_size -= (old_size); \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring])-= (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_ring_size[(entry_ptr)->ring])-= (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); \ + (cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring] += (new_size); \ } else { \ - (cache_ptr)->clean_index_size += (new_size); \ - ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring])+= (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, \ (cache_ptr)->il_size, \ - (old_size), (new_size), (fail_val)) \ + (old_size), (new_size), (fail_val)); \ H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, fail_val) \ -} + entry_ptr, fail_val); \ +} while (0) /************************************************************************** * - * Skip list insertion and deletion macros: + * Skip list modification macros * **************************************************************************/ -/*------------------------------------------------------------------------- - * - * Macro: H5C__INSERT_ENTRY_IN_SLIST - * - * Purpose: Insert the specified instance of H5C_cache_entry_t into - * the skip list in the specified instance of H5C_t. Update - * the associated length and size fields. - * - * Return: N/A - * - * Programmer: John Mainzer, 5/10/04 - * - *------------------------------------------------------------------------- - */ - -/* NOTE: The H5C__INSERT_ENTRY_IN_SLIST() macro is set up so that - * - * H5C_DO_SANITY_CHECKS - * - * and - * - * H5C_DO_SLIST_SANITY_CHECKS - * - * can be selected independently. This is easy to miss as the - * two #defines are easy to confuse. - */ - #ifdef H5C_DO_SLIST_SANITY_CHECKS -#define H5C_ENTRY_IN_SLIST(cache_ptr, entry_ptr) \ +#define H5C__ENTRY_IN_SLIST(cache_ptr, entry_ptr) \ H5C__entry_in_skip_list((cache_ptr), (entry_ptr)) #else /* H5C_DO_SLIST_SANITY_CHECKS */ -#define H5C_ENTRY_IN_SLIST(cache_ptr, entry_ptr) FALSE +#define H5C__ENTRY_IN_SLIST(cache_ptr, entry_ptr) FALSE #endif /* H5C_DO_SLIST_SANITY_CHECKS */ #ifdef H5C_DO_SANITY_CHECKS -#define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - \ - if ( (cache_ptr)->slist_enabled ) { \ - \ - assert( (entry_ptr) ); \ - assert( (entry_ptr)->size > 0 ); \ - assert( H5_addr_defined((entry_ptr)->addr) ); \ - assert( !((entry_ptr)->in_slist) ); \ - assert( ! H5C_ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ - assert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - assert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - assert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - assert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - if ( H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, \ - &((entry_ptr)->addr)) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), \ - "can't insert entry in skip list") \ - \ - (entry_ptr)->in_slist = TRUE; \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len++; \ - (cache_ptr)->slist_size += (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size;\ - (cache_ptr)->slist_len_increase++; \ - (cache_ptr)->slist_size_increase += (int64_t)((entry_ptr)->size); \ - \ - assert( (cache_ptr)->slist_len > 0 ); \ - assert( (cache_ptr)->slist_size > 0 ); \ - \ - } else { /* slist disabled */ \ - \ - assert( (cache_ptr)->slist_len == 0 ); \ - assert( (cache_ptr)->slist_size == 0 ); \ - } \ -} /* H5C__INSERT_ENTRY_IN_SLIST */ +#define H5C__SLIST_INSERT_ENTRY_SC(cache_ptr, entry_ptr) \ +do { \ + (cache_ptr)->slist_len_increase++; \ + (cache_ptr)->slist_size_increase += (int64_t)((entry_ptr)->size); \ +} while (0) /* H5C__SLIST_INSERT_ENTRY_SC() */ +#define H5C__SLIST_REMOVE_ENTRY_SC(cache_ptr, entry_ptr) \ +do { \ + (cache_ptr)->slist_len_increase--; \ + (cache_ptr)->slist_size_increase -= (int64_t)((entry_ptr)->size); \ +} while (0) /* H5C__SLIST_REMOVE_ENTRY_SC() */ +#define H5C__SLIST_UPDATE_FOR_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size) \ +do { \ + (cache_ptr)->slist_size_increase -= (int64_t)(old_size); \ + (cache_ptr)->slist_size_increase += (int64_t)(new_size); \ +} while (0) /* H5C__SLIST_UPDATE_FOR_ENTRY_SIZE_CHANGE_SC() */ #else /* H5C_DO_SANITY_CHECKS */ +#define H5C__SLIST_INSERT_ENTRY_SC(cache_ptr, entry_ptr) +#define H5C__SLIST_REMOVE_ENTRY_SC(cache_ptr, entry_ptr) +#define H5C__SLIST_UPDATE_FOR_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size) + +#endif /* H5C_DO_SANITY_CHECKS */ + + +/*------------------------------------------------------------------------- + * + * Macro: H5C__INSERT_ENTRY_IN_SLIST + * + * Purpose: Insert a cache entry into a cache's skip list. Updates + * the associated length and size fields. + * + * Note: This macro is set up so that H5C_DO_SANITY_CHECKS and + * H5C_DO_SLIST_SANITY_CHECKS can be selected independently. + * + *------------------------------------------------------------------------- + */ + #define H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ +do { \ + assert(cache_ptr); \ \ - if ( (cache_ptr)->slist_enabled ) { \ + if((cache_ptr)->slist_enabled) { \ + assert(entry_ptr); \ + assert((entry_ptr)->size > 0); \ + assert(H5_addr_defined((entry_ptr)->addr)); \ + assert(!(entry_ptr)->in_slist); \ + assert(!H5C__ENTRY_IN_SLIST((cache_ptr), (entry_ptr))); \ + assert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + assert((entry_ptr)->ring < H5C_RING_NTYPES); \ + assert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ + (cache_ptr)->slist_len); \ + assert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ + (cache_ptr)->slist_size); \ + assert((cache_ptr)->slist_ptr); \ \ - assert( (entry_ptr) ); \ - assert( (entry_ptr)->size > 0 ); \ - assert( ! H5C_ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ - assert( H5_addr_defined((entry_ptr)->addr) ); \ - assert( !((entry_ptr)->in_slist) ); \ - assert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - assert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - assert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - assert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - assert( (cache_ptr)->slist_ptr ); \ - \ - if ( H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, \ - &((entry_ptr)->addr)) < 0) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), \ - "can't insert entry in skip list") \ + if(H5SL_insert((cache_ptr)->slist_ptr, entry_ptr, &((entry_ptr)->addr)) < 0) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't insert entry in skip list") \ \ (entry_ptr)->in_slist = TRUE; \ (cache_ptr)->slist_changed = TRUE; \ @@ -1427,288 +1073,155 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->slist_size += (entry_ptr)->size; \ ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])++; \ ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (entry_ptr)->size;\ + H5C__SLIST_INSERT_ENTRY_SC(cache_ptr, entry_ptr); \ \ - assert( (cache_ptr)->slist_len > 0 ); \ - assert( (cache_ptr)->slist_size > 0 ); \ - \ + assert((cache_ptr)->slist_len > 0); \ + assert((cache_ptr)->slist_size > 0); \ } else { /* slist disabled */ \ - \ - assert( (cache_ptr)->slist_len == 0 ); \ - assert( (cache_ptr)->slist_size == 0 ); \ + assert((cache_ptr)->slist_len == 0); \ + assert((cache_ptr)->slist_size == 0); \ } \ -} /* H5C__INSERT_ENTRY_IN_SLIST */ - -#endif /* H5C_DO_SANITY_CHECKS */ +} while (0) /* H5C__INSERT_ENTRY_IN_SLIST */ /*------------------------------------------------------------------------- * - * Function: H5C__REMOVE_ENTRY_FROM_SLIST + * Macro: H5C__REMOVE_ENTRY_FROM_SLIST * - * Purpose: Remove the specified instance of H5C_cache_entry_t from the - * index skip list in the specified instance of H5C_t. Update + * Purpose: Insert a cache entry into a cache's skip list. Updates * the associated length and size fields. * - * Return: N/A - * - * Programmer: John Mainzer, 5/10/04 - * *------------------------------------------------------------------------- */ -#ifdef H5C_DO_SANITY_CHECKS -#define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - \ - if ( (cache_ptr)->slist_enabled ) { \ - \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - assert( (entry_ptr)->in_slist ); \ - assert( (cache_ptr)->slist_ptr ); \ - assert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - assert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - assert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - assert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - assert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ - \ - if ( H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) \ - != (entry_ptr) ) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, \ - "can't delete entry from skip list") \ - \ - assert( (cache_ptr)->slist_len > 0 ); \ - if(!(during_flush)) \ - (cache_ptr)->slist_changed = TRUE; \ - (cache_ptr)->slist_len--; \ - assert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ - (cache_ptr)->slist_size -= (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - assert( (cache_ptr)->slist_ring_size[((entry_ptr)->ring)] >= \ - (entry_ptr)->size ); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size;\ - (cache_ptr)->slist_len_increase--; \ - (cache_ptr)->slist_size_increase -= (int64_t)((entry_ptr)->size); \ - (entry_ptr)->in_slist = FALSE; \ - \ - } else { /* slist disabled */ \ - \ - assert( (cache_ptr)->slist_len == 0 ); \ - assert( (cache_ptr)->slist_size == 0 ); \ - } \ -} /* H5C__REMOVE_ENTRY_FROM_SLIST */ - -#else /* H5C_DO_SANITY_CHECKS */ - -#define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - \ - if ( (cache_ptr)->slist_enabled ) { \ +#define H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, during_flush, fail_val) \ +do { \ + assert(cache_ptr); \ \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->in_slist ); \ - assert( (cache_ptr)->slist_ptr ); \ - assert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - assert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - assert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - assert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ + if((cache_ptr)->slist_enabled) { \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0); \ + assert((entry_ptr)->size > 0); \ + assert((entry_ptr)->in_slist); \ + assert((cache_ptr)->slist_ptr); \ + assert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + assert((entry_ptr)->ring < H5C_RING_NTYPES); \ + assert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ + (cache_ptr)->slist_len); \ + assert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ + (cache_ptr)->slist_size); \ + assert((cache_ptr)->slist_size >= (entry_ptr)->size); \ \ - if ( H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) \ - != (entry_ptr) ) \ - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, \ - "can't delete entry from skip list") \ + if(H5SL_remove((cache_ptr)->slist_ptr, &(entry_ptr)->addr) != (entry_ptr) ) \ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, (fail_val), "can't delete entry from skip list") \ \ - assert( (cache_ptr)->slist_len > 0 ); \ + assert((cache_ptr)->slist_len > 0); \ if(!(during_flush)) \ (cache_ptr)->slist_changed = TRUE; \ (cache_ptr)->slist_len--; \ - assert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ + assert((cache_ptr)->slist_size >= (entry_ptr)->size); \ (cache_ptr)->slist_size -= (entry_ptr)->size; \ - ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - assert( (cache_ptr)->slist_ring_size[((entry_ptr)->ring)] >= \ - (entry_ptr)->size ); \ + (cache_ptr)->slist_ring_len[(entry_ptr)->ring]--; \ + assert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] >= (entry_ptr)->size); \ ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size;\ + H5C__SLIST_REMOVE_ENTRY_SC(cache_ptr, entry_ptr); \ (entry_ptr)->in_slist = FALSE; \ - \ } else { /* slist disabled */ \ - \ - assert( (cache_ptr)->slist_len == 0 ); \ - assert( (cache_ptr)->slist_size == 0 ); \ + assert((cache_ptr)->slist_len == 0); \ + assert((cache_ptr)->slist_size == 0); \ } \ -} /* H5C__REMOVE_ENTRY_FROM_SLIST */ - -#endif /* H5C_DO_SANITY_CHECKS */ +} while (0) /* H5C__REMOVE_ENTRY_FROM_SLIST */ /*------------------------------------------------------------------------- * - * Function: H5C__UPDATE_SLIST_FOR_SIZE_CHANGE + * Macro: H5C__UPDATE_SLIST_FOR_SIZE_CHANGE * * Purpose: Update cache_ptr->slist_size for a change in the size of * and entry in the slist. * - * Return: N/A - * - * Programmer: John Mainzer, 9/07/05 - * *------------------------------------------------------------------------- */ -#ifdef H5C_DO_SANITY_CHECKS - #define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ +do { \ + assert(cache_ptr); \ \ - if ( (cache_ptr)->slist_enabled ) { \ - \ - assert( (old_size) > 0 ); \ - assert( (new_size) > 0 ); \ - assert( (old_size) <= (cache_ptr)->slist_size ); \ - assert( (cache_ptr)->slist_len > 0 ); \ - assert( ((cache_ptr)->slist_len > 1) || \ - ( (cache_ptr)->slist_size == (old_size) ) ); \ - assert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - assert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - assert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - assert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ + if((cache_ptr)->slist_enabled) { \ + assert((old_size) > 0); \ + assert((new_size) > 0); \ + assert((old_size) <= (cache_ptr)->slist_size); \ + assert((cache_ptr)->slist_len > 0); \ + assert((cache_ptr)->slist_len > 1 || \ + (cache_ptr)->slist_size == (old_size)); \ + assert((entry_ptr)->ring > H5C_RING_UNDEFINED); \ + assert((entry_ptr)->ring < H5C_RING_NTYPES); \ + assert((cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ + (cache_ptr)->slist_len); \ + assert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ + (cache_ptr)->slist_size); \ \ (cache_ptr)->slist_size -= (old_size); \ (cache_ptr)->slist_size += (new_size); \ \ - assert( (cache_ptr)->slist_ring_size[((entry_ptr)->ring)] \ - >= (old_size) ); \ - \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ + assert((cache_ptr)->slist_ring_size[(entry_ptr)->ring] >= (old_size)); \ \ - (cache_ptr)->slist_size_increase -= (int64_t)(old_size); \ - (cache_ptr)->slist_size_increase += (int64_t)(new_size); \ + (cache_ptr)->slist_ring_size[(entry_ptr)->ring] -= (old_size); \ + (cache_ptr)->slist_ring_size[(entry_ptr)->ring] += (new_size); \ \ - assert( (new_size) <= (cache_ptr)->slist_size ); \ - assert( ( (cache_ptr)->slist_len > 1 ) || \ - ( (cache_ptr)->slist_size == (new_size) ) ); \ + H5C__SLIST_UPDATE_FOR_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size); \ \ + assert((new_size) <= (cache_ptr)->slist_size); \ + assert((cache_ptr)->slist_len > 1 || \ + (cache_ptr)->slist_size == (new_size)); \ } else { /* slist disabled */ \ - \ - assert( (cache_ptr)->slist_len == 0 ); \ - assert( (cache_ptr)->slist_size == 0 ); \ + assert((cache_ptr)->slist_len == 0); \ + assert((cache_ptr)->slist_size == 0); \ } \ -} /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ - -#else /* H5C_DO_SANITY_CHECKS */ - -#define H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - \ - if ( (cache_ptr)->slist_enabled ) { \ - \ - assert( (old_size) > 0 ); \ - assert( (new_size) > 0 ); \ - assert( (old_size) <= (cache_ptr)->slist_size ); \ - assert( (cache_ptr)->slist_len > 0 ); \ - assert( ((cache_ptr)->slist_len > 1) || \ - ( (cache_ptr)->slist_size == (old_size) ) ); \ - assert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ - assert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ - assert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_len ); \ - assert( (cache_ptr)->slist_ring_size[(entry_ptr)->ring] <= \ - (cache_ptr)->slist_size ); \ - \ - (cache_ptr)->slist_size -= (old_size); \ - (cache_ptr)->slist_size += (new_size); \ - \ - assert( (cache_ptr)->slist_ring_size[((entry_ptr)->ring)] >= \ - (old_size) ); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ - ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) += (new_size); \ - \ - assert( (new_size) <= (cache_ptr)->slist_size ); \ - assert( ( (cache_ptr)->slist_len > 1 ) || \ - ( (cache_ptr)->slist_size == (new_size) ) ); \ - \ - } else { /* slist disabled */ \ - \ - assert( (cache_ptr)->slist_len == 0 ); \ - assert( (cache_ptr)->slist_size == 0 ); \ - } \ -} /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ - -#endif /* H5C_DO_SANITY_CHECKS */ +} while (0) /* H5C__UPDATE_SLIST_FOR_SIZE_CHANGE */ /************************************************************************** * - * Replacement policy update macros: + * Replacement policy update macros * **************************************************************************/ -/*------------------------------------------------------------------------- - * - * Macro: H5C__UPDATE_RP_FOR_EVICTION - * - * Purpose: Update the replacement policy data structures for an - * eviction of the specified cache entry. - * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 5/10/04 - * - *------------------------------------------------------------------------- - */ - #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( !((entry_ptr)->is_pinned) ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ +#define H5C__UPDATE_RP_FOR_EVICTION_CD_LRU(cache_ptr, entry_ptr, fail_val) \ +do { \ /* If the entry is clean when it is evicted, it should be on the \ * clean LRU list, if it was dirty, it should be on the dirty LRU list. \ * Remove it from the appropriate list according to the value of the \ * dirty flag. \ */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ + if((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_EVICTION_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_FLUSH_CD_LRU(cache_ptr, entry_ptr, fail_val) \ +do { \ + /* An entry being flushed or cleared, may not be dirty. 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. \ + */ \ + if((entry_ptr)->is_dirty) { \ H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ @@ -1720,73 +1233,226 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->cLRU_list_size, (fail_val)) \ } \ \ -} /* H5C__UPDATE_RP_FOR_EVICTION */ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ +} while (0) /* H5C__UPDATE_RP_FOR_FLUSH_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_INSERT_APPEND_CD_LRU(cache_ptr, entry_ptr, fail_val) \ +do { \ + /* Insert the entry at the _tail_ of the clean or dirty LRU list as \ + * appropriate. \ + */ \ + if((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)); \ + } else { \ + H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)); \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_INSERT_APPEND_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_INSERTION_CD_LRU(cache_ptr, entry_ptr, fail_val) \ +do { \ + /* Insert the entry at the head of the clean or dirty LRU list as \ + * appropriate. \ + */ \ + if((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ +} while(0) /* H5C__UPDATE_RP_FOR_INSERTION_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_PROTECT_CD_LRU(cache_ptr, entry_ptr, fail_val) \ +{ \ + /* Remove the entry from the clean or dirty LRU list as appropriate */ \ + if((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_PROTECT_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_MOVE_CD_LRU(cache_ptr, entry_ptr, was_dirty, fail_val) \ +do { \ + /* Remove the entry from either the clean or dirty LRU list as \ + * indicated by the was_dirty parameter \ + */ \ + if(was_dirty) { \ + H5C__AUX_DLL_REMOVE((entry_ptr), \ + (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)); \ + \ + } else { \ + H5C__AUX_DLL_REMOVE((entry_ptr), \ + (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)); \ + } \ + \ + /* Insert the entry at the head of either the clean or dirty \ + * LRU list as appropriate. \ + */ \ + if((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)); \ + } else { \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)); \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_MOVE_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE_CD_LRU(cache_ptr, entry_ptr, new_size, fail_val) \ +do { \ + /* Update the size of the clean or dirty LRU list as \ + * appropriate. \ + */ \ + 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), (fail_val)) \ + \ + } else { \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, \ + (entry_ptr)->size, \ + (new_size), (fail_val)) \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_SIZE_CHANGE_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_UNPIN_CD_LRU(cache_ptr, entry_ptr, fail_val) \ +do { \ + /* Insert the entry at the head of either the clean \ + * or dirty LRU list as appropriate. \ + */ \ + if((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_PREPEND((entry_ptr), \ + (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_UNPIN_CD_LRU() */ + +#define H5C__UPDATE_RP_FOR_UNPROTECT_CD_LRU(cache_ptr, entry_ptr, fail_val) \ +do { \ + /* Insert the entry at the head of either the clean or \ + * dirty LRU list as appropriate. \ + */ \ + if((entry_ptr)->is_dirty) { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_tail_ptr, \ + (cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, (fail_val)) \ + } else { \ + H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_tail_ptr, \ + (cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, (fail_val)) \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_UNPROTECT_CD_LRU() */ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ +#define H5C__UPDATE_RP_FOR_EVICTION_CD_LRU(cache_ptr, entry_ptr, fail_val) +#define H5C__UPDATE_RP_FOR_FLUSH_CD_LRU(cache_ptr, entry_ptr, fail_val) +#define H5C__UPDATE_RP_FOR_INSERT_APPEND_CD_LRU(cache_ptr, entry_ptr, fail_val) +#define H5C__UPDATE_RP_FOR_INSERTION_CD_LRU(cache_ptr, entry_ptr, fail_val) +#define H5C__UPDATE_RP_FOR_PROTECT_CD_LRU(cache_ptr, entry_ptr, fail_val) +#define H5C__UPDATE_RP_FOR_MOVE_CD_LRU(cache_ptr, entry_ptr, was_dirty, fail_val) +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE_CD_LRU(cache_ptr, entry_ptr, new_size, fail_val) +#define H5C__UPDATE_RP_FOR_UNPIN_CD_LRU(cache_ptr, entry_ptr, fail_val) +#define H5C__UPDATE_RP_FOR_UNPROTECT_CD_LRU(cache_ptr, entry_ptr, fail_val) + +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + +/*------------------------------------------------------------------------- + * + * Macro: H5C__UPDATE_RP_FOR_EVICTION + * + * Purpose: Update the replacement policy data structures for an + * eviction of the specified cache entry. + * + *------------------------------------------------------------------------- + */ + #define H5C__UPDATE_RP_FOR_EVICTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( !((entry_ptr)->is_pinned) ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_protected); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0); \ + assert(!(entry_ptr)->is_pinned); \ + assert((entry_ptr)->size > 0); \ \ + /* Remove the entry from the LRU list */ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ -} /* H5C__UPDATE_RP_FOR_EVICTION */ - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /* Remove the entry from the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_EVICTION_CD_LRU(cache_ptr, entry_ptr, fail_val); \ +} while (0) /* H5C__UPDATE_RP_FOR_EVICTION */ /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_FLUSH + * Macro: H5C__UPDATE_RP_FOR_FLUSH * * Purpose: Update the replacement policy data structures for a flush - * of the specified cache entry. - * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. - * - * Return: N/A - * - * Programmer: John Mainzer, 5/6/04 + * of the specified cache entry. * *------------------------------------------------------------------------- */ -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - #define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ((entry_ptr)->is_pinned) ) { \ - \ - /* modified LRU specific code */ \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_protected); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0); \ + assert((entry_ptr)->size > 0); \ \ - /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ + if(!(entry_ptr)->is_pinned) { \ + /* Remove the entry from its location in the LRU list \ + * and re-insert it at the head of the list. \ */ \ - \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ (cache_ptr)->LRU_list_len, \ @@ -1797,893 +1463,310 @@ if ( ( (cache_ptr)->index_size != \ (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. \ - * \ - * 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. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_FLUSH */ - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__UPDATE_RP_FOR_FLUSH(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ((entry_ptr)->is_pinned) ) { \ - \ - /* 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_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_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_FLUSH_CD_LRU(cache_ptr, entry_ptr, fail_val); \ } \ -} /* H5C__UPDATE_RP_FOR_FLUSH */ - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ +} while (0) /* H5C__UPDATE_RP_FOR_FLUSH */ /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_INSERT_APPEND + * Macro: H5C__UPDATE_RP_FOR_INSERT_APPEND * * Purpose: Update the replacement policy data structures for an - * insertion of the specified cache entry. - * - * Unlike H5C__UPDATE_RP_FOR_INSERTION below, mark the - * new entry as the LEAST recently used entry, not the - * most recently used. - * - * For now at least, this macro should only be used in - * the reconstruction of the metadata cache from a cache - * image block. + * insertion of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. - * - * Return: N/A - * - * Programmer: John Mainzer, 8/15/15 + * Unlike H5C__UPDATE_RP_FOR_INSERTION below, insert a non-pinned + * new entry as the LEAST recently used entry, not the + * most recently used. * *------------------------------------------------------------------------- */ -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - #define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_protected); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0 ); \ + assert((entry_ptr)->size > 0 ); \ \ + if((entry_ptr)->is_pinned) { \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ (cache_ptr)->pel_tail_ptr, \ (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ - \ } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the tail of the LRU list. */ \ - \ + /* Insert the entry at the tail of the LRU list. */ \ H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (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 \ - * appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_APPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ -} - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the tail of the LRU list. */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - - -/*------------------------------------------------------------------------- - * - * Macro: H5C__UPDATE_RP_FOR_INSERTION - * - * Purpose: Update the replacement policy data structures for an - * insertion of the specified cache entry. - * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. - * - * Return: N/A - * - * Programmer: John Mainzer, 5/17/04 - * - *------------------------------------------------------------------------- - */ - -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - -#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (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 \ - * appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - } else { \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ -} - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ -} - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - - -/*------------------------------------------------------------------------- - * - * Macro: H5C__UPDATE_RP_FOR_PROTECT - * - * Purpose: Update the replacement policy data structures for a - * protect of the specified cache entry. - * - * To do this, unlink the specified entry from any data - * structures used by the replacement policy, and add the - * entry to the protected list. - * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. - * - * Return: N/A - * - * Programmer: John Mainzer, 5/17/04 - * - *------------------------------------------------------------------------- - */ - -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - -#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (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_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, remove the entry from the clean or dirty LRU list \ - * as appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - /* Regardless of the replacement policy, or whether the entry is \ - * pinned, now add the entry to the protected list. \ - */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ - (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, \ - (cache_ptr)->pl_size, (fail_val)) \ -} /* H5C__UPDATE_RP_FOR_PROTECT */ - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (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_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list. */ \ - \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - } \ - \ - /* Regardless of the replacement policy, or whether the entry is \ - * pinned, now add the entry to the protected list. \ - */ \ - \ - H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ - (cache_ptr)->pl_tail_ptr, \ - (cache_ptr)->pl_len, \ - (cache_ptr)->pl_size, (fail_val)) \ -} /* H5C__UPDATE_RP_FOR_PROTECT */ - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_INSERT_APPEND_CD_LRU(cache_ptr, entry_ptr, fail_val); \ + } \ +} while (0) /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_MOVE - * - * Purpose: Update the replacement policy data structures for a - * move of the specified cache entry. - * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. - * - * Return: N/A + * Macro: H5C__UPDATE_RP_FOR_INSERTION * - * Programmer: John Mainzer, 5/17/04 + * Purpose: Update the replacement policy data structures for an + * insertion of the specified cache entry. * *------------------------------------------------------------------------- */ -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - -#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( ((entry_ptr)->is_protected ) ) ) {\ +#define H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, fail_val) \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_protected); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0); \ + assert((entry_ptr)->size > 0); \ \ - /* 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_size, (fail_val)) \ + if((entry_ptr)->is_pinned) { \ + H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, (fail_val)) \ \ + } else { \ + /* Insert the entry at the head of the LRU list. */ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ - /* remove the entry from either the clean or dirty LUR list as \ - * indicated by the was_dirty parameter \ - */ \ - if ( was_dirty ) { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ - } \ - \ - /* insert the entry at the head of either the clean or dirty \ - * LRU list as appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_MOVE */ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_INSERTION_CD_LRU(cache_ptr, entry_ptr, fail_val); \ + } \ +} while (0) -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + +/*------------------------------------------------------------------------- + * + * Macro: H5C__UPDATE_RP_FOR_PROTECT + * + * Purpose: Update the replacement policy data structures for a + * protect of the specified cache entry. + * + * To do this, unlink the specified entry from any data + * structures used by the replacement policy (or the pinned list, + * which is outside of the replacement policy), and add the + * entry to the protected list. + * + *------------------------------------------------------------------------- + */ + +#define H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, entry_ptr, fail_val) \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_protected); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0); \ + assert((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_size, (fail_val)) \ + } else { \ + /* Remove the entry from the LRU list. */ \ + H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ + (cache_ptr)->LRU_tail_ptr, \ + (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, (fail_val)) \ + \ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_PROTECT_CD_LRU(cache_ptr, entry_ptr, fail_val); \ + } \ + \ + /* Regardless of whether the entry is pinned, add it to the protected \ + * list. \ + */ \ + H5C__DLL_APPEND((entry_ptr), (cache_ptr)->pl_head_ptr, \ + (cache_ptr)->pl_tail_ptr, \ + (cache_ptr)->pl_len, \ + (cache_ptr)->pl_size, (fail_val)) \ +} while (0) /* H5C__UPDATE_RP_FOR_PROTECT */ + + +/*------------------------------------------------------------------------- + * + * Macro: H5C__UPDATE_RP_FOR_MOVE + * + * Purpose: Update the replacement policy data structures for a + * move of the specified cache entry. + * + *------------------------------------------------------------------------- + */ #define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( ((entry_ptr)->is_protected ) ) ) {\ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0); \ + assert((entry_ptr)->size > 0); \ \ - /* modified LRU specific code */ \ - \ - /* remove the entry from the LRU list, and re-insert it at the head. \ + if(!(entry_ptr)->is_pinned && !(entry_ptr)->is_protected) { \ + /* 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_size, (fail_val)) \ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (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_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_size, (fail_val)) \ \ - /* End modified LRU specific code. */ \ - } \ -} /* H5C__UPDATE_RP_FOR_MOVE */ - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_MOVE_CD_LRU(cache_ptr, entry_ptr, was_dirty, fail_val); \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_MOVE */ /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_SIZE_CHANGE + * Macro: H5C__UPDATE_RP_FOR_SIZE_CHANGE * * Purpose: Update the replacement policy data structures for a - * size change of the specified cache entry. - * - * To do this, determine if the entry is pinned. If it is, - * update the size of the pinned entry list. + * size change of the specified cache entry. * - * If it isn't pinned, the entry must handled by the - * replacement policy. Update the appropriate replacement - * policy data structures. + * To do this, determine if the entry is pinned. If it is, + * update the size of the pinned entry list. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. + * If it isn't pinned, the entry must handled by the + * replacement policy. Update the appropriate replacement + * policy data structures. * - * Return: N/A - * - * Programmer: John Mainzer, 8/23/06 + * If the entry is accessed with collective operations for + * parallel I/O, update that list. * *------------------------------------------------------------------------- */ -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS +#ifdef H5_HAVE_PARALLEL + +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE_COLL(cache_ptr, entry_ptr, new_size, fail_val) \ +do { \ + 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), (fail_val)); \ + \ + } \ +} while (0) /* H5C__UPDATE_RP_FOR_SIZE_CHANGE_COLL() */ + +#else /* H5_HAVE_PARALLEL */ + +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE_COLL(cache_ptr, entry_ptr, new_size, fail_val) + +#endif /* H5_HAVE_PARALLEL */ #define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - assert( new_size > 0 ); \ - \ - 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), (fail_val)); \ - \ - } \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_protected); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0); \ + assert((entry_ptr)->size > 0 ); \ + assert(new_size > 0 ); \ \ - if ( (entry_ptr)->is_pinned ) { \ + /* Maintain the collective access list, if enabled */ \ + H5C__UPDATE_RP_FOR_SIZE_CHANGE_COLL(cache_ptr, entry_ptr, new_size, fail_val); \ \ + if((entry_ptr)->is_pinned) { \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ (cache_ptr)->pel_size, \ (entry_ptr)->size, \ - (new_size), (fail_val)); \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* 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), (fail_val)); \ - \ - /* Similarly, update the size of the clean or dirty LRU list as \ - * 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), (fail_val)); \ - \ - } else { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (entry_ptr)->size, \ - (new_size), (fail_val)); \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ -} /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->size > 0 ); \ - assert( new_size > 0 ); \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, \ - (entry_ptr)->size, \ - (new_size), (fail_val)); \ - \ + (new_size), (fail_val)) \ } else { \ - \ - /* modified LRU specific code */ \ - \ /* 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), (fail_val)); \ + (new_size), (fail_val)) \ \ - /* End modified LRU specific code. */ \ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_SIZE_CHANGE_CD_LRU(cache_ptr, entry_ptr, new_size, fail_val); \ } \ - \ -} /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ +} while (0) /* H5C__UPDATE_RP_FOR_SIZE_CHANGE */ /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_UNPIN + * Macro: H5C__UPDATE_RP_FOR_UNPIN * * Purpose: Update the replacement policy data structures for an - * unpin of the specified cache entry. - * - * To do this, unlink the specified entry from the protected - * entry list, and re-insert it in the data structures used - * by the current replacement policy. + * unpin of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the macro - * should switch on the current policy and act accordingly. - * - * Return: N/A - * - * Programmer: John Mainzer, 3/22/06 + * To do this, unlink the specified entry from the pinned + * entry list, and re-insert it in the data structures used + * by the current replacement policy. * *------------------------------------------------------------------------- */ -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - #define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->is_pinned); \ - assert( (entry_ptr)->size > 0 ); \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert(!(entry_ptr)->is_protected); \ + assert(!(entry_ptr)->is_read_only); \ + assert((entry_ptr)->ro_ref_count == 0 ); \ + assert((entry_ptr)->is_pinned); \ + assert((entry_ptr)->size > 0); \ \ /* Regardless of the replacement policy, remove the entry from the \ * pinned entry list. \ */ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ (cache_ptr)->pel_tail_ptr, (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ + (cache_ptr)->pel_size, (fail_val)); \ \ + /* Insert the entry at the head of the LRU list. */ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, insert the entry at the head of either the clean \ - * or dirty LRU list as appropriate. \ - */ \ + (cache_ptr)->LRU_list_size, (fail_val)); \ \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - \ -} /* H5C__UPDATE_RP_FOR_UNPIN */ - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__UPDATE_RP_FOR_UNPIN(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( !((entry_ptr)->is_protected) ); \ - assert( !((entry_ptr)->is_read_only) ); \ - assert( ((entry_ptr)->ro_ref_count) == 0 ); \ - assert( (entry_ptr)->is_pinned); \ - assert( (entry_ptr)->size > 0 ); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * pinned entry list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* End modified LRU specific code. */ \ - \ -} /* H5C__UPDATE_RP_FOR_UNPIN */ - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_UNPIN_CD_LRU(cache_ptr, entry_ptr, fail_val); \ +} while(0) /* H5C__UPDATE_RP_FOR_UNPIN */ /*------------------------------------------------------------------------- * - * Macro: H5C__UPDATE_RP_FOR_UNPROTECT + * Macro: H5C__UPDATE_RP_FOR_UNPROTECT * * Purpose: Update the replacement policy data structures for an - * unprotect of the specified cache entry. - * - * To do this, unlink the specified entry from the protected - * list, and re-insert it in the data structures used by the - * current replacement policy. + * unprotect of the specified cache entry. * - * At present, we only support the modified LRU policy, so - * this function deals with that case unconditionally. If - * we ever support other replacement policies, the function - * should switch on the current policy and act accordingly. - * - * Return: N/A - * - * Programmer: John Mainzer, 5/19/04 + * To do this, unlink the specified entry from the protected + * list, and re-insert it in the data structures used by the + * current replacement policy. * *------------------------------------------------------------------------- */ -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - -#define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( (entry_ptr)->is_protected); \ - assert( (entry_ptr)->size > 0 ); \ - \ - /* Regardless of the replacement policy, remove the entry from the \ - * protected list. \ - */ \ - H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pl_head_ptr, \ - (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ - (cache_ptr)->pl_size, (fail_val)) \ - \ - if ( (entry_ptr)->is_pinned ) { \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, (fail_val)) \ - \ - } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ - H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ - (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, (fail_val)) \ - \ - /* Similarly, insert the entry at the head of either the clean or \ - * dirty LRU list as appropriate. \ - */ \ - \ - if ( (entry_ptr)->is_dirty ) { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->dLRU_head_ptr, \ - (cache_ptr)->dLRU_tail_ptr, \ - (cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, (fail_val)) \ - \ - } else { \ - \ - H5C__AUX_DLL_PREPEND((entry_ptr), (cache_ptr)->cLRU_head_ptr, \ - (cache_ptr)->cLRU_tail_ptr, \ - (cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, (fail_val)) \ - } \ - \ - /* End modified LRU specific code. */ \ - } \ - \ -} /* H5C__UPDATE_RP_FOR_UNPROTECT */ - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - #define H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - assert( (entry_ptr)->is_protected); \ - assert( (entry_ptr)->size > 0 ); \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ + assert((entry_ptr)->is_protected); \ + assert((entry_ptr)->size > 0); \ \ /* Regardless of the replacement policy, remove the entry from the \ * protected list. \ @@ -2692,265 +1775,103 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->pl_tail_ptr, (cache_ptr)->pl_len, \ (cache_ptr)->pl_size, (fail_val)) \ \ - if ( (entry_ptr)->is_pinned ) { \ - \ + if((entry_ptr)->is_pinned) { \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->pel_head_ptr, \ (cache_ptr)->pel_tail_ptr, \ (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ - \ } else { \ - \ - /* modified LRU specific code */ \ - \ - /* insert the entry at the head of the LRU list. */ \ - \ + /* Insert the entry at the head of the LRU list. */ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ - /* End modified LRU specific code. */ \ + /* Maintain the clean & dirty LRU lists, if enabled */ \ + H5C__UPDATE_RP_FOR_UNPROTECT_CD_LRU(cache_ptr, entry_ptr, fail_val); \ } \ -} /* H5C__UPDATE_RP_FOR_UNPROTECT */ +} while (0) /* H5C__UPDATE_RP_FOR_UNPROTECT */ -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL -#ifdef H5C_DO_SANITY_CHECKS - -#define H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( (hd_ptr) == NULL ) || \ - ( (tail_ptr) == NULL ) || \ - ( (entry_ptr) == NULL ) || \ - ( (len) <= 0 ) || \ - ( (list_size) < (entry_ptr)->size ) || \ - ( ( (list_size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ - ( ( (entry_ptr)->coll_prev == NULL ) && ( (hd_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 ) && \ - ( (entry_ptr)->coll_prev == NULL ) && \ - ( (list_size) == (entry_ptr)->size ) \ - ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "coll DLL pre remove SC failed") \ -} - -#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ -if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (head_ptr) != (tail_ptr) ) \ - ) || \ - ( (len) < 0 ) || \ - ( (list_size) < 0 ) || \ - ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (head_ptr) == NULL ) || ( (head_ptr)->coll_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->coll_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "COLL DLL sanity check failed")\ -} - -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val)\ -if ( ( (entry_ptr) == NULL ) || \ - ( (entry_ptr)->coll_next != NULL ) || \ - ( (entry_ptr)->coll_prev != NULL ) || \ - ( ( ( (hd_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ - ( (hd_ptr) != (tail_ptr) ) \ - ) || \ - ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (list_size) ) \ - ) \ - ) || \ - ( ( (len) >= 1 ) && \ - ( ( (hd_ptr) == NULL ) || ( (hd_ptr)->coll_prev != NULL ) || \ - ( (tail_ptr) == NULL ) || ( (tail_ptr)->coll_next != NULL ) \ - ) \ - ) \ - ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "COLL DLL pre insert SC failed") \ -} - -#else /* H5C_DO_SANITY_CHECKS */ - -#define H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val) - -#endif /* H5C_DO_SANITY_CHECKS */ - - -#define H5C__COLL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ - fail_val) \ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (tail_ptr)->coll_next = (entry_ptr); \ - (entry_ptr)->coll_prev = (tail_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (list_size) += entry_ptr->size; \ -} /* H5C__COLL_DLL_APPEND() */ - -#define H5C__COLL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val)\ - if ( (head_ptr) == NULL ) \ - { \ - (head_ptr) = (entry_ptr); \ - (tail_ptr) = (entry_ptr); \ - } \ - else \ - { \ - (head_ptr)->coll_prev = (entry_ptr); \ - (entry_ptr)->coll_next = (head_ptr); \ - (head_ptr) = (entry_ptr); \ - } \ - (len)++; \ - (list_size) += entry_ptr->size; \ -} /* H5C__COLL_DLL_PREPEND() */ - -#define H5C__COLL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ -{ \ - H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val)\ - { \ - if ( (head_ptr) == (entry_ptr) ) \ - { \ - (head_ptr) = (entry_ptr)->coll_next; \ - if ( (head_ptr) != NULL ) \ - (head_ptr)->coll_prev = NULL; \ - } \ - else \ - { \ - (entry_ptr)->coll_prev->coll_next = (entry_ptr)->coll_next; \ - } \ - if ( (tail_ptr) == (entry_ptr) ) \ - { \ - (tail_ptr) = (entry_ptr)->coll_prev; \ - if ( (tail_ptr) != NULL ) \ - (tail_ptr)->coll_next = NULL; \ - } \ - else \ - (entry_ptr)->coll_next->coll_prev = (entry_ptr)->coll_prev; \ - entry_ptr->coll_next = NULL; \ - entry_ptr->coll_prev = NULL; \ - (len)--; \ - (list_size) -= entry_ptr->size; \ - } \ -} /* H5C__COLL_DLL_REMOVE() */ +/* Macros that modify the "collective I/O" LRU list */ +#define H5C__COLL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_PREPEND(entry_ptr, coll_next, coll_prev, head_ptr, tail_ptr, len, list_size, fail_val) +#define H5C__COLL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ + H5C__GEN_DLL_REMOVE(entry_ptr, coll_next, coll_prev, head_ptr, tail_ptr, len, list_size, fail_val) /*------------------------------------------------------------------------- * - * Macro: H5C__INSERT_IN_COLL_LIST + * Macro: H5C__INSERT_IN_COLL_LIST * * Purpose: Insert entry into collective entries list * - * Return: N/A - * - * Programmer: Mohamad Chaarawi - * *------------------------------------------------------------------------- */ #define H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - \ - /* insert the entry at the head of the list. */ \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ \ + /* Insert the entry at the head of the list. */ \ H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, \ (cache_ptr)->coll_tail_ptr, \ (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ - \ -} /* H5C__INSERT_IN_COLL_LIST */ + (cache_ptr)->coll_list_size, (fail_val)) \ +} while (0) /* H5C__INSERT_IN_COLL_LIST */ /*------------------------------------------------------------------------- * - * Macro: H5C__REMOVE_FROM_COLL_LIST + * Macro: H5C__REMOVE_FROM_COLL_LIST * * Purpose: Remove entry from collective entries list * - * Return: N/A - * - * Programmer: Mohamad Chaarawi - * *------------------------------------------------------------------------- */ #define H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert( (cache_ptr) ); \ - assert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - assert( (entry_ptr) ); \ - \ - /* remove the entry from the list. */ \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ \ + /* Remove the entry from the list. */ \ H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, \ (cache_ptr)->coll_tail_ptr, \ (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ - \ -} /* H5C__REMOVE_FROM_COLL_LIST */ + (cache_ptr)->coll_list_size, (fail_val)) \ +} while (0) /* H5C__REMOVE_FROM_COLL_LIST */ /*------------------------------------------------------------------------- * - * Macro: H5C__MOVE_TO_TOP_IN_COLL_LIST + * Macro: H5C__MOVE_TO_TOP_IN_COLL_LIST * * Purpose: Update entry position in collective entries list * - * Return: N/A - * - * Programmer: Mohamad Chaarawi - * *------------------------------------------------------------------------- */ #define H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ -{ \ - assert((cache_ptr)); \ - assert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ - assert((entry_ptr)); \ +do { \ + assert(cache_ptr); \ + assert(entry_ptr); \ \ /* Remove entry and insert at the head of the list. */ \ H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, \ (cache_ptr)->coll_tail_ptr, \ (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ + (cache_ptr)->coll_list_size, (fail_val)) \ \ H5C__COLL_DLL_PREPEND((entry_ptr), (cache_ptr)->coll_head_ptr, \ (cache_ptr)->coll_tail_ptr, \ (cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (fail_val)) \ + (cache_ptr)->coll_list_size, (fail_val)) \ \ -} /* H5C__MOVE_TO_TOP_IN_COLL_LIST */ +} while (0) /* H5C__MOVE_TO_TOP_IN_COLL_LIST */ #endif /* H5_HAVE_PARALLEL */ @@ -2993,7 +1914,7 @@ typedef struct H5C_tag_info_t { hbool_t corked; /* Whether this object is corked */ /* Hash table fields */ - UT_hash_handle hh; /* Hash table handle (must be LAST) */ + UT_hash_handle hh; /* Hash table handle (must be LAST) */ } H5C_tag_info_t; @@ -3001,7 +1922,7 @@ typedef struct H5C_tag_info_t { * * structure H5C_t * - * Catchall structure for all variables specific to an instance of the cache. + * Structure for all information specific to an instance of the cache. * * While the cache was designed with multiple replacement policies in mind, * at present only a modified form of LRU is supported. @@ -3010,14 +1931,9 @@ typedef struct H5C_tag_info_t { * advantages of flushing entries in increasing address order, a skip list * is used to track dirty entries. * - * magic: Unsigned 32 bit integer always set to H5C__H5C_T_MAGIC. - * This field is used to validate pointers to instances of - * H5C_t. - * - * flush_in_progress: Boolean flag indicating whether a flush is in - * progress. + * flush_in_progress: Boolean flag indicating whether a flush is in progress. * - * log_info: Information used by the MDC logging functionality. + * log_info: Information used by the cache logging functionality. * Described in H5Clog.h. * * aux_ptr: Pointer to void used to allow wrapper code to associate @@ -3026,29 +1942,27 @@ typedef struct H5C_tag_info_t { * * max_type_id: Integer field containing the maximum type id number assigned * to a type of entry in the cache. All type ids from 0 to - * max_type_id inclusive must be defined. The names of the - * types are stored in the type_name_table discussed below, and - * indexed by the ids. + * max_type_id inclusive must be defined. * * class_table_ptr: Pointer to an array of H5C_class_t of length - * max_type_id + 1. Entry classes for the cache. + * max_type_id + 1. Entry classes for the cache. * * max_cache_size: Nominal maximum number of bytes that may be stored in the - * cache. This value should be viewed as a soft limit, as the - * cache can exceed this value under the following circumstances: + * cache. This value should be viewed as a soft limit, as the + * cache can exceed this value under the following circumstances: * - * a) All entries in the cache are protected, and the cache is - * asked to insert a new entry. In this case the new entry - * will be created. If this causes the cache to exceed - * max_cache_size, it will do so. The cache will attempt - * to reduce its size as entries are unprotected. + * a) All entries in the cache are protected, and the cache is + * asked to insert a new entry. In this case the new entry + * will be created. If this causes the cache to exceed + * max_cache_size, it will do so. The cache will attempt + * to reduce its size as entries are unprotected. * - * b) When running in parallel mode, the cache may not be + * b) When running in parallel mode, the cache may not be * permitted to flush a dirty entry in response to a read. * If there are no clean entries available to evict, the * cache will exceed its maximum size. Again the cache - * will attempt to reduce its size to the max_cache_size - * limit on the next cache write. + * will attempt to reduce its size to the max_cache_size + * limit on the next cache write. * * c) When an entry increases in size, the cache may exceed * the max_cache_size limit until the next time the cache @@ -3059,16 +1973,15 @@ typedef struct H5C_tag_info_t { * field is set to true. * * min_clean_size: Nominal minimum number of clean bytes in the cache. - * The cache attempts to maintain this number of bytes of - * clean data so as to avoid case b) above. Again, this is - * a soft limit. + * The cache attempts to maintain this number of bytes of clean + * data so as to avoid case b) above. Again, this is a soft limit. * * close_warning_received: Boolean flag indicating that a file closing * warning has been received. * * - * In addition to the call back functions required for each entry, the - * cache requires the following call back functions for this instance of + * In addition to the callback functions required for each entry's class, + * the cache requires the following callback functions for an instance of * the cache as a whole: * * check_write_permitted: In certain applications, the cache may not @@ -3103,7 +2016,7 @@ typedef struct H5C_tag_info_t { * following fields support that index. * * We sometimes need to visit all entries in the cache, they are stored in - * the index list. + * an index list. * * The index list is maintained by the same macros that maintain the * index, and must have the same length and size as the index proper. @@ -3112,13 +2025,13 @@ typedef struct H5C_tag_info_t { * the cache. * * index_size: Number of bytes of cache entries currently stored in the - * hash table used to index the cache. + * hash table used to index the cache. * - * This value should not be mistaken for footprint of the - * cache in memory. The average cache entry is small, and - * the cache has a considerable overhead. Multiplying the - * index_size by three should yield a conservative estimate - * of the cache's memory footprint. + * This value should not be mistaken for footprint of the + * cache in memory. The average cache entry is small, and + * the cache has a considerable overhead. Multiplying the + * index_size by three should yield a conservative estimate + * of the cache's memory footprint. * * index_ring_len: Array of integer of length H5C_RING_NTYPES used to * maintain a count of entries in the index by ring. Note @@ -3131,7 +2044,7 @@ typedef struct H5C_tag_info_t { * equal the value stored in index_size above. * * clean_index_size: Number of bytes of clean entries currently stored in - * the hash table. Note that the index_size field (above) + * the hash table. Note that the index_size field (above) * is also the sum of the sizes of all entries in the cache. * Thus we should have the invariant that clean_index_size + * dirty_index_size == index_size. @@ -3148,7 +2061,7 @@ typedef struct H5C_tag_info_t { * must equal the value stored in clean_index_size above. * * dirty_index_size: Number of bytes of dirty entries currently stored in - * the hash table. Note that the index_size field (above) + * the hash table. Note that the index_size field (above) * is also the sum of the sizes of all entries in the cache. * Thus we should have the invariant that clean_index_size + * dirty_index_size == index_size. @@ -3158,7 +2071,7 @@ typedef struct H5C_tag_info_t { * index by ring. Note that the sum of all cells in this array * must equal the value stored in dirty_index_size above. * - * index: Array of pointer to H5C_cache_entry_t of size + * index: Array of pointers to H5C_cache_entry_t of size * H5C__HASH_TABLE_LEN. At present, this value is a power * of two, not the usual prime number. * @@ -3173,7 +2086,7 @@ typedef struct H5C_tag_info_t { * changing the H5C__HASH_FCN macro and the deletion of the * H5C__HASH_MASK #define. No other changes should be required. * - * il_len: Number of entries on the index list. + * il_len: Number of entries on the index list. * * This must always be equal to index_len. As such, this * field is redundant. However, the existing linked list @@ -3181,7 +2094,7 @@ typedef struct H5C_tag_info_t { * this field exists primarily to avoid adding complexity to * these macros. * - * il_size: Number of bytes of cache entries currently stored in the + * il_size: Number of bytes of cache entries currently stored in the * index list. * * This must always be equal to index_size. As such, this @@ -3190,17 +2103,17 @@ typedef struct H5C_tag_info_t { * this field exists primarily to avoid adding complexity to * these macros. * - * il_head: Pointer to the head of the doubly linked list of entries in - * the index list. Note that cache entries on this list are + * il_head: Pointer to the head of the doubly linked list of entries in + * the index list. Note that cache entries on this list are * linked by their il_next and il_prev fields. * - * This field is NULL if the index is empty. + * This field is NULL if the index is empty. * - * il_tail: Pointer to the tail of the doubly linked list of entries in - * the index list. Note that cache entries on this list are - * linked by their il_next and il_prev fields. + * il_tail: Pointer to the tail of the doubly linked list of entries in + * the index list. Note that cache entries on this list are + * linked by their il_next and il_prev fields. * - * This field is NULL if the index is empty. + * This field is NULL if the index is empty. * * * It is possible that an entry may be removed from the cache as the result @@ -3212,7 +2125,7 @@ typedef struct H5C_tag_info_t { * * The following fields are maintained to facilitate this. * - * entries_removed_counter: Counter that is incremented each time an + * entries_removed_counter: Counter that is incremented each time an * entry is removed from the cache by any means (eviction, * expungement, or take ownership at this point in time). * Functions that perform scans on lists may set this field @@ -3220,7 +2133,7 @@ typedef struct H5C_tag_info_t { * Unexpected changes to the counter indicate that an entry * was removed from the cache as a side effect of the flush. * - * last_entry_removed_ptr: Pointer to the instance of H5C_cache_entry_t + * last_entry_removed_ptr: Pointer to the instance of H5C_cache_entry_t * which contained the last entry to be removed from the cache, * or NULL if there either is no such entry, or if a function * performing a scan of a list has set this field to NULL prior @@ -3230,8 +2143,7 @@ typedef struct H5C_tag_info_t { * maintained to allow functions that perform scans of lists * to compare this pointer with their pointers to next, thus * allowing them to avoid unnecessary restarts of scans if the - * pointers don't match, and if entries_removed_counter is - * one. + * pointers don't match, and if entries_removed_counter is one. * * entry_watched_for_removal: Pointer to an instance of H5C_cache_entry_t * which contains the 'next' entry for an iteration. Removing @@ -3266,50 +2178,47 @@ typedef struct H5C_tag_info_t { * the next flush or close. * * slist_enabled: Boolean flag used to control operation of the skip - * list. If this filed is FALSE, operations on the - * slist are no-ops, and the slist must be empty. If - * it is TRUE, operations on the slist proceed as usual, - * and all dirty entries in the metadata cache must be - * listed in the slist. + * list. If this filed is FALSE, operations on the slist are + * no-ops, and the slist must be empty. If it is TRUE, + * operations on the skip list proceed as usual, and all dirty + * entries in the metadata cache must be listed in the skip list. * * slist_changed: Boolean flag used to indicate whether the contents of - * the slist has changed since the last time this flag was + * the skip list has changed since the last time this flag was * reset. This is used in the cache flush code to detect * conditions in which pre-serialize or serialize callbacks - * have modified the slist -- which obliges us to restart - * the scan of the slist from the beginning. + * have modified the skip list -- which obliges us to restart + * the scan of the skip list from the beginning. * - * slist_len: Number of entries currently in the skip list - * used to maintain a sorted list of dirty entries in the - * cache. + * slist_len: Number of entries currently in the skip list. Used to + * maintain a sorted list of dirty entries in the cache. * - * slist_size: Number of bytes of cache entries currently stored in the - * skip list used to maintain a sorted list of - * dirty entries in the cache. + * slist_size: Number of bytes of cache entries currently stored in the + * skip list used to maintain a sorted list of dirty entries in + * the cache. * * slist_ring_len: Array of integer of length H5C_RING_NTYPES used to - * maintain a count of entries in the slist by ring. Note + * maintain a count of entries in the skip list by ring. Note * that the sum of all the cells in this array must equal * the value stored in slist_len above. * * slist_ring_size: Array of size_t of length H5C_RING_NTYPES used to - * maintain the sum of the sizes of all entries in the - * slist by ring. Note that the sum of all cells in this - * array must equal the value stored in slist_size above. + * maintain the sum of the sizes of all entries in the skip list + * by ring. Note that the sum of all cells in this array must + * equal the value stored in slist_size above. * - * slist_ptr: pointer to the instance of H5SL_t used maintain a sorted - * list of dirty entries in the cache. This sorted list has - * two uses: + * slist_ptr: Pointer to the instance of H5SL_t used maintain a sorted + * list of dirty entries in the cache. This sorted list has + * two uses: * - * a) It allows us to flush dirty entries in increasing address - * order, which results in significant savings. + * a) It allows us to flush dirty entries in increasing address + * order, which results in significant savings. * - * b) It facilitates checking for adjacent dirty entries when - * attempting to evict entries from the cache. + * b) It facilitates checking for adjacent dirty entries when + * attempting to evict entries from the cache. * * num_last_entries: The number of entries in the cache that can only be - * flushed after all other entries in the cache have - * been flushed. + * flushed after all other entries in the cache have been flushed. * * Note: At this time, the this field will only be applied to * two types of entries: the superblock and the file driver info @@ -3322,11 +2231,11 @@ typedef struct H5C_tag_info_t { * compiled in when H5C_DO_SANITY_CHECKS is TRUE. * * slist_len_increase: Number of entries that have been added to the - * slist since the last time this field was set to zero. + * skip list since the last time this field was set to zero. * Note that this value can be negative. * * slist_size_increase: Total size of all entries that have been added - * to the slist since the last time this field was set to + * to the skip list since the last time this field was set to * zero. Note that this value can be negative. * * Cache entries belonging to a particular object are "tagged" with that @@ -3334,71 +2243,69 @@ typedef struct H5C_tag_info_t { * * The following fields are maintained to facilitate this. * - * tag_list: A collection to track entries that belong to an object. - * Each H5C_tag_info_t struct on the tag list corresponds to - * a particular object in the file. Tagged entries can be - * flushed or evicted as a group, or corked to prevent entries - * from being evicted from the cache. + * tag_list: A collection to track entries that belong to an object. + * Each H5C_tag_info_t struct on the tag list corresponds to a + * particular object in the file. Tagged entries can be flushed + * or evicted as a group, or corked to prevent entries from being + * evicted from the cache. * - * "Global" entries, like the superblock and the file's - * freelist, as well as shared entries like global - * heaps and shared object header messages, are not tagged. + * "Global" entries, like the superblock and the file's freelist, + * as well as shared entries like global heaps and shared object + * header messages, are not tagged. * - * ignore_tags: Boolean flag to disable tag validation during entry insertion. + * ignore_tags: Boolean flag to disable tag validation during entry insertion. * * num_objs_corked: Unsigned integer field containing the number of objects - * that are "corked". The "corked" status of an object is - * found by searching the "tag_list". This field is added - * for optimization so that the skip list search on "tag_list" - * can be skipped if this field is zero, i.e. no "corked" - * objects. + * that are "corked". The "corked" status of an object is found by + * searching the "tag_list". This field is added for optimization + * so that the skip list search on "tag_list" can be skipped if this + * field is zero, i.e. no "corked" objects. * * When a cache entry is protected, it must be removed from the LRU - * list(s) as it cannot be either flushed or evicted until it is unprotected. + * list(s), as it cannot be either flushed or evicted until it is unprotected. * The following fields are used to implement the protected list (pl). * - * pl_len: Number of entries currently residing on the protected list. + * pl_len: Number of entries currently residing on the protected list. * - * pl_size: Number of bytes of cache entries currently residing on the - * protected list. + * pl_size: Number of bytes of cache entries currently residing on the + * protected list. * * pl_head_ptr: Pointer to the head of the doubly linked list of protected - * entries. Note that cache entries on this list are linked - * by their next and prev fields. + * entries. Note that cache entries on this list are linked + * by their next and prev fields. * - * This field is NULL if the list is empty. + * This field is NULL if the list is empty. * * pl_tail_ptr: Pointer to the tail of the doubly linked list of protected - * entries. Note that cache entries on this list are linked - * by their next and prev fields. + * entries. Note that cache entries on this list are linked + * by their next and prev fields. * - * This field is NULL if the list is empty. + * This field is NULL if the list is empty. * * * For very frequently used entries, the protect/unprotect overhead can - * become burdensome. To avoid this overhead, the cache - * allows entries to be "pinned". A pinned entry is similar to a - * protected entry, in the sense that it cannot be evicted, and that - * the entry can be modified at any time. + * become burdensome. To avoid this overhead, the cache allows entries to + * be "pinned". A pinned entry is similar to a protected entry, in the + * sense that it cannot be evicted, and that the entry can be modified at + * any time. * * Pinning an entry has the following implications: * - * 1) A pinned entry cannot be evicted. Thus unprotected - * pinned entries reside in the pinned entry list, instead - * of the LRU list(s) (or other lists maintained by the current - * replacement policy code). + * 1) A pinned entry cannot be evicted. Thus unprotected pinned + * entries reside in the pinned entry list, instead of the LRU + * list(s) or other lists maintained by the current replacement + * policy code. * * 2) A pinned entry can be accessed or modified at any time. * This places an additional burden on the associated pre-serialize - * and serialize callbacks, which must ensure the entry is in - * a consistent state before creating an image of it. + * and serialize callbacks, which must ensure the entry is in + * a consistent state before creating an image of it. * * 3) A pinned entry can be marked as dirty (and possibly * change size) while it is unprotected. * * 4) The flush-destroy code must allow pinned entries to - * be unpinned (and possibly unprotected) during the - * flush. + * be unpinned (and possibly unprotected) during the flush. * * Since pinned entries cannot be evicted, they must be kept on a pinned * entry list (pel), instead of being entrusted to the replacement policy @@ -3406,23 +2313,22 @@ typedef struct H5C_tag_info_t { * * Maintaining the pinned entry list requires the following fields: * - * pel_len: Number of entries currently residing on the pinned - * entry list. + * pel_len: Number of entries currently residing on the pinned entry list. * - * pel_size: Number of bytes of cache entries currently residing on + * pel_size: Number of bytes of cache entries currently residing on * the pinned entry list. * * pel_head_ptr: Pointer to the head of the doubly linked list of pinned * but not protected entries. Note that cache entries on * this list are linked by their next and prev fields. * - * This field is NULL if the list is empty. + * This field is NULL if the list is empty. * * pel_tail_ptr: Pointer to the tail of the doubly linked list of pinned * but not protected entries. Note that cache entries on * this list are linked by their next and prev fields. * - * This field is NULL if the list is empty. + * This field is NULL if the list is empty. * * * The cache must have a replacement policy, and the fields supporting this @@ -3446,10 +2352,9 @@ typedef struct H5C_tag_info_t { * * When reading in parallel mode, we evict from the clean LRU list only. * This implies that we must try to ensure that the clean LRU list is - * reasonably well stocked at all times. - * - * We attempt to do this by trying to flush enough entries on each write - * to keep the cLRU_list_size >= min_clean_size. + * reasonably well stocked at all times. We attempt to do this by trying + * to flush enough entries on each write to keep the cLRU_list_size >= + * min_clean_size. * * Even if we start with a completely clean cache, a sequence of protects * without unprotects can empty the clean LRU list. In this case, the @@ -3463,14 +2368,14 @@ typedef struct H5C_tag_info_t { * * LRU_list_len: Number of cache entries currently on the LRU list. * - * Observe that LRU_list_len + pl_len + pel_len must always - * equal index_len. + * The LRU_list_len + pl_len + pel_len must always + * equal index_len. * * LRU_list_size: Number of bytes of cache entries currently residing on the * LRU list. * - * Observe that LRU_list_size + pl_size + pel_size must always - * equal index_size. + * The LRU_list_size + pl_size + pel_size must always + * equal index_size. * * LRU_head_ptr: Pointer to the head of the doubly linked LRU list. Cache * entries on this list are linked by their next and prev fields. @@ -3484,13 +2389,13 @@ typedef struct H5C_tag_info_t { * * cLRU_list_len: Number of cache entries currently on the clean LRU list. * - * Observe that cLRU_list_len + dLRU_list_len must always + * The cLRU_list_len + dLRU_list_len must always * equal LRU_list_len. * * cLRU_list_size: Number of bytes of cache entries currently residing on * the clean LRU list. * - * Observe that cLRU_list_size + dLRU_list_size must always + * The cLRU_list_size + dLRU_list_size must always * equal LRU_list_size. * * cLRU_head_ptr: Pointer to the head of the doubly linked clean LRU list. @@ -3507,12 +2412,12 @@ typedef struct H5C_tag_info_t { * * dLRU_list_len: Number of cache entries currently on the dirty LRU list. * - * Observe that cLRU_list_len + dLRU_list_len must always + * The cLRU_list_len + dLRU_list_len must always * equal LRU_list_len. * * dLRU_list_size: Number of cache entries currently on the dirty LRU list. * - * Observe that cLRU_list_len + dLRU_list_len must always + * The cLRU_list_len + dLRU_list_len must always * equal LRU_list_len. * * dLRU_head_ptr: Pointer to the head of the doubly linked dirty LRU list. @@ -3530,8 +2435,8 @@ typedef struct H5C_tag_info_t { * * Automatic cache size adjustment: * - * While the default cache size is adequate for most cases, we can run into - * cases where the default is too small. Ideally, we will let the user + * While the default cache size is adequate for many cases, there are + * cases where the default is too small. Ideally, the user should * adjust the cache size as required. However, this is not possible in all * cases, so the cache has automatic cache size adjustment code. * @@ -3539,36 +2444,32 @@ typedef struct H5C_tag_info_t { * the structure described below: * * size_increase_possible: Depending on the configuration data given - * in the resize_ctl field, it may or may not be possible - * to increase the size of the cache. Rather than test for - * all the ways this can happen, we simply set this flag when - * we receive a new configuration. + * in the resize_ctl field, it may or may not be possible to + * increase the size of the cache. Rather than test for all the + * ways this can happen, we simply set this flag when we receive + * a new configuration. * * flash_size_increase_possible: Depending on the configuration data given - * in the resize_ctl field, it may or may not be possible - * for a flash size increase to occur. We set this flag - * whenever we receive a new configuration so as to avoid - * repeated calculations. + * in the resize_ctl field, it may or may not be possible for a + * flash size increase to occur. We set this flag whenever we + * receive a new configuration so as to avoid repeated calculations. * * flash_size_increase_threshold: If a flash cache size increase is possible, - * this field is used to store the minimum size of a new entry - * or size increase needed to trigger a flash cache size - * increase. Note that this field must be updated whenever - * the size of the cache is changed. + * this field is used to store the minimum size of a new entry or size + * increase needed to trigger a flash cache size increase. Note that + * this field must be updated whenever the size of the cache is changed. * - * size_decrease_possible: Depending on the configuration data given - * in the resize_ctl field, it may or may not be possible - * to decrease the size of the cache. Rather than test for - * all the ways this can happen, we simply set this flag when - * we receive a new configuration. + * size_decrease_possible: Depending on the configuration data given in the + * resize_ctl field, it may or may not be possible to decrease the + * size of the cache. Rather than test for all the ways this can + * happen, we simply set this flag when we receive a new configuration. * * resize_enabled: This is another convenience flag which is set whenever - * a new set of values for resize_ctl are provided. Very - * simply: + * a new set of values for resize_ctl are provided. Very simply: * * resize_enabled = size_increase_possible || size_decrease_possible; * - * cache_full: Boolean flag used to keep track of whether the cache is + * cache_full: Boolean flag used to keep track of whether the cache is * full, so we can refrain from increasing the size of a * cache which hasn't used up the space allotted to it. * @@ -3590,18 +2491,16 @@ typedef struct H5C_tag_info_t { * occur. * * msic_in_progress: As the metadata cache has become re-entrant, and as - * the free space manager code has become more tightly - * integrated with the metadata cache, it is possible that - * a call to H5C_insert_entry() may trigger a call to - * H5C_make_space_in_cache(), which, via H5C__flush_single_entry() - * and client callbacks, may trigger an infinite regression - * of calls to H5C_make_space_in_cache(). - * - * The msic_in_progress boolean flag is used to detect this, - * and prevent the infinite regression that would otherwise - * occur. - * - * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration + * the free space manager code has become more tightly integrated + * with the metadata cache, it is possible that a call to + * H5C_insert_entry() may trigger a call to H5C_make_space_in_cache(), + * which, via H5C__flush_single_entry() and client callbacks, may + * trigger an infinite regression of calls to H5C_make_space_in_cache(). + * + * The msic_in_progress boolean flag is used to detect this, + * and prevent the infinite regression that would otherwise occur. + * + * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration * data for automatic cache resizing. * * epoch_markers_active: Integer field containing the number of epoch @@ -3634,27 +2533,24 @@ typedef struct H5C_tag_info_t { * in the ring buffer. * * epoch_markers: Array of instances of H5C_cache_entry_t of length - * H5C__MAX_EPOCH_MARKERS. The entries are used as markers - * in the LRU list to identify cache entries that haven't - * been accessed for some (small) specified number of - * epochs. These entries (if any) can then be evicted and - * the cache size reduced -- ideally without evicting any - * of the current working set. Needless to say, the epoch - * length and the number of epochs before an unused entry - * must be chosen so that all, or almost all, the working - * set will be accessed before the limit. - * - * Epoch markers only appear in the LRU list, never in - * the index or slist. While they are of type - * H5C__EPOCH_MARKER_TYPE, and have associated class - * functions, these functions should never be called. - * - * The addr fields of these instances of H5C_cache_entry_t - * are set to the index of the instance in the epoch_markers - * array, the size is set to 0, and the type field points - * to the constant structure epoch_marker_class defined - * in H5C.c. The next and prev fields are used as usual - * to link the entry into the LRU list. + * H5C__MAX_EPOCH_MARKERS. The entries are used as markers in the + * LRU list to identify cache entries that haven't been accessed for + * some (small) specified number of epochs. These entries (if any) + * can then be evicted and the cache size reduced -- ideally without + * evicting any of the current working set. Needless to say, the epoch + * length and the number of epochs before an unused entry must be + * chosen so that all, or almost all, the working set will be accessed + * before the limit. + * + * Epoch markers only appear in the LRU list, never in the index or + * skip list. While they are of type H5C__EPOCH_MARKER_TYPE, and have + * associated class functions, these functions should never be called. + * + * The addr fields of these instances of H5C_cache_entry_t are set to + * the index of the instance in the epoch_markers array, the size is + * set to 0, and the type field points to the constant structure + * epoch_marker_class defined in H5Cepoch.c. The next and prev fields + * are used as usual to link the entry into the LRU list. * * All other fields are unused. * @@ -3665,36 +2561,33 @@ typedef struct H5C_tag_info_t { * simple cache hit rate computation regardless of whether statistics * collection is enabled. The following fields support this capability. * - * cache_hits: Number of cache hits since the last time the cache hit - * rate statistics were reset. Note that when automatic cache - * re-sizing is enabled, this field will be reset every automatic - * resize epoch. + * cache_hits: Number of cache hits since the last time the cache hit rate + * statistics were reset. Note that when automatic cache re-sizing + * is enabled, this field will be reset every automatic resize epoch. * * cache_accesses: Number of times the cache has been accessed while - * since the last since the last time the cache hit rate statistics - * were reset. Note that when automatic cache re-sizing is enabled, - * this field will be reset every automatic resize epoch. + * since the last since the last time the cache hit rate statistics + * were reset. Note that when automatic cache re-sizing is enabled, + * this field will be reset every automatic resize epoch. * * * Metadata cache image management related fields. * - * image_ctl: Instance of H5C_cache_image_ctl_t containing configuration - * data for generation of a cache image on file close. + * image_ctl: Instance of H5C_cache_image_ctl_t containing configuration + * data for generation of a cache image on file close. * - * serialization_in_progress: Boolean field that is set to TRUE iff - * the cache is in the process of being serialized. This - * field is needed to support the H5C_serialization_in_progress() - * call, which is in turn required for sanity checks in some - * cache clients. + * serialization_in_progress: Boolean field that is set to TRUE iff + * the cache is in the process of being serialized. This field is + * needed to support the H5C_serialization_in_progress() call, which + * is in turn required for sanity checks in some cache clients. * - * load_image: Boolean flag indicating that the metadata cache image - * superblock extension message exists and should be - * read, and the image block read and decoded on the next - * call to H5C_protect(). + * load_image: Boolean flag indicating that the metadata cache image + * superblock extension message exists and should be read, and the + * image block read and decoded on the next call to H5C_protect(). * - * image_loaded: Boolean flag indicating that the metadata cache has + * image_loaded: Boolean flag indicating that the metadata cache has * loaded the metadata cache image as directed by the - * MDC cache image superblock extension message. + * cache image superblock extension message. * * delete_image: Boolean flag indicating whether the metadata cache image * superblock message should be deleted and the cache image @@ -3703,20 +2596,18 @@ typedef struct H5C_tag_info_t { * This flag should be set to TRUE iff the file is opened * R/W and there is a cache image to be read. * - * image_addr: haddr_t containing the base address of the on disk - * metadata cache image, or HADDR_UNDEF if that value is - * undefined. Note that this field is used both in the - * construction and write, and the read and decode of - * metadata cache image blocks. + * image_addr: The base address of the on-disk metadata cache image, or + * HADDR_UNDEF if that value is undefined. Note that this field + * is used both in the construction and write, and the read and + * decode of metadata cache image blocks. * - * image_len: hsize_t containing the size of the on disk metadata cache - * image, or zero if that value is undefined. Note that this - * field is used both in the construction and write, and the - * read and decode of metadata cache image blocks. + * image_len: The size of the on disk metadata cache image, or zero if that + * value is undefined. Note that this field is used both in the + * construction and write, and the read and decode of metadata cache + * image blocks. * - * image_data_len: size_t containing the number of bytes of data in the - * on disk metadata cache image, or zero if that value is - * undefined. + * image_data_len: The number of bytes of data in the on disk metadata + * cache image, or zero if that value is undefined. * * In most cases, this value is the same as the image_len * above. It exists to allow for metadata cache image blocks @@ -3762,11 +2653,11 @@ typedef struct H5C_tag_info_t { * The following fields are used assemble the cache image prior to * writing it to disk. * - * num_entries_in_image: Unsigned integer field containing the number of entries - * to be copied into the metadata cache image. Note that - * this value will be less than the number of entries in - * the cache, and the superblock and its related entries - * are not written to the metadata cache image. + * num_entries_in_image: Unsigned integer field containing the number of + * entries to be copied into the metadata cache image. Note that + * this value will be less than the number of entries in the cache, + * and the superblock and its related entries are not written to the + * metadata cache image. * * image_entries: Pointer to a dynamically allocated array of instance of * H5C_image_entry_t of length num_entries_in_image, or NULL @@ -3776,19 +2667,19 @@ typedef struct H5C_tag_info_t { * * image_buffer: Pointer to the dynamically allocated buffer of length * image_len in which the metadata cache image is assembled, - * or NULL if that buffer does not exist. + * or NULL if that buffer does not exist. * * * Free Space Manager Related fields: * - * The free space managers must be informed when we are about to close - * or flush the file so that they order themselves accordingly. This used - * to be done much later in the close process, but with cache image and + * The free space managers for the file must be informed when we are about to + * close or flush the file so that they order themselves accordingly. This + * used to be done much later in the close process, but with cache image and * page buffering, this is no longer viable, as we must finalize the on * disk image of all metadata much sooner. * * This is handled by the H5MF_settle_raw_data_fsm() and - * H5MF_settle_meta_data_FSM() routines. As these calls are expensive, + * H5MF_settle_meta_data_fsm() routines. As these calls are expensive, * the following fields are used to track whether the target free space * managers are clean. * @@ -3822,151 +2713,122 @@ typedef struct H5C_tag_info_t { * below. The first set are collected only when H5C_COLLECT_CACHE_STATS * is true. * - * hits: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id + * hits: Array to record the number of times an entry with type id * equal to the array index has been in cache when requested in * the current epoch. * - * misses: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id + * misses: Array to record the number of times an entry with type id * equal to the array index has not been in cache when * requested in the current epoch. * - * write_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with + * write_protects: Array to record the number of times an entry with * type id equal to the array index has been write protected * in the current epoch. * * Observe that (hits + misses) = (write_protects + read_protects). * - * read_protects: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with + * read_protects: Array to record the number of times an entry with * type id equal to the array index has been read protected in * the current epoch. * - * Observe that (hits + misses) = (write_protects + read_protects). + * Observe that (hits + misses) = (write_protects + read_protects). * - * max_read_protects: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to maximum number of simultaneous read + * max_read_protects: Array to maximum number of simultaneous read * protects on any entry with type id equal to the array index * in the current epoch. * - * insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type + * insertions: Array to record the number of times an entry with type * id equal to the array index has been inserted into the * cache in the current epoch. * - * pinned_insertions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry + * pinned_insertions: Array to record the number of times an entry * with type id equal to the array index has been inserted * pinned into the cache in the current epoch. * - * clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times a dirty entry with type - * id equal to the array index has been cleared in the current - * epoch. + * clears: Array to record the number of times a dirty entry with type + * id equal to the array index has been cleared in the current epoch. * - * flushes: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id + * flushes: Array to record the number of times an entry with type id * equal to the array index has been written to disk in the - * current epoch. + * current epoch. * - * evictions: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type id + * evictions: Array to record the number of times an entry with type id * equal to the array index has been evicted from the cache in * the current epoch. * - * take_ownerships: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry with + * take_ownerships: Array to record the number of times an entry with * type id equal to the array index has been removed from the * cache via the H5C__TAKE_OWNERSHIP_FLAG in the current epoch. * - * moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been moved in the current - * epoch. + * moves: Array to record the number of times an entry with type + * id equal to the array index has been moved in the current epoch. * - * entry_flush_moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry + * entry_flush_moves: Array to record the number of times an entry * with type id equal to the array index has been moved * during its pre-serialize callback in the current epoch. * - * cache_flush_moves: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry + * cache_flush_moves: Array to record the number of times an entry * with type id equal to the array index has been moved * during a cache flush in the current epoch. * - * pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been pinned in the current - * epoch. + * pins: Array to record the number of times an entry with type + * id equal to the array index has been pinned in the current epoch. * - * unpins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type - * id equal to the array index has been unpinned in the current - * epoch. + * unpins: Array to record the number of times an entry with type + * id equal to the array index has been unpinned in the current epoch. * - * dirty_pins: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the number of times an entry with type + * dirty_pins: Array to record the number of times an entry with type * id equal to the array index has been marked dirty while pinned * in the current epoch. * - * pinned_flushes: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry + * pinned_flushes: Array to record the number of times an entry * with type id equal to the array index has been flushed while * pinned in the current epoch. * - * pinned_clears: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. The - * cells are used to record the number of times an entry + * pinned_clears: Array to record the number of times an entry * with type id equal to the array index has been cleared while * pinned in the current epoch. * - * size_increases: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry + * size_increases: Array to record the number of times an entry * with type id equal to the array index has increased in * size in the current epoch. * - * size_decreases: Array of int64 of length H5C__MAX_NUM_TYPE_IDS + 1. - * The cells are used to record the number of times an entry + * size_decreases: Array to record the number of times an entry * with type id equal to the array index has decreased in * size in the current epoch. * - * entry_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the - * array index has changed size while in its pre-serialize - * callback. + * entry_flush_size_changes: Array to record the number of times an entry + * with type id equal to the array index has changed size while in + * its pre-serialize callback. * - * cache_flush_size_changes: Array of int64 of length - * H5C__MAX_NUM_TYPE_IDS + 1. The cells are used to record - * the number of times an entry with type id equal to the - * array index has changed size during a cache flush + * cache_flush_size_changes: Array to record the number of times an entry + * with type id equal to the array index has changed size during a + * cache flush * * total_ht_insertions: Number of times entries have been inserted into the * hash table in the current epoch. * * total_ht_deletions: Number of times entries have been deleted from the - * hash table in the current epoch. - * - * successful_ht_searches: int64 containing the total number of successful - * searches of the hash table in the current epoch. + * hash table in the current epoch. * - * total_successful_ht_search_depth: int64 containing the total number of - * entries other than the targets examined in successful - * searches of the hash table in the current epoch. + * successful_ht_searches: The total number of successful searches of the + * hash table in the current epoch. * - * failed_ht_searches: int64 containing the total number of unsuccessful - * searches of the hash table in the current epoch. + * total_successful_ht_search_depth: The total number of entries other than + * the targets examined in successful searches of the hash table in + * the current epoch. * - * total_failed_ht_search_depth: int64 containing the total number of - * entries examined in unsuccessful searches of the hash + * failed_ht_searches: The total number of unsuccessful searches of the hash * table in the current epoch. * - * max_index_len: Largest value attained by the index_len field in the - * current epoch. + * total_failed_ht_search_depth: The total number of entries examined in + * unsuccessful searches of the hash table in the current epoch. + * + * max_index_len: Largest value attained by the index_len field in the + * current epoch. * - * max_index_size: Largest value attained by the index_size field in the - * current epoch. + * max_index_size: Largest value attained by the index_size field in the + * current epoch. * * max_clean_index_size: Largest value attained by the clean_index_size field * in the current epoch. @@ -3974,75 +2836,73 @@ typedef struct H5C_tag_info_t { * max_dirty_index_size: Largest value attained by the dirty_index_size field * in the current epoch. * - * max_slist_len: Largest value attained by the slist_len field in the - * current epoch. + * max_slist_len: Largest value attained by the slist_len field in the + * current epoch. * - * max_slist_size: Largest value attained by the slist_size field in the - * current epoch. + * max_slist_size: Largest value attained by the slist_size field in the + * current epoch. * * max_pl_len: Largest value attained by the pl_len field in the - * current epoch. + * current epoch. * * max_pl_size: Largest value attained by the pl_size field in the - * current epoch. + * current epoch. * * max_pel_len: Largest value attained by the pel_len field in the - * current epoch. + * current epoch. * * max_pel_size: Largest value attained by the pel_size field in the - * current epoch. + * current epoch. * * calls_to_msic: Total number of calls to H5C__make_space_in_cache * * total_entries_skipped_in_msic: Number of clean entries skipped while - * enforcing the min_clean_fraction in H5C__make_space_in_cache(). + * enforcing the min_clean_fraction in H5C__make_space_in_cache(). * * total_dirty_pf_entries_skipped_in_msic: Number of dirty prefetched entries - * skipped in H5C__make_space_in_cache(). Note that this can - * only occur when a file is opened R/O with a cache image - * containing dirty entries. + * skipped in H5C__make_space_in_cache(). Note that this can + * only occur when a file is opened R/O with a cache image + * containing dirty entries. * * total_entries_scanned_in_msic: Number of clean entries skipped while - * enforcing the min_clean_fraction in H5C__make_space_in_cache(). + * enforcing the min_clean_fraction in H5C__make_space_in_cache(). * * max_entries_skipped_in_msic: Maximum number of clean entries skipped - * in any one call to H5C__make_space_in_cache(). + * in any one call to H5C__make_space_in_cache(). * * max_dirty_pf_entries_skipped_in_msic: Maximum number of dirty prefetched - * entries skipped in any one call to H5C__make_space_in_cache(). - * Note that this can only occur when the file is opened - * R/O with a cache image containing dirty entries. + * entries skipped in any one call to H5C__make_space_in_cache(). + * Note that this can only occur when the file is opened + * R/O with a cache image containing dirty entries. * * max_entries_scanned_in_msic: Maximum number of entries scanned over - * in any one call to H5C__make_space_in_cache(). + * in any one call to H5C__make_space_in_cache(). * * entries_scanned_to_make_space: Number of entries scanned only when looking - * for entries to evict in order to make space in cache. + * for entries to evict in order to make space in cache. * * * The following fields track statistics on cache images. * - * images_created: Integer field containing the number of cache images - * created since the last time statistics were reset. + * images_created: The number of cache images created since the last + * time statistics were reset. * * At present, this field must always be either 0 or 1. * Further, since cache images are only created at file * close, this field should only be set at that time. * - * images_read: Integer field containing the number of cache images - * read from file. Note that reading an image is different - * from loading it -- reading the image means just that, - * while loading the image refers to decoding it and loading - * it into the metadata cache. + * images_read: The number of cache images read from file. Note that + * reading an image is different from loading it -- reading the + * image means just that, while loading the image refers to decoding + * it and loading it into the metadata cache. * - * In the serial case, image_read should always equal - * images_loaded. However, in the parallel case, the - * image should only be read by process 0. All other - * processes should receive the cache image via a broadcast - * from process 0. + * In the serial case, image_read should always equal images_loaded. + * However, in the parallel case, the image should only be read by + * process 0. All other processes should receive the cache image via + * a broadcast from process 0. * - * images_loaded: Integer field containing the number of cache images - * loaded since the last time statistics were reset. + * images_loaded: The number of cache images loaded since the last time + * statistics were reset. * * At present, this field must always be either 0 or 1. * Further, since cache images are only loaded at the @@ -4062,25 +2922,24 @@ typedef struct H5C_tag_info_t { * of prefetched entries are tracked in the flushes and evictions arrays * discussed above. * - * prefetches: Number of prefetched entries that are loaded to the cache. + * prefetches: Number of prefetched entries that are loaded to the cache. * - * dirty_prefetches: Number of dirty prefetched entries that are loaded + * dirty_prefetches: Number of dirty prefetched entries that are loaded * into the cache. * - * prefetch_hits: Number of prefetched entries that are actually used. + * prefetch_hits: Number of prefetched entries that are actually used. * * - * Entries may move, load, dirty, and delete - * other entries in their pre_serialize and serialize callbacks, there is - * code to restart scans of lists so as to avoid - * improper behavior if the next entry in the list is the target of one on - * these operations. + * Entries may move, load, dirty, and delete other entries in their + * pre_serialize and serialize callbacks, there is code to restart scans of + * lists so as to avoid improper behavior if the next entry in the list is + * the target of one on these operations. * * The following fields are use to count such occurrences. They are used * both in tests (to verify that the scan has been restarted), and to * obtain estimates of how frequently these restarts occur. * - * slist_scan_restarts: Number of times a scan of the slist (that contains + * slist_scan_restarts: Number of times a scan of the skip list (that contains * calls to H5C__flush_single_entry()) has been restarted to * avoid potential issues with change of status of the next * entry in the scan. @@ -4102,42 +2961,35 @@ typedef struct H5C_tag_info_t { * The remaining stats are collected only when both H5C_COLLECT_CACHE_STATS * and H5C_COLLECT_CACHE_ENTRY_STATS are true. * - * max_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single + * max_accesses: Array to record the maximum number of times any single * entry with type id equal to the array index has been * accessed in the current epoch. * - * min_accesses: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the minimum number of times any single + * min_accesses: Array to record the minimum number of times any single * entry with type id equal to the array index has been * accessed in the current epoch. * - * max_clears: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single + * max_clears: Array to record the maximum number of times any single * entry with type id equal to the array index has been cleared * in the current epoch. * - * max_flushes: Array of int32 of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times any single + * max_flushes: Array to record the maximum number of times any single * entry with type id equal to the array index has been * flushed in the current epoch. * - * max_size: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum size of any single entry + * max_size: Array to record the maximum size of any single entry * with type id equal to the array index that has resided in * the cache in the current epoch. * - * max_pins: Array of size_t of length H5C__MAX_NUM_TYPE_IDS + 1. The cells - * are used to record the maximum number of times that any single + * max_pins: Array to record the maximum number of times that any single * entry with type id equal to the array index that has been * marked as pinned in the cache in the current epoch. * * * Fields supporting testing: * - * prefix Array of char used to prefix debugging output. The - * field is intended to allow marking of output of with - * the processes mpi rank. + * prefix: Array of char used to prefix debugging output. The field is + * intended to allow marking of output of with the processes mpi rank. * * get_entry_ptr_from_addr_counter: Counter used to track the number of * times the H5C_get_entry_ptr_from_addr() function has been @@ -4145,241 +2997,239 @@ typedef struct H5C_tag_info_t { * NDEBUG is not #defined. * ****************************************************************************/ - struct H5C_t { - uint32_t magic; - hbool_t flush_in_progress; - H5C_log_info_t *log_info; - void * aux_ptr; - int32_t max_type_id; - const H5C_class_t * const *class_table_ptr; - size_t max_cache_size; - size_t min_clean_size; - H5C_write_permitted_func_t check_write_permitted; - hbool_t write_permitted; - H5C_log_flush_func_t log_flush; - hbool_t evictions_enabled; - hbool_t close_warning_received; + hbool_t flush_in_progress; + H5C_log_info_t * log_info; + void * aux_ptr; + int32_t max_type_id; + const H5C_class_t * const *class_table_ptr; + size_t max_cache_size; + size_t min_clean_size; + H5C_write_permitted_func_t check_write_permitted; + hbool_t write_permitted; + H5C_log_flush_func_t log_flush; + hbool_t evictions_enabled; + hbool_t close_warning_received; /* Fields for maintaining the [hash table] index of entries */ - uint32_t index_len; - size_t index_size; + uint32_t index_len; + size_t index_size; uint32_t index_ring_len[H5C_RING_NTYPES]; - size_t index_ring_size[H5C_RING_NTYPES]; - size_t clean_index_size; - size_t clean_index_ring_size[H5C_RING_NTYPES]; - size_t dirty_index_size; - size_t dirty_index_ring_size[H5C_RING_NTYPES]; - H5C_cache_entry_t * index[H5C__HASH_TABLE_LEN]; - uint32_t il_len; - size_t il_size; - H5C_cache_entry_t * il_head; - H5C_cache_entry_t * il_tail; + size_t index_ring_size[H5C_RING_NTYPES]; + size_t clean_index_size; + size_t clean_index_ring_size[H5C_RING_NTYPES]; + size_t dirty_index_size; + size_t dirty_index_ring_size[H5C_RING_NTYPES]; + H5C_cache_entry_t * index[H5C__HASH_TABLE_LEN]; + uint32_t il_len; + size_t il_size; + H5C_cache_entry_t * il_head; + H5C_cache_entry_t * il_tail; /* Fields to detect entries removed during scans */ - int64_t entries_removed_counter; - H5C_cache_entry_t * last_entry_removed_ptr; - H5C_cache_entry_t * entry_watched_for_removal; + int64_t entries_removed_counter; + H5C_cache_entry_t * last_entry_removed_ptr; + H5C_cache_entry_t * entry_watched_for_removal; /* Fields for maintaining list of in-order entries, for flushing */ - hbool_t slist_enabled; - hbool_t slist_changed; - uint32_t slist_len; - size_t slist_size; + hbool_t slist_enabled; + hbool_t slist_changed; + uint32_t slist_len; + size_t slist_size; uint32_t slist_ring_len[H5C_RING_NTYPES]; - size_t slist_ring_size[H5C_RING_NTYPES]; - H5SL_t * slist_ptr; - uint32_t num_last_entries; + size_t slist_ring_size[H5C_RING_NTYPES]; + H5SL_t * slist_ptr; + uint32_t num_last_entries; #ifdef H5C_DO_SANITY_CHECKS - int32_t slist_len_increase; - int64_t slist_size_increase; + int32_t slist_len_increase; + int64_t slist_size_increase; #endif /* H5C_DO_SANITY_CHECKS */ /* Fields for maintaining list of tagged entries */ - H5C_tag_info_t * tag_list; - hbool_t ignore_tags; - uint32_t num_objs_corked; + H5C_tag_info_t * tag_list; + hbool_t ignore_tags; + uint32_t num_objs_corked; /* Fields for tracking protected entries */ - uint32_t pl_len; - size_t pl_size; - H5C_cache_entry_t * pl_head_ptr; - H5C_cache_entry_t * pl_tail_ptr; + uint32_t pl_len; + size_t pl_size; + H5C_cache_entry_t * pl_head_ptr; + H5C_cache_entry_t * pl_tail_ptr; /* Fields for tracking pinned entries */ - uint32_t pel_len; - size_t pel_size; - H5C_cache_entry_t * pel_head_ptr; - H5C_cache_entry_t * pel_tail_ptr; + uint32_t pel_len; + size_t pel_size; + H5C_cache_entry_t * pel_head_ptr; + H5C_cache_entry_t * pel_tail_ptr; /* Fields for complete LRU list of entries */ - uint32_t LRU_list_len; - size_t LRU_list_size; - H5C_cache_entry_t * LRU_head_ptr; - H5C_cache_entry_t * LRU_tail_ptr; + uint32_t LRU_list_len; + size_t LRU_list_size; + H5C_cache_entry_t * LRU_head_ptr; + H5C_cache_entry_t * LRU_tail_ptr; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS /* Fields for clean LRU list of entries */ - uint32_t cLRU_list_len; - size_t cLRU_list_size; - H5C_cache_entry_t * cLRU_head_ptr; - H5C_cache_entry_t * cLRU_tail_ptr; + uint32_t cLRU_list_len; + size_t cLRU_list_size; + H5C_cache_entry_t * cLRU_head_ptr; + H5C_cache_entry_t * cLRU_tail_ptr; /* Fields for dirty LRU list of entries */ - uint32_t dLRU_list_len; - size_t dLRU_list_size; - H5C_cache_entry_t * dLRU_head_ptr; - H5C_cache_entry_t * dLRU_tail_ptr; + uint32_t dLRU_list_len; + size_t dLRU_list_size; + H5C_cache_entry_t * dLRU_head_ptr; + H5C_cache_entry_t * dLRU_tail_ptr; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ #ifdef H5_HAVE_PARALLEL /* Fields for collective metadata reads */ - uint32_t coll_list_len; - size_t coll_list_size; - H5C_cache_entry_t * coll_head_ptr; - H5C_cache_entry_t * coll_tail_ptr; + uint32_t coll_list_len; + size_t coll_list_size; + H5C_cache_entry_t * coll_head_ptr; + H5C_cache_entry_t * coll_tail_ptr; /* Fields for collective metadata writes */ - H5SL_t * coll_write_list; + H5SL_t * coll_write_list; #endif /* H5_HAVE_PARALLEL */ /* Fields for automatic cache size adjustment */ - hbool_t size_increase_possible; - hbool_t flash_size_increase_possible; - size_t flash_size_increase_threshold; - hbool_t size_decrease_possible; - hbool_t resize_enabled; - hbool_t cache_full; - hbool_t size_decreased; - hbool_t resize_in_progress; - hbool_t msic_in_progress; - H5C_auto_size_ctl_t resize_ctl; + hbool_t size_increase_possible; + hbool_t flash_size_increase_possible; + size_t flash_size_increase_threshold; + hbool_t size_decrease_possible; + hbool_t resize_enabled; + hbool_t cache_full; + hbool_t size_decreased; + hbool_t resize_in_progress; + hbool_t msic_in_progress; + H5C_auto_size_ctl_t resize_ctl; /* Fields for epoch markers used in automatic cache size adjustment */ - int32_t epoch_markers_active; - hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; - int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS+1]; - int32_t epoch_marker_ringbuf_first; - int32_t epoch_marker_ringbuf_last; - int32_t epoch_marker_ringbuf_size; - H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_markers_active; + hbool_t epoch_marker_active[H5C__MAX_EPOCH_MARKERS]; + int32_t epoch_marker_ringbuf[H5C__MAX_EPOCH_MARKERS+1]; + int32_t epoch_marker_ringbuf_first; + int32_t epoch_marker_ringbuf_last; + int32_t epoch_marker_ringbuf_size; + H5C_cache_entry_t epoch_markers[H5C__MAX_EPOCH_MARKERS]; /* Fields for cache hit rate collection */ - int64_t cache_hits; - int64_t cache_accesses; + int64_t cache_hits; + int64_t cache_accesses; /* fields supporting generation of a cache image on file close */ - H5C_cache_image_ctl_t image_ctl; - hbool_t serialization_in_progress; - hbool_t load_image; - hbool_t image_loaded; - hbool_t delete_image; + H5C_cache_image_ctl_t image_ctl; + hbool_t serialization_in_progress; + hbool_t load_image; + hbool_t image_loaded; + hbool_t delete_image; haddr_t image_addr; - hsize_t image_len; - hsize_t image_data_len; - int64_t entries_loaded_counter; - int64_t entries_inserted_counter; - int64_t entries_relocated_counter; - int64_t entry_fd_height_change_counter; + hsize_t image_len; + hsize_t image_data_len; + int64_t entries_loaded_counter; + int64_t entries_inserted_counter; + int64_t entries_relocated_counter; + int64_t entry_fd_height_change_counter; uint32_t num_entries_in_image; - H5C_image_entry_t * image_entries; - void * image_buffer; + H5C_image_entry_t * image_entries; + void * image_buffer; /* Free Space Manager Related fields */ hbool_t rdfsm_settled; - hbool_t mdfsm_settled; + hbool_t mdfsm_settled; #if H5C_COLLECT_CACHE_STATS /* stats fields */ - int64_t hits[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t misses[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t write_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t insertions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_insertions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t evictions[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t take_ownerships[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t entry_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t cache_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t unpins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t dirty_pins[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t pinned_clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t size_increases[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t size_decreases[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t entry_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; - int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t hits[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t misses[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t write_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_read_protects[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t insertions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_insertions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t evictions[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t take_ownerships[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t entry_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t cache_flush_moves[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t unpins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t dirty_pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t pinned_clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t size_increases[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t size_decreases[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t entry_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; + int64_t cache_flush_size_changes[H5C__MAX_NUM_TYPE_IDS + 1]; /* Fields for hash table operations */ - int64_t total_ht_insertions; - int64_t total_ht_deletions; - int64_t successful_ht_searches; - int64_t total_successful_ht_search_depth; - int64_t failed_ht_searches; - int64_t total_failed_ht_search_depth; - uint32_t max_index_len; - size_t max_index_size; - size_t max_clean_index_size; - size_t max_dirty_index_size; + int64_t total_ht_insertions; + int64_t total_ht_deletions; + int64_t successful_ht_searches; + int64_t total_successful_ht_search_depth; + int64_t failed_ht_searches; + int64_t total_failed_ht_search_depth; + uint32_t max_index_len; + size_t max_index_size; + size_t max_clean_index_size; + size_t max_dirty_index_size; /* Fields for in-order skip list */ - uint32_t max_slist_len; - size_t max_slist_size; + uint32_t max_slist_len; + size_t max_slist_size; /* Fields for protected entry list */ - uint32_t max_pl_len; - size_t max_pl_size; + uint32_t max_pl_len; + size_t max_pl_size; /* Fields for pinned entry list */ - uint32_t max_pel_len; - size_t max_pel_size; + uint32_t max_pel_len; + size_t max_pel_size; /* Fields for tracking 'make space in cache' (msic) operations */ - int64_t calls_to_msic; - int64_t total_entries_skipped_in_msic; - int64_t total_dirty_pf_entries_skipped_in_msic; - int64_t total_entries_scanned_in_msic; - int32_t max_entries_skipped_in_msic; - int32_t max_dirty_pf_entries_skipped_in_msic; - int32_t max_entries_scanned_in_msic; - int64_t entries_scanned_to_make_space; + int64_t calls_to_msic; + int64_t total_entries_skipped_in_msic; + int64_t total_dirty_pf_entries_skipped_in_msic; + int64_t total_entries_scanned_in_msic; + int32_t max_entries_skipped_in_msic; + int32_t max_dirty_pf_entries_skipped_in_msic; + int32_t max_entries_scanned_in_msic; + int64_t entries_scanned_to_make_space; /* Fields for tracking skip list scan restarts */ - int64_t slist_scan_restarts; - int64_t LRU_scan_restarts; - int64_t index_scan_restarts; + int64_t slist_scan_restarts; + int64_t LRU_scan_restarts; + int64_t index_scan_restarts; /* Fields for tracking cache image operations */ - int32_t images_created; - int32_t images_read; - int32_t images_loaded; - hsize_t last_image_size; + int32_t images_created; + int32_t images_read; + int32_t images_loaded; + hsize_t last_image_size; /* Fields for tracking prefetched entries */ - int64_t prefetches; - int64_t dirty_prefetches; - int64_t prefetch_hits; + int64_t prefetches; + int64_t dirty_prefetches; + int64_t prefetch_hits; #if H5C_COLLECT_CACHE_ENTRY_STATS - int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t min_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_clears[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; - size_t max_size[H5C__MAX_NUM_TYPE_IDS + 1]; - int32_t max_pins[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t min_accesses[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_clears[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_flushes[H5C__MAX_NUM_TYPE_IDS + 1]; + size_t max_size[H5C__MAX_NUM_TYPE_IDS + 1]; + int32_t max_pins[H5C__MAX_NUM_TYPE_IDS + 1]; #endif /* H5C_COLLECT_CACHE_ENTRY_STATS */ #endif /* H5C_COLLECT_CACHE_STATS */ - char prefix[H5C__PREFIX_LEN]; + char prefix[H5C__PREFIX_LEN]; #ifndef NDEBUG - int64_t get_entry_ptr_from_addr_counter; -#endif /* NDEBUG */ + int64_t get_entry_ptr_from_addr_counter; +#endif }; /* H5C_t */ @@ -4396,19 +3246,22 @@ typedef int (*H5C_tag_iter_cb_t)(H5C_cache_entry_t *entry, void *ctx); /* Package Private Prototypes */ /******************************/ H5_DLL herr_t H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated); -H5_DLL herr_t H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t * cache_ptr, - H5C_cache_entry_t** entry_ptr_ptr, const H5C_class_t * type, haddr_t addr, - void * udata); /* General routines */ +H5_DLL herr_t H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted); +H5_DLL herr_t H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr); +H5_DLL herr_t H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr); +H5_DLL herr_t H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t new_entry_size); +H5_DLL herr_t H5C__flush_invalidate_cache(H5F_t *f, unsigned flags); +H5_DLL herr_t H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags); H5_DLL herr_t H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags); H5_DLL herr_t H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr); H5_DLL herr_t H5C__load_cache_image(H5F_t *f); H5_DLL herr_t H5C__make_space_in_cache(H5F_t * f, size_t space_needed, hbool_t write_permitted); -H5_DLL herr_t H5C__flush_marked_entries(H5F_t * f); H5_DLL herr_t H5C__serialize_cache(H5F_t *f); +H5_DLL herr_t H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr); H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_tag_iter_cb_t cb, void *cb_ctx); @@ -4416,10 +3269,14 @@ H5_DLL herr_t H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_ H5_DLL herr_t H5C__tag_entry(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr); H5_DLL herr_t H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry); +/* Routines for operating on cache images */ +H5_DLL herr_t H5C__get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); +H5_DLL herr_t H5C__image_stats(H5C_t *cache_ptr, hbool_t print_header); + +/* Debugging routines */ #ifdef H5C_DO_SLIST_SANITY_CHECKS H5_DLL hbool_t H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr); #endif - #ifdef H5C_DO_EXTREME_SANITY_CHECKS H5_DLL herr_t H5C__validate_lru_list(H5C_t *cache_ptr); H5_DLL herr_t H5C__validate_pinned_entry_list(H5C_t *cache_ptr); diff --git a/src/H5Cprefetched.c b/src/H5Cprefetched.c index 911728f..b9d25aed 100644 --- a/src/H5Cprefetched.c +++ b/src/H5Cprefetched.c @@ -13,21 +13,28 @@ /*------------------------------------------------------------------------- * * Created: H5Cprefetched.c - * December 28 2016 - * Quincey Koziol * - * Purpose: Metadata cache prefetched entry callbacks. + * Purpose: Metadata cache prefetched entry callbacks * *------------------------------------------------------------------------- */ +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ + /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory Management */ /****************/ /* Local Macros */ @@ -208,7 +215,6 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) /* Sanity checks */ assert(entry_ptr); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(entry_ptr->prefetched); switch (action) { @@ -232,7 +238,6 @@ H5C__prefetched_entry_notify(H5C_notify_action_t action, void *_thing) assert(entry_ptr->flush_dep_parent); parent_ptr = entry_ptr->flush_dep_parent[u]; assert(parent_ptr); - assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(parent_ptr->flush_dep_nchildren > 0); /* Destroy flush dependency with flush dependency parent */ @@ -283,7 +288,6 @@ H5C__prefetched_entry_free_icr(void *_thing) /* Sanity checks */ assert(entry_ptr); - assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(entry_ptr->prefetched); /* Release array for flush dependency parent addresses */ diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 36ff5b1..2e818d2 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -85,10 +85,6 @@ #define H5C__DEFAULT_MAX_CACHE_SIZE ((size_t)(4 * 1024 * 1024)) #define H5C__DEFAULT_MIN_CLEAN_SIZE ((size_t)(2 * 1024 * 1024)) -/* Values for cache entry magic field */ -#define H5C__H5C_CACHE_ENTRY_T_MAGIC 0x005CAC0A -#define H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC 0xDeadBeef - /* Cache configuration validation definitions */ #define H5C_RESIZE_CFG__VALIDATE_GENERAL 0x1 #define H5C_RESIZE_CFG__VALIDATE_INCREMENT 0x2 @@ -974,25 +970,6 @@ typedef int H5C_ring_t; * * The fields of this structure are discussed individually below: * - * magic: Unsigned 32 bit integer that must always be set to - * H5C__H5C_CACHE_ENTRY_T_MAGIC when the entry is valid. - * The field must be set to H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC - * just before the entry is freed. - * - * This is necessary, as the LRU list can be changed out - * from under H5C__make_space_in_cache() by the serialize - * callback which may change the size of an existing entry, - * and/or load a new entry while serializing the target entry. - * - * This in turn can cause a recursive call to - * H5C__make_space_in_cache() which may either flush or evict - * the next entry that the first invocation of that function - * was about to examine. - * - * The magic field allows H5C__make_space_in_cache() to - * detect this case, and re-start its scan from the bottom - * of the LRU when this situation occurs. - * * cache_ptr: Pointer to the cache that this entry is contained within. * * addr: Base address of the cache entry on disk. @@ -1568,7 +1545,6 @@ typedef int H5C_ring_t; * ****************************************************************************/ typedef struct H5C_cache_entry_t { - uint32_t magic; H5C_t *cache_ptr; haddr_t addr; size_t size; @@ -1666,11 +1642,6 @@ typedef struct H5C_cache_entry_t { * * The fields of this structure are discussed individually below: * - * magic: Unsigned 32 bit integer that must always be set to - * H5C_IMAGE_ENTRY_T_MAGIC when the entry is valid. - * The field must be set to H5C_IMAGE_ENTRY_T_BAD_MAGIC - * just before the entry is freed. - * * addr: Base address of the cache entry on disk. * * size: Length of the cache entry on disk in bytes. @@ -1794,11 +1765,8 @@ typedef struct H5C_cache_entry_t { * callbacks must be used to update this image before it is * written to disk * - * ****************************************************************************/ - typedef struct H5C_image_entry_t { - uint32_t magic; haddr_t addr; size_t size; H5C_ring_t ring; @@ -2213,7 +2181,6 @@ herr_t H5C_verify_tag(int id, haddr_t tag); #endif H5_DLL herr_t H5C_flush_to_min_clean(H5F_t *f); H5_DLL herr_t H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); -H5_DLL herr_t H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); H5_DLL herr_t H5C_get_cache_size(const H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, uint32_t *cur_num_entries_ptr); H5_DLL herr_t H5C_get_cache_flush_in_progress(const H5C_t *cache_ptr, hbool_t *flush_in_progress_ptr); @@ -2224,7 +2191,6 @@ H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, size_t *size_pt hbool_t *is_flush_dep_child_ptr, hbool_t *image_up_to_date_ptr); H5_DLL herr_t H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr); H5_DLL void *H5C_get_aux_ptr(const H5C_t *cache_ptr); -H5_DLL herr_t H5C_image_stats(H5C_t *cache_ptr, hbool_t print_header); H5_DLL herr_t H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags); H5_DLL herr_t H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_t rw); diff --git a/src/H5Cquery.c b/src/H5Cquery.c index d0c65af..952ee12 100644 --- a/src/H5Cquery.c +++ b/src/H5Cquery.c @@ -77,7 +77,7 @@ H5C_get_cache_auto_resize_config(const H5C_t *cache_ptr, H5C_auto_size_ctl_t *co FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") if (config_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad config_ptr on entry.") @@ -112,7 +112,7 @@ H5C_get_cache_size(const H5C_t *cache_ptr, size_t *max_size_ptr, size_t *min_cle FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") if (max_size_ptr != NULL) @@ -148,7 +148,7 @@ H5C_get_cache_flush_in_progress(const H5C_t *cache_ptr, hbool_t *flush_in_progre FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") if (flush_in_progress_ptr != NULL) @@ -178,7 +178,7 @@ H5C_get_cache_hit_rate(const H5C_t *cache_ptr, double *hit_rate_ptr) FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") if (hit_rate_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad hit_rate_ptr on entry.") @@ -196,7 +196,6 @@ done: } /* H5C_get_cache_hit_rate() */ /*------------------------------------------------------------------------- - * * Function: H5C_get_entry_status * * Purpose: This function is used to determine whether the cache @@ -229,21 +228,15 @@ H5C_get_entry_status(const H5F_t *f, haddr_t addr, size_t *size_ptr, hbool_t *in /* Sanity checks */ assert(f); assert(f->shared); - cache_ptr = f->shared->cache; - assert(cache_ptr != NULL); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(addr)); assert(in_cache_ptr != NULL); - /* this test duplicates two of the above asserts, but we need an - * invocation of HGOTO_ERROR to keep the compiler happy. - */ - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) { /* the entry doesn't exist in the cache -- report this @@ -292,7 +285,7 @@ H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") if (evictions_enabled_ptr == NULL) @@ -323,7 +316,6 @@ H5C_get_aux_ptr(const H5C_t *cache_ptr) /* Check arguments */ assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); FUNC_LEAVE_NOAPI(cache_ptr->aux_ptr) } /* H5C_get_aux_ptr() */ @@ -354,11 +346,10 @@ H5C_get_entry_ring(const H5F_t *f, haddr_t addr, H5C_ring_t *ring) assert(f->shared); cache_ptr = f->shared->cache; assert(cache_ptr); - assert(cache_ptr->magic == H5C__H5C_T_MAGIC); assert(H5_addr_defined(addr)); /* Locate the entry at the address */ - H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL); if (entry_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "can't find entry in index") @@ -385,7 +376,7 @@ H5C_get_mdc_image_info(const H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *ima FUNC_ENTER_NOAPI(FAIL) - if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) + if (cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") if (image_addr) diff --git a/src/H5Ctag.c b/src/H5Ctag.c index b37c851..a13c121 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -13,11 +13,9 @@ /*------------------------------------------------------------------------- * * Created: H5Ctag.c - * June 5 2016 - * Quincey Koziol * * Purpose: Functions in this file operate on tags for metadata - * cache entries. + * cache entries * *------------------------------------------------------------------------- */ @@ -32,14 +30,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Cpkg.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -81,7 +79,9 @@ typedef struct { /********************/ /* Local Prototypes */ /********************/ +static herr_t H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, void *cb_ctx); static herr_t H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag); +static herr_t H5C__flush_marked_entries(H5F_t *f); /*********************/ /* Package Variables */ @@ -99,7 +99,6 @@ H5FL_EXTERN(H5C_tag_info_t); /*******************/ /*------------------------------------------------------------------------- - * * Function: H5C_ignore_tags * * Purpose: Override all assertion frameworks associated with making @@ -115,9 +114,6 @@ H5FL_EXTERN(H5C_tag_info_t); * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Mike McGreevy - * December 1, 2009 - * *------------------------------------------------------------------------- */ herr_t @@ -127,7 +123,6 @@ H5C_ignore_tags(H5C_t *cache) /* Assertions */ assert(cache != NULL); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Set variable to ignore tag values upon assignment */ cache->ignore_tags = TRUE; @@ -136,58 +131,48 @@ H5C_ignore_tags(H5C_t *cache) } /* H5C_ignore_tags */ /*------------------------------------------------------------------------- - * * Function: H5C_get_ignore_tags * * Purpose: Retrieve the 'ignore_tags' field for the cache * * Return: 'ignore_tags' value (can't fail) * - * Programmer: Quincey Koziol - * April 30, 2016 - * *------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5C_get_ignore_tags(const H5C_t *cache) { FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ assert(cache); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Return ignore tag value */ FUNC_LEAVE_NOAPI(cache->ignore_tags) } /* H5C_get_ignore_tags */ /*------------------------------------------------------------------------- - * * Function: H5C_get_num_objs_corked * * Purpose: Retrieve the 'num_objs_corked' field for the cache * * Return: 'num_objs_corked' value (can't fail) * - * Programmer: Vailin Choi; Feb 2019 - * *------------------------------------------------------------------------- */ -uint32_t +H5_ATTR_PURE uint32_t H5C_get_num_objs_corked(const H5C_t *cache) { FUNC_ENTER_NOAPI_NOERR /* Sanity checks */ assert(cache); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Return value for num_objs_corked */ FUNC_LEAVE_NOAPI(cache->num_objs_corked) } /* H5C_get_num_objs_corked */ /*------------------------------------------------------------------------- - * * Function: H5C__tag_entry * * Purpose: Tags an entry with the provided tag (contained in the API context). @@ -197,9 +182,6 @@ H5C_get_num_objs_corked(const H5C_t *cache) * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Mike McGreevy - * January 14, 2010 - * *------------------------------------------------------------------------- */ herr_t @@ -214,7 +196,6 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) /* Assertions */ assert(cache != NULL); assert(entry != NULL); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Get the tag */ tag = H5CX_get_tag(); @@ -274,7 +255,6 @@ done: } /* H5C__tag_entry */ /*------------------------------------------------------------------------- - * * Function: H5C__untag_entry * * Purpose: Removes an entry from a tag list, possibly removing the tag @@ -282,9 +262,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Quincey Koziol - * July 8, 2016 - * *------------------------------------------------------------------------- */ herr_t @@ -298,7 +275,6 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) /* Assertions */ assert(cache != NULL); assert(entry != NULL); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Get the entry's tag info struct */ if (NULL != (tag_info = entry->tag_info)) { @@ -333,16 +309,12 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) } /* H5C__untag_entry */ /*------------------------------------------------------------------------- - * * Function: H5C__iter_tagged_entries_real * * Purpose: Iterate over tagged entries, making a callback for matches * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Quincey Koziol - * June 7, 2016 - * *------------------------------------------------------------------------- */ static herr_t @@ -356,7 +328,6 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, v /* Sanity checks */ assert(cache != NULL); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Search the list of tagged object addresses in the cache */ HASH_FIND(hh, cache->tag_list, &tag, sizeof(haddr_t), tag_info); @@ -390,16 +361,12 @@ done: } /* H5C__iter_tagged_entries_real() */ /*------------------------------------------------------------------------- - * * Function: H5C__iter_tagged_entries * * Purpose: Iterate over tagged entries, making a callback for matches * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Quincey Koziol - * June 7, 2016 - * *------------------------------------------------------------------------- */ herr_t @@ -412,7 +379,6 @@ H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, H5C_ta /* Sanity checks */ assert(cache != NULL); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Iterate over the entries for this tag */ if (H5C__iter_tagged_entries_real(cache, tag, cb, cb_ctx) < 0) @@ -434,16 +400,12 @@ done: } /* H5C__iter_tagged_entries() */ /*------------------------------------------------------------------------- - * * Function: H5C__evict_tagged_entries_cb * * Purpose: Callback for evicting tagged entries * * Return: H5_ITER_ERROR if error is detected, H5_ITER_CONT otherwise. * - * Programmer: Mike McGreevy - * August 19, 2010 - * *------------------------------------------------------------------------- */ static int @@ -485,16 +447,12 @@ done: } /* H5C__evict_tagged_entries_cb() */ /*------------------------------------------------------------------------- - * * Function: H5C_evict_tagged_entries * * Purpose: Evicts all entries with the specified tag from cache * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Mike McGreevy - * August 19, 2010 - * *------------------------------------------------------------------------- */ herr_t @@ -512,7 +470,6 @@ H5C_evict_tagged_entries(H5F_t *f, haddr_t tag, hbool_t match_global) assert(f->shared); cache = f->shared->cache; /* Get cache pointer */ assert(cache != NULL); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Construct context for iterator callbacks */ ctx.f = f; @@ -564,16 +521,12 @@ done: } /* H5C_evict_tagged_entries() */ /*------------------------------------------------------------------------- - * * Function: H5C__mark_tagged_entries_cb * * Purpose: Callback to set the flush marker on dirty entries in the cache * * Return: H5_ITER_CONT (can't fail) * - * Programmer: Mike McGreevy - * September 9, 2010 - * *------------------------------------------------------------------------- */ static int @@ -594,7 +547,6 @@ H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) } /* H5C__mark_tagged_entries_cb() */ /*------------------------------------------------------------------------- - * * Function: H5C__mark_tagged_entries * * Purpose: Set the flush marker on dirty entries in the cache that have @@ -602,9 +554,6 @@ H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Mike McGreevy - * September 9, 2010 - * *------------------------------------------------------------------------- */ static herr_t @@ -617,7 +566,6 @@ H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) /* Sanity check */ assert(cache); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Iterate through hash table entries, marking those with specified tag, as * well as any major global entries which should always be flushed @@ -629,19 +577,53 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__mark_tagged_entries() */ +/*------------------------------------------------------------------------- + * Function: H5C__flush_marked_entries + * + * Purpose: Flushes all marked entries in the cache. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__flush_marked_entries(H5F_t *f) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + /* Assertions */ + assert(f != NULL); + + /* Enable the slist, as it is needed in the flush */ + if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed") + + /* Flush all marked entries */ + if (H5C_flush_cache(f, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") + + /* Disable the slist. Set the clear_slist parameter to TRUE + * since we called H5C_flush_cache() with the + * H5C__FLUSH_MARKED_ENTRIES_FLAG. + */ + if (H5C_set_slist_enabled(f->shared->cache, FALSE, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_marked_entries */ + #ifdef H5C_DO_TAGGING_SANITY_CHECKS /*------------------------------------------------------------------------- - * * Function: H5C_verify_tag * * Purpose: Performs sanity checking on an entrytype/tag pair. * * Return: SUCCEED or FAIL. * - * Programmer: Mike McGreevy - * January 14, 2010 - * *------------------------------------------------------------------------- */ herr_t @@ -703,16 +685,12 @@ done: #endif /*------------------------------------------------------------------------- - * * Function: H5C_flush_tagged_entries * * Purpose: Flushes all entries with the specified tag to disk. * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Mike McGreevy - * August 19, 2010 - * *------------------------------------------------------------------------- */ herr_t @@ -744,7 +722,6 @@ done: } /* H5C_flush_tagged_entries */ /*------------------------------------------------------------------------- - * * Function: H5C_retag_entries * * Purpose: Searches through cache index for all entries with the @@ -753,9 +730,6 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Mike McGreevy - * March 17, 2010 - * *------------------------------------------------------------------------- */ herr_t @@ -786,7 +760,6 @@ H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) } /* H5C_retag_entries() */ /*------------------------------------------------------------------------- - * * Function: H5C__expunge_tag_type_metadata_cb * * Purpose: Expunge from the cache entries associated @@ -794,9 +767,6 @@ H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) * * Return: H5_ITER_ERROR if error is detected, H5_ITER_CONT otherwise. * - * Programmer: Vailin Choi - * May 2016 - * *------------------------------------------------------------------------- */ static int @@ -822,7 +792,6 @@ done: } /* H5C__expunge_tag_type_metadata_cb() */ /*------------------------------------------------------------------------- - * * Function: H5C_expunge_tag_type_metadata * * Purpose: Search and expunge from the cache entries associated @@ -830,9 +799,6 @@ done: * * Return: FAIL if error is detected, SUCCEED otherwise. * - * Programmer: Vailin Choi - * May 2016 - * *------------------------------------------------------------------------- */ herr_t @@ -850,7 +816,6 @@ H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags assert(f->shared); cache = f->shared->cache; /* Get cache pointer */ assert(cache != NULL); - assert(cache->magic == H5C__H5C_T_MAGIC); /* Construct context for iterator callbacks */ ctx.f = f; @@ -866,16 +831,12 @@ done: } /* H5C_expunge_tag_type_metadata() */ /*------------------------------------------------------------------------- - * * Function: H5C_get_tag() * * Purpose: Get the tag for a metadata cache entry. * * Return: SUCCEED (can't fail) * - * Programmer: Dana Robinson - * Fall 2016 - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5D.c b/src/H5D.c index 7f03a03..cd4b1b0 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -26,6 +26,7 @@ #include "H5ESprivate.h" /* Event Sets */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -140,7 +141,7 @@ H5D__create_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t spac done: if (H5I_INVALID_HID == ret_value) if (dset && H5VL_dataset_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_api_common() */ @@ -228,7 +229,7 @@ H5Dcreate_async(const char *app_file, const char *app_func, unsigned app_line, h H5ARG_TRACE11(__func__, "*s*sIui*siiiiii", app_file, app_func, app_line, loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on dataset ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on dataset ID"); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -319,7 +320,7 @@ done: /* Cleanup on failure */ if (H5I_INVALID_HID == ret_value) if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset"); FUNC_LEAVE_API(ret_value) } /* end H5Dcreate_anon() */ @@ -369,7 +370,7 @@ H5D__open_api_common(hid_t loc_id, const char *name, hid_t dapl_id, void **token done: if (H5I_INVALID_HID == ret_value) if (dset && H5VL_dataset_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset"); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__open_api_common() */ @@ -442,7 +443,7 @@ H5Dopen_async(const char *app_file, const char *app_func, unsigned app_line, hid H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, dapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on dataset ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on dataset ID"); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -539,7 +540,7 @@ H5Dclose_async(const char *app_file, const char *app_func, unsigned app_line, hi done: if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement ref count on connector") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); FUNC_LEAVE_API(ret_value) } /* end H5Dclose_async() */ @@ -653,7 +654,7 @@ H5Dget_space_async(const char *app_file, const char *app_func, unsigned app_line /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, - "can't decrement count on dataspace ID") + "can't decrement count on dataspace ID"); HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -1126,7 +1127,7 @@ H5Dread_multi(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t mem_spac H5TRACE7("e", "z*i*i*i*iix", count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); if (count == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Read the data */ if (H5D__read_api_common(count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, NULL, @@ -1437,7 +1438,7 @@ H5Dwrite_multi(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t mem_spa H5TRACE7("e", "z*i*i*i*ii**x", count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); if (count == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Write the data */ if (H5D__write_api_common(count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, NULL, @@ -1638,7 +1639,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_ done: /* Release selection iterator */ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release selection iterator"); if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); @@ -1734,7 +1735,7 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf done: /* Release selection iterator */ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release selection iterator"); if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); @@ -2263,7 +2264,7 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* H5Dget_chunk_storage_size() */ /*------------------------------------------------------------------------- @@ -2312,7 +2313,7 @@ H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks /*out*/) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of chunks") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* H5Dget_num_chunks() */ /*------------------------------------------------------------------------- @@ -2383,7 +2384,7 @@ H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *of HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info by index") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* H5Dget_chunk_info() */ /*------------------------------------------------------------------------- diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 2ddd84b..40edc77 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -157,7 +157,7 @@ const H5D_chunk_ops_t H5D_COPS_BTREE[1] = {{ /*****************************/ /* inherits B-tree like properties from H5B */ -H5B_class_t H5B_BTREE[1] = {{ +static H5B_class_t H5B_BTREE[1] = {{ H5B_CHUNK_ID, /*id */ sizeof(H5D_btree_key_t), /*sizeof_nkey */ H5D__btree_get_shared, /*get_shared */ @@ -417,7 +417,7 @@ H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key, hbo for (u = 0; u < udata->common.layout->ndims; u++) if (udata->common.scaled[u] >= (lt_key->scaled[u] + 1)) { *found = FALSE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* Initialize return values */ @@ -459,7 +459,7 @@ H5D__chunk_disjoint(unsigned n, const hsize_t *scaled1, const hsize_t *scaled2) /* Loop over two chunks, detecting disjointness and getting out quickly */ for (u = 0; u < n; u++) if ((scaled1[u] + 1) <= scaled2[u] || (scaled2[u] + 1) <= scaled1[u]) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1377,9 +1377,9 @@ done: if (shared_init) { /* Free the raw B-tree node buffer */ if (NULL == storage.u.btree.shared) - HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted shared info nil") + HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted shared info nil"); else if (H5UC_DEC(storage.u.btree.shared) < 0) - HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted shared info") + HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted shared info"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index ff420e1..ac4e7d5 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -361,7 +361,7 @@ H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) assert(ctx); /* Encode the record's fields */ - H5_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); /* (Don't encode the chunk size & filter mask for non-filtered B-tree records) */ for (u = 0; u < ctx->ndims; u++) UINT64ENCODE(raw, record->scaled[u]); @@ -393,7 +393,7 @@ H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) assert(ctx); /* Decode the record's fields */ - H5_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); record->nbytes = ctx->chunk_size; record->filter_mask = 0; for (u = 0; u < ctx->ndims; u++) @@ -463,7 +463,7 @@ H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) assert(0 != record->nbytes); /* Encode the record's fields */ - H5_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, record->chunk_addr); UINT64ENCODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32ENCODE(raw, record->filter_mask); for (u = 0; u < ctx->ndims; u++) @@ -497,7 +497,7 @@ H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) assert(record); /* Decode the record's fields */ - H5_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &record->chunk_addr); UINT64DECODE_VAR(raw, record->nbytes, ctx->chunk_size_len); UINT32DECODE(raw, record->filter_mask); for (u = 0; u < ctx->ndims; u++) @@ -623,7 +623,7 @@ H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) done: /* Release the object header from the cache */ if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__btree2_idx_depend() */ @@ -1269,7 +1269,7 @@ H5D__bt2_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_id HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Create v2 B-tree that describes the chunked dataset in the destination file */ if (H5D__bt2_idx_create(idx_info_dst) < 0) @@ -1360,7 +1360,7 @@ H5D__bt2_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) done: /* Close v2 B-tree index */ if (bt2_cdset && H5B2_close(bt2_cdset) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for tracking chunked dataset") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for tracking chunked dataset"); idx_info->storage->u.btree2.bt2 = NULL; FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 3da5d98..d8ebd81 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -79,13 +79,14 @@ /* Sanity check on chunk index types: commonly used by a lot of routines in this file */ #define H5D_CHUNK_STORAGE_INDEX_CHK(storage) \ - assert((H5D_CHUNK_IDX_EARRAY == (storage)->idx_type && H5D_COPS_EARRAY == (storage)->ops) || \ - (H5D_CHUNK_IDX_FARRAY == (storage)->idx_type && H5D_COPS_FARRAY == (storage)->ops) || \ - (H5D_CHUNK_IDX_BT2 == (storage)->idx_type && H5D_COPS_BT2 == (storage)->ops) || \ - (H5D_CHUNK_IDX_BTREE == (storage)->idx_type && H5D_COPS_BTREE == (storage)->ops) || \ - (H5D_CHUNK_IDX_SINGLE == (storage)->idx_type && H5D_COPS_SINGLE == (storage)->ops) || \ - (H5D_CHUNK_IDX_NONE == (storage)->idx_type && H5D_COPS_NONE == (storage)->ops)); - + do { \ + assert((H5D_CHUNK_IDX_EARRAY == (storage)->idx_type && H5D_COPS_EARRAY == (storage)->ops) || \ + (H5D_CHUNK_IDX_FARRAY == (storage)->idx_type && H5D_COPS_FARRAY == (storage)->ops) || \ + (H5D_CHUNK_IDX_BT2 == (storage)->idx_type && H5D_COPS_BT2 == (storage)->ops) || \ + (H5D_CHUNK_IDX_BTREE == (storage)->idx_type && H5D_COPS_BTREE == (storage)->ops) || \ + (H5D_CHUNK_IDX_SINGLE == (storage)->idx_type && H5D_COPS_SINGLE == (storage)->ops) || \ + (H5D_CHUNK_IDX_NONE == (storage)->idx_type && H5D_COPS_NONE == (storage)->ops)); \ + } while (0) /* * Feature: If this constant is defined then every cache preemption and load * causes a character to be printed on the standard error stream: @@ -345,7 +346,7 @@ const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{ /*******************/ /* "nonexistent" storage layout I/O ops */ -const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = { +static const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = { {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5D__nonexistent_readvv, NULL, NULL, NULL, NULL}}; /* Declare a free list to manage the H5F_rdcc_ent_ptr_t sequence information */ @@ -355,7 +356,7 @@ H5FL_SEQ_DEFINE_STATIC(H5D_rdcc_ent_ptr_t); H5FL_DEFINE_STATIC(H5D_rdcc_ent_t); /* Declare a free list to manage the H5D_chunk_info_t struct */ -H5FL_DEFINE(H5D_chunk_map_t); +H5FL_DEFINE_STATIC(H5D_chunk_map_t); /* Declare a free list to manage the H5D_piece_info_t struct */ H5FL_DEFINE(H5D_piece_info_t); @@ -590,7 +591,7 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage /* Allocate dataspace and initialize it if it hasn't been. */ if (!(*layout->ops->is_space_alloc)(&layout->storage)) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Calculate the index of this chunk */ H5VM_chunk_scaled(dset->shared->ndims, offset, layout->u.chunk.dim, scaled); @@ -1107,7 +1108,7 @@ H5D__chunk_io_init(H5D_io_info_t *io_info, H5D_dset_io_info_t *dinfo) done: if (file_space_normalized == TRUE) if (H5S_hyper_denormalize_offset(dinfo->file_space, old_offset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't denormalize selection") + HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't denormalize selection"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_init() */ @@ -1311,15 +1312,15 @@ done: if (tmp_mspace && !fm->mchunk_tmpl) if (H5S_close(tmp_mspace) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, - "can't release memory chunk dataspace template") + "can't release memory chunk dataspace template"); if (H5D__chunk_io_term(io_info, dinfo) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping"); } /* end if */ if (iter_init && H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); if (file_type && (H5T_close_real(file_type) < 0)) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Can't free temporary datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Can't free temporary datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_io_init_selections() */ @@ -1758,7 +1759,7 @@ H5D__create_piece_file_map_all(H5D_dset_io_info_t *di, H5D_io_info_t *io_info) done: /* Clean up */ if (tmp_fchunk && H5S_close(tmp_fchunk) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_chunk_file_map_all() */ @@ -1893,7 +1894,7 @@ H5D__create_piece_file_map_hyper(H5D_dset_io_info_t *dinfo, H5D_io_info_t *io_in /* Leave if we are done */ if (sel_points == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Increment chunk index */ @@ -1937,7 +1938,7 @@ done: /* Clean up on failure */ if (ret_value < 0) if (tmp_fchunk && H5S_close(tmp_fchunk) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release temporary dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__create_piece_file_map_hyper() */ @@ -2634,7 +2635,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info) /* Different blocks depending on whether we're using selection I/O */ if (io_info->use_select_io == H5D_SELECTION_IO_MODE_ON) { - size_t num_chunks; + size_t num_chunks = 0; size_t element_sizes[2] = {dset_info->type_info.src_type_size, 0}; void *bufs[2] = {dset_info->buf.vp, NULL}; @@ -2739,7 +2740,7 @@ H5D__chunk_read(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info) /* Issue selection I/O call (we can skip the page buffer because we've * already verified it won't be used, and the metadata accumulator * because this is raw data) */ - H5_CHECK_OVERFLOW(num_chunks, size_t, uint32_t) + H5_CHECK_OVERFLOW(num_chunks, size_t, uint32_t); if (H5F_shared_select_read(H5F_SHARED(dset_info->dset->oloc.file), H5FD_MEM_DRAW, (uint32_t)num_chunks, chunk_mem_spaces, chunk_file_spaces, chunk_addrs, element_sizes, bufs) < 0) @@ -2952,7 +2953,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info) /* Different blocks depending on whether we're using selection I/O */ if (io_info->use_select_io == H5D_SELECTION_IO_MODE_ON) { - size_t num_chunks; + size_t num_chunks = 0; size_t element_sizes[2] = {dset_info->type_info.dst_type_size, 0}; const void *bufs[2] = {dset_info->buf.cvp, NULL}; @@ -3125,7 +3126,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_info) /* Issue selection I/O call (we can skip the page buffer because we've * already verified it won't be used, and the metadata accumulator * because this is raw data) */ - H5_CHECK_OVERFLOW(num_chunks, size_t, uint32_t) + H5_CHECK_OVERFLOW(num_chunks, size_t, uint32_t); if (H5F_shared_select_write(H5F_SHARED(dset_info->dset->oloc.file), H5FD_MEM_DRAW, (uint32_t)num_chunks, chunk_mem_spaces, chunk_file_spaces, chunk_addrs, element_sizes, bufs) < 0) @@ -3416,7 +3417,7 @@ H5D__chunk_dest(H5D_t *dset) /* Continue even if there are failures. */ if (nerrors) - HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") + HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks"); /* Release cache structures */ if (rdcc->slot) @@ -3551,7 +3552,7 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda /* Check that the scaled offset is the same */ for (u = 0; u < udata->common.layout->ndims; u++) if (last->scaled[u] != udata->common.scaled[u]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Retrieve the information from the cache */ udata->chunk_block.offset = last->addr; @@ -3560,7 +3561,7 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda udata->filter_mask = last->filter_mask; /* Indicate that the data was found */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ done: @@ -3727,8 +3728,7 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udat udata->idx_hint = idx; udata->chunk_block.offset = ent->chunk_block.offset; udata->chunk_block.length = ent->chunk_block.length; - ; - udata->chunk_idx = ent->chunk_idx; + udata->chunk_idx = ent->chunk_idx; } /* end if */ else { /* Invalidate idx_hint, to signal that the chunk is not in cache */ @@ -4023,7 +4023,7 @@ H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush) if (flush) { /* Flush */ if (H5D__chunk_flush_entry(dset, ent, TRUE) < 0) - HDONE_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") + HDONE_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer"); } /* end if */ else { /* Don't flush, just free chunk */ @@ -4577,7 +4577,7 @@ H5D__chunk_lock(const H5D_io_info_t H5_ATTR_NDEBUG_UNUSED *io_info, const H5D_ds done: /* Release the fill buffer info, if it's been initialized */ if (fb_info_init && H5D__fill_term(&fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, NULL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, NULL, "Can't release fill buffer info"); /* Release the chunk allocated, on error */ if (!ret_value) @@ -4845,7 +4845,7 @@ H5D__chunk_allocate(const H5D_t *dset, hbool_t full_overwrite, const hsize_t old if (space_dim[op_dim] == 0) { /* Reset any cached chunk info for this dataset */ H5D__chunk_cinfo_cache_reset(&dset->shared->cache.chunk.last); - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ #ifdef H5_HAVE_PARALLEL @@ -5229,7 +5229,7 @@ H5D__chunk_allocate(const H5D_t *dset, hbool_t full_overwrite, const hsize_t old done: /* Release the fill buffer info, if it's been initialized */ if (fb_info_init && H5D__fill_term(&fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); /* Free the unfiltered fill value buffer */ unfilt_fill_buf = H5D__chunk_mem_xfree(unfilt_fill_buf, &def_pline); @@ -5300,7 +5300,7 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) if ((space_dim[op_dim] < chunk_dim[op_dim]) || old_dim[op_dim] == 0) { /* Reset any cached chunk info for this dataset */ H5D__chunk_cinfo_cache_reset(&dset->shared->cache.chunk.last); - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Set up chunked I/O info object, for operations on chunks (in callback). @@ -5538,8 +5538,8 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_fill_info_t *chunk_ } if (need_sort) - HDqsort(chunk_fill_info->chunk_info, chunk_fill_info->num_chunks, - sizeof(struct chunk_coll_fill_info), H5D__chunk_cmp_coll_fill_info); + qsort(chunk_fill_info->chunk_info, chunk_fill_info->num_chunks, + sizeof(struct chunk_coll_fill_info), H5D__chunk_cmp_coll_fill_info); /* Allocate buffer for block lengths if necessary */ if (!all_same_block_len) @@ -5663,7 +5663,7 @@ done: if (have_xfer_mode) /* Set transfer mode */ if (H5CX_set_io_xfer_mode(prev_xfer_mode) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode") + HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set transfer mode"); /* free things */ if (MPI_BYTE != file_type) @@ -5736,7 +5736,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) /* If this chunk does not exist in cache or on disk, no need to do anything */ if (!H5_addr_defined(chk_udata.chunk_block.offset) && UINT_MAX == chk_udata.idx_hint) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Initialize the fill value buffer, if necessary */ if (!udata->fb_info_init) { @@ -5806,7 +5806,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) done: /* Release the selection iterator */ if (chunk_iter_init && H5S_SELECT_ITER_RELEASE(chunk_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (chunk_iter) chunk_iter = H5FL_FREE(H5S_sel_iter_t, chunk_iter); @@ -5964,7 +5964,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) if (old_dim[op_dim] == 0) { /* Reset any cached chunk info for this dataset */ H5D__chunk_cinfo_cache_reset(&dset->shared->cache.chunk.last); - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Round up to the next integer # of chunks, to accommodate partial chunks */ @@ -6237,10 +6237,10 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) done: /* Release resources */ if (chunk_space && H5S_close(chunk_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace"); if (udata_init) if (udata.fb_info_init && H5D__fill_term(&udata.fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_prune_by_extent() */ @@ -6387,10 +6387,10 @@ done: /* Clean up any messages read in */ if (pline_read) if (H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message"); if (layout_read) if (H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_delete() */ @@ -6734,13 +6734,13 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file") /* Set metadata tag in API context */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Insert chunk record into index */ if (need_insert && udata->idx_info_dst->storage->ops->insert) if ((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst, NULL) < 0) HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, - "unable to insert chunk addr into index") + "unable to insert chunk addr into index"); /* Reset metadata tag in API context */ H5_END_TAG @@ -7006,13 +7006,13 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk done: if (sid_buf > 0 && H5I_dec_ref(sid_buf) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID"); if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (buf) H5MM_xfree(buf); if (bkg) @@ -7024,7 +7024,7 @@ done: if (copy_setup_done) if (storage_src->ops->copy_shutdown && (storage_src->ops->copy_shutdown)(storage_src, storage_dst) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to shut down index copying info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to shut down index copying info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_copy() */ @@ -7094,11 +7094,11 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, hsize_ done: /* Free resources, if they've been initialized */ if (idx_info_init && sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info"); if (pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message"); if (space && H5S_close(space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_bh_info() */ @@ -7224,7 +7224,7 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) FUNC_ENTER_PACKAGE_NOERR if (!H5DEBUG(AC)) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); if (headers) { fprintf(H5DEBUG(AC), "H5D: raw data cache statistics\n"); @@ -7302,7 +7302,7 @@ H5D__nonexistent_readvv_cb(hsize_t H5_ATTR_UNUSED dst_off, hsize_t src_off, size done: /* Release the fill buffer info, if it's been initialized */ if (fb_info_init && H5D__fill_term(&fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); FUNC_LEAVE_NOAPI(ret_value) } /* H5D__nonexistent_readvv_cb() */ diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index aec476a..04e4357 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -141,7 +141,7 @@ H5D__compact_fill(const H5D_t *dset) done: /* Release the fill buffer info, if it's been initialized */ if (fb_info_init && H5D__fill_term(&fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__compact_fill() */ @@ -628,13 +628,13 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds done: if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID"); if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (buf) buf = H5FL_BLK_FREE(type_conv, buf); if (reclaim_buf) diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 27f903c..f9b36bd 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -288,7 +288,7 @@ H5D__contig_fill(H5D_t *dset) * still participate in following MPI_Barrier. */ blocks_written = TRUE; - HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") + HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset"); break; } } @@ -325,7 +325,7 @@ H5D__contig_fill(H5D_t *dset) done: /* Release the fill buffer info, if it's been initialized */ if (fb_info_init && H5D__fill_term(&fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__contig_fill() */ @@ -667,13 +667,13 @@ H5D__contig_io_init(H5D_io_info_t *io_info, H5D_dset_io_info_t *dinfo) done: if (ret_value < 0) { if (H5D__contig_io_term(io_info, dinfo) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataset I/O info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataset I/O info"); } /* end if */ if (file_space_normalized) { /* (Casting away const OK -QAK) */ if (H5S_hyper_denormalize_offset(dinfo->file_space, old_offset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") + HDONE_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1352,8 +1352,8 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void /* Prepend to existing sieve buffer */ if ((addr + len) == sieve_start) { /* Move existing sieve information to correct location */ - HDmemmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, - dset_contig->sieve_size); + memmove(dset_contig->sieve_buf + len, dset_contig->sieve_buf, + dset_contig->sieve_size); /* Copy in new information (must be first in sieve buffer) */ H5MM_memcpy(dset_contig->sieve_buf, buf, len); @@ -1835,13 +1835,13 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f done: if (buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID"); if (tid_src > 0 && H5I_dec_ref(tid_src) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (buf) buf = H5FL_BLK_FREE(type_conv, buf); if (reclaim_buf) diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 4c0cd16..1cf6ef3 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -144,7 +144,7 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t done: if (H5I_INVALID_HID == ret_value) if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset"); FUNC_LEAVE_API(ret_value) } /* end H5Dcreate1() */ @@ -200,7 +200,7 @@ H5Dopen1(hid_t loc_id, const char *name) done: if (H5I_INVALID_HID == ret_value) if (dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset"); FUNC_LEAVE_API(ret_value) } /* end H5Dopen1() */ @@ -286,7 +286,7 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) done: /* Close the dataspace */ if (sid != H5I_INVALID_HID && H5I_dec_app_ref(sid) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close dataspace"); FUNC_LEAVE_API(ret_value) } /* end H5Dextend() */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index aa2f047..e468ffb 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -321,7 +321,7 @@ H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ - H5_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); + H5F_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); /* Advance native element pointer */ elmt++; @@ -361,7 +361,7 @@ H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ - H5_addr_decode_len(ctx->file_addr_len, &raw, elmt); + H5F_addr_decode_len(ctx->file_addr_len, &raw, elmt); /* Advance native element pointer */ elmt++; @@ -458,7 +458,7 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ - H5_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); + H5F_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); UINT64ENCODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); UINT32ENCODE(raw, elmt->filter_mask); @@ -501,7 +501,7 @@ H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ - H5_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); + H5F_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); UINT64DECODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); UINT32DECODE(raw, elmt->filter_mask); @@ -612,7 +612,7 @@ done: /* Close object header */ if (obj_opened) if (H5O_close(&obj_loc, NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -700,7 +700,7 @@ H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info) done: /* Release the object header from the cache */ if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_idx_depend() */ @@ -1500,7 +1500,7 @@ H5D__earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Create the extensible array that describes chunked storage in the dest. file */ if (H5D__earray_idx_create(idx_info_dst) < 0) diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index 24d9154..4a18d98 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -319,7 +319,7 @@ H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ - H5_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); + H5F_addr_encode_len(ctx->file_addr_len, (uint8_t **)&raw, *elmt); /* Advance native element pointer */ elmt++; @@ -359,7 +359,7 @@ H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ - H5_addr_decode_len(ctx->file_addr_len, &raw, elmt); + H5F_addr_decode_len(ctx->file_addr_len, &raw, elmt); /* Advance native element pointer */ elmt++; @@ -464,7 +464,7 @@ done: /* Close object header */ if (obj_opened) if (H5O_close(&obj_loc, NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -554,7 +554,7 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx while (nelmts) { /* Encode element */ /* (advances 'raw' pointer) */ - H5_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); + H5F_addr_encode_len(ctx->file_addr_len, &raw, elmt->addr); UINT64ENCODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); UINT32ENCODE(raw, elmt->filter_mask); @@ -597,7 +597,7 @@ H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx while (nelmts) { /* Decode element */ /* (advances 'raw' pointer) */ - H5_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); + H5F_addr_decode_len(ctx->file_addr_len, &raw, &elmt->addr); UINT64DECODE_VAR(raw, elmt->nbytes, ctx->chunk_size_len); UINT32DECODE(raw, elmt->filter_mask); @@ -696,7 +696,7 @@ H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info) done: /* Release the object header from the cache */ if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_idx_depend() */ @@ -1358,7 +1358,7 @@ H5D__farray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Create the fixed array that describes chunked storage in the dest. file */ if (H5D__farray_idx_create(idx_info_dst) < 0) diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 84095c9..db0989c 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -269,19 +269,19 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ done: if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); if (src_id != (-1) && H5I_dec_ref(src_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (dst_id != (-1) && H5I_dec_ref(dst_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (tmp_buf) tmp_buf = H5FL_BLK_FREE(type_conv, tmp_buf); if (elem_wb && H5WB_unwrap(elem_wb) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer"); if (bkg_elem_wb && H5WB_unwrap(bkg_elem_wb) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer"); if (bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); @@ -480,7 +480,7 @@ done: /* Cleanup on error */ if (ret_value < 0) if (H5D__fill_term(fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__fill_init() */ @@ -548,11 +548,11 @@ done: /* Free dynamically allocated VL elements in fill buffer */ if (fb_info->fill->type) { if (H5T_vlen_reclaim_elmt(buf, fb_info->fill->type) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element"); } /* end if */ else { if (H5T_vlen_reclaim_elmt(buf, fb_info->mem_type) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't reclaim vlen element"); } /* end else */ /* Free temporary fill buffer */ diff --git a/src/H5Dint.c b/src/H5Dint.c index e2629e9..9c74d45 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -30,6 +30,7 @@ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VMprivate.h" /* Vector Functions */ /****************/ /* Local Macros */ @@ -467,9 +468,9 @@ done: if (ret_value == NULL) if (new_dset != NULL) { if (new_dset->dcpl_id != 0 && H5I_dec_ref(new_dset->dcpl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID"); if (new_dset->dapl_id != 0 && H5I_dec_ref(new_dset->dapl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "can't decrement temporary datatype ID"); new_dset = H5FL_FREE(H5D_shared_t, new_dset); } /* end if */ @@ -665,7 +666,7 @@ H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) done: if (FAIL == ret_value) *minimize = FALSE; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5D__use_minimized_dset_headers */ /*------------------------------------------------------------------------- @@ -783,7 +784,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5D__calculate_minimum_header_size */ /*------------------------------------------------------------------------- @@ -823,7 +824,7 @@ H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't apply object header to file") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5D__prepare_minimized_oh */ /*------------------------------------------------------------------------- @@ -1021,14 +1022,14 @@ done: /* Release pointer to object header itself */ if (oh != NULL) if (H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header"); /* Error cleanup */ if (ret_value < 0) if (layout_init) /* Destroy the layout information for the dataset */ if (dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__update_oh_info() */ @@ -1328,48 +1329,48 @@ done: if (new_dset->shared) { if (layout_init) if (new_dset->shared->layout.ops->dest && (new_dset->shared->layout.ops->dest)(new_dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy layout info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy layout info"); if (pline_copied) if (H5O_msg_reset(H5O_PLINE_ID, &new_dset->shared->dcpl_cache.pline) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset I/O pipeline info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset I/O pipeline info"); if (layout_copied) if (H5O_msg_reset(H5O_LAYOUT_ID, &new_dset->shared->layout) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset layout info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset layout info"); if (fill_copied) if (H5O_msg_reset(H5O_FILL_ID, &new_dset->shared->dcpl_cache.fill) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset fill-value info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset fill-value info"); if (efl_copied) if (H5O_msg_reset(H5O_EFL_ID, &new_dset->shared->dcpl_cache.efl) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset external file list info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset external file list info"); if (new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace"); if (new_dset->shared->type) { if (new_dset->shared->type_id > 0) { if (H5I_dec_ref(new_dset->shared->type_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype"); } /* end if */ else { if (H5T_close_real(new_dset->shared->type) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype"); } /* end else */ } /* end if */ if (H5_addr_defined(new_dset->oloc.addr)) { if (H5O_dec_rc_by_loc(&(new_dset->oloc)) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, - "unable to decrement refcount on newly created object") + "unable to decrement refcount on newly created object"); if (H5O_close(&(new_dset->oloc), NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header"); if (file) { if (H5O_delete(file, new_dset->oloc.addr) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header"); } /* end if */ } /* end if */ if (new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list"); if (new_dset->shared->dapl_id != 0 && H5I_dec_ref(new_dset->shared->dapl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list"); new_dset->shared->extfile_prefix = (char *)H5MM_xfree(new_dset->shared->extfile_prefix); new_dset->shared->vds_prefix = (char *)H5MM_xfree(new_dset->shared->vds_prefix); new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); @@ -1433,7 +1434,7 @@ H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id) done: if (!ret_value) if (loc_found && H5G_loc_free(&dset_loc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__open_name() */ @@ -1820,21 +1821,21 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) done: if (ret_value < 0) { if (H5_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc), NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header"); if (dataset->shared) { if (layout_init) if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info"); if (dataset->shared->space && H5S_close(dataset->shared->space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace"); if (dataset->shared->type) { if (dataset->shared->type_id > 0) { if (H5I_dec_ref(dataset->shared->type_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype"); } /* end if */ else { if (H5T_close_real(dataset->shared->type) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype"); } /* end else */ } /* end if */ } /* end if */ @@ -1877,7 +1878,7 @@ H5D_close(H5D_t *dataset) /* Flush the dataset's information. Continue to close even if it fails. */ if (H5D__flush_real(dataset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") + HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info"); /* Set a flag to indicate the dataset is closing, before we start freeing things */ /* (Avoids problems with flushing datasets twice, when one is holding @@ -1932,7 +1933,7 @@ H5D_close(H5D_t *dataset) if (dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) { assert(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset != dataset); if (H5D_close(dataset->shared->layout.storage.u.virt.list[i].source_dset.dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset"); dataset->shared->layout.storage.u.virt.list[i].source_dset.dset = NULL; } /* end if */ @@ -1944,7 +1945,7 @@ H5D_close(H5D_t *dataset) if (H5D_close(dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, - "unable to close source dataset") + "unable to close source dataset"); dataset->shared->layout.storage.u.virt.list[i].sub_dset[j].dset = NULL; } /* end if */ } /* end for */ @@ -1962,7 +1963,7 @@ H5D_close(H5D_t *dataset) /* Destroy any cached layout information for the dataset */ if (dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info"); /* Free the external file prefix */ dataset->shared->extfile_prefix = (char *)H5MM_xfree(dataset->shared->extfile_prefix); @@ -1979,10 +1980,10 @@ H5D_close(H5D_t *dataset) /* Uncork cache entries with object address tag */ if (H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status"); if (corked) if (H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object") + HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object"); /* Release datatype, dataspace, and creation and access property lists -- there isn't * much we can do if one of these fails, so we just continue. @@ -1993,21 +1994,21 @@ H5D_close(H5D_t *dataset) /* Remove the dataset from the list of opened objects in the file */ if (H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object"); if (H5FO_delete(dataset->oloc.file, dataset->oloc.addr) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects"); /* Close the dataset object */ /* (This closes the file, if this is the last object open) */ if (H5O_close(&(dataset->oloc), &file_closed) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header"); /* Evict dataset metadata if evicting on close */ if (!file_closed && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) { if (H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata"); if (H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE) < 0) - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata"); } /* end if */ /* @@ -2725,9 +2726,9 @@ H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size done: if (fspace && H5S_close(fspace) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); if (mspace && H5S_close(mspace) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); if (vlen_bufsize.common.fl_tbuf != NULL) vlen_bufsize.common.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.common.fl_tbuf); if (vlen_bufsize.common.vl_tbuf != NULL) @@ -2882,29 +2883,29 @@ H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id done: if (vlen_bufsize.fspace_id >= 0) { if (H5I_dec_app_ref(vlen_bufsize.fspace_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id"); vlen_bufsize.fspace = NULL; } /* end if */ if (vlen_bufsize.fspace && H5S_close(vlen_bufsize.fspace) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); if (vlen_bufsize.mspace_id >= 0) { if (H5I_dec_app_ref(vlen_bufsize.mspace_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "problem freeing id"); mspace = NULL; } /* end if */ if (mspace && H5S_close(mspace) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); if (vlen_bufsize.common.fl_tbuf != NULL) vlen_bufsize.common.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.common.fl_tbuf); if (vlen_bufsize.common.vl_tbuf != NULL) vlen_bufsize.common.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.common.vl_tbuf); if (vlen_bufsize.dxpl_id != H5I_INVALID_HID) { if (H5I_dec_app_ref(vlen_bufsize.dxpl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close property list") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close property list"); dxpl = NULL; } /* end if */ if (dxpl && H5P_close(dxpl) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release DXPL") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release DXPL"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__vlen_get_buf_size_gen() */ @@ -3373,30 +3374,30 @@ done: /* Remove new layout message */ if (add_new_layout) if (H5O_msg_remove(&dataset->oloc, H5O_LAYOUT_ID, H5O_ALL, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete layout message") + HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete layout message"); /* Add back old layout message */ if (delete_old_layout) if (H5O_msg_create(&dataset->oloc, H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &dataset->shared->layout) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to add layout header message") + HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to add layout header message"); /* Clean up v1 b-tree chunk index */ if (init_new_index) { if (H5_addr_defined(new_idx_info.storage->idx_addr)) { /* Check for valid address i.e. tag */ if (!H5_addr_defined(dataset->oloc.addr)) - HDONE_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "address undefined") + HDONE_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "address undefined"); /* 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)) - HDONE_ERROR(H5E_DATASET, H5E_CANTEXPUNGE, FAIL, "unable to expunge index metadata") + HDONE_ERROR(H5E_DATASET, H5E_CANTEXPUNGE, FAIL, "unable to expunge index metadata"); } /* end if */ /* Delete v1 B-tree chunk index */ if (new_idx_info.storage->ops->dest && (new_idx_info.storage->ops->dest)(&new_idx_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info"); } /* end if */ } /* end if */ @@ -3461,7 +3462,7 @@ done: /* Release pointer to object header */ if (oh != NULL) if (H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") + HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mark() */ @@ -3699,7 +3700,7 @@ done: if (ret_value < 0) if (new_dcpl_id > 0) if (H5I_dec_app_ref(new_dcpl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_create_plist() */ @@ -3820,7 +3821,7 @@ done: if (ret_value < 0) if (new_dapl_id > 0) if (H5I_dec_app_ref(new_dapl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_access_plist() */ @@ -3859,7 +3860,7 @@ done: if (ret_value < 0) if (space != NULL) if (H5S_close(space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_space() */ @@ -3913,7 +3914,7 @@ H5D__get_type(const H5D_t *dset) done: if (ret_value < 0) if (dt && H5T_close(dt) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_type() */ @@ -3959,7 +3960,7 @@ done: /* Release hold on (source) virtual datasets' files */ if (virt_dsets_held) if (H5D__virtual_release_source_dset_files(head) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't release VDS source files held open") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't release VDS source files held open"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__refresh() */ diff --git a/src/H5Dio.c b/src/H5Dio.c index 099a9c0..24c7be9 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -288,7 +288,7 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) /* If no datasets have I/O, we're done */ if (io_op_init == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Perform second phase of type info initialization */ if (H5D__typeinfo_init_phase2(&io_info) < 0) @@ -395,7 +395,7 @@ H5D__read(size_t count, H5D_dset_io_info_t *dset_info) } else { /* Call selection I/O directly */ - H5_CHECK_OVERFLOW(io_info.pieces_added, size_t, uint32_t) + H5_CHECK_OVERFLOW(io_info.pieces_added, size_t, uint32_t); if (H5F_shared_select_read(io_info.f_sh, H5FD_MEM_DRAW, (uint32_t)io_info.pieces_added, io_info.mem_spaces, io_info.file_spaces, io_info.addrs, io_info.element_sizes, io_info.rbufs) < 0) @@ -424,11 +424,11 @@ done: for (i = 0; i < io_op_init; i++) if (!dset_info[i].skip_io && dset_info[i].layout_ops.io_term && (*dset_info[i].layout_ops.io_term)(&io_info, &(dset_info[i])) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info") + HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info"); /* Shut down datatype info for operation */ if (H5D__typeinfo_term(&io_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info") + HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info"); /* Discard projected mem spaces and restore originals */ if (orig_mem_space) { @@ -436,7 +436,7 @@ done: if (orig_mem_space[i]) { if (H5S_close(dset_info[i].mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, - "unable to shut down projected memory dataspace") + "unable to shut down projected memory dataspace"); dset_info[i].mem_space = orig_mem_space[i]; } @@ -797,7 +797,7 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) } else { /* Call selection I/O directly */ - H5_CHECK_OVERFLOW(io_info.pieces_added, size_t, uint32_t) + H5_CHECK_OVERFLOW(io_info.pieces_added, size_t, uint32_t); if (H5F_shared_select_write(io_info.f_sh, H5FD_MEM_DRAW, (uint32_t)io_info.pieces_added, io_info.mem_spaces, io_info.file_spaces, io_info.addrs, io_info.element_sizes, io_info.wbufs) < 0) @@ -827,36 +827,18 @@ H5D__write(size_t count, H5D_dset_io_info_t *dset_info) #endif /* H5_HAVE_PARALLEL */ } -#ifdef OLD_WAY - /* - * This was taken out because it can be called in a parallel program with - * independent access, causing the metadata cache to get corrupted. Its been - * disabled for all types of access (serial as well as parallel) to make the - * modification time consistent for all programs. -QAK - * - * We should set a value in the dataset's shared information instead and flush - * it to the file when the dataset is being closed. -QAK - */ - /* - * Update modification time. We have to do this explicitly because - * writing to a dataset doesn't necessarily change the object header. - */ - if (H5O_touch(&(dataset->oloc), FALSE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time") -#endif /* OLD_WAY */ - done: /* Shut down the I/O op information */ for (i = 0; i < io_op_init; i++) { assert(!dset_info[i].skip_io); if (dset_info[i].layout_ops.io_term && (*dset_info[i].layout_ops.io_term)(&io_info, &(dset_info[i])) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info") + HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info"); } /* Shut down datatype info for operation */ if (H5D__typeinfo_term(&io_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info") + HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down type info"); /* Discard projected mem spaces and restore originals */ if (orig_mem_space) { @@ -864,7 +846,7 @@ done: if (orig_mem_space[i]) { if (H5S_close(dset_info[i].mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, - "unable to shut down projected memory dataspace") + "unable to shut down projected memory dataspace"); dset_info[i].mem_space = orig_mem_space[i]; } diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 1b7511e..21f52a4 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -551,7 +551,7 @@ done: if (layout_init) /* Destroy any cached layout information for the dataset */ if (dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__layout_oh_create() */ @@ -570,7 +570,7 @@ herr_t H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) { htri_t msg_exists; /* Whether a particular type of message exists */ - hbool_t pline_copied = FALSE; /* Flag to indicate that pline's message was copied */ + hbool_t pline_copied = FALSE; /* Flag to indicate that dcpl_cache.pline's message was copied */ hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ hbool_t efl_copied = FALSE; /* Flag to indicate that the EFL message was copied */ herr_t ret_value = SUCCEED; /* Return value */ @@ -646,13 +646,13 @@ done: if (ret_value < 0) { if (pline_copied) if (H5O_msg_reset(H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset pipeline info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset pipeline info"); if (layout_copied) if (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info"); if (efl_copied) if (H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset efl message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset efl message"); } FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_oh_read() */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 83366fb..812e748 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -1318,8 +1318,8 @@ done: /* Close debugging log file */ if (debug_log_file) { fprintf(debug_log_file, "##############\n\n"); - if (EOF == HDfclose(debug_log_file)) - HDONE_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "couldn't close debugging log file") + if (EOF == fclose(debug_log_file)) + HDONE_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "couldn't close debugging log file"); debug_stream = H5DEBUG(D); } #endif @@ -1476,8 +1476,8 @@ H5D__link_piece_collective_io(H5D_io_info_t *io_info, int H5_ATTR_UNUSED mpi_ran /* Sort sel_pieces if necessary */ if (need_sort) - HDqsort(io_info->sel_pieces, io_info->pieces_added, sizeof(io_info->sel_pieces[0]), - H5D__cmp_piece_addr); + qsort(io_info->sel_pieces, io_info->pieces_added, sizeof(io_info->sel_pieces[0]), + H5D__cmp_piece_addr); /* Allocate chunking information */ if (NULL == (chunk_mtype = (MPI_Datatype *)H5MM_malloc(num_chunk * sizeof(MPI_Datatype)))) @@ -2127,7 +2127,7 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, H5D_dset_io_info_t *dset_ done: /* Reset collective opt mode */ if (H5CX_set_mpio_coll_opt(orig_coll_opt_mode) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't reset MPI-I/O collective_op property") + HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't reset MPI-I/O collective_op property"); /* Free memory */ if (chunk_io_option) @@ -2855,7 +2855,7 @@ H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_dset_io_info_t *di, uint8_t as for (ic = 0; ic < total_chunks; ic++) assign_io_mode[ic] = H5D_CHUNK_IO_MODE_COL; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ threshold_nproc_per_chunk = (unsigned)mpi_size * percent_nproc_per_chunk / 100; @@ -2880,7 +2880,7 @@ H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_dset_io_info_t *di, uint8_t as } /* end while */ /* Gather all the information */ - H5_CHECK_OVERFLOW(total_chunks, size_t, int) + H5_CHECK_OVERFLOW(total_chunks, size_t, int); if (MPI_SUCCESS != (mpi_code = MPI_Gather(io_mode_info, (int)total_chunks, MPI_BYTE, recv_io_mode_info, (int)total_chunks, MPI_BYTE, root, comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Gather failed", mpi_code) @@ -3159,8 +3159,8 @@ H5D__mpio_collective_filtered_chunk_io_setup(const H5D_io_info_t *io_info, const /* Ensure the chunk list is sorted in ascending order of offset in the file */ if (need_sort) - HDqsort(local_info_array, num_chunks_selected, sizeof(H5D_filtered_collective_io_info_t), - H5D__cmp_filtered_collective_io_info_entry); + qsort(local_info_array, num_chunks_selected, sizeof(H5D_filtered_collective_io_info_t), + H5D__cmp_filtered_collective_io_info_entry); #ifdef H5Dmpio_DEBUG H5D__mpio_dump_collective_filtered_chunk_list(local_info_array, num_chunks_selected, mpi_rank); @@ -3409,7 +3409,7 @@ H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chun if (NULL == (counts_disps_array = H5MM_malloc(2 * (size_t)mpi_size * sizeof(*counts_disps_array)))) { /* Push an error, but still participate in collective gather operation */ HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "couldn't allocate receive counts and displacements array") + "couldn't allocate receive counts and displacements array"); } else { /* Set the receive counts from the assigned chunks map */ @@ -3467,8 +3467,8 @@ H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chun memset(num_chunks_assigned_map, 0, (size_t)mpi_size * sizeof(*num_chunks_assigned_map)); /* Sort collective chunk list according to chunk index */ - HDqsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t), - H5D__cmp_chunk_redistribute_info); + qsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t), + H5D__cmp_chunk_redistribute_info); /* * Process all chunks in the collective chunk list. @@ -3549,8 +3549,8 @@ H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chun * algorithm may be devised that doesn't rely on frail sorting, * but the current implementation is a quick and naive approach. */ - HDqsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t), - H5D__cmp_chunk_redistribute_info_orig_owner); + qsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t), + H5D__cmp_chunk_redistribute_info_orig_owner); } if (all_ranks_involved) { @@ -3842,7 +3842,7 @@ H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk * future, this may become a problem and derived datatypes * will need to be used. */ - H5_CHECK_OVERFLOW(mod_data_size, size_t, int) + H5_CHECK_OVERFLOW(mod_data_size, size_t, int); /* Send modification data to new owner */ if (MPI_SUCCESS != @@ -3882,8 +3882,8 @@ H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "too many shared chunks in parallel filtered write operation") - H5_CHECK_OVERFLOW(num_send_requests, size_t, int) - H5_CHECK_OVERFLOW(num_msgs_incoming, size_t, int) + H5_CHECK_OVERFLOW(num_send_requests, size_t, int); + H5_CHECK_OVERFLOW(num_msgs_incoming, size_t, int); /* * Allocate receive buffer and MPI_Request arrays for non-blocking @@ -3919,7 +3919,7 @@ H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&status, MPI_BYTE, &msg_size))) HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements_x failed", mpi_code) - H5_CHECK_OVERFLOW(msg_size, MPI_Count, int) + H5_CHECK_OVERFLOW(msg_size, MPI_Count, int); #else int msg_size = 0; @@ -4067,7 +4067,7 @@ done: if (mem_iter) { if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release dataspace selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release dataspace selection iterator"); mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); } @@ -4162,7 +4162,7 @@ H5D__mpio_collective_filtered_chunk_common_io(H5D_filtered_collective_io_info_t */ if (num_chunks == 0) { if (mpi_size == 1) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); else { if (io_info->op_type == H5D_IO_OP_WRITE) coll_io_info.base_maddr.cvp = &fake_buf; @@ -4288,7 +4288,7 @@ H5D__mpio_collective_filtered_chunk_read(H5D_filtered_collective_io_info_t *chun if (NULL == (chunk_list[i].buf = H5MM_malloc(chunk_list[i].chunk_buf_size))) { /* Push an error, but participate in collective read */ - HDONE_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer") + HDONE_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer"); break; } @@ -4407,9 +4407,9 @@ done: /* Release the fill buffer info, if it's been initialized */ if (fb_info_init && H5D__fill_term(&fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); if (fill_space && (H5S_close(fill_space) < 0)) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space"); #ifdef H5Dmpio_DEBUG H5D_MPIO_TIME_STOP(mpi_rank); @@ -4526,7 +4526,7 @@ H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *ch if (NULL == chunk_list[i].buf) { /* Push an error, but participate in collective read */ - HDONE_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer") + HDONE_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer"); break; } @@ -4738,17 +4738,17 @@ H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *ch done: if (sel_iter) { if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator"); sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); } if (dataspace && (H5S_close(dataspace) < 0)) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace"); if (fill_space && (H5S_close(fill_space) < 0)) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space"); /* Release the fill buffer info, if it's been initialized */ if (fb_info_init && H5D__fill_term(&fb_info) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info"); /* On failure, try to free all resources used by entries in the chunk list */ if (ret_value < 0) { @@ -4841,7 +4841,7 @@ H5D__mpio_collective_filtered_chunk_reallocate(H5D_filtered_collective_io_info_t if (NULL == (counts_disps_array = H5MM_malloc(2 * (size_t)mpi_size * sizeof(*counts_disps_array)))) { /* Push an error, but still participate in collective gather operation */ HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "couldn't allocate receive counts and displacements array") + "couldn't allocate receive counts and displacements array"); } else { /* Set the receive counts from the assigned chunks map */ @@ -4935,8 +4935,8 @@ H5D__mpio_collective_filtered_chunk_reallocate(H5D_filtered_collective_io_info_t * ascending order of offset in the file */ if (need_sort) - HDqsort(chunk_list, chunk_list_num_entries, sizeof(H5D_filtered_collective_io_info_t), - H5D__cmp_filtered_collective_io_info_entry); + qsort(chunk_list, chunk_list_num_entries, sizeof(H5D_filtered_collective_io_info_t), + H5D__cmp_filtered_collective_io_info_entry); done: H5MM_free(gathered_array); @@ -5035,7 +5035,7 @@ H5D__mpio_collective_filtered_chunk_reinsert(H5D_filtered_collective_io_info_t * if (NULL == (counts_disps_array = H5MM_malloc(2 * (size_t)mpi_size * sizeof(*counts_disps_array)))) { /* Push an error, but still participate in collective gather operation */ HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "couldn't allocate receive counts and displacements array") + "couldn't allocate receive counts and displacements array"); } else { /* Set the receive counts from the assigned chunks map */ diff --git a/src/H5Dnone.c b/src/H5Dnone.c index 6b9ed91..3ade6ee 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -370,7 +370,7 @@ H5D__none_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_inf assert(idx_info_dst->storage); /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Allocate dataset chunks in the dest. file */ if (H5D__none_idx_create(idx_info_dst) < 0) diff --git a/src/H5Doh.c b/src/H5Doh.c index 0d6f08c..30d43fa 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -171,13 +171,13 @@ H5O__dset_isa(const H5O_t *oh) if ((exists = H5O_msg_exists_oh(oh, H5O_DTYPE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") else if (!exists) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Layout */ if ((exists = H5O_msg_exists_oh(oh, H5O_SDSPACE_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") else if (!exists) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -238,7 +238,7 @@ H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) done: if (NULL == ret_value) if (dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_open() */ @@ -284,7 +284,7 @@ H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) done: if (ret_value == NULL) if (dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_create() */ @@ -393,9 +393,9 @@ H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) done: /* Free messages, if they've been read in */ if (layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message"); if (efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_bh_info() */ @@ -429,7 +429,7 @@ H5O__dset_flush(void *_obj_ptr) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if (H5D__flush_real(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") + HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info"); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index 9d73002..e5743eb 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -464,7 +464,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset_ /* Check for NOOP read */ if (dset_info->nelmts == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Allocate the iterators */ if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) @@ -554,15 +554,15 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset_ done: /* Release selection iterators */ if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); if (bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (bkg_iter) bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter); @@ -606,7 +606,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset /* Check for NOOP write */ if (dset_info->nelmts == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Allocate the iterators */ if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) @@ -697,15 +697,15 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset done: /* Release selection iterators */ if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); if (bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (bkg_iter) bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter); @@ -834,7 +834,7 @@ H5D__scatgath_read_select(H5D_io_info_t *io_info) } /* Read data from all pieces */ - H5_CHECK_OVERFLOW(io_info->pieces_added, size_t, uint32_t) + H5_CHECK_OVERFLOW(io_info->pieces_added, size_t, uint32_t); if (H5F_shared_select_read(io_info->f_sh, H5FD_MEM_DRAW, (uint32_t)io_info->pieces_added, tmp_mem_spaces, io_info->file_spaces, io_info->addrs, io_info->element_sizes, tmp_bufs) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "selection read failed") @@ -922,7 +922,7 @@ H5D__scatgath_read_select(H5D_io_info_t *io_info) done: /* Release and free selection iterator */ if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); @@ -935,7 +935,7 @@ done: for (i = 0; i < io_info->pieces_added; i++) if (tmp_mem_spaces[i] != io_info->mem_spaces[i] && tmp_mem_spaces[i] && H5S_close(tmp_mem_spaces[i]) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "Can't close dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "Can't close dataspace"); H5MM_free(tmp_mem_spaces); tmp_mem_spaces = NULL; } @@ -1171,7 +1171,7 @@ H5D__scatgath_write_select(H5D_io_info_t *io_info) size_t j = 0; /* Index into array of background buffers */ /* Read data */ - H5_CHECK_OVERFLOW(bkg_pieces, size_t, uint32_t) + H5_CHECK_OVERFLOW(bkg_pieces, size_t, uint32_t); if (H5F_shared_select_read(io_info->f_sh, H5FD_MEM_DRAW, (uint32_t)bkg_pieces, bkg_mem_spaces, bkg_file_spaces, bkg_addrs, bkg_element_sizes, bkg_bufs) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "selection read to background buffer failed") @@ -1222,7 +1222,7 @@ H5D__scatgath_write_select(H5D_io_info_t *io_info) } /* Write data to disk */ - H5_CHECK_OVERFLOW(io_info->pieces_added, size_t, uint32_t) + H5_CHECK_OVERFLOW(io_info->pieces_added, size_t, uint32_t); if (H5F_shared_select_write(io_info->f_sh, H5FD_MEM_DRAW, (uint32_t)io_info->pieces_added, write_mem_spaces, io_info->file_spaces, io_info->addrs, io_info->element_sizes, write_bufs) < 0) @@ -1231,7 +1231,7 @@ H5D__scatgath_write_select(H5D_io_info_t *io_info) done: /* Release and free selection iterator */ if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); @@ -1244,7 +1244,7 @@ done: for (i = 0; i < spaces_added; i++) { assert(write_mem_spaces[i]); if (write_mem_spaces[i] != io_info->mem_spaces[i] && H5S_close(write_mem_spaces[i]) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "Can't close dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "Can't close dataspace"); } H5MM_free(write_mem_spaces); write_mem_spaces = NULL; @@ -1369,7 +1369,7 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_ /* Copy the data into the right place. */ for (i = 0; i < curr_nelmts; i++) { - HDmemmove(xubuf, xdbuf, copy_size); + memmove(xubuf, xdbuf, copy_size); /* Update pointers */ xdbuf += src_stride; @@ -1442,7 +1442,7 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info, uint8_t xsbuf = tconv_buf; xdbuf = tconv_buf; for (i = 0; i < nelmts; i++) { - HDmemmove(xdbuf, xsbuf, dst_stride); + memmove(xdbuf, xsbuf, dst_stride); /* Update pointers */ xsbuf += src_stride; diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 1c0cdfe..11e2e32 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -23,11 +23,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5VMprivate.h" /* Vector Functions */ /****************/ /* Local Macros */ @@ -234,11 +235,11 @@ H5D__select_io(const H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset_info done: /* Release selection iterators */ if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); if (file_iter) file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter); if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); if (mem_iter) mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); @@ -413,13 +414,13 @@ done: /* Release selection iterators */ if (src_sel_iter) { if (src_sel_iter_init && H5S_SELECT_ITER_RELEASE(src_sel_iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); src_sel_iter = H5FL_FREE(H5S_sel_iter_t, src_sel_iter); } if (dst_sel_iter) { if (dst_sel_iter_init && H5S_SELECT_ITER_RELEASE(dst_sel_iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); dst_sel_iter = H5FL_FREE(H5S_sel_iter_t, dst_sel_iter); } diff --git a/src/H5Dsingle.c b/src/H5Dsingle.c index 40238b5..12c776d 100644 --- a/src/H5Dsingle.c +++ b/src/H5Dsingle.c @@ -420,7 +420,7 @@ H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_i assert(idx_info_dst->storage); /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Set up information at the destination file */ if (H5D__single_idx_create(idx_info_dst) < 0) diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 716047d..cc24698 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -277,7 +277,7 @@ done: /* Free temporary space */ if (tmp_space) if (H5S_close(tmp_space) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "can't close dataspace") + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "can't close dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_virtual_check_mapping_post() */ @@ -318,7 +318,7 @@ H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) /* Do not update min_dims for "all" or "none" selections */ if ((sel_type == H5S_SEL_ALL) || (sel_type == H5S_SEL_NONE)) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Get rank of vspace */ if ((rank = H5S_GET_EXTENT_NDIMS(ent->source_dset.virtual_select)) < 0) @@ -478,7 +478,7 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) /* Number of entries */ tmp_nentries = (hsize_t)virt->list_nused; - H5F_ENCODE_LENGTH(f, heap_block_p, tmp_nentries) + H5F_ENCODE_LENGTH(f, heap_block_p, tmp_nentries); /* Encode each entry */ for (i = 0; i < virt->list_nused; i++) { @@ -502,7 +502,7 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) /* Checksum */ chksum = H5_checksum_metadata(heap_block, block_size - (size_t)4, 0); - UINT32ENCODE(heap_block_p, chksum) + UINT32ENCODE(heap_block_p, chksum); /* Insert block into global heap */ if (H5HG_insert(f, block_size, heap_block, &(virt->serial_list_hobjid)) < 0) @@ -670,7 +670,7 @@ done: /* Release allocated resources on failure */ if (ret_value < 0) if (H5D__virtual_reset_layout(layout) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset virtual layout") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset virtual layout"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_copy_layout() */ @@ -707,7 +707,7 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Free source_dset */ if (H5D__virtual_reset_source_dset(ent, &ent->source_dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset"); /* Free original source names */ (void)H5MM_xfree(ent->source_file_name); @@ -716,13 +716,13 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) /* Free sub_dset */ for (j = 0; j < ent->sub_dset_nalloc; j++) if (H5D__virtual_reset_source_dset(ent, &ent->sub_dset[j]) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset"); ent->sub_dset = H5MM_xfree(ent->sub_dset); /* Free source_select */ if (ent->source_select) if (H5S_close(ent->source_select) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection"); /* Free parsed_source_file_name */ H5D_virtual_free_parsed_name(ent->parsed_source_file_name); @@ -740,12 +740,12 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) /* Close access property lists */ if (virt->source_fapl >= 0) { if (H5I_dec_ref(virt->source_fapl) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source fapl") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source fapl"); virt->source_fapl = -1; } if (virt->source_dapl >= 0) { if (H5I_dec_ref(virt->source_dapl) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source dapl") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source dapl"); virt->source_dapl = -1; } @@ -927,7 +927,7 @@ done: /* Release resources */ if (src_file_open) if (H5F_efc_close(vdset->oloc.file, src_file) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "can't close source file") + HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "can't close source file"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_open_source_dset() */ @@ -955,7 +955,7 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, /* Free dataset */ if (source_dset->dset) { if (H5D_close(source_dset->dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close source dataset"); source_dset->dset = NULL; } /* end if */ @@ -983,14 +983,14 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, if (source_dset->clipped_virtual_select) { if (source_dset->clipped_virtual_select != source_dset->virtual_select) if (H5S_close(source_dset->clipped_virtual_select) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped virtual selection"); source_dset->clipped_virtual_select = NULL; } /* end if */ /* Free virtual selection */ if (source_dset->virtual_select) { if (H5S_close(source_dset->virtual_select) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection"); source_dset->virtual_select = NULL; } /* end if */ @@ -998,7 +998,7 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, if (source_dset->clipped_source_select) { if (source_dset->clipped_source_select != virtual_ent->source_select) if (H5S_close(source_dset->clipped_source_select) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release clipped source selection"); source_dset->clipped_source_select = NULL; } /* end if */ @@ -1078,7 +1078,7 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, s **p = '\0'; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_str_append() */ /*------------------------------------------------------------------------- @@ -1610,7 +1610,7 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) * numbers of datasets open */ if (H5D_close(storage->list[i].sub_dset[j].dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, - "unable to close source dataset") + "unable to close source dataset"); storage->list[i].sub_dset[j].dset = NULL; } /* end if */ } /* end else */ @@ -2613,7 +2613,7 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) /* Close projected memory space */ if (storage->list[i].sub_dset[j].projected_mem_space) { if (H5S_close(storage->list[i].sub_dset[j].projected_mem_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space"); storage->list[i].sub_dset[j].projected_mem_space = NULL; } /* end if */ } /* end if */ @@ -2621,7 +2621,7 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) /* Close projected memory space */ if (storage->list[i].source_dset.projected_mem_space) { if (H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space"); storage->list[i].source_dset.projected_mem_space = NULL; } /* end if */ @@ -2689,7 +2689,7 @@ done: if (projected_src_space) { assert(ret_value < 0); if (H5S_close(projected_src_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2815,12 +2815,12 @@ H5D__virtual_read(H5D_io_info_t H5_ATTR_NDEBUG_UNUSED *io_info, H5D_dset_io_info done: /* Cleanup I/O operation */ if (H5D__virtual_post_io(storage) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation"); /* Close fill space */ if (fill_space) if (H5S_close(fill_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_read() */ @@ -2886,7 +2886,7 @@ done: if (projected_src_space) { assert(ret_value < 0); if (H5S_close(projected_src_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close projected source space"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2962,7 +2962,7 @@ H5D__virtual_write(H5D_io_info_t H5_ATTR_NDEBUG_UNUSED *io_info, H5D_dset_io_inf done: /* Cleanup I/O operation */ if (H5D__virtual_post_io(storage) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't cleanup I/O operation"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_write() */ @@ -3076,7 +3076,7 @@ done: if (ret_value < 0) /* Release hold on files and delete list on error */ if (*head && H5D__virtual_release_source_dset_files(*head) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release source datasets' files held open") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release source datasets' files held open"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_hold_source_dset_files() */ @@ -3119,7 +3119,7 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) done: if (vol_obj && H5VL_free_object(vol_obj) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object") + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_refresh_source_dset() */ diff --git a/src/H5E.c b/src/H5E.c index cd8eaad..c89e494 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -449,7 +449,7 @@ H5E__register_class(const char *cls_name, const char *lib_name, const char *vers done: if (!ret_value) if (cls && H5E__free_class(cls) < 0) - HDONE_ERROR(H5E_ERROR, H5E_CANTRELEASE, NULL, "unable to free error class") + HDONE_ERROR(H5E_ERROR, H5E_CANTRELEASE, NULL, "unable to free error class"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__register_class() */ @@ -752,7 +752,7 @@ H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) done: if (!ret_value) if (msg && H5E__close_msg(msg, NULL) < 0) - HDONE_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, NULL, "unable to close error message") + HDONE_ERROR(H5E_ERROR, H5E_CANTCLOSEOBJ, NULL, "unable to close error message"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5E__create_msg() */ diff --git a/src/H5EA.c b/src/H5EA.c index 2c29473..0971695 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -95,7 +95,7 @@ const H5EA_class_t *const H5EA_client_class_g[] = { H5FL_DEFINE_STATIC(H5EA_t); /* Declare a PQ free list to manage the element */ -H5FL_BLK_DEFINE(ea_native_elmt); +H5FL_BLK_DEFINE_STATIC(ea_native_elmt); /*------------------------------------------------------------------------- * Function: H5EA__new @@ -151,10 +151,10 @@ H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata) done: if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to release extensible array header"); if (!ret_value) if (ea && H5EA_close(ea) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__new() */ @@ -200,7 +200,7 @@ H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata) done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA_create() */ @@ -238,7 +238,7 @@ H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata) done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA_open() */ @@ -350,7 +350,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned t hdr_dirty = TRUE; } /* end if */ else - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Protect index block */ @@ -406,7 +406,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned t iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Protect data block */ @@ -458,7 +458,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned t iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Protect super block */ @@ -505,7 +505,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned t } /* end if */ } /* end if */ else - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Adjust index to offset in data block */ @@ -543,7 +543,7 @@ H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned t sblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Protect data block page */ @@ -616,18 +616,19 @@ done: if (hdr_dirty) if (H5EA__hdr_modified(hdr) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, - "unable to mark extensible array header as modified") + "unable to mark extensible array header as modified"); /* Release resources */ if (iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block"); /* (Note: super blocks don't contain elements, so don't have a '*thing != sblock' check) */ if (sblock && H5EA__sblock_unprotect(sblock, sblock_cache_flags) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block"); if (dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block"); if (dblk_page && *thing != dblk_page && H5EA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to release extensible array data block page"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__lookup_elmt() */ @@ -690,7 +691,7 @@ H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt) done: /* Release resources */ if (thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA_set() */ @@ -752,7 +753,7 @@ H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt) done: /* Release thing */ if (thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA_get() */ @@ -943,7 +944,7 @@ H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata) done: /* Unprotect the header if an error occurred */ if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA_delete() */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index b0c67f3..383a215 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -263,7 +263,7 @@ H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE if (stored_chksum != computed_chksum) ret_value = FALSE; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__cache_hdr_verify_chksum() */ /*------------------------------------------------------------------------- @@ -338,7 +338,7 @@ H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_ H5F_DECODE_LENGTH(udata->f, image, hdr->stats.stored.nelmts); /* Number of elements 'realized' */ /* Internal information */ - H5_addr_decode(udata->f, &image, &hdr->idx_blk_addr); /* Address of index block */ + H5F_addr_decode(udata->f, &image, &hdr->idx_blk_addr); /* Address of index block */ /* Index block statistics */ if (H5_addr_defined(hdr->idx_blk_addr)) { @@ -385,7 +385,7 @@ done: /* Release resources */ if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__cache_hdr_deserialize() */ @@ -470,7 +470,7 @@ H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le H5F_ENCODE_LENGTH(f, image, hdr->stats.stored.nelmts); /* Number of elements 'realized' */ /* Internal information */ - H5_addr_encode(f, &image, hdr->idx_blk_addr); /* Address of index block */ + H5F_addr_encode(f, &image, hdr->idx_blk_addr); /* Address of index block */ /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -705,7 +705,7 @@ H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, hbo HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ - H5_addr_decode(hdr->f, &image, &arr_addr); + H5F_addr_decode(hdr->f, &image, &arr_addr); if (H5_addr_ne(arr_addr, hdr->addr)) HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") @@ -724,14 +724,14 @@ H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, hbo if (iblock->ndblk_addrs > 0) { /* Decode addresses of data blocks in index block */ for (u = 0; u < iblock->ndblk_addrs; u++) - H5_addr_decode(hdr->f, &image, &iblock->dblk_addrs[u]); + H5F_addr_decode(hdr->f, &image, &iblock->dblk_addrs[u]); } /* end if */ /* Decode super block addresses in index block */ if (iblock->nsblk_addrs > 0) { /* Decode addresses of super blocks in index block */ for (u = 0; u < iblock->nsblk_addrs; u++) - H5_addr_decode(hdr->f, &image, &iblock->sblk_addrs[u]); + H5F_addr_decode(hdr->f, &image, &iblock->sblk_addrs[u]); } /* end if */ /* Sanity check */ @@ -756,7 +756,7 @@ done: /* Release resources */ if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__cache_iblock_deserialize() */ @@ -826,7 +826,7 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = (uint8_t)iblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ - H5_addr_encode(f, &image, iblock->hdr->addr); + H5F_addr_encode(f, &image, iblock->hdr->addr); /* Internal information */ @@ -845,7 +845,7 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Encode addresses of data blocks in index block */ for (u = 0; u < iblock->ndblk_addrs; u++) - H5_addr_encode(f, &image, iblock->dblk_addrs[u]); + H5F_addr_encode(f, &image, iblock->dblk_addrs[u]); } /* end if */ /* Encode data block addresses in index block */ @@ -854,7 +854,7 @@ H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Encode addresses of super blocks in index block */ for (u = 0; u < iblock->nsblk_addrs; u++) - H5_addr_encode(f, &image, iblock->sblk_addrs[u]); + H5F_addr_encode(f, &image, iblock->sblk_addrs[u]); } /* end if */ /* Compute metadata checksum */ @@ -1108,7 +1108,7 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, hbo HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ - H5_addr_decode(udata->hdr->f, &image, &arr_addr); + H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5_addr_ne(arr_addr, udata->hdr->addr)) HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") @@ -1129,7 +1129,7 @@ H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, hbo /* Decode data block addresses */ for (u = 0; u < sblock->ndblks; u++) - H5_addr_decode(udata->hdr->f, &image, &sblock->dblk_addrs[u]); + H5F_addr_decode(udata->hdr->f, &image, &sblock->dblk_addrs[u]); /* Sanity check */ /* (allow for checksum not decoded yet) */ @@ -1153,7 +1153,7 @@ done: /* Release resources */ if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__cache_sblock_deserialize() */ @@ -1221,7 +1221,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = (uint8_t)sblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ - H5_addr_encode(f, &image, sblock->hdr->addr); + H5F_addr_encode(f, &image, sblock->hdr->addr); /* Offset of block in array */ UINT64ENCODE_VAR(image, sblock->block_off, sblock->hdr->arr_off_size); @@ -1240,7 +1240,7 @@ H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED /* Encode addresses of data blocks in super block */ for (u = 0; u < sblock->ndblks; u++) - H5_addr_encode(f, &image, sblock->dblk_addrs[u]); + H5F_addr_encode(f, &image, sblock->dblk_addrs[u]); /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -1517,7 +1517,7 @@ H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ - H5_addr_decode(udata->hdr->f, &image, &arr_addr); + H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5_addr_ne(arr_addr, udata->hdr->addr)) HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") @@ -1559,9 +1559,9 @@ done: /* Release resources */ if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block"); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__cache_dblock_deserialize() */ /*------------------------------------------------------------------------- @@ -1630,7 +1630,7 @@ H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = (uint8_t)dblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ - H5_addr_encode(f, &image, dblock->hdr->addr); + H5F_addr_encode(f, &image, dblock->hdr->addr); /* Offset of block in array */ UINT64ENCODE_VAR(image, dblock->block_off, dblock->hdr->arr_off_size); @@ -1815,7 +1815,6 @@ H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) /* Check arguments */ assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblock->cache_info.type == H5AC_EARRAY_DBLOCK); assert(fsf_size); @@ -1951,7 +1950,7 @@ done: /* Release resources */ if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__cache_dblk_page_deserialize() */ diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index 90be264..e9a53ca 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -136,9 +136,10 @@ H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, co done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to release extensible array debugging context"); if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__hdr_debug() */ @@ -251,11 +252,12 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to release extensible array debugging context"); if (iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block"); if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__iblock_debug() */ @@ -337,11 +339,12 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to release extensible array debugging context"); if (sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block"); if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__sblock_debug() */ @@ -413,11 +416,12 @@ H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to release extensible array debugging context"); if (dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block"); if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__dblock_debug() */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index d6fc8f5..a96768f 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -113,7 +113,7 @@ H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent) done: if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__dblk_page_alloc() */ @@ -173,12 +173,12 @@ done: if (inserted) if (H5AC_remove_entry(dblk_page) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, FAIL, - "unable to remove extensible array data block page from cache") + "unable to remove extensible array data block page from cache"); /* Destroy data block page */ if (H5EA__dblk_page_dest(dblk_page) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, - "unable to destroy extensible array data block page") + "unable to destroy extensible array data block page"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -242,7 +242,7 @@ done: H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to unprotect extensible array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + (unsigned long long)dblk_page->addr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__dblk_page_protect() */ diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index 6b73df9..ea11aa9 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -125,7 +125,7 @@ H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts) done: if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__dblock_alloc() */ @@ -211,18 +211,18 @@ done: if (inserted) if (H5AC_remove_entry(dblock) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, - "unable to remove extensible array data block from cache") + "unable to remove extensible array data block from cache"); /* Release data block's disk space */ if (H5_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, - "unable to release extensible array data block") + "unable to release extensible array data block"); /* Destroy data block */ if (H5EA__dblock_dest(dblock) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, - "unable to destroy extensible array data block") + "unable to destroy extensible array data block"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -319,7 +319,7 @@ done: H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to unprotect extensible array data block, address = %llu", - (unsigned long long)dblock->addr) + (unsigned long long)dblock->addr); } FUNC_LEAVE_NOAPI(ret_value) @@ -412,7 +412,7 @@ done: /* Finished deleting data block in metadata cache */ if (dblock && H5EA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__dblock_delete() */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index 41ff397..9a95610 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -127,7 +127,7 @@ H5EA__hdr_alloc(H5F_t *f) done: if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__hdr_alloc() */ @@ -431,17 +431,17 @@ done: if (inserted) if (H5AC_remove_entry(hdr) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, - "unable to remove extensible array header from cache") + "unable to remove extensible array header from cache"); /* Release header's disk space */ if (H5_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_EARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free extensible array header"); /* Destroy header */ if (H5EA__hdr_dest(hdr) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, - "unable to destroy extensible array header") + "unable to destroy extensible array header"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index da362ea..eacb7a9 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -140,7 +140,7 @@ H5EA__iblock_alloc(H5EA_hdr_t *hdr) done: if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__iblock_alloc() */ @@ -241,18 +241,18 @@ done: if (inserted) if (H5AC_remove_entry(iblock) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, - "unable to remove extensible array index block from cache") + "unable to remove extensible array index block from cache"); /* Release index block's disk space */ if (H5_addr_defined(iblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, - "unable to release file space for extensible array index block") + "unable to release file space for extensible array index block"); /* Destroy index block */ if (H5EA__iblock_dest(iblock) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, - "unable to destroy extensible array index block") + "unable to destroy extensible array index block"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -308,7 +308,7 @@ done: H5AC_unprotect(hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to unprotect extensible array index block, address = %llu", - (unsigned long long)iblock->addr) + (unsigned long long)iblock->addr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -422,7 +422,7 @@ done: /* Finished deleting index block in metadata cache */ if (iblock && H5EA__iblock_unprotect(iblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__iblock_delete() */ diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index 118941f..677a0f3 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -152,7 +152,7 @@ H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx) done: if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__sblock_alloc() */ @@ -232,18 +232,18 @@ done: if (inserted) if (H5AC_remove_entry(sblock) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, - "unable to remove extensible array super block from cache") + "unable to remove extensible array super block from cache"); /* Release super block's disk space */ if (H5_addr_defined(sblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_SBLOCK, sblock->addr, (hsize_t)sblock->size) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, - "unable to release extensible array super block") + "unable to release extensible array super block"); /* Destroy super block */ if (H5EA__sblock_dest(sblock) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, - "unable to destroy extensible array super block") + "unable to destroy extensible array super block"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -308,7 +308,7 @@ done: H5AC_unprotect(hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to unprotect extensible array super block, address = %llu", - (unsigned long long)sblock->addr) + (unsigned long long)sblock->addr); } FUNC_LEAVE_NOAPI(ret_value) @@ -386,7 +386,7 @@ done: /* Finished deleting super block in metadata cache */ if (sblock && H5EA__sblock_unprotect(sblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5EA__sblock_delete() */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index 4c4845a..f15f2ee 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -416,34 +416,34 @@ H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2 /* Compare creation parameters for array */ if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) - HGOTO_DONE(1) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5ES.c b/src/H5ES.c index d57302f..7370b89 100644 --- a/src/H5ES.c +++ b/src/H5ES.c @@ -139,7 +139,7 @@ done: if (ret_value < 0) /* Release newly created connector */ if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") + HDONE_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector"); FUNC_LEAVE_API(ret_value) } /* end H5ESinsert_request() */ diff --git a/src/H5ESevent.c b/src/H5ESevent.c index 5328012..b18ea58 100644 --- a/src/H5ESevent.c +++ b/src/H5ESevent.c @@ -94,7 +94,7 @@ H5ES__event_new(H5VL_t *connector, void *token) /* Create vol object for token */ if (NULL == (request = H5VL_create_object(token, connector))) { if (H5VL_request_free(token) < 0) - HDONE_ERROR(H5E_EVENTSET, H5E_CANTFREE, NULL, "can't free request") + HDONE_ERROR(H5E_EVENTSET, H5E_CANTFREE, NULL, "can't free request"); HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINIT, NULL, "can't create vol object for request token") } /* end if */ @@ -109,7 +109,7 @@ H5ES__event_new(H5VL_t *connector, void *token) ret_value = ev; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5ES__event_new() */ /*------------------------------------------------------------------------- diff --git a/src/H5ESint.c b/src/H5ESint.c index c3d781a..6109b17 100644 --- a/src/H5ESint.c +++ b/src/H5ESint.c @@ -225,7 +225,7 @@ H5ES__create(void) done: if (!ret_value) if (es && H5ES__close(es) < 0) - HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, NULL, "unable to free event set") + HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, NULL, "unable to free event set"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5ES__create() */ @@ -297,7 +297,7 @@ done: if (ev_inserted) H5ES__list_remove(&es->active, ev); if (H5ES__event_free(ev) < 0) - HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release event") + HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release event"); } FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Eint.c b/src/H5Eint.c index b2d731e..6dddb70 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -198,7 +198,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) /* Check for bad pointer(s), but can't issue error, just leave */ if (!maj_ptr || !min_ptr) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); if (maj_ptr->msg) maj_str = maj_ptr->msg; @@ -317,7 +317,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) /* Check for bad pointer(s), but can't issue error, just leave */ if (!maj_ptr || !min_ptr) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); if (maj_ptr->msg) maj_str = maj_ptr->msg; @@ -330,7 +330,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) /* Check for bad pointer(s), but can't issue error, just leave */ if (!cls_ptr) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); /* Print error class header if new class */ if (eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name) != 0) { @@ -652,11 +652,11 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin /* Use the vasprintf() routine, since it does what we're trying to do below */ if (HDvasprintf(&tmp, fmt, ap) < 0) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); /* Push the error on the stack */ if (H5E__push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); done: if (va_started) @@ -711,7 +711,7 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line if (estack == NULL) if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); /* * Don't fail if arguments are bad. Instead, substitute some default @@ -732,13 +732,13 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line if (estack->nused < H5E_NSLOTS) { /* Increment the IDs to indicate that they are used in this stack */ if (H5I_inc_ref(cls_id, FALSE) < 0) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); estack->slot[estack->nused].cls_id = cls_id; if (H5I_inc_ref(maj_id, FALSE) < 0) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); estack->slot[estack->nused].maj_num = maj_id; if (H5I_inc_ref(min_id, FALSE) < 0) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); estack->slot[estack->nused].min_num = min_id; /* The 'func' & 'file' strings are statically allocated (by the compiler) * there's no need to duplicate them. @@ -747,7 +747,7 @@ H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line estack->slot[estack->nused].file_name = file; estack->slot[estack->nused].line = line; if (NULL == (estack->slot[estack->nused].desc = H5MM_xstrdup(desc))) - HGOTO_DONE(FAIL) + HGOTO_DONE(FAIL); estack->nused++; } /* end if */ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 1d1c5b0..0491439 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -30,16 +30,20 @@ typedef struct H5E_t H5E_t; * error number, the minor error number, and a description of the error. */ #define HERROR(maj_id, min_id, ...) \ - H5E_printf_stack(NULL, __FILE__, __func__, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__) + do { \ + H5E_printf_stack(NULL, __FILE__, __func__, __LINE__, H5E_ERR_CLS_g, maj_id, min_id, __VA_ARGS__); \ + } while (0) /* * HCOMMON_ERROR macro, used by HDONE_ERROR and HGOTO_ERROR * (Shouldn't need to be used outside this header file) */ #define HCOMMON_ERROR(maj, min, ...) \ - HERROR(maj, min, __VA_ARGS__); \ - err_occurred = TRUE; \ - err_occurred = err_occurred; /* Shut GCC warnings up! */ + do { \ + HERROR(maj, min, __VA_ARGS__); \ + err_occurred = TRUE; \ + err_occurred = err_occurred; /* Shut GCC warnings up! */ \ + } while (0) /* * HDONE_ERROR macro, used to facilitate error reporting between a @@ -51,10 +55,10 @@ typedef struct H5E_t H5E_t; * without jumping to any labels) */ #define HDONE_ERROR(maj, min, ret_val, ...) \ - { \ + do { \ HCOMMON_ERROR(maj, min, __VA_ARGS__); \ ret_value = ret_val; \ - } + } while (0) /* * HGOTO_ERROR macro, used to facilitate error reporting between a @@ -66,7 +70,7 @@ typedef struct H5E_t H5E_t; #define HGOTO_ERROR(maj, min, ret_val, ...) \ { \ HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - HGOTO_DONE(ret_val) \ + HGOTO_DONE(ret_val); \ } /* @@ -74,11 +78,11 @@ typedef struct H5E_t H5E_t; * H5_END_TAG statements. Resets the metadata tag before leaving the function. */ #define HGOTO_ERROR_TAG(maj, min, ret_val, ...) \ - { \ + do { \ H5AC_tag(prv_tag, NULL); \ HCOMMON_ERROR(maj, min, __VA_ARGS__); \ - HGOTO_DONE(ret_val) \ - } + HGOTO_DONE(ret_val); \ + } while (0) /* * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER() @@ -87,20 +91,20 @@ typedef struct H5E_t H5E_t; * the `done' label. */ #define HGOTO_DONE(ret_val) \ - { \ + do { \ ret_value = ret_val; \ goto done; \ - } + } while (0) /* * HGOTO_DONE_TAG macro, used like HGOTO_DONE between H5_BEGIN_TAG and * H5_END_TAG statements. Resets the metadata tag before leaving the function. */ #define HGOTO_DONE_TAG(ret_val) \ - { \ + do { \ H5AC_tag(prv_tag, NULL); \ - HGOTO_DONE(ret_val) \ - } + HGOTO_DONE(ret_val); \ + } while (0) /* * Macros handling system error messages as described in C standard. diff --git a/src/H5F.c b/src/H5F.c index 7b88519..19c134e 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -713,7 +713,7 @@ H5Fcreate_async(const char *app_file, const char *app_func, unsigned app_line, c H5ARG_TRACE8(__func__, "*s*sIu*sIuiii", app_file, app_func, app_line, filename, flags, fcpl_id, fapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID"); HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -890,7 +890,7 @@ H5Fopen_async(const char *app_file, const char *app_func, unsigned app_line, con H5ARG_TRACE7(__func__, "*s*sIu*sIuii", app_file, app_func, app_line, filename, flags, fapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID"); HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -1119,7 +1119,7 @@ H5Fclose_async(const char *app_file, const char *app_func, unsigned app_line, hi done: if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't decrement ref count on connector") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); FUNC_LEAVE_API(ret_value) } /* end H5Fclose_async() */ @@ -1294,9 +1294,9 @@ done: if (grp) { assert(loc_vol_obj); if (H5VL_group_close(loc_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to release group") + HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to release group"); if (H5VL_free_object(loc_vol_obj) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object"); } /* end if */ FUNC_LEAVE_API(ret_value) @@ -1390,9 +1390,9 @@ done: if (grp) { assert(loc_vol_obj); if (H5VL_group_close(loc_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to release group") + HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to release group"); if (H5VL_free_object(loc_vol_obj) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object"); } /* end if */ FUNC_LEAVE_API(ret_value) @@ -1526,7 +1526,7 @@ H5Freopen_async(const char *app_file, const char *app_func, unsigned app_line, h H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, file_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID"); HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ diff --git a/src/H5FA.c b/src/H5FA.c index 3ae9c4d..26895b1 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -139,10 +139,10 @@ H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata) done: if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, "unable to release fixed array header"); if (!ret_value) if (fa && H5FA_close(fa) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__new() */ @@ -188,7 +188,7 @@ H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA_create() */ @@ -226,7 +226,7 @@ H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata) done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA_open() */ @@ -381,13 +381,13 @@ done: /* Check for header modified */ if (hdr_dirty) if (H5FA__hdr_modified(hdr) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as modified") + HDONE_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as modified"); /* Release resources */ if (dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block"); if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA_set() */ @@ -450,7 +450,7 @@ H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt) HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") /* We've retrieved the value, leave now */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ else { /* get the page */ size_t dblk_page_nelmts; /* # of elements in a data block page */ @@ -486,9 +486,9 @@ H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt) done: if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block"); if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA_get() */ @@ -634,7 +634,7 @@ H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata) done: /* Unprotect the header if an error occurred */ if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA_delete() */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index df7121f..18c83cf 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -272,7 +272,7 @@ H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len H5F_DECODE_LENGTH(udata->f, image, hdr->cparam.nelmts); /* Number of elements */ /* Internal information */ - H5_addr_decode(udata->f, &image, &hdr->dblk_addr); /* Address of index block */ + H5F_addr_decode(udata->f, &image, &hdr->dblk_addr); /* Address of index block */ /* Check for data block */ if (H5_addr_defined(hdr->dblk_addr)) { @@ -317,7 +317,7 @@ done: /* Release resources */ if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__cache_hdr_deserialize() */ @@ -392,7 +392,7 @@ H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED le H5F_ENCODE_LENGTH(f, image, hdr->stats.nelmts); /* Number of elements for the fixed array */ /* Internal information */ - H5_addr_encode(f, &image, hdr->dblk_addr); /* Address of fixed array data block */ + H5F_addr_encode(f, &image, hdr->dblk_addr); /* Address of fixed array data block */ /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -645,7 +645,7 @@ H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HGOTO_ERROR(H5E_FARRAY, H5E_BADTYPE, NULL, "incorrect fixed array class") /* Address of header for array that owns this block (just for file integrity checks) */ - H5_addr_decode(udata->hdr->f, &image, &arr_addr); + H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5_addr_ne(arr_addr, udata->hdr->addr)) HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array header address") @@ -687,7 +687,7 @@ done: /* Release resources */ if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__cache_dblock_deserialize() */ @@ -758,7 +758,7 @@ H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED *image++ = (uint8_t)dblock->hdr->cparam.cls->id; /* Address of array header for array which owns this block */ - H5_addr_encode(f, &image, dblock->hdr->addr); + H5F_addr_encode(f, &image, dblock->hdr->addr); /* Page init flags */ if (dblock->npages > 0) { @@ -927,7 +927,6 @@ H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) /* Check arguments */ assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblock->cache_info.type == H5AC_FARRAY_DBLOCK); assert(fsf_size); @@ -1064,7 +1063,7 @@ done: /* Release resources */ if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__cache_dblk_page_deserialize() */ diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c index 44fda03..a62b530 100644 --- a/src/H5FAdbg.c +++ b/src/H5FAdbg.c @@ -127,9 +127,9 @@ H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, co done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context"); if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__hdr_debug() */ @@ -257,11 +257,11 @@ H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context"); if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block"); if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__dblock_debug() */ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index bd714cc..4d40882 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -116,7 +116,7 @@ done: if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__dblk_page_alloc() */ @@ -183,11 +183,11 @@ done: if (inserted) if (H5AC_remove_entry(dblk_page) < 0) HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, FAIL, - "unable to remove fixed array data block page from cache") + "unable to remove fixed array data block page from cache"); /* Destroy data block page */ if (H5FA__dblk_page_dest(dblk_page) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "unable to destroy fixed array data block page"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -256,7 +256,7 @@ done: H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, "unable to unprotect fixed array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + (unsigned long long)dblk_page->addr); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index ccf4a72..a5489f1 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -152,7 +152,7 @@ H5FA__dblock_alloc(H5FA_hdr_t *hdr) done: if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__dblock_alloc() */ @@ -228,16 +228,18 @@ done: if (inserted) if (H5AC_remove_entry(dblock) < 0) HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, - "unable to remove fixed array data block from cache") + "unable to remove fixed array data block from cache"); /* Release data block's disk space */ if (H5_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release fixed array data block"); /* Destroy data block */ if (H5FA__dblock_dest(dblock) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy fixed array data block"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -383,7 +385,7 @@ done: /* Finished deleting data block in metadata cache */ if (dblock && H5FA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__dblock_delete() */ diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 712ca15..419a933 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -108,7 +108,7 @@ H5FA__hdr_alloc(H5F_t *f) done: if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__hdr_alloc() */ @@ -227,16 +227,16 @@ done: if (inserted) if (H5AC_remove_entry(hdr) < 0) HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, - "unable to remove fixed array header from cache") + "unable to remove fixed array header from cache"); /* Release header's disk space */ if (H5_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free Fixed Array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free Fixed Array header"); /* Destroy header */ if (H5FA__hdr_dest(hdr) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy Fixed Array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy Fixed Array header"); } FUNC_LEAVE_NOAPI(ret_value) @@ -518,7 +518,7 @@ H5FA__hdr_delete(H5FA_hdr_t *hdr) done: /* Unprotect the header, deleting it if an error hasn't occurred */ if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__hdr_delete() */ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 4da72c1..9a979b2 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -320,7 +320,7 @@ H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_a ret_value = ctx; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FA__test_crt_dbg_context() */ /*------------------------------------------------------------------------- @@ -345,7 +345,7 @@ H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam) cparam->raw_elmt_size = fa->hdr->cparam.raw_elmt_size; cparam->nelmts = fa->hdr->cparam.nelmts; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FA__get_cparam_test() */ /*------------------------------------------------------------------------- diff --git a/src/H5FD.c b/src/H5FD.c index 040ded2..473410d 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -929,26 +929,26 @@ 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) + HGOTO_DONE(0); if (!f1 || !f1->cls) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (!f2 || !f2->cls) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->cls < f2->cls) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->cls > f2->cls) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Files are same driver; no cmp callback */ if (!f1->cls->cmp) { if (f1 < f2) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1 > f2) - HGOTO_DONE(1) - HGOTO_DONE(0) + HGOTO_DONE(1); + HGOTO_DONE(0); } /* Dispatch to driver */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 0e07350..9c2f1a4 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -1034,57 +1034,57 @@ H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) /* Compare low level file information for backing store */ #ifdef H5_HAVE_WIN32_API if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->nFileIndexHigh < f2->nFileIndexHigh) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->nFileIndexHigh > f2->nFileIndexHigh) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->nFileIndexLow < f2->nFileIndexLow) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->nFileIndexLow > f2->nFileIndexLow) - HGOTO_DONE(1) + HGOTO_DONE(1); #else #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->device > f2->device) - HGOTO_DONE(1) + HGOTO_DONE(1); #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->inode > f2->inode) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif /*H5_HAVE_WIN32_API*/ } /* end if */ else { if (NULL == f1->name && NULL == f2->name) { if (f1 < f2) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1 > f2) - HGOTO_DONE(1) - HGOTO_DONE(0) + HGOTO_DONE(1); + HGOTO_DONE(0); } /* end if */ if (NULL == f1->name) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (NULL == f2->name) - HGOTO_DONE(1) + HGOTO_DONE(1); ret_value = HDstrcmp(f1->name, f2->name); } /* end else */ diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 3e58162..d3332c8 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -526,11 +526,11 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad * than the one where the program is running. */ /* NOTE: Use malloc and free here to ensure compatibility with - * HDposix_memalign. + * posix_memalign(). */ buf1 = malloc(sizeof(int)); - if (HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed") + if (posix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "posix_memalign failed") if (o_flags & O_CREAT) { if (HDwrite(file->fd, buf1, sizeof(int)) < 0) { @@ -635,36 +635,36 @@ H5FD__direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) #ifdef H5_HAVE_WIN32_API if (f1->fileindexhi < f2->fileindexhi) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->fileindexhi > f2->fileindexhi) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->fileindexlo < f2->fileindexlo) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->fileindexlo > f2->fileindexlo) - HGOTO_DONE(1) + HGOTO_DONE(1); #else #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->device > f2->device) - HGOTO_DONE(1) + HGOTO_DONE(1); #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->inode > f2->inode) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif @@ -896,8 +896,8 @@ H5FD__direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U if (alloc_size > _cbsize) alloc_size = _cbsize; assert(!(alloc_size % _fbsize)); - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") + if (posix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "posix_memalign failed") /* look for the aligned position for reading the data */ assert(!(((addr / _fbsize) * _fbsize) % _fbsize)); @@ -1074,8 +1074,8 @@ H5FD__direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_ alloc_size = _cbsize; assert(!(alloc_size % _fbsize)); - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") + if (posix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "posix_memalign failed") /* look for the right position for reading or writing the data */ if (HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0) diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 4cbb3a3..036bb4a 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -190,7 +190,7 @@ H5FD__family_get_default_config(H5FD_family_fapl_t *fa_out) done: if (ret_value < 0 && fa_out->memb_fapl_id >= 0) { if (H5I_dec_ref(fa_out->memb_fapl_id) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement ref. count on member FAPL ID") + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement ref. count on member FAPL ID"); } FUNC_LEAVE_NOAPI(ret_value) @@ -777,7 +777,7 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad file->memb[file->nmembs] = H5FDopen(memb_name, (0 == file->nmembs ? flags : t_flags), file->memb_fapl_id, HADDR_UNDEF); } - H5E_END_TRY; + H5E_END_TRY if (!file->memb[file->nmembs]) { if (0 == file->nmembs) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open member file") @@ -820,7 +820,7 @@ done: if (file->memb) H5MM_xfree(file->memb); if (H5I_dec_ref(file->memb_fapl_id) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID") + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID"); if (file->name) H5MM_xfree(file->name); H5MM_xfree(file); @@ -865,12 +865,12 @@ H5FD__family_close(H5FD_t *_file) } /* end for */ if (nerrors) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files"); /* Clean up other stuff */ if (H5I_dec_ref(file->memb_fapl_id) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID"); H5MM_xfree(file->memb); H5MM_xfree(file->name); H5MM_xfree(file); @@ -1023,7 +1023,7 @@ H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT, file->memb_fapl_id, (haddr_t)file->memb_size); } - H5E_END_TRY; + H5E_END_TRY if (NULL == file->memb[u]) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open member file") } /* end if */ @@ -1365,7 +1365,7 @@ H5FD__family_lock(H5FD_t *_file, hbool_t rw) for (v = 0; v < u; v++) { if (H5FD_unlock(file->memb[v]) < 0) /* Push error, but keep going */ - HDONE_ERROR(H5E_IO, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock member files") + HDONE_ERROR(H5E_IO, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock member files"); } /* end for */ HGOTO_ERROR(H5E_IO, H5E_CANTLOCKFILE, FAIL, "unable to lock member files") } /* end if */ @@ -1493,7 +1493,7 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) { delete_error = H5FD_delete(member_name, memb_fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (FAIL == delete_error) { if (0 == current_member) HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete member file") @@ -1512,7 +1512,7 @@ done: /* Only close memb_fapl_id if we created one from the default configuration */ if (default_fa.memb_fapl_id >= 0 && H5I_dec_ref(default_fa.memb_fapl_id) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement ref. count on member FAPL ID") + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement ref. count on member FAPL ID"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_delete() */ diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 80a06a4..61cbea7 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -449,12 +449,12 @@ done: handle->magic++; if (handle->file != NULL) if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close hdfs file handle") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close hdfs file handle"); if (handle->fileinfo != NULL) hdfsFreeFileInfo(handle->fileinfo, 1); if (handle->filesystem != NULL) if (FAIL == (hdfsDisconnect(handle->filesystem))) - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to disconnect from hdfs") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to disconnect from hdfs"); H5MM_xfree(handle); } @@ -491,12 +491,12 @@ H5FD__hdfs_handle_close(hdfs_t *handle) handle->magic++; if (handle->file != NULL) if (FAIL == (hdfsCloseFile(handle->filesystem, handle->file))) - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close hdfs file handle") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close hdfs file handle"); if (handle->fileinfo != NULL) hdfsFreeFileInfo(handle->fileinfo, 1); if (handle->filesystem != NULL) if (FAIL == (hdfsDisconnect(handle->filesystem))) - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to disconnect hdfs file system") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to disconnect hdfs file system"); H5MM_xfree(handle); @@ -767,7 +767,7 @@ hdfs__reset_stats(H5FD_hdfs_t *file) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* hdfs__reset_stats */ #endif /* HDFS_STATS */ @@ -848,7 +848,7 @@ done: if (ret_value == NULL) { if (handle != NULL) if (FAIL == H5FD__hdfs_handle_close(handle)) - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close HDFS file handle") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, NULL, "unable to close HDFS file handle"); if (file != NULL) file = H5FL_FREE(H5FD_hdfs_t, file); } /* end if null return value (error) */ @@ -1109,7 +1109,7 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* hdfs__fprint_stats */ #endif /* HDFS_STATS */ diff --git a/src/H5FDint.c b/src/H5FDint.c index 5dece6f..d202a94 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -35,6 +35,7 @@ #include "H5FDpkg.h" /* File Drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5PLprivate.h" /* Plugins */ /****************/ @@ -229,7 +230,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /* * collective transfer. */ if (0 == size) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); #endif /* H5_HAVE_PARALLEL */ /* If the file is open for SWMR read access, allow access to data past @@ -291,7 +292,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void * collective transfer. */ if (0 == size) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); #endif /* H5_HAVE_PARALLEL */ if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) @@ -354,8 +355,8 @@ H5FD_read_vector(H5FD_t *file, uint32_t count, H5FD_mem_t types[], haddr_t addrs hbool_t extend_sizes = FALSE; hbool_t extend_types = FALSE; uint32_t i; - size_t size; - H5FD_mem_t type; + size_t size = 0; + H5FD_mem_t type = H5FD_MEM_DEFAULT; hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */ herr_t ret_value = SUCCEED; /* Return value */ @@ -385,7 +386,7 @@ H5FD_read_vector(H5FD_t *file, uint32_t count, H5FD_mem_t types[], haddr_t addrs * collective transfer. */ if (0 == count) { - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } #endif /* H5_HAVE_PARALLEL */ @@ -568,8 +569,8 @@ H5FD_write_vector(H5FD_t *file, uint32_t count, H5FD_mem_t types[], haddr_t addr hbool_t extend_sizes = FALSE; hbool_t extend_types = FALSE; uint32_t i; - size_t size; - H5FD_mem_t type; + size_t size = 0; + H5FD_mem_t type = H5FD_MEM_DEFAULT; hid_t dxpl_id; /* DXPL for operation */ haddr_t eoa = HADDR_UNDEF; /* EOA for file */ herr_t ret_value = SUCCEED; /* Return value */ @@ -600,7 +601,7 @@ H5FD_write_vector(H5FD_t *file, uint32_t count, H5FD_mem_t types[], haddr_t addr * collective transfer. */ if (0 == count) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); #endif /* H5_HAVE_PARALLEL */ if (file->base_addr > 0) { @@ -754,9 +755,9 @@ H5FD__read_selection_translate(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uin hbool_t extend_sizes = FALSE; hbool_t extend_bufs = FALSE; uint32_t i; - size_t element_size; - void *buf; - hbool_t use_vector = FALSE; + size_t element_size = 0; + void *buf = NULL; + hbool_t use_vector = FALSE; haddr_t addrs_local[H5FD_LOCAL_VECTOR_LEN]; haddr_t *addrs = addrs_local; size_t sizes_local[H5FD_LOCAL_VECTOR_LEN]; @@ -992,7 +993,7 @@ H5FD__read_selection_translate(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uin /* Issue vector read call if appropriate */ if (use_vector) { - H5_CHECK_OVERFLOW(vec_arr_nused, size_t, uint32_t) + H5_CHECK_OVERFLOW(vec_arr_nused, size_t, uint32_t); if ((file->cls->read_vector)(file, dxpl_id, (uint32_t)vec_arr_nused, types, addrs, sizes, vec_bufs) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read vector request failed") @@ -1114,7 +1115,7 @@ H5FD_read_selection(H5FD_t *file, H5FD_mem_t type, uint32_t count, H5S_t **mem_s * collective transfer. */ if (0 == count) { - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } #endif /* H5_HAVE_PARALLEL */ @@ -1174,7 +1175,7 @@ H5FD_read_selection(H5FD_t *file, H5FD_mem_t type, uint32_t count, H5S_t **mem_s if ((file_space_ids[num_spaces] = H5I_register(H5I_DATASPACE, file_spaces[num_spaces], TRUE)) < 0) { if (NULL == H5I_remove(mem_space_ids[num_spaces])) - HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id") + HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id"); HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") } } @@ -1208,9 +1209,9 @@ done: */ for (i = 0; i < num_spaces; i++) { if (NULL == H5I_remove(mem_space_ids[i])) - HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id") + HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id"); if (NULL == H5I_remove(file_space_ids[i])) - HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id") + HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id"); } if (mem_space_ids != mem_space_ids_local) mem_space_ids = H5MM_xfree(mem_space_ids); @@ -1276,7 +1277,7 @@ H5FD_read_selection_id(H5FD_t *file, H5FD_mem_t type, uint32_t count, hid_t mem_ * collective transfer. */ if (0 == count) { - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } #endif /* H5_HAVE_PARALLEL */ @@ -1395,9 +1396,9 @@ H5FD__write_selection_translate(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, ui hbool_t extend_sizes = FALSE; hbool_t extend_bufs = FALSE; uint32_t i; - size_t element_size; - const void *buf; - hbool_t use_vector = FALSE; + size_t element_size = 0; + const void *buf = NULL; + hbool_t use_vector = FALSE; haddr_t addrs_local[H5FD_LOCAL_VECTOR_LEN]; haddr_t *addrs = addrs_local; size_t sizes_local[H5FD_LOCAL_VECTOR_LEN]; @@ -1633,7 +1634,7 @@ H5FD__write_selection_translate(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, ui /* Issue vector write call if appropriate */ if (use_vector) { - H5_CHECK_OVERFLOW(vec_arr_nused, size_t, uint32_t) + H5_CHECK_OVERFLOW(vec_arr_nused, size_t, uint32_t); if ((file->cls->write_vector)(file, dxpl_id, (uint32_t)vec_arr_nused, types, addrs, sizes, vec_bufs) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write vector request failed") @@ -1753,7 +1754,7 @@ H5FD_write_selection(H5FD_t *file, H5FD_mem_t type, uint32_t count, H5S_t **mem_ * collective transfer. */ if (0 == count) { - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } #endif /* H5_HAVE_PARALLEL */ @@ -1807,7 +1808,7 @@ H5FD_write_selection(H5FD_t *file, H5FD_mem_t type, uint32_t count, H5S_t **mem_ if ((file_space_ids[num_spaces] = H5I_register(H5I_DATASPACE, file_spaces[num_spaces], TRUE)) < 0) { if (NULL == H5I_remove(mem_space_ids[num_spaces])) - HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id") + HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id"); HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") } } @@ -1841,9 +1842,9 @@ done: */ for (i = 0; i < num_spaces; i++) { if (NULL == H5I_remove(mem_space_ids[i])) - HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id") + HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id"); if (NULL == H5I_remove(file_space_ids[i])) - HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id") + HDONE_ERROR(H5E_VFL, H5E_CANTREMOVE, FAIL, "problem removing id"); } if (mem_space_ids != mem_space_ids_local) mem_space_ids = H5MM_xfree(mem_space_ids); @@ -1906,7 +1907,7 @@ H5FD_write_selection_id(H5FD_t *file, H5FD_mem_t type, uint32_t count, hid_t mem * collective transfer. */ if (0 == count) { - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } #endif /* H5_HAVE_PARALLEL */ @@ -2276,7 +2277,7 @@ H5FD_sort_vector_io_req(hbool_t *vector_was_sorted, uint32_t _count, H5FD_mem_t } /* sort the srt_tmp array */ - HDqsort(srt_tmp, count, sizeof(struct H5FD_vsrt_tmp_t), H5FD__vsrt_tmp_cmp); + qsort(srt_tmp, count, sizeof(struct H5FD_vsrt_tmp_t), H5FD__vsrt_tmp_cmp); /* verify no duplicate entries */ i = 1; diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 62351f8..2f86609 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -770,7 +770,7 @@ H5FD__log_close(H5FD_t *_file) if (file->fa.flags & H5FD_LOG_FLAVOR) file->flavor = (unsigned char *)H5MM_xfree(file->flavor); if (file->logfp != stderr) - HDfclose(file->logfp); + fclose(file->logfp); } /* end if */ if (file->fa.logfile) @@ -806,40 +806,40 @@ H5FD__log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) #ifdef H5_HAVE_WIN32_API if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->nFileIndexHigh < f2->nFileIndexHigh) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->nFileIndexHigh > f2->nFileIndexHigh) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->nFileIndexLow < f2->nFileIndexLow) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->nFileIndexLow > f2->nFileIndexLow) - HGOTO_DONE(1) + HGOTO_DONE(1); #else #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->device > f2->device) - HGOTO_DONE(1) + HGOTO_DONE(1); #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->inode > f2->inode) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index 47d8cd3..1130fac 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -285,7 +285,7 @@ H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *_buf) assert(_buf && out); H5MM_memcpy(&n, _buf, sizeof(n)); - *out = (uint16_t)HDntohs(n); + *out = (uint16_t)ntohs(n); return 2; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint16() */ @@ -313,7 +313,7 @@ H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf) assert(_buf && out); H5MM_memcpy(&n, _buf, sizeof(n)); - *out = (uint32_t)HDntohl(n); + *out = (uint32_t)ntohl(n); return 4; /* number of bytes eaten */ } /* end H5FD__mirror_xmit_decode_uint32() */ @@ -422,7 +422,7 @@ H5FD__mirror_xmit_encode_uint16(unsigned char *_dest, uint16_t v) assert(_dest); - n = (uint16_t)HDhtons(v); + n = (uint16_t)htons(v); H5MM_memcpy(_dest, &n, sizeof(n)); return 2; @@ -449,7 +449,7 @@ H5FD__mirror_xmit_encode_uint32(unsigned char *_dest, uint32_t v) assert(_dest); - n = (uint32_t)HDhtonl(v); + n = (uint32_t)htonl(v); H5MM_memcpy(_dest, &n, sizeof(n)); return 4; @@ -1144,7 +1144,7 @@ done: if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_verify_reply() */ /* ------------------------------------------------------------------------- @@ -1285,7 +1285,7 @@ H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_dst /*out*/) H5MM_memcpy(fa_dst, fa_src, sizeof(H5FD_mirror_fapl_t)); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_mirror() */ /*------------------------------------------------------------------------- @@ -1378,17 +1378,17 @@ H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad /* Handshake with remote */ /* --------------------- */ - live_socket = HDsocket(AF_INET, SOCK_STREAM, 0); + live_socket = socket(AF_INET, SOCK_STREAM, 0); if (live_socket < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't create socket"); target_addr.sin_family = AF_INET; - target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port); - target_addr.sin_addr.s_addr = HDinet_addr(fa.remote_ip); + target_addr.sin_port = htons((uint16_t)fa.handshake_port); + target_addr.sin_addr.s_addr = inet_addr(fa.remote_ip); memset(target_addr.sin_zero, '\0', sizeof target_addr.sin_zero); addr_size = sizeof(target_addr); - if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) + if (connect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't connect to remote server"); /* ------------- */ @@ -1547,7 +1547,7 @@ done: static herr_t H5FD__mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) { - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR LOG_OP_CALL(__func__); @@ -1564,7 +1564,7 @@ H5FD__mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | H5FD_FEAT_SUPPORTS_SWMR_IO | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__mirror_query() */ /*------------------------------------------------------------------------- @@ -1860,7 +1860,7 @@ done: if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_lock */ /*------------------------------------------------------------------------- @@ -1904,7 +1904,7 @@ done: if (xmit_buf) xmit_buf = H5FL_BLK_FREE(xmit, xmit_buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mirror_unlock */ #endif /* H5_HAVE_MIRROR_VFD */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 555551d..e4a78b9 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -282,8 +282,8 @@ H5FD_mpio_init(void) /* Allow MPI buf-and-file-type optimizations? */ s = HDgetenv("HDF5_MPI_OPT_TYPES"); - if (s && HDisdigit(*s)) - H5FD_mpi_opt_types_g = (0 == HDstrtol(s, NULL, 0)) ? FALSE : TRUE; + if (s && isdigit(*s)) + H5FD_mpi_opt_types_g = (0 == strtol(s, NULL, 0)) ? FALSE : TRUE; #ifdef H5FDmpio_DEBUG /* Clear the flag buffer */ @@ -450,10 +450,10 @@ done: if (ret_value != SUCCEED) { if (comm) if (H5_mpi_comm_free(comm) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator") + HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator"); if (info) if (H5_mpi_info_free(info) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object") + HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object"); } FUNC_LEAVE_API(ret_value) @@ -968,9 +968,9 @@ done: if (file_opened) MPI_File_close(&fh); if (H5_mpi_comm_free(&comm) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI communicator") + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI communicator"); if (H5_mpi_info_free(&info) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI info object") + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, NULL, "unable to free MPI info object"); if (file) H5MM_xfree(file); } /* end if */ @@ -2932,9 +2932,9 @@ H5FD__mpio_delete(const char *filename, hid_t fapl_id) done: /* Free duplicated MPI Communicator and Info objects */ if (H5_mpi_comm_free(&comm) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free MPI communicator") + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free MPI communicator"); if (H5_mpi_info_free(&info) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free MPI info object") + HDONE_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "unable to free MPI info object"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__mpio_delete() */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index dc3f46a..1bccdaf 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -421,7 +421,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl { fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (!fa || (H5P_FILE_ACCESS_DEFAULT == fapl_id)) { if (H5FD_multi_populate_config(NULL, NULL, NULL, NULL, TRUE, &default_fa) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTSET, "can't setup default driver configuration", @@ -491,7 +491,7 @@ H5FD_split_populate_config(const char *meta_ext, hid_t meta_plist_id, const char _memb_name[mt] = NULL; _memb_addr[mt] = HADDR_UNDEF; } - END_MEMBERS; + END_MEMBERS /* The file access properties */ _memb_fapl[H5FD_MEM_SUPER] = meta_plist_id; @@ -555,7 +555,7 @@ H5FD_split_populate_config(const char *meta_ext, hid_t meta_plist_id, const char if (!_memb_name[mmt] || !_memb_name[mmt][0]) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); } - END_MEMBERS; + END_MEMBERS /* * Initialize driver specific information. No need to copy it into the FA @@ -577,7 +577,7 @@ H5FD_split_populate_config(const char *meta_ext, hid_t meta_plist_id, const char "can't set sec2 driver on member FAPL", -1); } } - END_MEMBERS; + END_MEMBERS return ret_value; } @@ -706,7 +706,7 @@ H5FD_multi_sb_size(H5FD_t *_file) UNIQUE_MEMBERS (file->fa.memb_map, mt) { nseen++; } - END_MEMBERS; + END_MEMBERS /* Addresses and EOA markers */ nbytes += nseen * 2 * 8; @@ -716,7 +716,7 @@ H5FD_multi_sb_size(H5FD_t *_file) size_t n = strlen(file->fa.memb_name[mt]) + 1; nbytes += (n + 7) & ~((size_t)0x0007); } - END_MEMBERS; + END_MEMBERS return nbytes; } @@ -784,7 +784,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out p += sizeof(haddr_t); nseen++; } - END_MEMBERS; + END_MEMBERS if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen * 2, buf + 8, NULL, H5P_DEFAULT) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1); @@ -797,7 +797,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out for (i = n; i % 8; i++) *p++ = '\0'; } - END_MEMBERS; + END_MEMBERS return 0; } /* end H5FD_multi_sb_encode() */ @@ -848,7 +848,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) memb_eoa[mt] = HADDR_UNDEF; memb_name[mt] = NULL; } - END_MEMBERS; + END_MEMBERS /* * Read the map and count the unique members. @@ -864,7 +864,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) UNIQUE_MEMBERS (map, mt) { nseen++; } - END_MEMBERS; + END_MEMBERS buf += 8; /* Decode Address and EOA values */ @@ -879,7 +879,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) memb_addr[_unmapped] = *ap++; memb_eoa[_unmapped] = *ap++; } - END_MEMBERS; + END_MEMBERS /* Decode name templates */ UNIQUE_MEMBERS (map, mt) { @@ -887,7 +887,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) memb_name[_unmapped] = (const char *)buf; buf += (n + 7) & ~((unsigned)0x0007); } - END_MEMBERS; + END_MEMBERS /* * Use the mapping saved in the superblock in preference to the one @@ -900,14 +900,14 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) ALL_MEMBERS (mt) { file->fa.memb_map[mt] = map[mt]; } - END_MEMBERS; + END_MEMBERS /* Close files which are unused now */ memset(in_use, 0, sizeof in_use); UNIQUE_MEMBERS (map, mt) { in_use[mt] = TRUE; } - END_MEMBERS; + END_MEMBERS ALL_MEMBERS (mt) { if (!in_use[mt] && file->memb[mt]) { (void)H5FDclose(file->memb[mt]); @@ -915,7 +915,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) } file->fa.memb_map[mt] = map[mt]; } - END_MEMBERS; + END_MEMBERS } /* Commit member starting addresses and name templates */ @@ -927,7 +927,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) file->fa.memb_name[mt] = my_strdup(memb_name[mt]); } } - END_MEMBERS; + END_MEMBERS if (compute_next(file) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1); @@ -945,7 +945,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) */ file->memb_eoa[mt] = memb_eoa[mt]; } - END_MEMBERS; + END_MEMBERS return 0; } /* end H5FD_multi_sb_decode() */ @@ -1016,7 +1016,7 @@ H5FD_multi_fapl_copy(const void *_old_fa) } } } - END_MEMBERS; + END_MEMBERS if (nerrors) { ALL_MEMBERS (mt) { @@ -1025,7 +1025,7 @@ H5FD_multi_fapl_copy(const void *_old_fa) if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]); } - END_MEMBERS; + END_MEMBERS free(new_fa); H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "can't release object on error", NULL); } @@ -1059,7 +1059,7 @@ H5FD_multi_fapl_free(void *_fa) if (fa->memb_name[mt]) free(fa->memb_name[mt]); } - END_MEMBERS; + END_MEMBERS free(fa); return 0; @@ -1108,7 +1108,7 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr { fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (!fa || (H5P_FILE_ACCESS_DEFAULT == fapl_id) || (H5FD_MULTI != H5Pget_driver(fapl_id))) { char *env = getenv(HDF5_DRIVER); @@ -1136,7 +1136,7 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr else file->fa.memb_name[mt] = NULL; } - END_MEMBERS; + END_MEMBERS file->fa.relax = fa->relax; file->flags = flags; file->name = my_strdup(name); @@ -1169,7 +1169,7 @@ error: if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); } - END_MEMBERS; + END_MEMBERS if (file->name) free(file->name); free(file); @@ -1211,7 +1211,7 @@ H5FD_multi_close(H5FD_t *_file) } } } - END_MEMBERS; + END_MEMBERS if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1); @@ -1222,7 +1222,7 @@ H5FD_multi_close(H5FD_t *_file) if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); } - END_MEMBERS; + END_MEMBERS free(file->name); free(file); @@ -1266,7 +1266,7 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) cmp = 1; } } - END_MEMBERS; + END_MEMBERS assert(cmp || out_mt < H5FD_MEM_NTYPES); if (out_mt >= H5FD_MEM_NTYPES) return cmp; @@ -1364,7 +1364,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) { memb_eoa = H5FDget_eoa(file->memb[mt], mt); } - H5E_END_TRY; + H5E_END_TRY if (HADDR_UNDEF == memb_eoa) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", @@ -1387,7 +1387,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) if (memb_eoa > eoa) eoa = memb_eoa; } - END_MEMBERS; + END_MEMBERS } else { H5FD_mem_t mmt = file->fa.memb_map[type]; @@ -1400,7 +1400,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) { eoa = H5FDget_eoa(file->memb[mmt], mmt); } - H5E_END_TRY; + H5E_END_TRY if (HADDR_UNDEF == eoa) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eoa", @@ -1478,7 +1478,7 @@ H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) { status = H5FDset_eoa(file->memb[mmt], mmt, (eoa - file->fa.memb_addr[mmt])); } - H5E_END_TRY; + H5E_END_TRY if (status < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1); @@ -1519,7 +1519,7 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) { tmp_eof = H5FDget_eof(file->memb[mt], type); } - H5E_END_TRY; + H5E_END_TRY if (HADDR_UNDEF == tmp_eof) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", @@ -1541,7 +1541,7 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) if (tmp_eof > eof) eof = tmp_eof; } - END_MEMBERS; + END_MEMBERS } else { H5FD_mem_t mmt = file->fa.memb_map[type]; @@ -1555,7 +1555,7 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) { eof = H5FDget_eof(file->memb[mmt], mmt); } - H5E_END_TRY; + H5E_END_TRY if (HADDR_UNDEF == eof) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", @@ -1636,7 +1636,7 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) if (file->memb[mt]) file->memb[mt]->paged_aggr = file->pub.paged_aggr; } - END_MEMBERS; + END_MEMBERS } if (HADDR_UNDEF == (addr = H5FDalloc(file->memb[mmt], mmt, dxpl_id, size))) @@ -1838,7 +1838,7 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) if (H5FDflush(file->memb[mt], dxpl_id, closing) < 0) nerrors++; } - H5E_END_TRY; + H5E_END_TRY } } if (nerrors) @@ -1876,7 +1876,7 @@ H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) if (H5FDtruncate(file->memb[mt], dxpl_id, closing) < 0) nerrors++; } - H5E_END_TRY; + H5E_END_TRY } } if (nerrors) @@ -1920,10 +1920,10 @@ H5FD_multi_lock(H5FD_t *_file, hbool_t rw) break; } /* end if */ } - H5E_END_TRY; + H5E_END_TRY } /* end if */ } - END_MEMBERS; + END_MEMBERS /* Try to unlock the member files that are locked before error is encountered */ if (nerrors) { @@ -1935,7 +1935,7 @@ H5FD_multi_lock(H5FD_t *_file, hbool_t rw) if (H5FDunlock(file->memb[k]) < 0) nerrors++; } - H5E_END_TRY; + H5E_END_TRY } /* end for */ } /* end if */ @@ -1972,7 +1972,7 @@ H5FD_multi_unlock(H5FD_t *_file) if (H5FDunlock(file->memb[mt]) < 0) nerrors++; } - END_MEMBERS; + END_MEMBERS if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTUNLOCKFILE, "error unlocking member files", -1); @@ -2001,7 +2001,7 @@ compute_next(H5FD_multi_t *file) ALL_MEMBERS (mt) { file->memb_next[mt] = HADDR_UNDEF; } - END_MEMBERS; + END_MEMBERS UNIQUE_MEMBERS (file->fa.memb_map, mt1) { UNIQUE_MEMBERS2(file->fa.memb_map, mt2) @@ -2011,12 +2011,12 @@ compute_next(H5FD_multi_t *file) file->memb_next[mt1] = file->fa.memb_addr[mt2]; } } - END_MEMBERS; + END_MEMBERS if (HADDR_UNDEF == file->memb_next[mt1]) { file->memb_next[mt1] = HADDR_MAX; /*last member*/ } } - END_MEMBERS; + END_MEMBERS return 0; } @@ -2064,13 +2064,13 @@ open_members(H5FD_multi_t *file) { file->memb[mt] = H5FDopen(tmp, file->flags, file->fa.memb_fapl[mt], HADDR_UNDEF); } - H5E_END_TRY; + H5E_END_TRY if (!file->memb[mt]) { if (!file->fa.relax || (file->flags & H5F_ACC_RDWR)) nerrors++; } } - END_MEMBERS; + END_MEMBERS if (nerrors) H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1); @@ -2107,7 +2107,7 @@ H5FD_multi_delete(const char *filename, hid_t fapl_id) { fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); } - H5E_END_TRY; + H5E_END_TRY if (!fa) { char *env = getenv(HDF5_DRIVER); @@ -2137,7 +2137,7 @@ H5FD_multi_delete(const char *filename, hid_t fapl_id) if (H5FDdelete(full_filename, fa->memb_fapl[mt]) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_BADVALUE, "error deleting member files", -1); } - END_MEMBERS; + END_MEMBERS return 0; } /* end H5FD_multi_delete() */ diff --git a/src/H5FDonion.c b/src/H5FDonion.c index ffee132..1daaeee 100644 --- a/src/H5FDonion.c +++ b/src/H5FDonion.c @@ -259,7 +259,7 @@ H5FD__onion_term(void) /* Reset VFL ID */ H5FD_ONION_g = 0; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__onion_term() */ @@ -535,7 +535,7 @@ done: H5MM_xfree(buf); H5MM_xfree(new_list); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_commit_new_revision_record() */ /*----------------------------------------------------------------------------- @@ -585,13 +585,13 @@ done: /* Destroy things as best we can, even if there were earlier errors */ if (file->original_file) if (H5FD_close(file->original_file) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close backing canon file") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close backing canon file"); if (file->onion_file) if (H5FD_close(file->onion_file) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close backing onion file") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close backing onion file"); if (file->recovery_file) { if (H5FD_close(file->recovery_file) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close backing recovery file") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close backing recovery file"); /* TODO: Use the VFD's del callback instead of remove (this requires * storing a copy of the fapl that was used to open it) */ @@ -599,7 +599,7 @@ done: } if (file->rev_index) if (H5FD__onion_revision_index_destroy(file->rev_index) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close revision index") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't close revision index"); H5MM_xfree(file->recovery_file_name); H5MM_xfree(file->history.record_locs); @@ -624,7 +624,7 @@ H5FD__onion_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_onion_t *file = (const H5FD_onion_t *)_file; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR FUNC_LEAVE_NOAPI(file->logical_eoa) } /* end H5FD__onion_get_eoa() */ @@ -642,7 +642,7 @@ H5FD__onion_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_onion_t *file = (const H5FD_onion_t *)_file; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR FUNC_LEAVE_NOAPI(file->logical_eof) } /* end H5FD__onion_get_eof() */ @@ -693,7 +693,7 @@ H5FD__onion_create_truncate_onion(H5FD_onion_t *file, const char *filename, cons size_t size = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(file != NULL); @@ -772,7 +772,7 @@ done: if (FAIL == ret_value) HDremove(recovery_file_nameery); /* destroy new temp file, if 'twas created */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_create_truncate_onion() */ static herr_t @@ -780,7 +780,7 @@ H5FD__onion_remove_unused_symbols(char *s) { char *d = s; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR do { while (*d == '{' || *d == '}' || *d == ' ') { @@ -788,7 +788,7 @@ H5FD__onion_remove_unused_symbols(char *s) } } while ((*s++ = *d++)); - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } static herr_t @@ -797,7 +797,7 @@ H5FD__onion_parse_config_str(const char *config_str, H5FD_onion_fapl_info_t *fa) char *config_str_copy = NULL; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE if (!HDstrcmp(config_str, "")) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "configure string can't be empty") @@ -817,7 +817,7 @@ H5FD__onion_parse_config_str(const char *config_str, H5FD_onion_fapl_info_t *fa) * e.g. {revision_num: 2; page_size: 4;} */ if (config_str[0] != '{') - fa->revision_num = (uint64_t)HDstrtoull(config_str, NULL, 10); + fa->revision_num = (uint64_t)strtoull(config_str, NULL, 10); else { char *token1 = NULL, *token2 = NULL; @@ -847,22 +847,22 @@ H5FD__onion_parse_config_str(const char *config_str, H5FD_onion_fapl_info_t *fa) else if (!strcmp(token2, "H5I_INVALID_HID")) fa->backing_fapl_id = H5I_INVALID_HID; else - fa->backing_fapl_id = HDstrtoll(token2, NULL, 10); + fa->backing_fapl_id = strtoll(token2, NULL, 10); } else if (!HDstrcmp(token1, "page_size")) { - fa->page_size = (uint32_t)HDstrtoul(token2, NULL, 10); + fa->page_size = (uint32_t)strtoul(token2, NULL, 10); } else if (!HDstrcmp(token1, "revision_num")) { if (!HDstrcmp(token2, "H5FD_ONION_FAPL_INFO_REVISION_ID_LATEST")) fa->revision_num = H5FD_ONION_FAPL_INFO_REVISION_ID_LATEST; else - fa->revision_num = (uint64_t)HDstrtoull(token2, NULL, 10); + fa->revision_num = (uint64_t)strtoull(token2, NULL, 10); } else if (!HDstrcmp(token1, "force_write_open")) { - fa->force_write_open = (uint8_t)HDstrtoul(token2, NULL, 10); + fa->force_write_open = (uint8_t)strtoul(token2, NULL, 10); } else if (!HDstrcmp(token1, "creation_flags")) { - fa->creation_flags = (uint8_t)HDstrtoul(token2, NULL, 10); + fa->creation_flags = (uint8_t)strtoul(token2, NULL, 10); } else if (!HDstrcmp(token1, "comment")) { HDstrcpy(fa->comment, token2); @@ -891,7 +891,7 @@ H5FD__onion_parse_config_str(const char *config_str, H5FD_onion_fapl_info_t *fa) done: H5MM_free(config_str_copy); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /*----------------------------------------------------------------------------- @@ -1029,7 +1029,7 @@ H5FD__onion_open(const char *filename, unsigned flags, hid_t fapl_id, haddr_t ma { file->onion_file = H5FD_open(name_onion, flags, backing_fapl_id, maxaddr); } - H5E_END_TRY; + H5E_END_TRY /* If that didn't work, create a new onion file */ /* TODO: Move to a new function */ @@ -1216,17 +1216,17 @@ done: if (file->original_file) if (H5FD_close(file->original_file) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy backing canon") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy backing canon"); if (file->onion_file) if (H5FD_close(file->onion_file) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy backing onion") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy backing onion"); if (file->recovery_file) if (H5FD_close(file->recovery_file) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy backing recov") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy backing recov"); if (file->rev_index) if (H5FD__onion_revision_index_destroy(file->rev_index) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy revision index") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, NULL, "can't destroy revision index"); H5MM_xfree(file->history.record_locs); @@ -1238,7 +1238,7 @@ done: H5MM_xfree(new_fa); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_open() */ /*----------------------------------------------------------------------------- @@ -1262,7 +1262,7 @@ H5FD__onion_open_rw(H5FD_onion_t *file, unsigned int flags, haddr_t maxaddr, boo uint32_t checksum = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE /* Guard against simultaneous write-open. * TODO: support recovery open with force-write-open flag in FAPL info. @@ -1309,20 +1309,20 @@ done: if (FAIL == ret_value) { if (file->recovery_file != NULL) { if (H5FD_close(file->recovery_file) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close recovery file") + HDONE_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "can't close recovery file"); file->recovery_file = NULL; } if (file->rev_index != NULL) { if (H5FD__onion_revision_index_destroy(file->rev_index) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't destroy revision index") + HDONE_ERROR(H5E_VFL, H5E_CANTRELEASE, FAIL, "can't destroy revision index"); file->rev_index = NULL; } } H5MM_xfree(buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_open_rw() */ /*----------------------------------------------------------------------------- @@ -1425,7 +1425,7 @@ H5FD__onion_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h assert(0 == bytes_to_read); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_read() */ /*----------------------------------------------------------------------------- @@ -1441,11 +1441,11 @@ H5FD__onion_set_eoa(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr) { H5FD_onion_t *file = (H5FD_onion_t *)_file; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR file->logical_eoa = addr; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__onion_set_eoa() */ /*----------------------------------------------------------------------------- @@ -1601,7 +1601,7 @@ H5FD__onion_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, done: H5MM_xfree(page_buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_write() */ /*------------------------------------------------------------------------- @@ -1742,7 +1742,7 @@ H5FD__onion_write_final_history(H5FD_onion_t *file) size_t size = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE /* TODO: history EOF may not be correct (under what circumstances?) */ if (0 == (size = H5FD__onion_write_history(&(file->history), file->onion_file, file->onion_eof, @@ -1758,5 +1758,5 @@ H5FD__onion_write_final_history(H5FD_onion_t *file) file->onion_eof += size; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_write_final_history() */ diff --git a/src/H5FDonion_header.c b/src/H5FDonion_header.c index e882af2..b9ab88a 100644 --- a/src/H5FDonion_header.c +++ b/src/H5FDonion_header.c @@ -19,11 +19,12 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDonion.h" /* Onion file driver */ -#include "H5FDonion_priv.h" /* Onion file driver internals */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDonion.h" /* Onion file driver */ +#include "H5FDonion_priv.h" /* Onion file driver internals */ +#include "H5MMprivate.h" /* Memory management */ /*----------------------------------------------------------------------------- * Function: H5FD_ingest_header @@ -43,7 +44,7 @@ H5FD__onion_ingest_header(H5FD_onion_header_t *hdr_out, H5FD_t *raw_file, haddr_ haddr_t size = (haddr_t)H5FD_ONION_ENCODED_SIZE_HEADER; uint32_t sum = 0; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE if (H5FD_get_eof(raw_file, H5FD_MEM_DRAW) < (addr + size)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "header indicates history beyond EOF") @@ -67,7 +68,7 @@ H5FD__onion_ingest_header(H5FD_onion_header_t *hdr_out, H5FD_t *raw_file, haddr_ done: H5MM_xfree(buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_ingest_header() */ /*------------------------------------------------------------------------- @@ -87,7 +88,7 @@ H5FD__onion_write_header(H5FD_onion_header_t *header, H5FD_t *file) unsigned char *buf = NULL; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE if (NULL == (buf = H5MM_malloc(H5FD_ONION_ENCODED_SIZE_HEADER))) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "can't allocate buffer for updated history header") @@ -101,7 +102,7 @@ H5FD__onion_write_header(H5FD_onion_header_t *header, H5FD_t *file) done: H5MM_xfree(buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_write_header()*/ /*----------------------------------------------------------------------------- @@ -127,7 +128,7 @@ H5FD__onion_header_decode(unsigned char *buf, H5FD_onion_header_t *header) unsigned char *ptr = NULL; size_t ret_value = 0; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(buf != NULL); assert(header != NULL); @@ -179,7 +180,7 @@ H5FD__onion_header_decode(unsigned char *buf, H5FD_onion_header_t *header) ret_value = (size_t)(ptr - buf); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_header_decode() */ /*----------------------------------------------------------------------------- @@ -205,7 +206,7 @@ H5FD__onion_header_encode(H5FD_onion_header_t *header, unsigned char *buf, uint3 unsigned char *ptr = buf; size_t ret_value = 0; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR assert(buf != NULL); assert(checksum != NULL); @@ -227,5 +228,5 @@ H5FD__onion_header_encode(H5FD_onion_header_t *header, unsigned char *buf, uint3 UINT32ENCODE(ptr, *checksum); ret_value = (size_t)(ptr - buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_header_encode() */ diff --git a/src/H5FDonion_history.c b/src/H5FDonion_history.c index b4c9fd2..06a3e3b 100644 --- a/src/H5FDonion_history.c +++ b/src/H5FDonion_history.c @@ -19,11 +19,12 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDonion.h" /* Onion file driver */ -#include "H5FDonion_priv.h" /* Onion file driver internals */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDonion.h" /* Onion file driver */ +#include "H5FDonion_priv.h" /* Onion file driver internals */ +#include "H5MMprivate.h" /* Memory management */ /*----------------------------------------------------------------------------- * Function: H5FD__onion_write_history @@ -42,7 +43,7 @@ H5FD__onion_ingest_history(H5FD_onion_history_t *history_out, H5FD_t *raw_file, uint32_t sum = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(history_out); assert(raw_file); @@ -82,7 +83,7 @@ done: if (ret_value < 0) H5MM_xfree(history_out->record_locs); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_ingest_history() */ /*----------------------------------------------------------------------------- @@ -103,7 +104,7 @@ H5FD__onion_write_history(H5FD_onion_history_t *history, H5FD_t *file, haddr_t o unsigned char *buf = NULL; uint64_t ret_value = 0; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE if (NULL == (buf = H5MM_malloc(H5FD_ONION_ENCODED_SIZE_HISTORY + (H5FD_ONION_ENCODED_SIZE_RECORD_POINTER * history->n_revisions)))) @@ -123,7 +124,7 @@ H5FD__onion_write_history(H5FD_onion_history_t *history, H5FD_t *file, haddr_t o done: H5MM_xfree(buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_write_history() */ /*----------------------------------------------------------------------------- @@ -165,7 +166,7 @@ H5FD__onion_history_decode(unsigned char *buf, H5FD_onion_history_t *history) unsigned char *ptr = NULL; size_t ret_value = 0; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(buf != NULL); assert(history != NULL); @@ -238,7 +239,7 @@ H5FD__onion_history_decode(unsigned char *buf, H5FD_onion_history_t *history) ret_value = (size_t)(ptr - buf); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_history_decode() */ /*----------------------------------------------------------------------------- @@ -267,7 +268,7 @@ H5FD__onion_history_encode(H5FD_onion_history_t *history, unsigned char *buf, ui unsigned char *ptr = buf; size_t vers_u32 = (uint32_t)history->version; /* pad out unused bytes */ - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR assert(history != NULL); assert(H5FD_ONION_HISTORY_VERSION_CURR == history->version); @@ -301,5 +302,5 @@ H5FD__onion_history_encode(H5FD_onion_history_t *history, unsigned char *buf, ui *checksum = H5_checksum_fletcher32(buf, (size_t)(ptr - buf)); UINT32ENCODE(ptr, *checksum); - FUNC_LEAVE_NOAPI((size_t)(ptr - buf)); + FUNC_LEAVE_NOAPI((size_t)(ptr - buf)) } /* end H5FD__onion_history_encode() */ diff --git a/src/H5FDonion_index.c b/src/H5FDonion_index.c index a164e91..62cc009 100644 --- a/src/H5FDonion_index.c +++ b/src/H5FDonion_index.c @@ -19,11 +19,12 @@ /* This source code file is part of the H5FD driver module */ #include "H5FDdrvr_module.h" -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDonion.h" /* Onion file driver */ -#include "H5FDonion_priv.h" /* Onion file driver internals */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDonion.h" /* Onion file driver */ +#include "H5FDonion_priv.h" /* Onion file driver internals */ +#include "H5MMprivate.h" /* Memory management */ /* 2^n for uint64_t types -- H5_EXP2 unsafe past 32 bits */ #define U64_EXP2(n) ((uint64_t)1 << (n)) @@ -51,7 +52,7 @@ H5FD__onion_ingest_revision_record(H5FD_onion_revision_record_t *r_out, H5FD_t * haddr_t addr = 0; size_t size = 0; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(r_out); assert(raw_file); @@ -161,7 +162,7 @@ done: H5MM_xfree(r_out->archival_index.list); } - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_ingest_revision_record() */ /*----------------------------------------------------------------------------- @@ -183,23 +184,23 @@ H5FD__onion_archival_index_is_valid(const H5FD_onion_archival_index_t *aix) { hbool_t ret_value = TRUE; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR assert(aix); if (H5FD_ONION_ARCHIVAL_INDEX_VERSION_CURR != aix->version) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (NULL == aix->list) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Ensure list is sorted on logical_page field */ if (aix->n_entries > 1) for (uint64_t i = 1; i < aix->n_entries - 1; i++) if (aix->list[i + 1].logical_page <= aix->list[i].logical_page) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_archival_index_is_valid() */ /*----------------------------------------------------------------------------- @@ -227,7 +228,7 @@ H5FD__onion_archival_index_find(const H5FD_onion_archival_index_t *aix, uint64_t H5FD_onion_index_entry_t *x = NULL; int ret_value = 0; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR assert(aix); assert(H5FD_ONION_ARCHIVAL_INDEX_VERSION_CURR == aix->version); @@ -241,7 +242,7 @@ H5FD__onion_archival_index_find(const H5FD_onion_archival_index_t *aix, uint64_t /* Trivial cases */ if (aix->n_entries == 0 || logical_page > aix->list[high].logical_page || logical_page < aix->list[0].logical_page) - HGOTO_DONE(0) + HGOTO_DONE(0); /* * Binary search on sorted list @@ -275,7 +276,7 @@ H5FD__onion_archival_index_find(const H5FD_onion_archival_index_t *aix, uint64_t } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_archival_index_find() */ /*----------------------------------------------------------------------------- @@ -291,7 +292,7 @@ H5FD__onion_revision_index_destroy(H5FD_onion_revision_index_t *rix) { herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR assert(rix); assert(H5FD_ONION_REVISION_INDEX_VERSION_CURR == rix->version); @@ -314,7 +315,7 @@ H5FD__onion_revision_index_destroy(H5FD_onion_revision_index_t *rix) H5MM_xfree(rix->_hash_table); H5MM_xfree(rix); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_revision_index_destroy() */ /*----------------------------------------------------------------------------- @@ -335,7 +336,7 @@ H5FD__onion_revision_index_init(uint32_t page_size) H5FD_onion_revision_index_t *rix = NULL; H5FD_onion_revision_index_t *ret_value = NULL; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(0 != page_size); assert(POWER_OF_TWO(page_size)); @@ -363,7 +364,7 @@ done: if (NULL == ret_value) H5MM_xfree(rix); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_revision_index_init() */ /*----------------------------------------------------------------------------- @@ -389,7 +390,7 @@ H5FD__onion_revision_index_resize(H5FD_onion_revision_index_t *rix) uint64_t new_n_keys_populated = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(rix); assert(H5FD_ONION_REVISION_INDEX_VERSION_CURR == rix->version); @@ -427,7 +428,7 @@ H5FD__onion_revision_index_resize(H5FD_onion_revision_index_t *rix) rix->_hash_table = new_table; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_revision_index_resize() */ /*----------------------------------------------------------------------------- @@ -451,7 +452,7 @@ H5FD__onion_revision_index_insert(H5FD_onion_revision_index_t *rix, const H5FD_o H5FD_onion_revision_index_hash_chain_node_t **append_dest = NULL; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(rix); assert(H5FD_ONION_REVISION_INDEX_VERSION_CURR == rix->version); @@ -501,7 +502,7 @@ H5FD__onion_revision_index_insert(H5FD_onion_revision_index_t *rix, const H5FD_o } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_revision_index_insert() */ /*----------------------------------------------------------------------------- @@ -524,7 +525,7 @@ H5FD__onion_revision_index_find(const H5FD_onion_revision_index_t *rix, uint64_t uint64_t key = 0; int ret_value = 0; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR assert(rix); assert(H5FD_ONION_REVISION_INDEX_VERSION_CURR == rix->version); @@ -546,7 +547,7 @@ H5FD__onion_revision_index_find(const H5FD_onion_revision_index_t *rix, uint64_t } } - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_revision_index_find() */ /*----------------------------------------------------------------------------- @@ -596,7 +597,7 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor unsigned char *ptr = NULL; size_t ret_value = 0; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(buf != NULL); assert(record != NULL); @@ -722,7 +723,7 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor ret_value = (size_t)(ptr - buf); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_revision_record_decode() */ /*----------------------------------------------------------------------------- @@ -753,7 +754,7 @@ H5FD__onion_revision_record_encode(H5FD_onion_revision_record_t *record, unsigne uint32_t vers_u32 = (uint32_t)record->version; /* pad out unused bytes */ uint32_t page_size = 0; - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR assert(checksum != NULL); assert(buf != NULL); @@ -804,7 +805,7 @@ H5FD__onion_revision_record_encode(H5FD_onion_revision_record_t *record, unsigne *checksum = H5_checksum_fletcher32(buf, (size_t)(ptr - buf)); UINT32ENCODE(ptr, *checksum); - FUNC_LEAVE_NOAPI((size_t)(ptr - buf)); + FUNC_LEAVE_NOAPI((size_t)(ptr - buf)) } /* end H5FD__onion_revision_record_encode() */ /*----------------------------------------------------------------------------- @@ -853,7 +854,7 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i }; herr_t ret_value = SUCCEED; - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE assert(rix); assert(aix); @@ -881,8 +882,8 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i } /* Sort the new archival list */ - HDqsort(new_aix.list, new_aix.n_entries, sizeof(H5FD_onion_index_entry_t), - H5FD__onion_archival_index_list_sort_cmp); + qsort(new_aix.list, new_aix.n_entries, sizeof(H5FD_onion_index_entry_t), + H5FD__onion_archival_index_list_sort_cmp); /* Add the old archival index entries to a 'kept' list containing the * old archival list entries that are not also included in the revision @@ -923,13 +924,13 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i } /* Sort this list */ - HDqsort(aix->list, aix->n_entries, sizeof(H5FD_onion_index_entry_t), - H5FD__onion_archival_index_list_sort_cmp); + qsort(aix->list, aix->n_entries, sizeof(H5FD_onion_index_entry_t), + H5FD__onion_archival_index_list_sort_cmp); done: /* Free the temporary lists */ H5MM_xfree(kept_list); H5MM_xfree(new_aix.list); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__onion_merge_revision_index_into_archival_index() */ diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 2208aff..c9ff5da 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -229,6 +229,11 @@ static herr_t H5FD__ros3_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing static herr_t H5FD__ros3_validate_config(const H5FD_ros3_fapl_t *fa); +static herr_t H5FD__ros3_str_token_copy(const char *name, size_t size, void *_value); +static int H5FD__ros3_str_token_cmp(const void *_value1, const void *_value2, size_t size); +static herr_t H5FD__ros3_str_token_close(const char *name, size_t size, void *_value); +static herr_t H5FD__ros3_str_token_delete(hid_t prop_id, const char *name, size_t size, void *_value); + static const H5FD_class_t H5FD_ros3_g = { H5FD_CLASS_VERSION, /* struct version */ H5FD_ROS3_VALUE, /* value */ @@ -1406,9 +1411,9 @@ H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HGOTO_DONE(-1); } else if (purl1->port) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (purl2->port) - HGOTO_DONE(-1) + HGOTO_DONE(-1); /* URL: PATH */ if (purl1->path && purl2->path) { @@ -1416,9 +1421,9 @@ H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HGOTO_DONE(-1); } else if (purl1->path && !purl2->path) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (purl2->path && !purl1->path) - HGOTO_DONE(-1) + HGOTO_DONE(-1); /* URL: QUERY */ if (purl1->query && purl2->query) { @@ -1426,9 +1431,9 @@ H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HGOTO_DONE(-1); } else if (purl1->query && !purl2->query) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (purl2->query && !purl1->query) - HGOTO_DONE(-1) + HGOTO_DONE(-1); /* FAPL: AWS_REGION */ if (f1->fa.aws_region[0] != '\0' && f2->fa.aws_region[0] != '\0') { @@ -1436,9 +1441,9 @@ H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HGOTO_DONE(-1); } else if (f1->fa.aws_region[0] != '\0') - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (f2->fa.aws_region[0] != '\0') - HGOTO_DONE(-1) + HGOTO_DONE(-1); /* FAPL: SECRET_ID */ if (f1->fa.secret_id[0] != '\0' && f2->fa.secret_id[0] != '\0') { @@ -1446,9 +1451,9 @@ H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HGOTO_DONE(-1); } else if (f1->fa.secret_id[0] != '\0') - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (f2->fa.secret_id[0] != '\0') - HGOTO_DONE(-1) + HGOTO_DONE(-1); /* FAPL: SECRET_KEY */ if (f1->fa.secret_key[0] != '\0' && f2->fa.secret_key[0] != '\0') { @@ -1456,9 +1461,9 @@ H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) HGOTO_DONE(-1); } else if (f1->fa.secret_key[0] != '\0') - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (f2->fa.secret_key[0] != '\0') - HGOTO_DONE(-1) + HGOTO_DONE(-1); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index cfc4f7e..8bca57b 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -453,39 +453,39 @@ H5FD__sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) #ifdef H5_HAVE_WIN32_API if (f1->dwVolumeSerialNumber < f2->dwVolumeSerialNumber) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->dwVolumeSerialNumber > f2->dwVolumeSerialNumber) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->nFileIndexHigh < f2->nFileIndexHigh) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->nFileIndexHigh > f2->nFileIndexHigh) - HGOTO_DONE(1) + HGOTO_DONE(1); if (f1->nFileIndexLow < f2->nFileIndexLow) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->nFileIndexLow > f2->nFileIndexLow) - HGOTO_DONE(1) + HGOTO_DONE(1); #else /* H5_HAVE_WIN32_API */ #ifdef H5_DEV_T_IS_SCALAR if (f1->device < f2->device) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->device > f2->device) - HGOTO_DONE(1) + HGOTO_DONE(1); #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (memcmp(&(f1->device), &(f2->device), sizeof(dev_t)) > 0) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif /* H5_DEV_T_IS_SCALAR */ if (f1->inode < f2->inode) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (f1->inode > f2->inode) - HGOTO_DONE(1) + HGOTO_DONE(1); #endif /* H5_HAVE_WIN32_API */ done: diff --git a/src/H5FDspace.c b/src/H5FDspace.c index 2b64b56..23f53b4 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -413,7 +413,7 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end, hsize_ HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark EOA info as dirty") /* Indicate success */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ done: diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index f0ed1b0..159a161 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -267,7 +267,7 @@ H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr) HGOTO_ERROR(H5E_VFL, H5E_BADTYPE, -1, "unable to copy file access property list"); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__copy_plist() */ /*------------------------------------------------------------------------- @@ -880,7 +880,7 @@ done: if (file_ptr->wo_file) H5FD_close(file_ptr->wo_file); if (file_ptr->logfp) - HDfclose(file_ptr->logfp); + fclose(file_ptr->logfp); H5FL_FREE(H5FD_splitter_t, file_ptr); } } /* end if error */ @@ -924,7 +924,7 @@ H5FD__splitter_close(H5FD_t *_file) "unable to close W/O file") if (file->logfp) { - HDfclose(file->logfp); + fclose(file->logfp); file->logfp = NULL; } @@ -1580,7 +1580,7 @@ H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const ret_value = FAIL; else if (size < (size_t)HDsnprintf(s, size + 1, "%s: %s\n", atfunc, msg)) ret_value = FAIL; - else if (size != HDfwrite(s, 1, size, file->logfp)) + else if (size != fwrite(s, 1, size, file->logfp)) ret_value = FAIL; H5MM_free(s); } diff --git a/src/H5FDsubfiling/H5FDioc.c b/src/H5FDsubfiling/H5FDioc.c index 6e00fdf..81ad0e7 100644 --- a/src/H5FDsubfiling/H5FDioc.c +++ b/src/H5FDsubfiling/H5FDioc.c @@ -1518,7 +1518,7 @@ H5FD__ioc_del(const char *name, hid_t fapl) n_subfiles = (int32_t)read_n_subfiles; /* Delete the Subfiling configuration file */ - if (EOF == HDfclose(config_file)) { + if (EOF == fclose(config_file)) { config_file = NULL; H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close subfiling config file"); @@ -1555,7 +1555,7 @@ H5FD__ioc_del(const char *name, hid_t fapl) done: if (config_file) - if (EOF == HDfclose(config_file)) + if (EOF == fclose(config_file)) H5_SUBFILING_DONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close subfiling config file"); /* Set up a barrier (don't want processes to run ahead of the delete) */ diff --git a/src/H5FDsubfiling/H5FDsubfiling.c b/src/H5FDsubfiling/H5FDsubfiling.c index 0f86626..6a04f68 100644 --- a/src/H5FDsubfiling/H5FDsubfiling.c +++ b/src/H5FDsubfiling/H5FDsubfiling.c @@ -327,7 +327,7 @@ H5FD_subfiling_init(void) H5_SUBFILING_GOTO_ERROR(H5E_VFL, H5E_CANTINIT, H5I_INVALID_HID, "MPI doesn't support MPI_Init_thread with MPI_THREAD_MULTIPLE"); - if (HDatexit(H5FD__subfiling_mpi_finalize) < 0) + if (atexit(H5FD__subfiling_mpi_finalize) < 0) H5_SUBFILING_GOTO_ERROR(H5E_VFL, H5E_CANTINIT, H5I_INVALID_HID, "can't register atexit handler for MPI_Finalize"); } diff --git a/src/H5FDsubfiling/H5subfiling_common.c b/src/H5FDsubfiling/H5subfiling_common.c index a5eb195..63791c1 100644 --- a/src/H5FDsubfiling/H5subfiling_common.c +++ b/src/H5FDsubfiling/H5subfiling_common.c @@ -856,7 +856,7 @@ init_subfiling(const char *base_filename, uint64_t file_id, H5FD_subfiling_param errno = 0; - stripe_size = HDstrtoll(env_value, NULL, 0); + stripe_size = strtoll(env_value, NULL, 0); if (ERANGE == errno) H5_SUBFILING_SYS_GOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid stripe size setting for " H5FD_SUBFILING_STRIPE_SIZE); @@ -899,7 +899,7 @@ init_subfiling(const char *base_filename, uint64_t file_id, H5FD_subfiling_param *context_id_out = context_id; done: - if (config_file && (EOF == HDfclose(config_file))) + if (config_file && (EOF == fclose(config_file))) H5_SUBFILING_DONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "couldn't close subfiling configuration file"); @@ -983,7 +983,7 @@ init_app_topology(H5FD_subfiling_params_t *subfiling_config, MPI_Comm comm, MPI_ /* Check for an IOC-per-node value set in the environment */ if ((env_value = HDgetenv(H5FD_SUBFILING_IOC_PER_NODE))) { errno = 0; - ioc_select_val = HDstrtol(env_value, NULL, 0); + ioc_select_val = strtol(env_value, NULL, 0); if ((ERANGE == errno)) { printf("invalid value '%s' for " H5FD_SUBFILING_IOC_PER_NODE "\n", env_value); ioc_select_val = 1; @@ -1010,7 +1010,7 @@ init_app_topology(H5FD_subfiling_params_t *subfiling_config, MPI_Comm comm, MPI_ ioc_select_val = 1; if (ioc_sel_str) { errno = 0; - ioc_select_val = HDstrtol(ioc_sel_str, NULL, 0); + ioc_select_val = strtol(ioc_sel_str, NULL, 0); if ((ERANGE == errno) || (ioc_select_val <= 0)) { printf("invalid IOC selection strategy string '%s' for strategy " "SELECT_IOC_EVERY_NTH_RANK; defaulting to SELECT_IOC_ONE_PER_NODE\n", @@ -1046,7 +1046,7 @@ init_app_topology(H5FD_subfiling_params_t *subfiling_config, MPI_Comm comm, MPI_ ioc_select_val = 1; if (ioc_sel_str) { errno = 0; - ioc_select_val = HDstrtol(ioc_sel_str, NULL, 0); + ioc_select_val = strtol(ioc_sel_str, NULL, 0); if ((ERANGE == errno) || (ioc_select_val <= 0)) { printf("invalid IOC selection strategy string '%s' for strategy SELECT_IOC_TOTAL; " "defaulting to SELECT_IOC_ONE_PER_NODE\n", @@ -1209,7 +1209,7 @@ get_ioc_selection_criteria_from_env(H5FD_subfiling_ioc_select_t *ioc_selection_t *opt_value++ = '\0'; errno = 0; - check_value = HDstrtol(env_value, NULL, 0); + check_value = strtol(env_value, NULL, 0); if (errno == ERANGE) H5_SUBFILING_SYS_GOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, @@ -1354,7 +1354,7 @@ init_app_layout(sf_topology_t *app_topology, MPI_Comm comm, MPI_Comm node_comm) H5_SUBFILING_GOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "can't gather application topology info"); /* Sort the list according to the node local lead rank values */ - HDqsort(app_layout->layout, (size_t)app_layout->world_size, sizeof(layout_t), compare_layout_nodelocal); + qsort(app_layout->layout, (size_t)app_layout->world_size, sizeof(layout_t), compare_layout_nodelocal); /* * Count the number of nodes by checking how many @@ -2297,31 +2297,31 @@ create_config_file(subfiling_context_t *sf_context, const char *base_filename, c /* Write the subfiling stripe size to the configuration file */ HDsnprintf(line_buf, PATH_MAX, "stripe_size=%" PRId64 "\n", sf_context->sf_stripe_size); - if (HDfwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) + if (fwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "failed to write to subfiling configuration file"); /* Write the number of I/O concentrators to the configuration file */ HDsnprintf(line_buf, PATH_MAX, "aggregator_count=%d\n", sf_context->topology->n_io_concentrators); - if (HDfwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) + if (fwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "failed to write to subfiling configuration file"); /* Write the number of subfiles to the configuration file */ HDsnprintf(line_buf, PATH_MAX, "subfile_count=%d\n", n_subfiles); - if (HDfwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) + if (fwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "failed to write to subfiling configuration file"); /* Write the base HDF5 filename to the configuration file */ HDsnprintf(line_buf, PATH_MAX, "hdf5_file=%s\n", sf_context->h5_filename); - if (HDfwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) + if (fwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "failed to write to subfiling configuration file"); /* Write the optional subfile directory prefix to the configuration file */ HDsnprintf(line_buf, PATH_MAX, "subfile_dir=%s\n", subfile_dir); - if (HDfwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) + if (fwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "failed to write to subfiling configuration file"); @@ -2331,7 +2331,7 @@ create_config_file(subfiling_context_t *sf_context, const char *base_filename, c HDsnprintf(line_buf, PATH_MAX, H5FD_SUBFILING_FILENAME_TEMPLATE "\n", base_filename, sf_context->h5_file_id, num_digits, k + 1, n_subfiles); - if (HDfwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) + if (fwrite(line_buf, HDstrlen(line_buf), 1, config_file) != 1) H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "failed to write to subfiling configuration file"); } @@ -2339,7 +2339,7 @@ create_config_file(subfiling_context_t *sf_context, const char *base_filename, c done: if (config_file) { - if (EOF == HDfclose(config_file)) + if (EOF == fclose(config_file)) H5_SUBFILING_DONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "couldn't close subfiling configuration file"); } @@ -2416,7 +2416,7 @@ open_config_file(const char *base_filename, const char *config_dir, uint64_t fil done: if (ret_value < 0) { - if (config_file && (EOF == HDfclose(config_file))) + if (config_file && (EOF == fclose(config_file))) H5_SUBFILING_DONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "couldn't close subfiling configuration file"); } @@ -2464,7 +2464,7 @@ H5_get_subfiling_config_from_file(FILE *config_file, int64_t *stripe_size, int64 H5_SUBFILING_GOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "couldn't allocate space for reading from subfiling configuration file"); - if (HDfread(config_buf, (size_t)config_file_len, 1, config_file) != 1) + if (fread(config_buf, (size_t)config_file_len, 1, config_file) != 1) H5_SUBFILING_SYS_GOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "couldn't read from subfiling configuration file"); @@ -2773,7 +2773,7 @@ H5_close_subfiles(int64_t subfiling_context_id, MPI_Comm file_comm) H5_subfiling_log(sf_context->sf_context_id, "\n-- LOGGING FINISH - %s", asctime(tm)); - HDfclose(sf_context->sf_logfile); + fclose(sf_context->sf_logfile); sf_context->sf_logfile = NULL; } #endif diff --git a/src/H5FDtest.c b/src/H5FDtest.c index dc9ad93..87d24b6 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -71,8 +71,6 @@ * VFD feature flags (which do not exist until the driver * is instantiated). * - * See test/Makefile.am for a list of the VFD strings. - * * This function is only intended for use in the test code. * * Return: TRUE (1) if the VFD supports SWMR I/O or vfd_name is @@ -82,10 +80,6 @@ * * This function cannot fail at this time so there is no * error return value. - * - * Programmer: Dana Robinson - * Fall 2014 - * *------------------------------------------------------------------------- */ hbool_t diff --git a/src/H5FL.c b/src/H5FL.c index b0d70af..2b7896c 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -146,7 +146,7 @@ static int H5FL__fac_term_all(void); H5FL_DEFINE(H5FL_blk_node_t); /* Declare a free list to manage the H5FL_fac_gc_node_t struct */ -H5FL_DEFINE(H5FL_fac_gc_node_t); +H5FL_DEFINE_STATIC(H5FL_fac_gc_node_t); /* Declare a free list to manage the H5FL_fac_head_t struct */ H5FL_DEFINE(H5FL_fac_head_t); @@ -1367,7 +1367,7 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) /* The H5MM_xfree code allows obj to null */ if (!obj) - HGOTO_DONE(NULL) + HGOTO_DONE(NULL); /* Double check parameters */ assert(head); diff --git a/src/H5FS.c b/src/H5FS.c index c547859..bafc83e 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -142,7 +142,7 @@ H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t done: if (!ret_value && fspace) if (H5FS__hdr_dest(fspace) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header"); #ifdef H5FS_DEBUG fprintf(stderr, "%s: Leaving, ret_value = %p\n", __func__, (void *)ret_value); @@ -362,7 +362,7 @@ H5FS_delete(H5F_t *f, haddr_t fs_addr) done: if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space header") + HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPROTECT, FAIL, "unable to release free space header"); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_delete() */ @@ -880,7 +880,6 @@ H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space) assert(fspace); cache_flags = H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; - ; /* Free space for section info */ if (H5_addr_defined(fspace->sect_addr)) { diff --git a/src/H5FScache.c b/src/H5FScache.c index 449628d..9554c1b 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -283,7 +283,7 @@ H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len H5F_DECODE_LENGTH(udata->f, image, fspace->max_sect_size); /* Address of serialized free space sections */ - H5_addr_decode(udata->f, &image, &fspace->sect_addr); + H5F_addr_decode(udata->f, &image, &fspace->sect_addr); /* Size of serialized free space sections */ H5F_DECODE_LENGTH(udata->f, image, fspace->sect_size); @@ -306,7 +306,7 @@ done: /* Release resources */ if (!ret_value && fspace) if (H5FS__hdr_dest(fspace) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_hdr_deserialize() */ @@ -330,7 +330,6 @@ H5FS__cache_hdr_image_len(const void *_thing, size_t *image_len) /* Check arguments */ assert(fspace); - assert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(fspace->cache_info.type == H5AC_FSPACE_HDR); assert(image_len); @@ -378,7 +377,6 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_AT /* Sanity check */ assert(f); assert(fspace); - assert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(fspace->cache_info.type == H5AC_FSPACE_HDR); assert(H5_addr_defined(addr)); assert(new_addr); @@ -521,7 +519,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_AT H5_BEGIN_TAG(tag) if (H5AC_insert_entry((H5F_t *)f, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR_TAG(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache") + HGOTO_ERROR_TAG(H5E_FSPACE, H5E_CANTINIT, FAIL, "can't add free space sections to cache"); H5_END_TAG assert(fspace->sinfo->cache_info.size == fspace->alloc_sect_size); @@ -674,7 +672,6 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN assert(f); assert(image); assert(fspace); - assert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(fspace->cache_info.type == H5AC_FSPACE_HDR); assert(fspace->hdr_size == len); @@ -732,7 +729,7 @@ H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN H5F_ENCODE_LENGTH(f, image, fspace->max_sect_size); /* Address of serialized free space sections */ - H5_addr_encode(f, &image, fspace->sect_addr); + H5F_addr_encode(f, &image, fspace->sect_addr); /* Size of serialized free space sections */ H5F_ENCODE_LENGTH(f, image, fspace->sect_size); @@ -811,10 +808,6 @@ done: * * Purpose: Destroys a free space header in memory. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -830,7 +823,6 @@ H5FS__cache_hdr_free_icr(void *_thing) /* Sanity checks */ assert(fspace); - assert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(fspace->cache_info.type == H5AC_FSPACE_HDR); /* We should not still be holding on to the free space section info */ @@ -963,7 +955,7 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "wrong free space sections version") /* Address of free space header for these sections */ - H5_addr_decode(udata->f, &image, &fs_addr); + H5F_addr_decode(udata->f, &image, &fs_addr); if (H5_addr_ne(fs_addr, fspace->addr)) HGOTO_ERROR(H5E_FSPACE, H5E_CANTLOAD, NULL, "incorrect header address for free space sections") @@ -1064,7 +1056,7 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l done: if (!ret_value && sinfo) if (H5FS__sinfo_dest(sinfo) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS__cache_sinfo_deserialize() */ @@ -1088,10 +1080,8 @@ H5FS__cache_sinfo_image_len(const void *_thing, size_t *image_len) /* Sanity checks */ assert(sinfo); - assert(sinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sinfo->cache_info.type == H5AC_FSPACE_SINFO); assert(sinfo->fspace); - assert(sinfo->fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sinfo->fspace->cache_info.type == H5AC_FSPACE_HDR); assert(image_len); @@ -1128,10 +1118,8 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ /* Sanity checks */ assert(f); assert(sinfo); - assert(sinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sinfo->cache_info.type == H5AC_FSPACE_SINFO); fspace = sinfo->fspace; - assert(fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(fspace->cache_info.type == H5AC_FSPACE_HDR); assert(fspace->cache_info.is_pinned); assert(H5_addr_defined(addr)); @@ -1211,9 +1199,7 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, void *_thi assert(f); assert(image); assert(sinfo); - assert(sinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sinfo->cache_info.type == H5AC_FSPACE_SINFO); - assert(sinfo->fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sinfo->fspace->cache_info.type == H5AC_FSPACE_HDR); assert(sinfo->fspace->cache_info.is_pinned); assert(sinfo->fspace->sect_size == len); @@ -1227,7 +1213,7 @@ H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, void *_thi *image++ = H5FS_SINFO_VERSION; /* Address of free space header for these sections */ - H5_addr_encode(f, &image, sinfo->fspace->addr); + H5F_addr_encode(f, &image, sinfo->fspace->addr); /* Set up user data for iterator */ udata.sinfo = sinfo; @@ -1328,10 +1314,6 @@ done: * Purpose: Free the memory used for the in core representation of the * free space manager section info. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -1347,9 +1329,7 @@ H5FS__cache_sinfo_free_icr(void *_thing) /* Sanity checks */ assert(sinfo); - assert(sinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(sinfo->cache_info.type == H5AC_FSPACE_SINFO); - assert(sinfo->fspace->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sinfo->fspace->cache_info.type == H5AC_FSPACE_HDR); assert(sinfo->fspace->cache_info.is_pinned); diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c index 6ff7b3c..3b07052 100644 --- a/src/H5FSdbg.c +++ b/src/H5FSdbg.c @@ -140,7 +140,7 @@ H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) done: if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, addr, fspace, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") + HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_debug() */ @@ -232,7 +232,7 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent * and reloaded later, with the correct client information -QAK) */ if (H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__DELETED_FLAG) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") + HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header"); fspace = NULL; /* Print opening message */ @@ -260,7 +260,7 @@ H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent done: if (fspace && H5AC_unprotect(f, H5AC_FSPACE_HDR, fs_addr, fspace, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header") + HDONE_ERROR(H5E_FSPACE, H5E_PROTECT, FAIL, "unable to release free space header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_sects_debug() */ diff --git a/src/H5FSsection.c b/src/H5FSsection.c index fbe07ff..a233f37 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -896,7 +896,7 @@ H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect) done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_remove() */ @@ -990,7 +990,7 @@ done: if (fspace_node && fspace_node_alloc) { if (fspace_node->sect_list && H5SL_close(fspace_node->sect_list) < 0) HDONE_ERROR(H5E_FSPACE, H5E_CANTCLOSEOBJ, FAIL, - "can't destroy size free space node's skip list") + "can't destroy size free space node's skip list"); fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); } /* end if */ @@ -1348,7 +1348,7 @@ H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flag done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); #ifdef H5FS_DEBUG_ASSERT if (!(flags & (H5FS_ADD_DESERIALIZING | H5FS_ADD_SKIP_VALID))) @@ -1490,7 +1490,7 @@ H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, hsize done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_extend() */ @@ -1536,7 +1536,7 @@ H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigne /* Check if section is shrunk and/or merged away completely */ if (!sect) { sinfo_modified = TRUE; - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ else { /* Check if section is merged */ @@ -1545,14 +1545,14 @@ H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigne HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") sinfo_modified = TRUE; - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ } /* end else */ done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_merge() */ @@ -1621,7 +1621,7 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't remove section from non-size tracking data structures") /* Indicate that we found a node for the request */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ } /* end if */ else { /* alignment is set */ @@ -1687,7 +1687,7 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node assert(request <= (*node)->size); } /* end if */ /* Indicate that we found a node for the request */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ /* Get the next section node in the list */ @@ -1753,7 +1753,7 @@ H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t ** done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, sinfo_modified) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); #ifdef H5FS_DEBUG_ASSERT H5FS__assert(fspace); @@ -1876,7 +1876,7 @@ H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data) done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, FALSE) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_iterate() */ @@ -2052,7 +2052,7 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, TRUE) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_change_class() */ @@ -2261,7 +2261,7 @@ H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data) done: /* Release the section info */ if (sinfo_valid && H5FS__sinfo_unlock(f, fspace, section_removed) < 0) - HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info") + HDONE_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't release section info"); FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_sect_try_shrink_eoa() */ diff --git a/src/H5FStest.c b/src/H5FStest.c index 02319d8..30f598d 100644 --- a/src/H5FStest.c +++ b/src/H5FStest.c @@ -107,29 +107,29 @@ H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2 assert(cparam2); if (cparam1->client < cparam2->client) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->client > cparam2->client) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->shrink_percent < cparam2->shrink_percent) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->shrink_percent > cparam2->shrink_percent) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->expand_percent < cparam2->expand_percent) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->expand_percent > cparam2->expand_percent) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->max_sect_size < cparam2->max_sect_size) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->max_sect_size > cparam2->max_sect_size) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->max_sect_addr < cparam2->max_sect_addr) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->max_sect_addr > cparam2->max_sect_addr) - HGOTO_DONE(1) + HGOTO_DONE(1); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Faccum.c b/src/H5Faccum.c index d3b318d..4d4b1f9 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -156,7 +156,7 @@ H5F__accum_read(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t si H5_CHECKED_ASSIGN(amount_before, size_t, (accum->loc - addr), hsize_t); /* Make room for the metadata to read in */ - HDmemmove(accum->buf + amount_before, accum->buf, accum->size); + memmove(accum->buf + amount_before, accum->buf, accum->size); /* Adjust dirty region tracking info, if present */ if (accum->dirty) @@ -360,7 +360,7 @@ H5F__accum_adjust(H5F_meta_accum_t *accum, H5FD_t *file, H5F_accum_adjust_t adju /* When appending, need to adjust location of accumulator */ if (H5F_ACCUM_APPEND == adjust) { /* Move remnant of accumulator down */ - HDmemmove(accum->buf, (accum->buf + shrink_size), remnant_size); + memmove(accum->buf, (accum->buf + shrink_size), remnant_size); /* Adjust accumulator's location */ accum->loc += shrink_size; @@ -434,7 +434,7 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t s HGOTO_ERROR(H5E_IO, H5E_CANTRESIZE, FAIL, "can't adjust metadata accumulator") /* Move the existing metadata to the proper location */ - HDmemmove(accum->buf + size, accum->buf, accum->size); + memmove(accum->buf + size, accum->buf, accum->size); /* Copy the new metadata at the front */ H5MM_memcpy(accum->buf, buf, size); @@ -524,7 +524,7 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t s H5_CHECKED_ASSIGN(old_offset, size_t, (addr + size) - accum->loc, hsize_t); /* Move the existing metadata to the proper location */ - HDmemmove(accum->buf + size, accum->buf + old_offset, (accum->size - old_offset)); + memmove(accum->buf + size, accum->buf + old_offset, (accum->size - old_offset)); /* Copy the new metadata at the front */ H5MM_memcpy(accum->buf, buf, size); @@ -771,7 +771,7 @@ H5F__accum_write(H5F_shared_t *f_sh, H5FD_mem_t map_type, haddr_t addr, size_t s /* Trim bottom of accumulator off */ accum->loc += overlap_size; accum->size -= overlap_size; - HDmemmove(accum->buf, accum->buf + overlap_size, accum->size); + memmove(accum->buf, accum->buf + overlap_size, accum->size); } /* end if */ else { /* Access covers whole accumulator */ /* Reset accumulator, but don't flush */ @@ -881,7 +881,7 @@ H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr new_accum_size = accum->size - overlap_size; /* Move the accumulator buffer information to eliminate the freed block */ - HDmemmove(accum->buf, accum->buf + overlap_size, new_accum_size); + memmove(accum->buf, accum->buf + overlap_size, new_accum_size); /* Adjust the accumulator information */ accum->loc += overlap_size; diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index 03cbdc6..f5892a3 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -113,13 +113,13 @@ H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) for (i = H5F_NCWFS - 1; i >= 0; --i) if (H5HG_FREE_SIZE(f->shared->cwfs[i]) < H5HG_FREE_SIZE(heap)) { - HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, (size_t)i * sizeof(H5HG_heap_t *)); + memmove(f->shared->cwfs + 1, f->shared->cwfs, (size_t)i * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; break; } /* end if */ } else { - HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, f->shared->ncwfs * sizeof(H5HG_heap_t *)); + memmove(f->shared->cwfs + 1, f->shared->cwfs, f->shared->ncwfs * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; f->shared->ncwfs += 1; } /* end else */ @@ -288,7 +288,7 @@ H5F_cwfs_remove_heap(H5F_shared_t *shared, H5HG_heap_t *heap) for (u = 0; u < shared->ncwfs; u++) { if (shared->cwfs[u] == heap) { shared->ncwfs -= 1; - HDmemmove(shared->cwfs + u, shared->cwfs + u + 1, (shared->ncwfs - u) * sizeof(H5HG_heap_t *)); + memmove(shared->cwfs + u, shared->cwfs + u + 1, (shared->ncwfs - u) * sizeof(H5HG_heap_t *)); break; } /* end if */ } /* end for */ diff --git a/src/H5Fefc.c b/src/H5Fefc.c index ef67742..00c6d86 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -171,7 +171,7 @@ H5F__efc_open(H5F_efc_t *efc, const char *name, unsigned flags, hid_t fcpl_id, h * H5F_decr_nopen_objs() in H5L_extern_traverse(). */ ret_value->nopen_objs++; - HGOTO_DONE(ret_value) + HGOTO_DONE(ret_value); } /* end if */ /* Search the skip list for name if the skip list exists, create the skip @@ -247,7 +247,7 @@ H5F__efc_open(H5F_efc_t *efc, const char *name, unsigned flags, hid_t fcpl_id, h * file id */ ret_value->nopen_objs++; - HGOTO_DONE(ret_value) + HGOTO_DONE(ret_value); } /* end else */ } /* end if */ else @@ -311,7 +311,7 @@ done: if (open_file) { ent->file->nopen_objs--; if (H5F_try_close(ent->file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close external file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close external file"); } /* end if */ ent->name = (char *)H5MM_xfree(ent->name); ent = H5FL_FREE(H5F_efc_ent_t, ent); @@ -358,7 +358,7 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) if (H5F_try_close(file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Scan the parent's LRU list from the head to file file. We do this @@ -456,7 +456,7 @@ H5F__efc_release_real(H5F_efc_t *efc) efc->tag = H5F_EFC_TAG_DEFAULT; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_release_real() */ /*------------------------------------------------------------------------- @@ -534,7 +534,7 @@ H5F__efc_destroy(H5F_efc_t *efc) (void)H5FL_FREE(H5F_efc_t, efc); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__efc_destroy() */ /*------------------------------------------------------------------------- @@ -819,7 +819,7 @@ H5F__efc_try_close(H5F_t *f) * EFC (i.e. none were open). */ assert(f->shared->efc->nfiles == 0); - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Conditions where we should not do anything and just return immediately */ @@ -838,7 +838,7 @@ H5F__efc_try_close(H5F_t *f) (f->shared->efc->nfiles == 0)) /* We must have reentered this function, and we should not close this * file. Just return. */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* If the file EFC were locked, that should always mean that there exists * a reference to this file that is not in an EFC (it may have just been @@ -871,7 +871,7 @@ H5F__efc_try_close(H5F_t *f) sf->efc->tmp_next = NULL; sf = next; } /* end while */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Run through the linked list , separating into two lists, one with tag == diff --git a/src/H5Fint.c b/src/H5Fint.c index de9c595..85d9b50 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -447,7 +447,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) done: /* Release the copy of the driver info, if it was set up */ if (driver_prop_copied && H5FD_free_driver_info(driver_prop.driver_id, driver_prop.driver_info) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close copy of driver info") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close copy of driver info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_access_plist() */ @@ -717,8 +717,8 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) * H5_ITER_CONT to continue the iteration. */ if (olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) - HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ - } /* end if */ + HGOTO_DONE(H5_ITER_STOP); /* Indicate that the iterator should stop */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1008,7 +1008,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c done: if ((NULL == ret_value) && src_file) if (H5F_efc_close(primary_file, src_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close source file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close source file"); if (full_name) full_name = (char *)H5MM_xfree(full_name); if (temp_file_name) @@ -1063,7 +1063,7 @@ done: /* Close the file */ if (file) if (H5FD_close(file) < 0 && TRUE == ret_value) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__is_hdf5() */ @@ -1328,10 +1328,10 @@ done: /* Attempt to clean up some of the shared file structures */ if (f->shared->efc) if (H5F__efc_destroy(f->shared->efc) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't destroy external file cache") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't destroy external file cache"); if (f->shared->fcpl_id > 0) if (H5I_dec_ref(f->shared->fcpl_id) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list"); f->shared = H5FL_FREE(H5F_shared_t, f->shared); } @@ -1377,7 +1377,7 @@ H5F__dest(H5F_t *f, hbool_t flush) if ((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) if (H5F__flush_phase1(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 1)") + HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 1)"); /* Notify the metadata cache that the file is about to be closed. * This allows the cache to set up for creating a metadata cache @@ -1385,7 +1385,7 @@ H5F__dest(H5F_t *f, hbool_t flush) */ if (H5AC_prep_for_file_close(f) < 0) /* Push error, but keep going */ - HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "metadata cache prep for close failed") + HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "metadata cache prep for close failed"); /* Flush at this point since the file will be closed (phase 2). * Only try to flush the file if it was opened with write access, and if @@ -1394,7 +1394,7 @@ H5F__dest(H5F_t *f, hbool_t flush) if ((H5F_ACC_RDWR & H5F_INTENT(f)) && flush) if (H5F__flush_phase2(f, TRUE) < 0) /* Push error, but keep going */ - HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 2)") + HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 2)"); /* With the shutdown modifications, the contents of the metadata cache * should be clean at this point, with the possible exception of the @@ -1408,7 +1408,7 @@ H5F__dest(H5F_t *f, hbool_t flush) if (f->shared->efc) { if (H5F__efc_destroy(f->shared->efc) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't destroy external file cache") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't destroy external file cache"); f->shared->efc = NULL; } /* end if */ @@ -1441,7 +1441,7 @@ H5F__dest(H5F_t *f, hbool_t flush) if (H5F_ACC_RDWR & H5F_INTENT(f)) { if (H5MF_close(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info"); /* at this point, only the superblock and superblock * extension should be dirty. @@ -1459,7 +1459,7 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Mark EOA info dirty in cache, so change will get encoded */ if (H5F_eoa_dirty(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty"); /* Release any space allocated to space aggregators, * so that the eoa value corresponds to the end of the @@ -1470,12 +1470,12 @@ H5F__dest(H5F_t *f, hbool_t flush) */ if (H5MF_free_aggrs(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space"); /* Truncate the file to the current allocated size */ if (H5FD_truncate(f->shared->lf, TRUE) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") + HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed"); /* at this point, only the superblock and superblock * extension should be dirty. @@ -1490,12 +1490,12 @@ H5F__dest(H5F_t *f, hbool_t flush) if (f->shared->drvinfo) if (H5AC_unpin_entry(f->shared->drvinfo) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin drvinfo") + HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin drvinfo"); /* Unpin the superblock, since we're about to destroy the cache */ if (H5AC_unpin_entry(f->shared->sblock) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") + HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock"); f->shared->sblock = NULL; } /* end if */ @@ -1509,7 +1509,7 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Remove shared file struct from list of open files */ if (H5F__sfile_remove(f->shared) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file"); /* Shutdown the metadata cache */ /* (Flushes any remaining dirty entries, which should only be the @@ -1517,12 +1517,12 @@ H5F__dest(H5F_t *f, hbool_t flush) */ if (H5AC_dest(f)) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file"); /* Shutdown the page buffer cache */ if (H5PB_dest(f->shared) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing page buffer cache") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing page buffer cache"); /* Clean up the metadata cache log location string */ if (f->shared->mdc_log_location) @@ -1536,45 +1536,45 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Free the root group */ if (H5G_root_free(f->shared->root_grp) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file"); f->shared->root_grp = NULL; } /* end if */ /* Destroy other components of the file */ if (H5F__accum_reset(f->shared, TRUE) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file"); if (H5FO_dest(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file"); f->shared->cwfs = (struct H5HG_heap_t **)H5MM_xfree(f->shared->cwfs); if (H5G_node_close(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file"); /* Destroy file creation properties */ if (H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a property list") + HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a property list"); if (H5I_dec_ref(f->shared->fcpl_id) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list"); /* Clean up the cached VOL connector ID & info */ if (f->shared->vol_info) if (H5VL_free_connector_info(f->shared->vol_id, f->shared->vol_info) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object"); if (f->shared->vol_id > 0) if (H5I_dec_ref(f->shared->vol_id) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID"); f->shared->vol_cls = NULL; /* Close the file */ if (H5FD_close(f->shared->lf) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file"); /* Free mount table */ f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child); @@ -1609,16 +1609,16 @@ H5F__dest(H5F_t *f, hbool_t flush) * and unwrap file VOL object */ if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL object wrap context") + HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL object wrap context"); if (vol_wrap_ctx && (NULL == H5VL_object_unwrap(f->vol_obj))) - HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't unwrap VOL object") + HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't unwrap VOL object"); if (H5VL_free_object(f->vol_obj) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object"); f->vol_obj = NULL; } if (H5FO_top_dest(f) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "problems closing file"); f->shared = NULL; if (ret_value >= 0) @@ -1904,7 +1904,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if (H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) { /* Locking failed - Closing will remove the lock */ if (H5FD_close(lf) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close low-level file info") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close low-level file info"); HGOTO_ERROR(H5E_FILE, H5E_CANTLOCKFILE, NULL, "unable to lock the file") } /* end if */ @@ -1915,7 +1915,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * so we have to close lf here before heading to the error handling. */ if (H5FD_close(lf) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") + HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info"); HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to initialize file structure") } /* end if */ @@ -2119,7 +2119,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) done: if ((NULL == ret_value) && file) if (H5F__dest(file, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_open() */ @@ -2174,7 +2174,7 @@ H5F__flush_phase1(H5F_t *f) /* Flush any cached dataset storage raw data */ if (H5D_flush_all(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache"); /* Release any space allocated to space aggregators, so that the eoa value * corresponds to the end of the space written to in the file. @@ -2184,7 +2184,7 @@ H5F__flush_phase1(H5F_t *f) */ if (H5MF_free_aggrs(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush_phase1() */ @@ -2211,12 +2211,12 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) /* Inform the metadata cache that we are about to flush */ if (H5AC_prep_for_file_flush(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "prep for MDC flush failed") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "prep for MDC flush failed"); /* Flush the entire metadata cache */ if (H5AC_flush(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache"); #ifdef H5_HAVE_PARALLEL if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { @@ -2232,12 +2232,12 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) /* Truncate the file to the current allocated size */ if (H5FD_truncate(f->shared->lf, closing) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed") + HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed"); /* Flush the entire metadata cache again since the EOA could have changed in the truncate call. */ if (H5AC_flush(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache"); #ifdef H5_HAVE_PARALLEL if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) @@ -2248,22 +2248,22 @@ H5F__flush_phase2(H5F_t *f, hbool_t closing) /* Inform the metadata cache that we are done with the flush */ if (H5AC_secure_from_file_flush(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "secure from MDC flush failed") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "secure from MDC flush failed"); /* Flush out the metadata accumulator */ if (H5F__accum_flush(f->shared) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator") + HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator"); /* Flush the page buffer */ if (H5PB_flush(f->shared) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "page buffer flush failed") + HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "page buffer flush failed"); /* Flush file buffers to disk. */ if (H5FD_flush(f->shared->lf, closing) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "low level flush failed") + HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "low level flush failed"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush_phase2() */ @@ -2290,12 +2290,12 @@ H5F__flush(H5F_t *f) /* First phase of flushing data */ if (H5F__flush_phase1(f) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data"); /* Second phase of flushing data */ if (H5F__flush_phase2(f, FALSE) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush file data"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__flush() */ @@ -2425,7 +2425,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) if (f->closing) { if (was_closed) *was_closed = TRUE; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* Get the number of open objects and open files on this file/mount hierarchy */ @@ -2451,13 +2451,13 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * close all objects isn't a major problem. */ if ((nopen_files + nopen_objs) > 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); break; case H5F_CLOSE_SEMI: /* Can leave safely if file IDs are still open on this file */ if (nopen_files > 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Sanity check: If close degree if "semi" and we have gotten this * far and there are objects left open, bail out now. @@ -2471,7 +2471,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) case H5F_CLOSE_STRONG: /* If there are other open files in the hierarchy, we can leave now */ if (nopen_files > 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* If we've gotten this far (ie. there are no open file IDs in the file/mount hierarchy), fall * through to flush & close */ @@ -2789,7 +2789,7 @@ done: /* Close the property list */ if (new_fapl_id > 0) if (H5I_dec_app_ref(new_fapl_id) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL"); #ifdef H5_HAVE_SYMLINK if (realname) realname = (char *)H5MM_xfree(realname); @@ -2799,7 +2799,7 @@ done: } /* H5F__build_actual_name() */ /*------------------------------------------------------------------------- - * Function: H5_addr_encode_len + * Function: H5F_addr_encode_len * * Purpose: Encodes an address into the buffer pointed to by *PP and * then increments the pointer to the first byte after the @@ -2809,7 +2809,7 @@ done: *------------------------------------------------------------------------- */ void -H5_addr_encode_len(size_t addr_len, uint8_t **pp /*in,out*/, haddr_t addr) +H5F_addr_encode_len(size_t addr_len, uint8_t **pp /*in,out*/, haddr_t addr) { unsigned u; /* Local index variable */ @@ -2832,10 +2832,10 @@ H5_addr_encode_len(size_t addr_len, uint8_t **pp /*in,out*/, haddr_t addr) } /* end else */ FUNC_LEAVE_NOAPI_VOID -} /* end H5_addr_encode_len() */ +} /* end H5F_addr_encode_len() */ /*------------------------------------------------------------------------- - * Function: H5_addr_encode + * Function: H5F_addr_encode * * Purpose: Encodes an address into the buffer pointed to by *PP and * then increments the pointer to the first byte after the @@ -2845,20 +2845,20 @@ H5_addr_encode_len(size_t addr_len, uint8_t **pp /*in,out*/, haddr_t addr) *------------------------------------------------------------------------- */ void -H5_addr_encode(const H5F_t *f, uint8_t **pp /*in,out*/, haddr_t addr) +H5F_addr_encode(const H5F_t *f, uint8_t **pp /*in,out*/, haddr_t addr) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR assert(f); - H5_addr_encode_len(H5F_SIZEOF_ADDR(f), pp, addr); + H5F_addr_encode_len(H5F_SIZEOF_ADDR(f), pp, addr); FUNC_LEAVE_NOAPI_VOID -} /* end H5_addr_encode() */ +} /* end H5F_addr_encode() */ /*------------------------------------------------------------------------- - * Function: H5_addr_decode_len + * Function: H5F_addr_decode_len * * Purpose: Decodes an address from the buffer pointed to by *PP and * updates the pointer to point to the next byte after the @@ -2871,7 +2871,7 @@ H5_addr_encode(const H5F_t *f, uint8_t **pp /*in,out*/, haddr_t addr) *------------------------------------------------------------------------- */ void -H5_addr_decode_len(size_t addr_len, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) +H5F_addr_decode_len(size_t addr_len, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) { hbool_t all_zero = TRUE; /* True if address was all zeroes */ unsigned u; /* Local index variable */ @@ -2917,10 +2917,10 @@ H5_addr_decode_len(size_t addr_len, const uint8_t **pp /*in,out*/, haddr_t *addr *addr_p = HADDR_UNDEF; FUNC_LEAVE_NOAPI_VOID -} /* end H5_addr_decode_len() */ +} /* end H5F_addr_decode_len() */ /*------------------------------------------------------------------------- - * Function: H5_addr_decode + * Function: H5F_addr_decode * * Purpose: Decodes an address from the buffer pointed to by *PP and * updates the pointer to point to the next byte after the @@ -2933,17 +2933,17 @@ H5_addr_decode_len(size_t addr_len, const uint8_t **pp /*in,out*/, haddr_t *addr *------------------------------------------------------------------------- */ void -H5_addr_decode(const H5F_t *f, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) +H5F_addr_decode(const H5F_t *f, const uint8_t **pp /*in,out*/, haddr_t *addr_p /*out*/) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR assert(f); - H5_addr_decode_len(H5F_SIZEOF_ADDR(f), pp, addr_p); + H5F_addr_decode_len(H5F_SIZEOF_ADDR(f), pp, addr_p); FUNC_LEAVE_NOAPI_VOID -} /* end H5_addr_decode() */ +} /* end H5F_addr_decode() */ /*------------------------------------------------------------------------- * Function: H5F_set_grp_btree_shared @@ -3850,12 +3850,12 @@ done: /* Re-enable accumulator */ f->shared->feature_flags |= (unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD") + HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set feature_flags in VFD"); /* Reset the # of read attempts */ f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; if (H5F_set_retries(f) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins") + HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't set retries and retries_nbins"); /* Un-set H5F_ACC_SWMR_WRITE in shared open flags */ f->shared->flags &= ~H5F_ACC_SWMR_WRITE; @@ -3865,17 +3865,17 @@ done: /* Mark superblock as dirty */ if (H5F_super_dirty(f) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty"); /* Flush the superblock */ if (H5F_flush_tagged_metadata(f, H5AC__SUPERBLOCK_TAG) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock"); } /* end if */ /* Unlock the file */ if (H5F_USE_FILE_LOCKING(f)) if (H5FD_unlock(f->shared->lf) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock the file") + HDONE_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock the file"); /* Free memory */ if (obj_ids) @@ -3891,7 +3891,7 @@ done: if (obj_apl_ids) { for (u = 0; u < grp_dset_count; u++) if (obj_apl_ids[u] != H5P_DEFAULT && obj_apl_ids[u] >= 0 && H5I_dec_ref(obj_apl_ids[u]) < 0) - HDONE_ERROR(H5E_ID, H5E_CANTDEC, FAIL, "decrementing property list ID failed") + HDONE_ERROR(H5E_ID, H5E_CANTDEC, FAIL, "decrementing property list ID failed"); H5MM_xfree(obj_apl_ids); } @@ -4022,7 +4022,7 @@ H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_FILE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_file_id() */ diff --git a/src/H5Fio.c b/src/H5Fio.c index 6b0e9ab..1924004 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -415,37 +415,10 @@ H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_flush_tagged_metadata */ /*------------------------------------------------------------------------- - * Function: H5F_evict_tagged_metadata - * - * Purpose: Evicts metadata from the cache with specified tag. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mike McGreevy - * September 9, 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5F_evict_tagged_metadata(H5F_t *f, haddr_t tag) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Evict the object's metadata */ - if (H5AC_evict_tagged_metadata(f, tag, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "unable to evict tagged metadata") - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5F_evict_tagged_metadata */ - -/*------------------------------------------------------------------------- * Function: H5F__evict_cache_entries * * Purpose: To evict all cache entries except the pinned superblock entry @@ -492,7 +465,7 @@ H5F__evict_cache_entries(H5F_t *f) #endif /* NDEBUG */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__evict_cache_entries() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fmount.c b/src/H5Fmount.c index b17baea..1049bdc 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -65,8 +65,8 @@ H5F__close_mounts(H5F_t *f) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child file") /* Eliminate the mount point from the table */ - HDmemmove(f->shared->mtab.child + u, f->shared->mtab.child + u + 1, - (f->shared->mtab.nmounts - u - 1) * sizeof(f->shared->mtab.child[0])); + memmove(f->shared->mtab.child + u, f->shared->mtab.child + u + 1, + (f->shared->mtab.nmounts - u - 1) * sizeof(f->shared->mtab.child[0])); f->shared->mtab.nmounts--; f->nmounts--; } @@ -195,8 +195,8 @@ H5F_mount(const H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UN } /* Insert into table */ - HDmemmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md, - (parent->shared->mtab.nmounts - md) * sizeof(parent->shared->mtab.child[0])); + memmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md, + (parent->shared->mtab.nmounts - md) * sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts++; parent->nmounts++; parent->shared->mtab.child[md].group = mount_point; @@ -223,11 +223,11 @@ done: if (ret_value < 0) { if (mount_point) { if (H5G_close(mount_point) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group"); } else { if (H5G_loc_free(&mp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location"); } } @@ -356,10 +356,10 @@ H5F_unmount(const H5G_loc_t *loc, const char *name) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ - HDmemmove(parent->shared->mtab.child + (unsigned)child_idx, - (parent->shared->mtab.child + (unsigned)child_idx) + 1, - ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * - sizeof(parent->shared->mtab.child[0])); + memmove(parent->shared->mtab.child + (unsigned)child_idx, + (parent->shared->mtab.child + (unsigned)child_idx) + 1, + ((parent->shared->mtab.nmounts - (unsigned)child_idx) - 1) * + sizeof(parent->shared->mtab.child[0])); parent->shared->mtab.nmounts -= 1; parent->nmounts -= 1; diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 8b17aba..1a9b624 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -207,7 +207,7 @@ H5F__set_mpi_atomicity(H5F_t *file, hbool_t flag) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set atomicity flag"); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__set_mpi_atomicity() */ /*------------------------------------------------------------------------- @@ -228,7 +228,7 @@ H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL); + FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, flag); /* Get the file object */ @@ -245,7 +245,7 @@ H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set MPI atomicity"); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Fset_mpi_atomicity() */ /*------------------------------------------------------------------------- @@ -278,7 +278,7 @@ H5F__get_mpi_atomicity(const H5F_t *file, hbool_t *flag) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get atomicity flag"); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_mpi_atomicity() */ /*------------------------------------------------------------------------- @@ -299,7 +299,7 @@ H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag /*out*/) H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL); + FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", file_id, flag); /* Get the file object */ @@ -316,7 +316,7 @@ H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag /*out*/) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MPI atomicity"); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Fget_mpi_atomicity() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index f91fa85..aa62800 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -17,273 +17,25 @@ #ifndef H5Fprivate_H #define H5Fprivate_H -/* Early typedefs to avoid circular dependencies */ +/* This definition has to be early, before the other private headers, + * due to circular dependencies. + */ typedef struct H5F_t H5F_t; /* Include package's public header */ #include "H5Fpublic.h" /* Private headers needed by this file */ -#include "H5MMprivate.h" /* Memory management */ #include "H5FDprivate.h" /* File drivers */ #ifdef H5_HAVE_PARALLEL -#include "H5Pprivate.h" /* Property lists */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5Pprivate.h" /* Property lists */ +#endif #include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ /* Library Private Macros */ /**************************/ -/* - * Encode and decode macros for file meta-data. - * Currently, all file meta-data is little-endian. - */ - -#define INT16ENCODE(p, i) \ - { \ - *(p) = (uint8_t)((unsigned)(i)&0xff); \ - (p)++; \ - *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ - (p)++; \ - } - -#define UINT16ENCODE(p, i) \ - { \ - *(p) = (uint8_t)((unsigned)(i)&0xff); \ - (p)++; \ - *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ - (p)++; \ - } - -#define INT32ENCODE(p, i) \ - { \ - *(p) = (uint8_t)((uint32_t)(i)&0xff); \ - (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff); \ - (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff); \ - (p)++; \ - *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff); \ - (p)++; \ - } - -#define UINT32ENCODE(p, i) \ - { \ - *(p) = (uint8_t)((i)&0xff); \ - (p)++; \ - *(p) = (uint8_t)(((i) >> 8) & 0xff); \ - (p)++; \ - *(p) = (uint8_t)(((i) >> 16) & 0xff); \ - (p)++; \ - *(p) = (uint8_t)(((i) >> 24) & 0xff); \ - (p)++; \ - } - -/* Encode an unsigned integer into a variable-sized buffer */ -/* (Assumes that the high bits of the integer are zero) */ -#define ENCODE_VAR(p, typ, n, l) \ - { \ - typ _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t *)(p); \ - \ - for (_i = 0; _i < l; _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t *)(p) + l; \ - } - -/* Encode a 32-bit unsigned integer into a variable-sized buffer */ -/* (Assumes that the high bits of the integer are zero) */ -#define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) - -#define INT64ENCODE(p, n) \ - { \ - int64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t *)(p); \ - \ - for (_i = 0; _i < sizeof(int64_t); _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - for (/*void*/; _i < 8; _i++) \ - *_p++ = (uint8_t)((n) < 0 ? 0xff : 0); \ - (p) = (uint8_t *)(p) + 8; \ - } - -#define UINT64ENCODE(p, n) \ - { \ - uint64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t *)(p); \ - \ - for (_i = 0; _i < sizeof(uint64_t); _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - for (/*void*/; _i < 8; _i++) \ - *_p++ = 0; \ - (p) = (uint8_t *)(p) + 8; \ - } - -/* Encode a 64-bit unsigned integer into a variable-sized buffer */ -/* (Assumes that the high bits of the integer are zero) */ -#define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) - -/* Encode a 64-bit unsigned integer and its length into a variable-sized buffer */ -/* (Assumes that the high bits of the integer are zero) */ -#define UINT64ENCODE_VARLEN(p, n) \ - { \ - uint64_t __n = (uint64_t)(n); \ - unsigned _s = H5VM_limit_enc_size(__n); \ - \ - *(p)++ = (uint8_t)_s; \ - UINT64ENCODE_VAR(p, __n, _s); \ - } - -#define H5_ENCODE_UNSIGNED(p, n) \ - { \ - HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ - UINT32ENCODE(p, n) \ - } - -/* Assumes the endianness of uint64_t is the same as double */ -#define H5_ENCODE_DOUBLE(p, n) \ - { \ - uint64_t _n; \ - size_t _u; \ - uint8_t *_p = (uint8_t *)(p); \ - \ - HDcompile_assert(sizeof(double) == 8); \ - HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ - H5MM_memcpy(&_n, &n, sizeof(double)); \ - for (_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t *)(p) + 8; \ - } - -/* DECODE converts little endian bytes pointed by p to integer values and store - * it in i. For signed values, need to do sign-extension when converting - * the last byte which carries the sign bit. - * The macros does not require i be of a certain byte sizes. It just requires - * i be big enough to hold the intended value range. E.g. INT16DECODE works - * correctly even if i is actually a 64bit int like in a Cray. - */ - -#define INT16DECODE(p, i) \ - { \ - (i) = (int16_t)((*(p)&0xff)); \ - (p)++; \ - (i) |= (int16_t)(((*(p)&0xff) << 8) | ((*(p)&0x80) ? ~0xffff : 0x0)); \ - (p)++; \ - } - -#define UINT16DECODE(p, i) \ - { \ - (i) = (uint16_t)(*(p)&0xff); \ - (p)++; \ - (i) |= (uint16_t)((*(p)&0xff) << 8); \ - (p)++; \ - } - -#define INT32DECODE(p, i) \ - { \ - (i) = ((int32_t)(*(p)&0xff)); \ - (p)++; \ - (i) |= ((int32_t)(*(p)&0xff) << 8); \ - (p)++; \ - (i) |= ((int32_t)(*(p)&0xff) << 16); \ - (p)++; \ - (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | ((*(p)&0x80) ? ~0xffffffffULL : 0x0ULL))); \ - (p)++; \ - } - -#define UINT32DECODE(p, i) \ - { \ - (i) = (uint32_t)(*(p)&0xff); \ - (p)++; \ - (i) |= ((uint32_t)(*(p)&0xff) << 8); \ - (p)++; \ - (i) |= ((uint32_t)(*(p)&0xff) << 16); \ - (p)++; \ - (i) |= ((uint32_t)(*(p)&0xff) << 24); \ - (p)++; \ - } - -/* Decode a variable-sized buffer */ -/* (Assumes that the high bits of the integer will be zero) */ -#define DECODE_VAR(p, n, l) \ - { \ - size_t _i; \ - \ - n = 0; \ - (p) += l; \ - for (_i = 0; _i < l; _i++) \ - n = (n << 8) | *(--p); \ - (p) += l; \ - } - -/* Decode a variable-sized buffer into a 32-bit unsigned integer */ -/* (Assumes that the high bits of the integer will be zero) */ -#define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) - -#define INT64DECODE(p, n) \ - { \ - /* WE DON'T CHECK FOR OVERFLOW! */ \ - size_t _i; \ - \ - n = 0; \ - (p) += 8; \ - for (_i = 0; _i < sizeof(int64_t); _i++) \ - n = (n << 8) | *(--p); \ - (p) += 8; \ - } - -#define UINT64DECODE(p, n) \ - { \ - /* WE DON'T CHECK FOR OVERFLOW! */ \ - size_t _i; \ - \ - n = 0; \ - (p) += 8; \ - for (_i = 0; _i < sizeof(uint64_t); _i++) \ - n = (n << 8) | *(--p); \ - (p) += 8; \ - } - -/* Decode a variable-sized buffer into a 64-bit unsigned integer */ -/* (Assumes that the high bits of the integer will be zero) */ -#define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) - -/* Decode a 64-bit unsigned integer and its length from a variable-sized buffer */ -/* (Assumes that the high bits of the integer will be zero) */ -#define UINT64DECODE_VARLEN(p, n) \ - { \ - unsigned _s = *(p)++; \ - \ - UINT64DECODE_VAR(p, n, _s); \ - } - -#define H5_DECODE_UNSIGNED(p, n) \ - { \ - HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ - UINT32DECODE(p, n) \ - } - -/* Assumes the endianness of uint64_t is the same as double */ -#define H5_DECODE_DOUBLE(p, n) \ - { \ - uint64_t _n; \ - size_t _u; \ - \ - HDcompile_assert(sizeof(double) == 8); \ - HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ - _n = 0; \ - (p) += 8; \ - for (_u = 0; _u < sizeof(uint64_t); _u++) \ - _n = (_n << 8) | *(--p); \ - H5MM_memcpy(&(n), &_n, sizeof(double)); \ - (p) += 8; \ - } - /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5F_MODULE #define H5F_LOW_BOUND(F) ((F)->shared->low_bound) @@ -414,39 +166,8 @@ typedef struct H5F_t H5F_t; #endif /* H5F_MODULE */ /* Macros to encode/decode offset/length's for storing in the file */ -#define H5F_ENCODE_LENGTH_LEN(p, l, s) \ - switch (s) { \ - case 4: \ - UINT32ENCODE(p, l); \ - break; \ - case 8: \ - UINT64ENCODE(p, l); \ - break; \ - case 2: \ - UINT16ENCODE(p, l); \ - break; \ - default: \ - assert("bad sizeof size" && 0); \ - } - -#define H5F_ENCODE_LENGTH(f, p, l) H5F_ENCODE_LENGTH_LEN(p, l, H5F_SIZEOF_SIZE(f)) - -#define H5F_DECODE_LENGTH_LEN(p, l, s) \ - switch (s) { \ - case 4: \ - UINT32DECODE(p, l); \ - break; \ - case 8: \ - UINT64DECODE(p, l); \ - break; \ - case 2: \ - UINT16DECODE(p, l); \ - break; \ - default: \ - assert("bad sizeof size" && 0); \ - } - -#define H5F_DECODE_LENGTH(f, p, l) DECODE_VAR(p, l, H5F_SIZEOF_SIZE(f)) +#define H5F_ENCODE_LENGTH(f, p, l) H5_ENCODE_LENGTH_LEN(p, l, H5F_SIZEOF_SIZE(f)) +#define H5F_DECODE_LENGTH(f, p, l) H5_DECODE_LENGTH_LEN(p, l, H5F_SIZEOF_SIZE(f)) /* * Macros that check for overflows. These are somewhat dangerous to fiddle @@ -883,7 +604,6 @@ H5_DLL herr_t H5F_shared_vector_write(H5F_shared_t *f_sh, uint32_t count, H5FD_m /* Functions that flush or evict */ H5_DLL herr_t H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag); -H5_DLL herr_t H5F_evict_tagged_metadata(H5F_t *f, haddr_t tag); /* Functions that verify a piece of metadata with checksum */ H5_DLL herr_t H5F_get_checksums(const uint8_t *buf, size_t chk_size, uint32_t *s_chksum, uint32_t *c_chksum); @@ -897,10 +617,10 @@ H5_DLL herr_t H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *in H5_DLL herr_t H5F_object_flush_cb(H5F_t *f, hid_t obj_id); /* Address-related functions */ -H5_DLL void H5_addr_encode(const H5F_t *f, uint8_t **pp, haddr_t addr); -H5_DLL void H5_addr_encode_len(size_t addr_len, uint8_t **pp, haddr_t addr); -H5_DLL void H5_addr_decode(const H5F_t *f, const uint8_t **pp, haddr_t *addr_p); -H5_DLL void H5_addr_decode_len(size_t addr_len, const uint8_t **pp, haddr_t *addr_p); +H5_DLL void H5F_addr_encode(const H5F_t *f, uint8_t **pp, haddr_t addr); +H5_DLL void H5F_addr_encode_len(size_t addr_len, uint8_t **pp, haddr_t addr); +H5_DLL void H5F_addr_decode(const H5F_t *f, const uint8_t **pp, haddr_t *addr_p); +H5_DLL void H5F_addr_decode_len(size_t addr_len, const uint8_t **pp, haddr_t *addr_p); /* Shared file list related routines */ H5_DLL void H5F_sfile_assert_num(unsigned n); diff --git a/src/H5Fsfile.c b/src/H5Fsfile.c index 23043fb..312ddf0 100644 --- a/src/H5Fsfile.c +++ b/src/H5Fsfile.c @@ -35,7 +35,7 @@ typedef struct H5F_sfile_node_t { H5FL_DEFINE_STATIC(H5F_sfile_node_t); /* Declare a local variable to track the shared file information */ -H5F_sfile_node_t *H5F_sfile_head_g = NULL; +static H5F_sfile_node_t *H5F_sfile_head_s = NULL; /*------------------------------------------------------------------------- * Function: H5F_sfile_assert_num @@ -53,14 +53,14 @@ H5F_sfile_assert_num(unsigned n) if (n == 0) { /* Sanity checking */ - assert(H5F_sfile_head_g == NULL); + assert(H5F_sfile_head_s == NULL); } /* end if */ else { unsigned count; /* Number of open shared files */ H5F_sfile_node_t *curr; /* Current shared file node */ /* Iterate through low-level files for matching low-level file info */ - curr = H5F_sfile_head_g; + curr = H5F_sfile_head_s; count = 0; while (curr) { /* Increment # of open shared file structs */ @@ -105,8 +105,8 @@ H5F__sfile_add(H5F_shared_t *shared) new_shared->shared = shared; /* Prepend to list of shared files open */ - new_shared->next = H5F_sfile_head_g; - H5F_sfile_head_g = new_shared; + new_shared->next = H5F_sfile_head_s; + H5F_sfile_head_s = new_shared; done: FUNC_LEAVE_NOAPI(ret_value) @@ -134,11 +134,11 @@ H5F__sfile_search(H5FD_t *lf) assert(lf); /* Iterate through low-level files for matching low-level file info */ - curr = H5F_sfile_head_g; + curr = H5F_sfile_head_s; while (curr) { /* Check for match */ if (0 == H5FD_cmp(curr->shared->lf, lf)) - HGOTO_DONE(curr->shared) + HGOTO_DONE(curr->shared); /* Advance to next shared file node */ curr = curr->next; @@ -171,7 +171,7 @@ H5F__sfile_remove(H5F_shared_t *shared) /* Locate shared file node with correct shared file */ last = NULL; - curr = H5F_sfile_head_g; + curr = H5F_sfile_head_s; while (curr && curr->shared != shared) { /* Advance to next node */ last = curr; @@ -188,7 +188,7 @@ H5F__sfile_remove(H5F_shared_t *shared) last->next = curr->next; else /* Removing head node in list */ - H5F_sfile_head_g = curr->next; + H5F_sfile_head_s = curr->next; /* Release the shared file node struct */ /* (the shared file info itself is freed elsewhere) */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index fff70ac..63164dd 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -238,7 +238,6 @@ H5F__update_super_ext_driver_msg(H5F_t *f) assert(f->shared); sblock = f->shared->sblock; assert(sblock); - assert(sblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sblock->cache_info.type == H5AC_SUPERBLOCK); /* Update the driver information message in the superblock extension @@ -368,7 +367,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) { status = H5FD_locate_signature(file, &super_addr); } - H5E_END_TRY; + H5E_END_TRY /* Set superblock address to undefined on error */ if (status < 0) @@ -556,22 +555,21 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * Make sure that the data is not truncated. One case where this is * possible is if the first file of a family of files was opened * individually. - */ - /* Can skip this test when it is not the initial file open-- - * H5F__super_read() call from H5F_evict_tagged_metadata() for - * refreshing object. + * + * Can skip this test when it is not the initial file open. + * * When flushing file buffers and fractal heap is involved, * the library will allocate actual space for tmp addresses * via the file layer. The aggregator allocates a block, * thus the eoa might be greater than eof. * Note: the aggregator is changed again after being reset * earlier before H5AC_flush due to allocation of tmp addresses. - */ - /* The EOF check must be skipped when the file is opened for SWMR read, + * + * The EOF check must be skipped when the file is opened for SWMR read, * as the file can appear truncated if only part of it has been * been flushed to disk by the SWMR writer process. - */ - /* The EOF check is also skipped when the private property + * + * The EOF check is also skipped when the private property * H5F_ACS_SKIP_EOF_CHECK_NAME exists in the fapl. * This property is enabled by the tool h5clear with these * two options: (1) --filesize (2) --increment @@ -592,7 +590,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) (sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) skip_eof_check = TRUE; - } /* end if */ + } if (!skip_eof_check && initial_read) { if (HADDR_UNDEF == (eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to determine file size") @@ -603,7 +601,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) "truncated file: eof = %llu, sblock->base_addr = %llu, stored_eof = %llu", (unsigned long long)eof, (unsigned long long)sblock->base_addr, (unsigned long long)udata.stored_eof) - } /* end if */ + } /* * Tell the file driver how much address space has already been @@ -1020,7 +1018,7 @@ done: /* Release the superblock */ if (sblock && H5AC_unprotect(f, H5AC_SUPERBLOCK, (haddr_t)0, sblock, sblock_flags) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTUNPROTECT, FAIL, "unable to close superblock"); /* If we have failed, make sure no entries are left in the * metadata cache, so that it can be shut down and discarded. @@ -1029,12 +1027,12 @@ done: /* Unpin and discard drvinfo cache entry */ if (f->shared->drvinfo) { if (H5AC_unpin_entry(f->shared->drvinfo) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info") + HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info"); /* Evict the driver info block from the cache */ if (sblock) { if (H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block") + HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block"); f->shared->drvinfo = NULL; } } /* end if */ @@ -1043,11 +1041,11 @@ done: if (sblock) { /* Unpin superblock in cache */ if (H5AC_unpin_entry(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock"); /* Evict the superblock from the cache */ if (H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock"); f->shared->sblock = NULL; } /* end if */ } /* end if */ @@ -1446,7 +1444,7 @@ done: /* Close superblock extension, if it was created */ if (ext_created && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension"); /* Cleanup on failure */ if (ret_value < 0) { @@ -1456,11 +1454,11 @@ done: if (drvinfo_in_cache) { /* Unpin drvinfo in cache */ if (H5AC_unpin_entry(drvinfo) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info") + HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info"); /* Evict the driver info block from the cache */ if (H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block") + HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block"); } /* end if */ else /* Free driver info block */ @@ -1473,16 +1471,16 @@ done: if (sblock_in_cache) { /* Unpin superblock in cache */ if (H5AC_unpin_entry(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock"); /* Evict the superblock from the cache */ if (H5AC_expunge_entry(f, H5AC_SUPERBLOCK, (haddr_t)0, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge superblock"); } /* end if */ else /* Free superblock */ if (H5F__super_free(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock"); /* Reset variables in file structure */ f->shared->sblock = NULL; @@ -1727,11 +1725,11 @@ done: /* Close the superblock extension, if it was opened */ if (ext_opened && H5F__super_ext_close(f, &ext_loc, ext_created) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension"); /* Mark superblock dirty in cache, if superblock extension was created */ if (ext_created && H5AC_mark_entry_dirty(f->shared->sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty"); FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_write_msg() */ @@ -1803,7 +1801,7 @@ done: /* Close superblock extension object header, if opened */ if (ext_opened && H5F__super_ext_close(f, &ext_loc, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension") + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension"); FUNC_LEAVE_NOAPI(ret_value) } /* H5F__super_ext_remove_msg() */ diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index b199451..70a8888 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -524,10 +524,10 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata, /* Remainder of "variable-sized" portion of superblock */ if (H5_IS_BUFFER_OVERFLOW(image, H5F_sizeof_addr(udata->f) * 4, end)) HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") - H5_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); - H5_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr /*out*/); - H5_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof /*out*/); - H5_addr_decode(udata->f, (const uint8_t **)&image, &sblock->driver_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->driver_addr /*out*/); /* Allocate space for the root group symbol table entry */ if (sblock->root_ent) @@ -580,10 +580,10 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata, HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") /* Base, superblock extension, end of file & root group object header addresses */ - H5_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); - H5_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr /*out*/); - H5_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof /*out*/); - H5_addr_decode(udata->f, (const uint8_t **)&image, &sblock->root_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof /*out*/); + H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->root_addr /*out*/); /* checksum verification already done in verify_chksum cb */ @@ -604,7 +604,7 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata, /* Size check */ if ((size_t)(image - (const uint8_t *)_image) > len) - HDONE_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad decoded superblock size") + HDONE_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad decoded superblock size"); ret_value = sblock; @@ -612,7 +612,7 @@ done: /* Release the [possibly partially initialized] superblock on error */ if (!ret_value && sblock) if (H5F__super_free(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data") + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_deserialize() */ @@ -633,7 +633,6 @@ H5F__cache_superblock_image_len(const void *_thing, size_t *image_len) FUNC_ENTER_PACKAGE_NOERR assert(sblock); - assert(sblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sblock->cache_info.type == H5AC_SUPERBLOCK); assert(image_len); @@ -702,10 +701,10 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU } /* end if */ /* Encode the base address */ - H5_addr_encode(f, &image, sblock->base_addr); + H5F_addr_encode(f, &image, sblock->base_addr); /* Encode the address of global free-space index */ - H5_addr_encode(f, &image, sblock->ext_addr); + H5F_addr_encode(f, &image, sblock->ext_addr); /* Encode the end-of-file address. Note that at this point in time, * the EOF value itself may not be reflective of the file's size, as @@ -714,10 +713,10 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU * value will ultimately match it. */ if ((rel_eof = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - H5_addr_encode(f, &image, (rel_eof + sblock->base_addr)); + H5F_addr_encode(f, &image, (rel_eof + sblock->base_addr)); /* Encode the driver information block address */ - H5_addr_encode(f, &image, sblock->driver_addr); + H5F_addr_encode(f, &image, sblock->driver_addr); /* Encode the root group object entry, including the cached stab info */ if (H5G_ent_encode(f, &image, sblock->root_ent) < 0) @@ -736,10 +735,10 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU *image++ = sblock->status_flags; /* Encode the base address */ - H5_addr_encode(f, &image, sblock->base_addr); + H5F_addr_encode(f, &image, sblock->base_addr); /* Encode the address of the superblock extension */ - H5_addr_encode(f, &image, sblock->ext_addr); + H5F_addr_encode(f, &image, sblock->ext_addr); /* At this point in time, the EOF value itself may * not be reflective of the file's size, since we'll eventually @@ -748,14 +747,14 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU * ultimately match it. */ if ((rel_eof = H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") - H5_addr_encode(f, &image, (rel_eof + sblock->base_addr)); + H5F_addr_encode(f, &image, (rel_eof + sblock->base_addr)); /* Retrieve information for root group */ if (NULL == (root_oloc = H5G_oloc(f->shared->root_grp))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to retrieve root group information") /* Encode address of root group's object header */ - H5_addr_encode(f, &image, root_oloc->addr); + H5F_addr_encode(f, &image, root_oloc->addr); /* Compute superblock checksum */ chksum = H5_checksum_metadata(_image, ((size_t)H5F_SUPERBLOCK_SIZE(sblock) - H5F_SIZEOF_CHKSUM), 0); @@ -780,10 +779,6 @@ done: * Purpose: Destroy/release an "in core representation" of a data * structure * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ @@ -796,7 +791,6 @@ H5F__cache_superblock_free_icr(void *_thing) FUNC_ENTER_PACKAGE assert(sblock); - assert(sblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(sblock->cache_info.type == H5AC_SUPERBLOCK); /* Destroy superblock */ @@ -933,7 +927,6 @@ H5F__cache_drvrinfo_image_len(const void *_thing, size_t *image_len) FUNC_ENTER_PACKAGE_NOERR assert(drvinfo); - assert(drvinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(drvinfo->cache_info.type == H5AC_DRVRINFO); assert(image_len); @@ -965,7 +958,6 @@ H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBU assert(f); assert(image); assert(drvinfo); - assert(drvinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(drvinfo->cache_info.type == H5AC_DRVRINFO); assert(len == (size_t)(H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo->len)); @@ -1001,10 +993,6 @@ done: * Purpose: Destroy/release an "in core representation" of a data * structure * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ @@ -1016,7 +1004,6 @@ H5F__cache_drvrinfo_free_icr(void *_thing) FUNC_ENTER_PACKAGE_NOERR assert(drvinfo); - assert(drvinfo->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(drvinfo->cache_info.type == H5AC_DRVRINFO); /* Destroy driver info message */ diff --git a/src/H5Ftest.c b/src/H5Ftest.c index d54b8ad..d56461b 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -103,7 +103,7 @@ H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_coun done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_sohm_mesg_count_test() */ @@ -144,7 +144,7 @@ H5F__check_cached_stab_test(hid_t file_id) done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__check_cached_stab_test() */ diff --git a/src/H5G.c b/src/H5G.c index 88e7235..f15f250 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -190,7 +190,7 @@ H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl done: if (H5I_INVALID_HID == ret_value) if (grp && H5VL_group_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__create_api_common() */ @@ -273,7 +273,7 @@ H5Gcreate_async(const char *app_file, const char *app_func, unsigned app_line, h H5ARG_TRACE9(__func__, "*s*sIui*siiii", app_file, app_func, app_line, loc_id, name, lcpl_id, gcpl_id, gapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on group ID") + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on group ID"); HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -360,7 +360,7 @@ done: /* Cleanup on failure */ if (H5I_INVALID_HID == ret_value) if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); FUNC_LEAVE_API(ret_value) } /* end H5Gcreate_anon() */ @@ -409,7 +409,7 @@ H5G__open_api_common(hid_t loc_id, const char *name, hid_t gapl_id, void **token done: if (H5I_INVALID_HID == ret_value) if (grp && H5VL_group_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__open_api_common() */ @@ -482,7 +482,7 @@ H5Gopen_async(const char *app_file, const char *app_func, unsigned app_line, hid H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, gapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on group ID") + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on group ID"); HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -952,7 +952,7 @@ H5Gclose_async(const char *app_file, const char *app_func, unsigned app_line, hi done: if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't decrement ref count on connector") + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); FUNC_LEAVE_API(ret_value) } /* end H5Gclose_async() */ diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 7b94328..ba10f51 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -266,7 +266,7 @@ H5G__dense_btree2_name_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR_U FUNC_ENTER_PACKAGE_NOERR /* Encode the record's fields */ - UINT32ENCODE(raw, nrecord->hash) + UINT32ENCODE(raw, nrecord->hash); H5MM_memcpy(raw, nrecord->id, (size_t)H5G_DENSE_FHEAP_ID_LEN); FUNC_LEAVE_NOAPI(SUCCEED) @@ -290,7 +290,7 @@ H5G__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U FUNC_ENTER_PACKAGE_NOERR /* Decode the record's fields */ - UINT32DECODE(raw, nrecord->hash) + UINT32DECODE(raw, nrecord->hash); H5MM_memcpy(nrecord->id, raw, (size_t)H5G_DENSE_FHEAP_ID_LEN); FUNC_LEAVE_NOAPI(SUCCEED) @@ -399,7 +399,7 @@ H5G__dense_btree2_corder_encode(uint8_t *raw, const void *_nrecord, void H5_ATTR FUNC_ENTER_PACKAGE_NOERR /* Encode the record's fields */ - INT64ENCODE(raw, nrecord->corder) + INT64ENCODE(raw, nrecord->corder); H5MM_memcpy(raw, nrecord->id, (size_t)H5G_DENSE_FHEAP_ID_LEN); FUNC_LEAVE_NOAPI(SUCCEED) @@ -423,7 +423,7 @@ H5G__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR FUNC_ENTER_PACKAGE_NOERR /* Decode the record's fields */ - INT64DECODE(raw, nrecord->corder) + INT64DECODE(raw, nrecord->corder); H5MM_memcpy(nrecord->id, raw, (size_t)H5G_DENSE_FHEAP_ID_LEN); FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 853c62f..e4e42a7 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -194,7 +194,7 @@ H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, hbool_ done: if (!ret_value) if (sym && H5G__node_free(sym) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, NULL, "unable to destroy symbol table node") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, NULL, "unable to destroy symbol table node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__cache_node_deserialize() */ @@ -216,7 +216,6 @@ H5G__cache_node_image_len(const void *_thing, size_t *image_len) FUNC_ENTER_PACKAGE_NOERR assert(sym); - assert(sym->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sym->cache_info.type == H5AC_SNODE); assert(image_len); @@ -248,7 +247,6 @@ H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, void *_thing assert(f); assert(image); assert(sym); - assert(sym->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(sym->cache_info.type == H5AC_SNODE); assert(len == sym->node_size); @@ -281,10 +279,6 @@ done: * * Purpose: Destroy a symbol table node in memory * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ @@ -297,7 +291,6 @@ H5G__cache_node_free_icr(void *_thing) FUNC_ENTER_PACKAGE assert(sym); - assert(sym->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(sym->cache_info.type == H5AC_SNODE); /* Destroy symbol table node */ diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index bdb8f9a..c0dc257 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -226,7 +226,7 @@ H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5 done: /* Release link table */ if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_get_name_by_idx() */ @@ -261,7 +261,7 @@ H5G__compact_remove_common_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, vo HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get object type") /* Stop the iteration, we found the correct link */ - HGOTO_DONE(H5_ITER_STOP) + HGOTO_DONE(H5_ITER_STOP); } /* end if */ done: @@ -343,7 +343,7 @@ H5G__compact_remove_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5RS done: /* Release link table */ if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_remove_by_idx() */ @@ -383,7 +383,7 @@ H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t done: /* Release link table */ if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_iterate() */ @@ -423,7 +423,7 @@ H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_ud *udata->found = TRUE; /* Stop iteration now */ - HGOTO_DONE(H5_ITER_STOP) + HGOTO_DONE(H5_ITER_STOP); } /* end if */ done: @@ -507,7 +507,7 @@ H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_i done: /* Release link table */ if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup_by_idx() */ diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 7e96d16..158b811 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -322,11 +322,11 @@ H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline) done: /* Close the open objects */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_create() */ @@ -419,13 +419,13 @@ H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk) done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); if (wb && H5WB_unwrap(wb) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_insert() */ @@ -513,9 +513,9 @@ H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, hbool_t done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup() */ @@ -683,11 +683,11 @@ H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index"); if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_lookup_by_idx() */ @@ -970,11 +970,11 @@ H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_i done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index"); if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_iterate() */ @@ -1159,11 +1159,11 @@ H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, H5 done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index"); if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_get_name_by_idx() */ @@ -1223,7 +1223,7 @@ H5G__dense_remove_fh_cb(const void *obj, size_t obj_len, void *_udata) done: /* Release resources */ if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index"); if (lnk) H5O_msg_free(H5O_LINK_ID, lnk); @@ -1321,9 +1321,9 @@ H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_ done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove() */ @@ -1454,7 +1454,7 @@ H5G__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) done: /* Release resources */ if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for 'other' index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for 'other' index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_by_idx_bt2_cb() */ @@ -1555,11 +1555,11 @@ H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_ful done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for index"); if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_remove_by_idx() */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 65e71e8..b385df1 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -222,11 +222,11 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) done: if (H5I_INVALID_HID != tmp_gcpl && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) if (H5I_dec_ref(tmp_gcpl) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release property list") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release property list"); if (H5I_INVALID_HID == ret_value) if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); FUNC_LEAVE_API(ret_value) } /* end H5Gcreate1() */ @@ -280,7 +280,7 @@ H5Gopen1(hid_t loc_id, const char *name) done: if (H5I_INVALID_HID == ret_value) if (grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group"); FUNC_LEAVE_API(ret_value) } /* end H5Gopen1() */ @@ -932,7 +932,7 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t * H5VL_native_group_optional_args_t grp_opt_args; /* Arguments for optional operation */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL); + FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sbx", loc_id, name, follow_link, statbuf); /* Check arguments */ @@ -962,7 +962,7 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t * HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Gget_objinfo() */ /*------------------------------------------------------------------------- @@ -1045,7 +1045,7 @@ done: * location for the object */ *own_loc = H5G_OWN_NONE; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_objinfo_cb() */ /*------------------------------------------------------------------------- @@ -1067,7 +1067,7 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5 H5G_trav_goi_t udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE; + FUNC_ENTER_PACKAGE /* Sanity checks */ assert(loc); @@ -1099,7 +1099,7 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5 { ret = H5L_get_info(loc, name, &linfo); } - H5E_END_TRY; + H5E_END_TRY if (ret >= 0 && linfo.type != H5L_TYPE_HARD) { statbuf->linklen = linfo.u.val_size; @@ -1115,7 +1115,7 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5 } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_objinfo() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gent.c b/src/H5Gent.c index 74b83f9..4710ff1 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -128,7 +128,7 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, const uint8 if (H5_IS_BUFFER_OVERFLOW(*pp, H5F_SIZEOF_ADDR(f) + sizeof(uint32_t), p_end)) HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, FAIL, "image pointer is out of bounds") - H5_addr_decode(f, pp, &(ent->header)); + H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ @@ -146,8 +146,8 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, const uint8 assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); if (H5_IS_BUFFER_OVERFLOW(*pp, H5F_SIZEOF_ADDR(f) * 2, p_end)) HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, FAIL, "image pointer is out of bounds") - H5_addr_decode(f, pp, &(ent->cache.stab.btree_addr)); - H5_addr_decode(f, pp, &(ent->cache.stab.heap_addr)); + H5F_addr_decode(f, pp, &(ent->cache.stab.btree_addr)); + H5F_addr_decode(f, pp, &(ent->cache.stab.heap_addr)); break; case H5G_CACHED_SLINK: @@ -232,7 +232,7 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) if (ent) { /* encode header */ H5F_ENCODE_LENGTH(f, *pp, ent->name_off); - H5_addr_encode(f, pp, ent->header); + H5F_addr_encode(f, pp, ent->header); UINT32ENCODE(*pp, ent->type); UINT32ENCODE(*pp, 0); /*reserved*/ @@ -243,8 +243,8 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) case H5G_CACHED_STAB: assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH); - H5_addr_encode(f, pp, ent->cache.stab.btree_addr); - H5_addr_encode(f, pp, ent->cache.stab.heap_addr); + H5F_addr_encode(f, pp, ent->cache.stab.btree_addr); + H5F_addr_encode(f, pp, ent->cache.stab.heap_addr); break; case H5G_CACHED_SLINK: @@ -259,7 +259,7 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) } /* end if */ else { H5F_ENCODE_LENGTH(f, *pp, 0); - H5_addr_encode(f, pp, HADDR_UNDEF); + H5F_addr_encode(f, pp, HADDR_UNDEF); UINT32ENCODE(*pp, H5G_NOTHING_CACHED); UINT32ENCODE(*pp, 0); /*reserved*/ } /* end else */ @@ -309,7 +309,6 @@ H5G__ent_copy(H5G_entry_t *dst, H5G_entry_t *src, H5_copy_depth_t depth) /* Deep copy the names */ if (depth == H5_COPY_DEEP) { /* Nothing currently */ - ; } else if (depth == H5_COPY_SHALLOW) { H5G__ent_reset(src); diff --git a/src/H5Gint.c b/src/H5Gint.c index c5cb82b..d9716e2 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -326,11 +326,11 @@ done: if (oloc_init) { if (H5O_dec_rc_by_loc(&(grp->oloc)) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, - "unable to decrement refcount on newly created object") + "unable to decrement refcount on newly created object"); if (H5O_close(&(grp->oloc), NULL) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header"); if (H5O_delete(file, grp->oloc.addr) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header") + HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header"); } /* end if */ if (grp != NULL) { if (grp->shared != NULL) @@ -395,7 +395,7 @@ H5G__open_name(const H5G_loc_t *loc, const char *name) done: if (!ret_value) if (loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, NULL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__open_name() */ @@ -872,10 +872,10 @@ done: /* Release the group opened */ if (gid != H5I_INVALID_HID) { if (H5I_dec_app_ref(gid) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group"); } else if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_iterate() */ @@ -1054,7 +1054,7 @@ done: /* Release resources */ if (obj_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__visit_cb() */ @@ -1193,10 +1193,10 @@ done: /* Release the group opened */ if (gid != H5I_INVALID_HID) { if (H5I_dec_app_ref(gid) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group"); } else if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_visit() */ @@ -1286,7 +1286,7 @@ done: if (ret_value < 0) { if (new_gcpl_id > 0) if (H5I_dec_app_ref(new_gcpl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't free") + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't free"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1333,7 +1333,7 @@ H5G__get_info_by_name(const H5G_loc_t *loc, const char *name, H5G_info_t *grp_in done: /* Clean up */ if (loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_info_by_name() */ @@ -1380,7 +1380,7 @@ H5G__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t id done: /* Clean up */ if (loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_info_by_idx() */ diff --git a/src/H5Glink.c b/src/H5Glink.c index 353c73d..cea691b 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -390,18 +390,18 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_orde /* Pick appropriate sorting routine */ if (idx_type == H5_INDEX_NAME) { if (order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_inc); + qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_inc); else if (order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_dec); + qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_name_dec); else assert(order == H5_ITER_NATIVE); } /* end if */ else { assert(idx_type == H5_INDEX_CRT_ORDER); if (order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_inc); + qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_inc); else if (order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_dec); + qsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G__link_cmp_corder_dec); else assert(order == H5_ITER_NATIVE); } /* end else */ @@ -439,7 +439,7 @@ H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, hsize_t *l *last_lnk += skip; /* Iterate over link messages */ - H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t) + H5_CHECKED_ASSIGN(u, size_t, skip, hsize_t); for (; u < ltable->nlinks && !ret_value; u++) { /* Make the callback */ ret_value = (op)(&(ltable->lnks[u]), op_data); diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 4c38a22..885fdca 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -476,7 +476,7 @@ done: /* Release the object location if we failed after copying it */ if (ret_value < 0 && obj_loc_valid) if (H5G_loc_free(udata->loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location"); /* Indicate that this callback didn't take ownership of the group * * location for the object */ diff --git a/src/H5Gname.c b/src/H5Gname.c index 5355a20..92957c0 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -229,10 +229,10 @@ H5G__common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) assert(prefix); } /* end if */ else - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ else - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end while */ /* If we reached the end of the prefix path to check, it must be a valid prefix */ @@ -665,7 +665,7 @@ H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_DATATYPE: /* Avoid non-named datatypes */ if (!H5T_is_named((H5T_t *)obj_ptr)) - HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */ + HGOTO_DONE(SUCCEED); /* Do not exit search over IDs */ oloc = H5T_oloc((H5T_t *)obj_ptr); obj_path = H5T_nameof((H5T_t *)obj_ptr); @@ -697,7 +697,7 @@ H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Check if the object has a full path still */ if (!obj_path->full_path_r) - HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ + HGOTO_DONE(SUCCEED); /* No need to look at object, it's path is already invalid */ /* Find the top file in object's mount hier. */ if (H5F_PARENT(oloc->file)) { @@ -724,7 +724,7 @@ H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Check if the object is in same file mount hier. */ if (!H5F_SAME_SHARED(top_obj_file, names->src_file)) - HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ + HGOTO_DONE(SUCCEED); /* No need to look at object, it's path is already invalid */ switch (names->op) { /*------------------------------------------------------------------------- @@ -873,7 +873,7 @@ H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) } /* end switch */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__name_replace_cb() */ /*------------------------------------------------------------------------- @@ -1075,14 +1075,14 @@ H5G__get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string") /* We found a match so we return immediately */ - HGOTO_DONE(H5_ITER_STOP) + HGOTO_DONE(H5_ITER_STOP); } /* end if */ } /* end if */ } /* end if */ done: if (obj_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__get_name_by_addr_cb() */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 33708d6..9e55e0f 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -161,7 +161,7 @@ H5G__node_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) assert(raw); assert(key); - H5F_DECODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len); + H5_DECODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__node_decode_key() */ @@ -186,7 +186,7 @@ H5G__node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) assert(raw); assert(key); - H5F_ENCODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len); + H5_ENCODE_LENGTH_LEN(raw, key->offset, shared->sizeof_len); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__node_encode_key() */ @@ -497,7 +497,7 @@ H5G__node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, hboo done: if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_found() */ @@ -645,8 +645,8 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, hbool_t H /* Move entries down to make room for new entry */ assert(idx >= 0); - HDmemmove(insert_into->entry + idx + 1, insert_into->entry + idx, - (insert_into->nsyms - (unsigned)idx) * sizeof(H5G_entry_t)); + memmove(insert_into->entry + idx + 1, insert_into->entry + idx, + (insert_into->nsyms - (unsigned)idx) * sizeof(H5G_entry_t)); /* Copy new entry into table */ H5G__ent_copy(&(insert_into->entry[idx]), &ent, H5_COPY_SHALLOW); @@ -656,9 +656,9 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, hbool_t H done: if (snrt && H5AC_unprotect(f, H5AC_SNODE, *new_node_p, snrt, snrt_flags) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_insert() */ @@ -810,7 +810,7 @@ H5G__node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key /*i */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - HDmemmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); + memmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; } else if (idx + 1 == sn->nsyms) { @@ -832,7 +832,7 @@ H5G__node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key /*i */ sn->nsyms -= 1; sn_flags |= H5AC__DIRTIED_FLAG; - HDmemmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); + memmove(sn->entry + idx, sn->entry + idx + 1, (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; } /* end else */ } /* end if */ @@ -868,7 +868,7 @@ H5G__node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key /*i done: if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, sn_flags) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release symbol table node") + HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release symbol table node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_remove() */ @@ -943,7 +943,7 @@ H5G__node_iterate(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, done: /* Release resources */ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_iterate() */ @@ -983,7 +983,7 @@ H5G__node_sumup(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, done: if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_sumup() */ @@ -1040,7 +1040,7 @@ H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, done: if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_by_idx() */ @@ -1247,13 +1247,13 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get source object name") /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Insert the new object in the destination file's group */ /* (Don't increment the link count - that's already done above for hard links) */ if (H5G__stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, obj_type, (obj_type == H5O_TYPE_GROUP ? &gcrt_info : NULL)) < 0) - HGOTO_ERROR_TAG(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") + HGOTO_ERROR_TAG(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name"); /* Reset metadata tag */ H5_END_TAG @@ -1262,10 +1262,10 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const done: if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name"); if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_copy() */ @@ -1337,7 +1337,7 @@ H5G__node_build_table(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr done: /* Release the locked items */ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__node_build_table() */ @@ -1444,9 +1444,9 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, had done: if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node"); if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_debug() */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 209b8b0..963a4ff 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -320,7 +320,7 @@ H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo) done: /* Release resources */ if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__obj_get_linfo() */ @@ -531,7 +531,7 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link into group") /* Done with insertion now */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ else use_old_format = TRUE; @@ -580,7 +580,7 @@ H5G_obj_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, done: /* Free any space used by the pipeline message */ if (pline && H5O_msg_reset(H5O_PLINE_ID, pline) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "can't release pipeline") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "can't release pipeline"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G_obj_insert() */ @@ -722,7 +722,7 @@ H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info) done: /* Clean up resources */ if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "unable to close queried group") + HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "unable to close queried group"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__obj_info() */ @@ -866,7 +866,7 @@ H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo) /* Release object header */ if (H5O_unpin(oh) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTUNPIN, FAIL, - "unable to unpin group object header") + "unable to unpin group object header"); HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") } /* end if */ diff --git a/src/H5Goh.c b/src/H5Goh.c index 84ad254..8daf0fd 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -202,7 +202,7 @@ H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) done: if (NULL == ret_value) if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_open() */ @@ -247,7 +247,7 @@ H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) done: if (ret_value == NULL) if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_create() */ @@ -370,11 +370,11 @@ H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_bh_info() */ diff --git a/src/H5Groot.c b/src/H5Groot.c index ee30956..8346fc4 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -140,7 +140,7 @@ H5G_mkroot(H5F_t *f, hbool_t create_root) /* Check if the root group is already initialized */ if (f->shared->root_grp) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Create information needed for group nodes */ if (H5G__node_init(f) < 0) @@ -300,7 +300,7 @@ done: /* Mark superblock dirty in cache, if necessary */ if (sblock_dirty) if (H5AC_mark_entry_dirty(f->shared->sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") + HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_mkroot() */ diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 45b1be9..e253ff5 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -152,7 +152,7 @@ H5G__stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size_hint) done: /* Release resources */ if (heap && FAIL == H5HL_unprotect(heap)) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_create_components() */ @@ -260,7 +260,7 @@ H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, H5O_li done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_insert_real() */ @@ -343,7 +343,7 @@ H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, const char * done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_remove() */ @@ -397,7 +397,7 @@ H5G__stab_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); /* Reset the link information, if we have a copy */ if (lnk_copied) @@ -453,7 +453,7 @@ H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_delete() */ @@ -539,9 +539,9 @@ H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t skip, hs done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); if (ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_iterate() */ @@ -737,7 +737,7 @@ H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); /* Free the duplicated name */ if (udata_valid && udata.name != NULL) @@ -827,7 +827,7 @@ H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, hbool_t *found, H5 done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_lookup() */ @@ -931,7 +931,7 @@ H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_ done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__stab_lookup_by_idx() */ @@ -1009,7 +1009,7 @@ H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab) done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__stab_valid */ diff --git a/src/H5Gtest.c b/src/H5Gtest.c index ed22174..c917686 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -112,7 +112,7 @@ H5G__is_empty_test(hid_t gid) if (msg_exists > 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ /* Check for a link info message */ @@ -133,15 +133,15 @@ H5G__is_empty_test(hid_t gid) /* Check for 'dense' link storage file addresses being defined */ if (H5_addr_defined(linfo.fheap_addr)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (H5_addr_defined(linfo.name_bt2_addr)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (H5_addr_defined(linfo.corder_bt2_addr)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check for link count */ if (linfo.nlinks > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ /* "Old format" checks */ @@ -171,12 +171,12 @@ H5G__is_empty_test(hid_t gid) /* Check for link count */ if (nlinks > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__is_empty_test() */ @@ -223,7 +223,7 @@ H5G__has_links_test(hid_t gid, unsigned *nmsgs) if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if (msg_exists == 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check if the group has a symbol table message */ if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) @@ -243,7 +243,7 @@ H5G__has_links_test(hid_t gid, unsigned *nmsgs) done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__has_links_test() */ @@ -289,7 +289,7 @@ H5G__has_stab_test(hid_t gid) if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if (msg_exists == 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check if the group has any link messages */ if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) @@ -299,7 +299,7 @@ H5G__has_stab_test(hid_t gid) done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__has_stab_test() */ @@ -347,13 +347,13 @@ H5G__is_new_dense_test(hid_t gid) if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_STAB_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if (msg_exists > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check if the group has any link messages */ if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINK_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") if (msg_exists > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check if the group has link info message */ if ((msg_exists = H5O_msg_exists(&(grp->oloc), H5O_LINFO_ID)) < 0) @@ -367,14 +367,14 @@ H5G__is_new_dense_test(hid_t gid) /* Check for 'dense' link storage file addresses being defined */ if (!H5_addr_defined(linfo.fheap_addr)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (!H5_addr_defined(linfo.name_bt2_addr)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__is_new_dense_test() */ @@ -422,37 +422,37 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) api_ctx_pushed = TRUE; /* Set metadata tag in API context */ - H5_BEGIN_TAG(grp->oloc.addr); + H5_BEGIN_TAG(grp->oloc.addr) /* Get the link info */ if (H5G__obj_get_linfo(&(grp->oloc), &linfo) < 0) - HGOTO_ERROR_TAG(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") + HGOTO_ERROR_TAG(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info"); /* Check for 'dense' link storage file addresses being defined */ if (!H5_addr_defined(linfo.fheap_addr)) - HGOTO_DONE_TAG(FAIL) + HGOTO_DONE_TAG(FAIL); if (!H5_addr_defined(linfo.name_bt2_addr)) - HGOTO_DONE_TAG(FAIL) + HGOTO_DONE_TAG(FAIL); /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(grp->oloc.file, linfo.name_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index"); /* Retrieve # of records in name index */ if (H5B2_get_nrec(bt2_name, name_count) < 0) - HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index"); /* Check if there is a creation order index */ if (H5_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ if (NULL == (bt2_corder = H5B2_open(grp->oloc.file, linfo.corder_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, - "unable to open v2 B-tree for creation order index") + "unable to open v2 B-tree for creation order index"); /* Retrieve # of records in creation order index */ if (H5B2_get_nrec(bt2_corder, corder_count) < 0) HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, - "unable to retrieve # of records from creation order index") + "unable to retrieve # of records from creation order index"); } /* end if */ else *corder_count = 0; @@ -463,11 +463,11 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) done: /* Release resources */ if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_SYM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__new_dense_info_test() */ @@ -520,7 +520,7 @@ H5G__lheap_size_test(hid_t gid, size_t *lheap_size) done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__lheap_size_test() */ @@ -632,7 +632,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign done: if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5G__user_path_test() */ @@ -683,7 +683,7 @@ H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent) done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol table heap"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5G__verify_cached_stab_test() */ @@ -766,7 +766,7 @@ H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, h done: if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header") + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header"); if (targ_oh) { assert(ret_value == H5_ITER_ERROR); diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index bad168c..33dc7b3 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -238,10 +238,10 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G done: /* Close location given to callback. */ if (cur_grp > 0 && H5I_dec_ref(cur_grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close ID for current location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close ID for current location"); if (ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_ud() */ @@ -595,7 +595,7 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G if ((op)(&grp_loc, comp, cb_lnk, cb_loc, op_data, &own_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CALLBACK, FAIL, "traversal operator failed") - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Handle lookup failures now */ @@ -757,11 +757,11 @@ done: /* If there's valid information in the link, reset it */ if (link_valid) if (H5O_msg_reset(H5O_LINK_ID, &lnk) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link message") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to reset link message"); /* Release temporary component buffer */ if (wb && H5WB_unwrap(wb) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't release wrapped buffer"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__traverse_real() */ @@ -809,11 +809,11 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver * shouldn't be during the traversal. Note that for best tagging assertion * coverage, setting H5C_DO_TAGGING_SANITY_CHECKS is advised. */ - H5_BEGIN_TAG(H5AC__INVALID_TAG); + H5_BEGIN_TAG(H5AC__INVALID_TAG) /* Go perform "real" traversal */ if (H5G__traverse_real(loc, name, target, op, op_data) < 0) - HGOTO_ERROR_TAG(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed") + HGOTO_ERROR_TAG(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed"); /* Reset tag after traversal */ H5_END_TAG diff --git a/src/H5HF.c b/src/H5HF.c index 953cb69..9579760 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -172,10 +172,10 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam) done: if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header"); if (!ret_value && fh) if (H5HF_close(fh) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap") + HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_create() */ @@ -234,10 +234,10 @@ H5HF_open(H5F_t *f, haddr_t fh_addr) done: if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header"); if (!ret_value && fh) if (H5HF_close(fh) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap") + HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_open() */ @@ -865,7 +865,7 @@ H5HF_delete(H5F_t *f, haddr_t fh_addr) done: /* Unprotect the header, if an error occurred */ if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_delete() */ diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index c18817e..c5d12c9 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -13,8 +13,6 @@ /*------------------------------------------------------------------------- * * Created: H5HFbtree2.c - * Aug 7 2006 - * Quincey Koziol * * Purpose: v2 B-tree callbacks for "huge" object tracker * @@ -30,10 +28,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ -#include "H5MFprivate.h" /* File memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5B2private.h" /* B-Trees (Version 2) */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HFpkg.h" /* Fractal Heaps */ +#include "H5MFprivate.h" /* File Memory Management */ /****************/ /* Local Macros */ @@ -352,9 +353,9 @@ H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) assert(ctx); /* Encode the record's fields */ - H5_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_encode() */ @@ -381,9 +382,9 @@ H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) assert(ctx); /* Decode the record's fields */ - H5_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); - H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); - H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_indir_decode() */ @@ -529,11 +530,11 @@ H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) assert(ctx); /* Encode the record's fields */ - H5_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32ENCODE(raw, nrecord->filter_mask); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); + H5_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5_ENCODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_encode() */ @@ -560,11 +561,11 @@ H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) assert(ctx); /* Decode the record's fields */ - H5_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); - H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32DECODE(raw, nrecord->filter_mask); - H5F_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); - H5F_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); + H5_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5_DECODE_LENGTH_LEN(raw, nrecord->id, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_indir_decode() */ @@ -700,8 +701,8 @@ H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) assert(ctx); /* Encode the record's fields */ - H5_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_encode() */ @@ -728,8 +729,8 @@ H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) assert(ctx); /* Decode the record's fields */ - H5_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); - H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_dir_decode() */ @@ -886,10 +887,10 @@ H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) assert(ctx); /* Encode the record's fields */ - H5_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_addr_encode_len(ctx->sizeof_addr, &raw, nrecord->addr); + H5_ENCODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32ENCODE(raw, nrecord->filter_mask); - H5F_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5_ENCODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_encode() */ @@ -916,10 +917,10 @@ H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) assert(ctx); /* Decode the record's fields */ - H5_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); - H5F_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); + H5F_addr_decode_len(ctx->sizeof_addr, &raw, &nrecord->addr); + H5_DECODE_LENGTH_LEN(raw, nrecord->len, ctx->sizeof_size); UINT32DECODE(raw, nrecord->filter_mask); - H5F_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); + H5_DECODE_LENGTH_LEN(raw, nrecord->obj_size, ctx->sizeof_size); FUNC_LEAVE_NOAPI(SUCCEED) } /* H5HF__huge_bt2_filt_dir_decode() */ diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 9aa1251..d1146d7 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -13,10 +13,8 @@ /*------------------------------------------------------------------------- * * Created: H5HFcache.c - * Feb 24 2006 - * Quincey Koziol * - * Purpose: Implement fractal heap metadata cache methods. + * Purpose: Implement fractal heap metadata cache methods * *------------------------------------------------------------------------- */ @@ -261,7 +259,7 @@ H5HF__dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dtable) UINT16DECODE(*pp, dtable->cparam.start_root_rows); /* Address of table */ - H5_addr_decode(f, pp, &(dtable->table_addr)); + H5F_addr_decode(f, pp, &(dtable->table_addr)); /* Current # of rows in root indirect block */ UINT16DECODE(*pp, dtable->curr_root_rows); @@ -306,7 +304,7 @@ H5HF__dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable) UINT16ENCODE(*pp, dtable->cparam.start_root_rows); /* Address of root direct/indirect block */ - H5_addr_encode(f, pp, dtable->table_addr); + H5F_addr_encode(f, pp, dtable->table_addr); /* Current # of rows in root indirect block */ UINT16ENCODE(*pp, dtable->curr_root_rows); @@ -476,14 +474,14 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_ hdr->checksum_dblocks = heap_flags & H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS; /* "Huge" object information */ - UINT32DECODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ - H5F_DECODE_LENGTH(udata->f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ - H5_addr_decode(udata->f, &image, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ + UINT32DECODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ + H5F_DECODE_LENGTH(udata->f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ + H5F_addr_decode(udata->f, &image, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ /* "Managed" object free space information */ H5F_DECODE_LENGTH(udata->f, image, - hdr->total_man_free); /* Internal free space in managed direct blocks */ - H5_addr_decode(udata->f, &image, &hdr->fs_addr); /* Address of free section header */ + hdr->total_man_free); /* Internal free space in managed direct blocks */ + H5F_addr_decode(udata->f, &image, &hdr->fs_addr); /* Address of free section header */ /* Heap statistics */ H5F_DECODE_LENGTH(udata->f, image, hdr->man_size); @@ -555,7 +553,7 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_ done: if (!ret_value && hdr) if (H5HF__hdr_free(hdr) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_hdr_deserialize() */ @@ -583,7 +581,6 @@ H5HF__cache_hdr_image_len(const void *_thing, size_t *image_len) /* Sanity checks */ assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); assert(image_len); @@ -622,7 +619,6 @@ H5HF__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t len, /* Sanity checks */ assert(f); assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); assert(H5_addr_defined(addr)); assert(addr == hdr->heap_addr); @@ -707,7 +703,6 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN assert(f); assert(image); assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); assert(len == hdr->heap_size); @@ -740,11 +735,11 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN /* "Huge" object information */ UINT32ENCODE(image, hdr->max_man_size); /* Max. size of "managed" objects */ H5F_ENCODE_LENGTH(f, image, hdr->huge_next_id); /* Next ID to use for "huge" object */ - H5_addr_encode(f, &image, hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ + H5F_addr_encode(f, &image, hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */ /* "Managed" object free space information */ H5F_ENCODE_LENGTH(f, image, hdr->total_man_free); /* Internal free space in managed direct blocks */ - H5_addr_encode(f, &image, hdr->fs_addr); /* Address of free section header */ + H5F_addr_encode(f, &image, hdr->fs_addr); /* Address of free section header */ /* Heap statistics */ H5F_ENCODE_LENGTH(f, image, hdr->man_size); @@ -799,10 +794,6 @@ done: * This routine also does not free the file space that may * be allocated to the header. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -818,7 +809,6 @@ H5HF__cache_hdr_free_icr(void *_thing) /* Sanity checks */ assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); assert(hdr->rc == 0); @@ -964,7 +954,7 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version") /* Address of heap that owns this block */ - H5_addr_decode(udata->f, &image, &heap_addr); + H5F_addr_decode(udata->f, &image, &heap_addr); if (H5_addr_ne(heap_addr, hdr->heap_addr)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block") @@ -1017,7 +1007,7 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { /* Decode child block address */ - H5_addr_decode(udata->f, &image, &(iblock->ents[u].addr)); + H5F_addr_decode(udata->f, &image, &(iblock->ents[u].addr)); /* Check for heap with I/O filters */ if (hdr->filter_len > 0) { @@ -1080,7 +1070,7 @@ H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED done: if (!ret_value && iblock) if (H5HF__man_iblock_dest(iblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap indirect block") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap indirect block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_iblock_deserialize() */ @@ -1104,7 +1094,6 @@ H5HF__cache_iblock_image_len(const void *_thing, size_t *image_len) /* Sanity checks */ assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(image_len); @@ -1143,7 +1132,6 @@ H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5 /* Sanity checks */ assert(f); assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(iblock->cache_info.size == iblock->size); assert(H5_addr_defined(addr)); @@ -1153,7 +1141,6 @@ H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5 assert(flags); hdr = iblock->hdr; assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); #ifndef NDEBUG @@ -1269,7 +1256,6 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG assert(f); assert(image); assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(iblock->cache_info.size == iblock->size); assert(len == iblock->size); @@ -1296,7 +1282,7 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG *image++ = H5HF_IBLOCK_VERSION; /* Address of heap header for heap which owns this block */ - H5_addr_encode(f, &image, hdr->heap_addr); + H5F_addr_encode(f, &image, hdr->heap_addr); /* Offset of block in heap */ UINT64ENCODE_VAR(image, iblock->block_off, hdr->heap_off_size); @@ -1304,7 +1290,7 @@ H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG /* Encode indirect block-specific fields */ for (u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) { /* Encode child block address */ - H5_addr_encode(f, &image, iblock->ents[u].addr); + H5F_addr_encode(f, &image, iblock->ents[u].addr); /* Check for heap with I/O filters */ if (hdr->filter_len > 0) { @@ -1379,7 +1365,6 @@ H5HF__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) /* Sanity checks */ assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(iblock->hdr); @@ -1456,10 +1441,6 @@ done: * Purpose: Unlink the supplied instance of H5HF_indirect_t from the * fractal heap and free its memory. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -1475,7 +1456,6 @@ H5HF__cache_iblock_free_icr(void *thing) /* Sanity checks */ assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(iblock->rc == 0); assert(iblock->hdr); @@ -1628,7 +1608,7 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) computed_chksum = H5_checksum_metadata(read_buf, len, 0); /* Restore the checksum */ - UINT32ENCODE(chk_p, stored_chksum) + UINT32ENCODE(chk_p, stored_chksum); /* Verify checksum */ if (stored_chksum != computed_chksum) @@ -1694,7 +1674,6 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, hbo assert(par_info); hdr = par_info->hdr; assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); assert(dirty); @@ -1789,7 +1768,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, hbo HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version") /* Address of heap that owns this block (just for file integrity checks) */ - H5_addr_decode(udata->f, &image, &heap_addr); + H5F_addr_decode(udata->f, &image, &heap_addr); if (H5_addr_ne(heap_addr, hdr->heap_addr)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block") @@ -1834,7 +1813,7 @@ done: /* Cleanup on error */ if (!ret_value && dblock) if (H5HF__man_dblock_dest(dblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap direct block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__cache_dblock_deserialize() */ @@ -1862,7 +1841,6 @@ H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) /* Sanity checks */ assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); assert(image_len); @@ -2002,7 +1980,6 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t le /* Sanity checks */ assert(f); assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); assert(dblock->write_buf == NULL); assert(dblock->write_size == 0); @@ -2020,7 +1997,6 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t le hdr->f = (H5F_t *)f; assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); if (dblock->parent) { @@ -2033,7 +2009,6 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t le par_iblock = dblock->parent; par_entry = dblock->par_entry; - assert(par_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(par_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(H5_addr_eq(par_iblock->ents[par_entry].addr, addr)); } /* end if */ @@ -2063,7 +2038,7 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t le *image++ = H5HF_DBLOCK_VERSION; /* Address of heap header for heap which owns this block */ - H5_addr_encode(f, &image, hdr->heap_addr); + H5F_addr_encode(f, &image, hdr->heap_addr); /* Offset of block in heap */ UINT64ENCODE_VAR(image, dblock->block_off, hdr->heap_off_size); @@ -2365,7 +2340,6 @@ H5HF__cache_dblock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, assert(image); assert(len > 0); assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); assert((dblock->blk != dblock->write_buf) || (dblock->cache_info.size == dblock->size)); assert(dblock->write_buf); @@ -2410,7 +2384,6 @@ H5HF__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) /* Sanity checks */ assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); assert(dblock->hdr); @@ -2457,10 +2430,6 @@ done: * Purpose: Free the in core memory allocated to the supplied direct * block. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -2476,7 +2445,6 @@ H5HF__cache_dblock_free_icr(void *_thing) /* Sanity checks */ assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); /* Destroy fractal heap direct block */ @@ -2508,7 +2476,6 @@ H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) /* Sanity checks */ assert(dblock); - assert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblock->cache_info.type == H5AC_FHEAP_DBLOCK); assert(dblock->file_size > 0); assert(fsf_size); @@ -2593,7 +2560,6 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_ /* Sanity checks */ assert(f); assert(hdr); - assert(hdr->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(hdr->cache_info.type == H5AC_FHEAP_HDR); assert(fd_clean); assert(clean); @@ -2712,7 +2678,7 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_ if (NULL == (root_iblock = (H5HF_indirect_t *)H5AC_protect( f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") + HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed."); H5_END_TAG @@ -2787,7 +2753,7 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_ if (NULL == (iblock = (H5HF_indirect_t *)H5AC_protect( f, H5AC_FHEAP_IBLOCK, root_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") + HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed."); H5_END_TAG @@ -2800,7 +2766,6 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_ * in memory for the duration of the call. Do some sanity checks, * and then call H5HF__cache_verify_iblock_descendants_clean(). */ - assert(root_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(root_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); if (H5HF__cache_verify_iblock_descendants_clean(f, hdr->heap_addr, root_iblock, @@ -2955,7 +2920,6 @@ H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, H5 assert(f); assert(H5_addr_defined(fd_parent_addr)); assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(iblock_status); assert(fd_clean); @@ -3071,7 +3035,6 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_ assert(f); assert(H5_addr_defined(fd_parent_addr)); assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(fd_clean); assert(*fd_clean); @@ -3233,7 +3196,6 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5 assert(f); assert(H5_addr_defined(fd_parent_addr)); assert(iblock); - assert(iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(fd_clean); assert(*fd_clean); @@ -3356,7 +3318,7 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5 if (NULL == (child_iblock = (H5HF_indirect_t *)H5AC_protect( f, H5AC_FHEAP_IBLOCK, child_iblock_addr, NULL, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed.") + HGOTO_ERROR_TAG(H5E_HEAP, H5E_CANTPROTECT, FAIL, "H5AC_protect() failed."); H5_END_TAG @@ -3386,7 +3348,6 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5 * that we have the correct one. */ assert(child_iblock); - assert(child_iblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(child_iblock->cache_info.type == H5AC_FHEAP_IBLOCK); assert(child_iblock->addr == child_iblock_addr); diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index 6b75812..3ad0791 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -337,7 +337,7 @@ H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) done: if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_hdr_debug() */ @@ -389,11 +389,11 @@ H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) if (sect_start < dblock_start) start = 0; else - H5_CHECKED_ASSIGN(start, size_t, (sect_start - dblock_start), hsize_t) + H5_CHECKED_ASSIGN(start, size_t, (sect_start - dblock_start), hsize_t); if (sect_end > dblock_end) - H5_CHECKED_ASSIGN(end, size_t, udata->dblock_size, hsize_t) + H5_CHECKED_ASSIGN(end, size_t, udata->dblock_size, hsize_t); else - H5_CHECKED_ASSIGN(end, size_t, ((sect_end - dblock_start) + 1), hsize_t) + H5_CHECKED_ASSIGN(end, size_t, ((sect_end - dblock_start) + 1), hsize_t); /* Calculate the length */ len = end - start; @@ -531,9 +531,9 @@ H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, done: if (dblock && H5AC_unprotect(f, H5AC_FHEAP_DBLOCK, addr, dblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block"); if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header"); H5MM_xfree(marker); FUNC_LEAVE_NOAPI(ret_value) @@ -695,9 +695,9 @@ H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, done: if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap direct block"); if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_iblock_debug() */ @@ -802,7 +802,7 @@ H5HF_sects_debug(H5F_t *f, haddr_t fh_addr, FILE *stream, int indent, int fwidth done: if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release fractal heap header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_sects_debug() */ diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index d91f963..494e6e3 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -188,7 +188,7 @@ done: if (ret_value < 0) if (dblock) if (H5HF__man_dblock_dest(dblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_create() */ @@ -300,7 +300,7 @@ H5HF__man_dblock_destroy(H5HF_hdr_t *hdr, H5HF_direct_t *dblock, haddr_t dblock_ done: /* Unprotect the indirect block, with appropriate flags */ if (H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, cache_flags) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_dblock_destroy() */ diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index ae8266e..28346c0 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -473,7 +473,7 @@ H5HF__hdr_create(H5F_t *f, const H5HF_create_t *cparam) done: if (!H5_addr_defined(ret_value) && hdr) if (H5HF__hdr_free(hdr) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release fractal heap header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_create() */ @@ -1421,7 +1421,7 @@ H5HF__hdr_delete(H5HF_hdr_t *hdr) done: /* Unprotect the header with appropriate flags */ if (H5AC_unprotect(hdr->f, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__hdr_delete() */ diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index a28e367..4f18c4f 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -13,8 +13,6 @@ /*------------------------------------------------------------------------- * * Created: H5HFhuge.c - * Aug 7 2006 - * Quincey Koziol * * Purpose: Routines for "huge" objects in fractal heap * @@ -372,7 +370,7 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) /* Encode ID for user */ *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_HUGE; - H5_addr_encode(hdr->f, &id, obj_addr); + H5F_addr_encode(hdr->f, &id, obj_addr); H5F_ENCODE_LENGTH(hdr->f, id, (hsize_t)write_size); UINT32ENCODE(id, filter_mask); H5F_ENCODE_LENGTH(hdr->f, id, (hsize_t)obj_size); @@ -391,7 +389,7 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) /* Encode ID for user */ *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_HUGE; - H5_addr_encode(hdr->f, &id, obj_addr); + H5F_addr_encode(hdr->f, &id, obj_addr); H5F_ENCODE_LENGTH(hdr->f, id, (hsize_t)write_size); } /* end if */ } /* end if */ @@ -432,7 +430,7 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) /* Encode ID for user */ *id++ = H5HF_ID_VERS_CURR | H5HF_ID_TYPE_HUGE; - UINT64ENCODE_VAR(id, new_id, hdr->huge_id_size) + UINT64ENCODE_VAR(id, new_id, hdr->huge_id_size); } /* end else */ /* Update statistics about heap */ @@ -507,7 +505,7 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Look up object in v2 B-tree */ if (H5B2_find(hdr->huge_bt2, &search_rec, &found, H5HF__huge_bt2_filt_indir_found, &found_rec) < @@ -524,7 +522,7 @@ H5HF__huge_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Look up object in v2 B-tree */ if (H5B2_find(hdr->huge_bt2, &search_rec, &found, H5HF__huge_bt2_indir_found, &found_rec) < 0) @@ -572,7 +570,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) /* Check if 'huge' object ID encodes address & length directly */ if (hdr->huge_ids_direct) { /* Retrieve the object's address (common) */ - H5_addr_decode(hdr->f, &id, &obj_addr); + H5F_addr_decode(hdr->f, &id, &obj_addr); } /* end if */ else { hbool_t found = FALSE; /* Whether entry was found */ @@ -593,7 +591,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Look up object in v2 B-tree */ if (H5B2_find(hdr->huge_bt2, &search_rec, &found, H5HF__huge_bt2_filt_indir_found, &found_rec) < @@ -610,7 +608,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Look up object in v2 B-tree */ if (H5B2_find(hdr->huge_bt2, &search_rec, &found, H5HF__huge_bt2_indir_found, &found_rec) < 0) @@ -663,7 +661,7 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, H5HF_ope /* Check for 'huge' object ID that encodes address & length directly */ if (hdr->huge_ids_direct) { /* Retrieve the object's address and length (common) */ - H5_addr_decode(hdr->f, &id, &obj_addr); + H5F_addr_decode(hdr->f, &id, &obj_addr); H5F_DECODE_LENGTH(hdr->f, id, obj_size); /* Retrieve extra information needed for filtered objects */ @@ -689,7 +687,7 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, H5HF_ope H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Look up object in v2 B-tree */ if (H5B2_find(hdr->huge_bt2, &search_rec, &found, H5HF__huge_bt2_filt_indir_found, &found_rec) < @@ -708,7 +706,7 @@ H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, H5HF_ope H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Look up object in v2 B-tree */ if (H5B2_find(hdr->huge_bt2, &search_rec, &found, H5HF__huge_bt2_indir_found, &found_rec) < 0) @@ -780,34 +778,28 @@ done: } /* end H5HF__huge_op_real() */ /*------------------------------------------------------------------------- - * Function: H5HF__huge_write + * Function: H5HF__huge_write * - * Purpose: Write a 'huge' object to the heap + * Purpose: Write a 'huge' object to the heap * - * Note: This implementation somewhat limited: it doesn't handle - * heaps with filters, which would require re-compressing the - * huge object and probably changing the address of the object - * on disk (and possibly the heap ID for "direct" huge IDs). + * Note: This implementation somewhat limited: it doesn't handle + * heaps with filters, which would require re-compressing the + * huge object and probably changing the address of the object + * on disk (and possibly the heap ID for "direct" huge IDs). * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * Feb 21 2007 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) { - haddr_t obj_addr; /* Object's address in the file */ - size_t obj_size; /* Object's size in the file */ - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t obj_addr = HADDR_UNDEF; /* Object's address in the file */ + size_t obj_size = 0; /* Object's size in the file */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE - /* - * Check arguments. - */ assert(hdr); assert(id); assert(obj); @@ -822,9 +814,9 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) /* Check for 'huge' object ID that encodes address & length directly */ if (hdr->huge_ids_direct) { /* Retrieve the object's address and length (common) */ - H5_addr_decode(hdr->f, &id, &obj_addr); + H5F_addr_decode(hdr->f, &id, &obj_addr); H5F_DECODE_LENGTH(hdr->f, id, obj_size); - } /* end if */ + } else { H5HF_huge_bt2_indir_rec_t found_rec; /* Record found from tracking object */ H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ @@ -839,10 +831,10 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) if (NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, hdr->huge_bt2_addr, hdr->f))) HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") - } /* end if */ + } /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Look up object in v2 B-tree */ if (H5B2_find(hdr->huge_bt2, &search_rec, &found, H5HF__huge_bt2_indir_found, &found_rec) < 0) @@ -853,7 +845,7 @@ H5HF__huge_write(H5HF_hdr_t *hdr, const uint8_t *id, const void *obj) /* Retrieve the object's address & length */ obj_addr = found_rec.addr; H5_CHECKED_ASSIGN(obj_size, size_t, found_rec.len, hsize_t); - } /* end else */ + } /* Write the object's data to the file */ /* (writes directly from application's buffer) */ @@ -971,7 +963,7 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) /* Retrieve the object's address and length */ /* (used as key in v2 B-tree record) */ - H5_addr_decode(hdr->f, &id, &search_rec.addr); + H5F_addr_decode(hdr->f, &id, &search_rec.addr); H5F_DECODE_LENGTH(hdr->f, id, search_rec.len); /* Remove the record for tracking the 'huge' object from the v2 B-tree */ @@ -984,7 +976,7 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) /* Retrieve the object's address and length */ /* (used as key in v2 B-tree record) */ - H5_addr_decode(hdr->f, &id, &search_rec.addr); + H5F_addr_decode(hdr->f, &id, &search_rec.addr); H5F_DECODE_LENGTH(hdr->f, id, search_rec.len); /* Remove the record for tracking the 'huge' object from the v2 B-tree */ @@ -998,7 +990,7 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ @@ -1009,7 +1001,7 @@ H5HF__huge_remove(H5HF_hdr_t *hdr, const uint8_t *id) H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) + UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size); /* Remove the record for tracking the 'huge' object from the v2 B-tree */ /* (space in the file for the object is freed in the 'remove' callback) */ diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index fd23698..b126bf0 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -840,7 +840,7 @@ H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock) done: if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_root_revert() */ @@ -1051,7 +1051,7 @@ done: if (ret_value < 0) if (iblock) if (H5HF__man_iblock_dest(iblock) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_create() */ @@ -1637,7 +1637,7 @@ H5HF__man_iblock_delete(H5HF_hdr_t *hdr, haddr_t iblock_addr, unsigned iblock_nr done: /* Unprotect the indirect block, with appropriate flags */ if (iblock && H5HF__man_iblock_unprotect(iblock, cache_flags, did_protect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_iblock_delete() */ diff --git a/src/H5HFiter.c b/src/H5HFiter.c index 5af6f46..caa5d99 100644 --- a/src/H5HFiter.c +++ b/src/H5HFiter.c @@ -62,7 +62,7 @@ /*******************/ /* Declare a free list to manage the H5HF_block_loc_t struct */ -H5FL_DEFINE(H5HF_block_loc_t); +H5FL_DEFINE_STATIC(H5HF_block_loc_t); /*------------------------------------------------------------------------- * Function: H5HF__man_iter_init diff --git a/src/H5HFman.c b/src/H5HFman.c index b52e0fc..83c1585 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -190,11 +190,11 @@ done: /* Release section node on error */ if (ret_value < 0) if (sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node"); /* Release the direct block (marked as dirty) */ if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__DIRTIED_FLAG) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_insert() */ @@ -407,7 +407,7 @@ H5HF__man_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void * done: /* Unlock direct block */ if (dblock && H5AC_unprotect(hdr->f, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, dblock_cache_flags) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_op_real() */ @@ -634,12 +634,12 @@ done: if (ret_value < 0) { /* Release section node */ if (sec_node && H5HF__sect_single_free((H5FS_section_info_t *)sec_node) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release section node"); } /* end if */ /* Unlock indirect block */ if (iblock && H5HF__man_iblock_unprotect(iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__man_remove() */ diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 83fda1f..e036cf0 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -154,9 +154,11 @@ /* Decode a "managed" heap ID */ #define H5HF_MAN_ID_DECODE(i, h, f, o, l) \ - f = *(uint8_t *)i++; \ - UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ - UINT64DECODE_VAR((i), (l), (h)->heap_len_size) + do { \ + f = *(uint8_t *)i++; \ + UINT64DECODE_VAR((i), (o), (h)->heap_off_size); \ + UINT64DECODE_VAR((i), (l), (h)->heap_len_size); \ + } while (0) /* Free space section types for fractal heap */ /* (values stored in free space data structures in file) */ diff --git a/src/H5HFsection.c b/src/H5HFsection.c index a31bcda..e2e669e 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -261,7 +261,7 @@ H5FS_section_class_t H5HF_FSPACE_SECT_CLS_INDIRECT[1] = {{ }}; /* Declare a free list to manage the H5HF_free_section_t struct */ -H5FL_DEFINE(H5HF_free_section_t); +H5FL_DEFINE_STATIC(H5HF_free_section_t); /*****************************/ /* Library Private Variables */ @@ -840,7 +840,7 @@ H5HF__sect_single_can_merge(const H5FS_section_info_t *_sect1, const H5FS_sectio * are actually within the same direct block) */ if (H5_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr)) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -939,14 +939,14 @@ H5HF__sect_single_can_shrink(const H5FS_section_info_t *_sect, void *_udata) dblock_size = hdr->man_dtable.cparam.start_block_size; dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); if ((dblock_size - dblock_overhead) == sect->sect_info.size) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ else { /* We shouldn't have a situation where the 'next block' iterator * is moved before a direct block that still has objects within it. */ assert(hdr->man_iter_off > sect->sect_info.addr); - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end else */ done: @@ -1645,7 +1645,7 @@ H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_i /* Check if second section adjoins first section */ if (H5_addr_eq((top_indir_sect1->sect_info.addr + top_indir_sect1->u.indirect.span_size), top_indir_sect2->sect_info.addr)) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1732,7 +1732,7 @@ H5HF__sect_row_can_shrink(const H5FS_section_info_t *_sect, void H5_ATTR_UNUSED /* Check if section is past end of "next block" iterator */ if (sect->sect_info.addr >= hdr->man_iter_off) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -2172,7 +2172,7 @@ H5HF__sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, H5HF_free_ done: if (!ret_value && sect) if (H5HF__sect_indirect_free(sect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "can't free indirect section node") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "can't free indirect section node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_for_row() */ @@ -2496,7 +2496,7 @@ H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start done: if (ret_value < 0 && sect) if (H5HF__sect_indirect_free(sect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_add() */ @@ -2585,7 +2585,7 @@ H5HF__sect_indirect_revive_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) done: /* Unlock indirect block */ if (sec_iblock && H5HF__man_iblock_unprotect(sec_iblock, H5AC__NO_FLAGS_SET, did_protect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_revive_row() */ @@ -2747,8 +2747,8 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, h /* Adjust direct row sections for indirect section */ if (sect->u.indirect.dir_nrows > 0) { assert(sect->u.indirect.dir_rows); - HDmemmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[1], - sect->u.indirect.dir_nrows * sizeof(H5HF_free_section_t *)); + memmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[1], + sect->u.indirect.dir_nrows * sizeof(H5HF_free_section_t *)); assert(sect->u.indirect.dir_rows[0]); /* Make new "first row" in indirect section */ @@ -2841,8 +2841,8 @@ H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect, h /* Transfer row sections between current & peer sections */ H5MM_memcpy(&peer_sect->u.indirect.dir_rows[0], §->u.indirect.dir_rows[0], (sizeof(H5HF_free_section_t *) * peer_dir_nrows)); - HDmemmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[peer_dir_nrows], - (sizeof(H5HF_free_section_t *) * (sect->u.indirect.dir_nrows - peer_dir_nrows))); + memmove(§->u.indirect.dir_rows[0], §->u.indirect.dir_rows[peer_dir_nrows], + (sizeof(H5HF_free_section_t *) * (sect->u.indirect.dir_nrows - peer_dir_nrows))); sect->u.indirect.dir_nrows -= peer_dir_nrows; assert(row_sect == sect->u.indirect.dir_rows[0]); @@ -2902,7 +2902,7 @@ done: assert(ret_value < 0); if (H5HF__sect_indirect_free(peer_sect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2991,8 +2991,8 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned /* Adjust indirect entry information */ sect->u.indirect.indir_nents--; - HDmemmove(§->u.indirect.indir_ents[0], §->u.indirect.indir_ents[1], - sect->u.indirect.indir_nents * sizeof(H5HF_free_section_t *)); + memmove(§->u.indirect.indir_ents[0], §->u.indirect.indir_ents[1], + sect->u.indirect.indir_nents * sizeof(H5HF_free_section_t *)); assert(sect->u.indirect.indir_ents[0]); /* Make new "first row" in new first indirect child section */ @@ -3136,7 +3136,7 @@ done: assert(ret_value < 0); if (H5HF__sect_indirect_free(peer_sect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -3562,7 +3562,7 @@ H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) done: if (ret_value < 0) if (par_sect && H5HF__sect_indirect_free(par_sect) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node") + HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF__sect_indirect_build_parent() */ diff --git a/src/H5HFstat.c b/src/H5HFstat.c index 2899f86..53dbe03 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -156,7 +156,7 @@ H5HF_size(const H5HF_t *fh, hsize_t *heap_size) done: /* Release resources */ if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for tracking 'huge' objects") + HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for tracking 'huge' objects"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_size() */ diff --git a/src/H5HFtest.c b/src/H5HFtest.c index dc87945..8605163 100644 --- a/src/H5HFtest.c +++ b/src/H5HFtest.c @@ -115,41 +115,41 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) /* Compare doubling table parameters */ if (cparam1->managed.width < cparam2->managed.width) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->managed.width > cparam2->managed.width) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->managed.start_block_size < cparam2->managed.start_block_size) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->managed.start_block_size > cparam2->managed.start_block_size) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->managed.max_direct_size < cparam2->managed.max_direct_size) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->managed.max_direct_size > cparam2->managed.max_direct_size) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->managed.max_index < cparam2->managed.max_index) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->managed.max_index > cparam2->managed.max_index) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->managed.start_root_rows < cparam2->managed.start_root_rows) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->managed.start_root_rows > cparam2->managed.start_root_rows) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Compare other general parameters for heap */ if (cparam1->max_man_size < cparam2->max_man_size) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->max_man_size > cparam2->max_man_size) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cparam1->id_len < cparam2->id_len) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->id_len > cparam2->id_len) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Compare "important" parameters for any I/O pipeline filters */ if (cparam1->pline.nused < cparam2->pline.nused) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->pline.nused > cparam2->pline.nused) - HGOTO_DONE(1) + HGOTO_DONE(1); else { size_t u, v; /* Local index variables */ @@ -157,15 +157,15 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) for (u = 0; u < cparam1->pline.nused; u++) { /* Check filter ID */ if (cparam1->pline.filter[u].id < cparam2->pline.filter[u].id) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->pline.filter[u].id > cparam2->pline.filter[u].id) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Check filter flags */ if (cparam1->pline.filter[u].flags < cparam2->pline.filter[u].flags) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->pline.filter[u].flags > cparam2->pline.filter[u].flags) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Don't worry about comparing the filter names right now... */ /* (they are expanded during the encode/decode process, but aren't copied @@ -174,27 +174,27 @@ H5HF_cmp_cparam_test(const H5HF_create_t *cparam1, const H5HF_create_t *cparam2) #if 0 /* Check filter name */ if(!cparam1->pline.filter[u].name && cparam2->pline.filter[u].name) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if(cparam1->pline.filter[u].name && !cparam2->pline.filter[u].name) - HGOTO_DONE(1) + HGOTO_DONE(1); else if(cparam1->pline.filter[u].name && cparam2->pline.filter[u].name) { if((ret_value = HDstrcmp(cparam1->pline.filter[u].name, cparam2->pline.filter[u].name))) - HGOTO_DONE(ret_value) + HGOTO_DONE(ret_value); } /* end if */ #endif /* Check # of filter parameters */ if (cparam1->pline.filter[u].cd_nelmts < cparam2->pline.filter[u].cd_nelmts) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->pline.filter[u].cd_nelmts > cparam2->pline.filter[u].cd_nelmts) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Check filter parameters */ for (v = 0; v < cparam1->pline.filter[u].cd_nelmts; v++) { if (cparam1->pline.filter[u].cd_values[v] < cparam2->pline.filter[u].cd_values[v]) - HGOTO_DONE(-1) + HGOTO_DONE(-1); else if (cparam1->pline.filter[u].cd_values[v] > cparam2->pline.filter[u].cd_values[v]) - HGOTO_DONE(1) + HGOTO_DONE(1); } /* end for */ } /* end for */ diff --git a/src/H5HG.c b/src/H5HG.c index a9b3431..b18ecea 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -163,10 +163,6 @@ H5HG__create(H5F_t *f, size_t size) * align the pointer, but this might not be the case. */ n = (size_t)H5HG_ALIGN(p - heap->chunk) - (size_t)(p - heap->chunk); -#ifdef OLD_WAY - /* Don't bother zeroing out the rest of the info in the heap -QAK */ - memset(p, 0, n); -#endif /* OLD_WAY */ p += n; /* The freespace object */ @@ -178,10 +174,6 @@ H5HG__create(H5F_t *f, size_t size) UINT16ENCODE(p, 0); /*reference count*/ UINT32ENCODE(p, 0); /*reserved*/ H5F_ENCODE_LENGTH(f, p, heap->obj[0].size); -#ifdef OLD_WAY - /* Don't bother zeroing out the rest of the info in the heap -QAK */ - memset(p, 0, (size_t)((heap->chunk + heap->size) - p)); -#endif /* OLD_WAY */ /* Add this heap to the beginning of the CWFS list */ if (H5F_cwfs_add(f, heap) < 0) @@ -200,14 +192,14 @@ done: if (H5_addr_defined(addr)) { /* Release the space on disk */ if (H5MF_xfree(f, H5FD_MEM_GHEAP, addr, (hsize_t)size) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free global heap") + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free global heap"); /* Check if the heap object was allocated */ if (heap) /* Destroy the heap object */ if (H5HG__free(heap) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, - "unable to destroy global heap collection") + "unable to destroy global heap collection"); } /* end if */ } /* end if */ @@ -368,7 +360,7 @@ H5HG__alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr) ret_value = idx; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__alloc() */ /*------------------------------------------------------------------------- @@ -447,7 +439,7 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) done: if (heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG_extend() */ @@ -519,13 +511,8 @@ H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj /*out*/) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate global heap object") /* Copy data into the heap */ - if (size > 0) { + if (size > 0) H5MM_memcpy(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f), obj, size); -#ifdef OLD_WAY - /* Don't bother zeroing out the rest of the info in the heap -QAK */ - memset(heap->obj[idx].begin + H5HG_SIZEOF_OBJHDR(f) + size, 0, need - (H5HG_SIZEOF_OBJHDR(f) + size)); -#endif /* OLD_WAY */ - } /* end if */ heap_flags |= H5AC__DIRTIED_FLAG; /* Return value */ @@ -534,7 +521,7 @@ H5HG_insert(H5F_t *f, size_t size, const void *obj, H5HG_t *hobj /*out*/) done: if (heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap.") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap."); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* H5HG_insert() */ @@ -600,7 +587,7 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object /*out*/, size_t *buf_size) done: if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release object header"); if (NULL == ret_value && NULL == orig_object && object) H5MM_free(object); @@ -658,7 +645,7 @@ H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust) done: if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_link() */ @@ -698,7 +685,7 @@ H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size) done: if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_get_obj_size() */ @@ -741,7 +728,7 @@ H5HG_remove(H5F_t *f, H5HG_t *hobj) * the entry and let the second rewrite happen (see HDFFV-10635). In the future, it'd be nice to handle * this situation in H5T_conv_vlen in H5Tconv.c instead of this level (HDFFV-10648). */ if (heap->obj[hobj->idx].nrefs == 0 && heap->obj[hobj->idx].size == 0 && !heap->obj[hobj->idx].begin) - HGOTO_DONE(ret_value) + HGOTO_DONE(ret_value); obj_start = heap->obj[hobj->idx].begin; /* Include object header size */ @@ -758,7 +745,7 @@ H5HG_remove(H5F_t *f, H5HG_t *hobj) } /* end if */ else heap->obj[0].size += need; - HDmemmove(obj_start, obj_start + need, heap->size - (size_t)((obj_start + need) - heap->chunk)); + memmove(obj_start, obj_start + need, heap->size - (size_t)((obj_start + need) - heap->chunk)); if (heap->obj[0].size >= H5HG_SIZEOF_OBJHDR(f)) { p = heap->obj[0].begin; UINT16ENCODE(p, 0); /*id*/ @@ -790,9 +777,9 @@ H5HG_remove(H5F_t *f, H5HG_t *hobj) done: if (heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, flags) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); - FUNC_LEAVE_NOAPI_TAG(ret_value); + FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5HG_remove() */ /*------------------------------------------------------------------------- diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 1818900..0fa6c1b 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -190,6 +190,7 @@ H5HG__cache_heap_get_final_load_size(const void *image, size_t image_len, void * assert(image_len == H5HG_MINSIZE); /* Deserialize the heap's header */ + heap.size = 0; if (H5HG__hdr_deserialize(&heap, (const uint8_t *)image, image_len, (const H5F_t *)udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode global heap prefix") @@ -389,7 +390,7 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, hbool done: if (!ret_value && heap) if (H5HG__free(heap) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG__cache_heap_deserialize() */ @@ -411,7 +412,6 @@ H5HG__cache_heap_image_len(const void *_thing, size_t *image_len) FUNC_ENTER_PACKAGE_NOERR assert(heap); - assert(heap->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(heap->cache_info.type == H5AC_GHEAP); assert(heap->size >= H5HG_MINSIZE); assert(image_len); @@ -442,7 +442,6 @@ H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, si assert(f); assert(image); assert(heap); - assert(heap->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(heap->cache_info.type == H5AC_GHEAP); assert(heap->size == len); assert(heap->chunk); @@ -458,10 +457,6 @@ H5HG__cache_heap_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, si * * Purpose: Free the in memory representation of the supplied global heap. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ @@ -474,7 +469,6 @@ H5HG__cache_heap_free_icr(void *_thing) FUNC_ENTER_PACKAGE assert(heap); - assert(heap->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(heap->cache_info.type == H5AC_GHEAP); /* Destroy global heap collection */ diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index 3245e6f..60cf3f7 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -144,5 +144,5 @@ done: if (h && H5AC_unprotect(f, H5AC_GHEAP, addr, h, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG_debug() */ diff --git a/src/H5HL.c b/src/H5HL.c index 88e2dee..ffec3ad 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -13,8 +13,6 @@ /*------------------------------------------------------------------------- * * Created: H5HL.c - * Jul 16 1997 - * Robb Matzke * * Purpose: Heap functions for the local heaps used by symbol * tables to store names (among other things). @@ -31,11 +29,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File Memory Management */ +#include "H5MMprivate.h" /* Memory Management */ /****************/ /* Local Macros */ @@ -780,7 +781,7 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) if (FAIL == H5HL__minimize_heap_space(f, heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } fl2 = fl2->next; } @@ -788,7 +789,7 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) if (FAIL == H5HL__minimize_heap_space(f, heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } else if (fl->offset + fl->size == offset) { fl->size += size; @@ -803,7 +804,7 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) if (FAIL == H5HL__minimize_heap_space(f, heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } fl2 = fl2->next; } @@ -811,7 +812,7 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) if (FAIL == H5HL__minimize_heap_space(f, heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } fl = fl->next; } @@ -827,7 +828,7 @@ H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) fprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long)size); } #endif - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* Add an entry to the free list */ diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 66c4f8f..115062f 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -28,12 +28,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata Cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Eprivate.h" /* Error Handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MMprivate.h" /* Memory Management */ /****************/ /* Local Macros */ @@ -178,19 +180,19 @@ H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, size_t len, H5HL_cache /* Heap data size */ if (H5_IS_BUFFER_OVERFLOW(image, udata->sizeof_size, p_end)) HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); - H5F_DECODE_LENGTH_LEN(image, heap->dblk_size, udata->sizeof_size); + H5_DECODE_LENGTH_LEN(image, heap->dblk_size, udata->sizeof_size); /* Free list head */ if (H5_IS_BUFFER_OVERFLOW(image, udata->sizeof_size, p_end)) HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); - H5F_DECODE_LENGTH_LEN(image, heap->free_block, udata->sizeof_size); + H5_DECODE_LENGTH_LEN(image, heap->free_block, udata->sizeof_size); if (heap->free_block != H5HL_FREE_NULL && heap->free_block >= heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad heap free list") /* Heap data address */ if (H5_IS_BUFFER_OVERFLOW(image, udata->sizeof_addr, p_end)) HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); - H5_addr_decode_len(udata->sizeof_addr, &image, &(heap->dblk_addr)); + H5F_addr_decode_len(udata->sizeof_addr, &image, &(heap->dblk_addr)); done: FUNC_LEAVE_NOAPI(ret_value) @@ -236,12 +238,12 @@ H5HL__fl_deserialize(H5HL_t *heap) /* Decode offset of next free block */ image = heap->dblk_image + free_block; - H5F_DECODE_LENGTH_LEN(image, free_block, heap->sizeof_size); + H5_DECODE_LENGTH_LEN(image, free_block, heap->sizeof_size); if (0 == free_block) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "free block size is zero?") /* Decode length of this free block */ - H5F_DECODE_LENGTH_LEN(image, fl->size, heap->sizeof_size); + H5_DECODE_LENGTH_LEN(image, fl->size, heap->sizeof_size); if ((fl->offset + fl->size) > heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") @@ -290,11 +292,11 @@ H5HL__fl_serialize(const H5HL_t *heap) image = heap->dblk_image + fl->offset; if (fl->next) - H5F_ENCODE_LENGTH_LEN(image, fl->next->offset, heap->sizeof_size) + H5_ENCODE_LENGTH_LEN(image, fl->next->offset, heap->sizeof_size); else - H5F_ENCODE_LENGTH_LEN(image, H5HL_FREE_NULL, heap->sizeof_size) + H5_ENCODE_LENGTH_LEN(image, H5HL_FREE_NULL, heap->sizeof_size); - H5F_ENCODE_LENGTH_LEN(image, fl->size, heap->sizeof_size) + H5_ENCODE_LENGTH_LEN(image, fl->size, heap->sizeof_size); } FUNC_LEAVE_NOAPI_VOID @@ -490,7 +492,6 @@ H5HL__cache_prefix_image_len(const void *_thing, size_t *image_len) /* Check arguments */ assert(prfx); - assert(prfx->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(prfx->cache_info.type == H5AC_LHEAP_PRFX); assert(image_len); @@ -533,7 +534,6 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, assert(f); assert(image); assert(prfx); - assert(prfx->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(prfx->cache_info.type == H5AC_LHEAP_PRFX); assert(H5_addr_eq(prfx->cache_info.addr, prfx->heap->prfx_addr)); assert(prfx->heap); @@ -560,9 +560,9 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, *image++ = 0; /*reserved*/ *image++ = 0; /*reserved*/ *image++ = 0; /*reserved*/ - H5F_ENCODE_LENGTH_LEN(image, heap->dblk_size, heap->sizeof_size); - H5F_ENCODE_LENGTH_LEN(image, heap->free_block, heap->sizeof_size); - H5_addr_encode_len(heap->sizeof_addr, &image, heap->dblk_addr); + H5_ENCODE_LENGTH_LEN(image, heap->dblk_size, heap->sizeof_size); + H5_ENCODE_LENGTH_LEN(image, heap->free_block, heap->sizeof_size); + H5F_addr_encode_len(heap->sizeof_addr, &image, heap->dblk_addr); /* Check if the local heap is a single object in cache */ if (heap->single_cache_obj) { @@ -608,10 +608,6 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, * from a failed speculative load attempt. See comments below for * details. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -627,7 +623,6 @@ H5HL__cache_prefix_free_icr(void *_thing) /* Check arguments */ assert(prfx); - assert(prfx->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(prfx->cache_info.type == H5AC_LHEAP_PRFX); assert(H5_addr_eq(prfx->cache_info.addr, prfx->heap->prfx_addr)); @@ -748,7 +743,6 @@ H5HL__cache_datablock_image_len(const void *_thing, size_t *image_len) /* Check arguments */ assert(dblk); - assert(dblk->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblk->cache_info.type == H5AC_LHEAP_DBLK); assert(dblk->heap); assert(dblk->heap->dblk_size > 0); @@ -783,7 +777,6 @@ H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *imag assert(f); assert(image); assert(dblk); - assert(dblk->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(dblk->cache_info.type == H5AC_LHEAP_DBLK); assert(dblk->heap); heap = dblk->heap; @@ -873,10 +866,6 @@ done: * * Purpose: Free the in memory representation of the supplied local heap data block. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -892,7 +881,6 @@ H5HL__cache_datablock_free_icr(void *_thing) /* Check arguments */ assert(dblk); - assert(dblk->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(dblk->cache_info.type == H5AC_LHEAP_DBLK); /* Destroy the data block */ diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index 7f6bff1..675b940 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -106,10 +106,10 @@ H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) done: if (h && FAIL == H5HL_unprotect(h)) - HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release/unprotect local heap") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release/unprotect local heap"); if (marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't free marker buffer") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't free marker buffer"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_debug() */ diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index 6b3557a..8009f51 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -107,7 +107,7 @@ done: /* H5FL_FREE always returns NULL so we can't check for errors */ dblk = H5FL_FREE(H5HL_dblk_t, dblk); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__dblk_new() */ /*------------------------------------------------------------------------- diff --git a/src/H5HLint.c b/src/H5HLint.c index b6314af..8bf5e8b 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -102,7 +102,7 @@ H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size) done: if (!ret_value && heap != NULL) if (NULL == (heap = H5FL_FREE(H5HL_t, heap))) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't free heap memory") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't free heap memory"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__new() */ diff --git a/src/H5Iint.c b/src/H5Iint.c index 13d2168..abc351d 100644 --- a/src/H5Iint.c +++ b/src/H5Iint.c @@ -92,7 +92,7 @@ int H5I_next_type_g = (int)H5I_NTYPES; H5FL_DEFINE_STATIC(H5I_id_info_t); /* Whether deletes are actually marks (for mark-and-sweep) */ -hbool_t H5I_marking_g = FALSE; +static hbool_t H5I_marking_s = FALSE; /*****************************/ /* Library Private Variables */ @@ -314,7 +314,7 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) */ /* Set marking flag */ - H5I_marking_g = TRUE; + H5I_marking_s = TRUE; /* Mark nodes for deletion */ HASH_ITER(hh, udata.type_info->hash_table, item, tmp) @@ -325,7 +325,7 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) } /* Unset marking flag */ - H5I_marking_g = FALSE; + H5I_marking_s = FALSE; /* Perform sweep */ HASH_ITER(hh, udata.type_info->hash_table, item, tmp) @@ -803,7 +803,7 @@ H5I_is_file_object(hid_t id) H5I_type_t type = H5I_get_type(id); htri_t ret_value = FAIL; - FUNC_ENTER_NOAPI(FAIL); + FUNC_ENTER_NOAPI(FAIL) /* Fail if the ID type is out of range */ if (type < 1 || type >= H5I_NTYPES) @@ -827,7 +827,7 @@ H5I_is_file_object(hid_t id) ret_value = FALSE; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5I_is_file_object() */ /*------------------------------------------------------------------------- @@ -886,7 +886,7 @@ H5I__remove_common(H5I_type_info_t *type_info, hid_t id) HASH_FIND(hh, type_info->hash_table, &id, sizeof(hid_t), info); if (info) { assert(!info->marked); - if (!H5I_marking_g) + if (!H5I_marking_s) HASH_DELETE(hh, type_info->hash_table, info); else info->marked = TRUE; @@ -902,7 +902,7 @@ H5I__remove_common(H5I_type_info_t *type_info, hid_t id) ret_value = (void *)info->object; H5_GCC_CLANG_DIAG_ON("cast-qual") - if (!H5I_marking_g) + if (!H5I_marking_s) info = H5FL_FREE(H5I_id_info_t, info); /* Decrement the number of IDs in the type */ @@ -1591,10 +1591,10 @@ H5I__find_id(hid_t id) /* Check arguments */ type = H5I_TYPE(id); if (type <= H5I_BADID || (int)type >= H5I_next_type_g) - HGOTO_DONE(NULL) + HGOTO_DONE(NULL); type_info = H5I_type_info_array_g[type]; if (!type_info || type_info->init_count <= 0) - HGOTO_DONE(NULL) + HGOTO_DONE(NULL); /* Check for same ID as we have looked up last time */ if (type_info->last_id_info && type_info->last_id_info->id == id) @@ -1615,13 +1615,13 @@ H5I__find_id(hid_t id) /* Invoke the realize callback, to get the actual object */ if ((id_info->realize_cb)((void *)id_info->object, &actual_id) < 0) - HGOTO_DONE(NULL) + HGOTO_DONE(NULL); /* Verify that we received a valid ID, of the same type */ if (H5I_INVALID_HID == actual_id) - HGOTO_DONE(NULL) + HGOTO_DONE(NULL); if (H5I_TYPE(id) != H5I_TYPE(actual_id)) - HGOTO_DONE(NULL) + HGOTO_DONE(NULL); /* Swap the actual object in for the future object */ future_object = (void *)id_info->object; @@ -1631,7 +1631,7 @@ H5I__find_id(hid_t id) /* Discard the future object */ if ((id_info->discard_cb)(future_object) < 0) - HGOTO_DONE(NULL) + HGOTO_DONE(NULL); future_object = NULL; /* Change the ID from 'future' to 'actual' */ diff --git a/src/H5Itest.c b/src/H5Itest.c index 3a21de2..cd1a3cc 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -100,10 +100,10 @@ H5I__get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_ID, H5E_CANTRESET, (-1), "can't reset VOL wrapper info") + HDONE_ERROR(H5E_ID, H5E_CANTRESET, (-1), "can't reset VOL wrapper info"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRESET, (-1), "can't reset API context") + HDONE_ERROR(H5E_SYM, H5E_CANTRESET, (-1), "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__get_name_test() */ diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 620c271..1c148a4 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -239,15 +239,15 @@ done: /* Release resources */ if (fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) HDONE_ERROR(H5E_ID, H5E_CANTRELEASE, H5I_INVALID_HID, - "unable to close ID for file access property list") + "unable to close ID for file access property list"); if (ext_file && H5F_efc_close(loc.oloc->file, ext_file) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problem closing external file") + HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problem closing external file"); if (parent_group_name && parent_group_name != local_group_name) parent_group_name = (char *)H5MM_xfree(parent_group_name); if (ret_value < 0) { /* Close object if it's open and something failed */ if (ext_obj_id >= 0 && H5I_dec_ref(ext_obj_id) < 0) - HDONE_ERROR(H5E_ID, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close ID for external object") + HDONE_ERROR(H5E_ID, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close ID for external object"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Lint.c b/src/H5Lint.c index e563bb3..a6a3824 100644 --- a/src/H5Lint.c +++ b/src/H5Lint.c @@ -261,7 +261,7 @@ H5L__find_class_idx(H5L_type_t id) for (i = 0; i < H5L_table_used_g; i++) if (H5L_table_g[i].id == id) - HGOTO_DONE((int)i) + HGOTO_DONE((int)i); done: FUNC_LEAVE_NOAPI(ret_value) @@ -379,7 +379,7 @@ H5L_unregister(H5L_type_t id) /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5L_table_g[i], &H5L_table_g[i + 1], sizeof(H5L_class_t) * ((H5L_table_used_g - 1) - i)); + memmove(&H5L_table_g[i], &H5L_table_g[i + 1], sizeof(H5L_class_t) * ((H5L_table_used_g - 1) - i)); H5L_table_used_g--; done: @@ -630,17 +630,17 @@ done: /* Decrement refcount on new object's object header in memory */ if (H5O_dec_rc_by_loc(&oloc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + HDONE_ERROR(H5E_LINK, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object"); } /* end if */ /* Close the location given to the user callback if it was created */ if (grp_id >= 0) { if (H5I_dec_app_ref(grp_id) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback") + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback"); } /* end if */ else if (grp != NULL) { if (H5G_close(grp) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback"); } /* end if */ else if (temp_loc_init) H5G_loc_free(&temp_loc); @@ -796,7 +796,7 @@ done: /* Free the object header location */ if (loc_valid) if (H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to free location") + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to free location"); /* Free the normalized path name */ if (norm_cur_name) @@ -1360,11 +1360,11 @@ done: /* Close the location given to the user callback if it was created */ if (grp_id >= 0) { if (H5I_dec_app_ref(grp_id) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback") + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close ID from UD callback"); } /* end if */ else if (grp != NULL) { if (H5G_close(grp) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback") + HDONE_ERROR(H5E_LINK, H5E_CANTRELEASE, FAIL, "unable to close group given to UD callback"); } /* end if */ else if (temp_loc_init) H5G_loc_free(&temp_loc); @@ -2102,7 +2102,7 @@ done: /* Check if we need to free the temp source oloc */ if (expanded_link_open) if (H5G_loc_free(&tmp_src_loc) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTFREE, FAIL, "unable to free object") + HDONE_ERROR(H5E_LINK, H5E_CANTFREE, FAIL, "unable to free object"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5L__link_copy_file() */ diff --git a/src/H5M.c b/src/H5M.c index 1afd540..600785e 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -264,7 +264,7 @@ done: vol_cb_args.args = NULL; if (map && H5VL_optional(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -346,7 +346,7 @@ H5Mcreate_async(const char *app_file, const char *app_func, unsigned app_line, h H5ARG_TRACE11(__func__, "*s*sIui*siiiiii", app_file, app_func, app_line, loc_id, name, key_type_id, val_type_id, lcpl_id, mcpl_id, mapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_MAP, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on map ID") + HDONE_ERROR(H5E_MAP, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on map ID"); HGOTO_ERROR(H5E_MAP, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -436,7 +436,7 @@ done: vol_cb_args.args = NULL; if (map && H5VL_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map"); } /* end if */ FUNC_LEAVE_API(ret_value) @@ -500,7 +500,7 @@ done: vol_cb_args.args = NULL; if (map && H5VL_optional(*vol_obj_ptr, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release map"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -575,7 +575,7 @@ H5Mopen_async(const char *app_file, const char *app_func, unsigned app_line, hid H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, mapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_MAP, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on map ID") + HDONE_ERROR(H5E_MAP, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on map ID"); HGOTO_ERROR(H5E_MAP, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } /* end if */ @@ -672,7 +672,7 @@ H5Mclose_async(const char *app_file, const char *app_func, unsigned app_line, hi done: if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "can't decrement ref count on connector") + HDONE_ERROR(H5E_MAP, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); FUNC_LEAVE_API(ret_value) } /* end H5Mclose_async() */ diff --git a/src/H5MF.c b/src/H5MF.c index a86bfef..91d22b4 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -967,7 +967,7 @@ done: /* Release section node, if allocated and not added to section list or merged */ if (node) if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free section node") + HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, HADDR_UNDEF, "can't free section node"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__alloc_pagefs() */ @@ -1057,7 +1057,7 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) /* check arguments */ assert(f); if (!H5_addr_defined(addr) || 0 == size) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); assert(addr != 0); /* Can't deallocate the superblock :-) */ H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &fs_type); @@ -1113,13 +1113,13 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTMERGE, FAIL, "can't check for absorbing block") else if (status > 0) /* Indicate success */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); else if (size < f->shared->fs_threshold) { #ifdef H5MF_ALLOC_DEBUG_MORE fprintf(stderr, "%s: dropping addr = %" PRIuHADDR ", size = %" PRIuHSIZE ", on the floor!\n", __func__, addr, size); #endif /* H5MF_ALLOC_DEBUG_MORE */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end else-if */ } /* end if */ @@ -1137,7 +1137,7 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) fprintf(stderr, "%s: dropping addr = %" PRIuHADDR ", size = %" PRIuHSIZE ", on the floor!\n", __func__, addr, size); #endif /* H5MF_ALLOC_DEBUG_MORE */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* There's either already a free space manager, or the freed @@ -1197,7 +1197,7 @@ done: /* Release section node, if allocated and not added to section list or merged */ if (node) if (H5MF__sect_free((H5FS_section_info_t *)node) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") + HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node"); #ifdef H5MF_ALLOC_DEBUG fprintf(stderr, "%s: Leaving, ret_value = %d\n", __func__, ret_value); @@ -1469,7 +1469,7 @@ done: /* Free section node allocated */ if (node && H5MF__sect_free((H5FS_section_info_t *)node) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node") + HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node"); #ifdef H5MF_ALLOC_DEBUG fprintf(stderr, "%s: Leaving, ret_value = %d\n", __func__, ret_value); diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 977d86c..b18a02c 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -534,7 +534,7 @@ done: *shrink = H5MF_SHRINK_AGGR_ABSORB_SECT; /* Indicate success */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ } /* end if */ diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index cc70e3b..a9be085 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -67,14 +67,14 @@ /* Calculate the mis-aligned fragment */ #define H5MF_EOA_MISALIGN(F, E, A, FR) \ - { \ + do { \ hsize_t m; \ \ if (H5_addr_gt((E), 0) && ((m) = ((E) + H5F_BASE_ADDR(F)) % (A))) \ (FR) = (A)-m; \ else \ (FR) = 0; \ - } + } while (0) /****************************/ /* Package Private Typedefs */ diff --git a/src/H5MFsection.c b/src/H5MFsection.c index ff14a44..b5255b1 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -163,7 +163,7 @@ const H5FS_section_class_t H5MF_FSPACE_SECT_CLS_LARGE[1] = {{ /*******************/ /* Declare a free list to manage the H5MF_free_section_t struct */ -H5FL_DEFINE(H5MF_free_section_t); +H5FL_DEFINE_STATIC(H5MF_free_section_t); /* * "simple/small/large" section callbacks @@ -450,12 +450,12 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ else { /* Shrinking can't occur if the 'eoa_shrink_only' flag is set and we're not shrinking the EOA */ if (udata->allow_eoa_shrink_only) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check if this section is allowed to merge with metadata aggregation block */ if (udata->f->shared->fs_aggr_merge[udata->alloc_type] & H5F_FS_MERGE_METADATA) { @@ -474,7 +474,7 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ } /* end if */ @@ -496,7 +496,7 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ } /* end if */ } /* end else */ @@ -858,7 +858,7 @@ H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ done: diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index eab8c89..f94a433 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -26,7 +26,7 @@ /* Private headers needed by this file */ #include "H5private.h" -#define H5MM_free(Z) HDfree(Z) +#define H5MM_free(Z) free(Z) /* * Library prototypes... diff --git a/src/H5O.c b/src/H5O.c index b8d96e2..4c8933e 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -200,7 +200,7 @@ H5Oopen_async(const char *app_file, const char *app_func, unsigned app_line, hid H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on object ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on object ID"); HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } @@ -330,7 +330,7 @@ H5Oopen_by_idx_async(const char *app_file, const char *app_func, unsigned app_li H5ARG_TRACE10(__func__, "*s*sIui*sIiIohii", app_file, app_func, app_line, loc_id, group_name, idx_type, order, n, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on object ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on object ID"); HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set") } @@ -2002,7 +2002,7 @@ H5Oclose_async(const char *app_file, const char *app_func, unsigned app_line, hi done: if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement ref count on connector") + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement ref count on connector"); FUNC_LEAVE_API(ret_value) } /* end H5Oclose_async() */ @@ -2027,7 +2027,7 @@ H5O__disable_mdc_flushes(H5O_loc_t *oloc) HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5O__disable_mdc_flushes() */ /*------------------------------------------------------------------------- @@ -2049,7 +2049,7 @@ H5Odisable_mdc_flushes(hid_t object_id) H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL); + FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); /* Make sure the ID is a file object */ @@ -2074,7 +2074,7 @@ H5Odisable_mdc_flushes(hid_t object_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* H5Odisable_mdc_flushes() */ /*------------------------------------------------------------------------- @@ -2097,7 +2097,7 @@ H5O__enable_mdc_flushes(H5O_loc_t *oloc) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5O__enable_mdc_flushes() */ /*------------------------------------------------------------------------- @@ -2119,7 +2119,7 @@ H5Oenable_mdc_flushes(hid_t object_id) H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL); + FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); /* Make sure the ID is a file object */ @@ -2144,7 +2144,7 @@ H5Oenable_mdc_flushes(hid_t object_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* H5Oenable_mdc_flushes() */ /*------------------------------------------------------------------------- @@ -2195,7 +2195,7 @@ H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL); + FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*b", object_id, are_disabled); /* Sanity check */ diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index 0b02533..7d4d6b7 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -131,7 +131,7 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS if (ainfo->track_corder) { if (H5_IS_BUFFER_OVERFLOW(p, 2, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - UINT16DECODE(p, ainfo->max_crt_idx) + UINT16DECODE(p, ainfo->max_crt_idx); } else ainfo->max_crt_idx = H5O_MAX_CRT_ORDER_IDX; @@ -139,18 +139,18 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS /* Address of fractal heap to store "dense" attributes */ if (H5_IS_BUFFER_OVERFLOW(p, sizeof_addr, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(ainfo->fheap_addr)); + H5F_addr_decode(f, &p, &(ainfo->fheap_addr)); /* Address of v2 B-tree to index names of attributes (names are always indexed) */ if (H5_IS_BUFFER_OVERFLOW(p, sizeof_addr, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(ainfo->name_bt2_addr)); + H5F_addr_decode(f, &p, &(ainfo->name_bt2_addr)); /* Address of v2 B-tree to index creation order of links, if there is one */ if (ainfo->index_corder) { if (H5_IS_BUFFER_OVERFLOW(p, sizeof_addr, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(ainfo->corder_bt2_addr)); + H5F_addr_decode(f, &p, &(ainfo->corder_bt2_addr)); } else ainfo->corder_bt2_addr = HADDR_UNDEF; @@ -200,14 +200,14 @@ H5O__ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c UINT16ENCODE(p, ainfo->max_crt_idx); /* Address of fractal heap to store "dense" attributes */ - H5_addr_encode(f, &p, ainfo->fheap_addr); + H5F_addr_encode(f, &p, ainfo->fheap_addr); /* Address of v2 B-tree to index names of attributes */ - H5_addr_encode(f, &p, ainfo->name_bt2_addr); + H5F_addr_encode(f, &p, ainfo->name_bt2_addr); /* Address of v2 B-tree to index creation order of attributes, if they are indexed */ if (ainfo->index_corder) - H5_addr_encode(f, &p, ainfo->corder_bt2_addr); + H5F_addr_encode(f, &p, ainfo->corder_bt2_addr); else assert(!H5_addr_defined(ainfo->corder_bt2_addr)); @@ -407,10 +407,10 @@ H5O__ainfo_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, void *mesg_src, H5F_ /* Prepare to copy dense attributes - actual copy in post_copy */ /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) if (H5A__dense_create(file_dst, ainfo_dst) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes"); /* Reset metadata tag */ H5_END_TAG diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index d9cb550..3c57953 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -149,9 +149,9 @@ H5O__add_gap(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t *oh, unsigned chunkno, hbool_ oh->mesg[u].raw -= new_gap_size; /* Slide raw message info forward in chunk image */ - HDmemmove(new_gap_loc, new_gap_loc + new_gap_size, - (size_t)((oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))) - - (new_gap_loc + new_gap_size))); + memmove(new_gap_loc, new_gap_loc + new_gap_size, + (size_t)((oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))) - + (new_gap_loc + new_gap_size))); /* Add existing gap size to new gap size */ new_gap_size += oh->chunk[chunkno].gap; @@ -265,10 +265,10 @@ H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *g /* Slide raw message info in chunk image */ if (null_before_gap) /* Slide messages down */ - HDmemmove(move_start + gap_size, move_start, (size_t)(move_end - move_start)); + memmove(move_start + gap_size, move_start, (size_t)(move_end - move_start)); else { /* Slide messages up */ - HDmemmove(move_start - gap_size, move_start, (size_t)(move_end - move_start)); + memmove(move_start - gap_size, move_start, (size_t)(move_end - move_start)); /* Adjust start of null message */ mesg->raw -= gap_size; @@ -276,7 +276,7 @@ H5O__eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *g } else if (move_end == move_start && !null_before_gap) { /* Slide null message up */ - HDmemmove(move_start - gap_size, move_start, mesg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + memmove(move_start - gap_size, move_start, mesg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Adjust start of null message */ mesg->raw -= gap_size; @@ -399,7 +399,7 @@ H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new done: /* Release chunk */ if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_null() */ @@ -564,7 +564,7 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size if (was_extended < 0) /* error */ HGOTO_ERROR(H5E_OHDR, H5E_CANTEXTEND, FAIL, "can't tell if we can extend chunk") else if (was_extended == FALSE) /* can't extend -- we are done */ - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Adjust object header prefix flags */ if (adjust_size_flags) { @@ -619,9 +619,9 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size /* Move chunk 0 data up if the size flags changed */ if (adjust_size_flags) - HDmemmove(oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh), - oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) - extra_prfx_size, - old_size - (size_t)H5O_SIZEOF_HDR(oh) + extra_prfx_size); + memmove(oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh), + oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) - extra_prfx_size, + old_size - (size_t)H5O_SIZEOF_HDR(oh) + extra_prfx_size); /* Spin through existing messages, adjusting them */ for (u = 0; u < oh->nmesgs; u++) { @@ -666,7 +666,7 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size done: /* Release chunk */ if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_extend_chunk() */ @@ -940,7 +940,7 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, const H5O_ if (curr_msg->type->id == H5O_NULL_ID) { /* Delete the null message */ if (u < oh->nmesgs - 1) - HDmemmove(curr_msg, curr_msg + 1, ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); + memmove(curr_msg, curr_msg + 1, ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end if */ else { @@ -1036,8 +1036,8 @@ H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, const H5O_ /* Remove null message from list of messages */ if (found_msg->null_msgno < (oh->nmesgs - 1)) - HDmemmove(old_null_msg, old_null_msg + 1, - ((oh->nmesgs - 1) - found_msg->null_msgno) * sizeof(H5O_mesg_t)); + memmove(old_null_msg, old_null_msg + 1, + ((oh->nmesgs - 1) - found_msg->null_msgno) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ @@ -1369,7 +1369,7 @@ H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) done: /* Release chunk, if not already done */ if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__release_mesg() */ @@ -1498,8 +1498,8 @@ H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) /* Release any information/memory for continuation message */ H5O__msg_free_mesg(cont_msg); if (cont_u < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[cont_u], &oh->mesg[cont_u + 1], - ((oh->nmesgs - 1) - cont_u) * sizeof(H5O_mesg_t)); + memmove(&oh->mesg[cont_u], &oh->mesg[cont_u + 1], + ((oh->nmesgs - 1) - cont_u) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end else */ @@ -1516,8 +1516,8 @@ H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) /* Remove from message list */ if (v < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], - ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); + memmove(&oh->mesg[v], &oh->mesg[v + 1], + ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); oh->nmesgs--; } /* end if */ } /* end if */ @@ -1535,7 +1535,7 @@ H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) done: /* Release chunk, if not already done */ if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__move_cont() */ @@ -1606,9 +1606,9 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) "unable to load object header chunk") /* Copy raw data for non-null message to new location */ - HDmemmove(curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), - nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), - nonnull_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); + memmove(curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), + nonnull_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); /* Adjust non-null message's offset in chunk */ nonnull_msg->raw = curr_msg->raw; @@ -1718,8 +1718,6 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) if (0 != null_msg->chunkno) { /* Sanity checks */ assert(null_chk_mdc_obj); - assert(((H5C_cache_entry_t *)null_chk_mdc_obj)->magic == - H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type); assert(((H5C_cache_entry_t *)null_chk_mdc_obj)->type->id == H5AC_OHDR_CHK_ID); @@ -1901,12 +1899,12 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) done: if (ret_value < 0) { if (null_chk_proxy && H5O__chunk_unprotect(f, null_chk_proxy, null_chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect null object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect null object header chunk"); if (curr_chk_proxy && H5O__chunk_unprotect(f, curr_chk_proxy, curr_chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect current object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect current object header chunk"); if (cont_targ_chk_proxy && H5O__chunk_unprotect(f, cont_targ_chk_proxy, FALSE) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, - "unable to unprotect continuation message target object header chunk") + "unable to unprotect continuation message target object header chunk"); } /* end if */ else assert(!null_chk_proxy && !curr_chk_proxy && !cont_targ_chk_proxy); @@ -2011,8 +2009,8 @@ H5O__merge_null(H5F_t *f, H5O_t *oh) /* Remove second message from list of messages */ if (v < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], - ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); + memmove(&oh->mesg[v], &oh->mesg[v + 1], + ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ @@ -2150,8 +2148,8 @@ H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) /* Remove chunk from list of chunks */ if (null_msg->chunkno < (oh->nchunks - 1)) { - HDmemmove(&oh->chunk[null_msg->chunkno], &oh->chunk[null_msg->chunkno + 1], - ((oh->nchunks - 1) - null_msg->chunkno) * sizeof(H5O_chunk_t)); + memmove(&oh->chunk[null_msg->chunkno], &oh->chunk[null_msg->chunkno + 1], + ((oh->nchunks - 1) - null_msg->chunkno) * sizeof(H5O_chunk_t)); /* Adjust chunk number for any chunk proxies that are in the cache */ for (u = null_msg->chunkno; u < (oh->nchunks - 1); u++) { @@ -2184,8 +2182,8 @@ H5O__remove_empty_chunks(H5F_t *f, H5O_t *oh) /* Remove null message from list of messages */ if (null_msg_no < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[null_msg_no], &oh->mesg[null_msg_no + 1], - ((oh->nmesgs - 1) - null_msg_no) * sizeof(H5O_mesg_t)); + memmove(&oh->mesg[null_msg_no], &oh->mesg[null_msg_no + 1], + ((oh->nmesgs - 1) - null_msg_no) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now -QAK) */ @@ -2356,8 +2354,8 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) uint8_t *src = curr_msg->raw + curr_msg->raw_size; /* Source location */ /* Slide down the raw data */ - HDmemmove(curr_msg->raw - sizeof_msghdr, src, - (size_t)(old_image + new_size - sizeof_chksum - src)); + memmove(curr_msg->raw - sizeof_msghdr, src, + (size_t)(old_image + new_size - sizeof_chksum - src)); /* Update the raw data pointers for messages after this one */ for (v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) @@ -2373,7 +2371,7 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) /* Remove the deleted null message from list of messages */ if (u < (oh->nmesgs - 1)) - HDmemmove(&oh->mesg[u], &oh->mesg[u + 1], ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); + memmove(&oh->mesg[u], &oh->mesg[u + 1], ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); /* Decrement # of messages */ /* (Don't bother reducing size of message array for now) */ @@ -2432,9 +2430,9 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) oh->flags |= new_size_flags; /* Slide chunk 0 data down */ - HDmemmove(chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum, - chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum + less_prfx_size, - new_size - (size_t)H5O_SIZEOF_HDR(oh)); + memmove(chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum, + chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum + less_prfx_size, + new_size - (size_t)H5O_SIZEOF_HDR(oh)); /* Adjust chunk size */ new_size -= less_prfx_size; @@ -2491,7 +2489,7 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) done: /* Release chunk, marking it dirty */ if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, TRUE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__alloc_shrink_chunk() */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 643b9e2..15eb147 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -293,7 +293,7 @@ done: if (attr) { if (attr->shared) if (H5A__shared_free(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info"); attr = H5FL_FREE(H5A_t, attr); } if (extent) @@ -408,7 +408,7 @@ H5O__attr_encode(H5F_t *f, uint8_t *p, const void *mesg) memset(p, 0, attr->shared->data_size); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_encode() */ /*-------------------------------------------------------------------------- diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 2640adb..8ef4b22 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -370,7 +370,7 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_create() */ @@ -504,12 +504,12 @@ H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, NULL, "unable to release object header"); /* Release any resources, on error */ if (NULL == ret_value && opened_attr) if (H5A__close(opened_attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_open_by_name() */ @@ -605,7 +605,7 @@ done: /* Release any resources, on error */ if (NULL == ret_value && opened_attr) if (H5A__close(opened_attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, NULL, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_open_by_idx() */ @@ -831,7 +831,7 @@ H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUS done: /* Release chunk, if not already done */ if (chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_write_cb() */ @@ -902,7 +902,7 @@ H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr) done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_write */ @@ -1067,7 +1067,7 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR done: /* Release chunk, if not already done */ if (chk_proxy && H5O__chunk_unprotect(udata->f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_rename_mod_cb() */ @@ -1150,7 +1150,7 @@ H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, const char *new_nam done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_rename() */ @@ -1231,9 +1231,9 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, H done: /* Release resources */ if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (atable.attrs && H5A__attr_release_table(&atable) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_attr_iterate_real() */ @@ -1388,7 +1388,7 @@ H5O__attr_remove_update(const H5O_loc_t *loc, H5O_t *oh, H5O_ainfo_t *ainfo) done: /* Release resources */ if (atable.attrs && H5A__attr_release_table(&atable) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_remove_update() */ @@ -1509,7 +1509,7 @@ H5O__attr_remove(const H5O_loc_t *loc, const char *name) done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_remove() */ @@ -1595,9 +1595,9 @@ H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); if (atable.attrs && H5A__attr_release_table(&atable) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_remove_by_idx() */ @@ -1745,7 +1745,7 @@ H5O__attr_exists(const H5O_loc_t *loc, const char *name, hbool_t *attr_exists) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__attr_exists() */ @@ -1821,11 +1821,11 @@ H5O__attr_bh_info(H5F_t *f, H5O_t *oh, H5_ih_info_t *bh_info) done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap"); if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_ATTR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__attr_bh_info() */ diff --git a/src/H5Ocache.c b/src/H5Ocache.c index e828e2d..34dee05 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -321,7 +321,7 @@ done: /* Release the [possibly partially initialized] object header on errors */ if (!ret_value && oh) if (H5O__free(oh, FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header data") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header data"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_deserialize() */ @@ -344,7 +344,6 @@ H5O__cache_image_len(const void *_thing, size_t *image_len) FUNC_ENTER_PACKAGE_NOERR assert(oh); - assert(oh->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(oh->cache_info.type == H5AC_OHDR); assert(image_len); @@ -375,7 +374,6 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) assert(f); assert(image); assert(oh); - assert(oh->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(oh->cache_info.type == H5AC_OHDR); assert(oh->chunk[0].size == len); #ifdef H5O_DEBUG @@ -458,7 +456,7 @@ H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) /* Number of messages */ #ifdef H5O_ENABLE_BAD_MESG_COUNT if (oh->store_bad_mesg_count) - UINT16ENCODE(chunk_image, (oh->nmesgs - 1)) + UINT16ENCODE(chunk_image, (oh->nmesgs - 1)); else #endif /* H5O_ENABLE_BAD_MESG_COUNT */ UINT16ENCODE(chunk_image, oh->nmesgs); @@ -568,10 +566,6 @@ done: * * Purpose: Free the in core representation of the supplied object header. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ @@ -584,7 +578,6 @@ H5O__cache_free_icr(void *_thing) FUNC_ENTER_PACKAGE assert(oh); - assert(oh->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(oh->cache_info.type == H5AC_OHDR); /* Destroy object header */ @@ -727,7 +720,7 @@ H5O__cache_chk_deserialize(const void *image, size_t len, void *_udata, hbool_t done: if (NULL == ret_value) if (chk_proxy && H5O__chunk_dest(chk_proxy) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_deserialize() */ @@ -749,7 +742,6 @@ H5O__cache_chk_image_len(const void *_thing, size_t *image_len) FUNC_ENTER_PACKAGE_NOERR assert(chk_proxy); - assert(chk_proxy->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(chk_proxy->cache_info.type == H5AC_OHDR_CHK); assert(chk_proxy->oh); assert(image_len); @@ -781,7 +773,6 @@ H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *_thing) assert(f); assert(image); assert(chk_proxy); - assert(chk_proxy->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(chk_proxy->cache_info.type == H5AC_OHDR_CHK); assert(chk_proxy->oh); assert(chk_proxy->oh->chunk[chk_proxy->chunkno].size == len); @@ -825,8 +816,6 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) /* Add flush dependency on chunk with continuation, if one exists */ if (chk_proxy->fd_parent) { /* Sanity checks */ - assert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == - H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type); assert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); @@ -883,8 +872,6 @@ H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) /* Remove flush dependency on parent object header chunk, if one is set */ if (chk_proxy->fd_parent) { /* Sanity checks */ - assert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->magic == - H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type); assert((((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_ID) || (((H5C_cache_entry_t *)(chk_proxy->fd_parent))->type->id == H5AC_OHDR_CHK_ID)); @@ -919,10 +906,6 @@ done: * Purpose: Free the in core memory associated with the supplied object * header continuation chunk. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ @@ -935,7 +918,6 @@ H5O__cache_chk_free_icr(void *_thing) FUNC_ENTER_PACKAGE assert(chk_proxy); - assert(chk_proxy->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(chk_proxy->cache_info.type == H5AC_OHDR_CHK); /* Destroy object header chunk proxy */ @@ -1183,7 +1165,7 @@ done: /* Release the [possibly partially initialized] object header on errors */ if (ret_value < 0 && oh) if (H5O__free(oh, FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header data") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header data"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__prefix_deserialize() */ @@ -1287,7 +1269,7 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t chunk_size, const uint8_t if (oh->version == H5O_VERSION_1) { if (H5_IS_BUFFER_OVERFLOW(chunk_image, 2, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); - UINT16DECODE(chunk_image, id) + UINT16DECODE(chunk_image, id); } else { if (H5_IS_BUFFER_OVERFLOW(chunk_image, 1, p_end)) diff --git a/src/H5Ocache_image.c b/src/H5Ocache_image.c index ac2630a..e3e2a63 100644 --- a/src/H5Ocache_image.c +++ b/src/H5Ocache_image.c @@ -71,7 +71,7 @@ const H5O_msg_class_t H5O_MSG_MDCI[1] = {{ #define H5O_MDCI_VERSION_0 0 /* Declare the free list for H5O_mdci_t's */ -H5FL_DEFINE(H5O_mdci_t); +H5FL_DEFINE_STATIC(H5O_mdci_t); /*------------------------------------------------------------------------- * Function: H5O__mdci_decode @@ -109,7 +109,7 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(mesg->addr)); + H5F_addr_decode(f, &p, &(mesg->addr)); if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); @@ -148,7 +148,7 @@ H5O__mdci_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co /* encode */ *p++ = H5O_MDCI_VERSION_0; - H5_addr_encode(f, &p, mesg->addr); + H5F_addr_encode(f, &p, mesg->addr); H5F_ENCODE_LENGTH(f, p, mesg->size); FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index d96940a..48a1b8e 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -118,12 +118,12 @@ done: /* Cleanup on failure */ if (ret_value < 0) if (chk_proxy && H5O__chunk_dest(chk_proxy) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk"); /* Release resources */ if (cont_chk_proxy) if (H5O__chunk_unprotect(f, cont_chk_proxy, FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_add() */ @@ -193,7 +193,7 @@ done: /* Cleanup on error */ if (!ret_value) if (0 == idx && chk_proxy && H5O__chunk_dest(chk_proxy) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "unable to destroy object header chunk"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_protect() */ @@ -363,7 +363,7 @@ H5O__chunk_delete(H5F_t *f, H5O_t *oh, unsigned idx) done: /* Release the chunk proxy from the cache, marking it deleted */ if (chk_proxy && H5AC_unprotect(f, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, cache_flags) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__chunk_delete() */ diff --git a/src/H5Ocont.c b/src/H5Ocont.c index 1dfaf46..3f14a32 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -95,7 +95,7 @@ H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE /* Decode */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(cont->addr)); + H5F_addr_decode(f, &p, &(cont->addr)); if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); @@ -136,7 +136,7 @@ H5O__cont_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co assert(cont->size > 0); /* encode */ - H5_addr_encode(f, &p, cont->addr); + H5F_addr_encode(f, &p, cont->addr); H5F_ENCODE_LENGTH(f, p, cont->size); FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index ae37259..573abbd 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -166,9 +166,9 @@ H5O__copy(const H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, const done: if (loc_found && H5G_loc_free(&src_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location"); if (obj_open && H5O_close(&src_oloc, NULL) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy() */ @@ -281,7 +281,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5 HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") } /* end if */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ } /* end if */ @@ -739,11 +739,11 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5 HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "unable to re-tag metadata entries") /* Set metadata tag for destination object's object header */ - H5_BEGIN_TAG(oloc_dst->addr); + H5_BEGIN_TAG(oloc_dst->addr) /* Insert destination object header in cache */ if (H5AC_insert_entry(oloc_dst->file, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header"); oh_dst = NULL; inserted = TRUE; @@ -764,15 +764,15 @@ done: /* Release pointer to source object header and its derived objects */ if (oh_src && H5O_unprotect(oloc_src, oh_src, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); /* Free destination object header on failure */ if (ret_value < 0) { if (oh_dst && !inserted) { if (H5O__free(oh_dst, TRUE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") + 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") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data"); } /* end if */ if (addr_map == NULL && cpy_udata) { @@ -1122,9 +1122,9 @@ H5O__copy_comm_dt_cmp(const void *_key1, const void *_key2) * first so only one comparison needs to be made. */ if (key1->fileno != key2->fileno) { if (key1->fileno < key2->fileno) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (key1->fileno > key2->fileno) - HGOTO_DONE(1) + HGOTO_DONE(1); } /* end if */ ret_value = H5T_cmp(key1->dt, key2->dt, FALSE); @@ -1378,7 +1378,7 @@ H5O__copy_search_comm_dt_cb(hid_t H5_ATTR_UNUSED group, const char *name, const done: /* Release resources */ if (obj_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_search_comm_dt_cb */ diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c index 431a1aa..c9674d3 100644 --- a/src/H5Ocopy_ref.c +++ b/src/H5Ocopy_ref.c @@ -14,7 +14,7 @@ * * Created: H5Ocopy_ref.c * - * Purpose: Object with references copying routines. + * Purpose: Object with references copying routines * *------------------------------------------------------------------------- */ @@ -30,6 +30,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File */ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ @@ -242,7 +243,7 @@ H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t /* Get object address */ p = (const uint8_t *)data; - H5_addr_decode(src_oloc->file, &p, &src_oloc->addr); + H5F_addr_decode(src_oloc->file, &p, &src_oloc->addr); if (!H5_addr_defined(src_oloc->addr) || src_oloc->addr == 0) { H5MM_free(data); HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer") @@ -257,7 +258,7 @@ H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t /* Serialize object addr */ q = (uint8_t *)data; - H5_addr_encode(dst_oloc->file, &q, dst_oloc->addr); + H5F_addr_encode(dst_oloc->file, &q, dst_oloc->addr); /* Write to heap */ if (H5R__encode_heap(dst_oloc->file, dst_buf, &buf_size, data, (size_t)data_size) < 0) { @@ -401,20 +402,20 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, const H5T_t *dt done: if (buf_space && (H5S_close(buf_space) < 0)) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't close dataspace") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't close dataspace"); /* Don't decrement ID, we want to keep underlying datatype */ if (reg_tid_src && (tid_src > 0) && (NULL == H5I_remove(tid_src))) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if ((tid_mem > 0) && H5I_dec_ref(tid_mem) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if ((tid_dst > 0) && H5I_dec_ref(tid_dst) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID"); if (reclaim_buf) reclaim_buf = H5FL_BLK_FREE(type_conv, reclaim_buf); if (conv_buf) conv_buf = H5FL_BLK_FREE(type_conv, conv_buf); if ((dst_loc_id != H5I_INVALID_HID) && (H5I_dec_ref(dst_loc_id) < 0)) - HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id") + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_expand_ref_object2() */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 6fd7b32..5e6f04c 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -522,7 +522,7 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) done: if (oh && H5O_unprotect(&loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_debug() */ diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 5f38dd5..ae45d16 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -33,6 +33,7 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -90,14 +91,14 @@ static herr_t H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_p static herr_t H5O__reset_info1(H5O_info1_t *oinfo) { - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR /* Reset the passed-in info struct */ memset(oinfo, 0, sizeof(H5O_info1_t)); oinfo->type = H5O_TYPE_UNKNOWN; oinfo->addr = HADDR_UNDEF; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__reset_info1() */ /*------------------------------------------------------------------------- @@ -197,7 +198,7 @@ H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, ret_value = (shim_data->real_op)(obj_id, name, &oinfo, shim_data->real_op_data); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__iterate1_adapter() */ /*------------------------------------------------------------------------- diff --git a/src/H5Odtype.c b/src/H5Odtype.c index e3ab685..24e382c 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -384,13 +384,13 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT32DECODE_VAR(*pp, dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset, - offset_nbytes) + offset_nbytes); } else { if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 4, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); - UINT32DECODE(*pp, dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset) + UINT32DECODE(*pp, dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset); } /* Older versions of the library allowed a field to have @@ -448,7 +448,7 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name = H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name); if (H5T_close_real(temp_type) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info"); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type") } if (temp_type->shared->size == 0) @@ -472,7 +472,7 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name); if (H5T_close_real(temp_type) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, - "can't release datatype info") + "can't release datatype info"); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype") } @@ -777,7 +777,7 @@ done: /* Release (reset) dt but do not free it - leave it as an empty datatype as was the case on * function entry */ if (H5T__free(dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_decode_helper() */ @@ -1138,9 +1138,9 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt) /* Member offset */ /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ if (dt->shared->version >= H5O_DTYPE_VERSION_3) - UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes) + UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes); else - UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset) + UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset); /* If we don't have any array fields, write out the old style * member information, for better backward compatibility @@ -1344,7 +1344,7 @@ done: if (!ret_value) /* Free dt */ if (H5T_close_real(dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't release datatype info") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't release datatype info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_decode() */ @@ -1691,13 +1691,13 @@ H5O__dtype_can_share(const void *_mesg) /* Don't share immutable datatypes */ if ((tri_ret = H5T_is_immutable(mesg)) > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else if (tri_ret < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is immutable") /* Don't share committed datatypes */ if ((tri_ret = H5T_is_named(mesg)) > 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else if (tri_ret < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is shared") diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 9018540..51794f2 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -85,7 +85,6 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED /* Check args */ assert(f); assert(p); - assert(p_size > 0); if (NULL == (mesg = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") @@ -118,7 +117,7 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED /* Heap address */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(mesg->heap_addr)); + H5F_addr_decode(f, &p, &(mesg->heap_addr)); if (H5_addr_defined(mesg->heap_addr) == FALSE) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad local heap address when parsing efl msg") @@ -182,7 +181,7 @@ done: } if (heap != NULL) if (H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect local heap") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect local heap"); } FUNC_LEAVE_NOAPI(ret_value) @@ -226,7 +225,7 @@ H5O__efl_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, con /* Heap address */ assert(H5_addr_defined(mesg->heap_addr)); - H5_addr_encode(f, &p, mesg->heap_addr); + H5F_addr_encode(f, &p, mesg->heap_addr); /* Encode file list */ for (u = 0; u < mesg->nused; u++) { @@ -490,7 +489,7 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d done: /* Release resources */ if (heap && H5HL_unprotect(heap) < 0) - HDONE_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to unprotect EFL file name heap") + HDONE_ERROR(H5E_EFL, H5E_PROTECT, NULL, "unable to unprotect EFL file name heap"); if (!ret_value) if (efl_dst) H5MM_xfree(efl_dst); diff --git a/src/H5Ofill.c b/src/H5Ofill.c index ad9efe8..18ceb13 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -757,7 +757,7 @@ H5O_fill_reset_dyn(H5O_fill_t *fill) done: if (fill_type_id > 0 && H5I_dec_ref(fill_type_id) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_reset_dyn() */ @@ -1028,9 +1028,9 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) done: if (src_id >= 0 && H5I_dec_ref(src_id) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID"); if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID"); if (bkg) H5MM_xfree(bkg); diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 10657f2..844b240 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -160,7 +160,7 @@ H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag) done: /* Unprotect object header on failure */ if (oh && H5O_unprotect(oloc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__oh_tag() */ @@ -256,7 +256,7 @@ done: if (objs_incr && file) H5F_decr_nopen_objs(file); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_refresh_metadata() */ /*------------------------------------------------------------------------- @@ -319,7 +319,7 @@ H5O__refresh_metadata_close(H5O_loc_t *oloc, H5G_loc_t *obj_loc, hid_t oid) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") /* Evict the object's tagged metadata */ - if (H5F_evict_tagged_metadata(file, tag) < 0) + if (H5AC_evict_tagged_metadata(file, tag, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to evict metadata") /* Re-cork object with tag */ @@ -328,7 +328,7 @@ H5O__refresh_metadata_close(H5O_loc_t *oloc, H5G_loc_t *obj_loc, hid_t oid) HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to cork the object") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__refresh_metadata_close() */ /*------------------------------------------------------------------------- @@ -415,5 +415,5 @@ H5O_refresh_metadata_reopen(hid_t oid, hid_t apl_id, H5G_loc_t *obj_loc, H5VL_t HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to re-register object ID after refresh") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_refresh_metadata_reopen() */ diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index f9528fd..0936380 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -111,9 +111,9 @@ H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU vers = *p++; if (vers == H5O_FSINFO_VERSION_0) { - H5F_file_space_type_t strategy; /* Strategy */ - hsize_t threshold; /* Threshold */ - H5FD_mem_t type; /* Memory type for iteration */ + H5F_file_space_type_t strategy; /* Strategy */ + hsize_t threshold = 0; /* Threshold */ + H5FD_mem_t type; /* Memory type for iteration */ fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; @@ -138,7 +138,7 @@ H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(fsinfo->fs_addr[type - 1])); + H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type - 1])); } break; @@ -188,15 +188,15 @@ H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, - &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ + H5F_addr_decode(f, &p, + &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ /* Decode addresses of free space managers, if persisting */ if (fsinfo->persist) for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); + H5F_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); } fsinfo->mapped = FALSE; } @@ -238,15 +238,15 @@ H5O__fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section size threshold */ - H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ - UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ - H5_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ + H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ + UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ + H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ /* Store addresses of free-space managers, if persisting */ if (fsinfo->persist) /* Addresses of free-space managers */ for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) - H5_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); + H5F_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__fsinfo_encode() */ diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index 3a9bab7..3a61cdf 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -118,8 +118,8 @@ H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign if (ginfo->store_link_phase_change) { if (H5_IS_BUFFER_OVERFLOW(p, 2 * 2, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - UINT16DECODE(p, ginfo->max_compact) - UINT16DECODE(p, ginfo->min_dense) + UINT16DECODE(p, ginfo->max_compact); + UINT16DECODE(p, ginfo->min_dense); } else { ginfo->max_compact = H5G_CRT_GINFO_MAX_COMPACT; @@ -130,8 +130,8 @@ H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign if (ginfo->store_est_entry_info) { if (H5_IS_BUFFER_OVERFLOW(p, 2 * 2, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - UINT16DECODE(p, ginfo->est_num_entries) - UINT16DECODE(p, ginfo->est_name_len) + UINT16DECODE(p, ginfo->est_num_entries); + UINT16DECODE(p, ginfo->est_name_len); } else { ginfo->est_num_entries = H5G_CRT_GINFO_EST_NUM_ENTRIES; @@ -180,14 +180,14 @@ H5O__ginfo_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared /* Store the max. # of links to store compactly & the min. # of links to store densely */ if (ginfo->store_link_phase_change) { - UINT16ENCODE(p, ginfo->max_compact) - UINT16ENCODE(p, ginfo->min_dense) + UINT16ENCODE(p, ginfo->max_compact); + UINT16ENCODE(p, ginfo->min_dense); } /* end if */ /* Estimated # of entries & name lengths */ if (ginfo->store_est_entry_info) { - UINT16ENCODE(p, ginfo->est_num_entries) - UINT16ENCODE(p, ginfo->est_name_len) + UINT16ENCODE(p, ginfo->est_num_entries); + UINT16ENCODE(p, ginfo->est_name_len); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Oint.c b/src/H5Oint.c index ce15a33..43044b4 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -284,7 +284,7 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc done: if ((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh, TRUE) < 0)) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "can't delete object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "can't delete object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_create() */ @@ -345,7 +345,7 @@ H5O_create_ohdr(H5F_t *f, hid_t ocpl_id) done: if ((NULL == ret_value) && (NULL != oh) && (H5O__free(oh, TRUE) < 0)) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "can't delete object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "can't delete object header"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O_create_ohdr() */ @@ -505,11 +505,11 @@ H5O_apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t init } /* Set metadata tag in API context */ - H5_BEGIN_TAG(oh_addr); + H5_BEGIN_TAG(oh_addr) /* Cache object header */ if (H5AC_insert_entry(f, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header"); /* Reset object header pointer, now that it's been inserted into the cache */ oh = NULL; @@ -525,7 +525,7 @@ H5O_apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t init HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5O_apply_ohdr() */ /*------------------------------------------------------------------------- @@ -604,7 +604,7 @@ H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type) done: if (NULL == ret_value) if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_name() */ @@ -652,7 +652,7 @@ done: /* Release the object location if we failed after copying it */ if (NULL == ret_value) if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__open_by_idx() */ @@ -937,9 +937,9 @@ H5O_link(const H5O_loc_t *loc, int adjust) done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); if (ret_value >= 0 && deleted && H5O_delete(loc->file, loc->addr) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") + HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_link() */ @@ -1127,7 +1127,7 @@ done: cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs); if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header"); } FUNC_LEAVE_NOAPI_TAG(ret_value) @@ -1172,7 +1172,7 @@ H5O_pin(const H5O_loc_t *loc) done: /* Release the object header from the cache */ if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_pin() */ @@ -1347,7 +1347,7 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) done: /* Release chunk */ if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_touch_oh() */ @@ -1389,7 +1389,7 @@ H5O_touch(const H5O_loc_t *loc, hbool_t force) done: if (oh && H5O_unprotect(loc, oh, oh_flags) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_touch() */ @@ -1512,7 +1512,7 @@ H5O_delete(H5F_t *f, haddr_t addr) done: if (oh && H5O_unprotect(&loc, oh, oh_flags) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_delete() */ @@ -1585,7 +1585,7 @@ H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_obj_type() */ @@ -1654,7 +1654,7 @@ H5O__obj_class(const H5O_loc_t *loc) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__obj_class() */ @@ -1688,7 +1688,7 @@ H5O__obj_class_real(const H5O_t *oh) if ((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") else if (isa) - HGOTO_DONE(H5O_obj_class_g[i - 1]) + HGOTO_DONE(H5O_obj_class_g[i - 1]); } if (0 == i) @@ -1975,7 +1975,7 @@ H5O_get_hdr_info(const H5O_loc_t *loc, H5O_hdr_info_t *hdr) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_hdr_info() */ @@ -2158,7 +2158,7 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_get_info() */ @@ -2217,7 +2217,7 @@ H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fie done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_get_native_info() */ @@ -2272,7 +2272,7 @@ H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_create_plist() */ @@ -2308,7 +2308,7 @@ H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_nlinks() */ @@ -2392,7 +2392,7 @@ H5O_get_oh_flags(const H5O_t *oh) { FUNC_ENTER_NOAPI_NOINIT_NOERR assert(oh); - FUNC_LEAVE_NOAPI(oh->flags); /* flags can be 0 */ + FUNC_LEAVE_NOAPI(oh->flags) /* flags can be 0 */ } /* H5O_get_oh_flags() */ /*------------------------------------------------------------------------- @@ -2410,7 +2410,7 @@ H5O_get_oh_mtime(const H5O_t *oh) FUNC_ENTER_NOAPI_NOINIT_NOERR assert(oh); assert(oh->mtime); - FUNC_LEAVE_NOAPI(oh->mtime); + FUNC_LEAVE_NOAPI(oh->mtime) } /* H5O_get_oh_mtime() */ /*------------------------------------------------------------------------- @@ -2424,7 +2424,7 @@ H5O_get_oh_version(const H5O_t *oh) FUNC_ENTER_NOAPI_NOINIT_NOERR assert(oh); assert(oh->version); - FUNC_LEAVE_NOAPI(oh->version); + FUNC_LEAVE_NOAPI(oh->version) } /* H5O_get_oh_version() */ /*------------------------------------------------------------------------- @@ -2463,7 +2463,7 @@ H5O_get_rc_and_type(const H5O_loc_t *loc, unsigned *rc, H5O_type_t *otype) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_get_rc_and_type() */ @@ -2570,7 +2570,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *l done: /* Release resources */ if (obj_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__visit_cb() */ @@ -2715,10 +2715,10 @@ done: /* XXX (VOL MERGE): Probably also want to consider closing obj here on failures */ if (obj_id != H5I_INVALID_HID) { if (H5I_dec_app_ref(obj_id) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object"); } else if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location"); if (udata.visited) H5SL_destroy(udata.visited, H5O__free_visit_visited, NULL); @@ -2822,7 +2822,7 @@ H5O_dec_rc_by_loc(const H5O_loc_t *loc) done: /* Release the object header from the cache */ if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dec_rc_by_loc() */ @@ -2923,12 +2923,12 @@ done: static herr_t H5O__reset_info2(H5O_info2_t *oinfo) { - FUNC_ENTER_PACKAGE_NOERR; + FUNC_ENTER_PACKAGE_NOERR /* Reset the passed-in info struct */ memset(oinfo, 0, sizeof(H5O_info2_t)); oinfo->type = H5O_TYPE_UNKNOWN; oinfo->token = H5O_TOKEN_UNDEF; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__reset_info2() */ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index d501895..5b741f6 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -136,7 +136,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (mesg->type == H5D_CONTIGUOUS) { if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); /* Set the layout operations */ mesg->ops = H5D_LOPS_CONTIG; @@ -144,7 +144,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU else if (mesg->type == H5D_CHUNKED) { if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Set the layout operations */ mesg->ops = H5D_LOPS_CHUNK; @@ -255,7 +255,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU /* Contiguous storage address */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); /* Contiguous storage size */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) @@ -286,7 +286,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); if (H5_IS_BUFFER_OVERFLOW(p, (mesg->u.chunk.ndims * 4), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, @@ -512,7 +512,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); } /* Set the layout operations */ @@ -527,7 +527,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU /* Heap information */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(mesg->storage.u.virt.serial_list_hobjid.addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.virt.serial_list_hobjid.addr)); /* NOTE: virtual mapping global heap entry address could be undefined */ if (H5_IS_BUFFER_OVERFLOW(p, 4, p_end)) @@ -551,7 +551,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU uint8_t heap_vers; size_t block_size = 0; size_t tmp_size; - hsize_t tmp_hsize; + hsize_t tmp_hsize = 0; uint32_t stored_chksum; uint32_t computed_chksum; @@ -578,7 +578,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (H5_IS_BUFFER_OVERFLOW(heap_block_p, H5F_sizeof_size(f), heap_block_p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5F_DECODE_LENGTH(f, heap_block_p, tmp_hsize) + H5F_DECODE_LENGTH(f, heap_block_p, tmp_hsize); /* Allocate entry list */ if (NULL == (mesg->storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc( @@ -728,7 +728,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (H5_IS_BUFFER_OVERFLOW(heap_block_p, 4, heap_block_p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - UINT32DECODE(heap_block_p, stored_chksum) + UINT32DECODE(heap_block_p, stored_chksum); /* Compute checksum */ computed_chksum = H5_checksum_metadata(heap_block, block_size - (size_t)4, 0); @@ -763,7 +763,7 @@ done: if (mesg) { if (mesg->type == H5D_VIRTUAL) if (H5D__virtual_reset_layout(mesg) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to reset virtual layout") + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to reset virtual layout"); H5FL_FREE(H5O_layout_t, mesg); } @@ -822,7 +822,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, case H5D_CONTIGUOUS: /* Contiguous storage address */ - H5_addr_encode(f, &p, mesg->storage.u.contig.addr); + H5F_addr_encode(f, &p, mesg->storage.u.contig.addr); /* Contiguous storage size */ H5F_ENCODE_LENGTH(f, p, mesg->storage.u.contig.size); @@ -835,7 +835,7 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, *p++ = (uint8_t)mesg->u.chunk.ndims; /* B-tree address */ - H5_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr); + H5F_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr); /* Dimension sizes */ for (u = 0; u < mesg->u.chunk.ndims; u++) @@ -907,13 +907,13 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, * Single chunk index: address of the single chunk * Other indexes: chunk index address */ - H5_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr); + H5F_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr); } /* end else */ break; case H5D_VIRTUAL: /* Encode heap ID for VDS info */ - H5_addr_encode(f, &p, mesg->storage.u.virt.serial_list_hobjid.addr); + H5F_addr_encode(f, &p, mesg->storage.u.virt.serial_list_hobjid.addr); UINT32ENCODE(p, mesg->storage.u.virt.serial_list_hobjid.idx); break; diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index 4a1fc9f..36f664a 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -138,7 +138,7 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS if (linfo->track_corder) { if (H5_IS_BUFFER_OVERFLOW(p, 8, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - INT64DECODE(p, linfo->max_corder) + INT64DECODE(p, linfo->max_corder); } else linfo->max_corder = 0; @@ -148,16 +148,16 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") /* Address of fractal heap to store "dense" links */ - H5_addr_decode(f, &p, &(linfo->fheap_addr)); + H5F_addr_decode(f, &p, &(linfo->fheap_addr)); /* Address of v2 B-tree to index names of links (names are always indexed) */ - H5_addr_decode(f, &p, &(linfo->name_bt2_addr)); + H5F_addr_decode(f, &p, &(linfo->name_bt2_addr)); /* Address of v2 B-tree to index creation order of links, if there is one */ if (linfo->index_corder) { if (H5_IS_BUFFER_OVERFLOW(p, addr_size, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(linfo->corder_bt2_addr)); + H5F_addr_decode(f, &p, &(linfo->corder_bt2_addr)); } else linfo->corder_bt2_addr = HADDR_UNDEF; @@ -205,17 +205,17 @@ H5O__linfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c /* Max. link creation order value for the group, if tracked */ if (linfo->track_corder) - INT64ENCODE(p, linfo->max_corder) + INT64ENCODE(p, linfo->max_corder); /* Address of fractal heap to store "dense" links */ - H5_addr_encode(f, &p, linfo->fheap_addr); + H5F_addr_encode(f, &p, linfo->fheap_addr); /* Address of v2 B-tree to index names of links */ - H5_addr_encode(f, &p, linfo->name_bt2_addr); + H5F_addr_encode(f, &p, linfo->name_bt2_addr); /* Address of v2 B-tree to index creation order of links, if they are indexed */ if (linfo->index_corder) - H5_addr_encode(f, &p, linfo->corder_bt2_addr); + H5F_addr_encode(f, &p, linfo->corder_bt2_addr); else assert(!H5_addr_defined(linfo->corder_bt2_addr)); @@ -437,12 +437,12 @@ H5O__linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) dst_lnk_init = TRUE; /* Set metadata tag in API context */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Insert the new object in the destination file's group */ /* (Doesn't increment the link count - that's already been taken care of for hard links) */ if (H5G__dense_insert(udata->dst_oloc->file, udata->dst_linfo, &dst_lnk) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link"); /* Reset metadata tag in API context */ H5_END_TAG @@ -484,7 +484,7 @@ H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_l /* If we are performing a 'shallow hierarchy' copy, get out now */ if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Check for copying dense link storage */ if (H5_addr_defined(linfo_src->fheap_addr)) { diff --git a/src/H5Olink.c b/src/H5Olink.c index b42f2c0..4fa70c1 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -149,7 +149,7 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE if (link_flags & H5O_LINK_STORE_CORDER) { if (H5_IS_BUFFER_OVERFLOW(p, 8, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - INT64DECODE(p, lnk->corder) + INT64DECODE(p, lnk->corder); lnk->corder_valid = TRUE; } else { @@ -216,14 +216,14 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE /* Get the address of the object the link points to */ if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - H5_addr_decode(f, &p, &(lnk->u.hard.addr)); + H5F_addr_decode(f, &p, &(lnk->u.hard.addr)); break; case H5L_TYPE_SOFT: /* Get the link value */ if (H5_IS_BUFFER_OVERFLOW(p, 2, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - UINT16DECODE(p, len) + UINT16DECODE(p, len); if (len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid link length") @@ -247,7 +247,7 @@ H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE /* A UD link. Get the user-supplied data */ if (H5_IS_BUFFER_OVERFLOW(p, 2, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - UINT16DECODE(p, len) + UINT16DECODE(p, len); if (lnk->type == H5L_TYPE_EXTERNAL && len < 3) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "external link information length < 3") lnk->u.ud.size = len; @@ -329,7 +329,7 @@ H5O__link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co /* Store the link creation order in the file, if its valid */ if (lnk->corder_valid) - INT64ENCODE(p, lnk->corder) + INT64ENCODE(p, lnk->corder); /* Store a non-default link name character set */ if (link_flags & H5O_LINK_STORE_NAME_CSET) @@ -365,14 +365,14 @@ H5O__link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co switch (lnk->type) { case H5L_TYPE_HARD: /* Store the address of the object the link points to */ - H5_addr_encode(f, &p, lnk->u.hard.addr); + H5F_addr_encode(f, &p, lnk->u.hard.addr); break; case H5L_TYPE_SOFT: /* Store the link value */ len = (uint16_t)HDstrlen(lnk->u.soft.name); assert(len > 0); - UINT16ENCODE(p, len) + UINT16ENCODE(p, len); H5MM_memcpy(p, lnk->u.soft.name, (size_t)len); p += len; break; @@ -386,7 +386,7 @@ H5O__link_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co /* Store the user-supplied data, however long it is */ len = (uint16_t)lnk->u.ud.size; - UINT16ENCODE(p, len) + UINT16ENCODE(p, len); if (len > 0) { H5MM_memcpy(p, lnk->u.ud.udata, (size_t)len); p += len; @@ -645,7 +645,7 @@ H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) done: /* Release the file ID */ if (file_id > 0 && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") + HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_link_delete() */ diff --git a/src/H5Omessage.c b/src/H5Omessage.c index c26a0ff..1c68c22 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -116,7 +116,7 @@ H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, unsi done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_create() */ @@ -249,7 +249,7 @@ H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, unsig done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_write() */ @@ -433,7 +433,7 @@ H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_msg_read() */ @@ -722,7 +722,7 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_count() */ @@ -796,7 +796,7 @@ H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_msg_exists() */ @@ -833,7 +833,7 @@ H5O_msg_exists_oh(const H5O_t *oh, unsigned type_id) /* Scan through the messages looking for the right one */ for (u = 0; u < oh->nmesgs; u++) if (type == oh->mesg[u].type) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -883,7 +883,7 @@ H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_remove() */ @@ -930,7 +930,7 @@ H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, H5O_oper done: if (oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_remove_op() */ @@ -988,7 +988,7 @@ H5O__msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, un /* Break out now, if we've found the correct message */ if (udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL) - HGOTO_DONE(H5_ITER_STOP) + HGOTO_DONE(H5_ITER_STOP); } /* end if */ done: @@ -1104,7 +1104,7 @@ H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, const H5O_mesg_operator_ done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_iterate() */ @@ -1190,11 +1190,11 @@ done: */ if (oh_modified & H5O_MODIFY_CONDENSE) if (H5O__condense_header(f, oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack object header"); /* Mark object header as changed */ if (H5O_touch_oh(f, oh, FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object") + HDONE_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object"); /* Mark object header as dirty in cache */ if (H5AC_mark_entry_dirty(oh) < 0) @@ -1805,7 +1805,7 @@ H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, con done: /* Release chunk, if not already released */ if (chk_proxy && H5O__chunk_unprotect(f, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__copy_mesg() */ @@ -1922,7 +1922,7 @@ H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg) /* Encode the message prefix */ if (oh->version == H5O_VERSION_1) - UINT16ENCODE(p, msg_id) + UINT16ENCODE(p, msg_id); else *p++ = (uint8_t)msg_id; assert(mesg->raw_size < H5O_MESG_MAX_SIZE); @@ -2072,7 +2072,7 @@ H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t *flags) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_get_flags() */ diff --git a/src/H5Omtime.c b/src/H5Omtime.c index 71a0974..6cdd4b7 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -184,7 +184,7 @@ H5O__mtime_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, if (H5_IS_BUFFER_OVERFLOW(p, 16, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); for (int i = 0; i < 14; i++) - if (!HDisdigit(p[i])) + if (!isdigit(p[i])) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message") /* Convert YYYYMMDDhhmmss UTC to a time_t. */ diff --git a/src/H5Opline.c b/src/H5Opline.c index 5d613ce..476e2ac 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -228,7 +228,7 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign for (size_t j = 0; j < filter->cd_nelmts; j++) { if (H5_IS_BUFFER_OVERFLOW(p, 4, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - UINT32DECODE(p, filter->cd_values[j]) + UINT32DECODE(p, filter->cd_values[j]); } if (pline->version == H5O_PLINE_VERSION_1) diff --git a/src/H5Orefcount.c b/src/H5Orefcount.c index add9a8b..b280b3a 100644 --- a/src/H5Orefcount.c +++ b/src/H5Orefcount.c @@ -104,7 +104,7 @@ H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, /* Get reference count for object */ if (H5_IS_BUFFER_OVERFLOW(p, 4, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") - UINT32DECODE(p, *refcount) + UINT32DECODE(p, *refcount); /* Set return value */ ret_value = refcount; diff --git a/src/H5Oshared.c b/src/H5Oshared.c index d80ab9d..718b3a7 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -179,9 +179,9 @@ H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't close fractal heap") + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't close fractal heap"); if (wb && H5WB_unwrap(wb) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") + HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, NULL, "can't close wrapped buffer"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__shared_read() */ @@ -327,7 +327,7 @@ H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *b /* Decode stored "symbol table entry" into message location */ buf += H5F_SIZEOF_SIZE(f); /* Skip over local heap address */ - H5_addr_decode(f, &buf, &(sh_mesg.u.loc.oh_addr)); + H5F_addr_decode(f, &buf, &(sh_mesg.u.loc.oh_addr)); } /* end if */ else if (version >= H5O_SHARED_VERSION_2) { /* If this message is in the heap, copy a heap ID. @@ -345,7 +345,7 @@ H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *b sh_mesg.type = H5O_SHARE_TYPE_COMMITTED; sh_mesg.u.loc.index = 0; - H5_addr_decode(f, &buf, &sh_mesg.u.loc.oh_addr); + H5F_addr_decode(f, &buf, &sh_mesg.u.loc.oh_addr); } /* end else */ } /* end else if */ @@ -401,7 +401,7 @@ H5O__shared_encode(const H5F_t *f, uint8_t *buf /*out*/, const H5O_shared_t *sh_ if (sh_mesg->type == H5O_SHARE_TYPE_SOHM) H5MM_memcpy(buf, &(sh_mesg->u.heap_id), sizeof(sh_mesg->u.heap_id)); else - H5_addr_encode(f, &buf, sh_mesg->u.loc.oh_addr); + H5F_addr_encode(f, &buf, sh_mesg->u.loc.oh_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__shared_encode() */ @@ -572,10 +572,11 @@ H5O__shared_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, H5F_t *file_dst, if (shared_src->type != H5O_SHARE_TYPE_COMMITTED) { /* Simulate trying to share new message in the destination file. */ /* Set copied metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) if (H5SM_try_share(file_dst, NULL, H5SM_DEFER, mesg_type->id, _native_dst, mesg_flags) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_WRITEERROR, FAIL, + "unable to determine if message should be shared"); /* Reset metadata tag */ H5_END_TAG diff --git a/src/H5Oshared.h b/src/H5Oshared.h index d10b298..aef49f0 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -308,7 +308,7 @@ H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, hbool_ #endif /* H5O_SHARED_COPY_FILE_REAL */ /* Reset shared message info for new message */ - HDmemset(dst_mesg, 0, sizeof(H5O_shared_t)); + memset(dst_mesg, 0, sizeof(H5O_shared_t)); /* Handle sharing destination message */ if (H5O__shared_copy_file(file_src, file_dst, H5O_SHARED_TYPE, _native_src, dst_mesg, recompute_size, diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c index d044f97..d5303b7 100644 --- a/src/H5Oshmesg.c +++ b/src/H5Oshmesg.c @@ -87,7 +87,7 @@ H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(mesg->addr)); + H5F_addr_decode(f, &p, &(mesg->addr)); if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); @@ -126,7 +126,7 @@ H5O__shmesg_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, /* Store version, table address, and number of indexes */ *p++ = (uint8_t)mesg->version; - H5_addr_encode(f, &p, mesg->addr); + H5F_addr_encode(f, &p, mesg->addr); *p++ = (uint8_t)mesg->nindexes; FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 66ffe56..64dfb90 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -98,11 +98,11 @@ H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(stab->btree_addr)); + H5F_addr_decode(f, &p, &(stab->btree_addr)); if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); - H5_addr_decode(f, &p, &(stab->heap_addr)); + H5F_addr_decode(f, &p, &(stab->heap_addr)); ret_value = stab; @@ -135,8 +135,8 @@ H5O__stab_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co assert(stab); /* encode */ - H5_addr_encode(f, &p, stab->btree_addr); - H5_addr_encode(f, &p, stab->heap_addr); + H5F_addr_encode(f, &p, stab->btree_addr); + H5F_addr_encode(f, &p, stab->heap_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__stab_encode() */ @@ -289,11 +289,11 @@ H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, NULL, "can't query local heap size") /* Set copy metadata tag */ - H5_BEGIN_TAG(H5AC__COPIED_TAG); + H5_BEGIN_TAG(H5AC__COPIED_TAG) /* Create components of symbol table message */ if (H5G__stab_create_components(file_dst, stab_dst, size_hint) < 0) - HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components"); /* Reset metadata tag */ H5_END_TAG @@ -343,7 +343,7 @@ H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_lo /* If we are performing a 'shallow hierarchy' copy, get out now */ if (cpy_info->max_depth >= 0 && cpy_info->curr_depth >= cpy_info->max_depth) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Set up B-tree iteration user data */ udata.src_oloc = src_oloc; diff --git a/src/H5Otest.c b/src/H5Otest.c index e42af5c..ff902dd 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -124,9 +124,9 @@ H5O__is_attr_dense_test(hid_t oid) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__is_attr_dense_test() */ @@ -195,12 +195,12 @@ H5O__is_attr_empty_test(hid_t oid) assert(nattrs == 0); /* Set metadata tag in API context */ - H5_BEGIN_TAG(loc->addr); + H5_BEGIN_TAG(loc->addr) /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, - "unable to open v2 B-tree for name index") + "unable to open v2 B-tree for name index"); /* Reset metadata tag in API context */ H5_END_TAG @@ -224,11 +224,11 @@ H5O__is_attr_empty_test(hid_t oid) done: /* Release resources */ if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index"); if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__is_attr_empty_test() */ @@ -297,11 +297,11 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) assert(obj_nattrs == 0); /* Set metadata tag in API context */ - H5_BEGIN_TAG(loc->addr); + H5_BEGIN_TAG(loc->addr) /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index"); /* Reset metadata tag in API context */ H5_END_TAG @@ -321,11 +321,11 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) done: /* Release resources */ if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index"); if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__num_attrs_test() */ @@ -374,45 +374,45 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) api_ctx_pushed = TRUE; /* Set metadata tag in API context */ - H5_BEGIN_TAG(loc->addr); + H5_BEGIN_TAG(loc->addr) /* Get the object header */ if (NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header"); /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; if (oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ if (H5A__get_ainfo(loc->file, oh, &ainfo) < 0) - HGOTO_ERROR_TAG(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") + HGOTO_ERROR_TAG(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message"); } /* end if */ /* Check for 'dense' attribute storage file addresses being defined */ if (!H5_addr_defined(ainfo.fheap_addr)) - HGOTO_DONE_TAG(FAIL) + HGOTO_DONE_TAG(FAIL); if (!H5_addr_defined(ainfo.name_bt2_addr)) - HGOTO_DONE_TAG(FAIL) + HGOTO_DONE_TAG(FAIL); /* Open the name index v2 B-tree */ if (NULL == (bt2_name = H5B2_open(loc->file, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index"); /* Retrieve # of records in name index */ if (H5B2_get_nrec(bt2_name, name_count) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index"); /* Check if there is a creation order index */ if (H5_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ if (NULL == (bt2_corder = H5B2_open(loc->file, ainfo.corder_bt2_addr, NULL))) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, - "unable to open v2 B-tree for creation order index") + "unable to open v2 B-tree for creation order index"); /* Retrieve # of records in creation order index */ if (H5B2_get_nrec(bt2_corder, corder_count) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, - "unable to retrieve # of records from creation order index") + "unable to retrieve # of records from creation order index"); } /* end if */ else *corder_count = 0; @@ -423,13 +423,13 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) done: /* Release resources */ if (bt2_name && H5B2_close(bt2_name) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index") + HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for name index"); if (bt2_corder && H5B2_close(bt2_corder) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index") + HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for creation order index"); if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__attr_dense_info_test() */ @@ -492,7 +492,7 @@ H5O__check_msg_marked_test(hid_t oid, hbool_t flag_val) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__check_msg_marked_test() */ @@ -596,7 +596,7 @@ H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) done: /* Release the object header */ if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__get_rc_test() */ @@ -663,9 +663,9 @@ H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__msg_get_chunkno_test() */ @@ -774,9 +774,9 @@ H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) done: if (oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (api_ctx_pushed && H5CX_pop(FALSE) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context") + HDONE_ERROR(H5E_OHDR, H5E_CANTRESET, FAIL, "can't reset API context"); FUNC_LEAVE_NOAPI(ret_value) } /* H5O__msg_move_to_new_chunk_test() */ diff --git a/src/H5PB.c b/src/H5PB.c index d90d8a4..01cfac0 100644 --- a/src/H5PB.c +++ b/src/H5PB.c @@ -705,7 +705,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * */ if (NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || (bypass_pb && H5FD_MEM_DRAW == type)) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ /* Update statistics */ @@ -1003,13 +1003,13 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const */ if (NULL == page_buf || (size >= page_buf->page_size && H5FD_MEM_DRAW != type) || (bypass_pb && H5FD_MEM_DRAW == type)) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); #ifdef H5_HAVE_PARALLEL if (bypass_pb) { if (H5PB_update_entry(page_buf, addr, size, buf) > 0) HGOTO_ERROR(H5E_PAGEBUF, H5E_CANTUPDATE, FAIL, "failed to update PB with metadata cache") - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ #endif } /* end if */ @@ -1424,7 +1424,7 @@ H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) metadata, then we can't make space for raw data */ if (0 == page_buf->raw_count && page_buf->min_meta_count == page_buf->meta_count) { assert(page_buf->meta_count * page_buf->page_size == page_buf->max_size); - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ /* check the metadata threshold before evicting metadata items */ @@ -1441,7 +1441,7 @@ H5PB__make_space(H5F_shared_t *f_sh, H5PB_t *page_buf, H5FD_mem_t inserted_type) raw data, then we can't make space for meta data */ if (0 == page_buf->meta_count && page_buf->min_raw_count == page_buf->raw_count) { assert(page_buf->raw_count * page_buf->page_size == page_buf->max_size); - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ /* check the raw data threshold before evicting raw data items */ diff --git a/src/H5PLint.c b/src/H5PLint.c index e9156f2..a169ec9 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -346,25 +346,25 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *s */ if (NULL == (handle = H5PL_OPEN_DLIB(path))) { H5PL_CLR_ERROR; /* clear error */ - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* Return a handle for the function H5PLget_plugin_type in the dynamic library. * The plugin library is supposed to define this function. */ if (NULL == (get_plugin_type = (H5PL_get_plugin_type_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_type"))) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Return a handle for the function H5PLget_plugin_info in the dynamic library. * The plugin library is supposed to define this function. */ if (NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info"))) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Check the plugin type and return if it doesn't match the one passed in */ loaded_plugin_type = (H5PL_type_t)(*get_plugin_type)(); if ((type != H5PL_TYPE_NONE) && (type != loaded_plugin_type)) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Get the plugin information */ switch (loaded_plugin_type) { @@ -462,7 +462,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *s done: if (!(*success) && handle) if (H5PL__close(handle) < 0) - HDONE_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + HDONE_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__open() */ diff --git a/src/H5PLpath.c b/src/H5PLpath.c index 9575f3c..c47c6fa 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -579,7 +579,7 @@ H5PL__path_table_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__path_table_iterate() */ /*------------------------------------------------------------------------- @@ -617,7 +617,7 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type /* Open the directory - skip the path if the directory can't be opened */ if (!(dirp = HDopendir(plugin_path))) - HGOTO_DONE(H5_ITER_CONT) + HGOTO_DONE(H5_ITER_CONT); /* Iterate through all entries in the directory */ while (NULL != (dp = HDreaddir(dirp))) { @@ -681,7 +681,7 @@ done: if (dirp) if (HDclosedir(dirp) < 0) HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, H5_ITER_ERROR, "can't close directory: %s", - HDstrerror(errno)) + HDstrerror(errno)); path = (char *)H5MM_xfree(path); @@ -711,7 +711,7 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type * skip the path if the directory can't be opened */ HDsnprintf(service, sizeof(service), "%s\\*.dll", plugin_path); if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE) - HGOTO_DONE(H5_ITER_CONT) + HGOTO_DONE(H5_ITER_CONT); /* Loop over all the files */ do { @@ -897,7 +897,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo if (H5PL__open(path, search_params->type, search_params->key, found, NULL, plugin_info) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if (*found) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); path = (char *)H5MM_xfree(path); } /* end if */ @@ -906,7 +906,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo done: if (dirp) if (HDclosedir(dirp) < 0) - HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "can't close directory: %s", HDstrerror(errno)) + HDONE_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "can't close directory: %s", HDstrerror(errno)); path = (char *)H5MM_xfree(path); @@ -964,7 +964,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo if (H5PL__open(path, search_params->type, search_params->key, found, NULL, plugin_info) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if (*found) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); path = (char *)H5MM_xfree(path); } diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 0431393..2d3358b 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -28,13 +28,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector Functions */ /****************/ /* Local Macros */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 4ec9969..2351a93 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -449,7 +449,7 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) /* Encode chunk dims */ HDcompile_assert(sizeof(uint32_t) == sizeof(layout->u.chunk.dim[0])); for (u = 0; u < (size_t)layout->u.chunk.ndims; u++) { - UINT32ENCODE(*pp, layout->u.chunk.dim[u]) + UINT32ENCODE(*pp, layout->u.chunk.dim[u]); *size += sizeof(uint32_t); } /* end for */ } /* end if */ @@ -457,7 +457,7 @@ H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) uint64_t nentries = (uint64_t)layout->storage.u.virt.list_nused; /* Encode number of entries */ - UINT64ENCODE(*pp, nentries) + UINT64ENCODE(*pp, nentries); *size += (size_t)8; /* Iterate over entries */ @@ -599,7 +599,7 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) /* Set rank & dimensions */ tmp_layout.u.chunk.ndims = (unsigned)ndims; for (u = 0; u < ndims; u++) - UINT32DECODE(*pp, tmp_layout.u.chunk.dim[u]) + UINT32DECODE(*pp, tmp_layout.u.chunk.dim[u]); /* Point at the newly set up struct */ layout = &tmp_layout; @@ -610,7 +610,7 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) uint64_t nentries; /* Number of VDS mappings */ /* Decode number of entries */ - UINT64DECODE(*pp, nentries) + UINT64DECODE(*pp, nentries); if (nentries == (uint64_t)0) /* Just use the default struct */ @@ -825,9 +825,9 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_ /* Check for different layout type */ if (layout1->type < layout2->type) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (layout1->type > layout2->type) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Compare non-dataset-specific fields in layout info */ switch (layout1->type) { @@ -840,16 +840,16 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_ /* Check the number of dimensions */ if (layout1->u.chunk.ndims < layout2->u.chunk.ndims) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (layout1->u.chunk.ndims > layout2->u.chunk.ndims) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Compare the chunk dims */ for (u = 0; u < layout1->u.chunk.ndims - 1; u++) { if (layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) - HGOTO_DONE(1) + HGOTO_DONE(1); } /* end for */ } /* end case */ break; @@ -861,9 +861,9 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_ /* Compare number of mappings */ if (layout1->storage.u.virt.list_nused < layout2->storage.u.virt.list_nused) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (layout1->storage.u.virt.list_nused > layout2->storage.u.virt.list_nused) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Iterate over mappings */ for (u = 0; u < layout1->storage.u.virt.list_nused; u++) { @@ -873,45 +873,45 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_ if ((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (!equal) - HGOTO_DONE(1) + HGOTO_DONE(1); if ((equal = H5S_SELECT_SHAPE_SAME( layout1->storage.u.virt.list[u].source_dset.virtual_select, layout2->storage.u.virt.list[u].source_dset.virtual_select)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (!equal) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Compare source file names */ strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_file_name, layout2->storage.u.virt.list[u].source_file_name); if (strcmp_ret < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (strcmp_ret > 0) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Compare source dataset names */ strcmp_ret = HDstrcmp(layout1->storage.u.virt.list[u].source_dset_name, layout2->storage.u.virt.list[u].source_dset_name); if (strcmp_ret < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (strcmp_ret > 0) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Compare source spaces. Note we cannot tell which is * "greater", so just return 1 if different, -1 on failure. */ if ((equal = H5S_extent_equal(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (!equal) - HGOTO_DONE(1) + HGOTO_DONE(1); if ((equal = H5S_SELECT_SHAPE_SAME(layout1->storage.u.virt.list[u].source_select, layout2->storage.u.virt.list[u].source_select)) < 0) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (!equal) - HGOTO_DONE(1) + HGOTO_DONE(1); } /* end for */ } /* end block */ break; @@ -1058,7 +1058,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) *(*pp)++ = (uint8_t)fill->fill_time; /* Encode size of fill value */ - INT64ENCODE(*pp, fill->size) + INT64ENCODE(*pp, fill->size); /* Encode the fill value & datatype */ if (fill->size > 0) { @@ -1145,7 +1145,7 @@ H5P__dcrt_fill_value_dec(const void **_pp, void *_value) fill->fill_time = (H5D_fill_time_t) * (*pp)++; /* Decode fill size */ - INT64DECODE(*pp, fill->size) + INT64DECODE(*pp, fill->size); /* Check if there's a fill value */ if (fill->size > 0) { @@ -2150,7 +2150,7 @@ done: /* (Even on failure, so there's not a mangled layout struct in the list) */ if (retrieved_layout) { if (H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &virtual_layout) < 0) { - HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") + HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout"); if (old_list != virtual_layout.storage.u.virt.list) free_list = TRUE; } /* end if */ @@ -2164,10 +2164,10 @@ done: ent->source_file_name = (char *)H5MM_xfree(ent->source_file_name); ent->source_dset_name = (char *)H5MM_xfree(ent->source_dset_name); if (ent->source_dset.virtual_select && H5S_close(ent->source_dset.virtual_select) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection"); ent->source_dset.virtual_select = NULL; if (ent->source_select && H5S_close(ent->source_select) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection"); ent->source_select = NULL; H5D_virtual_free_parsed_name(ent->parsed_source_file_name); ent->parsed_source_file_name = NULL; @@ -2273,7 +2273,7 @@ done: /* Free space on failure */ if ((ret_value < 0) && space) if (H5S_close(space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection"); FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_vspace() */ @@ -2361,7 +2361,7 @@ done: /* Free space on failure */ if ((ret_value < 0) && space) if (H5S_close(space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection"); FUNC_LEAVE_API(ret_value) } /* end H5Pget_virtual_srcspace() */ @@ -3148,9 +3148,9 @@ done: if (bkg != value) H5MM_xfree(bkg); if (src_id >= 0 && H5I_dec_ref(src_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID"); if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_get_fill_value() */ diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index f3f96b8..acb5cd0 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -28,14 +28,15 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector Functions */ /****************/ /* Local Macros */ @@ -573,15 +574,15 @@ H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) *(*pp)++ = (uint8_t)sizeof(double); /* Encode the left split value */ - H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio) + H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio); btree_split_ratio++; /* Encode the middle split value */ - H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio) + H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio); btree_split_ratio++; /* Encode the right split value */ - H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio) + H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio); } /* end if */ /* Size of B-tree split ratio values */ @@ -623,9 +624,9 @@ H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") /* Decode the left, middle & left B-tree split ratios */ - H5_DECODE_DOUBLE(*pp, btree_split_ratio[0]) - H5_DECODE_DOUBLE(*pp, btree_split_ratio[1]) - H5_DECODE_DOUBLE(*pp, btree_split_ratio[2]) + H5_DECODE_DOUBLE(*pp, btree_split_ratio[0]); + H5_DECODE_DOUBLE(*pp, btree_split_ratio[1]); + H5_DECODE_DOUBLE(*pp, btree_split_ratio[2]); done: FUNC_LEAVE_NOAPI(ret_value) @@ -987,7 +988,7 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) done: if (ret_value < 0) if (data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression"); FUNC_LEAVE_API(ret_value) } /* end H5Pset_data_transform() */ @@ -2251,8 +2252,8 @@ herr_t H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper_t op, const hsize_t start[], const hsize_t stride[], const hsize_t count[], const hsize_t block[]) { - H5P_genplist_t *plist = NULL; /* Property list pointer */ - H5S_t *space; /* Dataspace to hold selection */ + H5P_genplist_t *plist = NULL; /* Property list pointer */ + H5S_t *space = NULL; /* Dataspace to hold selection */ hbool_t space_created = FALSE; /* Whether a new dataspace has been created */ hbool_t reset_prop_on_error = FALSE; /* Whether to reset the property on failure */ herr_t ret_value = SUCCEED; /* return value */ @@ -2342,9 +2343,9 @@ done: /* Cleanup on failure */ if (ret_value < 0) { if (reset_prop_on_error && plist && H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection") + HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection"); if (space_created && H5S_close(space) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace"); } /* end if */ FUNC_LEAVE_API(ret_value) diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index fc6a7b8..653f155 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -166,7 +166,7 @@ H5P__encode_unsigned(const void *value, void **_pp, size_t *size) *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode the value */ - H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)value) + H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)value); } /* end if */ /* Set size needed for encoding */ @@ -264,7 +264,7 @@ H5P__encode_double(const void *value, void **_pp, size_t *size) *(*pp)++ = (uint8_t)sizeof(double); /* Encode the value */ - H5_ENCODE_DOUBLE(*pp, *(const double *)value) + H5_ENCODE_DOUBLE(*pp, *(const double *)value); } /* end if */ /* Set size needed for encoding */ @@ -510,7 +510,7 @@ H5P__decode_unsigned(const void **_pp, void *_value) if (enc_size != sizeof(unsigned)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded") - H5_DECODE_UNSIGNED(*pp, *value) + H5_DECODE_UNSIGNED(*pp, *value); done: FUNC_LEAVE_NOAPI(ret_value) @@ -606,7 +606,7 @@ H5P__decode_double(const void **_pp, void *_value) if (enc_size != sizeof(double)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded") - H5_DECODE_DOUBLE(*pp, *value) + H5_DECODE_DOUBLE(*pp, *value); done: FUNC_LEAVE_NOAPI(ret_value) @@ -722,7 +722,7 @@ done: if (ret_value < 0) { if (plist_id > 0 && H5I_dec_ref(plist_id) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, - "unable to close partially initialized property list") + "unable to close partially initialized property list"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index e6f2b0c..40889a5 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -920,7 +920,7 @@ done: /* Clean up on error */ if (ret_value < 0) { if (driver_id >= 0 && driver_ref_inc && H5I_dec_app_ref(driver_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "unable to unregister VFL driver") + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "unable to unregister VFL driver"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1258,7 +1258,7 @@ H5P_set_driver_by_name(H5P_genplist_t *plist, const char *driver_name, const cha done: if (ret_value < 0) { if (new_driver_id >= 0 && H5I_dec_app_ref(new_driver_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID") + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID"); } FUNC_LEAVE_NOAPI(ret_value) @@ -1346,7 +1346,7 @@ H5P_set_driver_by_value(H5P_genplist_t *plist, H5FD_class_value_t driver_value, done: if (ret_value < 0) { if (new_driver_id >= 0 && H5I_dec_app_ref(new_driver_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID") + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID"); } FUNC_LEAVE_NOAPI(ret_value) @@ -1910,9 +1910,9 @@ H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, size_t H5_ATTR /* Compare drivers */ if (NULL == (cls1 = H5FD_get_class(info1->driver_id))) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (NULL == (cls2 = H5FD_get_class(info2->driver_id))) - HGOTO_DONE(1) + HGOTO_DONE(1); if (cls1->name == NULL && cls2->name != NULL) HGOTO_DONE(-1); if (cls1->name != NULL && cls2->name == NULL) @@ -1922,9 +1922,9 @@ H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, size_t H5_ATTR /* Compare driver infos */ if (cls1->fapl_size < cls2->fapl_size) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (cls1->fapl_size > cls2->fapl_size) - HGOTO_DONE(1) + HGOTO_DONE(1); assert(cls1->fapl_size == cls2->fapl_size); if (info1->driver_info == NULL && info2->driver_info != NULL) HGOTO_DONE(-1); @@ -3677,37 +3677,37 @@ H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, size_t H5_ /* Check for different buffer sizes */ if (info1->size < info2->size) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (info1->size > info2->size) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Check for different callbacks */ /* (Order in memory is fairly meaningless, so just check for equality) */ if (info1->callbacks.image_malloc != info2->callbacks.image_malloc) - HGOTO_DONE(1) + HGOTO_DONE(1); if (info1->callbacks.image_memcpy != info2->callbacks.image_memcpy) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (info1->callbacks.image_realloc != info2->callbacks.image_realloc) - HGOTO_DONE(1) + HGOTO_DONE(1); if (info1->callbacks.image_free != info2->callbacks.image_free) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (info1->callbacks.udata_copy != info2->callbacks.udata_copy) - HGOTO_DONE(1) + HGOTO_DONE(1); if (info1->callbacks.udata_free != info2->callbacks.udata_free) - HGOTO_DONE(-1) + HGOTO_DONE(-1); /* Check for different udata */ /* (Don't know how big it is, so can't check contents) */ if (info1->callbacks.udata < info2->callbacks.udata) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (info1->callbacks.udata > info2->callbacks.udata) - HGOTO_DONE(1) + HGOTO_DONE(1); /* Check buffer contents (instead of buffer pointers) */ if (info1->buffer != NULL && info2->buffer == NULL) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (info1->buffer == NULL && info2->buffer != NULL) - HGOTO_DONE(1) + HGOTO_DONE(1); if (info1->buffer != NULL && info2->buffer != NULL) ret_value = memcmp(info1->buffer, info2->buffer, size); @@ -6210,9 +6210,9 @@ H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED /* Compare connectors */ if (NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->connector_id))) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->connector_id))) - HGOTO_DONE(1) + HGOTO_DONE(1); status = H5VL_cmp_connector_cls(&cmp_value, cls1, cls2); assert(status >= 0); if (cmp_value != 0) diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 5920adf..82a0543 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -681,7 +681,7 @@ H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) /* Encode all the btree */ for (u = 0; u < H5B_NUM_BTREE_ID; u++) { /* Encode the left split value */ - H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)btree_k) + H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)btree_k); btree_k++; } /* end for */ } /* end if */ @@ -726,7 +726,7 @@ H5P__fcrt_btree_rank_dec(const void **_pp, void *_value) /* Decode all the type flags */ for (u = 0; u < H5B_NUM_BTREE_ID; u++) - H5_DECODE_UNSIGNED(*pp, btree_k[u]) + H5_DECODE_UNSIGNED(*pp, btree_k[u]); done: FUNC_LEAVE_NOAPI(ret_value) @@ -950,7 +950,7 @@ H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) /* Encode all the type flags */ for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { /* Encode the left split value */ - H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)type_flags) + H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)type_flags); type_flags++; } /* end for */ } /* end if */ @@ -996,7 +996,7 @@ H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *_value) /* Decode all the type flags */ for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) - H5_DECODE_UNSIGNED(*pp, type_flags[u]) + H5_DECODE_UNSIGNED(*pp, type_flags[u]); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1035,7 +1035,7 @@ H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) /* Encode all the minsize values */ for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { /* Encode the left split value */ - H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)minsizes) + H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)minsizes); minsizes++; } /* end for */ } /* end if */ @@ -1081,7 +1081,7 @@ H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *_value) /* Decode all the minsize values */ for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) - H5_DECODE_UNSIGNED(*pp, minsizes[u]) + H5_DECODE_UNSIGNED(*pp, minsizes[u]); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 8e4ac7b..c126ee3 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -511,11 +511,11 @@ H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size) FUNC_ENTER_PACKAGE_NOERR if (NULL != *pp) { - UINT32ENCODE(*pp, ginfo->lheap_size_hint) - UINT16ENCODE(*pp, ginfo->max_compact) - UINT16ENCODE(*pp, ginfo->min_dense) - UINT16ENCODE(*pp, ginfo->est_num_entries) - UINT16ENCODE(*pp, ginfo->est_name_len) + UINT32ENCODE(*pp, ginfo->lheap_size_hint); + UINT16ENCODE(*pp, ginfo->max_compact); + UINT16ENCODE(*pp, ginfo->min_dense); + UINT16ENCODE(*pp, ginfo->est_num_entries); + UINT16ENCODE(*pp, ginfo->est_name_len); } /* end if */ *size += sizeof(uint16_t) * 4 + sizeof(uint32_t); @@ -548,11 +548,11 @@ H5P__gcrt_group_info_dec(const void **_pp, void *_value) memset(ginfo, 0, sizeof(H5O_ginfo_t)); *ginfo = H5G_def_ginfo_g; - UINT32DECODE(*pp, ginfo->lheap_size_hint) - UINT16DECODE(*pp, ginfo->max_compact) - UINT16DECODE(*pp, ginfo->min_dense) - UINT16DECODE(*pp, ginfo->est_num_entries) - UINT16DECODE(*pp, ginfo->est_name_len) + UINT32DECODE(*pp, ginfo->lheap_size_hint); + UINT16DECODE(*pp, ginfo->max_compact); + UINT16DECODE(*pp, ginfo->min_dense); + UINT16DECODE(*pp, ginfo->est_num_entries); + UINT16DECODE(*pp, ginfo->est_name_len); /* Update fields */ if (ginfo->max_compact != H5G_CRT_GINFO_MAX_COMPACT || ginfo->min_dense != H5G_CRT_GINFO_MIN_DENSE) @@ -599,7 +599,7 @@ H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size) *(*pp)++ = (uint8_t)sizeof(unsigned); /* Encode the value */ - H5_ENCODE_UNSIGNED(*pp, crt_order_flags) + H5_ENCODE_UNSIGNED(*pp, crt_order_flags); } /* end if */ *size += (1 + sizeof(unsigned)); @@ -638,7 +638,7 @@ H5P__gcrt_link_info_dec(const void **_pp, void *_value) memset(linfo, 0, sizeof(H5O_linfo_t)); *linfo = H5G_def_linfo_g; - H5_DECODE_UNSIGNED(*pp, crt_order_flags) + H5_DECODE_UNSIGNED(*pp, crt_order_flags); /* Update fields */ linfo->track_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE); diff --git a/src/H5Pint.c b/src/H5Pint.c index c081405..40d90bc 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -510,12 +510,12 @@ done: if (*lib_class->class_id >= 0) { /* Close the class ID */ if (H5I_dec_ref(*lib_class->class_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class ID") + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class ID"); } else if (lib_class->pclass && *lib_class->pclass) { /* Close a half-initialized pclass */ if (H5P__close_class(*lib_class->pclass) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class") + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class"); } } } @@ -2233,7 +2233,7 @@ H5P__register_real(H5P_genclass_t *pclass, const char *name, size_t size, const done: if (ret_value < 0) if (new_prop && H5P__free_prop(new_prop) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property") + HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property"); FUNC_LEAVE_NOAPI(ret_value) } /* H5P__register_real() */ @@ -2489,7 +2489,7 @@ H5P__register(H5P_genclass_t **ppclass, const char *name, size_t size, const voi done: if (ret_value < 0) if (new_class && H5P__close_class(new_class) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close new property class") + HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close new property class"); FUNC_LEAVE_NOAPI(ret_value) } /* H5P__register() */ @@ -2728,7 +2728,7 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, H5 done: if (ret_value < 0) if (new_prop && H5P__free_prop(new_prop) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property") + HDONE_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close property"); FUNC_LEAVE_NOAPI(ret_value) } /* H5P_insert() */ @@ -3332,7 +3332,7 @@ H5P_exist_plist(const H5P_genplist_t *plist, const char *name) tclass = plist->pclass; while (tclass != NULL) { if (H5SL_search(tclass->props, name) != NULL) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); /* Go up to parent class */ tclass = tclass->parent; @@ -3387,7 +3387,7 @@ H5P__exist_pclass(H5P_genclass_t *pclass, const char *name) tclass = pclass->parent; while (tclass != NULL) { if (H5SL_search(tclass->props, name) != NULL) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); /* Go up to parent class */ tclass = tclass->parent; diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 57b6989..1c573dc 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -28,12 +28,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppkg.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector Functions */ /****************/ /* Local Macros */ @@ -1050,7 +1051,7 @@ H5Pget_elink_fapl(hid_t lapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_fapl() */ /*------------------------------------------------------------------------- diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index fe6d3f0..773ed64 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -29,14 +29,15 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5PLprivate.h" /* Dynamic plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5PLprivate.h" /* Dynamic plugin */ +#include "H5VMprivate.h" /* Vector Functions */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ @@ -1311,10 +1312,10 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) unsigned v; /* Local index variable */ /* encode filter ID */ - INT32ENCODE(*pp, pline->filter[u].id) + INT32ENCODE(*pp, pline->filter[u].id); /* encode filter flags */ - H5_ENCODE_UNSIGNED(*pp, pline->filter[u].flags) + H5_ENCODE_UNSIGNED(*pp, pline->filter[u].flags); /* encode filter name if it exists */ if (NULL != pline->filter[u].name) { @@ -1338,7 +1339,7 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) /* encode all values */ for (v = 0; v < pline->filter[u].cd_nelmts; v++) - H5_ENCODE_UNSIGNED(*pp, pline->filter[u].cd_values[v]) + H5_ENCODE_UNSIGNED(*pp, pline->filter[u].cd_values[v]); } /* end for */ } /* end if */ @@ -1404,10 +1405,10 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) unsigned v; /* Local index variable */ /* decode filter id */ - INT32DECODE(*pp, filter.id) + INT32DECODE(*pp, filter.id); /* decode filter flags */ - H5_DECODE_UNSIGNED(*pp, filter.flags) + H5_DECODE_UNSIGNED(*pp, filter.flags); /* decode value indicating if the name is encoded */ has_name = *(*pp)++; @@ -1434,7 +1435,7 @@ H5P__ocrt_pipeline_dec(const void **_pp, void *_value) /* decode values */ for (v = 0; v < filter.cd_nelmts; v++) - H5_DECODE_UNSIGNED(*pp, filter.cd_values[v]) + H5_DECODE_UNSIGNED(*pp, filter.cd_values[v]); /* Add the filter to the I/O pipeline */ if (H5Z_append(pline, filter.id, filter.flags, filter.cd_nelmts, filter.cd_values) < 0) diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index 74eea60..def9f82 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -203,7 +203,7 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) dt_list = tmp_node; } /* end while */ - FUNC_LEAVE_NOAPI(NULL); + FUNC_LEAVE_NOAPI(NULL) } /* H5P__free_merge_comm_dtype_list */ /*-------------------------------------------------------------------------- @@ -545,7 +545,7 @@ H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, s /* Compare paths */ ret_value = HDstrcmp(dt_list1->path, dt_list2->path); if (ret_value != 0) - HGOTO_DONE(ret_value) + HGOTO_DONE(ret_value); /* Advance to next node */ dt_list1 = dt_list1->next; @@ -554,9 +554,9 @@ H5P__ocpy_merge_comm_dt_list_cmp(const void *_dt_list1, const void *_dt_list2, s /* Check if one list is longer than the other */ if (dt_list1) - HGOTO_DONE(1) + HGOTO_DONE(1); if (dt_list2) - HGOTO_DONE(-1) + HGOTO_DONE(-1); done: FUNC_LEAVE_NOAPI(ret_value) @@ -668,7 +668,7 @@ done: * target file when merging committed datatypes during H5Ocopy * (i.e. when using the H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG flag * as set by H5Pset_copy_object). If the source named - * dataype is not found in the list of paths created by this + * datatype is not found in the list of paths created by this * function, the entire file will be searched. * * Usage: H5Padd_merge_committed_dtype_path(plist_id, path) diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index bebb0ec..2c26d6e 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -9584,10 +9584,10 @@ H5_DLL herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, * committed datatype. * If copied in a single H5Ocopy() operation, objects * that share a committed datatype in the source will - * share an anonymous committed dataype in the + * share an anonymous committed datatype in the * destination copy. Subsequent H5Ocopy() operations, * however, will be unaware of prior anonymous committed - * dataypes and will create new ones. + * datatypes and will create new ones. * * See the “See Also” section immediately below for * functions related to the use of this flag. diff --git a/src/H5R.c b/src/H5R.c index ce54bd2..bc7097e 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -156,7 +156,7 @@ H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_p done: if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file"); FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_object() */ @@ -258,7 +258,7 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, done: if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file"); FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_region() */ @@ -356,7 +356,7 @@ H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl done: if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file"); FUNC_LEAVE_API(ret_value) } /* end H5Rcreate_attr() */ @@ -708,10 +708,10 @@ H5R__open_region_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id, vo done: if ((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) - HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object"); if (H5I_INVALID_HID == ret_value) /* Cleanup on failure */ if ((space_id != H5I_INVALID_HID) && (H5I_dec_ref(space_id) < 0)) - HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close dataspace") + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__open_region_api_common() */ @@ -878,10 +878,10 @@ H5R__open_attr_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id, void done: if ((opened_obj_id != H5I_INVALID_HID) && (H5I_dec_ref(opened_obj_id) < 0)) - HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object") + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close object"); if (H5I_INVALID_HID == ret_value) /* Cleanup on failure */ if (opened_attr && H5VL_attr_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") + HDONE_ERROR(H5E_REFERENCE, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__open_attr_api_common() */ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index b1daf26..c0f3b1e 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -41,6 +41,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Rpkg.h" /* References */ #include "H5Sprivate.h" /* Dataspaces */ @@ -149,7 +150,7 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref done: if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_token_compat() */ @@ -482,7 +483,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t done: if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file"); FUNC_LEAVE_API(ret_value) } /* end H5Rcreate() */ @@ -701,7 +702,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) done: if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file"); FUNC_LEAVE_API(ret_value) } /* end H5Rget_region1() */ diff --git a/src/H5Rint.c b/src/H5Rint.c index ab3b82e..99278a2 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -1341,7 +1341,7 @@ H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, const unsigned ch HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to write reference information") /* Encode the heap information */ - H5_addr_encode(f, &p, hobjid.addr); + H5F_addr_encode(f, &p, hobjid.addr); UINT32ENCODE(p, hobjid.idx); } /* end if */ *nalloc = buf_size; @@ -1381,7 +1381,7 @@ H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned ch HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") /* Get the heap information */ - H5_addr_decode(f, &p, &(hobjid.addr)); + H5F_addr_decode(f, &p, &(hobjid.addr)); if (!H5_addr_defined(hobjid.addr) || hobjid.addr == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") UINT32DECODE(p, hobjid.idx); @@ -1532,7 +1532,7 @@ done: if (ret_value < 0) { if (space && H5S_close(space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace"); } FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5S.c b/src/H5S.c index f2d716c..9954c27 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -298,7 +298,7 @@ H5S_create(H5S_class_t type) done: if (ret_value == NULL) if (new_ds && H5S_close(new_ds) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_create() */ @@ -344,7 +344,7 @@ H5Screate(H5S_class_t type) done: if (ret_value < 0) if (new_ds && H5S_close(new_ds) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); FUNC_LEAVE_API(ret_value) } /* end H5Screate() */ @@ -481,7 +481,7 @@ H5Scopy(hid_t space_id) done: if (ret_value < 0) if (dst && H5S_close(dst) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace"); FUNC_LEAVE_API(ret_value) } /* end H5Scopy() */ @@ -1330,7 +1330,7 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/ done: if (ret_value < 0) if (space && H5S_close(space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace"); FUNC_LEAVE_API(ret_value) } /* end H5Screate_simple() */ @@ -1470,7 +1470,7 @@ H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc) done: /* Release fake file structure */ if (f && H5F_fake_free(f) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release fake file struct") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release fake file struct"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_encode() */ @@ -1585,7 +1585,7 @@ H5S_decode(const unsigned char **p) done: /* Release fake file structure */ if (f && H5F_fake_free(f) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release fake file struct") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release fake file struct"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_decode() */ @@ -1861,11 +1861,11 @@ H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) /* Make certain the dataspaces are the same type */ if (ds1->extent.type != ds2->extent.type) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Make certain the dataspaces are the same rank */ if (ds1->extent.rank != ds2->extent.rank) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Make certain the dataspaces' current dimensions are the same size */ if (ds1->extent.rank > 0) { @@ -1873,7 +1873,7 @@ H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) assert(ds2->extent.size); for (u = 0; u < ds1->extent.rank; u++) if (ds1->extent.size[u] != ds2->extent.size[u]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ /* Make certain the dataspaces' maximum dimensions are the same size */ @@ -1882,11 +1882,11 @@ H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) if (ds1->extent.max != NULL && ds2->extent.max != NULL) { for (u = 0; u < ds1->extent.rank; u++) if (ds1->extent.max[u] != ds2->extent.max[u]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ else if ((ds1->extent.max == NULL && ds2->extent.max != NULL) || (ds1->extent.max != NULL && ds2->extent.max == NULL)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ done: diff --git a/src/H5SL.c b/src/H5SL.c index a65a144..d185d6d 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -218,7 +218,7 @@ * head node if necessary. PREV is the previous node of the height that X is to * grow to. */ #define H5SL_PROMOTE(SLIST, X, PREV, ERR) \ - { \ + do { \ size_t _lvl = X->level; \ \ H5SL_GROW(X, _lvl, ERR); \ @@ -235,7 +235,7 @@ X->forward[_lvl + 1] = PREV->forward[_lvl + 1]; \ } \ PREV->forward[_lvl + 1] = X; \ - } + } while (0) /* Macro used to reduce the level of a node by 1. Does not update the head node * "current level". PREV is the previous node of the current height of X. */ @@ -293,7 +293,7 @@ /* Promote the middle node if necessary */ \ if (_count == 3) { \ assert(X == _last->forward[_i]->forward[_i]); \ - H5SL_PROMOTE(SLIST, X, _last, NULL) \ + H5SL_PROMOTE(SLIST, X, _last, NULL); \ } \ \ /* Prepare to drop down */ \ @@ -398,7 +398,7 @@ /* If there are 2 or more nodes, promote the first */ \ if (_next->forward[_i]->forward[_i] != _llast) { \ X = _next->forward[_i]; \ - H5SL_PROMOTE(SLIST, X, _last, NULL) \ + H5SL_PROMOTE(SLIST, X, _last, NULL); \ } \ else if (!_head->forward[_i + 1]) { \ /* shrink the header */ \ @@ -424,7 +424,7 @@ \ /* If there are 2 or more nodes, promote the last */ \ if (_count >= 2) \ - H5SL_PROMOTE(SLIST, X, _llast, NULL) \ + H5SL_PROMOTE(SLIST, X, _llast, NULL); \ else if (!_head->forward[_i + 1]) { \ /* shrink the header */ \ assert(_i == SLIST->curr_level - 1); \ diff --git a/src/H5SM.c b/src/H5SM.c index 9c01f04..8c34360 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -306,7 +306,7 @@ H5SM__get_index(const H5SM_master_table_t *table, unsigned type_id) */ for (x = 0; x < table->num_indexes; ++x) if (table->indexes[x].mesg_types & type_flag) - HGOTO_DONE((ssize_t)x) + HGOTO_DONE((ssize_t)x); /* At this point, ret_value is either the location of the correct * index or it's still FAIL because we didn't find an index. @@ -351,19 +351,19 @@ H5SM_type_shared(H5F_t *f, unsigned type_id) } /* end if */ else /* No shared messages of any type */ - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Search the indexes until we find one that matches this flag or we've * searched them all. */ for (u = 0; u < table->num_indexes; u++) if (table->indexes[u].mesg_types & type_flag) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); done: /* Release the master SOHM table */ if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_type_shared() */ @@ -410,7 +410,7 @@ H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) done: /* Release the master SOHM table */ if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_fheap_addr() */ @@ -504,9 +504,9 @@ H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__create_index */ @@ -750,7 +750,7 @@ H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, H5SM_list_t * done: /* Release resources */ if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); @@ -846,7 +846,7 @@ H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header) done: /* Release the SOHM list from the cache */ 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") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to unprotect SOHM index"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__convert_btree_to_list() */ @@ -876,13 +876,13 @@ H5SM__can_share_common(const H5F_t *f, unsigned type_id, const void *mesg) /* Check whether this message ought to be shared or not */ /* If sharing is disabled in this file, don't share the message */ if (!H5_addr_defined(H5F_SOHM_ADDR(f))) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Type-specific check */ if ((ret_value = H5O_msg_can_share(type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "can_share callback returned error") if (ret_value == FALSE) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* At this point, the message passes the "trivial" checks and is worth * further checks. @@ -922,7 +922,7 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, un if ((tri_ret = H5SM__can_share_common(f, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'trivial' sharing checks returned error") if (tri_ret == FALSE) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Look up the master SOHM table */ /* (use incoming master SOHM table if possible) */ @@ -944,14 +944,14 @@ H5SM_can_share(H5F_t *f, H5SM_master_table_t *table, ssize_t *sohm_index_num, un */ if ((index_num = H5SM__get_index(my_table, type_id)) < 0) { H5E_clear_stack(NULL); /*ignore error*/ - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ /* If the message isn't big enough, don't bother sharing it */ if (0 == (mesg_size = H5O_msg_raw_size(f, type_id, TRUE, mesg))) HGOTO_ERROR(H5E_SOHM, H5E_BADMESG, FAIL, "unable to get OH message size") if (mesg_size < my_table->indexes[index_num].min_mesg_size) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* At this point, the message will be shared, set the index number if requested. */ if (sohm_index_num) @@ -961,7 +961,7 @@ done: /* Release the master SOHM table, if we protected it */ if (my_table && my_table != table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), my_table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_can_share() */ @@ -1054,11 +1054,11 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, /* "trivial" sharing checks */ if (mesg_flags && (*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if ((tri_ret = H5SM__can_share_common(f, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'trivial' sharing checks returned error") if (tri_ret == FALSE) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Set up user data for callback */ cache_udata.f = f; @@ -1072,7 +1072,7 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, if ((tri_ret = H5SM_can_share(f, table, &index_num, type_id, mesg)) < 0) HGOTO_ERROR(H5E_SOHM, H5E_BADTYPE, FAIL, "'complex' sharing checks returned error") if (tri_ret == FALSE) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* At this point, the message will be shared. */ @@ -1114,7 +1114,7 @@ done: /* Release the master SOHM table */ if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_try_share() */ @@ -1474,14 +1474,14 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t done: /* Release the fractal heap & v2 B-tree if we opened them */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); /* If we got a list out of the cache, release it (it is always dirty after writing a message) */ if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, defer ? H5AC__NO_FLAGS_SET : H5AC__DIRTIED_FLAG) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index"); if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); @@ -1567,7 +1567,7 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) done: /* Release the master SOHM table (should only happen on error) */ if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); /* Release any native message we decoded */ if (native_mesg) @@ -1631,7 +1631,7 @@ H5SM__find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t * if (0 == cmp) { *pos = x; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } } else if (empty_pos && list->messages[x].location == H5SM_NO_LOC) { @@ -1871,13 +1871,13 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c done: /* Release the SOHM list */ 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 close SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index"); /* Release the fractal heap & v2 B-tree if we opened them */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); /* Free the message encoding, if we're not returning it in encoded_mesg * or if there's been an error. @@ -2007,7 +2007,7 @@ done: /* Release the master SOHM table if we took it out of the cache */ if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_get_info() */ @@ -2181,13 +2181,13 @@ H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize done: /* Release resources */ if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, header->index_addr, list, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index"); if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); if (encoding_buf) encoding_buf = H5MM_xfree(encoding_buf); @@ -2367,9 +2367,9 @@ done: /* Close the object header if we opened one and had an error */ if (oh && oh != open_oh) { if (oh && H5O_unprotect(&oloc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release object header"); if (H5O_close(&oloc, NULL) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close object header") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close object header"); } /* end if */ /* Release the encoding buffer on error */ @@ -2510,7 +2510,7 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwi done: if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_table_debug() */ @@ -2609,11 +2609,11 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidt done: if (fh && H5HF_close(fh) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close SOHM heap") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close SOHM heap"); if (list && H5AC_unprotect(f, H5AC_SOHM_LIST, list_addr, list, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index"); if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_list_debug() */ @@ -2703,11 +2703,11 @@ H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info) done: /* Release resources */ if (fheap && H5HF_close(fheap) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close fractal heap"); if (bt2 && H5B2_close(bt2) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index") + HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "can't close v2 B-tree for SOHM index"); if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM_ih_size() */ diff --git a/src/H5SMcache.c b/src/H5SMcache.c index cb95232..77bc03b 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -261,10 +261,10 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l UINT16DECODE(image, table->indexes[u].num_messages); /* Address of the actual index */ - H5_addr_decode(f, &image, &(table->indexes[u].index_addr)); + H5F_addr_decode(f, &image, &(table->indexes[u].index_addr)); /* Address of the index's heap */ - H5_addr_decode(f, &image, &(table->indexes[u].heap_addr)); + H5F_addr_decode(f, &image, &(table->indexes[u].heap_addr)); /* Compute the size of a list index for this SOHM index */ table->indexes[u].list_size = H5SM_LIST_SIZE(f, table->indexes[u].list_max); @@ -284,7 +284,7 @@ H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l done: if (!ret_value && table) if (H5SM__table_free(table) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTFREE, NULL, "unable to destroy sohm table") + HDONE_ERROR(H5E_SOHM, H5E_CANTFREE, NULL, "unable to destroy sohm table"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM__cache_table_deserialize() */ @@ -311,7 +311,6 @@ H5SM__cache_table_image_len(const void *_thing, size_t *image_len) /* Check arguments */ assert(table); - assert(table->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(table->cache_info.type == H5AC_SOHM_TABLE); assert(image_len); @@ -345,7 +344,6 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ assert(f); assert(image); assert(table); - assert(table->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(table->cache_info.type == H5AC_SOHM_TABLE); assert(table->table_size == len); @@ -382,10 +380,10 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ UINT16ENCODE(image, table->indexes[u].num_messages); /* Address of the actual index */ - H5_addr_encode(f, &image, table->indexes[u].index_addr); + H5F_addr_encode(f, &image, table->indexes[u].index_addr); /* Address of the index's heap */ - H5_addr_encode(f, &image, table->indexes[u].heap_addr); + H5F_addr_encode(f, &image, table->indexes[u].heap_addr); } /* end for */ /* Compute checksum on buffer */ @@ -407,10 +405,6 @@ H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_ * * Purpose: Free memory used by the SOHM table. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -426,7 +420,6 @@ H5SM__cache_table_free_icr(void *_thing) /* Check arguments */ assert(table); - assert(table->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(table->cache_info.type == H5AC_SOHM_TABLE); /* Destroy Shared Object Header Message table */ @@ -609,7 +602,6 @@ H5SM__cache_list_image_len(const void *_thing, size_t *image_len) /* Check arguments */ assert(list); - assert(list->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(list->cache_info.type == H5AC_SOHM_LIST); assert(list->header); assert(image_len); @@ -647,7 +639,6 @@ H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_U assert(f); assert(image); assert(list); - assert(list->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); assert(list->cache_info.type == H5AC_SOHM_LIST); assert(list->header); assert(list->header->list_size == len); @@ -694,10 +685,6 @@ done: * * Purpose: Free all memory used by the list. * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). - * * Return: Success: SUCCEED * Failure: FAIL * @@ -713,7 +700,6 @@ H5SM__cache_list_free_icr(void *_thing) /* Check arguments */ assert(list); - assert(list->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); assert(list->cache_info.type == H5AC_SOHM_LIST); /* Destroy Shared Object Header Message list */ diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c index 93b0024..26c8341 100644 --- a/src/H5SMmessage.c +++ b/src/H5SMmessage.c @@ -287,7 +287,7 @@ H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) *raw++ = 0; /* reserved (possible flags byte) */ *raw++ = (uint8_t)message->msg_type_id; UINT16ENCODE(raw, message->u.mesg_loc.index); - H5_addr_encode_len((size_t)ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); + H5F_addr_encode_len((size_t)ctx->sizeof_addr, &raw, message->u.mesg_loc.oh_addr); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) @@ -324,7 +324,7 @@ H5SM__message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) raw++; /* reserved */ message->msg_type_id = *raw++; UINT16DECODE(raw, message->u.mesg_loc.index); - H5_addr_decode_len((size_t)ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); + H5F_addr_decode_len((size_t)ctx->sizeof_addr, &raw, &message->u.mesg_loc.oh_addr); } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5SMtest.c b/src/H5SMtest.c index 3ed479d..6cf97cf 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -101,7 +101,7 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) done: /* Release resources */ if (table && H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") + HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table"); FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5SM__get_mesg_count_test() */ diff --git a/src/H5Sall.c b/src/H5Sall.c index 439b8b7..977a906 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -672,7 +672,7 @@ done: /* Free temporary space if not passed to caller (only happens on error) */ if (!*space && tmp_space) if (H5S_close(tmp_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__all_deserialize() */ @@ -918,7 +918,7 @@ H5S__all_shape_same(H5S_t *space1, H5S_t *space2) */ while (space2_dim >= 0) { if (space1->extent.size[space1_dim] != space2->extent.size[space2_dim]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space1_dim--; space2_dim--; @@ -929,7 +929,7 @@ H5S__all_shape_same(H5S_t *space1, H5S_t *space2) */ while (space1_dim >= 0) { if (space1->extent.size[space1_dim] != 1) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space1_dim--; } /* end while */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 3f161da..11c764c 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -533,7 +533,7 @@ H5S__hyper_get_op_gen(void) { FUNC_ENTER_PACKAGE_NOERR - FUNC_LEAVE_NOAPI(H5S_hyper_op_gen_g++); + FUNC_LEAVE_NOAPI(H5S_hyper_op_gen_g++) } /* end H5S__hyper_op_gen() */ /*------------------------------------------------------------------------- @@ -3008,16 +3008,16 @@ H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_sp if (span_info1 != span_info2) { /* Check for one span being NULL */ if (span_info1 == NULL || span_info2 == NULL) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { /* Compare low & high bounds for this span list */ /* (Could compare lower dimensions also, but not certain if * that's worth it. - QAK, 2019/01/23) */ if (span_info1->low_bounds[0] != span_info2->low_bounds[0]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else if (span_info1->high_bounds[0] != span_info2->high_bounds[0]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { const H5S_hyper_span_t *span1; const H5S_hyper_span_t *span2; @@ -3034,19 +3034,19 @@ H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_sp while (1) { /* Check for both spans being NULL */ if (span1 == NULL && span2 == NULL) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); else { /* Check for one span being NULL */ if (span1 == NULL || span2 == NULL) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { /* Check if the actual low & high span information is the same */ if (span1->low != span2->low || span1->high != span2->high) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { if (span1->down != NULL || span2->down != NULL) { if (!H5S__hyper_cmp_spans(span1->down, span2->down)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { /* Keep going... */ } /* end else */ @@ -3282,7 +3282,7 @@ H5S__hyper_is_valid(const H5S_t *space) /* Check for unlimited selection */ if (space->select.sel_info.hslab->unlim_dim >= 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check which set of low & high bounds we should be using */ if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { @@ -3298,9 +3298,9 @@ H5S__hyper_is_valid(const H5S_t *space) for (u = 0; u < space->extent.rank; u++) { /* Bounds check the selected point + offset against the extent */ if (((hssize_t)low_bounds[u] + space->select.offset[u]) < 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if ((high_bounds[u] + (hsize_t)space->select.offset[u]) >= space->extent.size[u]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end for */ done: @@ -4016,13 +4016,13 @@ H5S__hyper_serialize(H5S_t *space, uint8_t **p) UINT16ENCODE(pp, diminfo[u].start); UINT16ENCODE(pp, diminfo[u].stride); if (diminfo[u].count == H5S_UNLIMITED) - UINT16ENCODE(pp, H5S_UINT16_MAX) + UINT16ENCODE(pp, H5S_UINT16_MAX); else - UINT16ENCODE(pp, diminfo[u].count) + UINT16ENCODE(pp, diminfo[u].count); if (diminfo[u].block == H5S_UNLIMITED) - UINT16ENCODE(pp, H5S_UINT16_MAX) + UINT16ENCODE(pp, H5S_UINT16_MAX); else - UINT16ENCODE(pp, diminfo[u].block) + UINT16ENCODE(pp, diminfo[u].block); } /* end for */ break; @@ -4032,13 +4032,13 @@ H5S__hyper_serialize(H5S_t *space, uint8_t **p) UINT32ENCODE(pp, diminfo[u].start); UINT32ENCODE(pp, diminfo[u].stride); if (diminfo[u].count == H5S_UNLIMITED) - UINT32ENCODE(pp, H5S_UINT32_MAX) + UINT32ENCODE(pp, H5S_UINT32_MAX); else - UINT32ENCODE(pp, diminfo[u].count) + UINT32ENCODE(pp, diminfo[u].count); if (diminfo[u].block == H5S_UNLIMITED) - UINT32ENCODE(pp, H5S_UINT32_MAX) + UINT32ENCODE(pp, H5S_UINT32_MAX); else - UINT32ENCODE(pp, diminfo[u].block) + UINT32ENCODE(pp, diminfo[u].block); } /* end for */ break; @@ -4048,13 +4048,13 @@ H5S__hyper_serialize(H5S_t *space, uint8_t **p) UINT64ENCODE(pp, diminfo[u].start); UINT64ENCODE(pp, diminfo[u].stride); if (diminfo[u].count == H5S_UNLIMITED) - UINT64ENCODE(pp, H5S_UINT64_MAX) + UINT64ENCODE(pp, H5S_UINT64_MAX); else - UINT64ENCODE(pp, diminfo[u].count) + UINT64ENCODE(pp, diminfo[u].count); if (diminfo[u].block == H5S_UNLIMITED) - UINT64ENCODE(pp, H5S_UINT64_MAX) + UINT64ENCODE(pp, H5S_UINT64_MAX); else - UINT64ENCODE(pp, diminfo[u].block) + UINT64ENCODE(pp, diminfo[u].block); } /* end for */ if (version == H5S_HYPER_VERSION_2) len += (4 * space->extent.rank * 8); @@ -4493,7 +4493,7 @@ done: /* Free temporary space if not passed to caller (only happens on error) */ if (!*space && tmp_space) if (H5S_close(tmp_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_deserialize() */ @@ -5056,7 +5056,7 @@ H5S__hyper_unlim_dim(const H5S_t *space) { FUNC_ENTER_PACKAGE_NOERR - FUNC_LEAVE_NOAPI(space->select.sel_info.hslab->unlim_dim); + FUNC_LEAVE_NOAPI(space->select.sel_info.hslab->unlim_dim) } /* end H5S__hyper_unlim_dim() */ /*-------------------------------------------------------------------------- @@ -5330,7 +5330,7 @@ H5S__hyper_is_single(const H5S_t *space) /* Check for a single block */ for (u = 0; u < space->extent.rank; u++) if (space->select.sel_info.hslab->diminfo.opt[u].count > 1) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ else { H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ @@ -5349,7 +5349,7 @@ H5S__hyper_is_single(const H5S_t *space) /* Check that this is the only span and it spans the entire dimension */ if (span->next != NULL) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else /* Walk down to the next span */ spans = span->down; @@ -5449,9 +5449,9 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, * that's worth it. - QAK, 2019/01/23) */ if ((hsize_t)((hssize_t)span_info1->low_bounds[0] + offset[0]) != span_info2->low_bounds[0]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else if ((hsize_t)((hssize_t)span_info1->high_bounds[0] + offset[0]) != span_info2->high_bounds[0]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { const H5S_hyper_span_t *span1; const H5S_hyper_span_t *span2; @@ -5468,23 +5468,23 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, while (1) { /* Check for both spans being NULL */ if (span1 == NULL && span2 == NULL) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); /* Check for one span being NULL */ if (span1 == NULL || span2 == NULL) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check if the actual low & high span information is the same */ if ((hsize_t)((hssize_t)span1->low + offset[0]) != span2->low || (hsize_t)((hssize_t)span1->high + offset[0]) != span2->high) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check for down tree for this span */ if (span1->down != NULL || span2->down != NULL) { /* If the rest of the span trees have a zero offset, use the faster comparison routine */ if (rest_zeros[0]) { if (!H5S__hyper_cmp_spans(span1->down, span2->down)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { /* Keep going... */ } /* end else */ @@ -5492,7 +5492,7 @@ H5S__hyper_spans_shape_same_helper(const H5S_hyper_span_info_t *span_info1, else { if (!H5S__hyper_spans_shape_same_helper(span1->down, span2->down, &offset[1], &rest_zeros[1])) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { /* Keep going... */ } /* end else */ @@ -5678,15 +5678,15 @@ H5S__hyper_shape_same(H5S_t *space1, H5S_t *space2) while (space2_dim >= 0) { if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].stride != space2->select.sel_info.hslab->diminfo.opt[space2_dim].stride) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].count != space2->select.sel_info.hslab->diminfo.opt[space2_dim].count) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != space2->select.sel_info.hslab->diminfo.opt[space2_dim].block) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space1_dim--; space2_dim--; @@ -5694,7 +5694,7 @@ H5S__hyper_shape_same(H5S_t *space1, H5S_t *space2) while (space1_dim >= 0) { if (space1->select.sel_info.hslab->diminfo.opt[space1_dim].block != 1) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space1_dim--; } /* end while */ @@ -5730,11 +5730,11 @@ H5S__hyper_shape_same(H5S_t *space1, H5S_t *space2) /* Check for more spans in this dimension */ if (span->next) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check for span size > 1 element */ if (span->low != span->high) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Walk down to the next dimension */ spans1 = span->down; @@ -5859,7 +5859,7 @@ H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) done: if (ret_value == NULL && down != NULL) if (H5S__hyper_free_span_info(down) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_coord_to_span() */ @@ -6203,7 +6203,7 @@ done: if (ret_value < 0) if (head) if (H5S__hyper_free_span_info(head) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_add_span_element() */ @@ -6253,7 +6253,7 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, unsigned rank, c */ for (u = 0; u < rank; u++) if (start[u] > spans->high_bounds[u] || end[u] < spans->low_bounds[u]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Get the span list for spans in this tree */ curr = spans->head; @@ -6266,12 +6266,12 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, unsigned rank, c curr = curr->next; /* If this span is past the end of the block, then we're done in this dimension */ else if (curr->low > *end) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* block & span overlap */ else { /* If this is the bottom dimension, then the span tree overlaps the block */ if (curr->down == NULL) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); /* Recursively check spans in next dimension down */ else { /* If there is an intersection in the "down" dimensions, @@ -6279,7 +6279,7 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, unsigned rank, c */ if (H5S__hyper_intersect_block_helper(curr->down, rank - 1, start + 1, end + 1, op_info_i, op_gen)) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); /* No intersection in down dimensions, advance to next span */ curr = curr->next; @@ -6356,7 +6356,7 @@ H5S__hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *en * would have been rejected earlier, if they didn't intersect. */ if (single_block) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); else { /* Loop over the dimensions, checking for an intersection */ for (u = 0; u < space->extent.rank; u++) { @@ -6401,7 +6401,7 @@ H5S__hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *en * it doesn't intersect. */ if (adj_end < space->select.sel_info.hslab->diminfo.opt[u].stride) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ } /* end if */ } /* end for */ @@ -6409,7 +6409,7 @@ H5S__hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *en /* If we've looped through all dimensions and none of them didn't * overlap, then all of them do, so we report TRUE. */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end else */ } /* end if */ else { @@ -6777,7 +6777,7 @@ done: if (ret_value < 0 && new_space->select.sel_info.hslab->span_lst) { if (new_space->select.sel_info.hslab->span_lst->head) if (H5S__hyper_free_span(new_space->select.sel_info.hslab->span_lst->head) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span"); new_space->select.sel_info.hslab->span_lst = (H5S_hyper_span_info_t *)H5FL_ARR_FREE(hbounds_t, new_space->select.sel_info.hslab->span_lst); @@ -7337,7 +7337,7 @@ done: if (ret_value < 0) if (new_span) if (H5S__hyper_free_span(new_span) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_append_span() */ @@ -8341,7 +8341,7 @@ done: if (ret_value == NULL) if (merged_spans) if (H5S__hyper_free_span_info(merged_spans) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, NULL, "unable to free span info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__hyper_merge_spans_helper() */ @@ -8976,7 +8976,7 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp if (span->down) /* Go to the next down span and check whether the selection can be rebuilt */ if (!H5S__hyper_rebuild_helper(span->down, &span_slab_info[1])) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Assign the initial starting point & block size for this dimension */ start = span->low; @@ -8996,7 +8996,7 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp /* (Can skip check if previous span's down pointer is same as current one) */ if (span->down && prev_span->down != span->down) if (!H5S__hyper_cmp_spans(span->down, prev_span->down)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Obtain values for stride and block */ curr_stride = span->low - prev_low; @@ -9006,10 +9006,10 @@ H5S__hyper_rebuild_helper(const H5S_hyper_span_info_t *spans, H5S_hyper_dim_t sp * three spans are needed. Account for the first two spans. */ if (curr_block != block) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (spancount > 1) { if (stride != curr_stride) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ else stride = curr_stride; @@ -9518,13 +9518,13 @@ done: /* Free resources */ if (a_not_b) if (H5S__hyper_free_span_info(a_not_b) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); if (a_and_b) if (H5S__hyper_free_span_info(a_and_b) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); if (b_not_a) if (H5S__hyper_free_span_info(b_not_a) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__fill_in_new_space() */ @@ -9612,7 +9612,7 @@ H5S__generate_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], c done: if (new_spans) if (H5S__hyper_free_span_info(new_spans) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__generate_hyperslab() */ @@ -11351,7 +11351,7 @@ done: if (copied_span_info) { assert(ret_value < 0); if (H5S__hyper_free_span_info(copied_span_info) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); copied_span_info = NULL; } @@ -11777,14 +11777,14 @@ done: /* Free ss_span_info_buf */ if (ss_span_info_buf) { if (H5S__hyper_free_span_info(ss_span_info_buf) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); ss_span_info_buf = NULL; } /* Free ds_span_info_buf */ if (ds_span_info_buf) { if (H5S__hyper_free_span_info(ds_span_info_buf) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); ds_span_info_buf = NULL; } @@ -11796,7 +11796,7 @@ done: for (u = 0; u < udata.ds_rank; u++) if (udata.ps_span_info[u]) { if (H5S__hyper_free_span_info(udata.ps_span_info[u]) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to free span info"); udata.ps_span_info[u] = NULL; } } @@ -12277,7 +12277,7 @@ done: /* Free space on error */ if (!ret_value) if (space_out && H5S_close(space_out) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_hyper_get_unlim_block */ diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 29a6502..675e9de 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -429,7 +429,7 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ MPI_Aint temp; temp = disp[u]; - HDmemmove(disp + m + 1, disp + m, (u - m) * sizeof(MPI_Aint)); + memmove(disp + m + 1, disp + m, (u - m) * sizeof(MPI_Aint)); disp[m] = temp; } /* end if */ (*permute)[u] = m; @@ -571,8 +571,8 @@ H5S__mpio_permute_type(H5S_t *space, size_t elmt_size, hsize_t **permute, MPI_Da if ((*permute)[u] != num_points) { MPI_Aint temp = disp[u]; - HDmemmove(disp + (*permute)[u] + 1, disp + (*permute)[u], - (u - (*permute)[u]) * sizeof(MPI_Aint)); + memmove(disp + (*permute)[u] + 1, disp + (*permute)[u], + (u - (*permute)[u]) * sizeof(MPI_Aint)); disp[(*permute)[u]] = temp; } /* end if */ @@ -603,7 +603,7 @@ done: /* Release selection iterator */ if (sel_iter) { if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); } @@ -695,7 +695,7 @@ H5S__mpio_reg_hyper_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, fprintf(H5DEBUG(S), "%s: Flattened selection\n", __func__); #endif for (u = 0; u < rank; ++u) { - H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) + H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t); d[u].start = (hssize_t)diminfo[u].start + sel_iter->u.hyp.sel_off[u]; d[u].strid = diminfo[u].stride; d[u].block = diminfo[u].block; @@ -729,7 +729,7 @@ H5S__mpio_reg_hyper_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, fprintf(H5DEBUG(S), "%s: Non-flattened selection\n", __func__); #endif for (u = 0; u < rank; ++u) { - H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) + H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t); d[u].start = (hssize_t)diminfo[u].start + space->select.offset[u]; d[u].strid = diminfo[u].stride; d[u].block = diminfo[u].block; @@ -960,7 +960,7 @@ done: /* Release selection iterator */ if (sel_iter) { if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); } @@ -1178,7 +1178,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e /* Store displacement & block length */ disp[outercount] = (MPI_Aint)elmt_size * (MPI_Aint)span->low; - H5_CHECK_OVERFLOW(nelmts, hsize_t, int) + H5_CHECK_OVERFLOW(nelmts, hsize_t, int); blocklen[outercount] = (int)nelmts; if (bigio_count < (hsize_t)blocklen[outercount]) @@ -1287,7 +1287,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e nelmts = (span->high - span->low) + 1; /* Build the MPI datatype for this node */ - H5_CHECK_OVERFLOW(nelmts, hsize_t, int) + H5_CHECK_OVERFLOW(nelmts, hsize_t, int); if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)nelmts, 1, stride, down_type, &inner_type[outercount]))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) @@ -1297,7 +1297,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e } /* end while */ /* Building the whole vector datatype */ - H5_CHECK_OVERFLOW(outercount, size_t, int) + H5_CHECK_OVERFLOW(outercount, size_t, int); if (MPI_SUCCESS != (mpi_code = MPI_Type_create_struct((int)outercount, blocklen, disp, inner_type, &spans->op_info[op_info_i].u.down_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) diff --git a/src/H5Snone.c b/src/H5Snone.c index 79cbff8..da084bb 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -628,7 +628,7 @@ done: /* Free temporary space if not passed to caller (only happens on error) */ if (!*space && tmp_space) if (H5S_close(tmp_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_deserialize() */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 217e138..f5b606c 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -957,9 +957,9 @@ H5S__point_is_valid(const H5S_t *space) /* Bounds check the selected point + offset against the extent */ if ((space->select.sel_info.pnt_lst->high_bounds[u] + (hsize_t)space->select.offset[u]) > space->extent.size[u]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] + space->select.offset[u]) < 0) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end for */ done: @@ -1502,7 +1502,7 @@ done: /* Free temporary space if not passed to caller (only happens on error) */ if (!*space && tmp_space) if (H5S_close(tmp_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace"); /* Free the coordinate array if necessary */ if (coord != NULL) @@ -1987,7 +1987,7 @@ H5S__point_shape_same(H5S_t *space1, H5S_t *space2) /* Compare locations in common dimensions, including relative offset */ while (space2_dim >= 0) { if ((hsize_t)((hssize_t)pnt1->pnt[space1_dim] + offset[space1_dim]) != pnt2->pnt[space2_dim]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space1_dim--; space2_dim--; @@ -1997,7 +1997,7 @@ H5S__point_shape_same(H5S_t *space1, H5S_t *space2) while (space1_dim >= 0) { /* Compare the absolute offset in the remaining dimensions */ if ((hssize_t)pnt1->pnt[space1_dim] != offset[space1_dim]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space1_dim--; } /* end while */ @@ -2056,7 +2056,7 @@ H5S__point_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *en /* Check if point was within block for all dimensions */ if (u == space->extent.rank) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); /* Advance to next point */ pnt = pnt->next; diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 1a06414..4bdce64 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -1496,7 +1496,7 @@ done: /* Release selection iterator */ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); @@ -1613,7 +1613,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) /* Check for different number of elements selected */ if (H5S_GET_SELECT_NPOINTS(space1) != H5S_GET_SELECT_NPOINTS(space2)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Check special cases if both dataspaces aren't scalar */ /* (If only one is, the number of selected points check is sufficient) */ @@ -1683,7 +1683,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) /* Verify that the ranges are the same */ if ((high_a[space_a_dim] - low_a[space_a_dim]) != (high_b[space_b_dim] - low_b[space_b_dim])) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Go to next dimension */ space_a_dim--; @@ -1697,7 +1697,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) /* This range should be flat to be the same in a lower dimension */ if (low_a[space_a_dim] != high_a[space_a_dim]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space_a_dim--; } /* end while */ @@ -1708,7 +1708,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) * the same, then the selections are the same, even if the * selection types are different. */ - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ } /* end if */ @@ -1767,7 +1767,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) while (space_b_dim >= 0) { if ((end_a[space_a_dim] - start_a[space_a_dim]) != (end_b[space_b_dim] - start_b[space_b_dim])) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* Set the relative locations of the selections */ offset[space_a_dim] = (hssize_t)start_b[space_b_dim] - (hssize_t)start_a[space_a_dim]; @@ -1781,7 +1781,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) */ while (space_a_dim >= 0) { if (start_a[space_a_dim] != end_a[space_a_dim]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space_a_dim--; } /* end while */ @@ -1796,12 +1796,12 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) /* Check if the blocks are in the same relative location */ if ((hsize_t)((hssize_t)start_a[space_a_dim] + offset[space_a_dim]) != start_b[space_b_dim]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); /* If the block sizes from each selection doesn't match, get out */ if ((end_a[space_a_dim] - start_a[space_a_dim]) != (end_b[space_b_dim] - start_b[space_b_dim])) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space_a_dim--; space_b_dim--; @@ -1811,7 +1811,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) while (space_a_dim >= 0) { /* If the block size isn't 1, get out */ if (start_a[space_a_dim] != end_a[space_a_dim]) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); space_a_dim--; } /* end while */ @@ -1828,7 +1828,7 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) if ((status_a == FALSE) && (status_b == FALSE)) break; else if (status_a != status_b) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); else { /* Advance to next block in selection iterators */ if (H5S_SELECT_ITER_NEXT_BLOCK(iter_a) < 0) @@ -1845,11 +1845,11 @@ H5S_select_shape_same(H5S_t *space1, H5S_t *space2) done: if (iter_a_init && H5S_SELECT_ITER_RELEASE(iter_a) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator a") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator a"); if (iter_a) iter_a = H5FL_FREE(H5S_sel_iter_t, iter_a); if (iter_b_init && H5S_SELECT_ITER_RELEASE(iter_b) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator b") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator b"); if (iter_b) iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b); @@ -1946,7 +1946,7 @@ H5S_select_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *en for (u = 0; u < space->extent.rank; u++) /* If selection bounds & block don't overlap, can leave now */ if (!H5S_RANGE_OVERLAP(low[u], high[u], start[u], end[u])) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end if */ /* Call selection type's intersect routine */ @@ -2262,7 +2262,7 @@ done: /* Cleanup on error */ if (ret_value < 0) if (new_space && H5S_close(new_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_construct_projection() */ @@ -2368,7 +2368,7 @@ done: /* Release selection iterator */ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); @@ -2609,15 +2609,15 @@ done: /* Cleanup on error */ if (ret_value < 0) if (new_space && H5S_close(new_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); /* General cleanup */ if (tmp_src_intersect_space && H5S_close(tmp_src_intersect_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release temporary dataspace"); if (ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release source selection iterator"); if (ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release destination selection iterator"); ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter); ds_iter = H5FL_FREE(H5S_sel_iter_t, ds_iter); @@ -2697,7 +2697,7 @@ H5Sselect_project_intersection(hid_t src_space_id, hid_t dst_space_id, hid_t src done: if (ret_value < 0) if (proj_space && H5S_close(proj_space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace"); FUNC_LEAVE_API(ret_value) } /* end H5Sselect_project_intersection() */ @@ -2996,7 +2996,7 @@ H5S_select_contig_block(H5S_t *space, hbool_t *is_contig, hsize_t *off, size_t * done: if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator"); if (iter) iter = H5FL_FREE(H5S_sel_iter_t, iter); diff --git a/src/H5T.c b/src/H5T.c index 666c159..046331d 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -759,6 +759,7 @@ H5T_init(void) if (H5T__init_native() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface") + /* Initialize all other native types */ if (H5T__init_native_internal() < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize integers") diff --git a/src/H5TS.c b/src/H5TS.c index 2f34480..52cb1ce 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -11,14 +11,14 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: This file contains the framework for ensuring that the global - * library lock is held when an API routine is called. This - * framework works in concert with the FUNC_ENTER_API / FUNC_LEAVE_API - * macros defined in H5private.h. + * Purpose: This file contains the framework for ensuring that the global + * library lock is held when an API routine is called. This + * framework works in concert with the FUNC_ENTER_API / FUNC_LEAVE_API + * macros defined in H5private.h. * * Note: Because this threadsafety framework operates outside the library, - * it does not use the error stack and only uses the "namecheck only" - * FUNC_ENTER_* / FUNC_LEAVE_* macros. + * it does not use the error stack and only uses the "namecheck only" + * FUNC_ENTER_* / FUNC_LEAVE_* macros. */ /****************/ @@ -55,7 +55,7 @@ typedef void *(*H5TS_thread_cb_t)(void *); /* Local Prototypes */ /********************/ static void H5TS__key_destructor(void *key_val); -static herr_t H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, hbool_t *acquired); +static herr_t H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, bool *acquired); static herr_t H5TS__mutex_unlock(H5TS_mutex_t *mutex, unsigned int *lock_count); /*********************/ @@ -148,10 +148,6 @@ static H5TS_key_t H5TS_tid_key; * Frees the memory for a key. Called by each thread as it exits. * Currently all the thread-specific information for all keys are simple * structures allocated with malloc, so we can free them all uniformly. - * - * PROGRAMMER: Quincey Koziol - * February 7, 2003 - * *-------------------------------------------------------------------------- */ static void @@ -159,7 +155,7 @@ H5TS__key_destructor(void *key_val) { FUNC_ENTER_PACKAGE_NAMECHECK_ONLY - /* Use free here instead of H5MM_xfree(), to avoid calling the H5CS routines */ + /* Use free() here instead of H5MM_xfree(), to avoid calling the H5CS routines */ if (key_val != NULL) free(key_val); @@ -310,8 +306,8 @@ H5TS_thread_id(void) void H5TS_pthread_first_thread_init(void) { - H5_g.H5_libinit_g = FALSE; /* Library hasn't been initialized */ - H5_g.H5_libterm_g = FALSE; /* Library isn't being shutdown */ + H5_g.H5_libinit_g = false; /* Library hasn't been initialized */ + H5_g.H5_libterm_g = false; /* Library isn't being shutdown */ FUNC_ENTER_NOAPI_NAMECHECK_ONLY @@ -361,14 +357,10 @@ H5TS_pthread_first_thread_init(void) * Note: The Windows threads code is very likely bogus. * * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * Februrary 27, 2019 - * *-------------------------------------------------------------------------- */ static herr_t -H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, hbool_t *acquired) +H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, bool *acquired) { herr_t ret_value = SUCCEED; @@ -376,7 +368,7 @@ H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, hbool_t *acqui #ifdef H5_HAVE_WIN_THREADS EnterCriticalSection(&mutex->CriticalSection); - *acquired = TRUE; + *acquired = true; #else /* H5_HAVE_WIN_THREADS */ /* Attempt to acquire the mutex lock */ if (0 == pthread_mutex_lock(&mutex->atomic_lock)) { @@ -388,21 +380,21 @@ H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, hbool_t *acqui if (pthread_equal(my_thread_id, mutex->owner_thread)) { /* Already owned by self - increment count */ mutex->lock_count += lock_count; - *acquired = TRUE; - } /* end if */ + *acquired = true; + } else - *acquired = FALSE; - } /* end if */ + *acquired = false; + } else { /* Take ownership of the mutex */ mutex->owner_thread = my_thread_id; mutex->lock_count = lock_count; - *acquired = TRUE; - } /* end else */ + *acquired = true; + } if (0 != pthread_mutex_unlock(&mutex->atomic_lock)) ret_value = -1; - } /* end if */ + } else ret_value = -1; #endif /* H5_HAVE_WIN_THREADS */ @@ -419,14 +411,10 @@ H5TS__mutex_acquire(H5TS_mutex_t *mutex, unsigned int lock_count, hbool_t *acqui * global lock was acquired. * * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * Februrary 27, 2019 - * *-------------------------------------------------------------------------- */ herr_t -H5TSmutex_acquire(unsigned int lock_count, hbool_t *acquired){ +H5TSmutex_acquire(unsigned int lock_count, bool *acquired){ FUNC_ENTER_API_NAMECHECK_ONLY FUNC_LEAVE_API_NAMECHECK_ONLY(H5TS__mutex_acquire(&H5_g.init_lock, lock_count, acquired))} @@ -487,7 +475,7 @@ herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex) /* After we've received the signal, take ownership of the mutex */ mutex->owner_thread = pthread_self(); mutex->lock_count = 1; - } /* end else */ + } /* Release the library lock */ ret_value = pthread_mutex_unlock(&mutex->atomic_lock); @@ -545,7 +533,7 @@ H5TS__mutex_unlock(H5TS_mutex_t *mutex, unsigned int *lock_count) err = pthread_cond_signal(&mutex->cond_var); if (err != 0) ret_value = err; - } /* end if */ + } done: #endif /* H5_HAVE_WIN_THREADS */ @@ -600,7 +588,7 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) err = pthread_cond_signal(&mutex->cond_var); if (err != 0) ret_value = err; - } /* end if */ + } done: #endif /* H5_HAVE_WIN_THREADS */ @@ -613,10 +601,6 @@ done: * Purpose: Get the current count of the global lock attempt * * Return: Non-negative on success / Negative on failure - * - * Programmer: Houjun Tang - * June 24, 2019 - * *-------------------------------------------------------------------------- */ herr_t @@ -650,10 +634,6 @@ done: * Purpose: Releases the HDF5 library global lock * * Return: Non-negative on success / Negative on failure - * - * Programmer: Quincey Koziol - * Februrary 27, 2019 - * *-------------------------------------------------------------------------- */ herr_t @@ -728,8 +708,8 @@ H5TS_cancel_count_inc(void) if (ret_value) { free(cancel_counter); HGOTO_DONE(FAIL); - } /* end if */ - } /* end if */ + } + } /* Check if thread entering library */ if (cancel_counter->cancel_count == 0) diff --git a/src/H5TSdevelop.h b/src/H5TSdevelop.h index 1f68d87..c3e1a6a 100644 --- a/src/H5TSdevelop.h +++ b/src/H5TSdevelop.h @@ -39,7 +39,7 @@ extern "C" { #endif /* HDF5 global library lock routines */ -H5_DLL herr_t H5TSmutex_acquire(unsigned int lock_count, hbool_t *acquired); +H5_DLL herr_t H5TSmutex_acquire(unsigned int lock_count, bool *acquired); H5_DLL herr_t H5TSmutex_release(unsigned int *lock_count); H5_DLL herr_t H5TSmutex_get_attempt_count(unsigned int *count); diff --git a/src/H5Tarray.c b/src/H5Tarray.c index 8b01227..be3d98e 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -110,7 +110,7 @@ H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */]) done: if (ret_value < 0) if (dt && H5T_close_real(dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype"); FUNC_LEAVE_API(ret_value) } /* end H5Tarray_create2() */ @@ -342,7 +342,7 @@ H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], done: if (ret_value < 0) if (dt && H5T_close_real(dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, H5I_INVALID_HID, "can't release datatype"); FUNC_LEAVE_API(ret_value) } /* end H5Tarray_create1() */ diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 032ecb8..18e0234 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -216,7 +216,7 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) done: /* Release resources */ if (wb && H5WB_unwrap(wb) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_shift() */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 2a612f8..160e45f 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -274,22 +274,22 @@ done: if (dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { /* Remove the datatype from the list of opened objects in the file */ if (H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object"); if (H5FO_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, - "can't remove dataset from list of open objects") + "can't remove dataset from list of open objects"); /* Close the datatype object */ if (H5O_close(&(dt->oloc), NULL) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header"); /* Remove the datatype's object header from the file */ if (H5O_delete(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header"); /* Mark datatype as being back in memory */ if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to return datatype to memory") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to return datatype to memory"); dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; dt->shared->state = old_state; } /* end if */ @@ -520,11 +520,11 @@ done: (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) { if (H5O_dec_rc_by_loc(&(type->oloc)) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, - "unable to decrement refcount on newly created object") + "unable to decrement refcount on newly created object"); if (H5O_close(&(type->oloc), NULL) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header"); if (H5O_delete(file, type->sh_loc.u.loc.oh_addr) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header"); type->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; } /* end if */ } /* end if */ @@ -637,7 +637,7 @@ done: /* Cleanup on error */ if (H5I_INVALID_HID == ret_value) if (dt && H5VL_datatype_close(*vol_obj_ptr, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__open_api_common() */ @@ -924,7 +924,7 @@ done: if (ret_value < 0) if (new_tcpl_id > 0) if (H5I_dec_app_ref(new_tcpl_id) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, H5I_INVALID_HID, "unable to close temporary object") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, H5I_INVALID_HID, "unable to close temporary object"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__get_create_plist() */ @@ -986,7 +986,7 @@ done: if (NULL == ret_value) if (obj_found && H5_addr_defined(type_loc.oloc->addr)) if (H5G_loc_free(&type_loc) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__open_name() */ @@ -1091,7 +1091,7 @@ done: if (dt) { if (shared_fo == NULL) { /* Need to free shared file object */ if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object"); dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); } /* end if */ diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index be0a111..b1652c4 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -207,7 +207,7 @@ H5Tget_member_type(hid_t type_id, unsigned membno) done: if (ret_value < 0) if (memb_dt && H5T_close(memb_dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close datatype"); FUNC_LEAVE_API(ret_value) } /* end H5Tget_member_type() */ @@ -496,7 +496,7 @@ H5T__pack(const H5T_t *dt) if (H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) { /* If datatype has been packed, skip packing it and indicate success */ if (TRUE == H5T__is_packed(dt)) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Check for packing unmodifiable datatype */ if (H5T_STATE_TRANSIENT != dt->shared->state) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index e684c2d..547147c 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1000,7 +1000,7 @@ done: /* Print alignment statistics */ #define CI_PRINT_STATS(STYPE, DTYPE) \ - { \ + do { \ if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->s_aligned) { \ fprintf(H5DEBUG(T), " %zu src elements aligned on %zu-byte boundaries\n", \ ((H5T_conv_hw_t *)cdata->priv)->s_aligned, H5T_NATIVE_##STYPE##_ALIGN_g); \ @@ -1009,7 +1009,7 @@ done: fprintf(H5DEBUG(T), " %zu dst elements aligned on %zu-byte boundaries\n", \ ((H5T_conv_hw_t *)cdata->priv)->d_aligned, H5T_NATIVE_##DTYPE##_ALIGN_g); \ } \ - } + } while (0) /* Allocate private alignment structure for atomic types */ #define CI_ALLOC_PRIV \ @@ -1041,12 +1041,12 @@ done: /* Swap two elements (I & J) of an array using a temporary variable */ #define H5_SWAP_BYTES(ARRAY, I, J) \ - { \ + do { \ uint8_t _tmp; \ _tmp = ARRAY[I]; \ ARRAY[I] = ARRAY[J]; \ ARRAY[J] = _tmp; \ - } + } while (0) /* Minimum size of variable-length conversion buffer */ #define H5T_VLEN_MIN_CONF_BUF_SIZE 4096 @@ -2124,7 +2124,6 @@ H5T__conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) else /* If the numbers of source and dest members are equal and no conversion is needed, * the case should have been handled as noop earlier in H5Dio.c. */ { - ; } cdata->recalc = FALSE; @@ -2307,11 +2306,11 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, xbuf + src_memb->offset, xbkg + dst_memb->offset) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") - HDmemmove(xbuf + offset, xbuf + src_memb->offset, dst_memb->size); + memmove(xbuf + offset, xbuf + src_memb->offset, dst_memb->size); offset += dst_memb->size; } /* end if */ else { - HDmemmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); + memmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); offset += src_memb->size; } /* end else */ } /* end for */ @@ -2341,7 +2340,7 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* end if */ else offset -= dst_memb->size; - HDmemmove(xbkg + dst_memb->offset, xbuf + offset, dst_memb->size); + memmove(xbkg + dst_memb->offset, xbuf + offset, dst_memb->size); } /* end for */ assert(0 == offset); @@ -2361,7 +2360,7 @@ H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * buffer. */ for (xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { - HDmemmove(xbuf, xbkg, dst->shared->size); + memmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride ? buf_stride : dst->shared->size; xbkg += bkg_delta; } /* end for */ @@ -2552,7 +2551,7 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelm copy_size = priv->subset_info.copy_size; for (elmtno = 0; elmtno < nelmts; elmtno++) { - HDmemmove(xbkg, xbuf, copy_size); + memmove(xbkg, xbuf, copy_size); /* Update pointers */ xbuf += buf_stride; @@ -2582,14 +2581,14 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelm HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") for (elmtno = 0; elmtno < nelmts; elmtno++) { - HDmemmove(xbkg, xbuf, dst_memb->size); + memmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ } /* end if */ else { for (xbuf = buf, elmtno = 0; elmtno < nelmts; elmtno++) { - HDmemmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); + memmove(xbuf + offset, xbuf + src_memb->offset, src_memb->size); xbuf += buf_stride; } /* end for */ offset += src_memb->size; @@ -2619,7 +2618,7 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelm HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound datatype member") for (elmtno = 0; elmtno < nelmts; elmtno++) { - HDmemmove(xbkg, xbuf, dst_memb->size); + memmove(xbkg, xbuf, dst_memb->size); xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ @@ -2632,7 +2631,7 @@ H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelm /* Move background buffer into result buffer */ for (xbuf = buf, xbkg = bkg, elmtno = 0; elmtno < nelmts; elmtno++) { - HDmemmove(xbuf, xbkg, dst->shared->size); + memmove(xbuf, xbkg, dst->shared->size); xbuf += buf_stride; xbkg += bkg_stride; } /* end for */ @@ -3562,7 +3561,7 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, s /* Perform the actual conversion */ for (elmtno = 0; elmtno < nelmts; elmtno++) { /* Copy the source array into the correct location for the destination */ - HDmemmove(dp, sp, src->shared->size); + memmove(dp, sp, src->shared->size); /* Convert array */ if (H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, (size_t)0, bkg_stride, diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index b8d7d70..99e1e13 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -186,7 +186,7 @@ done: /* Cleanup on error */ if (H5I_INVALID_HID == ret_value) if (dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to close datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to close datatype"); FUNC_LEAVE_API(ret_value) } /* end H5Topen1() */ diff --git a/src/H5Tenum.c b/src/H5Tenum.c index fa083a6..3a1e51a 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -505,7 +505,7 @@ H5T__enum_valueof(const H5T_t *dt, const char *name, void *value /*out*/) done: if (copied_dt) if (H5T_close_real(copied_dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close data type") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close data type"); FUNC_LEAVE_NOAPI(ret_value) } diff --git a/src/H5Tfields.c b/src/H5Tfields.c index fdeaac0..de8b517 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -216,12 +216,12 @@ H5Tget_member_index(hid_t type_id, const char *name) case H5T_COMPOUND: for (i = 0; i < dt->shared->u.compnd.nmembs; i++) if (!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) - HGOTO_DONE((int)i) + HGOTO_DONE((int)i); break; case H5T_ENUM: for (i = 0; i < dt->shared->u.enumer.nmembs; i++) if (!HDstrcmp(dt->shared->u.enumer.name[i], name)) - HGOTO_DONE((int)i) + HGOTO_DONE((int)i); break; case H5T_NO_CLASS: diff --git a/src/H5Tnative.c b/src/H5Tnative.c index 7f792cc..bac956c 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -93,7 +93,7 @@ done: /* Error cleanup */ if (ret_value < 0) if (new_dt && H5T_close_real(new_dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype"); FUNC_LEAVE_API(ret_value) } /* end H5Tget_native_type() */ @@ -493,13 +493,13 @@ done: if (NULL == ret_value) { if (new_type) if (H5T_close_real(new_type) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype"); /* Free lists for members */ if (memb_list) { for (u = 0; u < nmemb; u++) if (memb_list[u] && H5T_close_real(memb_list[u]) < 0) - HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype") + HDONE_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot close datatype"); memb_list = (H5T_t **)H5MM_xfree(memb_list); } /* end if */ diff --git a/src/H5Toh.c b/src/H5Toh.c index be3fbad..42a2633 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -130,7 +130,7 @@ H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) done: if (NULL == ret_value) if (type && H5T_close(type) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_open() */ diff --git a/src/H5Tref.c b/src/H5Tref.c index 8313cfb..893a2b2 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -19,13 +19,14 @@ #define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5R_FRIEND /*suppress error about including H5Rpkg */ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Fpkg.h" /* File */ -#include "H5Rpkg.h" /* References */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Fpkg.h" /* File */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Rpkg.h" /* References */ +#include "H5Tpkg.h" /* Datatypes */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -169,7 +170,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Only change the location if it's different */ if (loc == dt->shared->u.atomic.u.r.loc && file == dt->shared->u.atomic.u.r.file) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); switch (loc) { case H5T_LOC_MEMORY: /* Memory based reference datatype */ @@ -740,7 +741,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size done: if ((file_id != H5I_INVALID_HID) && (H5I_dec_ref(file_id) < 0)) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id") + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on location id"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__ref_mem_write() */ @@ -1063,7 +1064,7 @@ H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbo HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Get the object address */ - H5_addr_decode(src_f, &p, &addr); + H5F_addr_decode(src_f, &p, &addr); /* Check if heap address is 'nil' */ *isnull = (addr == 0) ? TRUE : FALSE; @@ -1215,7 +1216,7 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Get the heap address */ - H5_addr_decode(src_f, &p, &addr); + H5F_addr_decode(src_f, &p, &addr); /* Check if heap address is 'nil' */ *isnull = (addr == 0) ? TRUE : FALSE; diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 121f6b0..826af92 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -216,7 +216,7 @@ H5T__vlen_create(const H5T_t *base) done: if (!ret_value) if (dt && H5T_close_real(dt) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release datatype info") + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release datatype info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_create() */ diff --git a/src/H5VL.c b/src/H5VL.c index 1838203..fd2f046 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -741,9 +741,9 @@ done: /* Cleanup on error */ if (ret_value < 0) { if (file_vol_obj && H5VL_free_object(file_vol_obj) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to free VOL object") + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to free VOL object"); if (file_type_id >= 0 && H5I_dec_ref(file_type_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to close file datatype") + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to close file datatype"); } /* end if */ FUNC_LEAVE_API(ret_value) diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index fa82414..95df78b 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -368,7 +368,7 @@ H5VL__common_optional_op(hid_t id, H5I_type_t id_type, H5VL_reg_opt_oper_t reg_o done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__common_optional_op() */ @@ -1036,7 +1036,7 @@ H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_para done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_create() */ @@ -1140,7 +1140,7 @@ H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_open() */ @@ -1238,7 +1238,7 @@ H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, void *buf, hid_t done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_read() */ @@ -1336,7 +1336,7 @@ H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, const void *buf done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_write() */ @@ -1434,7 +1434,7 @@ H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_args_t *args, hid_t dx done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_get() */ @@ -1538,7 +1538,7 @@ H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_specific() */ @@ -1639,7 +1639,7 @@ H5VL_attr_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_optional() */ @@ -1878,7 +1878,7 @@ H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_p done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_create() */ @@ -1982,7 +1982,7 @@ H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_par done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_open() */ @@ -2094,7 +2094,7 @@ H5VL_dataset_read_direct(size_t count, void *obj[], H5VL_t *connector, hid_t mem done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_read_direct() */ @@ -2154,7 +2154,7 @@ H5VL_dataset_read(size_t count, const H5VL_object_t *vol_obj[], hid_t mem_type_i done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); /* Free memory */ if (obj != &obj_local) @@ -2284,7 +2284,7 @@ H5VL_dataset_write_direct(size_t count, void *obj[], H5VL_t *connector, hid_t me done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_write_direct() */ @@ -2344,7 +2344,7 @@ H5VL_dataset_write(size_t count, const H5VL_object_t *vol_obj[], hid_t mem_type_ done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); /* Free memory */ if (obj != &obj_local) @@ -2460,7 +2460,7 @@ H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_args_t *args, hi done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_get() */ @@ -2560,7 +2560,7 @@ H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_args_t done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_specific() */ @@ -2659,7 +2659,7 @@ H5VL_dataset_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_optional() */ @@ -2810,7 +2810,7 @@ H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_close() */ @@ -2912,7 +2912,7 @@ H5VL_datatype_commit(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_ done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_commit() */ @@ -3016,7 +3016,7 @@ H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_open() */ @@ -3115,7 +3115,7 @@ H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_args_t *args, done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_get() */ @@ -3215,7 +3215,7 @@ H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_args done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_specific() */ @@ -3314,7 +3314,7 @@ H5VL_datatype_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_optional() */ @@ -3358,7 +3358,7 @@ H5VL_datatype_optional_op(H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hi done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_optional_op() */ @@ -3503,7 +3503,7 @@ H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_close() */ @@ -3752,7 +3752,7 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in { status = H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL); } - H5E_END_TRY; + H5E_END_TRY if (status < 0) { ssize_t new_num_errors = 0; @@ -3785,9 +3785,9 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in done: if (ret_value != H5_ITER_STOP) { if (fapl_id >= 0 && H5I_dec_app_ref(fapl_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close fapl") + HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close fapl"); if (connector_id >= 0 && H5I_dec_app_ref(connector_id) < 0) - HDONE_ERROR(H5E_ID, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close VOL connector ID") + HDONE_ERROR(H5E_ID, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close VOL connector ID"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -3968,7 +3968,7 @@ H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_args_t *args, hid_t dx done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_get() */ @@ -4100,7 +4100,7 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_specific() */ @@ -4198,7 +4198,7 @@ H5VL_file_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_optional() */ @@ -4343,7 +4343,7 @@ H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_close() */ @@ -4444,7 +4444,7 @@ H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_par done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_create() */ @@ -4547,7 +4547,7 @@ H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_param done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_open() */ @@ -4645,7 +4645,7 @@ H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_args_t *args, hid_t done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_get() */ @@ -4743,7 +4743,7 @@ H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_args_t *ar done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_specific() */ @@ -4844,7 +4844,7 @@ H5VL_group_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hi done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_optional() */ @@ -4990,7 +4990,7 @@ H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_close() */ @@ -5102,7 +5102,7 @@ H5VL_link_create(H5VL_link_create_args_t *args, const H5VL_object_t *vol_obj, done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_create() */ @@ -5207,7 +5207,7 @@ H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_pa done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_copy() */ @@ -5314,7 +5314,7 @@ H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_pa done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_move() */ @@ -5416,7 +5416,7 @@ H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_get() */ @@ -5519,7 +5519,7 @@ H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_specific() */ @@ -5620,7 +5620,7 @@ H5VL_link_optional(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_pa done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_link_optional() */ @@ -5715,7 +5715,7 @@ H5VLlink_optional_op(const char *app_file, const char *app_func, unsigned app_li done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_API(ret_value) } /* end H5VLlink_optional_op() */ @@ -5782,7 +5782,7 @@ H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_open() */ @@ -5891,7 +5891,7 @@ H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_ done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_copy() */ @@ -5994,7 +5994,7 @@ H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_param done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_get() */ @@ -6097,7 +6097,7 @@ H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_ done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_specific() */ @@ -6198,7 +6198,7 @@ H5VL_object_optional(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_ done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_optional() */ @@ -6294,7 +6294,7 @@ H5VLobject_optional_op(const char *app_file, const char *app_func, unsigned app_ done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_API(ret_value) } /* end H5VLobject_optional_op() */ @@ -6368,7 +6368,7 @@ H5VL_introspect_get_conn_cls(const H5VL_object_t *vol_obj, H5VL_get_conn_lvl_t l done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_introspect_get_conn_cls() */ @@ -6544,7 +6544,7 @@ H5VL_introspect_opt_query(const H5VL_object_t *vol_obj, H5VL_subclass_t subcls, done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_introspect_opt_query() */ @@ -6649,7 +6649,7 @@ H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5VL_request_s done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_wait() */ @@ -6753,7 +6753,7 @@ H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_notify() */ @@ -6856,7 +6856,7 @@ H5VL_request_cancel(const H5VL_object_t *vol_obj, H5VL_request_status_t *status) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_cancel() */ @@ -6960,7 +6960,7 @@ H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_args_t done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_specific() */ @@ -7065,7 +7065,7 @@ H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_optional() */ @@ -7205,7 +7205,7 @@ H5VL_request_free(const H5VL_object_t *vol_obj) done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_request_free() */ @@ -8016,7 +8016,7 @@ H5VL_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dx done: /* Reset object wrapping info in API context */ if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_optional() */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 412791b..dabbc0a 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -459,11 +459,11 @@ done: if (ret_value < 0) { if (vol_info) if (H5VL_free_connector_info(connector_id, vol_info) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free VOL connector info") + HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free VOL connector info"); if (connector_id >= 0) /* The H5VL_class_t struct will be freed by this function */ if (H5I_dec_ref(connector_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector") + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector"); } /* end if */ /* Clean up */ @@ -568,7 +568,7 @@ done: /* Cleanup on error */ if (NULL == ret_value) { if (conn_rc_incr && H5VL_conn_dec_rc(vol_connector) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector"); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -782,7 +782,7 @@ done: if (NULL == ret_value) { /* Decrement VOL connector ID ref count on error */ if (conn_id_incr && H5I_dec_ref(connector_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector"); /* Free VOL connector struct */ if (NULL != connector) @@ -916,7 +916,7 @@ done: if (!ret_value) { /* Decrement VOL connector ID ref count on error */ if (conn_id_incr && H5I_dec_ref(connector_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector") + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector"); /* Free VOL connector struct */ if (NULL != connector) @@ -1004,7 +1004,7 @@ done: hsize_t H5VL_object_inc_rc(H5VL_object_t *vol_obj) { - FUNC_ENTER_NOAPI_NOERR_NOFS + FUNC_ENTER_NOAPI_NOERR /* Check arguments */ assert(vol_obj); @@ -1953,45 +1953,45 @@ H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_clas /* Compare connector "values" */ if (cls1->value < cls2->value) { *cmp_value = -1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ if (cls1->value > cls2->value) { *cmp_value = 1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ assert(cls1->value == cls2->value); /* Compare connector names */ if (cls1->name == NULL && cls2->name != NULL) { *cmp_value = -1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ if (cls1->name != NULL && cls2->name == NULL) { *cmp_value = 1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ if (0 != (*cmp_value = HDstrcmp(cls1->name, cls2->name))) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Compare connector VOL API versions */ if (cls1->version < cls2->version) { *cmp_value = -1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ if (cls1->version > cls2->version) { *cmp_value = 1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ assert(cls1->version == cls2->version); /* Compare connector info */ if (cls1->info_cls.size < cls2->info_cls.size) { *cmp_value = -1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ if (cls1->info_cls.size > cls2->info_cls.size) { *cmp_value = 1; - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); } /* end if */ assert(cls1->info_cls.size == cls2->info_cls.size); diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 20e00f8..d6a8666 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -445,7 +445,7 @@ H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t addr, H5O_toke /* Encode token */ p = (uint8_t *)token; - H5_addr_encode_len(addr_len, &p, addr); + H5F_addr_encode_len(addr_len, &p, addr); done: FUNC_LEAVE_NOAPI(ret_value) @@ -536,7 +536,7 @@ H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, had /* Decode token */ p = (const uint8_t *)&token; - H5_addr_decode_len(addr_len, &p, addr); + H5F_addr_decode_len(addr_len, &p, addr); done: FUNC_LEAVE_NOAPI(ret_value) @@ -557,7 +557,7 @@ H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file) H5O_loc_t *oloc = NULL; /* Object location for ID */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL); + FUNC_ENTER_NOAPI(FAIL) *file = NULL; diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c index 4c27f51..3bd2b38 100644 --- a/src/H5VLnative_attr.c +++ b/src/H5VLnative_attr.c @@ -123,7 +123,7 @@ H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const c done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_attr_create() */ diff --git a/src/H5VLnative_blob.c b/src/H5VLnative_blob.c index fbc11be..6793bcb 100644 --- a/src/H5VLnative_blob.c +++ b/src/H5VLnative_blob.c @@ -76,7 +76,7 @@ H5VL__native_blob_put(void *obj, const void *buf, size_t size, void *blob_id, vo HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write blob information") /* Encode the heap information */ - H5_addr_encode(f, &id, hobjid.addr); + H5F_addr_encode(f, &id, hobjid.addr); UINT32ENCODE(id, hobjid.idx); done: @@ -109,7 +109,7 @@ H5VL__native_blob_get(void *obj, const void *blob_id, void *buf, size_t size, vo assert(buf); /* Get the heap information */ - H5_addr_decode(f, &id, &hobjid.addr); + H5F_addr_decode(f, &id, &hobjid.addr); UINT32DECODE(id, hobjid.idx); /* Check if this sequence actually has any data */ @@ -153,7 +153,7 @@ H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_args_t * haddr_t addr; /* Sequence's heap address */ /* Get the heap address */ - H5_addr_decode(f, &id, &addr); + H5F_addr_decode(f, &id, &addr); /* Check if heap address is 'nil' */ *args->args.is_null.isnull = (addr == 0 ? TRUE : FALSE); @@ -165,7 +165,7 @@ H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_args_t * uint8_t *id = (uint8_t *)blob_id; /* Pointer to the blob ID */ /* Encode the 'nil' heap pointer information */ - H5_addr_encode(f, &id, (haddr_t)0); + H5F_addr_encode(f, &id, (haddr_t)0); UINT32ENCODE(id, 0); break; @@ -176,7 +176,7 @@ H5VL__native_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_args_t * H5HG_t hobjid; /* VL sequence's heap ID */ /* Get heap information */ - H5_addr_decode(f, &id, &hobjid.addr); + H5F_addr_decode(f, &id, &hobjid.addr); UINT32DECODE(id, hobjid.idx); /* Free heap object */ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index a4e7d77..f6b9af6 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -31,6 +31,7 @@ #include "H5Fprivate.h" /* Files */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspaces */ #include "H5VLprivate.h" /* Virtual Object Layer */ @@ -214,13 +215,13 @@ H5VL__native_dataset_io_cleanup(size_t count, hid_t mem_space_id[], hid_t file_s if (H5S_BLOCK == mem_space_id[i] && dinfo[i].mem_space) if (H5S_close(dinfo[i].mem_space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, - "unable to release temporary memory dataspace for H5S_BLOCK") + "unable to release temporary memory dataspace for H5S_BLOCK"); /* Reset file dataspace selection if it was copied from the property list */ if (H5S_PLIST == file_space_id[i] && dinfo[i].file_space) if (H5S_select_all(dinfo[i].file_space, TRUE) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, - "unable to release file dataspace selection for H5S_PLIST") + "unable to release file dataspace selection for H5S_PLIST"); } FUNC_LEAVE_NOAPI(ret_value) @@ -279,12 +280,12 @@ done: /* Get the new dataset's object location */ if (NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset"); /* Decrement refcount on dataset's object header in memory */ if (H5O_dec_rc_by_loc(oloc) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, - "unable to decrement refcount on newly created object") + "unable to decrement refcount on newly created object"); } /* end if */ } /* end if */ @@ -363,7 +364,7 @@ H5VL__native_dataset_read(size_t count, void *obj[], hid_t mem_type_id[], hid_t done: /* Clean up */ if (H5VL__native_dataset_io_cleanup(count, mem_space_id, file_space_id, dinfo) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataset info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataset info"); if (dinfo != &dinfo_local) H5MM_xfree(dinfo); @@ -410,7 +411,7 @@ H5VL__native_dataset_write(size_t count, void *obj[], hid_t mem_type_id[], hid_t done: /* Clean up */ if (H5VL__native_dataset_io_cleanup(count, mem_space_id, file_space_id, dinfo) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataset info") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataset info"); if (dinfo != &dinfo_local) H5MM_xfree(dinfo); diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index ba6d16d..9694fb3 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -99,7 +99,7 @@ H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t done: if (NULL == ret_value && new_file) if (H5F__close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_create() */ @@ -132,7 +132,7 @@ H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t H5 done: if (NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__native_file_open() */ diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c index 163e03f..d5316ce 100644 --- a/src/H5VLnative_group.c +++ b/src/H5VLnative_group.c @@ -113,12 +113,12 @@ done: /* Get the new group's object location */ if (NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") + HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group"); /* Decrement refcount on group's object header in memory */ if (H5O_dec_rc_by_loc(oloc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, - "unable to decrement refcount on newly created object") + "unable to decrement refcount on newly created object"); } /* end if */ } /* end if */ diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index 17673b9..3867df2 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -1787,7 +1787,7 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_args_t *args, hid H5VL_pass_through_t *new_o; H5VL_file_specific_args_t my_args; H5VL_file_specific_args_t *new_args; - H5VL_pass_through_info_t *info; + H5VL_pass_through_info_t *info = NULL; hid_t under_vol_id = -1; herr_t ret_value; diff --git a/src/H5VM.c b/src/H5VM.c index 6e0ea81..af5b311 100644 --- a/src/H5VM.c +++ b/src/H5VM.c @@ -307,17 +307,17 @@ H5VM_hyper_eq(unsigned n, const hsize_t *offset1, const hsize_t *size1, const hs FUNC_ENTER_NOAPI_NOINIT_NOERR if (n == 0) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); for (i = 0; i < n; i++) { if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0)) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (0 == (nelmts1 *= (size1 ? size1[i] : 0))) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); if (0 == (nelmts2 *= (size2 ? size2[i] : 0))) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } done: diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 4567a78..aa1c0f1 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -35,21 +35,21 @@ typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off, size_t len, /* Other functions */ #define H5VM_vector_cpy(N, DST, SRC) \ - { \ + do { \ assert(sizeof(*(DST)) == sizeof(*(SRC))); \ if (SRC) \ H5MM_memcpy(DST, SRC, (N) * sizeof(*(DST))); \ else \ - HDmemset(DST, 0, (N) * sizeof(*(DST))); \ - } + memset(DST, 0, (N) * sizeof(*(DST))); \ + } while (0) -#define H5VM_vector_zero(N, DST) HDmemset(DST, 0, (N) * sizeof(*(DST))) +#define H5VM_vector_zero(N, DST) memset(DST, 0, (N) * sizeof(*(DST))) /* Given a coordinate offset array (COORDS) of type TYPE, move the unlimited * dimension (UNLIM_DIM) value to offset 0, sliding any intermediate values down * one position. */ #define H5VM_swizzle_coords(TYPE, COORDS, UNLIM_DIM) \ - { \ + do { \ /* COORDS must be an array of type TYPE */ \ assert(sizeof(COORDS[0]) == sizeof(TYPE)); \ \ @@ -57,17 +57,17 @@ typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off, size_t len, if (0 != (UNLIM_DIM)) { \ TYPE _tmp = (COORDS)[UNLIM_DIM]; \ \ - HDmemmove(&(COORDS)[1], &(COORDS)[0], sizeof(TYPE) * (UNLIM_DIM)); \ + memmove(&(COORDS)[1], &(COORDS)[0], sizeof(TYPE) * (UNLIM_DIM)); \ (COORDS)[0] = _tmp; \ } /* end if */ \ - } + } while (0) /* Given a coordinate offset array (COORDS) of type TYPE, move the value at * offset 0 to offset of the unlimied dimension (UNLIM_DIM), sliding any * intermediate values up one position. Undoes the "swizzle_coords" operation. */ #define H5VM_unswizzle_coords(TYPE, COORDS, UNLIM_DIM) \ - { \ + do { \ /* COORDS must be an array of type TYPE */ \ assert(sizeof(COORDS[0]) == sizeof(TYPE)); \ \ @@ -75,10 +75,10 @@ typedef herr_t (*H5VM_opvv_func_t)(hsize_t dst_off, hsize_t src_off, size_t len, if (0 != (UNLIM_DIM)) { \ TYPE _tmp = (COORDS)[0]; \ \ - HDmemmove(&(COORDS)[0], &(COORDS)[1], sizeof(TYPE) * (UNLIM_DIM)); \ + memmove(&(COORDS)[0], &(COORDS)[1], sizeof(TYPE) * (UNLIM_DIM)); \ (COORDS)[UNLIM_DIM] = _tmp; \ } /* end if */ \ - } + } while (0) /* A null pointer is equivalent to a zero vector */ #define H5VM_ZERO NULL @@ -142,7 +142,7 @@ H5VM_vector_reduce_product(unsigned n, const hsize_t *v) FUNC_ENTER_NOAPI_NOINIT_NOERR if (n && !v) - HGOTO_DONE(0) + HGOTO_DONE(0); while (n--) ret_value *= *v++; @@ -172,10 +172,10 @@ H5VM_vector_zerop_u(int n, const hsize_t *v) FUNC_ENTER_NOAPI_NOINIT_NOERR if (!v) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); while (n--) if (*v++) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -204,10 +204,10 @@ H5VM_vector_zerop_s(int n, const hssize_t *v) FUNC_ENTER_NOAPI_NOINIT_NOERR if (!v) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); while (n--) if (*v++) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); done: FUNC_LEAVE_NOAPI(ret_value) @@ -239,16 +239,16 @@ H5VM_vector_cmp_u(unsigned n, const hsize_t *v1, const hsize_t *v2) FUNC_ENTER_NOAPI_NOINIT_NOERR if (v1 == v2) - HGOTO_DONE(0) + HGOTO_DONE(0); if (v1 == NULL) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (v2 == NULL) - HGOTO_DONE(1) + HGOTO_DONE(1); while (n--) { if (*v1 < *v2) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (*v1 > *v2) - HGOTO_DONE(1) + HGOTO_DONE(1); v1++; v2++; } @@ -283,16 +283,16 @@ H5VM_vector_cmp_s(unsigned n, const hssize_t *v1, const hssize_t *v2) FUNC_ENTER_NOAPI_NOINIT_NOERR if (v1 == v2) - HGOTO_DONE(0) + HGOTO_DONE(0); if (v1 == NULL) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (v2 == NULL) - HGOTO_DONE(1) + HGOTO_DONE(1); while (n--) { if (*v1 < *v2) - HGOTO_DONE(-1) + HGOTO_DONE(-1); if (*v1 > *v2) - HGOTO_DONE(1) + HGOTO_DONE(1); v1++; v2++; } diff --git a/src/H5WB.c b/src/H5WB.c index 5754084..a9d98de 100644 --- a/src/H5WB.c +++ b/src/H5WB.c @@ -155,7 +155,7 @@ H5WB_actual(H5WB_t *wb, size_t need) /* Check if we can re-use existing buffer */ if (need <= wb->alloc_size) - HGOTO_DONE(wb->actual_buf) + HGOTO_DONE(wb->actual_buf); /* Can't re-use existing buffer, free it and proceed */ else wb->actual_buf = H5FL_BLK_FREE(extra_buf, wb->actual_buf); diff --git a/src/H5Z.c b/src/H5Z.c index 344ba80..2f6b2d8 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -86,7 +86,7 @@ H5Z_init(void) FUNC_ENTER_NOAPI(FAIL) if (H5_TERM_GLOBAL) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Internal filters */ if (H5Z_register(H5Z_SHUFFLE) < 0) @@ -428,11 +428,11 @@ H5Z__unregister(H5Z_filter_t filter_id) /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5Z_table_g[filter_index], &H5Z_table_g[filter_index + 1], - sizeof(H5Z_class2_t) * ((H5Z_table_used_g - 1) - filter_index)); + memmove(&H5Z_table_g[filter_index], &H5Z_table_g[filter_index + 1], + sizeof(H5Z_class2_t) * ((H5Z_table_used_g - 1) - filter_index)); #ifdef H5Z_DEBUG - HDmemmove(&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index + 1], - sizeof(H5Z_stats_t) * ((H5Z_table_used_g - 1) - filter_index)); + memmove(&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index + 1], + sizeof(H5Z_stats_t) * ((H5Z_table_used_g - 1) - filter_index)); #endif /* H5Z_DEBUG */ H5Z_table_used_g--; @@ -516,7 +516,7 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void done: if (ocpl_id > 0) if (H5I_dec_app_ref(ocpl_id) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") + HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_group_cb() */ @@ -566,7 +566,7 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void * done: if (ocpl_id > 0) if (H5I_dec_app_ref(ocpl_id) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") + HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_dset_cb() */ @@ -681,13 +681,13 @@ H5Z_filter_avail(H5Z_filter_t id) /* Is the filter already registered? */ for (i = 0; i < H5Z_table_used_g; i++) if (H5Z_table_g[i].id == id) - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); key.id = (int)id; if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { if (H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter") - HGOTO_DONE(TRUE) + HGOTO_DONE(TRUE); } /* end if */ done: @@ -851,7 +851,7 @@ H5Z__prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_typ done: if (space_id > 0 && H5I_dec_ref(space_id) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") + HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace"); if (dcpl_layout) dcpl_layout = (H5O_layout_t *)H5MM_xfree(dcpl_layout); @@ -1225,7 +1225,7 @@ H5Z__find_idx(H5Z_filter_t id) for (i = 0; i < H5Z_table_used_g; i++) if (H5Z_table_g[i].id == id) - HGOTO_DONE((int)i) + HGOTO_DONE((int)i); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1557,7 +1557,7 @@ H5Z_all_filters_avail(const H5O_pline_t *pline) /* Check if we didn't find the filter */ if (j == H5Z_table_used_g) - HGOTO_DONE(FALSE) + HGOTO_DONE(FALSE); } /* end for */ done: @@ -1587,7 +1587,7 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) /* if the pipeline has no filters, just return */ if (pline->nused == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); /* Delete all filters */ if (H5Z_FILTER_ALL == filter) { diff --git a/src/H5Znbit.c b/src/H5Znbit.c index a157933..ebaac36 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -262,7 +262,7 @@ H5Z__calc_parms_array(const H5T_t *type, size_t *cd_values_actual_nparms) done: if (dtype_base) if (H5T_close_real(dtype_base) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype") + HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__calc_parms_array() */ @@ -362,7 +362,7 @@ H5Z__calc_parms_compound(const H5T_t *type, size_t *cd_values_actual_nparms) done: if (dtype_member) if (H5T_close_real(dtype_member) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") + HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_calc_params_compound */ @@ -586,7 +586,7 @@ H5Z__set_parms_array(const H5T_t *type, unsigned *cd_values_index, unsigned cd_v done: if (dtype_base) if (H5T_close_real(dtype_base) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype") + HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close base datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__set_parms_array() */ @@ -730,7 +730,7 @@ H5Z__set_parms_compound(const H5T_t *type, unsigned *cd_values_index, unsigned c done: if (dtype_member) if (H5T_close_real(dtype_member) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype") + HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "Unable to close member datatype"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_params_compound */ @@ -934,7 +934,7 @@ H5Z__filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], s * cd_values[1] stores the flag if true indicating no need to compress */ if (cd_values[1]) - HGOTO_DONE(*buf_size) + HGOTO_DONE(*buf_size); /* copy a filter parameter to d_nelmts */ d_nelmts = cd_values[2]; diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 3390367..e605672 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -255,7 +255,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ /* Get the fill value for integer type */ #define H5Z_scaleoffset_get_filval_1(type, cd_values, fill_val) \ - { \ + do { \ unsigned _i = H5Z_SCALEOFFSET_PARM_FILVAL; /* index into cd_values */ \ uint32_t _cd_value; /* Current cd_value */ \ char *_fv_p; /* Pointer to current byte in fill_val */ \ @@ -319,15 +319,16 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ H5MM_memcpy(_fv_p, (char *)&_cd_value + 4 - _size_rem, _size_rem); \ } /* end if */ \ } /* end else */ \ - } + } while (0) /* Get the fill value for floating-point type */ #define H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ - { \ + do { \ if (sizeof(type) <= sizeof(long long)) \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) else HGOTO_ERROR( \ - H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ - } + H5Z_scaleoffset_get_filval_1(type, cd_values, filval); \ + else \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ + } while (0) /* Find maximum and minimum values of a buffer with fill value defined for integer type */ #define H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ @@ -445,7 +446,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ } \ } \ else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ } /* Precompress for unsigned integer type */ @@ -455,32 +456,32 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ unsigned i; \ \ if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, \ - filval) if (*minbits == H5Z_SO_INT_MINBITS_DEFAULT) \ - { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval); \ + if (*minbits == \ + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ H5Z_scaleoffset_check_1(type, max, min, minbits) span = (type)(max - min + 1); \ *minbits = H5Z__scaleoffset_log2((unsigned long long)(span + 1)); \ } \ else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_1( \ - i, d_nelmts, buf, filval, \ - min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - for (i = 0; i < d_nelmts; i++) buf[i] = \ - (type)((buf[i] == filval) ? (((type)1 << *minbits) - 1) : (buf[i] - min)); \ + H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min); \ + if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)((buf[i] == filval) ? (((type)1 << *minbits) - 1) : (buf[i] - min)); \ } \ else { /* fill value undefined */ \ if (*minbits == \ H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_1(type, max, min, minbits) span = (type)(max - min + 1); \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min); \ + H5Z_scaleoffset_check_1(type, max, min, minbits); \ + span = (type)(max - min + 1); \ *minbits = H5Z__scaleoffset_log2((unsigned long long)span); \ } \ else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_2( \ - i, d_nelmts, buf, \ - min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - for (i = 0; i < d_nelmts; i++) buf[i] = (type)(buf[i] - min); \ + H5Z_scaleoffset_min_2(i, d_nelmts, buf, min); \ + if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(buf[i] - min); \ } \ *minval = min; \ } while (0) @@ -493,20 +494,19 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ unsigned i; \ \ if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, \ - filval) if (*minbits == H5Z_SO_INT_MINBITS_DEFAULT) \ - { /* minbits not set yet, calculate max, min, and minbits */ \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval); \ + if (*minbits == \ + H5Z_SO_INT_MINBITS_DEFAULT) { /* minbits not set yet, calculate max, min, and minbits */ \ H5Z_scaleoffset_max_min_1(i, d_nelmts, buf, filval, max, min) \ H5Z_scaleoffset_check_2(type, max, min, minbits) span = (unsigned type)(max - min + 1); \ *minbits = H5Z__scaleoffset_log2((unsigned long long)(span + 1)); \ } \ else /* minbits already set, only calculate min */ \ - H5Z_scaleoffset_min_1( \ - i, d_nelmts, buf, filval, \ - min) if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ - for (i = 0; i < d_nelmts; i++) buf[i] = \ - (type)((buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) \ - : (buf[i] - min)); \ + H5Z_scaleoffset_min_1(i, d_nelmts, buf, filval, min); \ + if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)((buf[i] == filval) ? (type)(((unsigned type)1 << *minbits) - 1) \ + : (buf[i] - min)); \ } \ else { /* fill value undefined */ \ if (*minbits == \ @@ -553,7 +553,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ min * pow_fun((type)10, (type)D_val)); \ } \ else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ } /* Modify values of data in precompression if fill value undefined for floating-point type */ @@ -572,7 +572,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ *(long long *)((void *)&buf[i]) = llround_fun(buf[i] * pow_fun((type)10, (type)D_val) - \ min * pow_fun((type)10, (type)D_val)); \ else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ } /* Save the minimum value for floating-point type */ @@ -590,7 +590,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ H5MM_memcpy(((char *)minval) + (sizeof(long long) - sizeof(type)), &min, sizeof(type)); \ } /* end else */ \ else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ } /* Precompress for floating-point type using variable-minimum-bits method */ @@ -603,29 +603,29 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ \ *minval = 0; \ if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ - H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \ - H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ - (unsigned long long)(llround_fun(max * pow_fun((type)10, (type)D_val) - \ - min * pow_fun((type)10, (type)D_val)) + \ - 1); \ + H5Z_scaleoffset_get_filval_2(type, cd_values, filval); \ + H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val); \ + H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val); \ + span = (unsigned long long)(llround_fun(max * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)) + \ + 1); \ *minbits = H5Z__scaleoffset_log2(span + 1); \ if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ H5Z_scaleoffset_modify_1(i, type, pow_fun, abs_fun, lround_fun, llround_fun, buf, d_nelmts, \ - filval, minbits, min, D_val) \ + filval, minbits, min, D_val); \ } \ else { /* fill value undefined */ \ - H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min) \ - H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val) span = \ - (unsigned long long)(llround_fun(max * pow_fun((type)10, (type)D_val) - \ - min * pow_fun((type)10, (type)D_val)) + \ - 1); \ + H5Z_scaleoffset_max_min_2(i, d_nelmts, buf, max, min); \ + H5Z_scaleoffset_check_3(i, type, pow_fun, round_fun, max, min, minbits, D_val); \ + span = (unsigned long long)(llround_fun(max * pow_fun((type)10, (type)D_val) - \ + min * pow_fun((type)10, (type)D_val)) + \ + 1); \ *minbits = H5Z__scaleoffset_log2(span); \ if (*minbits != sizeof(type) * 8) /* change values if minbits != full precision */ \ H5Z_scaleoffset_modify_2(i, type, pow_fun, lround_fun, llround_fun, buf, d_nelmts, min, \ - D_val) \ + D_val); \ } \ - H5Z_scaleoffset_save_min(i, type, minval, min) \ + H5Z_scaleoffset_save_min(i, type, minval, min); \ } while (0) /* Postdecompress for unsigned integer type */ @@ -635,8 +635,9 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ unsigned i; \ \ if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) for (i = 0; i < d_nelmts; i++) buf[i] = \ - (type)((buf[i] == (((type)1 << minbits) - 1)) ? filval : (buf[i] + minval)); \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval); \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)((buf[i] == (((type)1 << minbits) - 1)) ? filval : (buf[i] + minval)); \ } \ else /* fill value undefined */ \ for (i = 0; i < d_nelmts; i++) \ @@ -650,9 +651,11 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ unsigned i; \ \ if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_1(type, cd_values, filval) for (i = 0; i < d_nelmts; i++) buf[i] = \ - (type)(((unsigned type)buf[i] == (((unsigned type)1 << minbits) - 1)) ? filval \ - : (buf[i] + minval)); \ + H5Z_scaleoffset_get_filval_1(type, cd_values, filval); \ + for (i = 0; i < d_nelmts; i++) \ + buf[i] = (type)(((unsigned type)buf[i] == (((unsigned type)1 << minbits) - 1)) \ + ? filval \ + : (buf[i] + minval)); \ } \ else /* fill value undefined */ \ for (i = 0; i < d_nelmts; i++) \ @@ -661,7 +664,7 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ /* Retrieve minimum value of floating-point type */ #define H5Z_scaleoffset_get_min(type, minval, min) \ - { \ + do { \ if (sizeof(type) <= sizeof(long long)) \ /* retrieve min value from corresponding position \ * byte-order has already been swapped as appropriate, but be sure to \ @@ -674,12 +677,12 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ H5MM_memcpy(&min, ((char *)&minval) + (sizeof(long long) - sizeof(type)), sizeof(type)); \ } /* end else */ \ else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ - } + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ + } while (0) /* Modify values of data in postdecompression if fill value defined for floating-point type */ #define H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ - { \ + do { \ if (sizeof(type) == sizeof(int)) \ for (i = 0; i < d_nelmts; i++) \ buf[i] = \ @@ -701,12 +704,12 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ : (type)(*(long long *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + \ min); \ else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ - } + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ + } while (0) /* Modify values of data in postdecompression if fill value undefined for floating-point type */ #define H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ - { \ + do { \ if (sizeof(type) == sizeof(int)) \ for (i = 0; i < d_nelmts; i++) \ buf[i] = ((type)(*(int *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ @@ -717,8 +720,8 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ for (i = 0; i < d_nelmts; i++) \ buf[i] = ((type)(*(long long *)((void *)&buf[i])) / pow_fun((type)10, (type)D_val) + min); \ else \ - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer dataype") \ - } + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "cannot find matched integer datatype") \ + } while (0) /* Postdecompress for floating-point type using variable-minimum-bits method */ #define H5Z_scaleoffset_postdecompress_3(type, pow_fun, data, d_nelmts, filavail, cd_values, minbits, \ @@ -727,15 +730,14 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{ type *buf = (type *)data, filval = 0, min = 0; \ unsigned i; \ \ - H5Z_scaleoffset_get_min(type, minval, min) \ + H5Z_scaleoffset_get_min(type, minval, min); \ \ - if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) \ - { /* fill value defined */ \ - H5Z_scaleoffset_get_filval_2(type, cd_values, filval) \ - H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val) \ + if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ \ + H5Z_scaleoffset_get_filval_2(type, cd_values, filval); \ + H5Z_scaleoffset_modify_3(i, type, pow_fun, buf, d_nelmts, filval, minbits, min, D_val); \ } \ else /* fill value undefined */ \ - H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \ + H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val); \ } while (0) /*------------------------------------------------------------------------- @@ -821,7 +823,7 @@ H5Z__scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dt type = t_ulong_long; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ else - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory datatype") } if (dtype_sign == H5Z_SCALEOFFSET_SGN_2) { /* signed integer */ @@ -838,7 +840,7 @@ H5Z__scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dt type = t_long_long; #endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */ else - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory datatype") } } @@ -848,7 +850,7 @@ H5Z__scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dt else if (dtype_size == sizeof(double)) type = t_double; else - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory datatype") } /* Set return value */ @@ -1523,9 +1525,10 @@ H5Z__scaleoffset_postdecompress_i(void *data, unsigned d_nelmts, enum H5Z_scaleo unsigned i; if (filavail == H5Z_SCALEOFFSET_FILL_DEFINED) { /* fill value defined */ - H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval) for (i = 0; i < d_nelmts; - i++) buf[i] = - (signed char)((buf[i] == (((unsigned char)1 << minbits) - 1)) ? filval : (buf[i] + sminval)); + H5Z_scaleoffset_get_filval_1(signed char, cd_values, filval); + for (i = 0; i < d_nelmts; i++) + buf[i] = (signed char)((buf[i] == (((unsigned char)1 << minbits) - 1)) ? filval + : (buf[i] + sminval)); } else /* fill value undefined */ for (i = 0; i < d_nelmts; i++) diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index c667dd6..d0ab2b9 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -379,10 +379,10 @@ H5Z__get_token(H5Z_token *current) current->tok_begin = current->tok_end; while (current->tok_begin[0] != '\0') { - if (HDisspace(current->tok_begin[0])) { + if (isspace(current->tok_begin[0])) { /* ignore whitespace */ } - else if (HDisdigit(current->tok_begin[0]) || current->tok_begin[0] == '.') { + else if (isdigit(current->tok_begin[0]) || current->tok_begin[0] == '.') { current->tok_end = current->tok_begin; /* @@ -394,7 +394,7 @@ H5Z__get_token(H5Z_token *current) /* is number */ current->tok_type = H5Z_XFORM_INTEGER; - while (HDisdigit(current->tok_end[0])) + while (isdigit(current->tok_end[0])) ++current->tok_end; } @@ -411,7 +411,7 @@ H5Z__get_token(H5Z_token *current) if (current->tok_end[0] == '.') do { ++current->tok_end; - } while (HDisdigit(current->tok_end[0])); + } while (isdigit(current->tok_end[0])); if (current->tok_end[0] == 'e' || current->tok_end[0] == 'E') { ++current->tok_end; @@ -419,18 +419,18 @@ H5Z__get_token(H5Z_token *current) if (current->tok_end[0] == '-' || current->tok_end[0] == '+') ++current->tok_end; - if (!HDisdigit(current->tok_end[0])) { + if (!isdigit(current->tok_end[0])) { current->tok_type = H5Z_XFORM_ERROR; HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Invalidly formatted floating point number") } - while (HDisdigit(current->tok_end[0])) + while (isdigit(current->tok_end[0])) ++current->tok_end; } /* Check that this is a properly formatted numerical value */ - if (HDisalpha(current->tok_end[0]) || current->tok_end[0] == '.') { + if (isalpha(current->tok_end[0]) || current->tok_end[0] == '.') { current->tok_type = H5Z_XFORM_ERROR; HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, current, "Invalidly formatted floating point number") } @@ -438,12 +438,12 @@ H5Z__get_token(H5Z_token *current) break; } - else if (HDisalpha(current->tok_begin[0])) { + else if (isalpha(current->tok_begin[0])) { /* is symbol */ current->tok_type = H5Z_XFORM_SYMBOL; current->tok_end = current->tok_begin; - while (HDisalnum(current->tok_end[0])) + while (isalnum(current->tok_end[0])) ++current->tok_end; break; @@ -613,10 +613,10 @@ H5Z__parse_expression(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) case H5Z_XFORM_RPAREN: H5Z__unget_token(current); - HGOTO_DONE(expr) + HGOTO_DONE(expr); case H5Z_XFORM_END: - HGOTO_DONE(expr) + HGOTO_DONE(expr); case H5Z_XFORM_ERROR: case H5Z_XFORM_INTEGER: @@ -701,10 +701,10 @@ H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) case H5Z_XFORM_RPAREN: H5Z__unget_token(current); - HGOTO_DONE(term) + HGOTO_DONE(term); case H5Z_XFORM_END: - HGOTO_DONE(term) + HGOTO_DONE(term); case H5Z_XFORM_INTEGER: case H5Z_XFORM_FLOAT: @@ -713,7 +713,7 @@ H5Z__parse_term(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) case H5Z_XFORM_MINUS: case H5Z_XFORM_LPAREN: H5Z__unget_token(current); - HGOTO_DONE(term) + HGOTO_DONE(term); case H5Z_XFORM_ERROR: default: @@ -871,7 +871,7 @@ H5Z__parse_factor(H5Z_token *current, H5Z_datval_ptrs *dat_val_pointers) ret_value = factor; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /*------------------------------------------------------------------------- @@ -1130,46 +1130,46 @@ H5Z__xform_find_type(const H5T_t *type) /* Check for SHORT type */ if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_SHORT) + HGOTO_DONE(H5T_NATIVE_SHORT); /* Check for INT type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_INT)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_INT) + HGOTO_DONE(H5T_NATIVE_INT); /* Check for LONG type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LONG)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LONG) + HGOTO_DONE(H5T_NATIVE_LONG); /* Check for LONGLONG type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LLONG) + HGOTO_DONE(H5T_NATIVE_LLONG); /* Check for UCHAR type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_UCHAR) + HGOTO_DONE(H5T_NATIVE_UCHAR); /* Check for CHAR type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_CHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_CHAR) + HGOTO_DONE(H5T_NATIVE_CHAR); /* Check for SCHAR type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_SCHAR)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_SCHAR) + HGOTO_DONE(H5T_NATIVE_SCHAR); /* Check for USHORT type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_USHORT)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_USHORT) + HGOTO_DONE(H5T_NATIVE_USHORT); /* Check for UINT type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_UINT)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_UINT) + HGOTO_DONE(H5T_NATIVE_UINT); /* Check for ULONG type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULONG)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_ULONG) + HGOTO_DONE(H5T_NATIVE_ULONG); /* Check for ULONGLONG type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_ULLONG) + HGOTO_DONE(H5T_NATIVE_ULLONG); /* Check for FLOAT type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_FLOAT) + HGOTO_DONE(H5T_NATIVE_FLOAT); /* Check for DOUBLE type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_DOUBLE) + HGOTO_DONE(H5T_NATIVE_DOUBLE); /* Check for LONGDOUBLE type */ else if ((tmp = (H5T_t *)H5I_object(H5T_NATIVE_LDOUBLE)) && 0 == H5T_cmp(type, tmp, FALSE)) - HGOTO_DONE(H5T_NATIVE_LDOUBLE) + HGOTO_DONE(H5T_NATIVE_LDOUBLE); else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not find matching type") @@ -1347,7 +1347,7 @@ H5Z__xform_reduce_tree(H5Z_node *tree) } } - FUNC_LEAVE_NOAPI_VOID; + FUNC_LEAVE_NOAPI_VOID } /*------------------------------------------------------------------------- @@ -1377,7 +1377,7 @@ H5Z__do_op(H5Z_node *tree) else if (tree->type == H5Z_XFORM_MINUS) H5Z_XFORM_DO_OP6(-) - FUNC_LEAVE_NOAPI_VOID; + FUNC_LEAVE_NOAPI_VOID } /*------------------------------------------------------------------------- @@ -1420,11 +1420,11 @@ H5Z_xform_create(const char *expr) * A more sophisticated check is needed to support scientific notation. */ for (i = 0; i < HDstrlen(expr); i++) { - if (HDisalpha(expr[i])) { + if (isalpha(expr[i])) { if ((i > 0) && (i < (HDstrlen(expr) - 1))) { if (((expr[i] == 'E') || (expr[i] == 'e')) && - (HDisdigit(expr[i - 1]) || (expr[i - 1] == '.')) && - (HDisdigit(expr[i + 1]) || (expr[i + 1] == '-') || (expr[i + 1] == '+'))) + (isdigit(expr[i - 1]) || (expr[i - 1] == '.')) && + (isdigit(expr[i + 1]) || (expr[i + 1] == '-') || (expr[i + 1] == '+'))) continue; } /* end if */ @@ -1558,7 +1558,7 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop) /* Find the number of times "x" is used in this equation, and allocate room for storing that many * points */ for (i = 0; i < HDstrlen(new_data_xform_prop->xform_exp); i++) - if (HDisalpha(new_data_xform_prop->xform_exp[i])) + if (isalpha(new_data_xform_prop->xform_exp[i])) count++; if (count > 0) diff --git a/src/H5checksum.c b/src/H5checksum.c index f2d15af..b9823d8 100644 --- a/src/H5checksum.c +++ b/src/H5checksum.c @@ -270,7 +270,7 @@ rotates. */ #define H5_lookup3_rot(x, k) (((x) << (k)) ^ ((x) >> (32 - (k)))) #define H5_lookup3_mix(a, b, c) \ - { \ + do { \ a -= c; \ a ^= H5_lookup3_rot(c, 4); \ c += b; \ @@ -289,7 +289,7 @@ rotates. c -= b; \ c ^= H5_lookup3_rot(b, 4); \ b += a; \ - } + } while (0) /* ------------------------------------------------------------------------------- @@ -317,7 +317,7 @@ and these came close: ------------------------------------------------------------------------------- */ #define H5_lookup3_final(a, b, c) \ - { \ + do { \ c ^= b; \ c -= H5_lookup3_rot(b, 14); \ a ^= c; \ @@ -332,7 +332,7 @@ and these came close: b -= H5_lookup3_rot(a, 14); \ c ^= b; \ c -= H5_lookup3_rot(b, 24); \ - } + } while (0) /* ------------------------------------------------------------------------------- diff --git a/src/H5dbg.c b/src/H5dbg.c index 083a81c..69afd01 100644 --- a/src/H5dbg.c +++ b/src/H5dbg.c @@ -114,7 +114,7 @@ H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, const uint8_t *mark else { c = buf[buf_offset + u + v]; - if (HDisprint(c)) + if (isprint(c)) HDfputc(c, stream); else HDfputc('.', stream); diff --git a/src/H5detect.c b/src/H5detect.c index 6135c03..45d27c7 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -174,7 +174,7 @@ precision(detected_t *d) } \ fix_order(sizeof(TYPE), _last, INFO.perm, (const char **)&_mesg); \ \ - if (!HDstrcmp(_mesg, "VAX")) \ + if (!strcmp(_mesg, "VAX")) \ INFO.is_vax = TRUE; \ \ /* Implicit mantissa bit */ \ @@ -203,8 +203,8 @@ precision(detected_t *d) _v1 = (TYPE)1.0L; \ INFO.bias = find_bias(INFO.epos, INFO.esize, INFO.perm, &_v1); \ precision(&(INFO)); \ - if (!HDstrcmp(INFO.varname, "FLOAT") || !HDstrcmp(INFO.varname, "DOUBLE") || \ - !HDstrcmp(INFO.varname, "LDOUBLE")) { \ + if (!strcmp(INFO.varname, "FLOAT") || !strcmp(INFO.varname, "DOUBLE") || \ + !strcmp(INFO.varname, "LDOUBLE")) { \ COMP_ALIGNMENT(TYPE, INFO.comp_align); \ } \ } @@ -395,10 +395,10 @@ dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n", d[i].varname); /* Variables for alignment of compound datatype */ - if (!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") || - !HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") || - !HDstrcmp(d[i].varname, "LLONG") || !HDstrcmp(d[i].varname, "FLOAT") || - !HDstrcmp(d[i].varname, "DOUBLE") || !HDstrcmp(d[i].varname, "LDOUBLE")) { + if (!strcmp(d[i].varname, "SCHAR") || !strcmp(d[i].varname, "SHORT") || + !strcmp(d[i].varname, "INT") || !strcmp(d[i].varname, "LONG") || !strcmp(d[i].varname, "LLONG") || + !strcmp(d[i].varname, "FLOAT") || !strcmp(d[i].varname, "DOUBLE") || + !strcmp(d[i].varname, "LDOUBLE")) { fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname, (unsigned long)(d[i].comp_align)); } @@ -455,7 +455,7 @@ iprint(detected_t *d) for (i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) { fprintf(rawoutstream, "%4d", d->perm[i]); if (i > pass * 4) - HDfputs(" ", rawoutstream); + fputs(" ", rawoutstream); if (!i) break; } @@ -470,25 +470,25 @@ iprint(detected_t *d) for (j = 8; j > 0; --j) { if (k == d->sign) { - HDfputc('S', rawoutstream); + fputc('S', rawoutstream); } else if (k >= d->epos && k < d->epos + d->esize) { - HDfputc('E', rawoutstream); + fputc('E', rawoutstream); } else if (k >= d->mpos && k < d->mpos + d->msize) { - HDfputc('M', rawoutstream); + fputc('M', rawoutstream); } else { - HDfputc('?', rawoutstream); /*unknown floating point bit */ + fputc('?', rawoutstream); /*unknown floating point bit */ } --k; } if (i > pass * 4) - HDfputc(' ', rawoutstream); + fputc(' ', rawoutstream); if (!i) break; } - HDfputc('\n', rawoutstream); + fputc('\n', rawoutstream); if (!pass) break; } @@ -557,11 +557,11 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, const unsigned char return i * 8 + j; } fprintf(stderr, "INTERNAL ERROR"); - HDabort(); + abort(); } } fprintf(stderr, "INTERNAL ERROR"); - HDabort(); + abort(); return 0; } @@ -781,14 +781,14 @@ bit.\n"; { size_t n; char *comma; - if ((pwd = HDgetpwuid(HDgetuid()))) { - if ((comma = HDstrchr(pwd->pw_gecos, ','))) { + if ((pwd = getpwuid(getuid()))) { + if ((comma = strchr(pwd->pw_gecos, ','))) { n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); - HDstrncpy(real_name, pwd->pw_gecos, n); + strncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; } else { - HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); + strncpy(real_name, pwd->pw_gecos, sizeof(real_name)); real_name[sizeof(real_name) - 1] = '\0'; } } @@ -803,7 +803,7 @@ bit.\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if (HDgethostname(host_name, sizeof(host_name)) < 0) { + if (gethostname(host_name, sizeof(host_name)) < 0) { host_name[0] = '\0'; } #else @@ -814,7 +814,7 @@ bit.\n"; * The file header: warning, copyright notice, build information. */ fprintf(rawoutstream, "/* Generated automatically by H5detect -- do not edit */\n\n\n"); - HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ + fputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); @@ -824,17 +824,17 @@ bit.\n"; fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID if (pwd) - HDfputs(pwd->pw_name, rawoutstream); + fputs(pwd->pw_name, rawoutstream); #endif if (host_name[0]) fprintf(rawoutstream, "@%s", host_name); if (real_name[0]) fprintf(rawoutstream, ">"); - HDfputc('\n', rawoutstream); + fputc('\n', rawoutstream); } fprintf(rawoutstream, " *\n * Purpose:\t\t"); for (s = purpose; *s; s++) { - HDfputc(*s, rawoutstream); + fputc(*s, rawoutstream); if ('\n' == *s && s[1]) fprintf(rawoutstream, " *\t\t\t"); } @@ -845,7 +845,7 @@ bit.\n"; fprintf(rawoutstream, " *\n *"); for (i = 0; i < 73; i++) - HDfputc('-', rawoutstream); + fputc('-', rawoutstream); fprintf(rawoutstream, "\n */\n\n"); } @@ -931,7 +931,7 @@ main(int argc, char *argv[]) print_results(nd_g, d_g); if (rawoutstream && rawoutstream != stdout) { - if (HDfclose(rawoutstream)) + if (fclose(rawoutstream)) fprintf(stderr, "closing rawoutstream"); else rawoutstream = NULL; diff --git a/src/H5encode.h b/src/H5encode.h new file mode 100644 index 0000000..a9172ff --- /dev/null +++ b/src/H5encode.h @@ -0,0 +1,287 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * File-independent encode/decode routines + */ + +#ifndef H5encode_H +#define H5encode_H + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/* + * Encode and decode macros for file meta-data. + * Currently, all file meta-data is little-endian. + */ + +#define INT16ENCODE(p, i) \ + do { \ + *(p) = (uint8_t)((unsigned)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ + (p)++; \ + } while (0) + +#define UINT16ENCODE(p, i) \ + do { \ + *(p) = (uint8_t)((unsigned)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff); \ + (p)++; \ + } while (0) + +#define INT32ENCODE(p, i) \ + do { \ + *(p) = (uint8_t)((uint32_t)(i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff); \ + (p)++; \ + } while (0) + +#define UINT32ENCODE(p, i) \ + do { \ + *(p) = (uint8_t)((i)&0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 8) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 16) & 0xff); \ + (p)++; \ + *(p) = (uint8_t)(((i) >> 24) & 0xff); \ + (p)++; \ + } while (0) + +/* Encode an unsigned integer into a variable-sized buffer */ +/* (Assumes that the high bits of the integer are zero) */ +#define ENCODE_VAR(p, typ, n, l) \ + do { \ + typ _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < l; _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + (p) = (uint8_t *)(p) + l; \ + } while (0) + +/* Encode a 32-bit unsigned integer into a variable-sized buffer */ +/* (Assumes that the high bits of the integer are zero) */ +#define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) + +#define INT64ENCODE(p, n) \ + do { \ + int64_t _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < sizeof(int64_t); _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + for (/*void*/; _i < 8; _i++) \ + *_p++ = (uint8_t)((n) < 0 ? 0xff : 0); \ + (p) = (uint8_t *)(p) + 8; \ + } while (0) + +#define UINT64ENCODE(p, n) \ + do { \ + uint64_t _n = (n); \ + size_t _i; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + for (_i = 0; _i < sizeof(uint64_t); _i++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + for (/*void*/; _i < 8; _i++) \ + *_p++ = 0; \ + (p) = (uint8_t *)(p) + 8; \ + } while (0) + +/* Encode a 64-bit unsigned integer into a variable-sized buffer */ +/* (Assumes that the high bits of the integer are zero) */ +#define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) + +#define H5_ENCODE_UNSIGNED(p, n) \ + do { \ + HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ + UINT32ENCODE(p, n); \ + } while (0) + +/* Assumes the endianness of uint64_t is the same as double */ +#define H5_ENCODE_DOUBLE(p, n) \ + do { \ + uint64_t _n; \ + size_t _u; \ + uint8_t *_p = (uint8_t *)(p); \ + \ + HDcompile_assert(sizeof(double) == 8); \ + HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ + memcpy(&_n, &n, sizeof(double)); \ + for (_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8) \ + *_p++ = (uint8_t)(_n & 0xff); \ + (p) = (uint8_t *)(p) + 8; \ + } while (0) + +/* DECODE converts little endian bytes pointed by p to integer values and store + * it in i. For signed values, need to do sign-extension when converting + * the last byte which carries the sign bit. + * The macros does not require i be of a certain byte sizes. It just requires + * i be big enough to hold the intended value range. E.g. INT16DECODE works + * correctly even if i is actually a 64bit int like in a Cray. + */ + +#define INT16DECODE(p, i) \ + do { \ + (i) = (int16_t)((*(p)&0xff)); \ + (p)++; \ + (i) |= (int16_t)(((*(p)&0xff) << 8) | ((*(p)&0x80) ? ~0xffff : 0x0)); \ + (p)++; \ + } while (0) + +#define UINT16DECODE(p, i) \ + do { \ + (i) = (uint16_t)(*(p)&0xff); \ + (p)++; \ + (i) |= (uint16_t)((*(p)&0xff) << 8); \ + (p)++; \ + } while (0) + +#define INT32DECODE(p, i) \ + do { \ + (i) = ((int32_t)(*(p)&0xff)); \ + (p)++; \ + (i) |= ((int32_t)(*(p)&0xff) << 8); \ + (p)++; \ + (i) |= ((int32_t)(*(p)&0xff) << 16); \ + (p)++; \ + (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | ((*(p)&0x80) ? ~0xffffffffULL : 0x0ULL))); \ + (p)++; \ + } while (0) + +#define UINT32DECODE(p, i) \ + do { \ + (i) = (uint32_t)(*(p)&0xff); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 8); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 16); \ + (p)++; \ + (i) |= ((uint32_t)(*(p)&0xff) << 24); \ + (p)++; \ + } while (0) + +/* Decode a variable-sized buffer */ +/* (Assumes that the high bits of the integer will be zero) */ +#define DECODE_VAR(p, n, l) \ + do { \ + size_t _i; \ + \ + n = 0; \ + (p) += l; \ + for (_i = 0; _i < l; _i++) \ + n = (n << 8) | *(--p); \ + (p) += l; \ + } while (0) + +/* Decode a variable-sized buffer into a 32-bit unsigned integer */ +/* (Assumes that the high bits of the integer will be zero) */ +#define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) + +#define INT64DECODE(p, n) \ + do { \ + /* WE DON'T CHECK FOR OVERFLOW! */ \ + size_t _i; \ + \ + n = 0; \ + (p) += 8; \ + for (_i = 0; _i < sizeof(int64_t); _i++) \ + n = (n << 8) | *(--p); \ + (p) += 8; \ + } while (0) + +#define UINT64DECODE(p, n) \ + do { \ + /* WE DON'T CHECK FOR OVERFLOW! */ \ + size_t _i; \ + \ + n = 0; \ + (p) += 8; \ + for (_i = 0; _i < sizeof(uint64_t); _i++) \ + n = (n << 8) | *(--p); \ + (p) += 8; \ + } while (0) + +/* Decode a variable-sized buffer into a 64-bit unsigned integer */ +/* (Assumes that the high bits of the integer will be zero) */ +#define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) + +#define H5_DECODE_UNSIGNED(p, n) \ + do { \ + HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t)); \ + UINT32DECODE(p, n); \ + } while (0) + +/* Assumes the endianness of uint64_t is the same as double */ +#define H5_DECODE_DOUBLE(p, n) \ + do { \ + uint64_t _n; \ + size_t _u; \ + \ + HDcompile_assert(sizeof(double) == 8); \ + HDcompile_assert(sizeof(double) == sizeof(uint64_t)); \ + _n = 0; \ + (p) += 8; \ + for (_u = 0; _u < sizeof(uint64_t); _u++) \ + _n = (_n << 8) | *(--p); \ + memcpy(&(n), &_n, sizeof(double)); \ + (p) += 8; \ + } while (0) + +/* Macros to encode/decode offset/length's for storing in the file */ +#define H5_ENCODE_LENGTH_LEN(p, l, s) \ + do { \ + switch (s) { \ + case 4: \ + UINT32ENCODE(p, l); \ + break; \ + case 8: \ + UINT64ENCODE(p, l); \ + break; \ + case 2: \ + UINT16ENCODE(p, l); \ + break; \ + default: \ + assert("bad sizeof size" && 0); \ + } \ + } while (0) + +#define H5_DECODE_LENGTH_LEN(p, l, s) \ + do { \ + switch (s) { \ + case 4: \ + UINT32DECODE(p, l); \ + break; \ + case 8: \ + UINT64DECODE(p, l); \ + break; \ + case 2: \ + UINT16DECODE(p, l); \ + break; \ + default: \ + assert("bad sizeof size" && 0); \ + } \ + } while (0) + +#endif /* H5encode_H */ diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index c76d492..2661288 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -60,7 +60,7 @@ insert_libhdf5_settings(FILE *flibinfo) int bol = 0; /* indicates the beginning of a new line */ if (NULL == (fsettings = fopen(LIBSETTINGSFNAME, "r"))) { - HDperror(LIBSETTINGSFNAME); + perror(LIBSETTINGSFNAME); exit(EXIT_FAILURE); } @@ -74,9 +74,9 @@ insert_libhdf5_settings(FILE *flibinfo) /* Print variable definition and the string. Do not use const or some * platforms (AIX?) will have issues. */ - fprintf(flibinfo, "char H5libhdf5_settings[]=\n"); + fprintf(flibinfo, "const char H5libhdf5_settings[]=\n"); bol++; - while (EOF != (inchar = HDgetc(fsettings))) { + while (EOF != (inchar = getc(fsettings))) { if (bol) { /* Start a new line */ fprintf(flibinfo, "\t\""); @@ -88,10 +88,10 @@ insert_libhdf5_settings(FILE *flibinfo) bol++; } else - HDputc(inchar, flibinfo); + putc(inchar, flibinfo); } - if (HDfeof(fsettings)) { + if (feof(fsettings)) { /* wrap up */ if (!bol) /* EOF found without a new line */ @@ -102,8 +102,8 @@ insert_libhdf5_settings(FILE *flibinfo) fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); exit(EXIT_FAILURE); } - if (0 != HDfclose(fsettings)) { - HDperror(LIBSETTINGSFNAME); + if (0 != fclose(fsettings)) { + perror(LIBSETTINGSFNAME); exit(EXIT_FAILURE); } @@ -114,7 +114,7 @@ insert_libhdf5_settings(FILE *flibinfo) /* Print variable definition and an empty string. Do not use const or some * platforms (AIX?) will have issues. */ - fprintf(flibinfo, "char H5libhdf5_settings[]=\"\";\n"); + fprintf(flibinfo, "const char H5libhdf5_settings[]=\"\";\n"); #endif } /* insert_libhdf5_settings() */ @@ -171,14 +171,14 @@ information about the library build configuration\n"; size_t n; char *comma; - if ((pwd = HDgetpwuid(HDgetuid()))) { - if ((comma = HDstrchr(pwd->pw_gecos, ','))) { + if ((pwd = getpwuid(getuid()))) { + if ((comma = strchr(pwd->pw_gecos, ','))) { n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); - HDstrncpy(real_name, pwd->pw_gecos, n); + strncpy(real_name, pwd->pw_gecos, n); real_name[n] = '\0'; } else { - HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); + strncpy(real_name, pwd->pw_gecos, sizeof(real_name)); real_name[sizeof(real_name) - 1] = '\0'; } } @@ -193,7 +193,7 @@ information about the library build configuration\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if (HDgethostname(host_name, sizeof(host_name)) < 0) + if (gethostname(host_name, sizeof(host_name)) < 0) host_name[0] = '\0'; #else host_name[0] = '\0'; @@ -203,7 +203,7 @@ information about the library build configuration\n"; * The file header: warning, copyright notice, build information. */ fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n"); - HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ + fputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); @@ -213,19 +213,19 @@ information about the library build configuration\n"; fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID if (pwd) - HDfputs(pwd->pw_name, rawoutstream); + fputs(pwd->pw_name, rawoutstream); #endif if (host_name[0]) fprintf(rawoutstream, "@%s", host_name); if (real_name[0]) fprintf(rawoutstream, ">"); - HDfputc('\n', rawoutstream); + fputc('\n', rawoutstream); } fprintf(rawoutstream, " *\n * Purpose:\t\t"); for (s = purpose; *s; s++) { - HDfputc(*s, rawoutstream); + fputc(*s, rawoutstream); if ('\n' == *s && s[1]) fprintf(rawoutstream, " *\t\t\t"); } @@ -236,7 +236,7 @@ information about the library build configuration\n"; fprintf(rawoutstream, " *\n *"); for (i = 0; i < 73; i++) - HDfputc('-', rawoutstream); + fputc('-', rawoutstream); fprintf(rawoutstream, "\n */\n\n"); } @@ -290,7 +290,7 @@ main(int argc, char *argv[]) print_footer(); if (rawoutstream && rawoutstream != stdout) { - if (HDfclose(rawoutstream)) + if (fclose(rawoutstream)) fprintf(stderr, "closing rawoutstream"); else rawoutstream = NULL; diff --git a/src/H5mpi.c b/src/H5mpi.c index 12f635c..e1b71f4 100644 --- a/src/H5mpi.c +++ b/src/H5mpi.c @@ -662,11 +662,11 @@ H5_mpio_gatherv_alloc(void *send_buf, int send_count, MPI_Datatype send_type, co /* If our buffer size is 0, there's nothing to do */ if (buf_size == 0) - HGOTO_DONE(SUCCEED) + HGOTO_DONE(SUCCEED); if (NULL == (recv_buf = H5MM_malloc(buf_size))) /* Push an error, but still participate in collective gather operation */ - HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "couldn't allocate receive buffer") + HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "couldn't allocate receive buffer"); } /* Perform gather operation */ @@ -735,7 +735,7 @@ H5_mpio_gatherv_alloc_simple(void *send_buf, int send_count, MPI_Datatype send_t (recv_counts_disps_array = H5MM_malloc(2 * (size_t)mpi_size * sizeof(*recv_counts_disps_array)))) /* Push an error, but still participate in collective gather operation */ HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "couldn't allocate receive counts and displacements array") + "couldn't allocate receive counts and displacements array"); } /* Collect each rank's send count to interested ranks */ diff --git a/src/H5private.h b/src/H5private.h index 327e2c9..a2d6453 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -194,7 +194,7 @@ # define H5_ATTR_DEBUG_API_USED /*void*/ # else # define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED -# endif /* H5_DEBUG_API */ +# endif # ifndef NDEBUG # define H5_ATTR_NDEBUG_UNUSED /*void*/ @@ -611,156 +611,36 @@ typedef off_t h5_stat_size_t; #ifndef HDabort #define HDabort() abort() #endif -#ifndef HDabs -#define HDabs(X) abs(X) -#endif -#ifndef HDaccept -#define HDaccept(A, B, C) accept((A), (B), (C)) -#endif #ifndef HDaccess #define HDaccess(F, M) access(F, M) #endif -#ifndef HDacos -#define HDacos(X) acos(X) -#endif -#ifndef HDalarm -#define HDalarm(N) alarm(N) -#endif #ifndef HDasctime #define HDasctime(T) asctime(T) #endif -#ifndef HDasin -#define HDasin(X) asin(X) -#endif -#ifndef HDasprintf -#define HDasprintf asprintf /*varargs*/ -#endif -#ifndef HDassert -#define HDassert(X) assert(X) -#endif -#ifndef HDatan -#define HDatan(X) atan(X) -#endif -#ifndef HDatan2 -#define HDatan2(X, Y) atan2(X, Y) -#endif -#ifndef HDatexit -#define HDatexit(F) atexit(F) -#endif -#ifndef HDatof -#define HDatof(S) atof(S) -#endif -#ifndef HDatoi -#define HDatoi(S) atoi(S) -#endif -#ifndef HDatol -#define HDatol(S) atol(S) -#endif -#ifndef HDatoll -#define HDatoll(S) atoll(S) -#endif -#ifndef HDbind -#define HDbind(A, B, C) bind((A), (B), (C)) -#endif -#ifndef HDbsearch -#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F) -#endif -#ifndef HDcalloc -#define HDcalloc(N, Z) calloc(N, Z) -#endif #ifndef HDceil #define HDceil(X) ceil(X) #endif -#ifndef HDcfgetispeed -#define HDcfgetispeed(T) cfgetispeed(T) -#endif -#ifndef HDcfgetospeed -#define HDcfgetospeed(T) cfgetospeed(T) -#endif -#ifndef HDcfsetispeed -#define HDcfsetispeed(T, S) cfsetispeed(T, S) -#endif -#ifndef HDcfsetospeed -#define HDcfsetospeed(T, S) cfsetospeed(T, S) -#endif #ifndef HDchdir #define HDchdir(S) chdir(S) #endif -#ifndef HDchmod -#define HDchmod(S, M) chmod(S, M) -#endif -#ifndef HDchown -#define HDchown(S, O, G) chown(S, O, G) -#endif -#ifndef HDclearerr -#define HDclearerr(F) clearerr(F) -#endif #ifndef HDclock #define HDclock() clock() #endif -#ifndef HDclock_gettime -#define HDclock_gettime(CID, TS) clock_gettime(CID, TS) -#endif #ifndef HDclose #define HDclose(F) close(F) #endif #ifndef HDclosedir #define HDclosedir(D) closedir(D) #endif -#ifndef HDconnect -#define HDconnect(A, B, C) connect((A), (B), (C)) -#endif -#ifndef HDcos -#define HDcos(X) cos(X) -#endif -#ifndef HDcosh -#define HDcosh(X) cosh(X) -#endif #ifndef HDcreat #define HDcreat(S, M) creat(S, M) #endif -#ifndef HDctermid -#define HDctermid(S) ctermid(S) -#endif #ifndef HDctime #define HDctime(T) ctime(T) #endif -#ifndef HDcuserid -#define HDcuserid(S) cuserid(S) -#endif #ifndef HDdifftime #define HDdifftime(X, Y) difftime(X, Y) #endif -#ifndef HDdiv -#define HDdiv(X, Y) div(X, Y) -#endif -#ifndef HDdup -#define HDdup(F) dup(F) -#endif -#ifndef HDdup2 -#define HDdup2(F, I) dup2(F, I) -#endif -#ifndef HDexecv -#define HDexecv(S, AV) execv(S, AV) -#endif -#ifndef HDexecve -#define HDexecve(S, AV, E) execve(S, AV, E) -#endif -#ifndef HDexecvp -#define HDexecvp(S, AV) execvp(S, AV) -#endif -#ifndef HDexit -#define HDexit(N) exit(N) -#endif -#ifndef HD_exit -#define HD_exit(N) _exit(N) -#endif -#ifndef HDexp -#define HDexp(X) exp(X) -#endif -#ifndef HDexp2 -#define HDexp2(X) exp2(X) -#endif #ifndef HDfabs #define HDfabs(X) fabs(X) #endif @@ -770,30 +650,12 @@ typedef off_t h5_stat_size_t; #ifndef HDfabsl #define HDfabsl(X) fabsl(X) #endif -#ifndef HDfclose -#define HDfclose(F) fclose(F) -#endif -#ifndef HDfcntl -#define HDfcntl(F, C, ...) fcntl(F, C, __VA_ARGS__) -#endif #ifndef HDfdopen #define HDfdopen(N, S) fdopen(N, S) #endif -#ifndef HDfeof -#define HDfeof(F) feof(F) -#endif -#ifndef HDferror -#define HDferror(F) ferror(F) -#endif -#ifndef HDfflush -#define HDfflush(F) fflush(F) -#endif #ifndef HDfgetc #define HDfgetc(F) fgetc(F) #endif -#ifndef HDfgetpos -#define HDfgetpos(F, P) fgetpos(F, P) -#endif #ifndef HDfgets #define HDfgets(S, N, F) fgets(S, N, F) #endif @@ -829,36 +691,12 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDfloor #define HDfloor(X) floor(X) #endif -#ifndef HDfmod -#define HDfmod(X, Y) fmod(X, Y) -#endif -#ifndef HDfopen -#define HDfopen(S, M) fopen(S, M) -#endif -#ifndef HDfork -#define HDfork() fork() -#endif -#ifndef HDfprintf -#define HDfprintf fprintf -#endif -#ifndef HDfpathconf -#define HDfpathconf(F, N) fpathconf(F, N) -#endif #ifndef HDfputc #define HDfputc(C, F) fputc(C, F) #endif #ifndef HDfputs #define HDfputs(S, F) fputs(S, F) #endif -#ifndef HDfread -#define HDfread(M, Z, N, F) fread(M, Z, N, F) -#endif -#ifndef HDfree -#define HDfree(M) free(M) -#endif -#ifndef HDfreopen -#define HDfreopen(S, M, F) freopen(S, M, F) -#endif #ifndef HDfrexp #define HDfrexp(X, N) frexp(X, N) #endif @@ -874,9 +712,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDfseek #define HDfseek(F, O, W) fseeko(F, O, W) #endif -#ifndef HDfsetpos -#define HDfsetpos(F, P) fsetpos(F, P) -#endif #ifndef HDfstat #define HDfstat(F, B) fstat(F, B) #endif @@ -886,15 +721,9 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDftruncate #define HDftruncate(F, L) ftruncate(F, L) #endif -#ifndef HDfwrite -#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F) -#endif #ifndef HDgetc #define HDgetc(F) getc(F) #endif -#ifndef HDgetchar -#define HDgetchar() getchar() -#endif #ifndef HDgetcwd #define HDgetcwd(S, Z) getcwd(S, Z) #endif @@ -907,51 +736,12 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #define HDgetdrive() 0 #endif -#ifndef HDgetegid -#define HDgetegid() getegid() -#endif #ifndef HDgetenv #define HDgetenv(S) getenv(S) #endif -#ifndef HDgeteuid -#define HDgeteuid() geteuid() -#endif -#ifndef HDgetgid -#define HDgetgid() getgid() -#endif -#ifndef HDgetgrgid -#define HDgetgrgid(G) getgrgid(G) -#endif -#ifndef HDgetgrnam -#define HDgetgrnam(S) getgrnam(S) -#endif -#ifndef HDgetgroups -#define HDgetgroups(Z, G) getgroups(Z, G) -#endif -#ifndef HDgethostbyaddr -#define HDgethostbyaddr(A, B, C) gethostbyaddr((A), (B), (C)) -#endif -#ifndef HDgethostname -#define HDgethostname(N, L) gethostname(N, L) -#endif -#ifndef HDgetpgrp -#define HDgetpgrp() getpgrp() -#endif #ifndef HDgetpid #define HDgetpid() getpid() #endif -#ifndef HDgetppid -#define HDgetppid() getppid() -#endif -#ifndef HDgetpwnam -#define HDgetpwnam(S) getpwnam(S) -#endif -#ifndef HDgetpwuid -#define HDgetpwuid(U) getpwuid(U) -#endif -#ifndef HDgetrusage -#define HDgetrusage(X, S) getrusage(X, S) -#endif /* Don't define HDgets - gets() was deprecated in C99 and removed in C11 */ #ifdef HDgets @@ -961,81 +751,21 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDgettimeofday #define HDgettimeofday(S, P) gettimeofday(S, P) #endif -#ifndef HDgetuid -#define HDgetuid() getuid() -#endif #ifndef HDgmtime #define HDgmtime(T) gmtime(T) #endif -#ifndef HDhtonl -#define HDhtonl(X) htonl((X)) -#endif -#ifndef HDhtons -#define HDhtons(X) htons((X)) -#endif -#ifndef HDinet_addr -#define HDinet_addr(C) inet_addr((C)) -#endif -#ifndef HDinet_ntoa -#define HDinet_ntoa(C) inet_ntoa((C)) -#endif -#ifndef HDisalnum -#define HDisalnum(C) isalnum((int)(C)) /* Cast for Solaris warning */ -#endif -#ifndef HDisalpha -#define HDisalpha(C) isalpha((int)(C)) /* Cast for Solaris warning */ -#endif #ifndef HDisatty #define HDisatty(F) isatty(F) #endif -#ifndef HDiscntrl -#define HDiscntrl(C) iscntrl((int)(C)) /* Cast for solaris warning */ -#endif -#ifndef HDisdigit -#define HDisdigit(C) isdigit((int)(C)) /* Cast for Solaris warning */ -#endif -#ifndef HDisgraph -#define HDisgraph(C) isgraph((int)(C)) /* Cast for Solaris warning*/ -#endif -#ifndef HDislower -#define HDislower(C) islower((int)(C)) /* Cast for Solaris warning */ -#endif #ifndef HDisnan #define HDisnan(X) isnan(X) #endif -#ifndef HDisprint -#define HDisprint(C) isprint((int)(C)) /* Cast for Solaris warning */ -#endif -#ifndef HDispunct -#define HDispunct(C) ispunct((int)(C)) /* Cast for Solaris warning */ -#endif -#ifndef HDisspace -#define HDisspace(C) isspace((int)(C)) /* Cast for Solaris warning */ -#endif -#ifndef HDisupper -#define HDisupper(C) isupper((int)(C)) /* Cast for Solaris warning */ -#endif -#ifndef HDisxdigit -#define HDisxdigit(C) isxdigit((int)(C)) /* Cast for Solaris warning */ -#endif -#ifndef HDkill -#define HDkill(P, S) kill(P, S) -#endif #ifndef HDlabs #define HDlabs(X) labs(X) #endif #ifndef HDldexp #define HDldexp(X, N) ldexp(X, N) #endif -#ifndef HDldiv -#define HDldiv(X, Y) ldiv(X, Y) -#endif -#ifndef HDlink -#define HDlink(OLD, NEW) link(OLD, NEW) -#endif -#ifndef HDlisten -#define HDlisten(A, B) listen((A), (B)) -#endif #ifndef HDllround #define HDllround(V) llround(V) #endif @@ -1045,9 +775,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDllroundl #define HDllroundl(V) llroundl(V) #endif -#ifndef HDlocaleconv -#define HDlocaleconv() localeconv() -#endif #ifndef HDlocaltime #define HDlocaltime(T) localtime(T) #endif @@ -1060,9 +787,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDlog10 #define HDlog10(X) log10(X) #endif -#ifndef HDlongjmp -#define HDlongjmp(J, N) longjmp(J, N) -#endif #ifndef HDlround #define HDlround(V) lround(V) #endif @@ -1078,75 +802,24 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDlstat #define HDlstat(S, B) lstat(S, B) #endif -#ifndef HDmalloc -#define HDmalloc(Z) malloc(Z) -#endif -#ifndef HDposix_memalign -#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z) -#endif -#ifndef HDmblen -#define HDmblen(S, N) mblen(S, N) -#endif -#ifndef HDmbstowcs -#define HDmbstowcs(P, S, Z) mbstowcs(P, S, Z) -#endif -#ifndef HDmbtowc -#define HDmbtowc(P, S, Z) mbtowc(P, S, Z) -#endif -#ifndef HDmemchr -#define HDmemchr(S, C, Z) memchr(S, C, Z) -#endif -#ifndef HDmemcmp -#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z) -#endif -#ifndef HDmemcpy -#define HDmemcpy(X, Y, Z) memcpy(X, Y, Z) -#endif -#ifndef HDmemmove -#define HDmemmove(X, Y, Z) memmove((char *)(X), (const char *)(Y), Z) -#endif -#ifndef HDmemset -#define HDmemset(X, C, Z) memset(X, C, Z) -#endif #ifndef HDmkdir #define HDmkdir(S, M) mkdir(S, M) #endif -#ifndef HDmkfifo -#define HDmkfifo(S, M) mkfifo(S, M) -#endif #ifndef HDmktime #define HDmktime(T) mktime(T) #endif -#ifndef HDmodf -#define HDmodf(X, Y) modf(X, Y) -#endif #ifndef HDnanosleep #define HDnanosleep(N, O) nanosleep(N, O) #endif -#ifndef HDntohl -#define HDntohl(A) ntohl((A)) -#endif -#ifndef HDntohs -#define HDntohs(A) ntohs((A)) -#endif #ifndef HDopen #define HDopen(F, ...) open(F, __VA_ARGS__) #endif #ifndef HDopendir #define HDopendir(S) opendir(S) #endif -#ifndef HDpathconf -#define HDpathconf(S, N) pathconf(S, N) -#endif -#ifndef HDpause -#define HDpause() pause() -#endif #ifndef HDperror #define HDperror(S) perror(S) #endif -#ifndef HDpipe -#define HDpipe(F) pipe(F) -#endif #ifndef HDpow #define HDpow(X, Y) pow(X, Y) #endif @@ -1156,9 +829,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDpread #define HDpread(F, B, C, O) pread(F, B, C, O) #endif -#ifndef HDprintf -#define HDprintf printf /*varargs*/ -#endif #ifndef HDputc #define HDputc(C, F) putc(C, F) #endif @@ -1171,12 +841,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDpwrite #define HDpwrite(F, B, C, O) pwrite(F, B, C, O) #endif -#ifndef HDqsort -#define HDqsort(M, N, Z, F) qsort(M, N, Z, F) -#endif -#ifndef HDraise -#define HDraise(N) raise(N) -#endif /* clang-format off */ #ifdef H5_HAVE_RAND_R @@ -1223,9 +887,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDreaddir #define HDreaddir(D) readdir(D) #endif -#ifndef HDrealloc -#define HDrealloc(M, Z) realloc(M, Z) -#endif #ifndef HDrealpath #define HDrealpath(F1, F2) realpath(F1, F2) #endif @@ -1238,9 +899,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDrewind #define HDrewind(F) rewind(F) #endif -#ifndef HDrewinddir -#define HDrewinddir(D) rewinddir(D) -#endif #ifndef HDround #define HDround(V) round(V) #endif @@ -1256,36 +914,12 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDscanf #define HDscanf scanf /*varargs*/ #endif -#ifndef HDselect -#define HDselect(N, RD, WR, ER, T) select(N, RD, WR, ER, T) -#endif #ifndef HDsetbuf #define HDsetbuf(F, S) setbuf(F, S) #endif #ifndef HDsetenv #define HDsetenv(N, V, O) setenv(N, V, O) #endif -#ifndef HDsetgid -#define HDsetgid(G) setgid(G) -#endif -#ifndef HDsetjmp -#define HDsetjmp(J) setjmp(J) -#endif -#ifndef HDsetlocale -#define HDsetlocale(N, S) setlocale(N, S) -#endif -#ifndef HDsetpgid -#define HDsetpgid(P, PG) setpgid(P, PG) -#endif -#ifndef HDsetsid -#define HDsetsid() setsid() -#endif -#ifndef HDsetsockopt -#define HDsetsockopt(A, B, C, D, E) setsockopt((A), (B), (C), (D), (E)) -#endif -#ifndef HDsetuid -#define HDsetuid(U) setuid(U) -#endif #ifndef HDsetvbuf #define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z) #endif @@ -1295,54 +929,18 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDsigaction #define HDsigaction(S, A, O) sigaction((S), (A), (O)) #endif -#ifndef HDsigaddset -#define HDsigaddset(S, N) sigaddset(S, N) -#endif -#ifndef HDsigdelset -#define HDsigdelset(S, N) sigdelset(S, N) -#endif #ifndef HDsigemptyset #define HDsigemptyset(S) sigemptyset(S) #endif -#ifndef HDsigfillset -#define HDsigfillset(S) sigfillset(S) -#endif -#ifndef HDsigismember -#define HDsigismember(S, N) sigismember(S, N) -#endif -#ifndef HDsiglongjmp -#define HDsiglongjmp(J, N) siglongjmp(J, N) -#endif #ifndef HDsignal #define HDsignal(N, F) signal(N, F) #endif -#ifndef HDsigpending -#define HDsigpending(S) sigpending(S) -#endif -#ifndef HDsigprocmask -#define HDsigprocmask(H, S, O) sigprocmask(H, S, O) -#endif -#ifndef HDsigsetjmp -#define HDsigsetjmp(J, N) sigsetjmp(J, N) -#endif -#ifndef HDsigsuspend -#define HDsigsuspend(S) sigsuspend(S) -#endif -#ifndef HDsin -#define HDsin(X) sin(X) -#endif -#ifndef HDsinh -#define HDsinh(X) sinh(X) -#endif #ifndef HDsleep #define HDsleep(N) sleep(N) #endif #ifndef HDsnprintf #define HDsnprintf snprintf /*varargs*/ #endif -#ifndef HDsocket -#define HDsocket(A, B, C) socket((A), (B), (C)) -#endif #ifndef HDsprintf #define HDsprintf sprintf /*varargs*/ #endif @@ -1374,9 +972,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDstrcasecmp #define HDstrcasecmp(X, Y) strcasecmp(X, Y) #endif -#ifndef HDstrcoll -#define HDstrcoll(X, Y) strcoll(X, Y) -#endif #ifndef HDstrcpy #define HDstrcpy(X, Y) strcpy(X, Y) #endif @@ -1410,126 +1005,39 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation); #ifndef HDstrndup #define HDstrndup(S, N) strndup(S, N) #endif -#ifndef HDstrpbrk -#define HDstrpbrk(X, Y) strpbrk(X, Y) -#endif #ifndef HDstrrchr #define HDstrrchr(S, C) strrchr(S, C) #endif -#ifndef HDstrspn -#define HDstrspn(X, Y) strspn(X, Y) -#endif #ifndef HDstrstr #define HDstrstr(X, Y) strstr(X, Y) #endif -#ifndef HDstrtod -#define HDstrtod(S, R) strtod(S, R) -#endif #ifndef HDstrtok #define HDstrtok(X, Y) strtok(X, Y) #endif #ifndef HDstrtok_r #define HDstrtok_r(X, Y, Z) strtok_r(X, Y, Z) #endif -#ifndef HDstrtol -#define HDstrtol(S, R, N) strtol(S, R, N) -#endif -#ifndef HDstrtoll -#define HDstrtoll(S, R, N) strtoll(S, R, N) -#endif -#ifndef HDstrtoul -#define HDstrtoul(S, R, N) strtoul(S, R, N) -#endif -#ifndef HDstrtoull -#define HDstrtoull(S, R, N) strtoull(S, R, N) -#endif -#ifndef HDstrtoumax -#define HDstrtoumax(S, R, N) strtoumax(S, R, N) -#endif -#ifndef HDstrxfrm -#define HDstrxfrm(X, Y, Z) strxfrm(X, Y, Z) -#endif -#ifndef HDsymlink -#define HDsymlink(F1, F2) symlink(F1, F2) -#endif -#ifndef HDsysconf -#define HDsysconf(N) sysconf(N) -#endif -#ifndef HDsystem -#define HDsystem(S) system(S) -#endif -#ifndef HDtan -#define HDtan(X) tan(X) -#endif -#ifndef HDtanh -#define HDtanh(X) tanh(X) -#endif -#ifndef HDtcdrain -#define HDtcdrain(F) tcdrain(F) -#endif -#ifndef HDtcflow -#define HDtcflow(F, A) tcflow(F, A) -#endif -#ifndef HDtcflush -#define HDtcflush(F, N) tcflush(F, N) -#endif -#ifndef HDtcgetattr -#define HDtcgetattr(F, T) tcgetattr(F, T) -#endif -#ifndef HDtcgetpgrp -#define HDtcgetpgrp(F) tcgetpgrp(F) -#endif -#ifndef HDtcsendbreak -#define HDtcsendbreak(F, N) tcsendbreak(F, N) -#endif -#ifndef HDtcsetattr -#define HDtcsetattr(F, O, T) tcsetattr(F, O, T) -#endif -#ifndef HDtcsetpgrp -#define HDtcsetpgrp(F, N) tcsetpgrp(F, N) -#endif #ifndef HDtime #define HDtime(T) time(T) #endif -#ifndef HDtimes -#define HDtimes(T) times(T) -#endif #ifndef HDtmpfile #define HDtmpfile() tmpfile() #endif -#ifndef HDtmpnam -#define HDtmpnam(S) tmpnam(S) -#endif #ifndef HDtolower #define HDtolower(C) tolower(C) #endif #ifndef HDtoupper #define HDtoupper(C) toupper(C) #endif -#ifndef HDttyname -#define HDttyname(F) ttyname(F) -#endif #ifndef HDtzset #define HDtzset() tzset() #endif -#ifndef HDumask -#define HDumask(N) umask(N) -#endif -#ifndef HDuname -#define HDuname(S) uname(S) -#endif -#ifndef HDungetc -#define HDungetc(C, F) ungetc(C, F) -#endif #ifndef HDunlink #define HDunlink(S) unlink(S) #endif #ifndef HDunsetenv #define HDunsetenv(S) unsetenv(S) #endif -#ifndef HDutime -#define HDutime(S, T) utime(S, T) -#endif #ifndef HDvasprintf #ifdef H5_HAVE_VASPRINTF @@ -1539,18 +1047,6 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); #endif #endif -#ifndef HDva_arg -#define HDva_arg(A, T) va_arg(A, T) -#endif -#ifndef HDva_copy -#define HDva_copy(D, S) va_copy(D, S) -#endif -#ifndef HDva_end -#define HDva_end(A) va_end(A) -#endif -#ifndef HDva_start -#define HDva_start(A, P) va_start(A, P) -#endif #ifndef HDvfprintf #define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A) #endif @@ -1563,18 +1059,6 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); #ifndef HDvsnprintf #define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) #endif -#ifndef HDwait -#define HDwait(W) wait(W) -#endif -#ifndef HDwaitpid -#define HDwaitpid(P, W, O) waitpid(P, W, O) -#endif -#ifndef HDwcstombs -#define HDwcstombs(S, P, Z) wcstombs(S, P, Z) -#endif -#ifndef HDwctomb -#define HDwctomb(S, C) wctomb(S, C) -#endif #ifndef HDwrite #define HDwrite(F, M, Z) write(F, M, Z) #endif @@ -1594,10 +1078,10 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); */ #ifndef NDEBUG #define H5_CHECK_OVERFLOW(var, vartype, casttype) \ - { \ + do { \ casttype _tmp_overflow = (casttype)(var); \ - HDassert((var) == (vartype)_tmp_overflow); \ - } + assert((var) == (vartype)_tmp_overflow); \ + } while (0) #else /* NDEBUG */ #define H5_CHECK_OVERFLOW(var, vartype, casttype) #endif /* NDEBUG */ @@ -1610,7 +1094,7 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); { \ srctype _tmp_src = (srctype)(src); \ dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ + assert(_tmp_src == (srctype)_tmp_dst); \ (dst) = _tmp_dst; \ } @@ -1620,8 +1104,8 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); { \ srctype _tmp_src = (srctype)(src); \ dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ + assert(_tmp_src >= 0); \ + assert(_tmp_src == (srctype)_tmp_dst); \ (dst) = _tmp_dst; \ } @@ -1631,8 +1115,8 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); { \ srctype _tmp_src = (srctype)(src); \ dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_dst >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ + assert(_tmp_dst >= 0); \ + assert(_tmp_src == (srctype)_tmp_dst); \ (dst) = _tmp_dst; \ } @@ -1640,8 +1124,8 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); { \ srctype _tmp_src = (srctype)(src); \ dsttype _tmp_dst = (dsttype)(_tmp_src); \ - HDassert(_tmp_src >= 0); \ - HDassert(_tmp_src == (srctype)_tmp_dst); \ + assert(_tmp_src >= 0); \ + assert(_tmp_src == (srctype)_tmp_dst); \ (dst) = _tmp_dst; \ } @@ -1663,10 +1147,15 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); * that will always generate the expected name. */ #define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ - ASSIGN_##srctype##_TO_##dsttype(dst, dsttype, src, srctype) + do { \ + ASSIGN_##srctype##_TO_##dsttype(dst, dsttype, src, srctype) \ + } while (0) #else /* NDEBUG */ -#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) (dst) = (dsttype)(src); +#define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ + do { \ + (dst) = (dsttype)(src); \ + } while (0) #endif /* NDEBUG */ #if defined(H5_HAVE_WINDOW_PATH) @@ -1676,8 +1165,8 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); #define H5_DIR_SEPC '\\' #define H5_DIR_SEPS "\\" #define H5_CHECK_DELIMITER(SS) ((SS == H5_DIR_SEPC) || (SS == H5_DIR_SLASH_SEPC)) -#define H5_CHECK_ABSOLUTE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':') && (H5_CHECK_DELIMITER(NAME[2]))) -#define H5_CHECK_ABS_DRIVE(NAME) ((HDisalpha(NAME[0])) && (NAME[1] == ':')) +#define H5_CHECK_ABSOLUTE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':') && (H5_CHECK_DELIMITER(NAME[2]))) +#define H5_CHECK_ABS_DRIVE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':')) #define H5_CHECK_ABS_PATH(NAME) (H5_CHECK_DELIMITER(NAME[0])) #define H5_GET_LAST_DELIMITER(NAME, ptr) \ @@ -1771,8 +1260,9 @@ extern hbool_t H5_coll_api_sanity_check_g; extern H5_debug_t H5_debug_g; #define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) -/* Do not use const else AIX strings does not show it. */ -extern char H5libhdf5_settings[]; /* embedded library information */ + +/* Embedded build information */ +extern const char H5libhdf5_settings[]; /*------------------------------------------------------------------------- * Purpose: These macros are inserted automatically just after the @@ -1914,34 +1404,34 @@ H5_DLL herr_t H5_trace_args(struct H5RS_str_t *rs, const char *type, va_list ap) * Handles H5XY_. */ #define H5_IS_API(S) \ - ('_' != ((const char *)S)[2] /* underscore at position 2 */ \ - && '_' != ((const char *)S)[3] /* underscore at position 3 */ \ - && !( /* NOT */ \ - ((const char *)S)[4] /* pos 4 exists */ \ - && (HDisupper(S[3]) || HDisdigit(S[3])) /* pos 3 dig | uc */ \ - && '_' == ((const char *)S)[4] /* pos 4 underscore */ \ + ('_' != ((const char *)S)[2] /* underscore at position 2 */ \ + && '_' != ((const char *)S)[3] /* underscore at position 3 */ \ + && !( /* NOT */ \ + ((const char *)S)[4] /* pos 4 exists */ \ + && (isupper(S[3]) || isdigit(S[3])) /* pos 3 dig | uc */ \ + && '_' == ((const char *)S)[4] /* pos 4 underscore */ \ )) /* `S' is the name of a function which is being tested to check if it's */ /* a public API function */ #define H5_IS_PUB(S) \ - (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && HDislower(S[3])) || \ - (!S[4] || ((HDisdigit(S[3]) || HDisupper(S[3])) && HDislower(S[4])))) + (((isdigit(S[1]) || isupper(S[1])) && islower(S[2])) || \ + ((isdigit(S[2]) || isupper(S[2])) && islower(S[3])) || \ + (!S[4] || ((isdigit(S[3]) || isupper(S[3])) && islower(S[4])))) /* `S' is the name of a function which is being tested to check if it's */ /* a private library function */ #define H5_IS_PRIV(S) \ - (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && HDislower(S[3])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && HDislower(S[4])) || \ - ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && HDislower(S[5]))) + (((isdigit(S[1]) || isupper(S[1])) && '_' == S[2] && islower(S[3])) || \ + ((isdigit(S[2]) || isupper(S[2])) && '_' == S[3] && islower(S[4])) || \ + ((isdigit(S[3]) || isupper(S[3])) && '_' == S[4] && islower(S[5]))) /* `S' is the name of a function which is being tested to check if it's */ /* a package private function */ #define H5_IS_PKG(S) \ - (((HDisdigit(S[1]) || HDisupper(S[1])) && '_' == S[2] && '_' == S[3] && HDislower(S[4])) || \ - ((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \ - ((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6]))) + (((isdigit(S[1]) || isupper(S[1])) && '_' == S[2] && '_' == S[3] && islower(S[4])) || \ + ((isdigit(S[2]) || isupper(S[2])) && '_' == S[3] && '_' == S[4] && islower(S[5])) || \ + ((isdigit(S[3]) || isupper(S[3])) && '_' == S[4] && '_' == S[5] && islower(S[6]))) /* global library version information string */ extern char H5_lib_vers_info_g[]; @@ -2027,9 +1517,9 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); \ if (!func_check) { \ /* Check function naming status */ \ - HDassert(asrt && \ - "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in " \ - "H5private.h (this is usually due to an incorrect number of underscores)"); \ + assert(asrt && \ + "Function naming conventions are incorrect - check H5_IS_API|PUB|PRIV|PKG macros in " \ + "H5private.h (this is usually due to an incorrect number of underscores)"); \ \ /* Don't check again */ \ func_check = TRUE; \ @@ -2469,6 +1959,9 @@ typedef union { const void *cvp; } H5_flexible_const_ptr_t; +/* File-independent encode/decode routines */ +#include "H5encode.h" + /* Private functions, not part of the publicly documented API */ H5_DLL herr_t H5_init_library(void); H5_DLL void H5_term_library(void); diff --git a/src/H5timer.c b/src/H5timer.c index bc50743..c0a945b 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -180,7 +180,7 @@ H5_now_usec(void) { struct timespec ts; - HDclock_gettime(CLOCK_MONOTONIC, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); /* Cast all values in this expression to uint64_t to ensure that all intermediate * calculations are done in 64 bit, to prevent overflow */ @@ -227,7 +227,7 @@ H5_get_time(void) { struct timespec ts; - HDclock_gettime(CLOCK_MONOTONIC, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); ret_value = (double)ts.tv_sec + ((double)ts.tv_nsec / 1000000000.0); } #elif defined(H5_HAVE_GETTIMEOFDAY) @@ -279,7 +279,7 @@ H5__timer_get_timevals(H5_timevals_t *times /*in,out*/) { struct rusage res; - if (HDgetrusage(RUSAGE_SELF, &res) < 0) + if (getrusage(RUSAGE_SELF, &res) < 0) return -1; times->system = (double)res.ru_stime.tv_sec + ((double)res.ru_stime.tv_usec / 1.0E6); times->user = (double)res.ru_utime.tv_sec + ((double)res.ru_utime.tv_usec / 1.0E6); diff --git a/src/H5trace.c b/src/H5trace.c index fb9a27c..0aa85ed 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -234,7 +234,7 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) asize[i] = -1; /* Parse the argument types */ - for (argno = 0; *type; argno++, type += (HDisupper(*type) ? 2 : 1)) { + for (argno = 0; *type; argno++, type += (isupper(*type) ? 2 : 1)) { /* Count levels of indirection */ for (ptr = 0; '*' == *type; type++) ptr++; @@ -244,7 +244,7 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) char *rest; if ('a' == type[1]) { - asize_idx = (int)HDstrtol(type + 2, &rest, 10); + asize_idx = (int)strtol(type + 2, &rest, 10); assert(0 <= asize_idx && asize_idx < (int)NELMTS(asize)); assert(']' == *rest); type = rest + 1; @@ -267,8 +267,6 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) argname = va_arg(ap, char *); if (argname) H5RS_asprintf_cat(rs, "%s%s=", argno ? ", " : "", argname); - else - argname = ""; /* A pointer/array */ if (ptr) { @@ -3906,7 +3904,7 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) break; default: - if (HDisupper(type[0])) + if (isupper(type[0])) H5RS_asprintf_cat(rs, "BADTYPE(%c%c)", type[0], type[1]); else H5RS_asprintf_cat(rs, "BADTYPE(%c)", type[0]); @@ -3960,8 +3958,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) hssize_t i; FILE *out = H5_debug_g.trace; static hbool_t is_first_invocation = TRUE; - H5_timer_t function_timer; - H5_timevals_t function_times = {0.0, 0.0, 0.0}; + H5_timer_t function_timer = {{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, FALSE}; + H5_timevals_t function_times = {0.0, 0.0, 0.0}; static H5_timer_t running_timer; H5_timevals_t running_times; static int current_depth = 0; diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 1b65c79..ba6028a 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -10,21 +10,22 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Purpose: This file is used to map HDF macros to Windows functions. This - * should get included H5private mappings, so as to override them. - * Any macro not mapped here, however, will receive a similar mapping - * inside H5private.h +/* Purpose: This file deals with Windows compatibility. MSVC is largely C99 + * compliant now, but we still need work-arounds for some POSIX + * things and MinGW. * + * This file must be included before the H5private.h HD mappings, so + * the definitions here will supersede them. */ -/* _MSC_VER = 192x VS2019 - * _MSC_VER = 191x VS2017 - * _MSC_VER = 1900 VS2015 - * _MSC_VER = 1800 VS2013 - * _MSC_VER = 1700 VS2012 - */ #ifdef H5_HAVE_WIN32_API +/* off_t exists on Windows, but is always a 32-bit long, even on 64-bit Windows, + * so we define HDoff_t to be __int64, which is the type of the st_size field + * of the _stati64 struct. + */ +#define HDoff_t __int64 + /* __int64 is the correct type for the st_size field of the _stati64 struct. * MSDN isn't very clear about this. */ @@ -32,38 +33,22 @@ typedef struct _stati64 h5_stat_t; typedef __int64 h5_stat_size_t; #ifdef H5_HAVE_VISUAL_STUDIO - struct timezone { int tz_minuteswest; int tz_dsttime; }; +#endif -#endif /* H5_HAVE_VISUAL_STUDIO */ - -#define HDaccess(F, M) _access(F, M) -#define HDchdir(S) _chdir(S) -#define HDclose(F) _close(F) #define HDcreat(S, M) Wopen_utf8(S, O_CREAT | O_TRUNC | O_RDWR, M) -#define HDdup(F) _dup(F) -#define HDfdopen(N, S) _fdopen(N, S) -#define HDfileno(F) _fileno(F) #define HDflock(F, L) Wflock(F, L) #define HDfstat(F, B) _fstati64(F, B) -#define HDgetcwd(S, Z) _getcwd(S, Z) #define HDgetdcwd(D, S, Z) _getdcwd(D, S, Z) #define HDgetdrive() _getdrive() #define HDgettimeofday(V, Z) Wgettimeofday(V, Z) -#define HDisatty(F) _isatty(F) #define HDlseek(F, O, W) _lseeki64(F, O, W) #define HDlstat(S, B) _lstati64(S, B) #define HDmkdir(S, M) _mkdir(S) -/* off_t exists on Windows, but is always a 32-bit long, even on 64-bit Windows, - * so we define HDoff_t to be __int64, which is the type of the st_size field - * of the _stati64 struct. - */ -#define HDoff_t __int64 - /* Note that the variadic HDopen macro is using a VC++ extension * where the comma is dropped if nothing is passed to the ellipsis. */ @@ -73,9 +58,7 @@ struct timezone { #define HDopen(S, F, ...) Wopen_utf8(S, F, ##__VA_ARGS__) #endif -#define HDread(F, M, Z) _read(F, M, Z) #define HDremove(S) Wremove_utf8(S) -#define HDrmdir(S) _rmdir(S) #define HDsetenv(N, V, O) Wsetenv(N, V, O) #define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2)) #define HDsleep(S) Sleep(S * 1000) @@ -84,19 +67,16 @@ struct timezone { #define HDstrcasestr(A, B) Wstrcasestr_wrap(A, B) #define HDstrndup(S, N) H5_strndup(S, N) #define HDstrtok_r(X, Y, Z) strtok_s(X, Y, Z) -#define HDtzset() _tzset() -#define HDunlink(S) _unlink(S) #define HDunsetenv(N) Wsetenv(N, "", 1) -#define HDwrite(F, M, Z) _write(F, M, Z) #ifndef H5_HAVE_MINGW #define HDftruncate(F, L) _chsize_s(F, L) #define HDfseek(F, O, W) _fseeki64(F, O, W) -#endif /* H5_HAVE_MINGW */ +#endif #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); H5_DLL int Wsetenv(const char *name, const char *value, int overwrite); H5_DLL int Wflock(int fd, int operation); @@ -109,6 +89,6 @@ H5_DLL char *H5_strndup(const char *s, size_t n); H5_DLL char *Wstrcasestr_wrap(const char *haystack, const char *needle); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif #endif /* H5_HAVE_WIN32_API */ diff --git a/src/Makefile.am b/src/Makefile.am index c546b89..81459a9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,7 +43,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5B.c H5Bcache.c H5Bdbg.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2hdr.c H5B2int.c H5B2internal.c \ H5B2leaf.c H5B2stat.c H5B2test.c \ - H5C.c H5Cdbg.c H5Cepoch.c H5Cimage.c H5Clog.c H5Clog_json.c H5Clog_trace.c \ + H5C.c H5Cdbg.c H5Centry.c H5Cepoch.c H5Cimage.c H5Cint.c \ + H5Clog.c H5Clog_json.c H5Clog_trace.c \ H5Cprefetched.c H5Cquery.c H5Ctag.c H5Ctest.c \ H5CS.c \ H5CX.c \ diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 32c82b9..f9e7928 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -1,5 +1,5 @@ - SUMMARY OF THE HDF5 CONFIGURATION - ================================= + SUMMARY OF THE HDF5 CONFIGURATION + ================================= General Information: ------------------- diff --git a/test/cache_common.h b/test/cache_common.h index 53f783e..8c54b5c 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -397,59 +397,40 @@ typedef struct test_entry_t { unsigned verify_ct; /* Count the # of checksum verification for an entry */ } test_entry_t; -/* The following are cut down test versions of the hash table manipulation - * macros from H5Cpkg.h, which have been further modified to avoid references - * to the error reporting macros. Needless to say, these macros must be - * updated as necessary. - */ - -#define H5C__HASH_MASK ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3) - #define H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - (!H5_addr_defined(Addr)) || (H5C__HASH_FCN(Addr) < 0) || \ - (H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN)) { \ - HDfprintf(stdout, "Pre HT search SC failed.\n"); \ + if (H5C__PRE_HT_SEARCH_SC_CMP(cache_ptr, Addr)) { \ + fprintf(stdout, "Pre HT search SC failed.\n"); \ } #define H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k) \ - if (((cache_ptr) == NULL) || ((cache_ptr)->magic != H5C__H5C_T_MAGIC) || ((cache_ptr)->index_len < 1) || \ - ((entry_ptr) == NULL) || ((cache_ptr)->index_size < (entry_ptr)->size) || \ - ((cache_ptr)->index_size != ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size)) || \ - ((entry_ptr)->size <= 0) || (((cache_ptr)->index)[k] == NULL) || \ - ((((cache_ptr)->index)[k] != (entry_ptr)) && ((entry_ptr)->ht_prev == NULL)) || \ - ((((cache_ptr)->index)[k] == (entry_ptr)) && ((entry_ptr)->ht_prev != NULL)) || \ - (((entry_ptr)->ht_prev != NULL) && ((entry_ptr)->ht_prev->ht_next != (entry_ptr))) || \ - (((entry_ptr)->ht_next != NULL) && ((entry_ptr)->ht_next->ht_prev != (entry_ptr)))) { \ - HDfprintf(stdout, "Post successful HT search SC failed.\n"); \ + if (H5C__POST_SUC_HT_SEARCH_SC_CMP(cache_ptr, entry_ptr, k)) { \ + fprintf(stdout, "Post successful HT search SC failed.\n"); \ } -#define H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k) \ - if (((cache_ptr) == NULL) || (((cache_ptr)->index)[k] != (entry_ptr)) || \ - ((entry_ptr)->ht_prev != NULL)) { \ - HDfprintf(stdout, "Post HT shift to front failed.\n"); \ +#define H5C_TEST__POST_HT_SHIFT_TO_FRONT_SC(cache_ptr, entry_ptr, k) \ + if (H5C__POST_HT_SHIFT_TO_FRONT_SC_CMP(cache_ptr, entry_ptr, k)) { \ + fprintf(stdout, "Post HT shift to front failed.\n"); \ } #define H5C_TEST__SEARCH_INDEX(cache_ptr, Addr, entry_ptr) \ { \ int k; \ H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr) \ - k = H5C__HASH_FCN(Addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ + k = H5C__HASH_FCN(Addr); \ + (entry_ptr) = (cache_ptr)->index[k]; \ while (entry_ptr) { \ if (H5_addr_eq(Addr, (entry_ptr)->addr)) { \ H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, k) \ - if (entry_ptr != ((cache_ptr)->index)[k]) { \ + if ((entry_ptr) != (cache_ptr)->index[k]) { \ if ((entry_ptr)->ht_next) \ (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev; \ assert((entry_ptr)->ht_prev != NULL); \ - (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ - ((cache_ptr)->index)[k]->ht_prev = (entry_ptr); \ - (entry_ptr)->ht_next = ((cache_ptr)->index)[k]; \ - (entry_ptr)->ht_prev = NULL; \ - ((cache_ptr)->index)[k] = (entry_ptr); \ - H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k) \ + (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next; \ + (cache_ptr)->index[k]->ht_prev = (entry_ptr); \ + (entry_ptr)->ht_next = (cache_ptr)->index[k]; \ + (entry_ptr)->ht_prev = NULL; \ + (cache_ptr)->index[k] = (entry_ptr); \ + H5C_TEST__POST_HT_SHIFT_TO_FRONT_SC(cache_ptr, entry_ptr, k) \ } \ break; \ } \ @@ -563,11 +544,6 @@ H5TEST_DLL void add_flush_op(int target_type, int target_idx, int op_code, int t H5TEST_DLL void addr_to_type_and_index(haddr_t addr, int32_t *type_ptr, int32_t *index_ptr); -#if 0 /* keep this for a while -- it may be useful */ -H5TEST_DLL haddr_t type_and_index_to_addr(int32_t type, - int32_t idx); -#endif - H5TEST_DLL void dirty_entry(H5F_t *file_ptr, int32_t type, int32_t idx, hbool_t dirty_pin); H5TEST_DLL void expunge_entry(H5F_t *file_ptr, int32_t type, int32_t idx); diff --git a/test/cache_image.c b/test/cache_image.c index ada65e4..2e95a97 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -717,10 +717,10 @@ open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, hbool_t read_onl */ if (pass) { - if (H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0) { + if (H5C__get_cache_image_config(cache_ptr, &image_ctl) < 0) { pass = FALSE; - failure_mssg = "error returned by H5C_get_cache_image_config()."; + failure_mssg = "error returned by H5C__get_cache_image_config()."; } } @@ -921,7 +921,7 @@ attempt_swmr_open_hdf5_file(const hbool_t create_file, const hbool_t set_mdci_fa { file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl_id); } - H5E_END_TRY; + H5E_END_TRY } else { @@ -929,7 +929,7 @@ attempt_swmr_open_hdf5_file(const hbool_t create_file, const hbool_t set_mdci_fa { file_id = H5Fopen(hdf_file_name, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl_id); } - H5E_END_TRY; + H5E_END_TRY } if (file_id >= 0) { diff --git a/test/hdfs.c b/test/hdfs.c index 3c4add5..52e2eae 100644 --- a/test/hdfs.c +++ b/test/hdfs.c @@ -1062,17 +1062,19 @@ test_H5FDread_without_eoa_set_fails(void) * TEST * ********/ - H5E_BEGIN_TRY{ - /* mute stack trace on expected failure */ - JSVERIFY(FAIL, H5FDread(file_shakespeare, H5FD_MEM_DRAW, H5P_DEFAULT, 1200699, 102, buffer), - "cannot read before eoa is set")} H5E_END_TRY for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++){ - JSVERIFY(0, (unsigned)buffer[i], "buffer was modified by write!")} + H5E_BEGIN_TRY{/* mute stack trace on expected failure */ + JSVERIFY(FAIL, H5FDread(file_shakespeare, H5FD_MEM_DRAW, H5P_DEFAULT, 1200699, 102, buffer), + "cannot read before eoa is set")} H5E_END_TRY + for (i = 0; i < HDFS_TEST_MAX_BUF_SIZE; i++) { + JSVERIFY(0, (unsigned)buffer[i], "buffer was modified by write!") + } /************ * TEARDOWN * ************/ - FAIL_IF(FAIL == H5FDclose(file_shakespeare)) file_shakespeare = NULL; + FAIL_IF(FAIL == H5FDclose(file_shakespeare)) + file_shakespeare = NULL; FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; @@ -1377,17 +1379,17 @@ test_noops_and_autofails(void) H5E_BEGIN_TRY{JSVERIFY(FAIL, H5FDwrite(file, H5FD_MEM_DRAW, H5P_DEFAULT, 1000, 35, data), "write must fail")} H5E_END_TRY - H5E_BEGIN_TRY{ - JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, FALSE), "truncate must fail")} H5E_END_TRY + H5E_BEGIN_TRY{JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, FALSE), "truncate must fail")} H5E_END_TRY - H5E_BEGIN_TRY{JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, TRUE), - "truncate must fail (closing)")} H5E_END_TRY + H5E_BEGIN_TRY{ + JSVERIFY(FAIL, H5FDtruncate(file, H5P_DEFAULT, TRUE), "truncate must fail (closing)")} H5E_END_TRY - /************ - * TEARDOWN * - ************/ + /************ + * TEARDOWN * + ************/ - FAIL_IF(FAIL == H5FDclose(file)) file = NULL; + FAIL_IF(FAIL == H5FDclose(file)) + file = NULL; FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; @@ -1504,14 +1506,13 @@ test_H5F_integration(void) */ H5E_BEGIN_TRY{FAIL_IF(0 <= H5Fopen(filename_example_h5, H5F_ACC_RDWR, fapl_id))} H5E_END_TRY - /* H5Fcreate() is not allowed with this file driver. - */ - H5E_BEGIN_TRY{ - FAIL_IF(0 <= H5Fcreate(filename_missing, H5F_ACC_RDONLY, H5P_DEFAULT, fapl_id))} H5E_END_TRY + /* H5Fcreate() is not allowed with this file driver. + */ + H5E_BEGIN_TRY{FAIL_IF(0 <= H5Fcreate(filename_missing, H5F_ACC_RDONLY, H5P_DEFAULT, fapl_id))} H5E_END_TRY - /* Successful open. - */ - file = H5Fopen(filename_example_h5, H5F_ACC_RDONLY, fapl_id); + /* Successful open. + */ + file = H5Fopen(filename_example_h5, H5F_ACC_RDONLY, fapl_id); FAIL_IF(file < 0) /************ diff --git a/test/ros3.c b/test/ros3.c index e7bc131..267aa0a 100644 --- a/test/ros3.c +++ b/test/ros3.c @@ -1087,7 +1087,8 @@ test_H5FDread_without_eoa_set_fails(void) * TEARDOWN * ************/ - FAIL_IF(FAIL == H5FDclose(file_shakespeare)) file_shakespeare = NULL; + FAIL_IF(FAIL == H5FDclose(file_shakespeare)) + file_shakespeare = NULL; FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; @@ -1396,7 +1397,8 @@ test_noops_and_autofails(void) * TEARDOWN * ************/ - FAIL_IF(FAIL == H5FDclose(file)) file = NULL; + FAIL_IF(FAIL == H5FDclose(file)) + file = NULL; FAIL_IF(FAIL == H5Pclose(fapl_id)) fapl_id = -1; diff --git a/testpar/t_cache_image.c b/testpar/t_cache_image.c index 8ce5662..f1f6f5d 100644 --- a/testpar/t_cache_image.c +++ b/testpar/t_cache_image.c @@ -1122,10 +1122,10 @@ open_hdf5_file(const hbool_t create_file, const hbool_t mdci_sbem_expected, cons */ if (pass) { - if (H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0) { + if (H5C__get_cache_image_config(cache_ptr, &image_ctl) < 0) { pass = FALSE; - failure_mssg = "error returned by H5C_get_cache_image_config()."; + failure_mssg = "error returned by H5C__get_cache_image_config()."; } } diff --git a/testpar/t_subfiling_vfd.c b/testpar/t_subfiling_vfd.c index 08e6e1f..8ac413a 100644 --- a/testpar/t_subfiling_vfd.c +++ b/testpar/t_subfiling_vfd.c @@ -212,7 +212,7 @@ test_create_and_close(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY VRFY((H5Pclose(fapl_id) >= 0), "FAPL close succeeded"); @@ -343,7 +343,7 @@ test_config_file(void) config_buf = malloc((size_t)config_file_len + 1); VRFY(config_buf, "malloc succeeded"); - VRFY((HDfread(config_buf, (size_t)config_file_len, 1, config_file) == 1), "HDfread succeeded"); + VRFY((fread(config_buf, (size_t)config_file_len, 1, config_file) == 1), "fread succeeded"); config_buf[config_file_len] = '\0'; /* Check the stripe_size field in the configuration file */ @@ -421,7 +421,7 @@ test_config_file(void) free(subfile_name); free(config_buf); - VRFY((HDfclose(config_file) >= 0), "HDfclose on configuration file succeeded"); + VRFY((fclose(config_file) >= 0), "fclose on configuration file succeeded"); } mpi_code_g = MPI_Barrier(comm_g); @@ -431,7 +431,7 @@ test_config_file(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY VRFY((H5Pclose(fapl_id) >= 0), "FAPL close succeeded"); @@ -572,7 +572,7 @@ test_stripe_sizes(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); /* Check file size */ VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded"); @@ -618,7 +618,7 @@ test_stripe_sizes(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); /* Check file size */ VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded"); @@ -644,7 +644,7 @@ test_stripe_sizes(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY VRFY((H5Pclose(fapl_id) >= 0), "FAPL close succeeded"); } @@ -738,7 +738,7 @@ test_stripe_sizes(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); /* Check file size */ VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded"); @@ -795,7 +795,7 @@ test_stripe_sizes(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); /* Check file size */ VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded"); @@ -822,7 +822,7 @@ test_stripe_sizes(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY free(write_buf); @@ -987,7 +987,7 @@ test_selection_strategies(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); } /* Ensure no extra subfiles are present */ @@ -1146,7 +1146,7 @@ test_read_different_stripe_size(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); /* Check file size */ VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded"); @@ -1217,7 +1217,7 @@ test_read_different_stripe_size(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); } else { /* Ensure file doesn't exist */ @@ -1234,7 +1234,7 @@ test_read_different_stripe_size(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY VRFY((H5Pclose(dxpl_id) >= 0), "DXPL close succeeded"); VRFY((H5Pclose(fapl_id) >= 0), "FAPL close succeeded"); @@ -1369,7 +1369,7 @@ test_subfiling_precreate_rank_0(void) /* Ensure file exists */ subfile_ptr = fopen(tmp_filename, "r"); VRFY(subfile_ptr, "fopen on subfile succeeded"); - VRFY((HDfclose(subfile_ptr) >= 0), "HDfclose on subfile succeeded"); + VRFY((fclose(subfile_ptr) >= 0), "fclose on subfile succeeded"); /* Check file size */ VRFY((HDstat(tmp_filename, &subfile_info) >= 0), "HDstat succeeded"); @@ -1436,7 +1436,7 @@ test_subfiling_precreate_rank_0(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY VRFY((H5Pclose(fapl_id) >= 0), "FAPL close succeeded"); VRFY((H5Pclose(dxpl_id) >= 0), "DXPL close succeeded"); @@ -1574,7 +1574,7 @@ test_subfiling_write_many_read_one(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY VRFY((H5Pclose(fapl_id) >= 0), "FAPL close succeeded"); } @@ -1760,7 +1760,7 @@ test_subfiling_write_many_read_few(void) { H5Fdelete(SUBF_FILENAME, fapl_id); } - H5E_END_TRY; + H5E_END_TRY VRFY((H5Pclose(fapl_id) >= 0), "FAPL close succeeded"); } @@ -1831,7 +1831,7 @@ test_subfiling_h5fuse(void) h5fuse_script = fopen("h5fuse.sh", "r"); if (h5fuse_script) - HDfclose(h5fuse_script); + fclose(h5fuse_script); else skip_test = 1; } @@ -1924,8 +1924,8 @@ test_subfiling_h5fuse(void) pid_t tmppid; int status; - pid = HDfork(); - VRFY(pid >= 0, "HDfork succeeded"); + pid = fork(); + VRFY(pid >= 0, "fork succeeded"); if (pid == 0) { char *tmp_filename; @@ -1947,11 +1947,11 @@ test_subfiling_h5fuse(void) args[6] = NULL; /* Call h5fuse script from MPI rank 0 */ - HDexecvp("env", args); + execvp("env", args); } else { - tmppid = HDwaitpid(pid, &status, 0); - VRFY(tmppid >= 0, "HDwaitpid succeeded"); + tmppid = waitpid(pid, &status, 0); + VRFY(tmppid >= 0, "waitpid succeeded"); if (WIFEXITED(status)) { int ret; @@ -2073,13 +2073,13 @@ parse_subfiling_env_vars(void) char *env_value; if (NULL != (env_value = HDgetenv(H5FD_SUBFILING_STRIPE_SIZE))) { - stripe_size_g = HDstrtoll(env_value, NULL, 0); + stripe_size_g = strtoll(env_value, NULL, 0); if ((ERANGE == errno) || (stripe_size_g <= 0)) stripe_size_g = -1; } if (NULL != (env_value = HDgetenv(H5FD_SUBFILING_IOC_PER_NODE))) { - ioc_per_node_g = HDstrtol(env_value, NULL, 0); + ioc_per_node_g = strtol(env_value, NULL, 0); if ((ERANGE == errno) || (ioc_per_node_g <= 0)) ioc_per_node_g = -1; else if (ioc_per_node_g * num_nodes_g > mpi_size) diff --git a/utils/Makefile.am b/utils/Makefile.am index cd63db4..229712e 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -41,4 +41,6 @@ endif # All subdirectories SUBDIRS=$(MIRROR_VFD_DIR) $(TESTUTIL_DIR) $(TOOLS_DIR) +bin_SCRIPTS = subfiling_vfd/h5fuse.sh + include $(top_srcdir)/config/conclude.am -- cgit v0.12