diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2023-04-22 06:25:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 06:25:12 (GMT) |
commit | 7707859279a60b32d2b6c915442a7c04d44445b4 (patch) | |
tree | 890d16aa2408b270368b36ea4f05ca20fe2f16f6 /src | |
parent | a4371b6fce577852691dfdeac642dec1dd4b9453 (diff) | |
download | hdf5-7707859279a60b32d2b6c915442a7c04d44445b4.zip hdf5-7707859279a60b32d2b6c915442a7c04d44445b4.tar.gz hdf5-7707859279a60b32d2b6c915442a7c04d44445b4.tar.bz2 |
Merge with develop (#2790)
Diffstat (limited to 'src')
155 files changed, 1788 insertions, 4036 deletions
@@ -312,7 +312,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cleaned entry list") } /* end if */ - /* construct the candidate slist for all processes. + /* construct the candidate skip list for all processes. * when the distributed strategy is selected as all processes * will use it in the case of a flush. */ @@ -413,14 +413,6 @@ done: * Programmer: Robb Matzke * Jul 9 1997 * - * Changes: - * - * In the parallel case, added code to setup the MDC slist - * before the call to H5AC__flush_entries() and take it down - * afterwards. - * - * JRM -- 7/29/20 - * *------------------------------------------------------------------------- */ herr_t @@ -447,34 +439,25 @@ H5AC_dest(H5F_t *f) /* Check if log messages are being emitted */ if (H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to get logging status") - if (log_enabled && curr_logging) { - - if (H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) - - HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") - } /* Tear down logging */ if (log_enabled) { + if (curr_logging) + if (H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") if (H5C_log_tear_down(f->shared->cache) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") - } + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "metadata cache logging tear-down failed") + } /* end if */ #ifdef H5_HAVE_PARALLEL - /* destroying the cache, so clear all collective entries */ if (H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't clear collective entries") aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); - if (aux_ptr) { - /* Sanity check */ HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -488,7 +471,7 @@ H5AC_dest(H5F_t *f) * H5AC__flush_entries() and disable it afterwards, as the * skip list will be disabled after the previous flush. * - * Note that H5C_dest() does slist setup and take down as well. + * Note that H5C_dest() does skip list setup and take down as well. * Unfortunately, we can't do the setup and take down just once, * as H5C_dest() is called directly in the test code. * @@ -496,59 +479,45 @@ H5AC_dest(H5F_t *f) * point, so the overhead should be minimal. */ if (H5F_ACC_RDWR & H5F_INTENT(f)) { - - /* enable and load the slist */ + /* enable and load the skip list */ if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't enable skip list") if (H5AC__flush_entries(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush") - /* disable the slist -- should be empty */ + /* disable the skip list -- should be empty */ if (H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist failed") - } - } -#endif /* H5_HAVE_PARALLEL */ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't disable skip list") + } /* end if */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ /* Destroy the cache */ if (H5C_dest(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't destroy cache") f->shared->cache = NULL; #ifdef H5_HAVE_PARALLEL - if (aux_ptr != NULL) { - if (aux_ptr->d_slist_ptr != NULL) { - HDassert(H5SL_count(aux_ptr->d_slist_ptr) == 0); H5SL_close(aux_ptr->d_slist_ptr); - } /* end if */ if (aux_ptr->c_slist_ptr != NULL) { - HDassert(H5SL_count(aux_ptr->c_slist_ptr) == 0); H5SL_close(aux_ptr->c_slist_ptr); - } /* end if */ if (aux_ptr->candidate_slist_ptr != NULL) { - HDassert(H5SL_count(aux_ptr->candidate_slist_ptr) == 0); H5SL_close(aux_ptr->candidate_slist_ptr); - } /* end if */ aux_ptr->magic = 0; aux_ptr = H5FL_FREE(H5AC_aux_t, aux_ptr); - } /* end if */ #endif /* H5_HAVE_PARALLEL */ @@ -1191,13 +1160,12 @@ done: * * Function: H5AC_prep_for_file_flush * - * Purpose: This function should be called just prior to the first - * call to H5AC_flush() during a file flush. + * Purpose: Handle any setup required prior to metadata cache flush. * - * Its purpose is to handly any setup required prior to - * metadata cache flush. + * This function should be called just prior to the first + * call to H5AC_flush() during a file flush. * - * Initially, this means setting up the slist prior to the + * Initially, this means setting up the skip list prior to the * flush. We do this in a separate call because * H5F__flush_phase2() make repeated calls to H5AC_flush(). * Handling this detail in separate calls allows us to avoid @@ -1209,8 +1177,6 @@ done: * Programmer: John Mainzer * 5/5/20 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -1226,13 +1192,10 @@ H5AC_prep_for_file_flush(H5F_t *f) HDassert(f->shared->cache); if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist enabled failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't enable skip list") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5AC_prep_for_file_flush() */ /*------------------------------------------------------------------------- @@ -1242,14 +1205,11 @@ done: * Purpose: This function should be called just after the last * call to H5AC_flush() during a file flush. * - * Its purpose is to perform any necessary cleanup after the - * metadata cache flush. - * * The objective of the call is to allow the metadata cache * to do any necessary necessary cleanup work after a cache * flush. * - * Initially, this means taking down the slist after the + * Initially, this means taking down the skip list after the * flush. We do this in a separate call because * H5F__flush_phase2() make repeated calls to H5AC_flush(). * Handling this detail in separate calls allows us to avoid @@ -1261,8 +1221,6 @@ done: * Programmer: John Mainzer * 5/5/20 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -1278,13 +1236,10 @@ H5AC_secure_from_file_flush(H5F_t *f) HDassert(f->shared->cache); if (H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist enabled failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't disable skip list") done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5AC_secure_from_file_flush() */ /*------------------------------------------------------------------------- @@ -1474,24 +1429,6 @@ H5AC_resize_entry(void *thing, size_t new_size) * amounts of dirty metadata creation in other areas -- which will * cause aux_ptr->dirty_bytes to be incremented. * - * The bottom line is that this code is probably OK, but the above - * points should be kept in mind. - * - * One final observation: This comment is occasioned by a bug caused - * by moving the call to H5AC__log_dirtied_entry() after the call to - * H5C_resize_entry(), and then only calling H5AC__log_dirtied_entry() - * if entry_ptr->is_dirty was false. - * - * Since H5C_resize_entry() marks the target entry dirty unless there - * is not change in size, this had the effect of not calling - * H5AC__log_dirtied_entry() when it should be, and corrupting - * the cleaned and dirtied lists used by rank 0 in the parallel - * version of the metadata cache. - * - * The point here is that you should be very careful when working with - * this code, and not modify it unless you fully understand it. - * - * JRM -- 2/28/22 */ if ((!entry_ptr->is_dirty) && (entry_ptr->size != new_size)) { diff --git a/src/H5ACmodule.h b/src/H5ACmodule.h index a7f9a27..1ce26f6 100644 --- a/src/H5ACmodule.h +++ b/src/H5ACmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5AC package. Including this header means that the source file - * is part of the H5AC package. + * Purpose: This file contains declarations which define macros for the + * H5AC package. Including this header means that the source file + * is part of the H5AC package. */ #ifndef H5ACmodule_H #define H5ACmodule_H diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index 197cc3c..e103a26 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -1860,8 +1860,6 @@ done: * Programmer: John Mainzer * April 28, 2010 * - * Changes: None. - * *------------------------------------------------------------------------- */ static herr_t @@ -1890,12 +1888,9 @@ H5AC__rsp__p0_only__flush(H5F_t *f) * However, when flushing from within the close operation from a file, * it's possible to skip this barrier (on the second flush of the cache). */ - if (!H5CX_get_mpi_file_flushing()) { - + if (!H5CX_get_mpi_file_flushing()) if (MPI_SUCCESS != (mpi_result = MPI_Barrier(aux_ptr->mpi_comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_result) - } /* Flush data to disk, from rank 0 process */ if (aux_ptr->mpi_rank == 0) { @@ -2104,31 +2099,28 @@ H5AC__run_sync_point(H5F_t *f, int sync_point_op) /* Sanity checks */ HDassert(f != NULL); - cache_ptr = f->shared->cache; - HDassert(cache_ptr != NULL); - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert((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 - HDfprintf(stdout, "%d:H5AC_propagate...:%u: (u/uu/i/iu/m/mu) = %zu/%u/%zu/%u/%zu/%u\n", aux_ptr->mpi_rank, + HDfprintf(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); #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ - /* clear collective access flag on half of the entries in the - cache and mark them as independent in case they need to be - evicted later. All ranks are guaranteed to mark the same entries - since we don't modify the order of the collectively accessed - entries except through collective access. */ + /* Clear collective access flag on half of the entries in the cache and + * mark them as independent in case they need to be evicted later. All + * ranks are guaranteed to mark the same entries since we don't modify the + * order of the collectively accessed entries except through collective + * access. + */ if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed.") @@ -2190,7 +2182,6 @@ H5AC__run_sync_point(H5F_t *f, int sync_point_op) #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ done: - FUNC_LEAVE_NOAPI(ret_value) } /* H5AC__run_sync_point() */ diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 8ccab4e..beb7ba7 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -11,18 +11,15 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: John Mainzer -- 4/19/06 + * Purpose: This file contains declarations which are normally visible + * only within the H5AC package (just H5AC.c at present). * - * Purpose: This file contains declarations which are normally visible - * only within the H5AC package (just H5AC.c at present). - * - * Source files outside the H5AC package should include - * H5ACprivate.h instead. - * - * The one exception to this rule is testpar/t_cache.c. The - * test code is easier to write if it can look at H5AC_aux_t. - * Indeed, this is the main reason why this file was created. + * Source files outside the H5AC package should include + * H5ACprivate.h instead. * + * The one exception to this rule is testpar/t_cache.c. The + * test code is easier to write if it can look at H5AC_aux_t. + * Indeed, this is the main reason why this file was created. */ #if !(defined H5AC_FRIEND || defined H5AC_MODULE) diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index 0967f77..5dc65c7 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -466,7 +466,7 @@ typedef struct H5AC_cache_config_t { /* general configuration fields: */ //! <!-- [H5AC_cache_config_t_general_snip] --> int version; - /**< Integer field indicating the the version of the H5AC_cache_config_t + /**< Integer field indicating the version of the H5AC_cache_config_t * in use. This field should be set to #H5AC__CURR_CACHE_CONFIG_VERSION * (defined in H5ACpublic.h). */ diff --git a/src/H5Amodule.h b/src/H5Amodule.h index 4823d0d..75a4c8c 100644 --- a/src/H5Amodule.h +++ b/src/H5Amodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5A package. Including this header means that the source file - * is part of the H5A package. + * Purpose: This file contains declarations which define macros for the + * H5A package. Including this header means that the source file + * is part of the H5A package. */ #ifndef H5Amodule_H #define H5Amodule_H diff --git a/src/H5Apkg.h b/src/H5Apkg.h index 49dfda2..3a5c411 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Monday, Apr 20 - * * Purpose: This file contains declarations which are visible only within * the H5A package. Source files outside the H5A package should * include H5Aprivate.h instead. diff --git a/src/H5Apublic.h b/src/H5Apublic.h index e21e808..92df94a 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -127,7 +127,7 @@ H5_DLL herr_t H5Aclose_async(hid_t attr_id, hid_t es_id); * The attribute identifier returned by this function must be released * with H5Aclose() resource leaks will develop. * - * \note If \p loc_id is a file identifier, the attribute will be attached + * \note If \p loc_id is a file identifier, the attribute will be attached to * that file’s root group. * * \par Example @@ -246,8 +246,8 @@ H5_DLL herr_t H5Adelete(hid_t loc_id, const char *attr_name); * \param[in] obj_name Name of object, relative to location, from which * attribute is to be removed * \param[in] idx_type Type of index - * \param[in] order Order in which to iterate over index - * \param[in] n Offset within index + * \param[in] order Order in which to iterate over the index + * \param[in] n Offset within the index * \lapl_id * * \return \herr_t @@ -264,7 +264,7 @@ H5_DLL herr_t H5Adelete(hid_t loc_id, const char *attr_name); * The order in which the index is to be traversed is specified by * \p order. For example, if \p idx_type, \p order, * and \p n are set to #H5_INDEX_NAME, #H5_ITER_INC, and 5, - * respectively, the fifth attribute in lexicographic order of + * respectively, the fifth attribute in the lexicographic order of * attribute names will be removed. * * The link access property list, \p lapl_id, may provide @@ -354,7 +354,7 @@ H5_DLL herr_t H5Aexists_async(hid_t obj_id, const char *attr_name, hbool_t *exis * \p loc_id specifies a location in the file containing the object. * \p obj_name is the name of the object to which the attribute is * attached and can be a relative name, relative to \p loc_id, - * or an absolute name, based in the root group of the file. + * or an absolute name, based on the root group of the file. * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access @@ -403,7 +403,7 @@ H5_DLL hid_t H5Aget_create_plist(hid_t attr_id); /** * \ingroup H5A * - * \brief Retrieves attribute information, by attribute identifier + * \brief Retrieves attribute information by attribute identifier * * \attr_id * \param[out] ainfo Attribute information struct @@ -438,7 +438,7 @@ H5_DLL herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/); * \details H5Aget_info_by_idx() retrieves information for an attribute * that is attached to an object, which is specified by its * location and name, \p loc_id and \p obj_name, respectively. - * The attribute is located by its index position and the attribute + * The attribute is located by its index position, and the attribute * information is returned in the \p ainfo struct. * * The attribute is located by means of an index type, an index @@ -458,7 +458,7 @@ H5_DLL herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t /** * \ingroup H5A * - * \brief Retrieves attribute information, by attribute name + * \brief Retrieves attribute information by attribute name * * \fgdt_loc_id * \param[in] obj_name Name of the object to which an attribute is attached, @@ -494,7 +494,7 @@ H5_DLL herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char * \param[out] buf Buffer to store name in * * \return Returns the length of the attribute's name, which may be longer - * than \p buf_size, if successful. Otherwise returns a negative + * than \p buf_size, if successful. Otherwise, returns a negative * value. * * \details H5Aget_name() retrieves the name of an attribute specified by @@ -529,7 +529,7 @@ H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); * \lapl_id * * \return Returns attribute name size, in bytes, if successful; - * otherwise returns a negative value. + * otherwise, returns a negative value. * * \details H5Aget_name_by_idx() retrieves the name of an attribute that is * attached to an object, which is specified by its location and @@ -584,7 +584,7 @@ H5_DLL hid_t H5Aget_space(hid_t attr_id); * \attr_id * * \return Returns the amount of storage size allocated for the attribute; - * otherwise returns 0 (zero). + * otherwise, returns 0 (zero). * * \details H5Aget_storage_size() returns the amount of storage that is * required for the specified attribute, \p attr_id. @@ -687,7 +687,7 @@ H5_DLL herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t ord * * \return \herr_t * Further note that this function returns the return value of - * the last operator if it was non-zero, which can be a negative + * the last operator if it is non-zero, which can be a negative * value, zero if all attributes were processed, or a positive value * indicating short-circuit success. * @@ -1150,7 +1150,7 @@ H5_DLL hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t spa * * \fgdt_loc_id * - * \return Returns the number of attributes if successful; otherwise returns + * \return Returns the number of attributes if successful; otherwise, returns * a negative value. * * \deprecation_note{H5Oget_info(), H5Oget_info_by_name(), and H5Oget_info_by_idx()} @@ -1207,8 +1207,8 @@ H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *idx, H5A_operator1_t op, void * * \deprecation_note{H5Aopen_by_idx()} * - * \details H5Aopen_idx() opens an attribute which is attached to the - * object specified with \p loc_id . The location object may be + * \details H5Aopen_idx() opens an attribute that is attached to the + * object specified with \p loc_id. The location object may be * either a group, dataset, or named datatype, all of which may * have any sort of attribute. The attribute specified by the index, * \p idx , indicates the attribute to access. The value of \p idx diff --git a/src/H5B2module.h b/src/H5B2module.h index 6a3131b..8eaea2f 100644 --- a/src/H5B2module.h +++ b/src/H5B2module.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5B2 package. Including this header means that the source file - * is part of the H5B2 package. + * Purpose: This file contains declarations which define macros for the + * H5B2 package. Including this header means that the source file + * is part of the H5B2 package. */ #ifndef H5B2module_H #define H5B2module_H diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 626ae2f..668ea5d 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Monday, January 31, 2005 - * - * Purpose: This file contains declarations which are visible only within - * the H5B2 package. Source files outside the H5B2 package should - * include H5B2private.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5B2 package. Source files outside the H5B2 package should + * include H5B2private.h instead. */ #if !(defined H5B2_FRIEND || defined H5B2_MODULE) #error "Do not include this file outside the H5B2 package!" diff --git a/src/H5Bmodule.h b/src/H5Bmodule.h index 9c0f73b..0ded756 100644 --- a/src/H5Bmodule.h +++ b/src/H5Bmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5B package. Including this header means that the source file - * is part of the H5B package. + * Purpose: This file contains declarations which define macros for the + * H5B package. Including this header means that the source file + * is part of the H5B package. */ #ifndef H5Bmodule_H #define H5Bmodule_H diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 3147315..ef9f56e 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Thursday, May 15, 2003 - * - * Purpose: This file contains declarations which are visible only within - * the H5B package. Source files outside the H5B package should - * include H5Bprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5B package. Source files outside the H5B package should + * include H5Bprivate.h instead. */ #if !(defined H5B_FRIEND || defined H5B_MODULE) #error "Do not include this file outside the H5B package!" @@ -93,43 +93,30 @@ typedef H5C_cache_entry_t *H5C_cache_entry_ptr_t; /********************/ 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, +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); @@ -179,88 +166,11 @@ H5FL_SEQ_DEFINE_STATIC(H5C_cache_entry_ptr_t); * flag to determine whether writes are permitted. * * Return: Success: Pointer to the new instance. - * * Failure: NULL * * Programmer: John Mainzer * 6/2/04 * - * Modifications: - * - * JRM -- 7/20/04 - * Updated for the addition of the hash table. - * - * JRM -- 10/5/04 - * Added call to H5C_reset_cache_hit_rate_stats(). Also - * added initialization for cache_is_full flag and for - * resize_ctl. - * - * JRM -- 11/12/04 - * Added initialization for the new size_decreased field. - * - * JRM -- 11/17/04 - * Added/updated initialization for the automatic cache - * size control data structures. - * - * JRM -- 6/24/05 - * Added support for the new write_permitted field of - * the H5C_t structure. - * - * JRM -- 7/5/05 - * Added the new log_flush parameter and supporting code. - * - * JRM -- 9/21/05 - * Added the new aux_ptr parameter and supporting code. - * - * JRM -- 1/20/06 - * Added initialization of the new prefix field in H5C_t. - * - * JRM -- 3/16/06 - * Added initialization for the pinned entry related fields. - * - * JRM -- 5/31/06 - * Added initialization for the trace_file_ptr field. - * - * JRM -- 8/19/06 - * Added initialization for the flush_in_progress field. - * - * JRM -- 8/25/06 - * Added initialization for the slist_len_increase and - * slist_size_increase fields. These fields are used - * for sanity checking in the flush process, and are not - * compiled in unless H5C_DO_SANITY_CHECKS is TRUE. - * - * JRM -- 3/28/07 - * Added initialization for the new is_read_only and - * ro_ref_count fields. - * - * JRM -- 7/27/07 - * Added initialization for the new evictions_enabled - * field of H5C_t. - * - * JRM -- 12/31/07 - * Added initialization for the new flash cache size increase - * related fields of H5C_t. - * - * JRM -- 11/5/08 - * Added initialization for the new clean_index_size and - * dirty_index_size fields of H5C_t. - * - * - * Missing entries? - * - * - * JRM -- 4/20/20 - * Added initialization for the slist_enabled field. Recall - * that the slist is used to flush metadata cache entries - * in (roughly) increasing address order. While this is - * needed at flush and close, it is not used elsewhere. - * The slist_enabled field exists to allow us to construct - * the slist when needed, and leave it empty otherwise -- thus - * avoiding the overhead of maintaining it. - * - * JRM -- 4/29/20 - * *------------------------------------------------------------------------- */ H5C_t * @@ -351,7 +261,7 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, cache_ptr->num_objs_corked = 0; /* slist field initializations */ - cache_ptr->slist_enabled = !H5C__SLIST_OPT_ENABLED; + cache_ptr->slist_enabled = FALSE; cache_ptr->slist_changed = FALSE; cache_ptr->slist_len = 0; cache_ptr->slist_size = (size_t)0; @@ -414,33 +324,33 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, cache_ptr->resize_in_progress = FALSE; cache_ptr->msic_in_progress = FALSE; - (cache_ptr->resize_ctl).version = H5C__CURR_AUTO_SIZE_CTL_VER; - (cache_ptr->resize_ctl).rpt_fcn = NULL; - (cache_ptr->resize_ctl).set_initial_size = FALSE; - (cache_ptr->resize_ctl).initial_size = H5C__DEF_AR_INIT_SIZE; - (cache_ptr->resize_ctl).min_clean_fraction = H5C__DEF_AR_MIN_CLEAN_FRAC; - (cache_ptr->resize_ctl).max_size = H5C__DEF_AR_MAX_SIZE; - (cache_ptr->resize_ctl).min_size = H5C__DEF_AR_MIN_SIZE; - (cache_ptr->resize_ctl).epoch_length = H5C__DEF_AR_EPOCH_LENGTH; - - (cache_ptr->resize_ctl).incr_mode = H5C_incr__off; - (cache_ptr->resize_ctl).lower_hr_threshold = H5C__DEF_AR_LOWER_THRESHHOLD; - (cache_ptr->resize_ctl).increment = H5C__DEF_AR_INCREMENT; - (cache_ptr->resize_ctl).apply_max_increment = TRUE; - (cache_ptr->resize_ctl).max_increment = H5C__DEF_AR_MAX_INCREMENT; - - (cache_ptr->resize_ctl).flash_incr_mode = H5C_flash_incr__off; - (cache_ptr->resize_ctl).flash_multiple = 1.0; - (cache_ptr->resize_ctl).flash_threshold = 0.25; - - (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; - (cache_ptr->resize_ctl).upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; - (cache_ptr->resize_ctl).decrement = H5C__DEF_AR_DECREMENT; - (cache_ptr->resize_ctl).apply_max_decrement = TRUE; - (cache_ptr->resize_ctl).max_decrement = H5C__DEF_AR_MAX_DECREMENT; - (cache_ptr->resize_ctl).epochs_before_eviction = H5C__DEF_AR_EPCHS_B4_EVICT; - (cache_ptr->resize_ctl).apply_empty_reserve = TRUE; - (cache_ptr->resize_ctl).empty_reserve = H5C__DEF_AR_EMPTY_RESERVE; + cache_ptr->resize_ctl.version = H5C__CURR_AUTO_SIZE_CTL_VER; + cache_ptr->resize_ctl.rpt_fcn = NULL; + cache_ptr->resize_ctl.set_initial_size = FALSE; + cache_ptr->resize_ctl.initial_size = H5C__DEF_AR_INIT_SIZE; + cache_ptr->resize_ctl.min_clean_fraction = H5C__DEF_AR_MIN_CLEAN_FRAC; + cache_ptr->resize_ctl.max_size = H5C__DEF_AR_MAX_SIZE; + cache_ptr->resize_ctl.min_size = H5C__DEF_AR_MIN_SIZE; + cache_ptr->resize_ctl.epoch_length = H5C__DEF_AR_EPOCH_LENGTH; + + cache_ptr->resize_ctl.incr_mode = H5C_incr__off; + cache_ptr->resize_ctl.lower_hr_threshold = H5C__DEF_AR_LOWER_THRESHHOLD; + cache_ptr->resize_ctl.increment = H5C__DEF_AR_INCREMENT; + cache_ptr->resize_ctl.apply_max_increment = TRUE; + cache_ptr->resize_ctl.max_increment = H5C__DEF_AR_MAX_INCREMENT; + + cache_ptr->resize_ctl.flash_incr_mode = H5C_flash_incr__off; + cache_ptr->resize_ctl.flash_multiple = 1.0; + cache_ptr->resize_ctl.flash_threshold = 0.25; + + cache_ptr->resize_ctl.decr_mode = H5C_decr__off; + cache_ptr->resize_ctl.upper_hr_threshold = H5C__DEF_AR_UPPER_THRESHHOLD; + cache_ptr->resize_ctl.decrement = H5C__DEF_AR_DECREMENT; + cache_ptr->resize_ctl.apply_max_decrement = TRUE; + cache_ptr->resize_ctl.max_decrement = H5C__DEF_AR_MAX_DECREMENT; + cache_ptr->resize_ctl.epochs_before_eviction = H5C__DEF_AR_EPCHS_B4_EVICT; + cache_ptr->resize_ctl.apply_empty_reserve = TRUE; + cache_ptr->resize_ctl.empty_reserve = H5C__DEF_AR_EMPTY_RESERVE; cache_ptr->epoch_markers_active = 0; @@ -561,12 +471,11 @@ H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, break; case increase: - HDassert(hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold); + HDassert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); HDassert(old_max_cache_size < new_max_cache_size); HDfprintf(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); - + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); HDfprintf(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; @@ -575,9 +484,7 @@ H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, HDassert(old_max_cache_size < new_max_cache_size); HDfprintf(stdout, "%sflash cache resize(%d) -- size threshold = %zu.\n", cache_ptr->prefix, - (int)((cache_ptr->resize_ctl).flash_incr_mode), - cache_ptr->flash_size_increase_threshold); - + (int)(cache_ptr->resize_ctl.flash_incr_mode), cache_ptr->flash_size_increase_threshold); HDfprintf(stdout, "%s cache size increased from (%zu/%zu) to (%zu/%zu).\n", cache_ptr->prefix, old_max_cache_size, old_min_clean_size, new_max_cache_size, new_min_clean_size); break; @@ -585,20 +492,19 @@ H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, case decrease: HDassert(old_max_cache_size > new_max_cache_size); - switch ((cache_ptr->resize_ctl).decr_mode) { + switch (cache_ptr->resize_ctl.decr_mode) { case H5C_decr__off: HDfprintf(stdout, "%sAuto cache resize -- decrease off. HR = %lf\n", cache_ptr->prefix, hit_rate); break; case H5C_decr__threshold: - HDassert(hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold); + HDassert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); HDfprintf(stdout, "%sAuto cache resize -- decrease by threshold. HR = %lf > %6.5lf\n", - cache_ptr->prefix, hit_rate, (cache_ptr->resize_ctl).upper_hr_threshold); - + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); HDfprintf(stdout, "%sout of bounds high (%6.5lf).\n", cache_ptr->prefix, - (cache_ptr->resize_ctl).upper_hr_threshold); + cache_ptr->resize_ctl.upper_hr_threshold); break; case H5C_decr__age_out: @@ -607,11 +513,11 @@ H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, break; case H5C_decr__age_out_with_threshold: - HDassert(hit_rate > (cache_ptr->resize_ctl).upper_hr_threshold); + HDassert(hit_rate > cache_ptr->resize_ctl.upper_hr_threshold); HDfprintf(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); + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.upper_hr_threshold); break; default: @@ -625,7 +531,7 @@ H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, case at_max_size: HDfprintf(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); + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); HDfprintf(stdout, "%s cache already at maximum size so no change.\n", cache_ptr->prefix); break; @@ -646,10 +552,10 @@ H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, break; case not_full: - HDassert(hit_rate < (cache_ptr->resize_ctl).lower_hr_threshold); + HDassert(hit_rate < cache_ptr->resize_ctl.lower_hr_threshold); HDfprintf(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); + cache_ptr->prefix, hit_rate, cache_ptr->resize_ctl.lower_hr_threshold); HDfprintf(stdout, "%s cache not full so no increase in size.\n", cache_ptr->prefix); break; @@ -691,10 +597,7 @@ H5C_prep_for_file_close(H5F_t *f) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - /* For now at least, it is possible to receive the - * close warning more than once -- the following - * if statement handles this. - */ + /* It is possible to receive the close warning more than once */ if (cache_ptr->close_warning_received) HGOTO_DONE(SUCCEED) cache_ptr->close_warning_received = TRUE; @@ -707,8 +610,8 @@ H5C_prep_for_file_close(H5F_t *f) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cache image") #ifdef H5_HAVE_PARALLEL - if ((H5F_INTENT(f) & H5F_ACC_RDWR) && (!image_generated) && (cache_ptr->aux_ptr != NULL) && - (f->shared->fs_persist)) { + if ((H5F_INTENT(f) & H5F_ACC_RDWR) && !image_generated && cache_ptr->aux_ptr != NULL && + f->shared->fs_persist) { /* If persistent free space managers are enabled, flushing the * metadata cache may result in the deletion, insertion, and/or * dirtying of entries. @@ -759,34 +662,22 @@ done: * This function fails if any object are protected since the * resulting file might not be consistent. * - * Note that *cache_ptr has been freed upon successful return. + * Note: *cache_ptr has been freed upon successful return. * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer * 6/2/04 * - * Modifications: - * - * JRM -- 5/15/20 - * - * Updated the function to enable the slist prior to the - * call to H5C__flush_invalidate_cache(). - * - * Arguably, it shouldn't be necessary to re-enable the - * slist after the call to H5C__flush_invalidate_cache(), as - * the metadata cache should be discarded. However, in the - * test code, we make multiple calls to H5C_dest(). Thus - * we re-enable the slist on failure if it and the cache - * still exist. - * *------------------------------------------------------------------------- */ herr_t H5C_dest(H5F_t *f) { - H5C_t *cache_ptr = f->shared->cache; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr = f->shared->cache; + H5C_tag_info_t *item = NULL; + H5C_tag_info_t *tmp = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -802,21 +693,16 @@ H5C_dest(H5F_t *f) /* 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 and invalidate all cache entries */ if (H5C__flush_invalidate_cache(f, H5C__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") /* Generate & write cache image if requested */ - if (cache_ptr->image_ctl.generate_image) { - + if (cache_ptr->image_ctl.generate_image) if (H5C__generate_cache_image(f, cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "Can't generate metadata cache image") - } /* Question: Is it possible for cache_ptr->slist be non-null at this * point? If no, shouldn't this if statement be an assert? @@ -826,12 +712,9 @@ H5C_dest(H5F_t *f) HDassert(cache_ptr->slist_size == 0); H5SL_close(cache_ptr->slist_ptr); - cache_ptr->slist_ptr = NULL; } - H5C_tag_info_t *item = NULL; - H5C_tag_info_t *tmp = NULL; HASH_ITER(hh, cache_ptr->tag_list, item, tmp) { HASH_DELETE(hh, cache_ptr->tag_list, item); @@ -843,12 +726,9 @@ H5C_dest(H5F_t *f) #ifndef NDEBUG #ifdef H5C_DO_SANITY_CHECKS - - if (cache_ptr->get_entry_ptr_from_addr_counter > 0) { - + if (cache_ptr->get_entry_ptr_from_addr_counter > 0) HDfprintf(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; @@ -857,18 +737,17 @@ H5C_dest(H5F_t *f) cache_ptr = H5FL_FREE(H5C_t, cache_ptr); done: - - if ((ret_value < 0) && (cache_ptr) && (cache_ptr->slist_ptr)) { - - /* need this for test code -- see change note for details */ - + if (ret_value < 0 && cache_ptr && cache_ptr->slist_ptr) + /* Arguably, it shouldn't be necessary to re-enable the slist after + * the call to H5C__flush_invalidate_cache(), as the metadata cache + * should be discarded. However, in the test code, we make multiple + * calls to H5C_dest(). Thus we re-enable the slist on failure if it + * 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") - } FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_dest() */ /*------------------------------------------------------------------------- @@ -881,14 +760,6 @@ done: * Programmer: Vailin Choi * Dec 2013 * - * Modifications: - * - * JRM -- 5/5/20 - * - * Added code to enable the skip list prior to the call - * to H5C__flush_invalidate_cache(), and disable it - * afterwards. - * *------------------------------------------------------------------------- */ herr_t @@ -903,17 +774,14 @@ H5C_evict(H5F_t *f) /* 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 and invalidate all cache entries except the pinned entries */ if (H5C__flush_invalidate_cache(f, H5C__EVICT_ALLOW_LAST_PINS_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict entries in the cache") /* Disable the slist */ if (H5C_set_slist_enabled(f->shared->cache, FALSE, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist disabled failed") done: @@ -923,9 +791,9 @@ done: /*------------------------------------------------------------------------- * Function: H5C_expunge_entry * - * Purpose: Use this function to tell the cache to expunge an entry - * from the cache without writing it to disk even if it is - * dirty. The entry may not be either pinned or protected. + * 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 * @@ -953,7 +821,7 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag HDassert(H5F_addr_defined(addr)); #ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C_validate_lru_list(cache_ptr) < 0) + 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 */ @@ -988,7 +856,7 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag done: #ifdef H5C_DO_EXTREME_SANITY_CHECKS - if (H5C_validate_lru_list(cache_ptr) < 0) + 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 */ @@ -1007,39 +875,11 @@ done: * function returns failure. * * Return: Non-negative on success/Negative on failure or if there was - * a request to flush all items and something was protected. + * a request to flush all items and an entry was protected. * * Programmer: John Mainzer * 6/2/04 * - * Changes: Modified function to test for slist chamges in - * pre_serialize and serialize callbacks, and re-start - * scans through the slist when such changes occur. - * - * This has been a potential problem for some time, - * and there has been code in this function to deal - * with elements of this issue. However the shift - * to the V3 cache in combination with the activities - * of some of the cache clients (in particular the - * free space manager and the fractal heap) have - * made this re-work necessary. - * - * JRM -- 12/13/14 - * - * Modified function to support rings. Basic idea is that - * every entry in the cache is assigned to a ring. Entries - * in the outermost ring are flushed first, followed by - * those in the next outermost ring, and so on until the - * innermost ring is flushed. See header comment on - * H5C_ring_t in H5Cprivate.h for a more detailed - * discussion. - * - * JRM -- 8/30/15 - * - * Modified function to call the free space manager - * settling functions. - * JRM -- 6/9/16 - * *------------------------------------------------------------------------- */ herr_t @@ -1095,8 +935,8 @@ H5C_flush_cache(H5F_t *f, unsigned flags) #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)) + 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 */ @@ -1116,7 +956,6 @@ H5C_flush_cache(H5F_t *f, unsigned flags) */ ring = H5C_RING_USER; while (ring < H5C_RING_NTYPES) { - /* Only call the free space manager settle routines when close * warning has been received. */ @@ -1226,8 +1065,6 @@ done: * exist on disk yet, but it must have an address and disk * space reserved. * - * Observe that this function cannot occasion a read. - * * Return: Non-negative on success/Negative on failure * * Programmer: John Mainzer @@ -1271,8 +1108,8 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u #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)) + 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 */ @@ -1443,9 +1280,6 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u * 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. - * - * Since items 1 and 2 are not changing any time soon, I see - * no point in worrying about the third. */ if (H5C__make_space_in_cache(f, space_needed, write_permitted) < 0) @@ -1461,8 +1295,8 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u 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)) + 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 */ @@ -1500,8 +1334,8 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u 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)) + 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 */ @@ -1531,12 +1365,6 @@ done: * Programmer: John Mainzer * 5/15/06 * - * JRM -- 11/5/08 - * Added call to H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY() to - * update the new clean_index_size and dirty_index_size - * fields of H5C_t in the case that the entry was clean - * prior to this call, and is pinned and not protected. - * *------------------------------------------------------------------------- */ herr_t @@ -1587,7 +1415,7 @@ H5C_mark_entry_dirty(void *thing) /* Modify cache data structures */ if (was_clean) - H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) + 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) @@ -1670,7 +1498,7 @@ H5C_mark_entry_clean(void *_thing) /* Modify cache data structures */ if (was_dirty) - H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) + 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) @@ -1825,8 +1653,8 @@ H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, hadd HDassert(H5F_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)) + 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 */ @@ -1931,8 +1759,8 @@ H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, hadd 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)) + 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 */ @@ -1978,7 +1806,7 @@ H5C_resize_entry(void *thing, size_t new_size) 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)) + 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 */ @@ -2007,41 +1835,35 @@ H5C_resize_entry(void *thing, size_t new_size) /* 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 (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)) - } /* end if */ - if (entry_ptr->is_protected) { - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pl_len), (cache_ptr->pl_size), (entry_ptr->size), - (new_size)) - } /* end if */ + 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)) - } /* end if */ -#endif /* 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); + 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) @@ -2074,7 +1896,7 @@ H5C_resize_entry(void *thing, size_t new_size) done: #ifdef H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || (H5C_validate_pinned_entry_list(cache_ptr) < 0)) + 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 */ @@ -2092,9 +1914,6 @@ done: * Programmer: John Mainzer * 4/26/06 * - * Changes: Added extreme sanity checks on entry and exit. - * JRM -- 4/26/14 - * *------------------------------------------------------------------------- */ herr_t @@ -2114,8 +1933,8 @@ H5C_pin_protected_entry(void *thing) HDassert(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)) + 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 */ @@ -2129,8 +1948,8 @@ H5C_pin_protected_entry(void *thing) 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)) + 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 */ @@ -2193,8 +2012,8 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign HDassert(H5F_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)) + 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 */ @@ -2242,16 +2061,16 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign if (entry_ptr->type != type) HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") - /* 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. */ #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)) { + if (!entry_ptr->is_dirty && !entry_ptr->coll_access) { MPI_Comm comm; /* File MPI Communicator */ int mpi_code; /* MPI error code */ int buf_size; @@ -2272,14 +2091,11 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign 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) { - if (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") - } - } + 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 */ HDassert(entry_ptr->image_ptr); @@ -2291,11 +2107,10 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign entry_ptr->coll_access = TRUE; H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) } /* end if */ - else if (entry_ptr->coll_access) { + else if (entry_ptr->coll_access) H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, NULL) - } /* end else-if */ - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ #ifdef H5C_DO_TAGGING_SANITY_CHECKS { @@ -2322,11 +2137,8 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign 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, @@ -2350,12 +2162,10 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign /* 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 (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; @@ -2366,7 +2176,7 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign * 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) && + 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))) { @@ -2415,24 +2225,16 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign * 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. - * - * Since items 1, 2, and 3 are not changing any time soon, I - * see no point in worrying about the fourth. */ - 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. It can't be dirty yet, so - * we don't even check to see if it should go in the skip list. - * - * This is no longer true -- due to a bug fix, we may modify - * data on load to repair a file. + /* Insert the entry in the hash table. * * ******************************************* * - * Set the flush_last field + * 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 @@ -2444,11 +2246,8 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign 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))) { - + 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 @@ -2477,28 +2276,23 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign 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 (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") @@ -2506,19 +2300,14 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign have_write_permitted = TRUE; } else { - - write_permitted = cache_ptr->write_permitted; - + 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 (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") - } /* end if */ if (cache_ptr->size_decreased) { cache_ptr->size_decreased = FALSE; @@ -2531,7 +2320,6 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign * 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 @@ -2554,14 +2342,13 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign * the cache and protected. We must wait until it is protected so it is not * evicted during the notify callback. */ - if (was_loaded) { + 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") - } /* end if */ #ifdef H5_HAVE_PARALLEL /* Make sure the size of the collective entries in the cache remain in check */ @@ -2581,8 +2368,8 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign 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)) + 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 */ @@ -2689,7 +2476,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Unknown incr_mode?!?!?") } /* end switch */ - /* logically, this is were configuration for flash cache size increases + /* 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. */ @@ -2700,21 +2487,21 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p 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))) + 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))) + 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)) + 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; @@ -2732,8 +2519,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p * following: */ cache_ptr->resize_enabled = cache_ptr->size_increase_possible || cache_ptr->size_decrease_possible; - - cache_ptr->resize_ctl = *config_ptr; + 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 @@ -2752,7 +2538,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p 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)); + 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 * @@ -2793,7 +2579,6 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p * 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: @@ -2803,8 +2588,7 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p 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)); + (size_t)(((double)(cache_ptr->max_cache_size)) * (cache_ptr->resize_ctl.flash_threshold)); break; default: /* should be unreachable */ @@ -2842,8 +2626,7 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) /* There is no fundamental reason why we should not permit * evictions to be disabled while automatic resize is enabled. - * However, I can't think of any good reason why one would - * want to, and allowing it would greatly complicate testing + * 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) || @@ -2912,10 +2695,6 @@ done: * Programmer: John Mainzer * 5/1/20 * - * Modifications: - * - * None. - * *------------------------------------------------------------------------- */ herr_t @@ -2927,24 +2706,13 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_sli 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 H5C__SLIST_OPT_ENABLED - if (slist_enabled) { - - if (cache_ptr->slist_enabled) { - - HDassert(FALSE); + 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)) { - - HDassert(FALSE); - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty (1)?") - } + 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. @@ -2953,16 +2721,10 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_sli /* scan the index list and insert all dirty entries in the slist */ entry_ptr = cache_ptr->il_head; - while (entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - - if (entry_ptr->is_dirty) { - + if (entry_ptr->is_dirty) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - } - entry_ptr = entry_ptr->il_next; } @@ -2975,35 +2737,22 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_sli HDassert(cache_ptr->dirty_index_size == cache_ptr->slist_size); } else { /* take down the skip list */ - - if (!cache_ptr->slist_enabled) { - - HDassert(FALSE); + 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 { - - HDassert(FALSE); - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty (2)?") - } + else + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty?") } cache_ptr->slist_enabled = FALSE; @@ -3012,16 +2761,8 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_sli HDassert(0 == cache_ptr->slist_size); } -#else /* H5C__SLIST_OPT_ENABLED is FALSE */ - - HDassert(cache_ptr->slist_enabled); - -#endif /* H5C__SLIST_OPT_ENABLED is FALSE */ - done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_set_slist_enabled() */ /*------------------------------------------------------------------------- @@ -3035,9 +2776,6 @@ done: * Programmer: John Mainzer * 3/22/06 * - * Changes: Added extreme sanity checks on entry and exit. - * JRM -- 4/26/14 - * *------------------------------------------------------------------------- */ herr_t @@ -3056,8 +2794,8 @@ H5C_unpin_entry(void *_entry_ptr) HDassert(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)) + 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 */ @@ -3067,8 +2805,8 @@ H5C_unpin_entry(void *_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)) + 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 */ @@ -3098,81 +2836,6 @@ done: * Programmer: John Mainzer * 6/2/04 * - * Modifications: - * - * JRM -- 7/21/04 - * Updated for the addition of the hash table. - * - * JRM -- 10/28/04 - * Added code to set cache_full to TRUE whenever we try to - * make space in the cache. - * - * JRM -- 11/12/04 - * Added code to call to H5C_make_space_in_cache() after the - * call to H5C__auto_adjust_cache_size() if that function - * sets the size_decreased flag is TRUE. - * - * JRM -- 4/25/05 - * The size_decreased flag can also be set to TRUE in - * H5C_set_cache_auto_resize_config() if a new configuration - * forces an immediate reduction in cache size. Modified - * the code to deal with this eventuallity. - * - * JRM -- 6/24/05 - * Added support for the new write_permitted field of H5C_t. - * - * JRM -- 10/22/05 - * Hand optimizations. - * - * JRM -- 5/3/06 - * Added code to set the new dirtied field in - * H5C_cache_entry_t to FALSE prior to return. - * - * JRM -- 6/23/06 - * Modified code to allow dirty entries to be loaded from - * disk. This is necessary as a bug fix in the object - * header code requires us to modify a header as it is read. - * - * JRM -- 3/28/07 - * Added the flags parameter and supporting code. At least - * for now, this parameter is used to allow the entry to - * be protected read only, thus allowing multiple protects. - * - * Also added code to allow multiple read only protects - * of cache entries. - * - * JRM -- 7/27/07 - * Added code supporting the new evictions_enabled field - * in H5C_t. - * - * JRM -- 1/3/08 - * Added to do a flash cache size increase if appropriate - * when a large entry is loaded. - * - * JRM -- 11/13/08 - * Modified function to call H5C_make_space_in_cache() when - * the min_clean_size is violated, not just when there isn't - * enough space for and entry that has just been loaded. - * - * The purpose of this modification is to avoid "metadata - * blizzards" in the write only case. In such instances, - * the cache was allowed to fill with dirty metadata. When - * we finally needed to evict an entry to make space, we had - * to flush out a whole cache full of metadata -- which has - * interesting performance effects. We hope to avoid (or - * perhaps more accurately hide) this effect by maintaining - * the min_clean_size, which should force us to start flushing - * entries long before we actually have to evict something - * to make space. - * - * - * Missing entries? - * - * - * JRM -- 5/8/20 - * Updated for the possibility that the slist will be - * disabled. - * *------------------------------------------------------------------------- */ herr_t @@ -3225,7 +2888,6 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) HDassert(!(free_file_space && take_ownership)); entry_ptr = (H5C_cache_entry_t *)thing; - HDassert(entry_ptr->addr == addr); /* also set the dirtied variable if the dirtied field is set in @@ -3235,9 +2897,8 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) 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)) - + 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 */ @@ -3246,13 +2907,11 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * drops to zero. */ if (entry_ptr->ro_ref_count > 1) { - /* Sanity check */ HDassert(entry_ptr->is_protected); HDassert(entry_ptr->is_read_only); if (dirtied) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") /* Reduce the RO ref count */ @@ -3260,35 +2919,26 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) /* 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 */ HDassert(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 @@ -3318,53 +2968,37 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) #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) { - - 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 */ - } /* end if */ + 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) + 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)) - + 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 (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) { @@ -3373,36 +3007,28 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * '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)) - + 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 (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 */ @@ -3417,52 +3043,36 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) * 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) { - + 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 + /* 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. - * - * On the other hand, this implementation is reasonably clean, and - * makes good use of existing code. - * JRM - 5/19/04 */ 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) { - + if (free_file_space) flush_flags |= H5C__FREE_FILE_SPACE_FLAG; - } /* Set the "take ownership" flag for the flush, if needed */ - if (take_ownership) { - + 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; @@ -3470,29 +3080,22 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) HDassert((!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. */ + /* 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 */ } @@ -3500,16 +3103,13 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) 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)) - + 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() */ /*------------------------------------------------------------------------- @@ -3681,27 +3281,20 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) 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 */ @@ -3714,7 +3307,6 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) 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") @@ -3744,18 +3336,14 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) } /* 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)) { - + (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]") @@ -3766,14 +3354,12 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) 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))) + 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 @@ -3781,12 +3367,11 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) */ } /* H5C_decr__age_out || H5C_decr__age_out_with_threshold */ - if (config_ptr->decr_mode == 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_decr__age_out_with_threshold */ - } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ + } /* H5C_RESIZE_CFG__VALIDATE_DECREMENT */ if ((tests & H5C_RESIZE_CFG__VALIDATE_INTERACTIONS) != 0) { if ((config_ptr->incr_mode == H5C_incr__threshold) && @@ -4249,9 +3834,9 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) HDassert(f); HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(cache_ptr->cache_accesses >= (cache_ptr->resize_ctl).epoch_length); - HDassert(0.0 <= (cache_ptr->resize_ctl).min_clean_fraction); - HDassert((cache_ptr->resize_ctl).min_clean_fraction <= 100.0); + HDassert(cache_ptr->cache_accesses >= cache_ptr->resize_ctl.epoch_length); + HDassert(0.0 <= cache_ptr->resize_ctl.min_clean_fraction); + HDassert(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 @@ -4268,55 +3853,43 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) if (!cache_ptr->resize_enabled) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Auto cache resize disabled") - HDassert(((cache_ptr->resize_ctl).incr_mode != H5C_incr__off) || - ((cache_ptr->resize_ctl).decr_mode != H5C_decr__off)); + HDassert((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") HDassert((0.0 <= hit_rate) && (hit_rate <= 1.0)); - switch ((cache_ptr->resize_ctl).incr_mode) { + 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) { - + 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) { - - HDassert(cache_ptr->max_cache_size == (cache_ptr->resize_ctl).max_size); + else if (cache_ptr->max_cache_size >= cache_ptr->resize_ctl.max_size) { + HDassert(cache_ptr->max_cache_size == cache_ptr->resize_ctl.max_size); status = at_max_size; } - else if (!cache_ptr->cache_full) { - + 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); + (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; - } + 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; - } + 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; } @@ -4331,7 +3904,7 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) * 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 the current epochs before eviction, and after + * 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 @@ -4339,9 +3912,9 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) * 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 (((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") @@ -4355,42 +3928,32 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) */ if (status == in_spec) { - - switch ((cache_ptr->resize_ctl).decr_mode) { + 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) { - + 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) { - - HDassert(cache_ptr->max_cache_size == (cache_ptr->resize_ctl).min_size); + else if (cache_ptr->max_cache_size <= cache_ptr->resize_ctl.min_size) { + HDassert(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); + 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; - } + 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)) { - + 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; - } + cache_ptr->max_cache_size - cache_ptr->resize_ctl.max_decrement; status = decrease; } @@ -4416,22 +3979,19 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) } /* 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)) { - + 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)); + (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 @@ -4441,25 +4001,20 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) * by definition. */ HDassert(new_min_clean_size <= new_max_cache_size); - HDassert((cache_ptr->resize_ctl).min_size <= new_max_cache_size); - HDassert(new_max_cache_size <= (cache_ptr->resize_ctl).max_size); + HDassert(cache_ptr->resize_ctl.min_size <= new_max_cache_size); + HDassert(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) { - + if (status == increase) cache_ptr->cache_full = FALSE; - } - else if (status == decrease) { - + 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) { + 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?!") @@ -4468,7 +4023,7 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) 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)); + (cache_ptr->resize_ctl.flash_threshold)); break; default: /* should be unreachable */ @@ -4478,11 +4033,10 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) } } - 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 (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... */ @@ -4534,69 +4088,54 @@ H5C__autoadjust__ageout(H5F_t *f, double hit_rate, enum H5C_resize_status *statu HDassert((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 (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) { + 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 (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; - } + 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)) { - + 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; - } + cache_ptr->max_cache_size - cache_ptr->resize_ctl.max_decrement; } } } - else { - + else *status_ptr = at_min_size; - } } done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C__autoadjust__ageout() */ /*------------------------------------------------------------------------- @@ -4630,18 +4169,14 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) 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) + 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, @@ -4650,23 +4185,20 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) /* now, re-insert it at the head of the LRU list, and at the tail of * the ring buffer. */ - - HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); - HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); - HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); + HDassert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); + HDassert(cache_ptr->epoch_markers[i].next == NULL); + HDassert(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; - + 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)) + 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) @@ -4679,7 +4211,7 @@ done: * * Purpose: Evict clean entries in the cache that haven't * been accessed for at least - * (cache_ptr->resize_ctl).epochs_before_eviction epochs, + * cache_ptr->resize_ctl.epochs_before_eviction epochs, * and flush dirty entries that haven't been accessed for * that amount of time. * @@ -4704,8 +4236,6 @@ done: * will be re-calculated, and will be enforced the next time * we have to make space in the cache. * - * Observe that this function cannot occasion a read. - * * Return: Non-negative on success/Negative on failure. * * Programmer: John Mainzer, 11/22/04 @@ -4737,22 +4267,16 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte * 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 { - + 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)) { + while (entry_ptr != NULL && entry_ptr->type->id != H5AC_EPOCH_MARKER_ID && + bytes_evicted < eviction_size_limit) { hbool_t skipping_entry = FALSE; HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -4793,7 +4317,6 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte } /* end else */ } /* end if */ else if (!entry_ptr->prefetched_dirty) { - bytes_evicted += entry_ptr->size; if (H5C__flush_single_entry( @@ -4841,7 +4364,6 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte * 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 @@ -4913,14 +4435,13 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if (cache_ptr->epoch_markers_active >= (cache_ptr->resize_ctl).epochs_before_eviction) + 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") @@ -4932,25 +4453,19 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr) 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) { - + 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)) + 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() */ /*------------------------------------------------------------------------- @@ -4991,23 +4506,21 @@ H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr) 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) + 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)) + 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; + cache_ptr->epoch_marker_active[i] = FALSE; - HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); - HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); - HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); + HDassert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); + HDassert(cache_ptr->epoch_markers[i].next == NULL); + HDassert(cache_ptr->epoch_markers[i].prev == NULL); /* decrement the number of active epoch markers */ cache_ptr->epoch_markers_active -= 1; @@ -5016,9 +4529,7 @@ H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr) } done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C__autoadjust__ageout__remove_all_markers() */ /*------------------------------------------------------------------------- @@ -5027,8 +4538,8 @@ done: * * Purpose: Remove epoch markers from the end of the LRU list and * mark them as inactive until the number of active markers - * equals the the current value of - * (cache_ptr->resize_ctl).epochs_before_eviction. + * equals the current value of + * cache_ptr->resize_ctl.epochs_before_eviction. * * Return: SUCCEED on success/FAIL on failure. * @@ -5048,14 +4559,13 @@ H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - if (cache_ptr->epoch_markers_active <= (cache_ptr->resize_ctl).epochs_before_eviction) + 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) { + 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]; @@ -5064,23 +4574,21 @@ H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr) 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) + 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)) + 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; + cache_ptr->epoch_marker_active[i] = FALSE; - HDassert(((cache_ptr->epoch_markers)[i]).addr == (haddr_t)i); - HDassert(((cache_ptr->epoch_markers)[i]).next == NULL); - HDassert(((cache_ptr->epoch_markers)[i]).prev == NULL); + HDassert(cache_ptr->epoch_markers[i].addr == (haddr_t)i); + HDassert(cache_ptr->epoch_markers[i].next == NULL); + HDassert(cache_ptr->epoch_markers[i].prev == NULL); /* decrement the number of active epoch markers */ cache_ptr->epoch_markers_active -= 1; @@ -5089,9 +4597,7 @@ H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr) } done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C__autoadjust__ageout__remove_excess_markers() */ /*------------------------------------------------------------------------- @@ -5100,7 +4606,7 @@ done: * * 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, + * 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. * @@ -5134,13 +4640,9 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n 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)) { - - /* we have work to do */ - - switch ((cache_ptr->resize_ctl).flash_incr_mode) { + (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?!") @@ -5148,14 +4650,11 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n case H5C_flash_incr__add_space: if (cache_ptr->index_size < cache_ptr->max_cache_size) { - HDassert((cache_ptr->max_cache_size - cache_ptr->index_size) < space_needed); space_needed -= cache_ptr->max_cache_size - cache_ptr->index_size; } - space_needed = (size_t)(((double)space_needed) * (cache_ptr->resize_ctl).flash_multiple); - + 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 */ @@ -5163,16 +4662,11 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n break; } - if (new_max_cache_size > (cache_ptr->resize_ctl).max_size) { - - new_max_cache_size = (cache_ptr->resize_ctl).max_size; - } - + if (new_max_cache_size > cache_ptr->resize_ctl.max_size) + new_max_cache_size = cache_ptr->resize_ctl.max_size; HDassert(new_max_cache_size > cache_ptr->max_cache_size); - new_min_clean_size = - (size_t)((double)new_max_cache_size * ((cache_ptr->resize_ctl).min_clean_fraction)); - + new_min_clean_size = (size_t)((double)new_max_cache_size * cache_ptr->resize_ctl.min_clean_fraction); HDassert(new_min_clean_size <= new_max_cache_size); old_max_cache_size = cache_ptr->max_cache_size; @@ -5184,7 +4678,7 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n /* update flash cache size increase fields as appropriate */ HDassert(cache_ptr->flash_size_increase_possible); - switch ((cache_ptr->resize_ctl).flash_incr_mode) { + 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?!") @@ -5192,8 +4686,7 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n 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)); + (size_t)((double)cache_ptr->max_cache_size * cache_ptr->resize_ctl.flash_threshold); break; default: /* should be unreachable */ @@ -5206,17 +4699,16 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n * we don't. */ - if ((cache_ptr->resize_ctl).rpt_fcn != NULL) { - + 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); + (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) @@ -5225,9 +4717,7 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n } done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C__flash_increase_cache_size() */ /*------------------------------------------------------------------------- @@ -5259,52 +4749,7 @@ done: * a request to flush all items and something was protected. * * Programmer: John Mainzer - * 3/24/065 - * - * Modifications: - * - * To support the fractal heap, the cache must now deal with - * entries being dirtied, resized, and/or renamed inside - * flush callbacks. Updated function to support this. - * - * -- JRM 8/27/06 - * - * Added code to detect and manage the case in which a - * flush callback changes the s-list out from under - * the function. The only way I can think of in which this - * can happen is if a flush function loads an entry - * into the cache that isn't there already. Quincey tells - * me that this will never happen, but I'm not sure I - * believe him. - * - * Note that this is a pretty bad scenario if it ever - * happens. The code I have added should allow us to - * handle the situation under all but the worst conditions, - * but one can argue that we should just scream and die if - * we ever detect the condition. - * - * -- JRM 10/13/07 - * - * Missing entries? - * - * - * Added support for the H5C__EVICT_ALLOW_LAST_PINS_FLAG. - * This flag is used to flush and evict all entries in - * the metadata cache that are not pinned -- typically, - * everything other than the superblock. - * - * ??? -- ??/??/?? - * - * Added sanity checks to verify that the skip list is - * enabled on entry. On the face of it, it would make - * sense to enable the slist on entry, and disable it - * on exit, as this function is not called repeatedly. - * However, since this function can be called from - * H5C_flush_cache(), this would create cases in the test - * code where we would have to check the flags to determine - * whether we must setup and take down the slist. - * - * JRM -- 5/5/20 + * 3/24/05 * *------------------------------------------------------------------------- */ @@ -5343,7 +4788,6 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) HDassert(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]; @@ -5351,7 +4795,6 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) slist_len += cache_ptr->slist_ring_len[i]; slist_size += cache_ptr->slist_ring_size[i]; - } /* end for */ HDassert(cache_ptr->index_len == index_len); @@ -5364,63 +4807,48 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) #endif /* H5C_DO_SANITY_CHECKS */ /* remove ageout markers if present */ - if (cache_ptr->epoch_markers_active > 0) { - + 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)) { - HDassert(cache_ptr->index_size == 0); HDassert(cache_ptr->clean_index_size == 0); HDassert(cache_ptr->pel_len == 0); HDassert(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++) { - HDassert(cache_ptr->index_ring_len[u] == 0); HDassert(cache_ptr->index_ring_size[u] == 0); HDassert(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 */ HDassert(entry_ptr->ring == H5C_RING_SB); /* Advance to next entry in pinned entry list */ entry_ptr = entry_ptr->next; - } /* end while */ } /* end else */ @@ -5431,11 +4859,10 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) HDassert(cache_ptr->pl_size == 0); HDassert(cache_ptr->LRU_list_len == 0); HDassert(cache_ptr->LRU_list_size == 0); +#endif /* NDEBUG */ done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C__flush_invalidate_cache() */ /*------------------------------------------------------------------------- @@ -5472,20 +4899,6 @@ done: * Programmer: John Mainzer * 9/1/15 * - * Changes: Added support for the H5C__EVICT_ALLOW_LAST_PINS_FLAG. - * This flag is used to flush and evict all entries in - * the metadata cache that are not pinned -- typically, - * everything other than the superblock. - * - * ??? -- ??/??/?? - * - * A recent optimization turns off the slist unless a flush - * is in progress. This should not effect this function, as - * it is only called during a flush. Added an assertion to - * verify this. - * - * JRM -- 5/6/20 - * *------------------------------------------------------------------------- */ static herr_t @@ -5546,38 +4959,30 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * for some other cache entry), we can no longer promise to flush * the cache entries in increasing address order. * - * Instead, we just do the best we can -- making a pass through + * 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 (From what Quincey tells me, the pin - * mechanism makes this impossible, but even it it is true now, - * we shouldn't count on it in the future.) + * 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) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(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 @@ -5620,32 +5025,25 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) /* 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 ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(next_entry_ptr->is_dirty); HDassert(next_entry_ptr->in_slist); HDassert(next_entry_ptr->ring >= ring); - } /* end if */ entry_ptr = next_entry_ptr; @@ -5671,13 +5069,9 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * 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 ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -5686,10 +5080,8 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert(next_entry_ptr->ring >= ring); HDassert(entry_ptr != next_entry_ptr); } /* end if */ - else { - + 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 @@ -5704,23 +5096,17 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) 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 + /* 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. @@ -5731,20 +5117,16 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) 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. @@ -5771,10 +5153,8 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) */ if (node_ptr == NULL) { - HDassert(cache_ptr->slist_len == (uint32_t)((int32_t)initial_slist_len + cache_ptr->slist_len_increase)); - HDassert(cache_ptr->slist_size == (size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase)); } /* end if */ @@ -5792,7 +5172,7 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * Writes to disk are possible here. */ - /* reset the counters so that we can detect insertions, loads, + /* 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; @@ -5800,9 +5180,7 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) cache_ptr->entries_relocated_counter = 0; next_entry_ptr = cache_ptr->il_head; - while (next_entry_ptr != NULL) { - entry_ptr = next_entry_ptr; HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->ring >= ring); @@ -5815,20 +5193,16 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) (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) { - + if (!entry_ptr->in_slist) HDassert(!(entry_ptr->is_dirty)); - } } /* end if */ - else if (!(entry_ptr->is_pinned)) { - + 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 @@ -5856,12 +5230,10 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * 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 @@ -5884,12 +5256,9 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) cache_ptr->entries_relocated_counter = 0; H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) - } /* end if */ - else { - + else cache_ptr->entry_watched_for_removal = NULL; - } } /* end if */ } /* end if */ } /* end for loop scanning hash table */ @@ -5907,49 +5276,39 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) cur_ring_pel_len = 0; while (entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->ring >= ring); - if (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) { - + 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) + 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 */ HDassert(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++) { - HDassert(cache_ptr->index_ring_len[i] == 0); HDassert(cache_ptr->index_ring_size[i] == (size_t)0); HDassert(cache_ptr->clean_index_ring_size[i] == (size_t)0); @@ -5957,24 +5316,17 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert(cache_ptr->slist_ring_len[i] == 0); HDassert(cache_ptr->slist_ring_size[i] == (size_t)0); - } /* end for */ HDassert(protected_entries <= cache_ptr->pl_len); - if (protected_entries > 0) { - + if (protected_entries > 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Cache has protected entries") - } - else if (cur_ring_pel_len > 0) { - + 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() */ /*------------------------------------------------------------------------- @@ -6000,14 +5352,6 @@ done: * Programmer: John Mainzer * 9/1/15 * - * Changes: A recent optimization turns off the slist unless a flush - * is in progress. This should not effect this function, as - * it is only called during a flush. Added an assertion to - * verify this. - * - * JRM -- 5/6/20 - * - * *------------------------------------------------------------------------- */ static herr_t @@ -6041,22 +5385,17 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert(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)) - + 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++) { - + if (!flush_marked_entries) + for (i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) HDassert(cache_ptr->slist_ring_len[i] == 0); - } - } HDassert(cache_ptr->flush_in_progress); @@ -6078,7 +5417,6 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) 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 @@ -6121,33 +5459,24 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) #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) { - + 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 ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(next_entry_ptr->is_dirty); HDassert(next_entry_ptr->in_slist); - } /* end if */ entry_ptr = next_entry_ptr; @@ -6158,7 +5487,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * dirty, resize, or take ownership of other entries * in the cache. * - * To deal with this, I have inserted code to detect any + * 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 @@ -6173,40 +5502,29 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert(entry_ptr->in_slist); HDassert(entry_ptr->is_dirty); - if ((!flush_marked_entries) || (entry_ptr->flush_marker)) { - + if (!flush_marked_entries || entry_ptr->flush_marker) HDassert(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 ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(next_entry_ptr->is_dirty); HDassert(next_entry_ptr->in_slist); - if (!flush_marked_entries || next_entry_ptr->flush_marker) { - + if (!flush_marked_entries || next_entry_ptr->flush_marker) HDassert(next_entry_ptr->ring >= ring); - } HDassert(entry_ptr != next_entry_ptr); - } /* end if */ - else { - + else next_entry_ptr = NULL; - } if ((!flush_marked_entries || entry_ptr->flush_marker) && ((!entry_ptr->flush_me_last) || @@ -6218,23 +5536,18 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert(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. @@ -6245,11 +5558,9 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) 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 ) ) */ @@ -6261,28 +5572,22 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert((size_t)((ssize_t)initial_slist_size + cache_ptr->slist_size_increase) == cache_ptr->slist_size); #endif /* H5C_DO_SANITY_CHECKS */ - - } /* while */ + } /* while */ HDassert(protected_entries <= cache_ptr->pl_len); - if (((cache_ptr->pl_len > 0) && (!ignore_protected)) || (tried_to_flush_protected_entry)) - + 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) { - HDassert(cache_ptr->slist_ring_len[ring] == 0); HDassert(cache_ptr->slist_ring_size[ring] == 0); - } /* end if */ #endif /* H5C_DO_SANITY_CHECKS */ done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C__flush_ring() */ /*------------------------------------------------------------------------- @@ -6310,69 +5615,6 @@ done: * * Programmer: John Mainzer, 5/5/04 * - * Modifications: - * - * JRM -- 7/21/04 - * Updated function for the addition of the hash table. - * - * QAK -- 11/26/04 - * Updated function for the switch from TBBTs to skip lists. - * - * JRM -- 1/6/05 - * Updated function to reset the flush_marker field. - * Also replace references to H5F_FLUSH_INVALIDATE and - * H5F_FLUSH_CLEAR_ONLY with references to - * H5C__FLUSH_INVALIDATE_FLAG and H5C__FLUSH_CLEAR_ONLY_FLAG - * respectively. - * - * JRM -- 6/24/05 - * Added code to remove dirty entries from the slist after - * they have been flushed. Also added a sanity check that - * will scream if we attempt a write when writes are - * completely disabled. - * - * JRM -- 7/5/05 - * Added code to call the new log_flush callback whenever - * a dirty entry is written to disk. Note that the callback - * is not called if the H5C__FLUSH_CLEAR_ONLY_FLAG is set, - * as there is no write to file in this case. - * - * JRM -- 8/21/06 - * Added code maintaining the flush_in_progress and - * destroy_in_progress fields in H5C_cache_entry_t. - * - * Also added flush_flags parameter to the call to - * type_ptr->flush() so that the flush routine can report - * whether the entry has been resized or renamed. Added - * code using the flush_flags variable to detect the case - * in which the target entry is resized during flush, and - * update the caches data structures accordingly. - * - * JRM -- 3/29/07 - * Added sanity checks on the new is_read_only and - * ro_ref_count fields. - * - * QAK -- 2/07/08 - * Separated "destroy entry" concept from "remove entry from - * cache" concept, by adding the 'take_ownership' flag and - * the "destroy_entry" variable. - * - * JRM -- 11/5/08 - * Added call to H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN() to - * maintain the new clean_index_size and clean_index_size - * fields of H5C_t. - * - * - * Missing entries?? - * - * - * JRM -- 5/8/20 - * Updated sanity checks for the possibility that the slist - * is disabled. - * - * Also updated main comment to conform more closely with - * the current state of the code. - * *------------------------------------------------------------------------- */ herr_t @@ -6419,26 +5661,18 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* Set the flag for destroying the entry, based on the 'take ownership' * and 'destroy' flags */ - if (take_ownership) { - + if (take_ownership) destroy_entry = FALSE; - } - else { - + 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) { - + if (entry_ptr->is_dirty && !clear_only) write_entry = TRUE; - } - else { - + 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 @@ -6447,8 +5681,8 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * 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)) { + 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 */ HDassert(entry_ptr->image_up_to_date || !(entry_ptr->include_in_image)); @@ -6459,58 +5693,37 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) suppress_image_entry_frees = TRUE; - if (cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES) { - + if (cache_ptr->image_ctl.flags & H5C_CI__SUPRESS_ENTRY_WRITES) suppress_image_entry_writes = TRUE; - - } /* end if */ - } /* end if */ + } /* end if */ /* run initial sanity checks */ #ifdef H5C_DO_SANITY_CHECKS if (cache_ptr->slist_enabled) { - if (entry_ptr->in_slist) { - HDassert(entry_ptr->is_dirty); - - if ((entry_ptr->flush_marker) && (!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 { - HDassert(!entry_ptr->is_dirty); HDassert(!entry_ptr->flush_marker); - - if ((entry_ptr->is_dirty) || (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 */ - HDassert(!entry_ptr->in_slist); - - if (!entry_ptr->is_dirty) { - + 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) { - - HDassert(!entry_ptr->is_protected); - + 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") - } /* end if */ - /* Set entry_ptr->flush_in_progress = TRUE and set * entry_ptr->flush_marker = FALSE * @@ -6528,13 +5741,9 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * entry. */ if (write_entry || generate_image) { - HDassert(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") @@ -6545,16 +5754,13 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) } /* end if */ - if (!(entry_ptr->image_up_to_date)) { - + if (!entry_ptr->image_up_to_date) { /* Sanity check */ HDassert(!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 */ @@ -6565,12 +5771,10 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * flag should only be used in test code. */ if (write_entry) { - HDassert(entry_ptr->is_dirty); #ifdef H5C_DO_SANITY_CHECKS - if ((cache_ptr->check_write_permitted) && (!(cache_ptr->write_permitted))) - + 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 */ @@ -6581,48 +5785,37 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * 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)) { - + 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) { - HDassert(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 { - + 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 */ - +#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)) - + 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 @@ -6635,21 +5828,15 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* start by updating the statistics */ if (clear_only) { - /* only log a clear if the entry was dirty */ - if (was_dirty) { - + if (was_dirty) H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) - - } /* end if */ } else if (write_entry) { - HDassert(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 @@ -6659,16 +5846,11 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* Update the cache internal data structures. */ if (destroy) { - /* Sanity checks */ - if (take_ownership) { - + if (take_ownership) HDassert(!destroy_entry); - } - else { - + else HDassert(destroy_entry); - } HDassert(!entry_ptr->is_pinned); @@ -6679,9 +5861,8 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * 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)) - + 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 @@ -6702,19 +5883,14 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) */ H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, FAIL) - if ((entry_ptr->in_slist) && (del_from_slist_on_destroy)) { - + 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 */ @@ -6722,16 +5898,13 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) /* 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 */ HDassert(entry_ptr->flush_dep_nparents == 0); HDassert(entry_ptr->flush_dep_nchildren == 0); - } /* end if */ else { - HDassert(clear_only || write_entry); HDassert(entry_ptr->is_dirty); HDassert((!cache_ptr->slist_enabled) || (entry_ptr->in_slist)); @@ -6741,12 +5914,8 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * 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. - * - * JRM -- 7/7/07 */ - 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 @@ -6755,35 +5924,27 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) */ entry_ptr->is_dirty = FALSE; - H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr); + 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)) - + 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) { - + if (entry_ptr->flush_dep_ndirty_children != 0) HDassert(entry_ptr->flush_dep_ndirty_children == 0); - } - - if (entry_ptr->flush_dep_nparents > 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 */ @@ -6801,7 +5962,6 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * Now discard the entry if appropriate. */ if (destroy) { - /* Sanity check */ HDassert(0 == entry_ptr->flush_dep_nparents); @@ -6812,14 +5972,10 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * * Otherwise, free the buffer if it exists. */ - if (suppress_image_entry_frees && entry_ptr->include_in_image) { - + if (suppress_image_entry_frees && entry_ptr->include_in_image) entry_ptr->image_ptr = NULL; - } - else if (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. @@ -6828,17 +5984,14 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * the flush dependency parents addresses array if necessary. */ if (!entry_ptr->prefetched) { - HDassert(0 == entry_ptr->fd_parent_count); HDassert(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 */ @@ -6859,22 +6012,15 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * 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 */ - + } /* 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 */ @@ -6898,17 +6044,13 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) cache_ptr->entries_removed_counter++; cache_ptr->last_entry_removed_ptr = entry_ptr; - if (entry_ptr == cache_ptr->entry_watched_for_removal) { - + 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; @@ -6916,12 +6058,10 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * '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)) - + 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 -- @@ -6934,20 +6074,15 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) HDassert(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 { - HDassert(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 + /* 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) */ @@ -6955,36 +6090,25 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) * so it doesn't go out of date */ if (update_page_buffer) { - /* Sanity check */ HDassert(!destroy); HDassert(entry_ptr->image_ptr); - if ((f->shared->page_buf) && (f->shared->page_buf->page_size >= entry_ptr->size)) { - + 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 */ - } /* end if */ - - if (cache_ptr->log_flush) { + } /* 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") - } /* end if */ - done: - HDassert((ret_value != SUCCEED) || (destroy_entry) || (!entry_ptr->flush_in_progress)); - HDassert((ret_value != SUCCEED) || (destroy_entry) || (take_ownership) || (!entry_ptr->is_dirty)); FUNC_LEAVE_NOAPI(ret_value) - } /* H5C__flush_single_entry() */ /*------------------------------------------------------------------------- @@ -7165,9 +6289,7 @@ H5C__load_entry(H5F_t *f, #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 */ @@ -7226,7 +6348,6 @@ H5C__load_entry(H5F_t *f, */ 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 */ @@ -7506,23 +6627,17 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) 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)) { - + 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) { - + 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 @@ -7585,9 +6700,7 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) } if (prev_ptr != NULL) { - - if (didnt_flush_entry) { - + 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 @@ -7595,10 +6708,8 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) * 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)) { - + 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. */ @@ -7606,26 +6717,18 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) entry_ptr = cache_ptr->LRU_tail_ptr; H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) } - else { - + else entry_ptr = prev_ptr; - } } - else { - + else entry_ptr = NULL; - } entries_examined++; - if (cache_ptr->index_size >= cache_ptr->max_cache_size) { - + if (cache_ptr->index_size >= cache_ptr->max_cache_size) empty_space = 0; - } - else { - + else empty_space = cache_ptr->max_cache_size - cache_ptr->index_size; - } HDassert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); } @@ -7637,18 +6740,14 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) 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) { - + 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) { - + 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 */ @@ -7667,7 +6766,6 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ } else { - HDassert(H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS); #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS @@ -7683,15 +6781,14 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) prev_ptr = entry_ptr->aux_prev; - if ((!(entry_ptr->prefetched_dirty)) + if (!entry_ptr->prefetched_dirty #ifdef H5_HAVE_PARALLEL - && (!(entry_ptr->coll_access)) + && !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 @@ -7718,7 +6815,7 @@ done: /*------------------------------------------------------------------------- * - * Function: H5C_validate_lru_list + * Function: H5C__validate_lru_list * * Purpose: Debugging function that scans the LRU list for errors. * @@ -7734,14 +6831,14 @@ done: */ #ifdef H5C_DO_EXTREME_SANITY_CHECKS herr_t -H5C_validate_lru_list(H5C_t *cache_ptr) +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_NOAPI(FAIL) + FUNC_ENTER_PACKAGE HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); @@ -7770,7 +6867,7 @@ H5C_validate_lru_list(H5C_t *cache_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)) + 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++; @@ -7786,12 +6883,12 @@ done: HDassert(0); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_lru_list() */ +} /* H5C__validate_lru_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /*------------------------------------------------------------------------- * - * Function: H5C_validate_pinned_entry_list + * Function: H5C__validate_pinned_entry_list * * Purpose: Debugging function that scans the pinned entry list for * errors. @@ -7808,14 +6905,14 @@ done: */ #ifdef H5C_DO_EXTREME_SANITY_CHECKS herr_t -H5C_validate_pinned_entry_list(H5C_t *cache_ptr) +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_NOAPI(FAIL) + FUNC_ENTER_PACKAGE HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); @@ -7863,12 +6960,12 @@ done: HDassert(0); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_pinned_entry_list() */ +} /* H5C__validate_pinned_entry_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /*------------------------------------------------------------------------- * - * Function: H5C_validate_protected_entry_list + * Function: H5C__validate_protected_entry_list * * Purpose: Debugging function that scans the protected entry list for * errors. @@ -7885,14 +6982,14 @@ done: */ #ifdef H5C_DO_EXTREME_SANITY_CHECKS herr_t -H5C_validate_protected_entry_list(H5C_t *cache_ptr) +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_NOAPI(FAIL) + FUNC_ENTER_PACKAGE HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); @@ -7940,12 +7037,12 @@ done: HDassert(0); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_validate_protected_entry_list() */ +} /* H5C__validate_protected_entry_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /*------------------------------------------------------------------------- * - * Function: H5C_entry_in_skip_list + * 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 @@ -7960,11 +7057,15 @@ done: */ #ifdef H5C_DO_SLIST_SANITY_CHECKS hbool_t -H5C_entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) +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 */ HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(cache_ptr->slist_ptr); @@ -7987,8 +7088,12 @@ H5C_entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) node_ptr = H5SL_next(node_ptr); } - return (in_slist); -} /* H5C_entry_in_skip_list() */ + /* Set return value */ + ret_value = in_slist; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__entry_in_skip_list() */ #endif /* H5C_DO_SLIST_SANITY_CHECKS */ /*------------------------------------------------------------------------- @@ -8002,18 +7107,8 @@ H5C_entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) * Programmer: Mike McGreevy * November 3, 2010 * - * Changes: Modified function to setup the slist before calling - * H%C_flush_cache(), and take it down afterwards. Note - * that the slist need not be empty after the call to - * H5C_flush_cache() since we are only flushing marked - * entries. Thus must set the clear_slist parameter - * of H5C_set_slist_enabled to TRUE. - * - * JRM -- 5/6/20 - * *------------------------------------------------------------------------- */ - herr_t H5C__flush_marked_entries(H5F_t *f) { @@ -8026,12 +7121,10 @@ H5C__flush_marked_entries(H5F_t *f) /* 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 @@ -8039,13 +7132,10 @@ H5C__flush_marked_entries(H5F_t *f) * 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 */ /*------------------------------------------------------------------------- @@ -8265,7 +7355,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t *entry_ptr) { int i; /* Local index variable */ @@ -8315,7 +7405,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t *entry_ptr) { unsigned u; /* Local index variable */ @@ -8412,8 +7502,6 @@ H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, const H5C_cache_en * 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. - * However, I gather that other uses for the routine are - * under consideration. * * Return: Non-negative on success/Negative on failure or if there was * a request to flush all items and something was protected. @@ -8476,8 +7564,8 @@ H5C__serialize_cache(H5F_t *f) #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)) + 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 */ @@ -8582,16 +7670,16 @@ done: * 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. + * 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. + * 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. + * 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. @@ -8861,7 +7949,7 @@ H5C__serialize_single_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry HDassert(!entry_ptr->flush_in_progress); HDassert(entry_ptr->type); - /* Set entry_ptr->flush_in_progress to TRUE so the the target entry + /* 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. */ @@ -8910,10 +7998,6 @@ done: * Programmer: Mohamad Chaarawi * 2/10/16 * - * Changes: Updated sanity checks for the possibility that the skip - * list is disabled. - * JRM 5/16/20 - * *------------------------------------------------------------------------- */ static herr_t @@ -8945,15 +8029,12 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) 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 @@ -8975,16 +8056,8 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) * in the parallel case, it will not detect an * entry that dirties, resizes, and/or moves * other entries during its flush. - * - * From what Quincey tells me, this test is - * sufficient for now, as any flush routine that - * does the latter will also do the former. - * - * If that ceases to be the case, further - * tests will be necessary. */ if (cache_ptr->aux_ptr != NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "resize/move in serialize occurred in parallel case") #endif @@ -8992,14 +8065,12 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) * data structures */ if (serialize_flags & H5C__SERIALIZE_RESIZED_FLAG) { - /* Sanity check */ HDassert(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") @@ -9013,14 +8084,14 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) /* 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)); + !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); + 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 @@ -9035,20 +8106,17 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) /* 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); @@ -9059,18 +8127,14 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) /* 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 */ - + } /* end if */ + else /* move is already done for us -- just do sanity checks */ HDassert(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 @@ -9088,12 +8152,9 @@ H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr) */ HDassert(entry_ptr->flush_dep_nunser_children == 0); - if (entry_ptr->flush_dep_nparents > 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) diff --git a/src/H5CXmodule.h b/src/H5CXmodule.h index f9844a1..ffb4804 100644 --- a/src/H5CXmodule.h +++ b/src/H5CXmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Sunday, February 25, 2018 - * - * Purpose: This file contains declarations which define macros for the - * H5CX package. Including this header means that the source file - * is part of the H5CX package. + * Purpose: This file contains declarations which define macros for the + * H5CX package. Including this header means that the source file + * is part of the H5CX package. */ #ifndef H5CXmodule_H #define H5CXmodule_H diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 4d74a0a..ed95bcd 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -259,12 +259,6 @@ H5C_dump_cache_LRU(H5C_t *cache_ptr, const char *cache_name) * Programmer: John Mainzer * 11/15/14 * - * Changes: Updated function for the slist_enabled field in H5C_t. - * Recall that to minimize slist overhead, the slist is - * empty and not maintained if cache_ptr->slist_enabled is - * false. - * JRM -- 5/6/20 - * *------------------------------------------------------------------------- */ #ifndef NDEBUG @@ -297,49 +291,33 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) i = 0; node_ptr = H5SL_first(cache_ptr->slist_ptr); - - if (node_ptr != NULL) { - + if (node_ptr != NULL) entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - } - else { - + else entry_ptr = NULL; - } while (entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDfprintf(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), entry_ptr->type->name); - HDfprintf(stdout, " node_ptr = %p, item = %p\n", (void *)node_ptr, H5SL_item(node_ptr)); /* increment node_ptr before we delete its target */ - node_ptr = H5SL_next(node_ptr); - - if (node_ptr != NULL) { - + if (node_ptr != NULL) entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - } - else { - + else entry_ptr = NULL; - } i++; - } /* end while */ } /* end if */ HDfprintf(stdout, "\n\n"); FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_dump_cache_skip_list() */ #endif /* NDEBUG */ diff --git a/src/H5Cepoch.c b/src/H5Cepoch.c index f6de3ff..1b55080 100644 --- a/src/H5Cepoch.c +++ b/src/H5Cepoch.c @@ -45,7 +45,7 @@ * * As a strategy for automatic cache size reduction, the cache may insert * marker entries in the LRU list at the end of each epoch. These markers - * are then used to identify entries that have not been accessed for n + * are then used to identify entries that have not been accessed for 'n' * epochs so that they can be evicted from the cache. * ****************************************************************************/ @@ -98,7 +98,6 @@ const H5AC_class_t H5AC_EPOCH_MARKER[1] = { * * None of these functions should ever be called, so there is no point in * documenting them separately. - * JRM - 11/16/04 * ***************************************************************************/ diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 6fbd936..b8f46f1 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -80,6 +80,48 @@ /* Maximum ring allowed in image */ #define H5C_MAX_RING_IN_IMAGE H5C_RING_MDFSM +/*********************************************************************** + * + * Stats collection macros + * + * The following macros must handle stats collection when collection + * is enabled, and evaluate to the empty string when it is not. + * + ***********************************************************************/ +#if H5C_COLLECT_CACHE_STATS +/* clang-format off */ +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ + (cache_ptr)->images_created++; +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \ +{ \ + /* make sure image len is still good */ \ + HDassert((cache_ptr)->image_len > 0); \ + (cache_ptr)->images_read++; \ +} +#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \ +{ \ + /* make sure image len is still good */ \ + HDassert((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++; +/* 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 */ + /******************/ /* Local Typedefs */ /******************/ @@ -298,8 +340,8 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) HDassert(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; + 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... */ f->shared->cache = fake_cache_ptr; @@ -310,43 +352,42 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) f->shared->cache = cache_ptr; /* verify expected contents */ - HDassert((cache_ptr->image_entries)[u].addr == (fake_cache_ptr->image_entries)[u].addr); - HDassert((cache_ptr->image_entries)[u].size == (fake_cache_ptr->image_entries)[u].size); - HDassert((cache_ptr->image_entries)[u].type_id == (fake_cache_ptr->image_entries)[u].type_id); - HDassert((cache_ptr->image_entries)[u].lru_rank == (fake_cache_ptr->image_entries)[u].lru_rank); - HDassert((cache_ptr->image_entries)[u].is_dirty == (fake_cache_ptr->image_entries)[u].is_dirty); + HDassert(cache_ptr->image_entries[u].addr == fake_cache_ptr->image_entries[u].addr); + HDassert(cache_ptr->image_entries[u].size == fake_cache_ptr->image_entries[u].size); + HDassert(cache_ptr->image_entries[u].type_id == fake_cache_ptr->image_entries[u].type_id); + HDassert(cache_ptr->image_entries[u].lru_rank == fake_cache_ptr->image_entries[u].lru_rank); + HDassert(cache_ptr->image_entries[u].is_dirty == fake_cache_ptr->image_entries[u].is_dirty); /* don't check image_fd_height as it is not stored in * the metadata cache image block. */ - HDassert((cache_ptr->image_entries)[u].fd_child_count == - (fake_cache_ptr->image_entries)[u].fd_child_count); - HDassert((cache_ptr->image_entries)[u].fd_dirty_child_count == - (fake_cache_ptr->image_entries)[u].fd_dirty_child_count); - HDassert((cache_ptr->image_entries)[u].fd_parent_count == - (fake_cache_ptr->image_entries)[u].fd_parent_count); + HDassert(cache_ptr->image_entries[u].fd_child_count == + fake_cache_ptr->image_entries[u].fd_child_count); + HDassert(cache_ptr->image_entries[u].fd_dirty_child_count == + fake_cache_ptr->image_entries[u].fd_dirty_child_count); + HDassert(cache_ptr->image_entries[u].fd_parent_count == + fake_cache_ptr->image_entries[u].fd_parent_count); - for (v = 0; v < (cache_ptr->image_entries)[u].fd_parent_count; v++) - HDassert((cache_ptr->image_entries)[u].fd_parent_addrs[v] == - (fake_cache_ptr->image_entries)[u].fd_parent_addrs[v]); + for (v = 0; v < cache_ptr->image_entries[u].fd_parent_count; v++) + HDassert(cache_ptr->image_entries[u].fd_parent_addrs[v] == + fake_cache_ptr->image_entries[u].fd_parent_addrs[v]); /* free the fd_parent_addrs array if it exists */ - if ((fake_cache_ptr->image_entries)[u].fd_parent_addrs) { - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count > 0); - (fake_cache_ptr->image_entries)[u].fd_parent_addrs = - (haddr_t *)H5MM_xfree((fake_cache_ptr->image_entries)[u].fd_parent_addrs); - (fake_cache_ptr->image_entries)[u].fd_parent_count = 0; + if (fake_cache_ptr->image_entries[u].fd_parent_addrs) { + HDassert(fake_cache_ptr->image_entries[u].fd_parent_count > 0); + fake_cache_ptr->image_entries[u].fd_parent_addrs = + (haddr_t *)H5MM_xfree(fake_cache_ptr->image_entries[u].fd_parent_addrs); + fake_cache_ptr->image_entries[u].fd_parent_count = 0; } /* end if */ else - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count == 0); + HDassert(fake_cache_ptr->image_entries[u].fd_parent_count == 0); - HDassert((cache_ptr->image_entries)[u].image_ptr); - HDassert((fake_cache_ptr->image_entries)[u].image_ptr); - HDassert(!HDmemcmp((cache_ptr->image_entries)[u].image_ptr, - (fake_cache_ptr->image_entries)[u].image_ptr, - (cache_ptr->image_entries)[u].size)); + HDassert(cache_ptr->image_entries[u].image_ptr); + HDassert(fake_cache_ptr->image_entries[u].image_ptr); + HDassert(!HDmemcmp(cache_ptr->image_entries[u].image_ptr, + fake_cache_ptr->image_entries[u].image_ptr, cache_ptr->image_entries[u].size)); - (fake_cache_ptr->image_entries)[u].image_ptr = - H5MM_xfree((fake_cache_ptr->image_entries)[u].image_ptr); + fake_cache_ptr->image_entries[u].image_ptr = + H5MM_xfree(fake_cache_ptr->image_entries[u].image_ptr); } /* end for */ HDassert((size_t)(q - (const uint8_t *)cache_ptr->image_buffer) == @@ -452,10 +493,6 @@ done: * * Programmer: John Mainzer, 8/10/15 * - * Changes: Updated sanity checks for possibility that the slist - * is disabled. - * JRM -- 5/17/20 - * *------------------------------------------------------------------------- */ herr_t @@ -696,12 +733,10 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t pf_entry_ptr->image_ptr = NULL; if (pf_entry_ptr->is_dirty) { - HDassert(((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) @@ -830,7 +865,7 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) H5C_image_entry_t *ie_ptr; /* Image entry to release */ /* Get pointer to image entry */ - ie_ptr = &((cache_ptr->image_entries)[u]); + ie_ptr = &(cache_ptr->image_entries[u]); /* Sanity checks */ HDassert(ie_ptr); @@ -991,7 +1026,6 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) int mpi_result; if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); #endif /* H5_HAVE_PARALLEL */ @@ -1007,21 +1041,16 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) #ifdef H5_HAVE_PARALLEL if (aux_ptr) { - /* Broadcast cache image */ if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, MPI_BYTE, 0, aux_ptr->mpi_comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - } /* end if */ } /* end if */ else if (aux_ptr) { - /* Retrieve the contents of the metadata cache image from process 0 */ if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, MPI_BYTE, 0, aux_ptr->mpi_comm))) - HMPI_GOTO_ERROR(FAIL, "can't receive cache image MPI_Bcast", mpi_result) } /* end else-if */ } /* end block */ @@ -1579,7 +1608,6 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl /* The collective metadata write code is not currently compatible * with cache image. Until this is fixed, suppress cache image silently * if there is more than one process. - * JRM -- 11/8/16 */ if (cache_ptr->aux_ptr) { H5C_cache_image_ctl_t default_image_ctl = H5C__DEFAULT_CACHE_IMAGE_CTL; @@ -1871,7 +1899,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint HDassert(buf); HDassert(*buf); HDassert(entry_num < cache_ptr->num_entries_in_image); - ie_ptr = &((cache_ptr->image_entries)[entry_num]); + ie_ptr = &(cache_ptr->image_entries[entry_num]); HDassert(ie_ptr); HDassert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); @@ -2222,7 +2250,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne HDassert(buf); HDassert(*buf); HDassert(entry_num < cache_ptr->num_entries_in_image); - ie_ptr = &((cache_ptr->image_entries)[entry_num]); + ie_ptr = &(cache_ptr->image_entries[entry_num]); HDassert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); /* Get pointer to buffer to encode into */ @@ -2296,22 +2324,7 @@ done: /*------------------------------------------------------------------------- * Function: H5C__prep_for_file_close__compute_fd_heights * - * Purpose: Recent modifications to flush dependency support in the - * metadata cache have removed the notion of flush dependency - * height. This is a problem for the cache image feature, - * as flush dependency height is used to order entries in the - * cache image so that flush dependency parents appear before - * flush dependency children. (Recall that the flush dependency - * height of an entry in a flush dependency relationship is the - * length of the longest path from the entry to a leaf entry -- - * that is an entry with flush dependency parents, but no - * flush dependency children. With the introduction of the - * possibility of multiple flush dependency parents, we have - * a flush partial dependency latice, not a flush dependency - * tree. But since the partial latice is acyclic, the concept - * of flush dependency height still makes sense. - * - * The purpose of this function is to compute the flush + * Purpose: The purpose of this function is to compute the flush * dependency height of all entries that appear in the cache * image. * @@ -2944,12 +2957,14 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) HDassert(num_entries_in_image <= num_entries_tentatively_in_image); #ifndef NDEBUG - unsigned j = 0; - for (int i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) - j += cache_ptr->index_ring_len[i]; + { + unsigned j = 0; + for (int i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) + j += cache_ptr->index_ring_len[i]; - /* This will change */ - HDassert(entries_visited == (num_entries_tentatively_in_image + j)); + /* This will change */ + HDassert(entries_visited == (num_entries_tentatively_in_image + j)); + } #endif cache_ptr->num_entries_in_image = num_entries_in_image; @@ -3147,23 +3162,17 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) i = -1; entry_ptr = cache_ptr->LRU_head_ptr; - while (entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->type != NULL); if (entry_ptr->prefetched) { - HDassert(entry_ptr->lru_rank != 0); HDassert((entry_ptr->lru_rank == -1) || (entry_ptr->lru_rank > i)); if ((entry_ptr->lru_rank > 1) && (entry_ptr->lru_rank > i + 1)) - lru_rank_holes += entry_ptr->lru_rank - (i + 1); - i = entry_ptr->lru_rank; - } /* end if */ entry_ptr = entry_ptr->next; @@ -3188,10 +3197,8 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) */ hbool_t write_permitted = FALSE; - if (cache_ptr->check_write_permitted != NULL) { - if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "Can't get write_permitted") - } /* end if */ + if (cache_ptr->check_write_permitted && (cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "Can't get write_permitted") else write_permitted = cache_ptr->write_permitted; diff --git a/src/H5Cmodule.h b/src/H5Cmodule.h index a3ef4d6..64c5279 100644 --- a/src/H5Cmodule.h +++ b/src/H5Cmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5C package. Including this header means that the source file - * is part of the H5C package. + * Purpose: This file contains declarations which define macros for the + * H5C package. Including this header means that the source file + * is part of the H5C package. */ #ifndef H5Cmodule_H #define H5Cmodule_H diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index cfd0780..a92ac10 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -212,7 +212,7 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha /* Create skip list of entries for collective write */ if (NULL == (cache_ptr->coll_write_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for entries") + HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create skip list for entries") } /* end if */ n = num_candidates / (unsigned)mpi_size; @@ -220,8 +220,7 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha if (NULL == (candidate_assignment_table = (unsigned *)H5MM_malloc(sizeof(unsigned) * (size_t)(mpi_size + 1)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for candidate assignment table") + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "memory allocation failed for candidate assignment table") candidate_assignment_table[0] = 0; candidate_assignment_table[mpi_size] = num_candidates; @@ -402,22 +401,11 @@ done: * shouldn't be used elsewhere. * * Return: Success: SUCCEED - * * Failure: FAIL * * Programmer: John Mainzer * 3/17/10 * - * Changes: With the slist optimization, the slist is not maintained - * unless a flush is in progress. Thus we can not longer use - * cache_ptr->slist_size to determine the total size of - * the entries we must insert in the candidate list. - * - * To address this, we now use cache_ptr->dirty_index_size - * instead. - * - * JRM -- 7/27/20 - * *------------------------------------------------------------------------- */ herr_t @@ -440,16 +428,14 @@ H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) HDassert((!cache_ptr->slist_enabled) || (space_needed == cache_ptr->slist_size)); - /* Recall that while we shouldn't have any protected entries at this - * point, it is possible that some dirty entries may reside on the - * pinned list at this point. + /* We shouldn't have any protected entries at this point, but it is + * possible that some dirty entries may reside on the pinned list. */ HDassert(cache_ptr->dirty_index_size <= (cache_ptr->dLRU_list_size + cache_ptr->pel_size)); HDassert((!cache_ptr->slist_enabled) || (cache_ptr->slist_len <= (cache_ptr->dLRU_list_len + cache_ptr->pel_len))); - if (space_needed > 0) { /* we have work to do */ - + if (space_needed > 0) { H5C_cache_entry_t *entry_ptr; unsigned nominated_entries_count = 0; size_t nominated_entries_size = 0; @@ -461,11 +447,9 @@ H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) * entries to free up the necessary space. */ entry_ptr = cache_ptr->dLRU_tail_ptr; - while ((nominated_entries_size < space_needed) && ((!cache_ptr->slist_enabled) || (nominated_entries_count < cache_ptr->slist_len)) && (entry_ptr != NULL)) { - HDassert(!(entry_ptr->is_protected)); HDassert(!(entry_ptr->is_read_only)); HDassert(entry_ptr->ro_ref_count == 0); @@ -473,15 +457,13 @@ H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) HDassert((!cache_ptr->slist_enabled) || (entry_ptr->in_slist)); nominated_addr = entry_ptr->addr; - if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; - entry_ptr = entry_ptr->aux_prev; + entry_ptr = entry_ptr->aux_prev; } /* end while */ HDassert(entry_ptr == NULL); @@ -490,13 +472,10 @@ H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) * protected entry list as well -- scan it too if necessary */ entry_ptr = cache_ptr->pel_head_ptr; - while ((nominated_entries_size < space_needed) && ((!cache_ptr->slist_enabled) || (nominated_entries_count < cache_ptr->slist_len)) && (entry_ptr != NULL)) { - if (entry_ptr->is_dirty) { - HDassert(!(entry_ptr->is_protected)); HDassert(!(entry_ptr->is_read_only)); HDassert(entry_ptr->ro_ref_count == 0); @@ -504,29 +483,22 @@ H5C_construct_candidate_list__clean_cache(H5C_t *cache_ptr) HDassert(entry_ptr->in_slist); nominated_addr = entry_ptr->addr; - if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; - } /* end if */ entry_ptr = entry_ptr->next; - } /* end while */ HDassert((!cache_ptr->slist_enabled) || (nominated_entries_count == cache_ptr->slist_len)); HDassert(nominated_entries_size == space_needed); - } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_construct_candidate_list__clean_cache() */ /*------------------------------------------------------------------------- @@ -545,12 +517,6 @@ done: * Programmer: John Mainzer * 3/17/10 * - * Changes: With the slist optimization, the slist is not maintained - * unless a flush is in progress. Updated sanity checks to - * reflect this. - * - * JRM -- 7/27/20 - * *------------------------------------------------------------------------- */ herr_t @@ -570,30 +536,20 @@ H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr) if (cache_ptr->max_cache_size > cache_ptr->index_size) { if (((cache_ptr->max_cache_size - cache_ptr->index_size) + cache_ptr->cLRU_list_size) >= - cache_ptr->min_clean_size) { - + cache_ptr->min_clean_size) space_needed = 0; - } - else { - + else space_needed = cache_ptr->min_clean_size - ((cache_ptr->max_cache_size - cache_ptr->index_size) + cache_ptr->cLRU_list_size); - } } /* end if */ else { - - if (cache_ptr->min_clean_size <= cache_ptr->cLRU_list_size) { - + if (cache_ptr->min_clean_size <= cache_ptr->cLRU_list_size) space_needed = 0; - } - else { - + else space_needed = cache_ptr->min_clean_size - cache_ptr->cLRU_list_size; - } } /* end else */ if (space_needed > 0) { /* we have work to do */ - H5C_cache_entry_t *entry_ptr; unsigned nominated_entries_count = 0; size_t nominated_entries_size = 0; @@ -604,11 +560,9 @@ H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr) * entries to free up the necessary space. */ entry_ptr = cache_ptr->dLRU_tail_ptr; - while ((nominated_entries_size < space_needed) && ((!cache_ptr->slist_enabled) || (nominated_entries_count < cache_ptr->slist_len)) && (entry_ptr != NULL) && (!entry_ptr->flush_me_last)) { - haddr_t nominated_addr; HDassert(!(entry_ptr->is_protected)); @@ -618,15 +572,13 @@ H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr) HDassert((!cache_ptr->slist_enabled) || (entry_ptr->in_slist)); nominated_addr = entry_ptr->addr; - if (H5AC_add_candidate((H5AC_t *)cache_ptr, nominated_addr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_add_candidate() failed") nominated_entries_size += entry_ptr->size; nominated_entries_count++; - entry_ptr = entry_ptr->aux_prev; + entry_ptr = entry_ptr->aux_prev; } /* end while */ HDassert((!cache_ptr->slist_enabled) || (nominated_entries_count <= cache_ptr->slist_len)); @@ -702,8 +654,8 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr HDassert(ce_array_ptr != NULL); #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) + 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 */ @@ -721,8 +673,8 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr } /* end else */ #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) + 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 in for loop") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ #endif /* H5C_DO_SANITY_CHECKS */ @@ -785,14 +737,8 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr * resizes, or removals of other entries can occur as * a side effect of the flush. Hence, there is no need * for the checks for entry removal / status change - * that I ported to H5C_apply_candidate_list(). + * that are in H5C_apply_candidate_list(). * - * However, if (in addition to allowing such operations - * in the parallel case), we allow such operations outside - * of the pre_serialize / serialize routines, this may - * cease to be the case -- requiring a review of this - * point. - * JRM -- 4/7/15 */ entries_cleared = 0; entries_examined = 0; @@ -857,10 +803,8 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr u = 0; entry_ptr = cache_ptr->pl_head_ptr; while (entry_ptr != NULL) { - if (entry_ptr->clear_on_unprotect) { - + if (entry_ptr->clear_on_unprotect) u++; - } entry_ptr = entry_ptr->next; } HDassert((entries_cleared + u) == ce_array_len); @@ -868,9 +812,9 @@ H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_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) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") + 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) @@ -1086,8 +1030,6 @@ done: * Programmer: John Mainzer * 2/10/17 * - * Changes: None. - * *------------------------------------------------------------------------- */ static herr_t @@ -1148,8 +1090,8 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES #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) + 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 */ @@ -1240,8 +1182,8 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flu HDassert(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)) + 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 */ @@ -1464,12 +1406,8 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flu cache_ptr->entries_removed_counter = 0; cache_ptr->last_entry_removed_ptr = NULL; - /* Add this entry to the list of entries to collectively write - * - * This comment is misleading -- the entry will be added to the - * collective write list only if said list exists. - * - * JRM -- 2/9/17 + /* Add this entry to the list of entries to collectively + * write, if the list exists. */ if (H5C__flush_single_entry(f, op_ptr, op_flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush entry") @@ -1491,12 +1429,6 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flu entry_ptr->is_protected || !entry_ptr->is_pinned)) { /* Something has happened to the pinned entry list -- start * over from the head. - * - * Recall that this code should be un-reachable at present, - * as all the operations by entries on flush that could cause - * it to be reachable are disallowed in the parallel case at - * present. Hence the following assertion which should be - * removed if the above changes. */ HDassert(!restart_scan); @@ -1505,7 +1437,13 @@ H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flu HDassert(!entry_ptr->is_protected); HDassert(entry_ptr->is_pinned); - HDassert(FALSE); /* see comment above */ + /* This code should be un-reachable at present, + * as all the operations by entries on flush that could cause + * it to be reachable are disallowed in the parallel case at + * present. Hence the following assertion which should be + * removed if the above changes. + */ + HDassert(FALSE); restart_scan = FALSE; diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 4f826d1..056c181 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -59,12 +59,6 @@ #define H5C_FLUSH_DEP_PARENT_INIT 8 -/* Set to TRUE to enable the slist optimization. If this field is TRUE, - * the slist is disabled whenever a flush is not in progress. - */ -#define H5C__SLIST_OPT_ENABLED TRUE - - /**************************************************************************** * * We maintain doubly linked lists of instances of H5C_cache_entry_t for a @@ -83,100 +77,17 @@ * to the HGOTO_ERROR macro, which may not be appropriate in all cases. * If so, we will need versions of the insertion and deletion macros which * do not reference the sanity checking macros. - * JRM - 5/5/04 - * - * Changes: - * - * - Removed the line: - * - * ( ( (Size) == (entry_ptr)->size ) && ( (len) != 1 ) ) || - * - * from the H5C__DLL_PRE_REMOVE_SC macro. With the addition of the - * epoch markers used in the age out based cache size reduction algorithm, - * this invariant need not hold, as the epoch markers are of size 0. - * - * One could argue that I should have given the epoch markers a positive - * size, but this would break the index_size = LRU_list_size + pl_size - * + pel_size invariant. - * - * Alternatively, I could pass the current decr_mode in to the macro, - * and just skip the check whenever epoch markers may be in use. - * - * However, any size errors should be caught when the cache is flushed - * and destroyed. Until we are tracking such an error, this should be - * good enough. - * JRM - 12/9/04 - * - * - * - In the H5C__DLL_PRE_INSERT_SC macro, replaced the lines: - * - * ( ( (len) == 1 ) && - * ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || - * ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) - * ) - * ) || - * - * with: - * - * ( ( (len) == 1 ) && - * ( ( (head_ptr) != (tail_ptr) ) || - * ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) - * ) - * ) || - * - * Epoch markers have size 0, so we can now have a non-empty list with - * zero size. Hence the "( (Size) <= 0 )" clause cause false failures - * in the sanity check. Since "Size" is typically a size_t, it can't - * take on negative values, and thus the revised clause "( (Size) < 0 )" - * caused compiler warnings. - * JRM - 12/22/04 - * - * - In the H5C__DLL_SC macro, replaced the lines: - * - * ( ( (len) == 1 ) && - * ( ( (head_ptr) != (tail_ptr) ) || ( (cache_ptr)->size <= 0 ) || - * ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) - * ) - * ) || - * - * with - * - * ( ( (len) == 1 ) && - * ( ( (head_ptr) != (tail_ptr) ) || - * ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) - * ) - * ) || - * - * Epoch markers have size 0, so we can now have a non-empty list with - * zero size. Hence the "( (Size) <= 0 )" clause cause false failures - * in the sanity check. Since "Size" is typically a size_t, it can't - * take on negative values, and thus the revised clause "( (Size) < 0 )" - * caused compiler warnings. - * JRM - 1/10/05 - * - * - Added the H5C__DLL_UPDATE_FOR_SIZE_CHANGE macro and the associated - * sanity checking macros. These macro are used to update the size of - * a DLL when one of its entries changes size. - * - * JRM - 9/8/05 - * - * - Added macros supporting the index list -- a doubly liked list of - * all entries in the index. This list is necessary to reduce the - * cost of visiting all entries in the cache, which was previously - * done via a scan of the hash table. - * - * JRM - 10/15/15 * ****************************************************************************/ #ifdef H5C_DO_SANITY_CHECKS -#define H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +#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 ) || \ - ( (Size) < (entry_ptr)->size ) || \ + ( (list_size) < (entry_ptr)->size ) || \ ( ( (entry_ptr)->prev == NULL ) && ( (head_ptr) != (entry_ptr) ) ) || \ ( ( (entry_ptr)->next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ ( ( (len) == 1 ) && \ @@ -184,23 +95,23 @@ if ( ( (head_ptr) == NULL ) || \ ( (tail_ptr) == (entry_ptr) ) && \ ( (entry_ptr)->next == NULL ) && \ ( (entry_ptr)->prev == NULL ) && \ - ( (Size) == (entry_ptr)->size ) \ + ( (list_size) == (entry_ptr)->size ) \ ) \ ) \ ) \ ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre remove SC failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "DLL pre remove SC failed") \ } -#define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +#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 ) || \ - ( (Size) < 0 ) || \ + ( (list_size) < 0 ) || \ ( ( (len) == 1 ) && \ ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -209,10 +120,10 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ) \ ) \ ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL sanity check failed") \ + 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, Size, fv) \ +#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 ) || \ @@ -221,7 +132,7 @@ if ( ( (entry_ptr) == NULL ) || \ ) || \ ( ( (len) == 1 ) && \ ( ( (head_ptr) != (tail_ptr) ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -230,39 +141,39 @@ if ( ( (entry_ptr) == NULL ) || \ ) \ ) \ ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "DLL pre insert SC failed") \ + 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) \ +#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) ) ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL pre size update SC failed") \ + 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) \ +#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) ) ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "DLL post size update SC failed") \ + 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, Size, fv) -#define H5C__DLL_SC(head_ptr, tail_ptr, len, Size, fv) -#define H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, fv) -#define H5C__DLL_PRE_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) -#define H5C__DLL_POST_SIZE_UPDATE_SC(dll_len, dll_size, old_size, new_size) +#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, Size, fail_val) \ +#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, Size, \ + H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ @@ -276,12 +187,12 @@ if ( ( (new_size) > (dll_size) ) || \ (tail_ptr) = (entry_ptr); \ } \ (len)++; \ - (Size) += (entry_ptr)->size; \ + (list_size) += (entry_ptr)->size; \ } /* H5C__DLL_APPEND() */ -#define H5C__DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ +#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, Size, \ + H5C__DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ @@ -295,12 +206,12 @@ if ( ( (new_size) > (dll_size) ) || \ (head_ptr) = (entry_ptr); \ } \ (len)++; \ - (Size) += entry_ptr->size; \ + (list_size) += (entry_ptr)->size; \ } /* H5C__DLL_PREPEND() */ -#define H5C__DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val) \ +#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, Size, \ + H5C__DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ fail_val) \ { \ if ( (head_ptr) == (entry_ptr) ) \ @@ -319,53 +230,53 @@ if ( ( (new_size) > (dll_size) ) || \ } \ else \ (entry_ptr)->next->prev = (entry_ptr)->prev; \ - entry_ptr->next = NULL; \ - entry_ptr->prev = NULL; \ + (entry_ptr)->next = NULL; \ + (entry_ptr)->prev = NULL; \ (len)--; \ - (Size) -= entry_ptr->size; \ + (list_size) -= (entry_ptr)->size; \ } \ } /* H5C__DLL_REMOVE() */ -#define H5C__DLL_UPDATE_FOR_SIZE_CHANGE(dll_len, dll_size, old_size, new_size) \ +#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) \ + 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) \ + 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, Size, fv) \ +#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 ) || \ - ( (Size) < (entry_ptr)->size ) || \ - ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ + ( (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 ) && \ - ( (Size) == (entry_ptr)->size ) \ + ( (list_size) == (entry_ptr)->size ) \ ) \ ) \ ) \ ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "aux DLL pre remove SC failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "aux DLL pre remove SC failed") \ } -#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +#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 ) || \ - ( (Size) < 0 ) || \ + ( (list_size) < 0 ) || \ ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ( ( (head_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -374,10 +285,10 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ) \ ) \ ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL sanity check failed") \ + 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, Size, fv) \ +#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 ) || \ @@ -385,8 +296,8 @@ if ( ( (entry_ptr) == NULL ) || \ ( (hd_ptr) != (tail_ptr) ) \ ) || \ ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ + ( ( (hd_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ + ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -395,21 +306,21 @@ if ( ( (entry_ptr) == NULL ) || \ ) \ ) \ ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "AUX DLL pre insert SC failed") \ + 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, Size, fv) -#define H5C__AUX_DLL_SC(head_ptr, tail_ptr, len, Size, fv) -#define H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) +#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) #endif /* H5C_DO_SANITY_CHECKS */ -#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fail_val)\ +#define H5C__AUX_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val)\ { \ - H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, Size, \ + H5C__AUX_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ @@ -423,12 +334,12 @@ if ( ( (entry_ptr) == NULL ) || \ (tail_ptr) = (entry_ptr); \ } \ (len)++; \ - (Size) += entry_ptr->size; \ + (list_size) += entry_ptr->size; \ } /* H5C__AUX_DLL_APPEND() */ -#define H5C__AUX_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +#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, Size, fv) \ + 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); \ @@ -441,12 +352,12 @@ if ( ( (entry_ptr) == NULL ) || \ (head_ptr) = (entry_ptr); \ } \ (len)++; \ - (Size) += entry_ptr->size; \ + (list_size) += entry_ptr->size; \ } /* H5C__AUX_DLL_PREPEND() */ -#define H5C__AUX_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +#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, Size, fv) \ + H5C__AUX_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ { \ if ( (head_ptr) == (entry_ptr) ) \ { \ @@ -467,35 +378,34 @@ if ( ( (entry_ptr) == NULL ) || \ entry_ptr->aux_next = NULL; \ entry_ptr->aux_prev = NULL; \ (len)--; \ - (Size) -= entry_ptr->size; \ + (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, Size, fv) \ +#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 ) || \ - ( (Size) < (entry_ptr)->size ) || \ - ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ + ( (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 ) && \ - ( (Size) == (entry_ptr)->size ) \ + ( (list_size) == (entry_ptr)->size ) \ ) \ ) \ ) \ ) { \ - HDassert(0 && "il DLL pre remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "il DLL pre remove SC failed") \ + 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, Size, fv) \ +#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 ) || \ @@ -503,8 +413,8 @@ if ( ( (entry_ptr) == NULL ) || \ ( (hd_ptr) != (tail_ptr) ) \ ) || \ ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ + ( ( (hd_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ + ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -513,17 +423,16 @@ if ( ( (entry_ptr) == NULL ) || \ ) \ ) \ ) { \ - HDassert(0 && "IL DLL pre insert SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL pre insert SC failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "IL DLL pre insert SC failed") \ } -#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +#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 != (Size) ) \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -532,22 +441,21 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ) \ ) \ ) { \ - HDassert(0 && "IL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "IL DLL sanity check failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "IL DLL sanity check failed") \ } #else /* H5C_DO_SANITY_CHECKS */ -#define H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) -#define H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) -#define H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) +#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) #endif /* H5C_DO_SANITY_CHECKS */ -#define H5C__IL_DLL_APPEND(entry_ptr, head_ptr, tail_ptr, len, 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, Size, \ + H5C__IL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ @@ -561,13 +469,13 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ (tail_ptr) = (entry_ptr); \ } \ (len)++; \ - (Size) += entry_ptr->size; \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fail_val) \ + (list_size) += entry_ptr->size; \ + H5C__IL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ } /* H5C__IL_DLL_APPEND() */ -#define H5C__IL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +#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, Size, fv) \ + H5C__IL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val) \ { \ if ( (head_ptr) == (entry_ptr) ) \ { \ @@ -588,9 +496,9 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ entry_ptr->il_next = NULL; \ entry_ptr->il_prev = NULL; \ (len)--; \ - (Size) -= entry_ptr->size; \ + (list_size) -= entry_ptr->size; \ } \ - H5C__IL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ + H5C__IL_DLL_SC(head_ptr, tail_ptr, len, list_size, fail_val) \ } /* H5C__IL_DLL_REMOVE() */ @@ -608,61 +516,55 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ***********************************************************************/ #define H5C__UPDATE_CACHE_HIT_RATE_STATS(cache_ptr, hit) \ - (cache_ptr->cache_accesses)++; \ - if ( hit ) { \ - (cache_ptr->cache_hits)++; \ - } \ + (cache_ptr)->cache_accesses++; \ + if (hit) \ + (cache_ptr)->cache_hits++; #if H5C_COLLECT_CACHE_STATS #define H5C__UPDATE_MAX_INDEX_SIZE_STATS(cache_ptr) \ - 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; + 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; #define H5C__UPDATE_STATS_FOR_DIRTY_PIN(cache_ptr, entry_ptr) \ - (((cache_ptr)->dirty_pins)[(entry_ptr)->type->id])++; - -#define H5C__UPDATE_STATS_FOR_UNPROTECT(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 ( (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)->dirty_pins[(entry_ptr)->type->id]++; + +#define H5C__UPDATE_STATS_FOR_UNPROTECT(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 ((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; -#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ - if ( cache_ptr->flush_in_progress ) \ - ((cache_ptr)->cache_flush_moves[(entry_ptr)->type->id])++; \ - 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++; +#define H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) \ + if ((cache_ptr)->flush_in_progress) \ + (cache_ptr)->cache_flush_moves[(entry_ptr)->type->id]++; \ + 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++; #define H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_size)\ - if ( cache_ptr->flush_in_progress ) \ - ((cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id])++; \ - 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) \ - if ( (cache_ptr)->slist_size > (cache_ptr)->max_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])++; \ - } + if ((cache_ptr)->flush_in_progress) \ + (cache_ptr)->cache_flush_size_changes[(entry_ptr)->type->id]++; \ + 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) \ + if ((cache_ptr)->slist_size > (cache_ptr)->max_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]++; #define H5C__UPDATE_STATS_FOR_HT_INSERTION(cache_ptr) \ (cache_ptr)->total_ht_insertions++; @@ -671,7 +573,7 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ (cache_ptr)->total_ht_deletions++; #define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) \ - if ( success ) { \ + if (success) { \ (cache_ptr)->successful_ht_searches++; \ (cache_ptr)->total_successful_ht_search_depth += depth; \ } else { \ @@ -680,48 +582,16 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ } #define H5C__UPDATE_STATS_FOR_UNPIN(cache_ptr, entry_ptr) \ - ((cache_ptr)->unpins)[(entry_ptr)->type->id]++; + (cache_ptr)->unpins[(entry_ptr)->type->id]++; #define H5C__UPDATE_STATS_FOR_SLIST_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->slist_scan_restarts)++; + (cache_ptr)->slist_scan_restarts++; #define H5C__UPDATE_STATS_FOR_LRU_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->LRU_scan_restarts)++; + (cache_ptr)->LRU_scan_restarts++; #define H5C__UPDATE_STATS_FOR_INDEX_SCAN_RESTART(cache_ptr) \ - ((cache_ptr)->index_scan_restarts)++; - -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \ -{ \ - (cache_ptr)->images_created++; \ -} - -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \ -{ \ - /* make sure image len is still good */ \ - HDassert((cache_ptr)->image_len > 0); \ - (cache_ptr)->images_read++; \ -} - -#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \ -{ \ - /* make sure image len is still good */ \ - HDassert((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++; \ -} + (cache_ptr)->index_scan_restarts++; #if H5C_COLLECT_CACHE_ENTRY_STATS @@ -735,113 +605,96 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ { \ - (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ + (cache_ptr)->clears[(entry_ptr)->type->id]++; \ if((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ - ((entry_ptr)->clears)++; \ + (cache_ptr)->pinned_clears[(entry_ptr)->type->id]++; \ + (entry_ptr)->clears++; \ } #define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ { \ - (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ + (cache_ptr)->flushes[(entry_ptr)->type->id]++; \ if((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ - ((entry_ptr)->flushes)++; \ + (cache_ptr)->pinned_flushes[(entry_ptr)->type->id]++; \ + (entry_ptr)->flushes++; \ } #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ { \ - if ( take_ownership ) \ - (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ + if (take_ownership) \ + (cache_ptr)->take_ownerships[(entry_ptr)->type->id]++; \ else \ - (((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] ) \ - ((cache_ptr)->min_accesses)[(entry_ptr)->type->id] = \ - (entry_ptr)->accesses; \ - if ( (entry_ptr)->clears > \ - ((cache_ptr)->max_clears)[(entry_ptr)->type->id] ) \ - ((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; \ + (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]) \ + (cache_ptr)->min_accesses[(entry_ptr)->type->id] = (entry_ptr)->accesses; \ + if ((entry_ptr)->clears > (cache_ptr)->max_clears[(entry_ptr)->type->id]) \ + (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; \ } #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]++; \ + (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 ) \ + 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; \ } \ - if ( (cache_ptr)->index_len > (cache_ptr)->max_index_len ) \ + 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 ) \ + 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 ) \ + 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++; \ + 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++; \ } #define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ { \ - if ( hit ) \ - ((cache_ptr)->hits)[(entry_ptr)->type->id]++; \ + 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); \ + (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 ) \ + 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 ) \ + 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 ) \ + 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_size)[(entry_ptr)->type->id] = (entry_ptr)->size; \ - ((entry_ptr)->accesses)++; \ + 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++; \ } #define H5C__UPDATE_STATS_FOR_PIN(cache_ptr, entry_ptr) \ { \ - ((cache_ptr)->pins)[(entry_ptr)->type->id]++; \ + (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; \ } @@ -851,24 +704,24 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) \ { \ - (((cache_ptr)->clears)[(entry_ptr)->type->id])++; \ + (cache_ptr)->clears[(entry_ptr)->type->id]++; \ if((entry_ptr)->is_pinned) \ - (((cache_ptr)->pinned_clears)[(entry_ptr)->type->id])++; \ + (cache_ptr)->pinned_clears[(entry_ptr)->type->id]++; \ } #define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) \ { \ - (((cache_ptr)->flushes)[(entry_ptr)->type->id])++; \ - if ( (entry_ptr)->is_pinned ) \ - (((cache_ptr)->pinned_flushes)[(entry_ptr)->type->id])++; \ + (cache_ptr)->flushes[(entry_ptr)->type->id]++; \ + if ((entry_ptr)->is_pinned) \ + (cache_ptr)->pinned_flushes[(entry_ptr)->type->id]++; \ } #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) \ { \ - if ( take_ownership ) \ - (((cache_ptr)->take_ownerships)[(entry_ptr)->type->id])++; \ + 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]++; \ } #define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) \ @@ -889,7 +742,7 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ (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++; \ + (cache_ptr)->entries_inserted_counter++; \ } #define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) \ @@ -938,7 +791,7 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #define H5C__UPDATE_STATS_FOR_HT_DELETION(cache_ptr) #define H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, success, depth) #define H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) -#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) +#define H5C__UPDATE_STATS_FOR_CLEAR(cache_ptr, entry_ptr) {} #define H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) #define H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) #define H5C__UPDATE_STATS_FOR_PROTECT(cache_ptr, entry_ptr, hit) @@ -947,11 +800,6 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ #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) -#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 */ @@ -966,28 +814,6 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ * When modifying these macros, remember to modify the similar macros * in tst/cache.c * - * Changes: - * - * - Updated existing index macros and sanity check macros to maintain - * the clean_index_size and dirty_index_size fields of H5C_t. Also - * added macros to allow us to track entry cleans and dirties. - * - * JRM -- 11/5/08 - * - * - Updated existing index macros and sanity check macros to maintain - * the index_ring_len, index_ring_size, clean_index_ring_size, and - * dirty_index_ring_size fields of H5C_t. - * - * JRM -- 9/1/15 - * - * - Updated existing index macros and sanity checks macros to - * maintain an doubly linked list of all entries in the index. - * This is necessary to reduce the computational cost of visiting - * all entries in the index, which used to be done by scanning - * the hash table. - * - * JRM -- 10/15/15 - * ***********************************************************************/ /* H5C__HASH_TABLE_LEN is defined in H5Cpkg.h. It mut be a power of two. */ @@ -1024,7 +850,6 @@ if ( ( (cache_ptr) == NULL ) || \ (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 ) ) { \ - HDassert(FALSE); \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT insert SC failed") \ } @@ -1046,11 +871,10 @@ if ( ( (cache_ptr) == NULL ) || \ (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) ) { \ - HDassert(FALSE); \ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT insert SC failed") \ } -#define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ +#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 ) || \ @@ -1087,11 +911,10 @@ if ( ( (cache_ptr) == NULL ) || \ (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 ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT remove SC failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "pre HT remove SC failed") \ } -#define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) \ +#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 ) || \ @@ -1113,20 +936,19 @@ if ( ( (cache_ptr) == NULL ) || \ (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 ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT remove SC failed") \ + 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, Addr, fail_val) \ +#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) ) || \ - ( ! H5F_addr_defined(Addr) ) || \ - ( H5C__HASH_FCN(Addr) < 0 ) || \ - ( H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "pre HT search SC failed") \ + ( ! H5F_addr_defined(entry_addr) ) || \ + ( H5C__HASH_FCN(entry_addr) < 0 ) || \ + ( H5C__HASH_FCN(entry_addr) >= H5C__HASH_TABLE_LEN ) ) { \ + 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) */ @@ -1148,7 +970,7 @@ if ( ( (cache_ptr) == NULL ) || \ ( (entry_ptr)->ht_prev->ht_next != (entry_ptr) ) ) || \ ( ( (entry_ptr)->ht_next != NULL ) && \ ( (entry_ptr)->ht_next->ht_prev != (entry_ptr) ) ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post successful HT search SC failed") \ + 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) */ @@ -1156,11 +978,11 @@ if ( ( (cache_ptr) == NULL ) || \ if ( ( (cache_ptr) == NULL ) || \ ( ((cache_ptr)->index)[k] != (entry_ptr) ) || \ ( (entry_ptr)->ht_prev != NULL ) ) { \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, fail_val, "post HT shift to front SC failed") \ + 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) \ + entry_ptr, was_clean, fail_val) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->index_len <= 0 ) || \ ( (cache_ptr)->index_size <= 0 ) || \ @@ -1190,12 +1012,11 @@ if ( ( (cache_ptr) == NULL ) || \ (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 ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT entry size change SC failed") \ + 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) \ + entry_ptr, fail_val) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->index_len <= 0 ) || \ ( (cache_ptr)->index_size <= 0 ) || \ @@ -1220,11 +1041,10 @@ if ( ( (cache_ptr) == NULL ) || \ (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 ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT entry size change SC failed") \ + 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) \ +#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 ) || \ @@ -1247,11 +1067,10 @@ if ( \ ( (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]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry clean SC failed") \ + 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) \ +#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 ) || \ @@ -1274,11 +1093,10 @@ if ( \ ( (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]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "pre HT update for entry dirty SC failed") \ + 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) \ +#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) ) || \ @@ -1290,11 +1108,10 @@ if ( ( (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]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry clean SC failed") \ + 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) \ +#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) ) || \ @@ -1306,27 +1123,26 @@ if ( ( (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]) ) ) { \ - HDassert(FALSE); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "post HT update for entry dirty SC failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "post HT update for entry dirty SC failed") \ } #else /* H5C_DO_SANITY_CHECKS */ #define H5C__PRE_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) #define H5C__POST_HT_INSERT_SC(cache_ptr, entry_ptr, fail_val) -#define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) -#define H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr) -#define H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) +#define H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) +#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__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) -#define H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) +#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) + entry_ptr, was_clean, fail_val) #define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr) -#define H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr) -#define H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr) + 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) #endif /* H5C_DO_SANITY_CHECKS */ @@ -1343,16 +1159,16 @@ if ( ( (cache_ptr)->index_size != \ ((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]) \ + ((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]) \ + ((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]) \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring]) \ += (entry_ptr)->size; \ } \ if((entry_ptr)->flush_me_last) { \ @@ -1369,7 +1185,7 @@ if ( ( (cache_ptr)->index_size != \ #define H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr, fail_val) \ { \ int k; \ - H5C__PRE_HT_REMOVE_SC(cache_ptr, entry_ptr) \ + 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; \ @@ -1381,16 +1197,16 @@ if ( ( (cache_ptr)->index_size != \ (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]) \ + ((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]) \ + ((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]) \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring]) \ -= (entry_ptr)->size; \ } \ if((entry_ptr)->flush_me_last) { \ @@ -1401,18 +1217,18 @@ if ( ( (cache_ptr)->index_size != \ (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) \ + H5C__POST_HT_REMOVE_SC(cache_ptr, entry_ptr, fail_val) \ } -#define H5C__SEARCH_INDEX(cache_ptr, Addr, 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, Addr, fail_val) \ - k = H5C__HASH_FCN(Addr); \ + 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(H5F_addr_eq(Addr, (entry_ptr)->addr)) { \ + if(H5F_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) \ @@ -1433,84 +1249,58 @@ if ( ( (cache_ptr)->index_size != \ H5C__UPDATE_STATS_FOR_HT_SEARCH(cache_ptr, (entry_ptr != NULL), depth) \ } -#define H5C__SEARCH_INDEX_NO_STATS(cache_ptr, Addr, entry_ptr, fail_val) \ -{ \ - int k; \ - H5C__PRE_HT_SEARCH_SC(cache_ptr, Addr, fail_val) \ - k = H5C__HASH_FCN(Addr); \ - entry_ptr = ((cache_ptr)->index)[k]; \ - while(entry_ptr) { \ - if(H5F_addr_eq(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; \ - HDassert((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; \ - } \ -} - -#define H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr) \ +#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); \ + 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]) \ + ((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]) \ + ((cache_ptr)->clean_index_ring_size[(entry_ptr)->ring]) \ += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ + H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr, fail_val) \ } -#define H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) \ +#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); \ + 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]) \ + ((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]) \ + ((cache_ptr)->dirty_index_ring_size[(entry_ptr)->ring]) \ += (entry_ptr)->size; \ - H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ + H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr, fail_val) \ } #define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ + entry_ptr, was_clean, fail_val) \ { \ H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ + 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_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_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)) \ + (old_size), (new_size), (fail_val)) \ H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr) \ + entry_ptr, fail_val) \ } @@ -1518,9 +1308,6 @@ if ( ( (cache_ptr)->index_size != \ * * Skip list insertion and deletion macros: * - * These used to be functions, but I converted them to macros to avoid some - * function call overhead. - * **************************************************************************/ /*------------------------------------------------------------------------- @@ -1535,56 +1322,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 5/10/04 * - * Modifications: - * - * JRM -- 7/21/04 - * Updated function to set the in_tree flag when inserting - * an entry into the tree. Also modified the function to - * update the tree size and len fields instead of the similar - * index fields. - * - * All of this is part of the modifications to support the - * hash table. - * - * JRM -- 7/27/04 - * Converted the function H5C_insert_entry_in_tree() into - * the macro H5C__INSERT_ENTRY_IN_TREE in the hopes of - * wringing a little more speed out of the cache. - * - * Note that we don't bother to check if the entry is already - * in the tree -- if it is, H5SL_insert() will fail. - * - * QAK -- 11/27/04 - * Switched over to using skip list routines. - * - * JRM -- 6/27/06 - * Added fail_val parameter. - * - * JRM -- 8/25/06 - * Added the H5C_DO_SANITY_CHECKS version of the macro. - * - * This version maintains the slist_len_increase and - * slist_size_increase fields that are used in sanity - * checks in the flush routines. - * - * All this is needed as the fractal heap needs to be - * able to dirty, resize and/or move entries during the - * flush. - * - * JRM -- 12/13/14 - * Added code to set cache_ptr->slist_changed to TRUE - * when an entry is inserted in the slist. - * - * JRM -- 9/1/15 - * Added code to maintain the cache_ptr->slist_ring_len - * and cache_ptr->slist_ring_size arrays. - * - * JRM -- 4/29/20 - * Reworked macro to support the slist_enabled field - * of H5C_t. If slist_enabled == TRUE, the macro - * functions as before. Otherwise, the macro is a no-op, - * and the slist must be empty. - * *------------------------------------------------------------------------- */ @@ -1602,12 +1339,12 @@ if ( ( (cache_ptr)->index_size != \ #ifdef H5C_DO_SLIST_SANITY_CHECKS -#define ENTRY_IN_SLIST(cache_ptr, entry_ptr) \ - H5C_entry_in_skip_list((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 ENTRY_IN_SLIST(cache_ptr, entry_ptr) FALSE +#define H5C_ENTRY_IN_SLIST(cache_ptr, entry_ptr) FALSE #endif /* H5C_DO_SLIST_SANITY_CHECKS */ @@ -1625,7 +1362,7 @@ if ( ( (cache_ptr)->index_size != \ HDassert( (entry_ptr)->size > 0 ); \ HDassert( H5F_addr_defined((entry_ptr)->addr) ); \ HDassert( !((entry_ptr)->in_slist) ); \ - HDassert( ! ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ + HDassert( ! H5C_ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ HDassert( (entry_ptr)->ring < H5C_RING_NTYPES ); \ HDassert( (cache_ptr)->slist_ring_len[(entry_ptr)->ring] <= \ @@ -1668,7 +1405,7 @@ if ( ( (cache_ptr)->index_size != \ \ HDassert( (entry_ptr) ); \ HDassert( (entry_ptr)->size > 0 ); \ - HDassert( ! ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ + HDassert( ! H5C_ENTRY_IN_SLIST((cache_ptr), (entry_ptr)) ); \ HDassert( H5F_addr_defined((entry_ptr)->addr) ); \ HDassert( !((entry_ptr)->in_slist) ); \ HDassert( (entry_ptr)->ring > H5C_RING_UNDEFINED ); \ @@ -1716,33 +1453,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 5/10/04 * - * Modifications: - * - * JRM -- 7/21/04 - * Updated function for the addition of the hash table. - * - * JRM - 7/27/04 - * Converted from the function H5C_remove_entry_from_tree() - * to the macro H5C__REMOVE_ENTRY_FROM_TREE in the hopes of - * wringing a little more performance out of the cache. - * - * QAK -- 11/27/04 - * Switched over to using skip list routines. - * - * JRM -- 3/28/07 - * Updated sanity checks for the new is_read_only and - * ro_ref_count fields in H5C_cache_entry_t. - * - * JRM -- 12/13/14 - * Added code to set cache_ptr->slist_changed to TRUE - * when an entry is removed from the slist. - * - * JRM -- 4/29/20 - * Reworked macro to support the slist_enabled field - * of H5C_t. If slist_enabled == TRUE, the macro - * functions as before. Otherwise, the macro is a no-op, - * and the slist must be empty. - * *------------------------------------------------------------------------- */ @@ -1780,7 +1490,7 @@ if ( ( (cache_ptr)->index_size != \ HDassert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ (cache_ptr)->slist_size -= (entry_ptr)->size; \ ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= \ + HDassert( (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--; \ @@ -1827,7 +1537,7 @@ if ( ( (cache_ptr)->index_size != \ HDassert( (cache_ptr)->slist_size >= (entry_ptr)->size ); \ (cache_ptr)->slist_size -= (entry_ptr)->size; \ ((cache_ptr)->slist_ring_len[(entry_ptr)->ring])--; \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= \ + HDassert( (cache_ptr)->slist_ring_size[((entry_ptr)->ring)] >= \ (entry_ptr)->size ); \ ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (entry_ptr)->size;\ (entry_ptr)->in_slist = FALSE; \ @@ -1853,33 +1563,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 9/07/05 * - * Modifications: - * - * JRM -- 8/27/06 - * Added the H5C_DO_SANITY_CHECKS version of the macro. - * - * This version maintains the slist_size_increase field - * that are used in sanity checks in the flush routines. - * - * All this is needed as the fractal heap needs to be - * able to dirty, resize and/or move entries during the - * flush. - * - * JRM -- 12/13/14 - * Note that we do not set cache_ptr->slist_changed to TRUE - * in this case, as the structure of the slist is not - * modified. - * - * JRM -- 9/1/15 - * Added code to maintain the cache_ptr->slist_ring_len - * and cache_ptr->slist_ring_size arrays. - * - * JRM -- 4/29/20 - * Reworked macro to support the slist_enabled field - * of H5C_t. If slist_enabled == TRUE, the macro - * functions as before. Otherwise, the macro is a no-op, - * and the slist must be empty. - * *------------------------------------------------------------------------- */ @@ -1908,7 +1591,7 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->slist_size -= (old_size); \ (cache_ptr)->slist_size += (new_size); \ \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] \ + HDassert( (cache_ptr)->slist_ring_size[((entry_ptr)->ring)] \ >= (old_size) ); \ \ ((cache_ptr)->slist_ring_size[(entry_ptr)->ring]) -= (old_size); \ @@ -1953,7 +1636,7 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->slist_size -= (old_size); \ (cache_ptr)->slist_size += (new_size); \ \ - HDassert( (cache_ptr)->slist_ring_size[(entry_ptr->ring)] >= \ + HDassert( (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); \ @@ -1976,146 +1659,10 @@ if ( ( (cache_ptr)->index_size != \ * * Replacement policy update macros: * - * These used to be functions, but I converted them to macros to avoid some - * function call overhead. - * **************************************************************************/ /*------------------------------------------------------------------------- * - * Macro: H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS - * - * Purpose: For efficiency, we sometimes change the order of flushes -- - * but doing so can confuse the replacement policy. This - * macro exists to allow us to specify an entry as the - * most recently touched so we can repair any such - * confusion. - * - * 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, 10/13/05 - * - * Modifications: - * - * JRM -- 3/20/06 - * Modified macro to ignore pinned entries. Pinned entries - * do not appear in the data structures maintained by the - * replacement policy code, and thus this macro has nothing - * to do if called for such an entry. - * - * JRM -- 3/28/07 - * Added sanity checks using the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. - * - *------------------------------------------------------------------------- - */ - -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - -#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (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)) \ - \ - /* 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 same LRU list. \ - * \ - * At least initially, all entries should be clean. That may \ - * change, so we may as well deal with both cases now. \ - */ \ - \ - 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)) \ - \ - 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_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__FAKE_RP_FOR_MOST_RECENT_ACCESS */ - -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - -#define H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS(cache_ptr, entry_ptr, fail_val) \ -{ \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ - HDassert( !((entry_ptr)->is_protected) ); \ - HDassert( !((entry_ptr)->is_read_only) ); \ - HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ - HDassert( (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. */ \ - } \ -} /* H5C__FAKE_RP_FOR_MOST_RECENT_ACCESS */ - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - - -/*------------------------------------------------------------------------- - * * Macro: H5C__UPDATE_RP_FOR_EVICTION * * Purpose: Update the replacement policy data structures for an @@ -2130,30 +1677,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 5/10/04 * - * Modifications: - * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_eviction() to the - * macro H5C__UPDATE_RP_FOR_EVICTION in an effort to squeeze - * a bit more performance out of the cache. - * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * the pre-processor, I'll have to remove them. - * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. - * - * JRM - 3/20/06 - * Pinned entries can't be evicted, so this entry should never - * be called on a pinned entry. Added assert to verify this. - * - * JRM -- 3/28/07 - * Added sanity checks for the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. - * *------------------------------------------------------------------------- */ @@ -2241,32 +1764,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 5/6/04 * - * Modifications: - * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_flush() to the - * macro H5C__UPDATE_RP_FOR_FLUSH in an effort to squeeze - * a bit more performance out of the cache. - * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. - * - * JRM - 7/28/04 - * Split macro into two versions, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. - * - * JRM - 3/20/06 - * While pinned entries can be flushed, they don't reside in - * the replacement policy data structures when unprotected. - * Thus I modified this macro to do nothing if the entry is - * pinned. - * - * JRM - 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. - * *------------------------------------------------------------------------- */ @@ -2430,7 +1927,7 @@ if ( ( (cache_ptr)->index_size != \ * appropriate. \ */ \ \ - if ( entry_ptr->is_dirty ) { \ + 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, \ @@ -2499,34 +1996,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 5/17/04 * - * Modifications: - * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_insertion() to the - * macro H5C__UPDATE_RP_FOR_INSERTION in an effort to squeeze - * a bit more performance out of the cache. - * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. - * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. - * - * JRM - 3/10/06 - * This macro should never be called on a pinned entry. - * Inserted an assert to verify this. - * - * JRM - 8/9/06 - * Not any more. We must now allow insertion of pinned - * entries. Updated macro to support this. - * - * JRM - 3/28/07 - * Added sanity checks using the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. - * *------------------------------------------------------------------------- */ @@ -2564,7 +2033,7 @@ if ( ( (cache_ptr)->index_size != \ * appropriate. \ */ \ \ - if ( entry_ptr->is_dirty ) { \ + 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, \ @@ -2637,31 +2106,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 5/17/04 * - * Modifications: - * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_protect() to the - * macro H5C__UPDATE_RP_FOR_PROTECT in an effort to squeeze - * a bit more performance out of the cache. - * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. - * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. - * - * JRM - 3/17/06 - * Modified macro to attempt to remove pinned entriese from - * the pinned entry list instead of from the data structures - * maintained by the replacement policy. - * - * JRM - 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. - * *------------------------------------------------------------------------- */ @@ -2803,7 +2247,7 @@ if ( ( (cache_ptr)->index_size != \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) {\ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( ((entry_ptr)->is_protected ) ) ) {\ \ /* modified LRU specific code */ \ \ @@ -2880,7 +2324,7 @@ if ( ( (cache_ptr)->index_size != \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) {\ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( ((entry_ptr)->is_protected ) ) ) {\ \ /* modified LRU specific code */ \ \ @@ -2927,18 +2371,12 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 8/23/06 * - * Modifications: - * - * JRM -- 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. - * *------------------------------------------------------------------------- */ #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS -#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ @@ -2954,7 +2392,7 @@ if ( ( (cache_ptr)->index_size != \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, \ (cache_ptr)->coll_list_size, \ (entry_ptr)->size, \ - (new_size)); \ + (new_size), (fail_val)); \ \ } \ \ @@ -2963,7 +2401,7 @@ if ( ( (cache_ptr)->index_size != \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ (cache_ptr)->pel_size, \ (entry_ptr)->size, \ - (new_size)); \ + (new_size), (fail_val)); \ \ } else { \ \ @@ -2974,7 +2412,7 @@ if ( ( (cache_ptr)->index_size != \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, \ (entry_ptr)->size, \ - (new_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 \ @@ -2986,14 +2424,14 @@ if ( ( (cache_ptr)->index_size != \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, \ (entry_ptr)->size, \ - (new_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)); \ + (new_size), (fail_val)); \ } \ \ /* End modified LRU specific code. */ \ @@ -3003,7 +2441,7 @@ if ( ( (cache_ptr)->index_size != \ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size) \ +#define H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_size, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ @@ -3019,7 +2457,7 @@ if ( ( (cache_ptr)->index_size != \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ (cache_ptr)->pel_size, \ (entry_ptr)->size, \ - (new_size)); \ + (new_size), (fail_val)); \ \ } else { \ \ @@ -3030,7 +2468,7 @@ if ( ( (cache_ptr)->index_size != \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, \ (entry_ptr)->size, \ - (new_size)); \ + (new_size), (fail_val)); \ \ /* End modified LRU specific code. */ \ } \ @@ -3060,12 +2498,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 3/22/06 * - * Modifications: - * - * JRM -- 3/28/07 - * Added sanity checks based on the new is_read_only and - * ro_ref_count fields of struct H5C_cache_entry_t. - * *------------------------------------------------------------------------- */ @@ -3181,27 +2613,6 @@ if ( ( (cache_ptr)->index_size != \ * * Programmer: John Mainzer, 5/19/04 * - * Modifications: - * - * JRM - 7/27/04 - * Converted the function H5C_update_rp_for_unprotect() to - * the macro H5C__UPDATE_RP_FOR_UNPROTECT in an effort to - * squeeze a bit more performance out of the cache. - * - * At least for the first cut, I am leaving the comments and - * white space in the macro. If they cause difficulties with - * pre-processor, I'll have to remove them. - * - * JRM - 7/28/04 - * Split macro into two version, one supporting the clean and - * dirty LRU lists, and the other not. Yet another attempt - * at optimization. - * - * JRM - 3/17/06 - * Modified macro to put pinned entries on the pinned entry - * list instead of inserting them in the data structures - * maintained by the replacement policy. - * *------------------------------------------------------------------------- */ @@ -3309,37 +2720,36 @@ if ( ( (cache_ptr)->index_size != \ #ifdef H5C_DO_SANITY_CHECKS -#define H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +#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 ) || \ - ( (Size) < (entry_ptr)->size ) || \ - ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ + ( (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 ) && \ - ( (Size) == (entry_ptr)->size ) \ + ( (list_size) == (entry_ptr)->size ) \ ) \ ) \ ) \ ) { \ - HDassert(0 && "coll DLL pre remove SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "coll DLL pre remove SC failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "coll DLL pre remove SC failed") \ } -#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) \ +#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 ) || \ - ( (Size) < 0 ) || \ + ( (list_size) < 0 ) || \ ( ( (len) == 1 ) && \ - ( ( (head_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (head_ptr) == NULL ) || ( (head_ptr)->size != (Size) ) \ + ( ( (head_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ + ( (head_ptr) == NULL ) || ( (head_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -3348,11 +2758,10 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ) \ ) \ ) { \ - HDassert(0 && "COLL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed")\ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fail_val), "COLL DLL sanity check failed")\ } -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv)\ +#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, list_size, fail_val)\ if ( ( (entry_ptr) == NULL ) || \ ( (entry_ptr)->coll_next != NULL ) || \ ( (entry_ptr)->coll_prev != NULL ) || \ @@ -3360,8 +2769,8 @@ if ( ( (entry_ptr) == NULL ) || \ ( (hd_ptr) != (tail_ptr) ) \ ) || \ ( ( (len) == 1 ) && \ - ( ( (hd_ptr) != (tail_ptr) ) || ( (Size) <= 0 ) || \ - ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (Size) ) \ + ( ( (hd_ptr) != (tail_ptr) ) || ( (list_size) <= 0 ) || \ + ( (hd_ptr) == NULL ) || ( (hd_ptr)->size != (list_size) ) \ ) \ ) || \ ( ( (len) >= 1 ) && \ @@ -3370,22 +2779,21 @@ if ( ( (entry_ptr) == NULL ) || \ ) \ ) \ ) { \ - HDassert(0 && "COLL DLL pre insert SC failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL pre insert SC failed") \ + 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, Size, fv) -#define H5C__COLL_DLL_SC(head_ptr, tail_ptr, len, Size, fv) -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) +#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, Size, fail_val) \ +#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, Size, \ + H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, \ fail_val) \ if ( (head_ptr) == NULL ) \ { \ @@ -3399,12 +2807,12 @@ if ( ( (entry_ptr) == NULL ) || \ (tail_ptr) = (entry_ptr); \ } \ (len)++; \ - (Size) += entry_ptr->size; \ + (list_size) += entry_ptr->size; \ } /* H5C__COLL_DLL_APPEND() */ -#define H5C__COLL_DLL_PREPEND(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +#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, Size, fv)\ + 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); \ @@ -3417,12 +2825,12 @@ if ( ( (entry_ptr) == NULL ) || \ (head_ptr) = (entry_ptr); \ } \ (len)++; \ - (Size) += entry_ptr->size; \ + (list_size) += entry_ptr->size; \ } /* H5C__COLL_DLL_PREPEND() */ -#define H5C__COLL_DLL_REMOVE(entry_ptr, head_ptr, tail_ptr, len, Size, fv) \ +#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, Size, fv)\ + H5C__COLL_DLL_PRE_REMOVE_SC(entry_ptr, head_ptr, tail_ptr, len, list_size, fail_val)\ { \ if ( (head_ptr) == (entry_ptr) ) \ { \ @@ -3445,7 +2853,7 @@ if ( ( (entry_ptr) == NULL ) || \ entry_ptr->coll_next = NULL; \ entry_ptr->coll_prev = NULL; \ (len)--; \ - (Size) -= entry_ptr->size; \ + (list_size) -= entry_ptr->size; \ } \ } /* H5C__COLL_DLL_REMOVE() */ @@ -3525,9 +2933,9 @@ if ( ( (entry_ptr) == NULL ) || \ #define H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, fail_val) \ { \ - HDassert( (cache_ptr) ); \ - HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ - HDassert( (entry_ptr) ); \ + HDassert((cache_ptr)); \ + HDassert((cache_ptr)->magic == H5C__H5C_T_MAGIC); \ + HDassert((entry_ptr)); \ \ /* Remove entry and insert at the head of the list. */ \ H5C__COLL_DLL_REMOVE((entry_ptr), (cache_ptr)->coll_head_ptr, \ @@ -3608,24 +3016,9 @@ typedef struct H5C_tag_info_t { * While the cache was designed with multiple replacement policies in mind, * at present only a modified form of LRU is supported. * - * JRM - 4/26/04 - * - * Profiling has indicated that searches in the instance of H5TB_TREE are - * too expensive. To deal with this issue, I have augmented the cache - * with a hash table in which all entries will be stored. Given the - * advantages of flushing entries in increasing address order, the TBBT - * is retained, but only dirty entries are stored in it. At least for - * now, we will leave entries in the TBBT after they are flushed. - * - * Note that index_size and index_len now refer to the total size of - * and number of entries in the hash table. - * - * JRM - 7/19/04 - * - * The TBBT has since been replaced with a skip list. This change - * greatly predates this note. - * - * JRM - 9/26/05 + * The cache has a hash table in which all entries are stored. Given the + * 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 @@ -3719,13 +3112,8 @@ typedef struct H5C_tag_info_t { * The cache requires an index to facilitate searching for entries. The * following fields support that index. * - * Addendum: JRM -- 10/14/15 - * - * We sometimes need to visit all entries in the cache. In the past, this - * was done by scanning the hash table. However, this is expensive, and - * we have come to scan the hash table often enough that it has become a - * performance issue. To repair this, I have added code to maintain a - * list of all entries in the index -- call this list the index list. + * We sometimes need to visit all entries in the cache, they are stored in + * the 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. @@ -3759,12 +3147,10 @@ typedef struct H5C_tag_info_t { * dirty_index_size == index_size. * * WARNING: - * - * The value of the clean_index_size must not be mistaken - * for the current clean size of the cache. Rather, the - * clean size of the cache is the current value of - * clean_index_size plus the amount of empty space (if any) - * in the cache. + * The value of the clean_index_size must not be mistaken for + * the current clean size of the cache. Rather, the clean size + * of the cache is the current value of clean_index_size plus + * the amount of empty space (if any) in the cache. * * clean_index_ring_size: Array of size_t of length H5C_RING_NTYPES used to * maintain the sum of the sizes of all clean entries in the @@ -3786,7 +3172,7 @@ typedef struct H5C_tag_info_t { * H5C__HASH_TABLE_LEN. At present, this value is a power * of two, not the usual prime number. * - * I hope that the variable size of cache elements, the large + * Hopefully the variable size of cache elements, the large * hash table size, and the way in which HDF5 allocates space * will combine to avoid problems with periodicity. If so, we * can use a trivial hash function (a bit-and and a 3 bit left @@ -3827,11 +3213,10 @@ typedef struct H5C_tag_info_t { * This field is NULL if the index is empty. * * - * With the addition of the take ownership flag, it is possible that - * an entry may be removed from the cache as the result of the flush of - * a second entry. In general, this causes little trouble, but it is - * possible that the entry removed may be the next entry in the scan of - * a list. In this case, we must be able to detect the fact that the + * It is possible that an entry may be removed from the cache as the result + * of the flush of a second entry. In general, this causes little trouble, + * but it is possible that the entry removed may be the next entry in the + * scan of a list. In this case, we must be able to detect the fact that the * entry has been removed, so that the scan doesn't attempt to proceed with * an entry that is no longer in the cache. * @@ -3859,29 +3244,19 @@ typedef struct H5C_tag_info_t { * one. * * entry_watched_for_removal: Pointer to an instance of H5C_cache_entry_t - * which contains the 'next' entry for an iteration. Removing - * this entry must trigger a rescan of the iteration, so each - * entry removed from the cache is compared against this pointer - * and the pointer is reset to NULL if the watched entry is - * removed. - * (This functions similarly to a "dead man's switch") + * which contains the 'next' entry for an iteration. Removing + * this entry must trigger a rescan of the iteration, so each + * entry removed from the cache is compared against this pointer + * and the pointer is reset to NULL if the watched entry is + * removed. (This functions similarly to a "dead man's switch") * * * When we flush the cache, we need to write entries out in increasing * address order. An instance of a skip list is used to store dirty entries in - * sorted order. Whether it is cheaper to sort the dirty entries as needed, - * or to maintain the list is an open question. At a guess, it depends - * on how frequently the cache is flushed. We will see how it goes. - * - * For now at least, I will not remove dirty entries from the list as they - * are flushed. (this has been changed -- dirty entries are now removed from - * the skip list as they are flushed. JRM - 10/25/05) + * sorted order. * - * Update 4/21/20: - * - * Profiling indicates that the cost of maintaining the skip list is - * significant. As it is only used on flush and close, maintaining it - * only when needed is an obvious optimization. + * The cost of maintaining the skip list is significant. As it is only used + * on flush and close, it is maintained only when needed. * * To do this, we add a flag to control maintenanace of the skip list. * This flag is initially set to FALSE, which disables all operations @@ -3940,30 +3315,21 @@ typedef struct H5C_tag_info_t { * order, which results in significant savings. * * b) It facilitates checking for adjacent dirty entries when - * attempting to evict entries from the cache. While we - * don't use this at present, I hope that this will allow - * some optimizations when I get to it. + * 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. At this time, this will only ever be - * one entry (the superblock), and the code has been - * protected with HDasserts to enforce this. This restraint - * can certainly be relaxed in the future if the need for - * multiple entries being flushed last arises, though - * explicit tests for that case should be added when said - * HDasserts are removed. - * - * Update: There are now two possible last entries - * (superblock and file driver info message). This - * number will probably increase as we add superblock - * messages. JRM -- 11/18/14 - * - * With the addition of the fractal heap, the cache must now deal with - * the case in which entries may be dirtied, moved, or have their sizes - * changed during a flush. To allow sanity checks in this situation, the - * following two fields have been added. They are only compiled in when - * H5C_DO_SANITY_CHECKS is TRUE. + * 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 + * message. The code utilizing these flags is protected with + * HDasserts to enforce this. + * + * The cache must deal with the case in which entries may be dirtied, moved, + * or have their sizes changed during a flush. To allow sanity checks in this + * situation, the following two fields have been added. They are only + * compiled in when H5C_DO_SANITY_CHECKS is TRUE. * * slist_len_increase: Number of entries that have been added to the * slist since the last time this field was set to zero. @@ -4020,8 +3386,8 @@ typedef struct H5C_tag_info_t { * * * For very frequently used entries, the protect/unprotect overhead can - * become burdensome. To avoid this overhead, I have modified the cache - * to allow entries to be "pinned". A pinned entry is similar to a + * 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. * @@ -4034,7 +3400,7 @@ typedef struct H5C_tag_info_t { * * 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 the entry is in + * 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 @@ -4072,29 +3438,15 @@ typedef struct H5C_tag_info_t { * The cache must have a replacement policy, and the fields supporting this * policy must be accessible from this structure. * - * While there has been interest in several replacement policies for - * this cache, the initial development schedule is tight. Thus I have - * elected to support only a modified LRU (least recently used) policy - * for the first cut. - * - * To further simplify matters, I have simply included the fields needed - * by the modified LRU in this structure. When and if we add support for - * other policies, it will probably be easiest to just add the necessary - * fields to this structure as well -- we only create one instance of this - * structure per file, so the overhead is not excessive. - * - * * Fields supporting the modified LRU policy: * - * See most any OS text for a discussion of the LRU replacement policy. - * * When operating in parallel mode, we must ensure that a read does not * cause a write. If it does, the process will hang, as the write will * be collective and the other processes will not know to participate. * - * To deal with this issue, I have modified the usual LRU policy by adding + * To deal with this issue, the usual LRU policy has been modified by adding * clean and dirty LRU lists to the usual LRU list. In general, these - * lists are only exist in parallel builds. + * lists only exist in parallel builds. * * The clean LRU list is simply the regular LRU list with all dirty cache * entries removed. @@ -4191,7 +3543,7 @@ typedef struct H5C_tag_info_t { * 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 * adjust the cache size as required. However, this is not possible in all - * cases. Thus I have added automatic cache size adjustment code. + * cases, so the cache has automatic cache size adjustment code. * * The configuration for the automatic cache size adjustment is stored in * the structure described below: @@ -4222,10 +3574,9 @@ typedef struct H5C_tag_info_t { * * resize_enabled: This is another convenience flag which is set whenever * a new set of values for resize_ctl are provided. Very - * simply, + * simply: * - * resize_enabled = size_increase_possible || - * size_decrease_possible; + * resize_enabled = size_increase_possible || size_decrease_possible; * * cache_full: Boolean flag used to keep track of whether the cache is * full, so we can refrain from increasing the size of a @@ -4248,11 +3599,6 @@ typedef struct H5C_tag_info_t { * and to prevent the infinite recursion that would otherwise * occur. * - * Note that this issue is not hypothetical -- this field - * was added 12/29/15 to fix a bug exposed in the testing - * of changes to the file driver info superblock extension - * management code needed to support rings. - * * 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 @@ -4265,11 +3611,6 @@ typedef struct H5C_tag_info_t { * and prevent the infinite regression that would otherwise * occur. * - * Note that this is issue is not hypothetical -- this field - * was added 2/16/17 to address this issue when it was - * exposed by modifications to test/fheap.c to cause it to - * use paged allocation. - * * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration * data for automatic cache resizing. * @@ -4362,8 +3703,8 @@ typedef struct H5C_tag_info_t { * call to H5C_protect(). * * 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. + * loaded the metadata cache image as directed by the + * MDC cache image superblock extension message. * * delete_image: Boolean flag indicating whether the metadata cache image * superblock message should be deleted and the cache image @@ -4398,7 +3739,7 @@ typedef struct H5C_tag_info_t { * order, we scan the index repeatedly, once for each flush dependency * height in increasing order. * - * This operation is complicated by the fact that entries other the the + * This operation is complicated by the fact that entries other than the * target may be inserted, loaded, relocated, or removed from the cache * (either by eviction or the take ownership flag) as the result of a * pre_serialize or serialize callback. While entry removals are not @@ -4476,11 +3817,11 @@ typedef struct H5C_tag_info_t { * free space manager metadata. * * mdfsm_settled: Boolean flag indicating whether the meta data free space - * manager is settled -- i.e. whether the correct space has - * been allocated for it in the file. + * manager is settled -- i.e. whether the correct space has + * been allocated for it in the file. * - * Note that the name of this field is deceptive. In the - * multi file case, the flag applies only to free space + * Note that the name of this field is deceptive. In the + * multi-file case, the flag applies only to free space * managers that are involved in allocating space for free * space managers. * @@ -4699,16 +4040,16 @@ typedef struct H5C_tag_info_t { * 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. + * 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. @@ -4719,21 +4060,19 @@ typedef struct H5C_tag_info_t { * should only change on those events. * * last_image_size: Size of the most recently loaded metadata cache image - * loaded into the cache, or zero if no image has been - * loaded. + * loaded into the cache, or zero if no image has been loaded. * - * At present, at most one cache image can be loaded into - * the metadata cache for any given file, and this image - * will be loaded either on the first protect, or on file - * close if no entry is protected before then. + * At present, at most one cache image can be loaded into + * the metadata cache for any given file, and this image + * will be loaded either on the first protect, or on file + * close if no entry is protected before then. * * * Fields for tracking prefetched entries. Note that flushes and evictions * 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 * into the cache. @@ -4741,9 +4080,9 @@ typedef struct H5C_tag_info_t { * prefetch_hits: Number of prefetched entries that are actually used. * * - * As entries are now capable of moving, loading, dirtying, and deleting - * other entries in their pre_serialize and serialize callbacks, it has - * been necessary to insert code to restart scans of lists so as to avoid + * 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. * @@ -4757,9 +4096,9 @@ typedef struct H5C_tag_info_t { * entry in the scan. * * LRU_scan_restarts: Number of times a scan of the LRU 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. + * calls to H5C__flush_single_entry()) has been restarted to + * avoid potential issues with change of status of the next + * entry in the scan. * * index_scan_restarts: Number of times a scan of the index has been * restarted to avoid potential issues with load, insertion @@ -4794,14 +4133,14 @@ typedef struct H5C_tag_info_t { * 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 + * are used 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 - * entry with type id equal to the array index that has been - * marked as pinned in the cache in the current epoch. + * are used 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: @@ -4811,9 +4150,9 @@ typedef struct H5C_tag_info_t { * 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 - * called successfully. This field is only defined when - * NDEBUG is not #defined. + * times the H5C_get_entry_ptr_from_addr() function has been + * called successfully. This field is only defined when + * NDEBUG is not #defined. * ****************************************************************************/ @@ -5076,8 +4415,6 @@ 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__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr); -H5_DLL herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr); 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); @@ -5089,6 +4426,16 @@ 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); +#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); +H5_DLL herr_t H5C__validate_protected_entry_list(H5C_t *cache_ptr); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + /* Testing functions */ #ifdef H5C_TESTING H5_DLL herr_t H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status); diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 109f5f6..a5330ce 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -42,8 +42,6 @@ /* This sanity checking constant was picked out of the air. Increase * or decrease it if appropriate. Its purposes is to detect corrupt * object sizes, so it probably doesn't matter if it is a bit big. - * - * JRM - 5/17/04 */ #define H5C_MAX_ENTRY_SIZE ((size_t)(32 * 1024 * 1024)) @@ -978,8 +976,6 @@ typedef int H5C_ring_t; * * The fields of this structure are discussed individually below: * - * JRM - 4/26/04 - * * 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 @@ -1100,15 +1096,9 @@ typedef int H5C_ring_t; * be unpinned (and possibly unprotected) during the * flush. * - * JRM -- 3/16/06 - * * in_slist: Boolean flag indicating whether the entry is in the skip list - * As a general rule, entries are placed in the list when they - * are marked dirty. However they may remain in the list after - * being flushed. - * - * Update: Dirty entries are now removed from the skip list - * when they are flushed. + * As a general rule, entries are placed in the list when they are + * marked dirty. * * flush_marker: Boolean flag indicating that the entry is to be flushed * the next time H5C_flush_cache() is called with the @@ -1116,24 +1106,13 @@ typedef int H5C_ring_t; * the entry is flushed for whatever reason. * * flush_me_last: Boolean flag indicating that this entry should not be - * flushed from the cache until all other entries without - * the flush_me_last flag set have been flushed. - * - * Note: - * - * At this time, the flush_me_last - * flag will only be applied to one entry, the superblock, - * and the code utilizing these flags is protected with HDasserts - * to enforce this. This restraint can certainly be relaxed in - * the future if the the need for multiple entries getting flushed - * last or collectively arises, though the code allowing for that - * will need to be expanded and tested appropriately if that - * functionality is desired. + * flushed from the cache until all other entries without the + * flush_me_last flag set have been flushed. * - * Update: There are now two possible last entries - * (superblock and file driver info message). This - * number will probably increase as we add superblock - * messages. JRM -- 11/18/14 + * Note: At this time, the flush_me_last flag will only be applied to + * two types of entries: the superblock and the file driver info + * message. The code utilizing these flags is protected with + * HDasserts to enforce this. * * clear_on_unprotect: Boolean flag used only in PHDF5. When H5C is used * to implement the metadata cache In the parallel case, only @@ -1228,8 +1207,6 @@ typedef int H5C_ring_t; * If there are multiple entries in any hash bin, they are stored in a doubly * linked list. * - * Addendum: JRM -- 10/14/15 - * * We have come to scan all entries in the cache frequently enough that * the cost of doing so by scanning the hash table has become unacceptable. * To reduce this cost, the index now also maintains a doubly linked list @@ -1691,8 +1668,6 @@ typedef struct H5C_cache_entry_t { * * The fields of this structure are discussed individually below: * - * JRM - 8/5/15 - * * 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 @@ -1855,7 +1830,7 @@ typedef struct H5C_image_entry_t { * H5C_auto_size_ctl_t passed to the cache must have a known * version number, or an error will be flagged. * - * report_fcn: Pointer to the function that is to be called to report + * rpt_fcn: Pointer to the function that is to be called to report * activities each time the auto cache resize code is executed. If the * field is NULL, no call is made. * @@ -1978,10 +1953,6 @@ typedef struct H5C_image_entry_t { * performance, however the above flash increment algorithm will not be * triggered. * - * Hopefully, the add space algorithm detailed above will be sufficient - * for the performance problems encountered to date. However, we should - * expect to revisit the issue. - * * flash_multiple: Double containing the multiple described above in the * H5C_flash_incr__add_space section of the discussion of the * flash_incr_mode section. This field is ignored unless flash_incr_mode @@ -2048,8 +2019,8 @@ typedef struct H5C_image_entry_t { * The field is a double containing the multiplier used to derive the * new cache size from the old if a cache size decrement is triggered. * The decrement must be in the range 0.0 (in which case the cache will - * try to contract to its minimum size) to 1.0 (in which case the - * cache will never shrink). + * try to contract to its minimum size) to 1.0 (in which case the + * cache will never shrink). * * apply_max_decrement: Boolean flag used to determine whether decrements * in cache size are to be limited by the max_decrement field. @@ -2295,16 +2266,6 @@ H5_DLL herr_t H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t * H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); H5_DLL herr_t H5C_get_mdc_image_info(const H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); -#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); -H5_DLL herr_t H5C_validate_protected_entry_list(H5C_t *cache_ptr); -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - /* Logging functions */ H5_DLL herr_t H5C_start_logging(H5C_t *cache); H5_DLL herr_t H5C_stop_logging(H5C_t *cache); diff --git a/src/H5Dint.c b/src/H5Dint.c index a8e7307..e930c6a 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1016,7 +1016,7 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) #endif /* H5O_ENABLE_BOGUS */ /* Add a modification time message, if using older format. */ - /* (If using v18 format versions and above, the the modification time is part of the object + /* (If using v18 format versions and above, the modification time is part of the object * header and doesn't use a separate message -QAK) */ if (!use_at_least_v18) @@ -1506,7 +1506,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) if (H5FO_top_incr(dataset->oloc.file, dataset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count") - /* We're the first dataset to use the the shared info */ + /* We're the first dataset to use the shared info */ dataset->shared->fo_count = 1; /* Set the external file prefix */ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 08766dd..804054e 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -42,11 +42,12 @@ /* Format version bounds for layout */ const unsigned H5O_layout_ver_bounds[] = { - H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ - H5O_LAYOUT_VERSION_3, /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */ - H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V110 */ - H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V112 */ - H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ + H5O_LAYOUT_VERSION_1, /* H5F_LIBVER_EARLIEST */ + H5O_LAYOUT_VERSION_3, + /* H5F_LIBVER_V18 */ /* H5O_LAYOUT_VERSION_DEFAULT */ + H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V110 */ + H5O_LAYOUT_VERSION_4, /* H5F_LIBVER_V112 */ + H5O_LAYOUT_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; /*****************************/ @@ -589,7 +590,7 @@ 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 layout_copied = FALSE; /* Flag to indicate that layout message was copied */ - hbool_t efl_copied = FALSE; /* Flag to indicate that efl message was copied */ + hbool_t efl_copied = FALSE; /* Flag to indicate that the EFL message was copied */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -606,7 +607,6 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) if (NULL == H5O_msg_read(&(dataset->oloc), H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") pline_copied = TRUE; - /* Set the I/O pipeline info in the property list */ if (H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set pipeline") diff --git a/src/H5Dmodule.h b/src/H5Dmodule.h index 4bdf936..eb58f68 100644 --- a/src/H5Dmodule.h +++ b/src/H5Dmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5D package. Including this header means that the source file - * is part of the H5D package. + * Purpose: This file contains declarations which define macros for the + * H5D package. Including this header means that the source file + * is part of the H5D package. */ #ifndef H5Dmodule_H #define H5Dmodule_H diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 1e66f80..8e413c1 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -1404,7 +1404,11 @@ done: *------------------------------------------------------------------------- */ static herr_t +#ifdef H5Dmpio_DEBUG H5D__link_piece_collective_io(H5D_io_info_t *io_info, int mpi_rank) +#else +H5D__link_piece_collective_io(H5D_io_info_t *io_info, int H5_ATTR_UNUSED mpi_rank) +#endif { MPI_Datatype chunk_final_mtype; /* Final memory MPI datatype for all chunks with selection */ hbool_t chunk_final_mtype_is_derived = FALSE; @@ -4697,8 +4701,10 @@ H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *ch /* Find the chunk entry according to its chunk index */ HASH_FIND(hh, chunk_hash_table, &chunk_idx, sizeof(hsize_t), chunk_entry); - HDassert(chunk_entry); - HDassert(mpi_rank == chunk_entry->new_owner); + if (chunk_entry == NULL) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFIND, FAIL, "unable to find chunk entry") + if (mpi_rank != chunk_entry->new_owner) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "chunk owner set to incorrect MPI rank") /* * Only process the chunk if its data buffer is allocated. diff --git a/src/H5Doh.c b/src/H5Doh.c index 1e498bc..42cb543 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -282,7 +282,7 @@ H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(crt_info); HDassert(obj_loc); - /* Create the the dataset */ + /* Create the dataset */ if (NULL == (dset = H5D__create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, crt_info->dapl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 6a09408..0906028 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Monday, April 14, 2003 - * - * Purpose: This file contains declarations which are visible only within - * the H5D package. Source files outside the H5D package should - * include H5Dprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5D package. Source files outside the H5D package should + * include H5Dprivate.h instead. */ #if !(defined H5D_FRIEND || defined H5D_MODULE) #error "Do not include this file outside the H5D package!" diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 45b941a..9ec6f70 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -279,7 +279,7 @@ extern "C" { * * \p loc_id may specify a file, group, dataset, named datatype, * or attribute. If an attribute, dataset, or named datatype is - * specified then the dataset will be created at the location + * specified, then the dataset will be created at the location * where the attribute, dataset, or named datatype is attached. * * \p name may be either an absolute path in the file or a relative @@ -290,7 +290,7 @@ extern "C" { * file location where the dataset will be created, the datatype * is copied and converted to a transient type. * - * The link creation property list, \p lcpl_id, governs creation + * The link creation property list, \p lcpl_id, governs the creation * of the link(s) by which the new dataset is accessed and the * creation of any intermediate groups that may be missing. * @@ -348,12 +348,12 @@ H5_DLL hid_t H5Dcreate_async(hid_t loc_id, const char *name, hid_t type_id, hid * * \p loc_id may specify a file, group, dataset, named datatype, * or attribute. If an attribute, dataset, or named datatype is - * specified then the dataset will be created at the location + * specified, then the dataset will be created at the location * where the attribute, dataset, or named datatype is attached. * * The dataset’s datatype and dataspace are specified by * \p type_id and \p space_id, respectively. These are the - * datatype and dataspace of the dataset as it will exist in + * datatype and dataspace of the dataset as they will exist in * the file, which may differ from the datatype and dataspace * in application memory. * @@ -692,7 +692,7 @@ H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, u * context \p op_data. * * \par Example - * For each chunk, print the allocated chunk size (0 for un-allocated chunks). + * For each chunk, print the allocated chunk size (0 for unallocated chunks). * \snippet H5D_examples.c H5Dchunk_iter_cb * Iterate over all chunked datasets and chunks in a file. * \snippet H5D_examples.c H5Ovisit_cb @@ -729,17 +729,17 @@ H5_DLL herr_t H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t cb * * \p chk_idx is the chunk index in the selection. The index value * may have a value of 0 up to the number of chunks stored in - * the file that have a nonempty intersection with the file - * dataspace selection + * the file that has a nonempty intersection with the file + * dataspace selection. * * \note As of 1.10.5, the dataspace intersection is not yet - * supported, hence, the index is of all the written chunks. + * supported. Hence, the index is of all the written chunks. * * \p fspace_id specifies the file dataspace selection. It is - * intended to take #H5S_ALL for specifying the current selection. + * intended to take #H5S_ALL to specify the current selection. * * \note Please be aware that this function currently does not - * support non-trivial selections, thus \p fspace_id has no + * support non-trivial selections; thus \p fspace_id has no * effect. Also, the implementation does not handle the #H5S_ALL * macro correctly. As a workaround, an application can get * the dataspace for the dataset using H5Dget_space() and pass that @@ -893,7 +893,7 @@ H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_ * * This function will produce the same results as \p count calls to * H5Dread(). Information listed in that function about the specifics - * of its behaviour also apply to H5Dread_multi(). By calling + * of its behavior also applies to H5Dread_multi(). By calling * H5Dread_multi() instead of multiple calls to H5Dread(), however, the * library can in some cases pass information about the entire I/O * operation to the file driver, which can improve performance. @@ -1156,7 +1156,7 @@ H5_DLL herr_t H5Dwrite_multi_async(size_t count, hid_t dset_id[], hid_t mem_type * the file. Only one chunk can be written with this function. * * \p filters is a mask providing a record of which filters are - * used with the the chunk. The default value of the mask is + * used with the chunk. The default value of the mask is * zero (0), indicating that all enabled filters are applied. A * filter is skipped if the bit corresponding to the filter’s * position in the pipeline (0 ≤ position < 32) is turned on. @@ -1489,7 +1489,7 @@ H5_DLL herr_t H5Drefresh(hid_t dset_id); * \p op and scatters it to the supplied buffer \p dst_buf in a * manner similar to data being written to a dataset. * - * \p dst_space_id is a dataspace which defines the extent of \p + * \p dst_space_id is a dataspace that defines the extent of \p * dst_buf and the selection within it to scatter the data to. * * \p type_id is the datatype of the data to be scattered in both @@ -1546,7 +1546,7 @@ H5_DLL herr_t H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hi * enough to hold all the data if the callback function \p op is * not provided. * - * \p op is a callback function which handles the gathered data. + * \p op is a callback function that handles the gathered data. * It is optional if \p dst_buf is large enough to hold all of the * gathered data; required otherwise. * @@ -1715,10 +1715,10 @@ H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); * * H5Dcreate() and H5Dcreate_anon() return a dataset identifier for * success or a negative value for failure. The dataset identifier - * should eventually be closed by calling H5Dclose() to release + * should eventually be closed by calling H5Dclose() to release the * resources it uses. * - * See H5Dcreate_anon() for discussion of the differences between + * See H5Dcreate_anon() for a discussion of the differences between * H5Dcreate() and H5Dcreate_anon(). * * The HDF5 library provides flexible means of specifying a fill value, @@ -1794,7 +1794,7 @@ H5_DLL hid_t H5Dopen1(hid_t loc_id, const char *name); * * This function ensures that the dataset dimensions are of at least * the sizes specified in size. The function H5Dset_extent() must be - * used if the dataset dimension sizes are are to be reduced. + * used if the dataset dimension sizes are to be reduced. * * \version 1.8.0 Function deprecated in this release. Parameter size * syntax changed to \Code{const hsize_t size[]} in this release. @@ -1822,7 +1822,7 @@ H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]); * The \p type_id must be the datatype stored in the buffer. The \p * space_id describes the selection for the memory buffer to free the * VL datatypes within. The \p dxpl_id is the dataset transfer property - * list which was used for the I/O transfer to create the buffer. And + * list that was used for the I/O transfer to create the buffer. And * \p buf is the pointer to the buffer to be reclaimed. * * The VL structures (\ref hvl_t) in the user's buffer are modified to diff --git a/src/H5EAmodule.h b/src/H5EAmodule.h index bba2a99..f992393 100644 --- a/src/H5EAmodule.h +++ b/src/H5EAmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5EA package. Including this header means that the source file - * is part of the H5EA package. + * Purpose: This file contains declarations which define macros for the + * H5EA package. Including this header means that the source file + * is part of the H5EA package. */ #ifndef H5EAmodule_H #define H5EAmodule_H diff --git a/src/H5EApkg.h b/src/H5EApkg.h index 272f1b8..5014cc5 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Tuesday, June 17, 2008 - * * Purpose: This file contains declarations which are visible only * within the H5EA package. Source files outside the H5EA * package should include H5EAprivate.h instead. diff --git a/src/H5ESmodule.h b/src/H5ESmodule.h index 1e333f7..f128fee 100644 --- a/src/H5ESmodule.h +++ b/src/H5ESmodule.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Monday, April 6, 2020 - * * Purpose: This file contains declarations which define macros for the * H5ES package. Including this header means that the source file * is part of the H5ES package. @@ -120,7 +117,7 @@ * * \brief Event Set Interface * - * \details \Bold{This interface can be only used with the HDF5 VOL connectors that + * \details \Bold{This interface can only be used with the HDF5 VOL connectors that * enable the asynchronous feature in HDF5.} The native HDF5 library has * only synchronous operations. * diff --git a/src/H5ESpkg.h b/src/H5ESpkg.h index 68e16c1..655efbb 100644 --- a/src/H5ESpkg.h +++ b/src/H5ESpkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Wednesday, April 8, 2020 - * - * Purpose: This file contains declarations which are visible only within - * the H5ES package. Source files outside the H5ES package should - * include H5ESprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5ES package. Source files outside the H5ES package should + * include H5ESprivate.h instead. */ #if !(defined H5ES_FRIEND || defined H5ES_MODULE) #error "Do not include this file outside the H5ES package!" diff --git a/src/H5Emodule.h b/src/H5Emodule.h index 0e4655c..7c4a836 100644 --- a/src/H5Emodule.h +++ b/src/H5Emodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5E package. Including this header means that the source file - * is part of the H5E package. + * Purpose: This file contains declarations which define macros for the + * H5E package. Including this header means that the source file + * is part of the H5E package. */ #ifndef H5Emodule_H #define H5Emodule_H diff --git a/src/H5Epkg.h b/src/H5Epkg.h index c6097e9..c761179 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Wednesday, April 11, 2007 - * - * Purpose: This file contains declarations which are visible only within - * the H5E package. Source files outside the H5E package should - * include H5Eprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5E package. Source files outside the H5E package should + * include H5Eprivate.h instead. */ #if !(defined H5E_FRIEND || defined H5E_MODULE) #error "Do not include this file outside the H5E package!" diff --git a/src/H5Epublic.h b/src/H5Epublic.h index dbc3457..c02049a 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -203,7 +203,7 @@ typedef herr_t (*H5E_auto2_t)(hid_t estack, void *client_data); * \param[in] cls_name Name of the error class * \param[in] lib_name Name of the client library or application to which the error class belongs * \param[in] version Version of the client library or application to which the - error class belongs. Can be \c NULL. + error class belongs. It can be \c NULL. * \return Returns a class identifier on success; otherwise returns H5I_INVALID_ID. * * \details H5Eregister_class() registers a client library or application @@ -341,12 +341,12 @@ H5_DLL herr_t H5Eclose_stack(hid_t stack_id); * * \param[in] class_id Error class identifier * \param[out] name Buffer for the error class name - * \param[in] size The maximum number of characters the class name to be returned - * by this function in\p name. + * \param[in] size The maximum number of characters of the class name to be returned + * by this function in \p name. * \return Returns non-negative value as on success; otherwise returns negative value. * * \details H5Eget_class_name() retrieves the name of the error class specified - * by the class identifier. If non-NULL pointer is passed in for \p + * by the class identifier. If a non-NULL pointer is passed in for \p * name and \p size is greater than zero, the class name of \p size * long is returned. The length of the error class name is also * returned. If NULL is passed in as \p name, only the length of class @@ -817,7 +817,7 @@ H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_ma * \deprecated 1.8.0 Function H5Eprint() renamed to H5Eprint1() and * deprecated in this release. * - * \details H5Eprint1() prints prints the error stack for the current thread + * \details H5Eprint1() prints the error stack for the current thread * on the specified stream, \p stream. Even if the error stack is empty, a * one-line message of the following form will be printed: * \code{.unparsed} diff --git a/src/H5FAmodule.h b/src/H5FAmodule.h index 3fbdb90..8ef7582 100644 --- a/src/H5FAmodule.h +++ b/src/H5FAmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5FA package. Including this header means that the source file - * is part of the H5FA package. + * Purpose: This file contains declarations which define macros for the + * H5FA package. Including this header means that the source file + * is part of the H5FA package. */ #ifndef H5FAmodule_H #define H5FAmodule_H diff --git a/src/H5FApkg.h b/src/H5FApkg.h index 48aa8df..c08e575 100644 --- a/src/H5FApkg.h +++ b/src/H5FApkg.h @@ -11,11 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: - * - * Purpose: This file contains declarations which are visible only within - * the H5FA package. Source files outside the H5FA package should - * include H5FAprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5FA package. Source files outside the H5FA package should + * include H5FAprivate.h instead. */ #if !(defined(H5FA_FRIEND) | defined(H5FA_MODULE)) #error "Do not include this file outside the H5FA package!" @@ -1501,8 +1501,6 @@ done: * * Programmer: JRM -- 6/10/20 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -1581,8 +1579,6 @@ done: * * Programmer: JRM -- 6/10/20 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -1678,8 +1674,6 @@ done: * * Programmer: NAF -- 5/19/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -1779,8 +1773,6 @@ done: * * Programmer: NAF -- 5/14/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5FDcore.h b/src/H5FDcore.h index fbff138..e4d792b 100644 --- a/src/H5FDcore.h +++ b/src/H5FDcore.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Monday, August 2, 1999 - * * Purpose: The public header file for the core driver. */ #ifndef H5FDcore_H diff --git a/src/H5FDdirect.h b/src/H5FDdirect.h index faa85db..7858dfd 100644 --- a/src/H5FDdirect.h +++ b/src/H5FDdirect.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu - * Wednesday, 20 September 2006 - * * Purpose: The public header file for the direct driver. */ #ifndef H5FDdirect_H diff --git a/src/H5FDdrvr_module.h b/src/H5FDdrvr_module.h index 4a7a4d1..c984cf5 100644 --- a/src/H5FDdrvr_module.h +++ b/src/H5FDdrvr_module.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5FD driver package. Including this header means that the source file - * is part of the H5FD driver package. + * Purpose: This file contains declarations which define macros for the + * H5FD driver package. Including this header means that the source file + * is part of the H5FD driver package. */ #ifndef H5FDdrvr_module_H #define H5FDdrvr_module_H diff --git a/src/H5FDfamily.h b/src/H5FDfamily.h index b0c560f..76020f0 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Monday, August 4, 1999 - * * Purpose: The public header file for the family driver. */ #ifndef H5FDfamily_H diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index d81e8a5..2c64237 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -924,7 +924,7 @@ done: * or "meta" (any other flag) * * Prints filename and listing of total number of reads and bytes read, - * both as a grand total and separate meta- and rawdata reads. + * both as a grand total and separate meta- and raw data reads. * * If any reads were done, prints out two tables: * @@ -1153,11 +1153,11 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) HDfprintf(stream, " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", re_dub, suffixes[suffix_i], /* bin ceiling */ m->count, /* metadata reads */ - r->count, /* rawdata reads */ + r->count, /* raw data reads */ bm_val, bm_suffix, /* metadata bytes */ - br_val, br_suffix, /* rawdata bytes */ + br_val, br_suffix, /* raw data bytes */ am_val, am_suffix, /* metadata average */ - ar_val, ar_suffix); /* rawdata average */ + ar_val, ar_suffix); /* raw data average */ HDfflush(stream); } diff --git a/src/H5FDhdfs.h b/src/H5FDhdfs.h index e3888d2..c8c2c37 100644 --- a/src/H5FDhdfs.h +++ b/src/H5FDhdfs.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Jacob Smith - * 2018-04-23 - * * Purpose: The public header file for the hdfs driver. */ @@ -90,11 +87,6 @@ extern "C" { * * TBD: If -1, relies on a default value. * - * - * - * Programmer: Jacob Smith - * 2018-04-23 - * ****************************************************************************/ #define H5FD__CURR_HDFS_FAPL_T_VERSION 1 diff --git a/src/H5FDint.c b/src/H5FDint.c index e1cb5ff..c5b8713 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -346,8 +346,6 @@ done: * * Programmer: JRM -- 6/10/20 * - * Changes: None - * *------------------------------------------------------------------------- */ herr_t @@ -558,8 +556,6 @@ done: * * Programmer: JRM -- 6/10/20 * - * Changes: None - * *------------------------------------------------------------------------- */ herr_t @@ -742,8 +738,6 @@ done: * * Programmer: NAF -- 5/13/21 * - * Changes: None - * *------------------------------------------------------------------------- */ static herr_t @@ -1066,8 +1060,6 @@ done: * * Programmer: NAF -- 3/29/21 * - * Changes: None - * *------------------------------------------------------------------------- */ herr_t @@ -1232,8 +1224,6 @@ done: * * Programmer: NAF -- 5/19/21 * - * Changes: None - * *------------------------------------------------------------------------- */ herr_t @@ -1387,8 +1377,6 @@ done: * * Programmer: NAF -- 5/13/21 * - * Changes: None - * *------------------------------------------------------------------------- */ static herr_t @@ -1709,8 +1697,6 @@ done: * * Programmer: NAF -- 3/29/21 * - * Changes: None - * *------------------------------------------------------------------------- */ herr_t @@ -1867,8 +1853,6 @@ done: * * Programmer: NAF -- 5/19/21 * - * Changes: None - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5FDlog.h b/src/H5FDlog.h index 96ded83..ae4e2d0 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Monday, April 17, 2000 - * * Purpose: The public header file for the log driver. */ #ifndef H5FDlog_H diff --git a/src/H5FDmodule.h b/src/H5FDmodule.h index 728b4b8..1e29ca9 100644 --- a/src/H5FDmodule.h +++ b/src/H5FDmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5FD package. Including this header means that the source file - * is part of the H5FD package. + * Purpose: This file contains declarations which define macros for the + * H5FD package. Including this header means that the source file + * is part of the H5FD package. */ #ifndef H5FDmodule_H #define H5FDmodule_H diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index e71c739..b7b7489 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -40,16 +40,6 @@ * Programmer: Quincey Koziol * Friday, January 30, 2004 * - * Changes: Reworked function to use the ctl callback so we can get - * rid of H5FD_class_mpi_t. Since there are no real limits - * on what the ctl callback can do, its file parameter can't - * be constant. Thus, I had to remove the const qualifier - * on this functions file parameter as well. Note also the - * circumlocution required to use the ctl callbacks output - * parameter to pass back the rank without introducing - * compiler warnings. - * JRM -- 8/13/21 - * *------------------------------------------------------------------------- */ int @@ -92,16 +82,6 @@ done: * Programmer: Quincey Koziol * Friday, January 30, 2004 * - * Changes: Reworked function to use the ctl callback so we can get - * rid of H5FD_class_mpi_t. Since there are no real limits - * on what the ctl callback can do, its file parameter can't - * be constant. Thus, I had to remove the const qualifier - * on this functions file parameter as well. Note also the - * circumlocution required to use the ctl callbacks output - * parameter to pass back the rank without introducing - * compiler warnings. - * JRM -- 8/13/21 - * *------------------------------------------------------------------------- */ int @@ -145,16 +125,6 @@ done: * Programmer: Quincey Koziol * Friday, January 30, 2004 * - * Changes: Reworked function to use the ctl callback so we can get - * rid of H5FD_class_mpi_t. Since there are no real limits - * on what the ctl callback can do, its file parameter can't - * be constant. Thus, I had to remove the const qualifier - * on this functions file parameter as well. Note also the - * circumlocution required to use the ctl callbacks output - * parameter to pass back the rank without introducing - * compiler warnings. - * JRM -- 8/13/21 - * *------------------------------------------------------------------------- */ MPI_Comm diff --git a/src/H5FDmpi.h b/src/H5FDmpi.h index fa3862b..9cee0e6 100644 --- a/src/H5FDmpi.h +++ b/src/H5FDmpi.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Friday, January 30, 2004 - * * Purpose: The public header file for common items for all MPI VFL drivers */ #ifndef H5FDmpi_H diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index ee7fa2e..3678601 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Monday, August 2, 1999 - * * Purpose: The public header file for the mpio driver. */ #ifndef H5FDmpio_H diff --git a/src/H5FDmulti.h b/src/H5FDmulti.h index e5975d3..23c3703 100644 --- a/src/H5FDmulti.h +++ b/src/H5FDmulti.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Monday, August 2, 1999 - * * Purpose: The public header file for the "multi" driver. */ #ifndef H5FDmulti_H @@ -226,17 +223,17 @@ H5_DLL herr_t H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid * * \par Example: * \code - * // Example 1: Both metadata and rawdata files are in the same + * // Example 1: Both metadata and raw data files are in the same * // directory. Use Station1-m.h5 and Station1-r.h5 as - * // the metadata and rawdata files. + * // the metadata and raw data files. * hid_t fapl, fid; * fapl = H5Pcreate(H5P_FILE_ACCESS); * H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT); * fid=H5Fcreate("Station1",H5F_ACC_TRUNC,H5P_DEFAULT,fapl); * - * // Example 2: metadata and rawdata files are in different + * // Example 2: metadata and raw data files are in different * // directories. Use PointA-m.h5 and /pfs/PointA-r.h5 as - * // the metadata and rawdata files. + * // the metadata and raw data files. * hid_t fapl, fid; * fapl = H5Pcreate(H5P_FILE_ACCESS); * H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "/pfs/%s-r.h5", H5P_DEFAULT); diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h index 893486d..b1d929c 100644 --- a/src/H5FDpkg.h +++ b/src/H5FDpkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Thursday, January 3, 2008 - * - * Purpose: This file contains declarations which are visible only within - * the H5FD package. Source files outside the H5FD package should - * include H5FDprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5FD package. Source files outside the H5FD package should + * include H5FDprivate.h instead. */ #if !(defined H5FD_FRIEND || defined H5FD_MODULE) #error "Do not include this file outside the H5FD package!" diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 0d5c323..c4ccfdd 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -10,10 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Robb Matzke - * Monday, July 26, 1999 - */ #ifndef H5FDprivate_H #define H5FDprivate_H diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 422cd18..891b348 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -10,10 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Robb Matzke - * Monday, July 26, 1999 - */ #ifndef H5FDpublic_H #define H5FDpublic_H diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 156da68..9a529d6 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -793,7 +793,7 @@ done: * or "meta" (any other flag) * * Prints filename and listing of total number of reads and bytes read, - * both as a grand total and separate meta- and rawdata reads. + * both as a grand total and separate meta- and raw data reads. * * If any reads were done, prints out two tables: * @@ -1042,11 +1042,11 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) HDfprintf(stream, " %8.3f%c %7d %7d %8.3f%c %8.3f%c %8.3f%c %8.3f%c\n", re_dub, suffixes[suffix_i], /* bin ceiling */ m->count, /* metadata reads */ - r->count, /* rawdata reads */ + r->count, /* raw data reads */ bm_val, bm_suffix, /* metadata bytes */ - br_val, br_suffix, /* rawdata bytes */ + br_val, br_suffix, /* raw data bytes */ am_val, am_suffix, /* metadata average */ - ar_val, ar_suffix); /* rawdata average */ + ar_val, ar_suffix); /* raw data average */ HDfflush(stream); } diff --git a/src/H5FDros3.h b/src/H5FDros3.h index 4c9e77f..f84b1a4 100644 --- a/src/H5FDros3.h +++ b/src/H5FDros3.h @@ -13,9 +13,6 @@ /* * Read-Only S3 Virtual File Driver (VFD) * - * Programmer: John Mainzer - * 2017-10-10 - * * Purpose: The public header file for the ros3 driver. */ #ifndef H5FDros3_H diff --git a/src/H5FDs3comms.h b/src/H5FDs3comms.h index aa354d9..1b21ad7 100644 --- a/src/H5FDs3comms.h +++ b/src/H5FDs3comms.h @@ -45,11 +45,6 @@ * ``` * ...in destination buffer. * - * TODO: put documentation in a consistent place and point to it from here. - * - * Programmer: Jacob Smith - * 2017-11-30 - * *****************************************************************************/ #include "H5private.h" /* Generic Functions */ diff --git a/src/H5FDsec2.h b/src/H5FDsec2.h index 5fa75b6..56f4575 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -11,10 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Monday, August 2, 1999 - * - * Purpose: The public header file for the sec2 driver. + * Purpose: The public header file for the sec2 driver */ #ifndef H5FDsec2_H #define H5FDsec2_H diff --git a/src/H5FDstdio.h b/src/H5FDstdio.h index 6ff5162..e2e05a7 100644 --- a/src/H5FDstdio.h +++ b/src/H5FDstdio.h @@ -11,10 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Monday, August 2, 1999 - * - * Purpose: The public header file for the sec2 driver. + * Purpose: The public header file for the C stdio driver */ #ifndef H5FDstdio_H #define H5FDstdio_H diff --git a/src/H5FDsubfiling/H5FDioc_int.c b/src/H5FDsubfiling/H5FDioc_int.c index 42f088e..ce5a000 100644 --- a/src/H5FDsubfiling/H5FDioc_int.c +++ b/src/H5FDsubfiling/H5FDioc_int.c @@ -91,7 +91,6 @@ cast_to_void(const void *data) * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ herr_t @@ -263,7 +262,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5FDsubfiling/H5FDioc_threads.c b/src/H5FDsubfiling/H5FDioc_threads.c index fd6fc01..abf816d 100644 --- a/src/H5FDsubfiling/H5FDioc_threads.c +++ b/src/H5FDsubfiling/H5FDioc_threads.c @@ -105,8 +105,6 @@ static void ioc_io_queue_add_entry(ioc_data_t *ioc_data, sf_work_request_t *wk_r * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ int @@ -264,8 +262,6 @@ finalize_ioc_threads(void *_sf_context) * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ static HG_THREAD_RETURN_TYPE @@ -339,7 +335,6 @@ ioc_thread_main(void *arg) * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ static int @@ -493,8 +488,6 @@ translate_opcode(io_op_t op) * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ static HG_THREAD_RETURN_TYPE @@ -591,8 +584,6 @@ handle_work_request(void *arg) * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ void @@ -612,8 +603,6 @@ H5FD_ioc_begin_thread_exclusive(void) * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ void @@ -679,8 +668,6 @@ from the thread pool threads... * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ static int @@ -870,8 +857,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ static int @@ -1217,8 +1202,6 @@ done: * Programmer: John Mainzer * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ @@ -1283,8 +1266,6 @@ done: * * Programmer: JRM -- 11/6/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ static ioc_io_queue_entry_t * @@ -1338,8 +1319,6 @@ ioc_io_queue_alloc_entry(void) * * Programmer: JRM -- 11/7/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ static void @@ -1461,8 +1440,6 @@ ioc_io_queue_add_entry(ioc_data_t *ioc_data, sf_work_request_t *wk_req_ptr) * * Programmer: JRM -- 11/7/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ /* TODO: Keep an eye on statistics and optimize this algorithm if necessary. While it is O(N) @@ -1629,8 +1606,6 @@ ioc_io_queue_dispatch_eligible_entries(ioc_data_t *ioc_data, hbool_t try_lock) * * Programmer: JRM -- 11/7/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ static void @@ -1715,8 +1690,6 @@ ioc_io_queue_complete_entry(ioc_data_t *ioc_data, ioc_io_queue_entry_t *entry_pt * * Programmer: JRM -- 11/6/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ static void diff --git a/src/H5FDsubfiling/H5FDsubfile_int.c b/src/H5FDsubfiling/H5FDsubfile_int.c index d4aef35..4c583e8 100644 --- a/src/H5FDsubfiling/H5FDsubfile_int.c +++ b/src/H5FDsubfiling/H5FDsubfile_int.c @@ -65,8 +65,6 @@ * * Programmer: JRM -- 12/13/21 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -280,8 +278,6 @@ done: * * Programmer: JRM -- 1/18/22 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5FDsubfiling/H5FDsubfiling.c b/src/H5FDsubfiling/H5FDsubfiling.c index afdf073..e086190 100644 --- a/src/H5FDsubfiling/H5FDsubfiling.c +++ b/src/H5FDsubfiling/H5FDsubfiling.c @@ -429,8 +429,6 @@ done: * Programmer: John Mainzer * 9/10/17 * - * Changes: None. - * *------------------------------------------------------------------------- */ herr_t @@ -945,8 +943,6 @@ done: * Programmer: John Mainzer * 9/8/17 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * @@ -1028,8 +1024,6 @@ done: * Programmer: John Mainzer * 9/8/17 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * @@ -1072,8 +1066,6 @@ done: * Programmer: John Mainzer * 9/8/17 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -2055,8 +2047,6 @@ done: * * Programmer: RAW -- ??/??/21 * - * Changes: None. - * * Notes: Thus function doesn't actually implement vector read. * Instead, it comverts the vector read call into a series * of scalar read calls. Fix this when time permits. @@ -2219,8 +2209,6 @@ done: * * Programmer: RAW -- ??/??/21 * - * Changes: None. - * * Notes: Thus function doesn't actually implement vector write. * Instead, it comverts the vector write call into a series * of scalar read calls. Fix this when time permits. diff --git a/src/H5FDsubfiling/H5subfiling_common.c b/src/H5FDsubfiling/H5subfiling_common.c index e4dcf25..58f3643 100644 --- a/src/H5FDsubfiling/H5subfiling_common.c +++ b/src/H5FDsubfiling/H5subfiling_common.c @@ -596,7 +596,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ herr_t @@ -1709,7 +1708,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ static herr_t @@ -1898,7 +1896,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ static herr_t @@ -1961,8 +1958,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ static herr_t @@ -2038,8 +2033,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ static void @@ -2091,8 +2084,6 @@ clear_fid_map_entry(uint64_t file_id, int64_t sf_context_id) * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ static herr_t @@ -2653,7 +2644,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ /*------------------------------------------------------------------------- @@ -2678,7 +2668,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. *------------------------------------------------------------------------- */ herr_t @@ -2980,8 +2969,6 @@ done: * Programmer: Richard Warren * 7/17/2020 * - * Changes: Initial Version/None. - * *------------------------------------------------------------------------- */ int64_t diff --git a/src/H5FDwindows.h b/src/H5FDwindows.h index a43e16f..a491e54 100644 --- a/src/H5FDwindows.h +++ b/src/H5FDwindows.h @@ -11,11 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Scott Wegner - * Based on code by Robb Matzke - * Thursday, May 24 2007 - * - * Purpose: The public header file for the windows driver. + * Purpose: The public header file for the Windows driver */ #ifndef H5FDwindows_H #define H5FDwindows_H diff --git a/src/H5FLmodule.h b/src/H5FLmodule.h index 0485603..5e9f157 100644 --- a/src/H5FLmodule.h +++ b/src/H5FLmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5FL package. Including this header means that the source file - * is part of the H5FL package. + * Purpose: This file contains declarations which define macros for the + * H5FL package. Including this header means that the source file + * is part of the H5FL package. */ #ifndef H5FLmodule_H #define H5FLmodule_H diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index ca16360..0fb4b32 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -24,9 +24,6 @@ #define H5FLprivate_H /* Public headers needed by this file */ -#ifdef LATER -#include "H5FLpublic.h" /*API prototypes */ -#endif /* LATER */ /* Private headers needed by this file */ diff --git a/src/H5FOprivate.h b/src/H5FOprivate.h index 9db0b0d..1f44ec8 100644 --- a/src/H5FOprivate.h +++ b/src/H5FOprivate.h @@ -16,10 +16,6 @@ #ifndef H5FOprivate_H #define H5FOprivate_H -#ifdef LATER -#include "H5FOpublic.h" -#endif /* LATER */ - /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ diff --git a/src/H5FSmodule.h b/src/H5FSmodule.h index 841b8fd..46bf8bf 100644 --- a/src/H5FSmodule.h +++ b/src/H5FSmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5FS package. Including this header means that the source file - * is part of the H5FS package. + * Purpose: This file contains declarations which define macros for the + * H5FS package. Including this header means that the source file + * is part of the H5FS package. */ #ifndef H5FSmodule_H #define H5FSmodule_H diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index 987e695..4ec7aaf 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Tuesday, May 2, 2006 - * * Purpose: This file contains declarations which are visible only within * the H5FS package. Source files outside the H5FS package should * include H5FSprivate.h instead. diff --git a/src/H5Fmodule.h b/src/H5Fmodule.h index 2d02e2f..6812ab3 100644 --- a/src/H5Fmodule.h +++ b/src/H5Fmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5F package. Including this header means that the source file - * is part of the H5F package. + * Purpose: This file contains declarations which define macros for the + * H5F package. Including this header means that the source file + * is part of the H5F package. */ #ifndef H5Fmodule_H #define H5Fmodule_H diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 8e00327..9f7002f 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Thursday, September 28, 2000 - * - * Purpose: This file contains declarations which are visible only within - * the H5F package. Source files outside the H5F package should - * include H5Fprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5F package. Source files outside the H5F package should + * include H5Fprivate.h instead. */ #if !(defined H5F_FRIEND || defined H5F_MODULE) #error "Do not include this file outside the H5F package!" diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 7d2a5da..97bf22a 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -397,7 +397,7 @@ H5_DLL hid_t H5Fcreate_async(const char *filename, unsigned flags, hid_t fcpl_id * opened. * * The \p fapl_id parameter specifies the file access property list. - * Use of #H5P_DEFAULT specifies that default I/O access properties + * The use of #H5P_DEFAULT specifies that default I/O access properties * are to be used. * * The \p flags parameter specifies whether the file will be opened in @@ -529,7 +529,7 @@ H5_DLL hid_t H5Freopen_async(hid_t file_id, hid_t es_id); * \snippet H5F_examples.c flush * * \attention HDF5 does not possess full control over buffering. H5Fflush() - * flushes the internal HDF5 buffers then asks the operating system + * flushes the internal HDF5 buffers and then asks the operating system * (the OS) to flush the system buffers for the open files. After * that, the OS is responsible for ensuring that the data is * actually flushed to disk. @@ -567,7 +567,7 @@ H5_DLL herr_t H5Fflush_async(hid_t object_id, H5F_scope_t scope, hid_t es_id); * \snippet H5F_examples.c minimal * * \note \Bold{Delayed close:} Note the following deviation from the - * above-described behavior. If H5Fclose() is called for a file but one + * above-described behavior. If H5Fclose() is called for a file, but one * or more objects within the file remain open, those objects will remain * accessible until they are individually closed. Thus, if the dataset * \c data_sample is open when H5Fclose() is called for the file @@ -576,7 +576,7 @@ H5_DLL herr_t H5Fflush_async(hid_t object_id, H5F_scope_t scope, hid_t es_id); * automatically closed once all objects in the file have been closed.\n * Be warned, however, that there are circumstances where it is not * possible to delay closing a file. For example, an MPI-IO file close is - * a collective call; all of the processes that opened the file must + * a collective call; all of the processes that open the file must * close it collectively. The file cannot be closed at some time in the * future by each process in an independent fashion. Another example is * that an application using an AFS token-based file access privilege may @@ -1359,7 +1359,7 @@ H5_DLL herr_t H5Fstart_swmr_write(hid_t file_id); * \snippet this H5F_sect_info_t_snip * * This routine retrieves free-space section information for \p nsects - * sections or at most the maximum number of sections in the specified + * sections or, at most, the maximum number of sections in the specified * free-space manager. If the number of sections is not known, a * preliminary H5Fget_free_sections() call can be made by setting \p * sect_info to NULL and the total number of free-space sections for @@ -1661,7 +1661,7 @@ H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t * file_id. This setting is used to inform the library to create * minimized dataset object headers when \c TRUE. * - * The setting's value is returned in the boolean pointer minimize. + * The setting's value is returned in the boolean pointer minimized. * * \since 1.10.5 * @@ -1887,7 +1887,7 @@ H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *file_info); /** * \ingroup H5F * - * \brief Sets thelatest version of the library to be used for writing objects + * \brief Sets the latest version of the library to be used for writing objects * * \file_id * \param[in] latest_format Latest format flag diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 5d9b628..467e287 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -433,6 +433,8 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS if (H5F__superblock_prefix_decode(sblock, &image, udata, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file superblock prefix") + const uint8_t *image_end = image + len - 1; + /* Check for older version of superblock format */ if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { uint32_t status_flags; /* File status flags */ @@ -440,10 +442,18 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */ unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Freespace version (hard-wired) */ if (HDF5_FREESPACE_VERSION != *image++) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number") + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Root group version number (hard-wired) */ if (HDF5_OBJECTDIR_VERSION != *image++) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number") @@ -451,6 +461,10 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS /* Skip over reserved byte */ image++; + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Shared header version number (hard-wired) */ if (HDF5_SHAREDHEADER_VERSION != *image++) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number") @@ -466,12 +480,20 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS /* Skip over reserved byte */ image++; + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, sizeof(uint16_t), image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Various B-tree sizes */ UINT16DECODE(image, sym_leaf_k); if (sym_leaf_k == 0) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad symbol table leaf node 1/2 rank") udata->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, sizeof(uint16_t), image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Need 'get' call to set other array values */ UINT16DECODE(image, snode_btree_k); if (snode_btree_k == 0) @@ -483,6 +505,10 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS * for the indexed storage B-tree internal 'K' value later. */ + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, sizeof(uint32_t), image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* File status flags (not really used yet) */ UINT32DECODE(image, status_flags); HDassert(status_flags <= 255); @@ -495,16 +521,29 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS * storage B-tree internal 'K' value */ if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, sizeof(uint16_t), image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + UINT16DECODE(image, chunk_btree_k); /* Reserved bytes are present only in version 1 */ - if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) + if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) { image += 2; /* reserved */ - } /* end if */ + + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + } + } /* end if */ else chunk_btree_k = HDF5_BTREE_CHUNK_IK_DEF; udata->btree_k[H5B_CHUNK_ID] = chunk_btree_k; + /* Check whether the image pointer will be out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, H5F_SIZEOF_ADDR(udata->f) * 4, image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Remainder of "variable-sized" portion of superblock */ 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*/); @@ -518,7 +557,7 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS "can't allocate space for root group symbol table entry") /* decode the root group symbol table entry */ - if (H5G_ent_decode(udata->f, (const uint8_t **)&image, sblock->root_ent) < 0) + if (H5G_ent_decode(udata->f, (const uint8_t **)&image, sblock->root_ent, image_end) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode root group symbol table entry") /* Set the root group address to the correct value */ @@ -544,16 +583,23 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS /* Skip over size of file addresses (already decoded) */ image++; udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */ - /* Skip over size of file sizes (already decoded) */ image++; udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* File status flags (not really used yet) */ sblock->status_flags = *image++; if (sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") + /* Check whether the image pointer will be out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, H5F_SIZEOF_ADDR(udata->f) * 4, image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Base, superblock extension, end of file & root group object header addresses */ 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*/); @@ -562,6 +608,10 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS /* checksum verification already done in verify_chksum cb */ + /* Check whether the image pointer will be out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, sizeof(uint32_t), image_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds") + /* Decode checksum */ UINT32DECODE(image, read_chksum); diff --git a/src/H5Gent.c b/src/H5Gent.c index f58ef5c..096e13e 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -93,7 +93,7 @@ H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5 for (u = 0; u < n; u++) { if (*pp > p_end) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "ran off the end of the image buffer") - if (H5G_ent_decode(f, pp, ent + u) < 0) + if (H5G_ent_decode(f, pp, ent + u, p_end) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode") } @@ -117,7 +117,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) +H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, const uint8_t *p_end) { const uint8_t *p_ret = *pp; uint32_t tmp; @@ -130,11 +130,22 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) HDassert(pp); HDassert(ent); + if (H5_IS_BUFFER_OVERFLOW(*pp, ent->name_off, p_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, FAIL, "image pointer is out of bounds") + /* decode header */ H5F_DECODE_LENGTH(f, *pp, ent->name_off); + + 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") + H5F_addr_decode(f, pp, &(ent->header)); UINT32DECODE(*pp, tmp); *pp += 4; /*reserved*/ + + if (H5_IS_BUFFER_OVERFLOW(*pp, 1, p_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, FAIL, "image pointer is out of bounds") + ent->type = (H5G_cache_type_t)tmp; /* decode scratch-pad */ @@ -144,11 +155,15 @@ H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) case H5G_CACHED_STAB: HDassert(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") 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: + if (H5_IS_BUFFER_OVERFLOW(*pp, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, FAIL, "image pointer is out of bounds") UINT32DECODE(*pp, ent->cache.slink.lval_offset); break; diff --git a/src/H5Gmodule.h b/src/H5Gmodule.h index d4738f6..bebca87 100644 --- a/src/H5Gmodule.h +++ b/src/H5Gmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5G package. Including this header means that the source file - * is part of the H5G package. + * Purpose: This file contains declarations which define macros for the + * H5G package. Including this header means that the source file + * is part of the H5G package. */ #ifndef H5Gmodule_H #define H5Gmodule_H @@ -886,24 +883,24 @@ * objects appear in at least one group (with the possible exception of * the root object) and since objects can have names in more than one * group, the set of all objects in an HDF5 file is a directed - * graph. The internal nodes (nodes with out-degree greater than zero) - * must be groups while the leaf nodes (nodes with out-degree zero) are + * graph. The internal nodes (nodes with an out-degree greater than zero) + * must be groups, while the leaf nodes (nodes with an out-degree zero) are * either empty groups or objects of some other type. Exactly one * object in every non-empty file is the root object. The root object * always has a positive in-degree because it is pointed to by the file - * super block. + * superblock. * * \Bold{Locating objects in the HDF5 file hierarchy:} An object name * consists of one or more components separated from one another by - * slashes. An absolute name begins with a slash and the object is + * slashes. An absolute name begins with a slash, and the object is * located by looking for the first component in the root object, then * looking for the second component in the first object, etc., until * the entire name is traversed. A relative name does not begin with a - * slash and the traversal begins at the location specified by the + * slash, and the traversal begins at the location specified by the * create or access function. * * \Bold{Group implementations in HDF5:} The original HDF5 group - * implementation provided a single indexed structure for link + * implementation provided a single-indexed structure for link * storage. A new group implementation, in HDF5 Release 1.8.0, enables * more efficient compact storage for very small groups, improved link * indexing for large groups, and other advanced features. diff --git a/src/H5Goh.c b/src/H5Goh.c index 5e8ab02..94d51f0 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -246,7 +246,7 @@ H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) HDassert(crt_info); HDassert(obj_loc); - /* Create the the group */ + /* Create the group */ if (NULL == (grp = H5G__create(f, crt_info))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index ce85f27..fdc05ec 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Thursday, September 18, 1997 - * * Purpose: This file contains declarations which are visible * only within the H5G package. Source files outside the * H5G package should include H5Gprivate.h instead. diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 0042fb2..2819e4f 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -248,7 +248,7 @@ H5_DLL herr_t H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, i * These functions operate on group object locations. */ H5_DLL herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent); -H5_DLL herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent); +H5_DLL herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, const uint8_t *p_end); /* * These functions operate on group hierarchy names. diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index ace2071..0e0a58b 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -406,7 +406,7 @@ H5_DLL herr_t H5Gget_info_by_idx_async(hid_t loc_id, const char *group_name, H5_ * \return \herr_t * * \details H5Gflush() causes all buffers associated with a group to be - * immediately flushed to disk without removing the data from + * immediately flushed to the disk without removing the data from * the cache. * * \attention @@ -414,7 +414,7 @@ H5_DLL herr_t H5Gget_info_by_idx_async(hid_t loc_id, const char *group_name, H5_ * flushes the internal HDF5 buffers and then asks the operating * system (the OS) to flush the system buffers for the open * files. After that, the OS is responsible for ensuring that - * the data is actually flushed to disk. + * the data is actually flushed to the disk. * * \since 1.8.0 * @@ -435,7 +435,7 @@ H5_DLL herr_t H5Gflush(hid_t group_id); * cleared and immediately re-loaded with updated contents from disk. * * This function essentially closes the group, evicts all - * metadata associated with it from the cache, and then re-opens + * metadata associated with it from the cache, and then reopens * the group. The reopened group is automatically re-registered * with the same identifier. * @@ -454,7 +454,7 @@ H5_DLL herr_t H5Grefresh(hid_t group_id); * * \return \herr_t * - * \details H5Gclose() releases resources used by a group which was + * \details H5Gclose() releases resources used by a group that was * opened by H5Gcreate() or H5Gopen(). After closing a group, * \p group_id cannot be used again until another H5Gcreate() * or H5Gopen() is called on it. @@ -926,7 +926,7 @@ H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment * \deprecated This function is deprecated in favor of the function * H5Oget_comment(). * - * \details H5Gget_comment() retrieves the comment for the the object specified + * \details H5Gget_comment() retrieves the comment for the object specified * by \p loc_id and \p name. The comment is returned in the buffer \p * buf. * @@ -987,7 +987,7 @@ H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char * * The operation receives the group identifier for the group being * iterated over, \p group, the name of the current object within * the group, \p name, and the pointer to the operator data - * passed in to H5Giterate(), \p op_data. + * passed into H5Giterate(), \p op_data. * * The return values from an operator are: * \li Zero causes the iterator to continue, returning zero when all @@ -1096,7 +1096,7 @@ H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link *------------------------------------------------------------------------- * \ingroup H5G * - * \brief Returns a name of an object specified by an index + * \brief Returns the name of an object specified by an index * * \fg_loc_id * \param[in] idx Transient index identifying object @@ -1109,7 +1109,7 @@ H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link * * \deprecated This function is deprecated in favor of the function H5Lget_name_by_idx(). * - * \details H5Gget_objname_by_idx() returns a name of the object specified by + * \details H5Gget_objname_by_idx() returns the name of the object specified by * the index \p idx in the group \p loc_id. * * The group is specified by a group identifier \p loc_id. If diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 3cb067c..ab01c1e 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -3385,7 +3385,7 @@ H5HF__cache_verify_descendant_iblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5 * If the entry is unprotected and unpinned, we simply * protect it. * - * If, however, the the child iblock is already protected, + * If, however, the child iblock is already protected, * but not pinned, we have a bit of a problem, as we have * no legitimate way of looking up its pointer in memory. * diff --git a/src/H5HFmodule.h b/src/H5HFmodule.h index 818c3d4..c4fb437 100644 --- a/src/H5HFmodule.h +++ b/src/H5HFmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5HF package. Including this header means that the source file - * is part of the H5HF package. + * Purpose: This file contains declarations which define macros for the + * H5HF package. Including this header means that the source file + * is part of the H5HF package. */ #ifndef H5HFmodule_H #define H5HFmodule_H diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index f1ac41d..83fda1f 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Friday, February 24, 2006 - * - * Purpose: This file contains declarations which are visible only within - * the H5HF package. Source files outside the H5HF package should - * include H5HFprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5HF package. Source files outside the H5HF package should + * include H5HFprivate.h instead. */ #if !(defined H5HF_FRIEND || defined H5HF_MODULE) #error "Do not include this file outside the H5HF package!" diff --git a/src/H5HGmodule.h b/src/H5HGmodule.h index 412223e..772ebe6 100644 --- a/src/H5HGmodule.h +++ b/src/H5HGmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5HG package. Including this header means that the source file - * is part of the H5HG package. + * Purpose: This file contains declarations which define macros for the + * H5HG package. Including this header means that the source file + * is part of the H5HG package. */ #ifndef H5HGmodule_H #define H5HGmodule_H diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index 5623e8b..ab7cd09 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Wednesday, July 9, 2003 - * * Purpose: This file contains declarations which are visible * only within the H5HG package. Source files outside the * H5HG package should include H5HGprivate.h instead. diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h index fae3713..892a0c7 100644 --- a/src/H5HGprivate.h +++ b/src/H5HGprivate.h @@ -10,10 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Robb Matzke - * Friday, March 27, 1998 - */ #ifndef H5HGprivate_H #define H5HGprivate_H diff --git a/src/H5HLmodule.h b/src/H5HLmodule.h index 5432f1a..1a871ab 100644 --- a/src/H5HLmodule.h +++ b/src/H5HLmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5HL package. Including this header means that the source file - * is part of the H5HL package. + * Purpose: This file contains declarations which define macros for the + * H5HL package. Including this header means that the source file + * is part of the H5HL package. */ #ifndef H5HLmodule_H #define H5HLmodule_H diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index 9471bd9..47c2060 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Wednesday, July 9, 2003 - * * Purpose: This file contains declarations which are visible * only within the H5HL package. Source files outside the * H5HL package should include H5HLprivate.h instead. diff --git a/src/H5Imodule.h b/src/H5Imodule.h index 9470cc9..e682850 100644 --- a/src/H5Imodule.h +++ b/src/H5Imodule.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * * Purpose: This file contains declarations which define macros for the * H5I package. Including this header means that the source file * is part of the H5I package. diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index b921ea0..1009ecb 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Thursday, May 15, 2003 - * - * Purpose: This file contains declarations which are visible only within - * the H5I package. Source files outside the H5I package should - * include H5Iprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5I package. Source files outside the H5I package should + * include H5Iprivate.h instead. */ #if !(defined H5I_FRIEND || defined H5I_MODULE) #error "Do not include this file outside the H5I package!" diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index d699c92..69b2450 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -235,7 +235,7 @@ H5_DLL hid_t H5Iget_file_id(hid_t id); * \brief Retrieves a name of an object based on the object identifier * * \obj_id{id} - * \param[out] name A buffer for thename associated with the identifier + * \param[out] name A buffer for the name associated with the identifier * \param[in] size The size of the \p name buffer; usually the size of * the name in bytes plus 1 for a NULL terminator * @@ -339,7 +339,7 @@ H5_DLL int H5Iinc_ref(hid_t id); * with H5Iinc_ref(). When an object identifier’s reference count * reaches zero, the object will be closed. Calling an object * identifier’s \c close function decrements the reference count for - * the identifier which normally closes the object, but if the + * the identifier, which normally closes the object, but if the * reference count for the identifier has been incremented with * H5Iinc_ref(), the object will only be closed when the reference * count reaches zero with further calls to this function or the @@ -348,15 +348,15 @@ H5_DLL int H5Iinc_ref(hid_t id); * If the object ID was created by a collective parallel call (such as * H5Dcreate(), H5Gopen(), etc.), the reference count should be * modified by all the processes which have copies of the ID. - * Generally this means that group, dataset, attribute, file and named + * Generally, this means that group, dataset, attribute, file and named * datatype IDs should be modified by all the processes and that all * other types of IDs are safe to modify by individual processes. * - * This function is of particular value when an application is - * maintaining multiple copies of an object ID. The object ID can be + * This function is of particular value when an application + * maintains multiple copies of an object ID. The object ID can be * incremented when a copy is made. Each copy of the ID can then be * safely closed or decremented and the HDF5 object will be closed - * when the reference count for that that object drops to zero. + * when the reference count for that object drops to zero. * * \since 1.6.2 * @@ -643,7 +643,7 @@ H5_DLL htri_t H5Itype_exists(H5I_type_t type); * \details Valid identifiers are those that have been obtained by an * application and can still be used to access the original target. * Examples of invalid identifiers include: - * \li Out of range values: negative, for example + * \li Out-of-range values: negative, for example * \li Previously-valid identifiers that have been released: * for example, a dataset identifier for which the dataset has * been closed @@ -651,7 +651,7 @@ H5_DLL htri_t H5Itype_exists(H5I_type_t type); * H5Iis_valid() can be used with any type of identifier: object * identifier, property list identifier, attribute identifier, error * message identifier, etc. When necessary, a call to H5Iget_type() - * can determine the type of the object that \p id identifies. + * can determine the type of object that the \p id identifies. * * \since 1.8.3 * diff --git a/src/H5Ldevelop.h b/src/H5Ldevelop.h index 34e50a0..148a5a5 100644 --- a/src/H5Ldevelop.h +++ b/src/H5Ldevelop.h @@ -30,6 +30,16 @@ */ #define H5L_LINK_CLASS_T_VERS 1 +/** + * \brief Version of external link format + */ +#define H5L_EXT_VERSION 0 + +/** + * \brief Valid flags for external links + */ +#define H5L_EXT_FLAGS_ALL 0 + /*******************/ /* Public Typedefs */ /*******************/ diff --git a/src/H5Lmodule.h b/src/H5Lmodule.h index cbb5060..26f9045 100644 --- a/src/H5Lmodule.h +++ b/src/H5Lmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5L package. Including this header means that the source file - * is part of the H5L package. + * Purpose: This file contains declarations which define macros for the + * H5L package. Including this header means that the source file + * is part of the H5L package. */ #ifndef H5Lmodule_H #define H5Lmodule_H diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h index 6fd15e7..53737d1 100644 --- a/src/H5Lpkg.h +++ b/src/H5Lpkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: James Laird - * Friday, December 1, 2005 - * * Purpose: This file contains declarations which are visible * only within the H5L package. Source files outside the * H5L package should include H5Lprivate.h instead. @@ -34,12 +31,6 @@ /* Package Private Macros */ /**************************/ -/* Version of external link format */ -#define H5L_EXT_VERSION 0 - -/* Valid flags for external links */ -#define H5L_EXT_FLAGS_ALL 0 - /****************************/ /* Package Private Typedefs */ /****************************/ diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 6feefcd..653bf27 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -209,7 +209,7 @@ H5_DLL herr_t H5Lmove(hid_t src_loc, const char *src_name, hid_t dst_loc, const * * H5Lcopy() retains the creation time and the target of the original * link. However, since the link may be renamed, the character - * encoding is that specified in \p lcpl_id rather than that of the + * encoding is specified in \p lcpl_id rather than in that of the * original link. Other link creation properties are ignored. * * If the link is a soft link, also known as a symbolic link, its @@ -337,7 +337,7 @@ H5_DLL herr_t H5Lcreate_hard_async(hid_t cur_loc_id, const char *cur_name, hid_t * * For instance, if target_path is \c ./foo, \p link_loc_id specifies * \c ./x/y/bar, and the name of the new link is \c new_link, then a - * subsequent request for \c ./x/y/bar/new_link will return same the + * subsequent request for \c ./x/y/bar/new_link will return the same * object as would be found at \c ./foo. * * \note H5Lcreate_soft() is for use only if the target object is in the @@ -480,7 +480,7 @@ H5_DLL herr_t H5Ldelete_by_idx_async(hid_t loc_id, const char *group_name, H5_in * * \return \herr_t * - * \details H5Lget_val() returns the value of link \p name. For smbolic links, + * \details H5Lget_val() returns the value of link \p name. For symbolic links, * this is the path to which the link points, including the null * terminator. For external and user-defined links, it is the link * buffer. @@ -607,7 +607,7 @@ H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t * the link \c datasetD in the \c group group1/group2/softlink_to_group3/, * where \c group1 is a member of the group specified by \c loc_id: * - * 1. First use H5Lexists() to verify that \c group1 exists. + * 1. First, use H5Lexists() to verify that the \c group1 exists. * 2. If \c group1 exists, use H5Lexists() again, this time with name * set to \c group1/group2, to verify that \c group2 exists. * 3. If \c group2 exists, use H5Lexists() with name set to @@ -624,7 +624,7 @@ H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t * \c /group1/group2/softlink_to_group3, the first call to H5Lexists() * would have name set to \c /group1. * - * Note that this is an outline and does not include all necessary + * Note that this is an outline and does not include all the necessary * details. Depending on circumstances, for example, you may need to * verify that an intermediate link points to a group and that a soft * link points to an existing target. @@ -713,7 +713,7 @@ H5_DLL herr_t H5Lexists_async(hid_t loc_id, const char *name, hbool_t *exists, h * There will be additional valid values if user-defined links have * been registered. * - * \p corder specifies the link’s creation order position while + * \p corder specifies the link’s creation order position, while * \p corder_valid indicates whether the value in corder is valid. * * If \p corder_valid is \c TRUE, the value in \p corder is known to @@ -732,7 +732,7 @@ H5_DLL herr_t H5Lexists_async(hid_t loc_id, const char *name, hbool_t *exists, h * This value is set with #H5Pset_char_encoding. * * \c token is the location that a hard link points to, and - * \c val_size is the size of a soft link or user defined link value. + * \c val_size is the size of a soft link or user-defined link value. * H5O_token_t is used in the VOL layer. It is defined in H5public.h * as: * \snippet H5public.h H5O_token_t_snip @@ -1118,7 +1118,7 @@ H5_DLL herr_t H5Lvisit2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order * (with an absolute name based in the file’s root group) or a group * relative to \p loc_id. If \p loc_id fully specifies the group that * is to serve as the root of the iteration, group_name should be '.' - * (a dot). (Note that when \p loc_id fully specifies the the group + * (a dot). (Note that when \p loc_id fully specifies the group * that is to serve as the root of the iteration, the user may wish to * consider using H5Lvisit2() instead of H5Lvisit_by_name2().) * @@ -1363,7 +1363,7 @@ H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval /*in*/, size_t link_si * If that target file does not exist, the new \p file_name after * stripping will be \c A.h5. * - For Windows, there are 6 cases: - * -# \p file_name is an absolute drive with absolute pathname. + * -# \p file_name is an absolute drive with an absolute pathname. * For example, consider a \p file_name of \c /tmp/A.h5. If that * target file does not exist, the new \p file_name after * stripping will be \c A.h5. @@ -1371,16 +1371,16 @@ H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval /*in*/, size_t link_si * name. For example, consider a \p file_name of \c /tmp/A.h5. * If that target file does not exist, the new \p file_name after * stripping will be \c A.h5. - * -# \p file_name is an absolute drive with relative pathname. + * -# \p file_name is an absolute drive with a relative pathname. * For example, consider a \p file_name of \c /tmp/A.h5. If that * target file does not exist, the new \p file_name after * stripping will be \c tmp\A.h5. * -# \p file_name is in UNC (Uniform Naming Convention) format with - * server name, share name, and pathname. For example, consider + * a server name, share name, and pathname. For example, consider * a \p file_name of \c /tmp/A.h5. If that target file does not * exist, the new \p file_name after stripping will be \c A.h5. * -# \p file_name is in Long UNC (Uniform Naming Convention) format - * with server name, share name, and pathname. For example, + * with a server name, share name, and pathname. For example, * consider a \p file_name of \c /tmp/A.h5. If that target file * does not exist, the new \p file_name after stripping will be * \c A.h5. @@ -1390,7 +1390,7 @@ H5_DLL herr_t H5Lunpack_elink_val(const void *ext_linkval /*in*/, size_t link_si * does not exist, the new \p file_name after stripping will be * \c A.h5. * - * The library opens target file \p file_name with the file access + * The library opens the target file \p file_name with the file access * property list that is set via H5Pset_elink_fapl() when the external * link link_name is accessed. If no such property list is set, the * library uses the file access property list associated with the file @@ -1879,7 +1879,7 @@ H5_DLL herr_t H5Lvisit1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order * (with an absolute name based in the file’s root group) or a group * relative to \p loc_id. If \p loc_id fully specifies the group that * is to serve as the root of the iteration, group_name should be '.' - * (a dot). (Note that when \p loc_id fully specifies the the group + * (a dot). (Note that when \p loc_id fully specifies the group * that is to serve as the root of the iteration, the user may wish to * consider using H5Lvisit1() instead of H5Lvisit_by_name1().) * @@ -3236,7 +3236,7 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) * multi file drivers, as the self referential free space * manager header and section info can be stored in up to * two different files -- requiring that up to two EOA's - * be stored in the the free space managers super block + * be stored in the free space manager's superblock * extension message. * * As of this writing, we are solving this problem by diff --git a/src/H5MFmodule.h b/src/H5MFmodule.h index 3e806c6..dd32cdc 100644 --- a/src/H5MFmodule.h +++ b/src/H5MFmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5MF package. Including this header means that the source file - * is part of the H5MF package. + * Purpose: This file contains declarations which define macros for the + * H5MF package. Including this header means that the source file + * is part of the H5MF package. */ #ifndef H5MFmodule_H #define H5MFmodule_H diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index 2711fcf..b679674 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Tuesday, January 8, 2008 - * * Purpose: This file contains declarations which are visible only within * the H5MF package. Source files outside the H5MF package should * include H5MFprivate.h instead. diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index 86fe433..f5874e8 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -211,7 +211,7 @@ extern "C" { * \details H5Mcreate() creates a new map object for storing key-value * pairs. The in-file datatype for keys is defined by \p key_type_id * and the in-file datatype for values is defined by \p val_type_id. \p - * loc_id specifies the location to create the the map object and \p + * loc_id specifies the location to create the map object and \p * name specifies the name of the link to the map object relative to * \p loc_id. * diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index 3364a67..f2ce582 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -13,8 +13,6 @@ /*------------------------------------------------------------------------- * * Created: H5Oainfo.c - * Mar 6 2007 - * Quincey Koziol * * Purpose: Attribute Information messages. * @@ -88,27 +86,28 @@ H5FL_DEFINE_STATIC(H5O_ainfo_t); * * Return: Success: Ptr to new message in native form. * Failure: NULL - * - * Programmer: Quincey Koziol - * Mar 6 2007 - * *------------------------------------------------------------------------- */ static void * H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_ainfo_t *ainfo = NULL; /* Attribute info */ - unsigned char flags; /* Flags for encoding attribute info */ - void *ret_value = NULL; /* Return value */ + const uint8_t *p_end = p + p_size - 1; /* End of input buffer */ + H5O_ainfo_t *ainfo = NULL; /* Attribute info */ + unsigned char flags; /* Flags for encoding attribute info */ + uint8_t sizeof_addr; /* Size of addresses in this file */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* check args */ HDassert(f); HDassert(p); + sizeof_addr = H5F_sizeof_addr(f); + /* Version of message */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); if (*p++ != H5O_AINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") @@ -117,6 +116,8 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the flags for the message */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); flags = *p++; if (flags & ~H5O_AINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") @@ -127,20 +128,30 @@ H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS ainfo->nattrs = HSIZET_MAX; /* Max. creation order value for the object */ - if (ainfo->track_corder) + 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) + } else ainfo->max_crt_idx = H5O_MAX_CRT_ORDER_IDX; /* 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"); 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"); 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 (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"); H5F_addr_decode(f, &p, &(ainfo->corder_bt2_addr)); + } else ainfo->corder_bt2_addr = HADDR_UNDEF; diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 17c1535..8484678 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -517,7 +517,7 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size HDassert(H5F_addr_defined(oh->chunk[chunkno].addr)); /* Test to see if the specified chunk ends with a null messages. - * If successful, set the index of the the null message in extend_msg. + * If successful, set the index of the null message in extend_msg. */ for (u = 0; u < oh->nmesgs; u++) { /* Check for null message at end of proper chunk */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index e431cd2..1d48a78 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -112,95 +112,125 @@ H5FL_EXTERN(H5S_extent_t); Pointer to the new message in native order on success, NULL on failure DESCRIPTION This function decodes the "raw" disk form of a attribute message - into a struct in memory native format. The struct is allocated within this - function using malloc() and is returned to the caller. + into a struct in memory native format. The struct is allocated within this + function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p) { - H5A_t *attr = NULL; - H5S_extent_t *extent; /*extent dimensionality information */ - size_t name_len; /*attribute name length */ - size_t dt_size; /* Datatype size */ - hssize_t sds_size; /* Signed Dataspace size */ - hsize_t ds_size; /* Dataspace size */ - unsigned flags = 0; /* Attribute flags */ - H5A_t *ret_value = NULL; /* Return value */ + H5A_t *attr = NULL; + const uint8_t *p_end = p + p_size - 1; /* End of input buffer */ + size_t delta = 0; /* Amount to move p in next field */ + H5S_extent_t *extent = NULL; /* Extent dimensionality information */ + size_t name_len; /* Attribute name length */ + size_t dt_size; /* Datatype size */ + hssize_t sds_size; /* Signed Dataspace size */ + hsize_t ds_size; /* Dataspace size */ + unsigned flags = 0; /* Attribute flags */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* check args */ HDassert(f); HDassert(p); if (NULL == (attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if (NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared attr structure") /* Version number */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); attr->shared->version = *p++; if (attr->shared->version < H5O_ATTR_VERSION_1 || attr->shared->version > H5O_ATTR_VERSION_LATEST) HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "bad version number for attribute message") /* Get the flags byte if we have a later version of the attribute */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); if (attr->shared->version >= H5O_ATTR_VERSION_2) { flags = *p++; /* Check for unknown flag */ if (flags & (unsigned)~H5O_ATTR_FLAG_ALL) HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "unknown flag for attribute message") - } /* end if */ + } else - p++; /* Byte is unused when version<2 */ + p++; /* Byte is unused when version < 2 */ - /* - * Decode the sizes of the parts of the attribute. The sizes stored in + /* Decode the sizes of the parts of the attribute. The sizes stored in * the file are exact but the parts are aligned on 8-byte boundaries. */ - UINT16DECODE(p, name_len); /*including null*/ + 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, name_len); /* Including null */ + 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, attr->shared->dt_size); + 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, attr->shared->ds_size); - /* - * Decode the character encoding for the name for versions 3 or later, + /* Decode the character encoding for the name for versions 3 or later, * as well as some reserved bytes. */ - if (attr->shared->version >= H5O_ATTR_VERSION_3) + if (attr->shared->version >= H5O_ATTR_VERSION_3) { + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); attr->shared->encoding = (H5T_cset_t)*p++; + } - /* Decode and store the name */ - if (NULL == (attr->shared->name = H5MM_strdup((const char *)p))) + /* Decode and store the name + * + * NOTE: If the buffer overflow error message changes, test_corrupted_attnamelen() + * in titerate.c will fail since it looks for it explicitly. + */ + if (H5_IS_BUFFER_OVERFLOW(p, name_len, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); + if (NULL == (attr->shared->name = H5MM_strndup((const char *)p, name_len - 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Make an attempt to detect corrupted name or name length - HDFFV-10588 */ - if (name_len != (HDstrlen(attr->shared->name) + 1)) + if (name_len != (HDstrnlen(attr->shared->name, name_len) + 1)) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "attribute name has different length than stored length") + /* Determine pointer movement and check if it's valid */ if (attr->shared->version < H5O_ATTR_VERSION_2) - p += H5O_ALIGN_OLD(name_len); /* advance the memory pointer */ + delta = H5O_ALIGN_OLD(name_len); else - p += name_len; /* advance the memory pointer */ + delta = name_len; + if (H5_IS_BUFFER_OVERFLOW(p, delta, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); + p += delta; /* Decode the attribute's datatype */ + if (H5_IS_BUFFER_OVERFLOW(p, attr->shared->dt_size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); if (NULL == (attr->shared->dt = (H5T_t *)(H5O_MSG_DTYPE->decode)( f, open_oh, ((flags & H5O_ATTR_FLAG_TYPE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->dt_size, p))) HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype") + + /* Determine pointer movement and check if it's valid */ if (attr->shared->version < H5O_ATTR_VERSION_2) - p += H5O_ALIGN_OLD(attr->shared->dt_size); + delta = H5O_ALIGN_OLD(attr->shared->dt_size); else - p += attr->shared->dt_size; + delta = attr->shared->dt_size; + if (H5_IS_BUFFER_OVERFLOW(p, delta, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); + p += delta; - /* decode the attribute dataspace. It can be shared in versions >= 3 + /* Decode the attribute dataspace. It can be shared in versions >= 3 * What's actually shared, though, is only the extent. */ if (NULL == (attr->shared->ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Decode attribute's dataspace extent */ + if (H5_IS_BUFFER_OVERFLOW(p, attr->shared->ds_size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); if ((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)( f, open_oh, ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), ioflags, attr->shared->ds_size, p)) == NULL) @@ -216,10 +246,14 @@ H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, u if (H5S_select_all(attr->shared->ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") + /* Determine pointer movement and check if it's valid */ if (attr->shared->version < H5O_ATTR_VERSION_2) - p += H5O_ALIGN_OLD(attr->shared->ds_size); + delta = H5O_ALIGN_OLD(attr->shared->ds_size); else - p += attr->shared->ds_size; + delta = attr->shared->ds_size; + if (H5_IS_BUFFER_OVERFLOW(p, delta, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); + p += delta; /* Get the datatype & dataspace sizes */ if (0 == (dt_size = H5T_get_size(attr->shared->dt))) @@ -234,17 +268,18 @@ H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, u if ((attr->shared->data_size / dt_size) != ds_size) HGOTO_ERROR(H5E_RESOURCE, H5E_OVERFLOW, NULL, "data size exceeds addressable range") - /* Go get the data */ + /* Get the data */ if (attr->shared->data_size) { /* Ensure that data size doesn't exceed buffer size, in case of - it's being corrupted in the file */ - if (attr->shared->data_size > p_size) - HGOTO_ERROR(H5E_RESOURCE, H5E_OVERFLOW, NULL, "data size exceeds buffer size") + * it's being corrupted in the file + */ + if (H5_IS_BUFFER_OVERFLOW(p, attr->shared->data_size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); if (NULL == (attr->shared->data = H5FL_BLK_MALLOC(attr_buf, attr->shared->data_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") H5MM_memcpy(attr->shared->data, p, attr->shared->data_size); - } /* end if */ + } /* Increment the reference count for this object header message in cache(compact storage) or for the object from dense storage. */ @@ -254,15 +289,16 @@ H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, u ret_value = attr; done: - if (NULL == ret_value) + if (NULL == ret_value) { if (attr) { - /* Free any dynamically allocated items */ if (attr->shared) if (H5A__shared_free(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info") - attr = H5FL_FREE(H5A_t, attr); - } /* end if */ + } + if (extent) + extent = H5FL_FREE(H5S_extent_t, extent); + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__attr_decode() */ diff --git a/src/H5Obtreek.c b/src/H5Obtreek.c index ff157da..c21b3b9 100644 --- a/src/H5Obtreek.c +++ b/src/H5Obtreek.c @@ -59,33 +59,32 @@ const H5O_msg_class_t H5O_MSG_BTREEK[1] = {{ #define H5O_BTREEK_VERSION 0 /*------------------------------------------------------------------------- - * Function: H5O__btreek_decode + * Function: H5O__btreek_decode * - * Purpose: Decode a shared message table message and return a pointer + * Purpose: Decode a shared message table message and return a pointer * to a newly allocated H5O_btreek_t struct. * - * Return: Success: Ptr to new message in native struct. - * Failure: NULL - * - * Programmer: Quincey Koziol - * Mar 1, 2007 - * + * Return: Success: Pointer to new message in native struct + * Failure: NULL *------------------------------------------------------------------------- */ static void * -H5O__btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__btreek_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, + const uint8_t *p) { - H5O_btreek_t *mesg; /* Native message */ - void *ret_value = NULL; /* Return value */ + const uint8_t *p_end = p + p_size - 1; /* End of input buffer */ + H5O_btreek_t *mesg = NULL; /* Native message */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* Sanity check */ HDassert(f); HDassert(p); /* Version of message */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); if (*p++ != H5O_BTREEK_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") @@ -94,14 +93,22 @@ H5O__btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsig HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for v1 B-tree 'K' message") /* Retrieve non-default B-tree 'K' values */ + 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, mesg->btree_k[H5B_CHUNK_ID]); + 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, mesg->btree_k[H5B_SNODE_ID]); + 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, mesg->sym_leaf_k); /* Set return value */ ret_value = (void *)mesg; done: + if (NULL == ret_value) + H5MM_free(mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__btreek_decode() */ diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 0851493..42d8f35 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -1510,8 +1510,9 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t chunk_size, const uint8_t H5O_cont_t *cont; /* Decode continuation message */ - cont = (H5O_cont_t *)(H5O_MSG_CONT->decode)(udata->f, NULL, 0, &ioflags, mesg->raw_size, - mesg->raw); + if (NULL == (cont = (H5O_cont_t *)(H5O_MSG_CONT->decode)(udata->f, NULL, 0, &ioflags, + mesg->raw_size, mesg->raw))) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "bad continuation message found") H5_CHECKED_ASSIGN(cont->chunkno, unsigned, udata->cont_msg_info->nmsgs + 1, size_t); /* the next continuation message/chunk */ diff --git a/src/H5Ocont.c b/src/H5Ocont.c index 8919ced..bbf233d 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -74,40 +74,43 @@ H5FL_DEFINE(H5O_cont_t); * Purpose: Decode the raw header continuation message. * * Return: Success: Ptr to the new native message - * * Failure: NULL - * - * Programmer: Robb Matzke - * Aug 6 1997 - * *------------------------------------------------------------------------- */ static void * H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_cont_t *cont = NULL; - void *ret_value = NULL; /* Return value */ + H5O_cont_t *cont = NULL; + const uint8_t *p_end = p + p_size - 1; + void *ret_value = NULL; FUNC_ENTER_PACKAGE - /* check args */ HDassert(f); HDassert(p); /* Allocate space for the message */ if (NULL == (cont = H5FL_MALLOC(H5O_cont_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed"); /* 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"); 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"); H5F_DECODE_LENGTH(f, p, cont->size); + cont->chunkno = 0; /* Set return value */ ret_value = cont; done: + if (NULL == ret_value && NULL != cont) + H5FL_FREE(H5O_cont_t, cont); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cont_decode() */ diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 35e2d9f..824590f 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -10,11 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 - */ - #include "H5Omodule.h" /* This source code file is part of the H5O module */ #include "H5private.h" /* Generic Functions */ @@ -64,14 +59,14 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ /*------------------------------------------------------------------------- * Function: H5O__efl_decode * - * Purpose: Decode an external file list message and return a pointer to - * the message (and some other data). + * Purpose: Decode an external file list message and return a pointer to + * the message (and some other data). * - * We allow zero dimension size starting from the 1.8.7 release. - * The dataset size of external storage can be zero. + * We allow zero dimension size starting from the 1.8.7 release. + * The dataset size of external storage can be zero. * - * Return: Success: Pointer to a new message struct - * Failure: NULL + * Return: Success: Pointer to a new message struct + * Failure: NULL *------------------------------------------------------------------------- */ static void * @@ -96,30 +91,33 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") /* Version (1 byte) */ - if ((p + 1 - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); version = *p++; if (version != H5O_EFL_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message") /* Reserved (3 bytes) */ - if ((p + 3 - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") + if (H5_IS_BUFFER_OVERFLOW(p, 3, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); p += 3; /* Number of slots (2x 2 bytes) */ - if ((p + 4 - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") + 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, mesg->nalloc); if (mesg->nalloc <= 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad number of allocated slots when parsing efl msg") + + 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, mesg->nused); if (mesg->nused > mesg->nalloc) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad number of in-use slots when parsing efl msg") /* Heap address */ - if ((p + H5F_SIZEOF_ADDR(f) - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") + 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"); H5F_addr_decode(f, &p, &(mesg->heap_addr)); if (H5F_addr_defined(mesg->heap_addr) == FALSE) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad local heap address when parsing efl msg") @@ -143,8 +141,8 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED for (size_t u = 0; u < mesg->nused; u++) { /* Name */ - if ((p + H5F_SIZEOF_SIZE(f) - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") + 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"); H5F_DECODE_LENGTH(f, p, mesg->slot[u].name_offset); if ((s = (const char *)H5HL_offset_into(heap, mesg->slot[u].name_offset)) == NULL) @@ -156,13 +154,13 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "string duplication failed") /* File offset */ - if ((p + H5F_SIZEOF_SIZE(f) - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") + 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"); H5F_DECODE_LENGTH(f, p, mesg->slot[u].offset); /* Size */ - if ((p + H5F_SIZEOF_SIZE(f) - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") + 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"); H5F_DECODE_LENGTH(f, p, mesg->slot[u].size); } @@ -173,7 +171,7 @@ H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED ret_value = mesg; done: - if (ret_value == NULL) + if (ret_value == NULL) { if (mesg != NULL) { if (mesg->slot != NULL) { for (size_t u = 0; u < mesg->nused; u++) @@ -182,6 +180,10 @@ done: } H5MM_xfree(mesg); } + if (heap != NULL) + if (H5HL_unprotect(heap) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect local heap") + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__efl_decode() */ diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index 0f9628b..54d8b8b 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -89,7 +89,7 @@ H5FL_DEFINE_STATIC(H5O_ginfo_t); */ static void * H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { H5O_ginfo_t *ginfo = NULL; /* Pointer to group information message */ unsigned char flags; /* Flags for encoding group info */ @@ -100,7 +100,15 @@ H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign /* check args */ HDassert(p); + if (p_size == 0) + HGOTO_ERROR(H5E_OHDR, H5E_ARGS, NULL, "size of given ginfo was zero") + + /* Points at last valid byte in buffer */ + const uint8_t *p_end = p + p_size - 1; + /* Version of message */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") if (*p++ != H5O_GINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") @@ -109,6 +117,9 @@ H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Get the flags for the group */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") + flags = *p++; if (flags & ~H5O_GINFO_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") @@ -117,6 +128,8 @@ H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign /* Get the max. # of links to store compactly & the min. # of links to store densely */ 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) } /* end if */ @@ -127,6 +140,8 @@ H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign /* Get the estimated # of entries & name lengths */ 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) } /* end if */ diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index d4ac3bb..11138df 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -105,11 +105,13 @@ H5FL_DEFINE_STATIC(H5O_linfo_t); */ static void * H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_linfo_t *linfo = NULL; /* Link info */ - unsigned char index_flags; /* Flags for encoding link index info */ - void *ret_value = NULL; /* Return value */ + const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ + H5O_linfo_t *linfo = NULL; /* Link info */ + unsigned char index_flags; /* Flags for encoding link index info */ + uint8_t addr_size = H5F_SIZEOF_ADDR(f); /* Temp var */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -117,6 +119,10 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS HDassert(f); HDassert(p); + /* Check input buffer before decoding version and index flags */ + if (H5_IS_BUFFER_OVERFLOW(p, 2, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") + /* Version of message */ if (*p++ != H5O_LINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") @@ -136,11 +142,18 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS linfo->nlinks = HSIZET_MAX; /* Max. link creation order value for the group, if tracked */ - if (linfo->track_corder) + 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) + } else linfo->max_corder = 0; + /* Check input buffer before decoding the next two addresses */ + if (H5_IS_BUFFER_OVERFLOW(p, addr_size + addr_size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") + /* Address of fractal heap to store "dense" links */ H5F_addr_decode(f, &p, &(linfo->fheap_addr)); @@ -148,8 +161,11 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS 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 (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") H5F_addr_decode(f, &p, &(linfo->corder_bt2_addr)); + } else linfo->corder_bt2_addr = HADDR_UNDEF; diff --git a/src/H5Omodule.h b/src/H5Omodule.h index afb005b..c3c3496 100644 --- a/src/H5Omodule.h +++ b/src/H5Omodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5O package. Including this header means that the source file - * is part of the H5O package. + * Purpose: This file contains declarations which define macros for the + * H5O package. Including this header means that the source file + * is part of the H5O package. */ #ifndef H5Omodule_H #define H5Omodule_H @@ -52,7 +49,7 @@ * * HDF5 objects are deleted as a side effect of rendering them unreachable * from the root group. The net effect is the diminution of the object's - * reference count to zero, which can (but should not usually) be effected + * reference count to zero, which can (but should not usually) be affected * by a function in this module. * * <table> diff --git a/src/H5Omtime.c b/src/H5Omtime.c index 5a491dd..8205a01 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -10,10 +10,8 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Robb Matzke - * Friday, July 24, 1998 - * - * Purpose: The object modification time message. +/* + * Purpose: The object modification time message */ #include "H5Omodule.h" /* This source code file is part of the H5O module */ @@ -93,46 +91,49 @@ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{ H5FL_DEFINE(time_t); /*------------------------------------------------------------------------- - * Function: H5O__mtime_new_decode + * Function: H5O__mtime_new_decode * * Purpose: Decode a new modification time message and return a pointer to * a new time_t value. * + * This version of the modification time was used in HDF5 + * 1.6.1 and later. + * * The new modification time message format was added due to the * performance overhead of the old format. * - * Return: Success: Ptr to new message in native struct. - * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Jan 3 2002 - * + * Return: Success: Pointer to new message in native struct + * Failure: NULL *------------------------------------------------------------------------- */ static void * -H5O__mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, - size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__mtime_new_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, + const uint8_t *p) { - time_t *mesg; - uint32_t tmp_time; /* Temporary copy of the time */ - void *ret_value = NULL; /* Return value */ + const uint8_t *p_end = p + p_size - 1; /* End of input buffer */ + time_t *mesg = NULL; + uint32_t tmp_time; /* Temporary copy of the time */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* check args */ HDassert(f); HDassert(p); - /* decode */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); if (*p++ != H5O_MTIME_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for mtime message"); /* Skip reserved bytes */ + if (H5_IS_BUFFER_OVERFLOW(p, 3, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); p += 3; /* Get the time_t from the file */ + 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, tmp_time); /* The return value */ @@ -153,35 +154,36 @@ done: * Purpose: Decode a modification time message and return a pointer to a * new time_t value. * + * This version of the modification time was used in HDF5 + * 1.6.0 and earlier. + * * The new modification time message format was added due to the * performance overhead of the old format. * - * Return: Success: Ptr to new message in native struct. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Jul 24 1998 - * + * Return: Success: Pointer to new message in native struct + * Failure: NULL *------------------------------------------------------------------------- */ static void * -H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__mtime_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, + const uint8_t *p) { - time_t *mesg, the_time; - struct tm tm; - int i; /* Local index variable */ - void *ret_value = NULL; /* Return value */ + const uint8_t *p_end = p + p_size - 1; /* End of input buffer */ + time_t *mesg = NULL; + time_t the_time; + struct tm tm; + void *ret_value = NULL; FUNC_ENTER_PACKAGE - /* check args */ HDassert(f); HDassert(p); - /* decode */ - for (i = 0; i < 14; i++) + /* Buffer should have 14 message bytes and 2 reserved bytes */ + 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])) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message") diff --git a/src/H5Oname.c b/src/H5Oname.c index a1e239b..10ea365 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -13,10 +13,8 @@ /*------------------------------------------------------------------------- * * Created: H5Oname.c - * Aug 12 1997 - * Robb Matzke * - * Purpose: Object name message. + * Purpose: Object name (comment) message * *------------------------------------------------------------------------- */ @@ -67,41 +65,37 @@ const H5O_msg_class_t H5O_MSG_NAME[1] = {{ * Purpose: Decode a name message and return a pointer to a new * native message struct. * - * Return: Success: Ptr to new message in native struct. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Aug 12 1997 - * + * Return: Success: Ptr to new message in native struct. + * Failure: NULL *------------------------------------------------------------------------- */ static void * -H5O__name_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) +H5O__name_decode(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, + const uint8_t *p) { - H5O_name_t *mesg; - void *ret_value = NULL; /* Return value */ + H5O_name_t *mesg = NULL; + void *ret_value = NULL; FUNC_ENTER_PACKAGE - /* check args */ HDassert(f); HDassert(p); - /* decode */ if (NULL == (mesg = (H5O_name_t *)H5MM_calloc(sizeof(H5O_name_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if (NULL == (mesg->s = (char *)H5MM_strdup((const char *)p))) + + if (NULL == (mesg->s = (char *)H5MM_strndup((const char *)p, p_size - 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - /* Set return value */ ret_value = mesg; done: if (NULL == ret_value) - if (mesg) - mesg = (H5O_name_t *)H5MM_xfree(mesg); + if (mesg) { + H5MM_xfree(mesg->s); + H5MM_xfree(mesg); + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__name_decode() */ diff --git a/src/H5Opublic.h b/src/H5Opublic.h index 65e140f..6fba508 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -246,7 +246,7 @@ extern "C" { * * H5Oopen() cannot be used to open a dataspace, attribute, property list, or file. * - * Once an object of unknown type has been opened with H5Oopen(), + * Once an object of an unknown type has been opened with H5Oopen(), * the type of that object can be determined by means of an H5Iget_type() call. * * \p loc_id may be a file, group, dataset, named datatype, or attribute. @@ -384,7 +384,7 @@ H5_DLL hid_t H5Oopen_by_idx_async(hid_t loc_id, const char *group_name, H5_inde * the \p loc_id and \p name combination exists. * \return Returns 0 if the object pointed to by * the \p loc_id and \p name combination does not exist. - * \return Returns a negatvie value when the function fails. + * \return Returns a negative value when the function fails. * * \details H5Oexists_by_name() allows an application to determine whether * the link \p name in the group or file specified with \p loc_id @@ -408,22 +408,22 @@ H5_DLL hid_t H5Oopen_by_idx_async(hid_t loc_id, const char *group_name, H5_inde * where \c group1 is a member of the group specified by \c loc_id: * * \par - * - First use H5Lexists() to verify that a link named \c group1 exists. + * - First, use H5Lexists() to verify that a link named \c group1 exists. * - If \c group1 exists, use H5Oexists_by_name() to verify that the * link \c group1 resolves to an object. - * - If \c group1 exists, use H5Lexists() again, this time with name + * - If \c group1 exists, use H5Lexists() again, this time with the name * set to \c group1/group2, to verify that the link \c group2 exists * in \c group1. * - If the \c group2 link exists, use H5Oexists_by_name() to verify * that \c group1/group2 resolves to an object. - * - If \c group2 exists, use H5Lexists() again, this time with name + * - If \c group2 exists, use H5Lexists() again, this time with the name * set to \c group1/group2/softlink_to_group3, to verify that the * link \c softlink_to_group3 exists in \c group2. * - If the \c softlink_to_group3 link exists, use H5Oexists_by_name() * to verify that \c group1/group2/softlink_to_group3 resolves to * an object. * - If \c softlink_to_group3 exists, you can now safely use H5Lexists - * with name set to \c group1/group2/softlink_to_group3/datasetD to + * with the name set to \c group1/group2/softlink_to_group3/datasetD to * verify that the target link, \c datasetD, exists. * - And finally, if the link \c datasetD exists, use H5Oexists_by_name * to verify that \c group1/group2/softlink_to_group3/datasetD @@ -437,12 +437,12 @@ H5_DLL hid_t H5Oopen_by_idx_async(hid_t loc_id, const char *group_name, H5_inde * H5Lexists() would have name set to \c /group1. * * \par - * Note that this is an outline and does not include all necessary + * Note that this is an outline and does not include all the necessary * details. Depending on circumstances, for example, an application * may need to verify the type of an object also. * * \warning \Bold{Failure Modes:} - * \warning If \p loc_id and \p name both exist but the combination does not + * \warning If \p loc_id and \p name both exist, but the combination does not * resolve to an object, the function will return 0 (zero); * the function does not fail in this case. * \warning If either the location or the link specified by the \p loc_id @@ -492,7 +492,7 @@ H5_DLL htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id); * \note If you are iterating through a lot of different objects to * retrieve information via the H5Oget_info() family of routines, * you may see memory building up. This can be due to memory - * allocation for metadata such as object headers and messages + * allocation for metadata, such as object headers and messages, * when the iterated objects are put into the metadata cache. * \note * If the memory buildup is not desirable, you can configure a @@ -722,7 +722,7 @@ H5_DLL herr_t H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5 * * \details H5Olink() creates a new hard link to an object in an HDF5 file. * \p new_loc_id and \p \p new_link_name specify the location and name of the - * new link while \p object_id identifies the object that the link + * new link, while \p object_id identifies the object that the link * points to. * * H5Olink() is designed for two purposes: @@ -792,7 +792,7 @@ H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_ * An object’s reference count is the number of hard links in the * file that point to that object. See the “Programming Model” * section of the HDF5 Groups chapter in the -- <em>\ref UG</em> - * for a more complete discussion of reference counts. + * for a complete discussion of reference counts. * * If a user application needs to determine an object’s reference * count, an H5Oget_info() call is required; the reference count @@ -965,7 +965,7 @@ H5_DLL herr_t H5Ocopy_async(hid_t src_loc_id, const char *src_name, hid_t dst_lo * is overwritten. * * The target object is specified by an identifier, \p obj_id. - * If \p comment is the empty string or a null pointer, any existing + * If \p comment is an empty string or a null pointer, any existing * comment message is removed from the object. * * Comments should be relatively short, null-terminated, ASCII strings. @@ -1010,7 +1010,7 @@ H5_DLL herr_t H5Oset_comment(hid_t obj_id, const char *comment); * - An absolute name of the object, starting from \c /, the file’s root group * - A dot (\c .), if \p loc_id fully specifies the object * - * If \p comment is the empty string or a null pointer, any existing + * If \p comment is an empty string or a null pointer, any existing * comment message is removed from the object. * * Comments should be relatively short, null-terminated, ASCII strings. @@ -1064,7 +1064,7 @@ H5_DLL herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char * only \p bufsize bytes of the comment, without a \c NULL terminator, * are returned in \p comment. * - * If an object does not have a comment, the empty string is + * If an object does not have a comment, an empty string is * returned in \p comment. * * \version 1.8.11 Fortran subroutine introduced in this release. @@ -1112,7 +1112,7 @@ H5_DLL ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize); * only \p bufsize bytes of the comment, without a \c NULL terminator, * are returned in \p comment. * - * If an object does not have a comment, the empty string is + * If an object does not have a comment, an empty string is * returned in \p comment. * * \p lapl_id contains a link access property list identifier. A @@ -1259,7 +1259,7 @@ H5_DLL herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * a file or an object in a file; if \p loc_id is an attribute identifier, * the object where the attribute is attached will be used. * \p obj_name specifies either an object in the file (with an absolute - * name based in the file’s root group) or an object name relative + * name based on the file’s root group) or an object name relative * to \p loc_id. If \p loc_id fully specifies the object that is to serve * as the root of the iteration, \p obj_name should be '\c .' (a dot). * (Note that when \p loc_id fully specifies the object that is to serve @@ -1374,7 +1374,7 @@ H5_DLL herr_t H5Oclose_async(hid_t object_id, hid_t es_id); * flushed to disk without removing the data from the cache. * * The object associated with \p object_id can be any named object in an - * HDF5 file including a dataset, a group, or a committed datatype. + * HDF5 file, including a dataset, a group, or a committed datatype. * * \warning H5Oflush doesn't work correctly with parallel. It causes an assertion * failure in metadata cache during H5Fclose(). @@ -1781,7 +1781,7 @@ typedef herr_t (*H5O_iterate1_t)(hid_t obj, const char *name, const H5O_info1_t * * The object’s address within the file, \p addr, is the byte offset of the first byte * of the object header from the beginning of the HDF5 file space, i.e., from the - * beginning of the super block (see the “HDF5 Storage Model” section of the The + * beginning of the superblock (see the “HDF5 Storage Model” section of the The * HDF5 Data Model and File Structure chapter of the <em>HDF5 User's Guide</em>.) * * \p addr can be obtained via either of two function calls. H5Gget_objinfo() returns @@ -1800,7 +1800,7 @@ typedef herr_t (*H5O_iterate1_t)(hid_t obj, const char *name, const H5O_info1_t * overcome by retrieving the object address with H5Gget_objinfo() or H5Lget_info() * immediately before calling H5Oopen_by_addr(). The immediacy of the operation can be * important; if time has elapsed and the object has been deleted from the file, - * the address will be invalid and file corruption can result. + * the address will be invalid, and file corruption can result. * * \version 1.8.4 Fortran subroutine added in this release. * @@ -1829,7 +1829,7 @@ H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); * \note If you are iterating through a lot of different objects to * retrieve information via the H5Oget_info() family of routines, * you may see memory building up. This can be due to memory - * allocation for metadata such as object headers and messages + * allocation for metadata, such as object headers and messages, * when the iterated objects are put into the metadata cache. * \note * If the memory buildup is not desirable, you can configure a @@ -1967,7 +1967,7 @@ H5_DLL herr_t H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index * \note If you are iterating through a lot of different objects to * retrieve information via the H5Oget_info() family of routines, * you may see memory building up. This can be due to memory - * allocation for metadata such as object headers and messages + * allocation for metadata, such as object headers and messages, * when the iterated objects are put into the metadata cache. * \note * If the memory buildup is not desirable, you can configure a @@ -2197,7 +2197,7 @@ H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * a file or an object in a file; if \p loc_id is an attribute identifier, * the object where the attribute is attached will be used. * \p obj_name specifies either an object in the file (with an absolute - * name based in the file’s root group) or an object name relative + * name based on the file’s root group) or an object name relative * to \p loc_id. If \p loc_id fully specifies the object that is to serve * as the root of the iteration, \p obj_name should be '\c .' (a dot). * (Note that when \p loc_id fully specifies the object that is to serve diff --git a/src/H5Oshared.h b/src/H5Oshared.h index 07bc4a1..b7d2353 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -11,16 +11,13 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Friday, January 19, 2007 - * * Purpose: This file contains inline definitions for "generic" routines - * supporting a "shared message interface" (ala Java) for object - * header messages that can be shared. This interface is - * dependent on a bunch of macros being defined which define - * the name of the interface and "real" methods which need to - * be implemented for each message class that supports the - * shared message interface. + * supporting a "shared message interface" (ala Java) for object + * header messages that can be shared. This interface is + * dependent on a bunch of macros being defined which define + * the name of the interface and "real" methods which need to + * be implemented for each message class that supports the + * shared message interface. */ #ifndef H5Oshared_H @@ -31,16 +28,12 @@ * * Purpose: Decode an object header message that may be shared. * - * Note: The actual name of this routine can be different in each source - * file that this header file is included in, and must be defined - * prior to including this header file. - * - * Return: Success: Pointer to the new message in native form - * Failure: NULL - * - * Programmer: Quincey Koziol - * Friday, January 19, 2007 + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. * + * Return: Success: Pointer to the new message in native form + * Failure: NULL *------------------------------------------------------------------------- */ static inline void * @@ -90,16 +83,11 @@ done: * * Purpose: Encode an object header message that may be shared. * - * Note: The actual name of this routine can be different in each source - * file that this header file is included in, and must be defined - * prior to including this header file. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Friday, January 19, 2007 + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static inline herr_t @@ -143,18 +131,14 @@ done: /*------------------------------------------------------------------------- * Function: H5O_SHARED_SIZE * - * Purpose: Returns the length of an encoded message. + * Purpose: Returns the length of an encoded message. * - * Note: The actual name of this routine can be different in each source - * file that this header file is included in, and must be defined - * prior to including this header file. - * - * Return: Success: Length - * Failure: 0 - * - * Programmer: Quincey Koziol - * Friday, January 19, 2007 + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. * + * Return: Success: Length + * Failure: 0 *------------------------------------------------------------------------- */ static inline size_t @@ -198,16 +182,11 @@ done: * Purpose: Decrement reference count on any objects referenced by * message * - * Note: The actual name of this routine can be different in each source - * file that this header file is included in, and must be defined - * prior to including this header file. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Friday, January 19, 2007 + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static inline herr_t @@ -249,16 +228,11 @@ done: * Purpose: Increment reference count on any objects referenced by * message * - * Note: The actual name of this routine can be different in each source - * file that this header file is included in, and must be defined - * prior to including this header file. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Friday, January 19, 2007 + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static inline herr_t @@ -299,16 +273,11 @@ done: * * Purpose: Copies a message from _SRC to _DEST in file * - * Note: The actual name of this routine can be different in each source - * file that this header file is included in, and must be defined - * prior to including this header file. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Friday, January 19, 2007 + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static inline void * @@ -366,12 +335,7 @@ done: * file that this header file is included in, and must be defined * prior to including this header file. * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Peter Cao - * May 25, 2007 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static inline herr_t @@ -418,7 +382,7 @@ H5O_SHARED_POST_COPY_FILE(const H5O_loc_t H5_ATTR_NDEBUG_UNUSED *oloc_src, const HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to update native message") #endif /* H5O_SHARED_POST_COPY_FILE_UPD */ - /* Make sure that if the the source or destination is committed, both are + /* Make sure that if the source or destination is committed, both are * committed */ HDassert((shared_src->type == H5O_SHARE_TYPE_COMMITTED) == (shared_dst->type == H5O_SHARE_TYPE_COMMITTED)); @@ -432,16 +396,11 @@ done: * * Purpose: Prints debugging info for a potentially shared message. * - * Note: The actual name of this routine can be different in each source - * file that this header file is included in, and must be defined - * prior to including this header file. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Saturday, February 3, 2007 + * Note: The actual name of this routine can be different in each source + * file that this header file is included in, and must be defined + * prior to including this header file. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static inline herr_t diff --git a/src/H5PBmodule.h b/src/H5PBmodule.h index 39db5d9..3a353db 100644 --- a/src/H5PBmodule.h +++ b/src/H5PBmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5PB package. Including this header means that the source file - * is part of the H5PB package. + * Purpose: This file contains declarations which define macros for the + * H5PB package. Including this header means that the source file + * is part of the H5PB package. */ #ifndef H5PBmodule_H #define H5PBmodule_H diff --git a/src/H5PLint.c b/src/H5PLint.c index 4995adb..62e0074 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -254,11 +254,17 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) /* If not found, try iterating through the path table to find an appropriate plugin */ if (!found) if (H5PL__find_plugin_in_path_table(&search_params, &found, &plugin_info) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in path table failed") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, + "can't find plugin in the paths either set by HDF5_PLUGIN_PATH, or default location, " + "or set by H5PLxxx functions") /* Set the return value we found the plugin */ if (found) ret_value = plugin_info; + else + HGOTO_ERROR(H5E_PLUGIN, H5E_NOTFOUND, NULL, + "can't find plugin. Check either HDF5_VOL_CONNECTOR, HDF5_PLUGIN_PATH, default location, " + "or path set by H5PLxxx functions") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5PLpath.c b/src/H5PLpath.c index f868a30..9619b13 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -854,7 +854,8 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo /* Open the directory */ if (!(dirp = HDopendir(dir))) - HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory: %s", dir) + HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory (%s). Please verify its existence", + dir) /* Iterate through all entries in the directory */ while (NULL != (dp = HDreaddir(dirp))) { diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h index 4595d22..c53053b 100644 --- a/src/H5PLpublic.h +++ b/src/H5PLpublic.h @@ -95,9 +95,9 @@ H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_control_mask); * \brief Queries the loadability of dynamic plugin types * * \param[out] plugin_control_mask List of dynamic plugin types that are enabled or disabled.\n - * A plugin bit set to 0 (zero) indicates that that the dynamic plugin type is + * A plugin bit set to 0 (zero) indicates that the dynamic plugin type is * disabled.\n - * A plugin bit set to 1 (one) indicates that that the dynamic plugin type is + * A plugin bit set to 1 (one) indicates that the dynamic plugin type is * enabled.\n * If the value of \p plugin_control_mask is negative, all dynamic plugin * types are enabled.\n @@ -105,7 +105,7 @@ H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_control_mask); * are disabled. * \return \herr_t * - * \details H5PLget_loading_state() retrieves the bitmask that controls whether a certain type of plugins + * \details H5PLget_loading_state() retrieves the bitmask that controls whether a certain type of plugin * (e.g.: filters, VOL drivers) will be loaded by the HDF5 library. * * Bit positions allocated to date are specified in \ref H5PL_type_t as follows: diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 07d64bc..8e9b680 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -5957,7 +5957,7 @@ H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, "Minimum metadata fractions must be between 0 and 100 inclusive") if (min_raw_perc > 100) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "Minimum rawdata fractions must be between 0 and 100 inclusive") + "Minimum raw data fractions must be between 0 and 100 inclusive") if (min_meta_perc + min_raw_perc > 100) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, @@ -5969,7 +5969,7 @@ H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min metadata entries") if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min rawdata entries") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min raw data entries") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Pmodule.h b/src/H5Pmodule.h index f2a1e5a..ea6a5e4 100644 --- a/src/H5Pmodule.h +++ b/src/H5Pmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5P package. Including this header means that the source file - * is part of the H5P package. + * Purpose: This file contains declarations which define macros for the + * H5P package. Including this header means that the source file + * is part of the H5P package. */ #ifndef H5Pmodule_H #define H5Pmodule_H diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index 05cc6a8..9a58d00 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Friday, November 16, 2001 - * - * Purpose: This file contains declarations which are visible only within - * the H5P package. Source files outside the H5P package should - * include H5Pprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5P package. Source files outside the H5P package should + * include H5Pprivate.h instead. */ #if !(defined H5P_FRIEND || defined H5P_MODULE) #error "Do not include this file outside the H5P package!" diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 24dc754..bb5d421 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -2419,7 +2419,7 @@ H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned level); * format. The filters will come into play only when dense storage * is used (see H5Pset_link_phase_change()) and will be applied to * the group’s fractal heap. The fractal heap will contain most of - * the the group’s link metadata, including link names. + * the group’s link metadata, including link names. * * \note When working with group creation property lists, if you are * adding a filter that is not in HDF5’s set of predefined filters, @@ -3268,7 +3268,7 @@ H5_DLL herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, /* out */ * after the call to H5Pset_fapl_core(). It is an error to use this * function with any other VFD. * - * \note This function only applies to the backing store write operation + * \note This function only applies to the backing store write operation, * which typically occurs when the file is flushed or closed. This * function has no relationship to the increment parameter passed * to H5Pset_fapl_core(). @@ -3315,7 +3315,7 @@ H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, siz * <tr> * <td>Direct</td> * <td>#H5FD_DIRECT</td> - * <td>This is the #H5FD_SEC2 driver except data is written to or + * <td>This is the #H5FD_SEC2 driver, except data is written to or * read from the file synchronously without being cached by the * system.</td> * <td>H5Pset_fapl_direct()</td> @@ -3366,7 +3366,7 @@ H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, siz * <td>Multi</td> * <td>#H5FD_MULTI</td> * <td>With this driver, data can be stored in multiple files - * according to the type of the data. I/O might work better if + * according to the type of data. I/O might work better if * data is stored in separate files based on the type of data. * The Split driver is a special case of this driver.</td> * <td>H5Pset_fapl_multi()</td> @@ -3947,7 +3947,7 @@ H5_DLL herr_t H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts); * for more information. * * The type of data returned in \p type will be one of those - * listed in the discussion of the \p type parameter in the the + * listed in the discussion of the \p type parameter in the * description of the function H5Pset_multi_type(). * * Use of this function is only appropriate for an HDF5 file @@ -4106,7 +4106,7 @@ H5_DLL herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); * \details H5Pset_alignment() sets the alignment properties of a * file access property list so that any file object greater * than or equal in size to \p threshold bytes will be aligned - * on an address which is a multiple of \p alignment. The + * on an address that is a multiple of \p alignment. The * addresses are relative to the end of the user block; the * alignment is calculated by subtracting the user block size * from the absolute file address and then adjusting the address @@ -4116,7 +4116,7 @@ H5_DLL herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); * implying no alignment. Generally the default values will * result in the best performance for single-process access to * the file. For MPI IO and other parallel systems, choose an - * alignment which is a multiple of the disk block size. + * alignment that is a multiple of the disk block size. * * If the file space handling strategy is set to * #H5F_FSPACE_STRATEGY_PAGE, then the alignment set via this @@ -4154,7 +4154,7 @@ H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignme * penalized when determining which chunks to flush * from cache. A value of 0 means fully read or * written chunks are treated no differently than - * other chunks (the preemption is strictly LRU) + * other chunks (the preemption is strictly LRU), * while a value of 1 means fully read or written * chunks are always preempted before other chunks. * If your application only reads or writes data once, @@ -4176,7 +4176,7 @@ H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignme * computing a hash value using the address of a chunk and then by * using that hash value as the chunk’s index into the table of * cached chunks. In other words, the size of this hash table and the - * number of possible hash values is determined by the \p rdcc_nslots + * number of possible hash values are determined by the \p rdcc_nslots * parameter. If a different chunk in the cache has the same hash value, * a collision will occur, which will reduce efficiency. If inserting * the chunk into the cache would cause the cache to be too big, then @@ -5341,7 +5341,7 @@ H5_DLL herr_t H5Pget_vol_cap_flags(hid_t plist_id, uint64_t *cap_flags); /** * \ingroup GAPL * - * \brief Sets metadata I/O mode for read operations to collective or independent (default) + * \brief Sets metadata I/O mode for read operations to be collective or independent (default) * * \gacpl_id * \param[in] is_collective Boolean value indicating whether metadata reads are collective @@ -5430,7 +5430,7 @@ H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collectiv /** * \ingroup FAPL * - * \brief Sets metadata write mode to collective or independent (default) + * \brief Sets metadata write mode to be collective or independent (default) * * \fapl_id{plist_id} * \param[out] is_collective Boolean value indicating whether metadata @@ -6699,7 +6699,7 @@ H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, * Specifically, a dataset with a datatype that is 8-, 16-, 32-, or * 64-bit signed or unsigned integer; char; or 32- or 64-bit float * can be compressed with SZIP. See Note, below, for further - * discussion of the the SZIP \p bits_per_pixel setting. + * discussion of the SZIP \p bits_per_pixel setting. * * SZIP options are passed in an options mask, \p options_mask, * as follows. diff --git a/src/H5RSmodule.h b/src/H5RSmodule.h index 8cd0333..ee6b7e8 100644 --- a/src/H5RSmodule.h +++ b/src/H5RSmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, October 10, 2020 - * * Purpose: This file contains declarations which define macros for the - * H5RS package. Including this header means that the source file - * is part of the H5RS package. + * H5RS package. Including this header means that the source file + * is part of the H5RS package. */ #ifndef H5RSmodule_H #define H5RSmodule_H diff --git a/src/H5RSprivate.h b/src/H5RSprivate.h index 0c8f3ea..a382140 100644 --- a/src/H5RSprivate.h +++ b/src/H5RSprivate.h @@ -19,9 +19,6 @@ /**************************************/ /* Public headers needed by this file */ /**************************************/ -#ifdef LATER -#include "H5RSpublic.h" -#endif /* LATER */ /***************************************/ /* Private headers needed by this file */ diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index 856a445..dfeffda 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -259,7 +259,7 @@ H5_DLL herr_t H5Rdestroy(H5R_ref_t *ref_ptr); * \snippet this H5R_type_t_snip * * Note that #H5R_OBJECT1 and #H5R_DATASET_REGION1 can never be - * associated to an \ref H5R_ref_t reference and can therefore never be + * associated with an \ref H5R_ref_t reference and can, therefore, never be * returned through that function. * * \ref H5R_ref_t is defined in H5Rpublic.h as: @@ -302,7 +302,7 @@ H5_DLL htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr); * \return \herr_t * * \details H5Rcopy() creates a copy of an existing reference. - * \p src_ref_ptr points to the reference to copy and \p dst_ref_ptr is the + * \p src_ref_ptr points to the reference to copy, and \p dst_ref_ptr is the * pointer to the destination reference. * */ @@ -336,7 +336,7 @@ H5_DLL herr_t H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr); * * The object opened with this function should be closed when it * is no longer needed so that resource leaks will not develop. Use - * the appropriate close function such as H5Oclose() or H5Dclose() + * the appropriate close function, such as H5Oclose() or H5Dclose() * for datasets. * */ @@ -628,7 +628,7 @@ H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *name, size_t siz * * A \Emph{reference type} is the type of reference, either an object * reference or a dataset region reference. An \Emph{object reference} - * points to an HDF5 object while a \Emph{dataset region reference} + * points to an HDF5 object, while a \Emph{dataset region reference} * points to a defined region within a dataset. * * The \Emph{referenced object} is the object the reference points @@ -700,7 +700,7 @@ H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref * * The object opened with this function should be closed when it is no * longer needed so that resource leaks will not develop. Use the - * appropriate close function such as H5Oclose() or H5Dclose() for + * appropriate close function, such as H5Oclose() or H5Dclose() for * datasets. * * \version 1.10.0 Function H5Rdereference() renamed to H5Rdereference1() and @@ -837,7 +837,7 @@ H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H * * The object opened with this function should be closed when it is no * longer needed so that resource leaks will not develop. Use the - * appropriate close function such as H5Oclose() or H5Dclose() for + * appropriate close function, such as H5Oclose() or H5Dclose() for * datasets. * * \since 1.10.0 diff --git a/src/H5SLmodule.h b/src/H5SLmodule.h index 606fa90..b0b3064 100644 --- a/src/H5SLmodule.h +++ b/src/H5SLmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5SL package. Including this header means that the source file - * is part of the H5SL package. + * Purpose: This file contains declarations which define macros for the + * H5SL package. Including this header means that the source file + * is part of the H5SL package. */ #ifndef H5SLmodule_H #define H5SLmodule_H diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index 6bd1b79..d7eb5be 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -19,9 +19,6 @@ /**************************************/ /* Public headers needed by this file */ /**************************************/ -#ifdef LATER -#include "H5SLpublic.h" -#endif /* LATER */ /***************************************/ /* Private headers needed by this file */ diff --git a/src/H5SMmodule.h b/src/H5SMmodule.h index 6308e14..1eaeea2 100644 --- a/src/H5SMmodule.h +++ b/src/H5SMmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5SM package. Including this header means that the source file - * is part of the H5SM package. + * Purpose: This file contains declarations which define macros for the + * H5SM package. Including this header means that the source file + * is part of the H5SM package. */ #ifndef H5SMmodule_H #define H5SMmodule_H diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 6e44601..64f5c76 100644 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -11,9 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: James Laird - * Thursday, March 30, 2006 - * * Purpose: This file contains declarations which are visible only within * the H5SM shared object header messages package. Source files * outside the H5SM package should include H5SMprivate.h instead. diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h index 95f831e..f6496f3 100644 --- a/src/H5SMprivate.h +++ b/src/H5SMprivate.h @@ -11,11 +11,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: James Laird - * Thursday, March 2, 2006 - * - * Purpose: This file contains private declarations for the H5SM - * shared object header messages module. + * Purpose: This file contains private declarations for the H5SM + * shared object header messages module. */ #ifndef H5SMprivate_H #define H5SMprivate_H diff --git a/src/H5Sall.c b/src/H5Sall.c index eb9a4d7..20c9a20 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -1109,7 +1109,7 @@ done: NAME H5S_select_all PURPOSE - Specify the the entire extent is selected + Specify the entire extent is selected USAGE herr_t H5S_select_all(dsid) hid_t dsid; IN: Dataspace ID of selection to modify @@ -1152,7 +1152,7 @@ done: NAME H5Sselect_all PURPOSE - Specify the the entire extent is selected + Specify the entire extent is selected USAGE herr_t H5Sselect_all(dsid) hid_t dsid; IN: Dataspace ID of selection to modify diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 84cef80..6cc991a 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -9229,7 +9229,7 @@ done: owned by the result. If not, the 2nd span list has to be copied. hbool_t *span2_owned; OUT: Indicates if the 2nd span list is actually owned - H5S_t **result; OUT: The dataspace containing the the new selection. It + H5S_t **result; OUT: The dataspace containing the new selection. It could be same with the 1st dataspace. RETURNS Non-negative on success, negative on failure diff --git a/src/H5Smodule.h b/src/H5Smodule.h index 73f5953..c5081c7 100644 --- a/src/H5Smodule.h +++ b/src/H5Smodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5S package. Including this header means that the source file - * is part of the H5S package. + * Purpose: This file contains declarations which define macros for the + * H5S package. Including this header means that the source file + * is part of the H5S package. */ #ifndef H5Smodule_H #define H5Smodule_H diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 8cc00be..1163484 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Thursday, September 28, 2000 - * - * Purpose: This file contains declarations which are visible only within - * the H5S package. Source files outside the H5S package should - * include H5Sprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5S package. Source files outside the H5S package should + * include H5Sprivate.h instead. */ #if !(defined H5S_FRIEND || defined H5S_MODULE) #error "Do not include this file outside the H5S package!" diff --git a/src/H5Spublic.h b/src/H5Spublic.h index f8fed47..871a8e7 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -1006,7 +1006,7 @@ H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); * The \p coord parameter is a pointer to a buffer containing a * serialized 2-dimensional array of size \p num_elements by the * rank of the dataspace. The array lists dataset elements in the - * point selection; that is, it’s a list of of zero-based values + * point selection; that is, it’s a list of zero-based values * specifying the coordinates in the dataset of the selected * elements. The order of the element coordinates in the \p coord * array specifies the order in which the array elements are @@ -1048,7 +1048,7 @@ H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); * * In the 1D case, we will be selecting five points and a 1D * dataspace has rank 1, so the selection will be described in a - * 5-by-1 array. To select the 1st, 14th, 17th, 23rd, 8th elements + * 5-by-1 array. To select the 1st, 14th, 17th, 23rd and 8th elements * of the dataset, the selection array would be as follows * (remembering that point coordinates are zero-based): * \n 0 @@ -1320,9 +1320,9 @@ H5_DLL herr_t H5Sset_extent_none(hid_t space_id); * \details H5Sset_extent_simple() sets or resets the size of an existing * dataspace. * - * \p dims is an array of size \p rank which contains the new size + * \p dims is an array of size \p rank that contains the new size * of each dimension in the dataspace. \p max is an array of size - * \p rank which contains the maximum size of each dimension in + * \p rank that contains the maximum size of each dimension in * the dataspace. * * Any previous extent is removed from the dataspace, the dataspace diff --git a/src/H5Sselect.c b/src/H5Sselect.c index c2fb7fa..9d13cf2 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -49,12 +49,6 @@ /* Local Prototypes */ /********************/ -#ifdef LATER -static herr_t H5S__select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); -static htri_t H5S__select_iter_has_next_block(const H5S_sel_iter_t *iter); -static herr_t H5S__select_iter_next_block(H5S_sel_iter_t *iter); -#endif /* LATER */ - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -1191,50 +1185,6 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_coords() */ -#ifdef LATER - -/*-------------------------------------------------------------------------- - NAME - H5S__select_iter_block - PURPOSE - Get the block of the current iterator position - USAGE - herr_t H5S__select_iter_block(sel_iter,start,end) - const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query - hsize_t *start; OUT: Array to place iterator start block coordinates - hsize_t *end; OUT: Array to place iterator end block coordinates - RETURNS - Non-negative on success, negative on failure. - DESCRIPTION - The current location of the iterator within the selection is placed in - the COORDS array. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine participates in the "Inlining C function pointers" - pattern, don't call it directly, use the appropriate macro - defined in H5Sprivate.h. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5S__select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) -{ - herr_t ret_value; /* return value */ - - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(iter); - HDassert(start); - HDassert(end); - - /* Call iter_block routine for selection type */ - ret_value = (*iter->type->iter_block)(iter, start, end); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S__select_iter_block() */ -#endif /* LATER */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_nelmts @@ -1271,46 +1221,6 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_nelmts() */ -#ifdef LATER - -/*-------------------------------------------------------------------------- - NAME - H5S__select_iter_has_next_block - PURPOSE - Check if there is another block available in the selection iterator - USAGE - htri_t H5S__select_iter_has_next_block(sel_iter) - const H5S_sel_iter_t *sel_iter; IN: Selection iterator to query - RETURNS - Non-negative on success, negative on failure. - DESCRIPTION - Check if there is another block available to advance to in the selection - iterator. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine participates in the "Inlining C function pointers" - pattern, don't call it directly, use the appropriate macro - defined in H5Sprivate.h. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static htri_t -H5S__select_iter_has_next_block(const H5S_sel_iter_t *iter) -{ - herr_t ret_value; /* return value */ - - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(iter); - - /* Call iter_has_next_block routine for selection type */ - ret_value = (*iter->type->iter_has_next_block)(iter); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S__select_iter_has_next_block() */ -#endif /* LATER */ - /*-------------------------------------------------------------------------- NAME H5S_select_iter_next @@ -1353,48 +1263,6 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_iter_next() */ -#ifdef LATER - -/*-------------------------------------------------------------------------- - NAME - H5S__select_iter_next_block - PURPOSE - Advance selection iterator to next block - USAGE - herr_t H5S__select_iter_next_block(iter) - H5S_sel_iter_t *iter; IN/OUT: Selection iterator to change - RETURNS - Non-negative on success, negative on failure. - DESCRIPTION - Move the current element for the selection iterator to the next - block in the selection. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Doesn't maintain the 'elmt_left' field of the selection iterator. - - This routine participates in the "Inlining C function pointers" - pattern, don't call it directly, use the appropriate macro - defined in H5Sprivate.h. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5S__select_iter_next_block(H5S_sel_iter_t *iter) -{ - herr_t ret_value; /* return value */ - - FUNC_ENTER_PACKAGE_NOERR - - /* Check args */ - HDassert(iter); - - /* Call iter_next_block routine for selection type */ - ret_value = (*iter->type->iter_next_block)(iter); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S__select_iter_next_block() */ -#endif /* LATER */ - /*------------------------------------------------------------------------- * Function: H5S_select_iter_get_seq_list * diff --git a/src/H5Tenum.c b/src/H5Tenum.c index af5812d..bf9b671 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -333,7 +333,7 @@ done: /*------------------------------------------------------------------------- * Function: H5T__enum_nameof * - * Purpose: Finds the symbol name that corresponds the the specified + * Purpose: Finds the symbol name that corresponds to the specified * VALUE of an enumeration data type DT. At most SIZE characters * of the symbol name are copied into the NAME buffer. If the * entire symbol name and null terminator do not fit in the NAME @@ -470,7 +470,7 @@ done: /*------------------------------------------------------------------------- * Function: H5T__enum_valueof * - * Purpose: Finds the value that corresponds the the specified symbol + * Purpose: Finds the value that corresponds to the specified symbol * NAME of an enumeration data type DT and copy it to the VALUE * result buffer. The VALUE should be allocated by the caller to * be large enough for the result. diff --git a/src/H5Tmodule.h b/src/H5Tmodule.h index bc521f1..c059d6e 100644 --- a/src/H5Tmodule.h +++ b/src/H5Tmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5T package. Including this header means that the source file - * is part of the H5T package. + * Purpose: This file contains declarations which define macros for the + * H5T package. Including this header means that the source file + * is part of the H5T package. */ #ifndef H5Tmodule_H #define H5Tmodule_H diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 98288f3..504f756 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Monday, December 8, 1997 - * - * Purpose: This file contains declarations which are visible only within - * the H5T package. Source files outside the H5T package should - * include H5Tprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5T package. Source files outside the H5T package should + * include H5Tprivate.h instead. */ #if !(defined H5T_FRIEND || defined H5T_MODULE) #error "Do not include this file outside the H5T package!" diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 16172a8..92ec134 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -1069,7 +1069,7 @@ H5_DLL hid_t H5Tcreate(H5T_class_t type, size_t size); * dataset's datatype. * * The returned datatype identifier should be released with H5Tclose() - * to prevent resource leak. + * to prevent resource leaks. * */ H5_DLL hid_t H5Tcopy(hid_t type_id); @@ -1158,7 +1158,7 @@ H5_DLL herr_t H5Tlock(hid_t type_id); * * \p loc_id may be a file identifier, or a group identifier within * that file. \p name may be either an absolute path in the file or - * a relative path from \p loc_id naming the newly-commited datatype. + * a relative path from \p loc_id naming the newly-committed datatype. * * The link creation property list, \p lcpl_id, governs creation of * the link(s) by which the new committed datatype is accessed and @@ -1235,7 +1235,7 @@ H5_DLL hid_t H5Topen_async(hid_t loc_id, const char *name, hid_t tapl_id, hid_t /** * \ingroup H5T * - * \brief Commits a transient datatype to a file, creating a new named + * \brief Commits a transient datatype to a file, creating a newly named * datatype, but does not link it into the file structure * * \fg_loc_id @@ -1365,7 +1365,7 @@ H5_DLL herr_t H5Tencode(hid_t obj_id, void *buf, size_t *nalloc); /** * \ingroup H5T * - * \brief Decodes a binary object description of datatype and return a new + * \brief Decodes a binary object description of datatype and returns a new * object handle * * \param[in] buf Buffer for the datatype object to be decoded @@ -1437,7 +1437,7 @@ H5_DLL herr_t H5Tflush(hid_t type_id); * contents from disk. * * This function essentially closes the datatype, evicts all - * metadata associated with it from the cache, and then re-opens the + * metadata associated with it from the cache, and then reopens the * datatype. The reopened datatype is automatically re-registered * with the same identifier. * @@ -2263,7 +2263,7 @@ H5_DLL htri_t H5Tis_variable_str(hid_t type_id); * \details H5Tget_native_type() returns the equivalent native datatype * identifier for the datatype specified by \p type_id. * - * H5Tget_native_type() is designed primarily to facilitate use of + * H5Tget_native_type() is designed primarily to facilitate the use of * the H5Dread() function, for which users otherwise must undertake a * multi-step process to determine the native datatype of a dataset * prior to reading it into memory. This function can be used for @@ -2321,7 +2321,7 @@ H5_DLL htri_t H5Tis_variable_str(hid_t type_id); * * \note Please note that a datatype is actually an object * identifier or handle returned from opening the datatype. It - * is not persistent and its value can be different from one HDF5 + * is not persistent, and its value can be different from one HDF5 * session to the next. * * \note H5Tequal() can be used to compare datatypes. @@ -2342,14 +2342,14 @@ H5_DLL hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction); * \brief Sets size for a datatype. * * \type_id - * \param[in] size New datatype size is bytes or #H5T_VARIABLE + * \param[in] size New datatype size in bytes or #H5T_VARIABLE * * \return \herr_t * * \details H5Tset_size() sets the total size, \p size, in bytes, for a * datatype. * - * \p size must have a positive value, unless it is passed in as + * \p size must have a positive value unless it is passed in as * #H5T_VARIABLE and the datatype is a string datatype. * * \li Numeric datatypes: If the datatype is atomic and the size @@ -2361,7 +2361,7 @@ H5_DLL hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction); * * \li String or character datatypes: The size set for a string * datatype should include space for the null-terminator character, - * otherwise it will not be stored on (or retrieved from) + * otherwise it will not be stored on (or retrieved from) the * disk. Adjusting the size of a string automatically sets the * precision to \p 8*size. * @@ -2767,7 +2767,7 @@ H5_DLL herr_t H5Treclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *bu /** * \ingroup H5T * - * \brief Commits a transient datatype to a file, creating a new named datatype + * \brief Commits a transient datatype to a file, creating a newly named datatype * * \fg_loc_id * \param[in] name Name given to committed datatype diff --git a/src/H5UCprivate.h b/src/H5UCprivate.h index 9a4aa2a..c6a6b7a 100644 --- a/src/H5UCprivate.h +++ b/src/H5UCprivate.h @@ -22,9 +22,6 @@ /**************************************/ /* Public headers needed by this file */ /**************************************/ -#ifdef LATER -#include "H5UCpublic.h" -#endif /* LATER */ /***************************************/ /* Private headers needed by this file */ @@ -967,7 +967,7 @@ H5VLquery_optional(hid_t obj_id, H5VL_subclass_t subcls, int opt_type, uint64_t /* Check args */ if (NULL == flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid 'flags' pointer") - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(obj_id))) + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Query the connector */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 07798c5..e1d7005 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -425,7 +425,7 @@ H5VL__set_def_conn(void) } /* end else */ /* Was there any connector info specified in the environment variable? */ - if (NULL != (tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) + if (NULL != (tok = HDstrtok_r(NULL, "\n\r", &lasts))) if (H5VL__connector_str_to_info(tok, connector_id, &vol_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info") diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index d7e730a..4ceac7a 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -388,6 +388,7 @@ H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id) new_obj = (H5VL_pass_through_t *)calloc(1, sizeof(H5VL_pass_through_t)); new_obj->under_object = under_obj; new_obj->under_vol_id = under_vol_id; + H5Iinc_ref(new_obj->under_vol_id); return new_obj; @@ -520,12 +521,27 @@ H5VL_pass_through_info_copy(const void *_info) printf("------- PASS THROUGH VOL INFO Copy\n"); #endif + /* Make sure the underneath VOL of this pass-through VOL is specified */ + if (!info) { + printf("\nH5VLpassthru.c line %d in %s: info for pass-through VOL can't be null\n", __LINE__, + __func__); + return NULL; + } + + if (H5Iis_valid(info->under_vol_id) <= 0) { + printf("\nH5VLpassthru.c line %d in %s: not a valid underneath VOL ID for pass-through VOL\n", + __LINE__, __func__); + return NULL; + } + /* Allocate new VOL info struct for the pass through connector */ new_info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); /* Increment reference count on underlying VOL ID, and copy the VOL info */ new_info->under_vol_id = info->under_vol_id; + H5Iinc_ref(new_info->under_vol_id); + if (info->under_vol_info) H5VLcopy_connector_info(new_info->under_vol_id, &(new_info->under_vol_info), info->under_vol_info); @@ -753,7 +769,9 @@ H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) /* Increment reference count on underlying VOL ID, and copy the VOL info */ new_wrap_ctx->under_vol_id = o->under_vol_id; + H5Iinc_ref(new_wrap_ctx->under_vol_id); + H5VLget_wrap_ctx(o->under_object, o->under_vol_id, &new_wrap_ctx->under_wrap_ctx); /* Set wrap context to return */ @@ -2605,6 +2623,19 @@ H5VL_pass_through_introspect_get_cap_flags(const void *_info, uint64_t *cap_flag printf("------- PASS THROUGH VOL INTROSPECT GetCapFlags\n"); #endif + /* Make sure the underneath VOL of this pass-through VOL is specified */ + if (!info) { + printf("\nH5VLpassthru.c line %d in %s: info for pass-through VOL can't be null\n", __LINE__, + __func__); + return -1; + } + + if (H5Iis_valid(info->under_vol_id) <= 0) { + printf("\nH5VLpassthru.c line %d in %s: not a valid underneath VOL ID for pass-through VOL\n", + __LINE__, __func__); + return -1; + } + /* Invoke the query on the underlying VOL connector */ ret_value = H5VLintrospect_get_cap_flags(info->under_vol_info, info->under_vol_id, cap_flags); @@ -35,11 +35,6 @@ static void H5VM__stride_optimize1(unsigned *np /*in,out*/, hsize_t *elmt_size / const hsize_t *size, hsize_t *stride1); static void H5VM__stride_optimize2(unsigned *np /*in,out*/, hsize_t *elmt_size /*in,out*/, const hsize_t *size, hsize_t *stride1, hsize_t *stride2); -#ifdef LATER -static void H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsize_t *dst_size, - const ssize_t *dst_stride, void *_dst, unsigned src_n, const hsize_t *src_size, - const ssize_t *src_stride, const void *_src); -#endif /* LATER */ /*------------------------------------------------------------------------- * Function: H5VM__stride_optimize1 @@ -761,76 +756,6 @@ H5VM_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size, const hss FUNC_LEAVE_NOAPI(SUCCEED) } -#ifdef LATER - -/*------------------------------------------------------------------------- - * Function: H5VM__stride_copy2 - * - * Purpose: Similar to H5VM_stride_copy() except the source and - * destination each have their own dimensionality and size and - * we copy exactly NELMTS elements each of size ELMT_SIZE. The - * size counters wrap if NELMTS is more than a size counter. - * - * Return: void - * - * Programmer: Robb Matzke - * Saturday, October 11, 1997 - * - *------------------------------------------------------------------------- - */ -static void -H5VM__stride_copy2(hsize_t nelmts, hsize_t elmt_size, unsigned dst_n, const hsize_t *dst_size, - const hsize_t *dst_stride, void *_dst, unsigned src_n, const hsize_t *src_size, - const hsize_t *src_stride, const void *_src) -{ - uint8_t *dst = (uint8_t *)_dst; - const uint8_t *src = (const uint8_t *)_src; - hsize_t dst_idx[H5VM_HYPER_NDIMS]; - hsize_t src_idx[H5VM_HYPER_NDIMS]; - hsize_t i; /* Local index variable */ - int j; /* Local index variable */ - hbool_t carry; - - FUNC_ENTER_PACKAGE_NOERR - - HDassert(elmt_size < SIZE_MAX); - HDassert(dst_n > 0); - HDassert(src_n > 0); - - H5VM_vector_cpy(dst_n, dst_idx, dst_size); - H5VM_vector_cpy(src_n, src_idx, src_size); - - for (i = 0; i < nelmts; i++) { - - /* Copy an element */ - H5_CHECK_OVERFLOW(elmt_size, hsize_t, size_t); - H5MM_memcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */ - - /* Decrement indices and advance pointers */ - for (j = (int)(dst_n - 1), carry = TRUE; j >= 0 && carry; --j) { - dst += dst_stride[j]; - if (--dst_idx[j]) - carry = FALSE; - else { - HDassert(dst_size); - dst_idx[j] = dst_size[j]; - } /* end else */ - } - for (j = (int)(src_n - 1), carry = TRUE; j >= 0 && carry; --j) { - src += src_stride[j]; - if (--src_idx[j]) - carry = FALSE; - else { - HDassert(src_size); - src_idx[j] = src_size[j]; - } /* end else */ - } - } - - FUNC_LEAVE_NOAPI_VOID -} -#endif /* LATER */ - /*------------------------------------------------------------------------- * Function: H5VM_array_fill * diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 1f94f0e..49bb53d 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -10,10 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Robb Matzke - * Friday, October 10, 1997 - */ #ifndef H5VMprivate_H #define H5VMprivate_H @@ -133,13 +129,8 @@ H5_DLL ssize_t H5VM_memcpyvv(void *_dst, size_t dst_max_nseq, size_t *dst_curr_s * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: Success: Product of elements - * - * Failure: 1 if N is zero - * - * Programmer: Robb Matzke - * Friday, October 10, 1997 - * + * Return: Success: Product of elements + * Failure: 1 if N is zero *------------------------------------------------------------------------- */ static inline hsize_t H5_ATTR_UNUSED @@ -168,14 +159,8 @@ done: * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: Success: TRUE if all elements are zero, - * FALSE otherwise - * - * Failure: TRUE if N is zero - * - * Programmer: Robb Matzke - * Friday, October 10, 1997 - * + * Return: Success: TRUE if all elements are zero, + * Failure: TRUE if N is zero *------------------------------------------------------------------------- */ static inline htri_t H5_ATTR_UNUSED @@ -205,14 +190,9 @@ done: * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: Success: TRUE if all elements are zero, - * FALSE otherwise - * - * Failure: TRUE if N is zero - * - * Programmer: Robb Matzke - * Friday, October 10, 1997 - * + * Return: Success: TRUE if all elements are zero, + * FALSE otherwise + * Failure: TRUE if N is zero *------------------------------------------------------------------------- */ static inline htri_t H5_ATTR_UNUSED @@ -243,15 +223,11 @@ done: * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: Success: -1 if V1 is less than V2 - * 0 if they are equal - * 1 if V1 is greater than V2 - * - * Failure: 0 if N is zero - * - * Programmer: Robb Matzke - * Friday, October 10, 1997 + * Return: Success: -1 if V1 is less than V2 + * 0 if they are equal + * 1 if V1 is greater than V2 * + * Failure: 0 if N is zero *------------------------------------------------------------------------- */ static inline int H5_ATTR_UNUSED @@ -291,15 +267,11 @@ done: * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: Success: -1 if V1 is less than V2 - * 0 if they are equal - * 1 if V1 is greater than V2 - * - * Failure: 0 if N is zero - * - * Programmer: Robb Matzke - * Wednesday, April 8, 1998 + * Return: Success: -1 if V1 is less than V2 + * 0 if they are equal + * 1 if V1 is greater than V2 * + * Failure: 0 if N is zero *------------------------------------------------------------------------- */ static inline int H5_ATTR_UNUSED @@ -339,10 +311,6 @@ done: * reflects its inclusion in a "private" header file. * * Return: void - * - * Programmer: Robb Matzke - * Monday, October 13, 1997 - * *------------------------------------------------------------------------- */ static inline void H5_ATTR_UNUSED @@ -383,10 +351,6 @@ static const unsigned char LogTable256[] = { * reflects its inclusion in a "private" header file. * * Return: log2(n) (always - no failure condition) - * - * Programmer: Quincey Koziol - * Monday, March 6, 2006 - * *------------------------------------------------------------------------- */ static inline unsigned H5_ATTR_UNUSED @@ -432,10 +396,6 @@ static const unsigned MultiplyDeBruijnBitPosition[32] = {0, 1, 28, 2, 29, 14, * reflects its inclusion in a "private" header file. * * Return: log2(n) (always - no failure condition) - * - * Programmer: Quincey Koziol - * Monday, February 27, 2006 - * *------------------------------------------------------------------------- */ static inline H5_ATTR_PURE unsigned @@ -450,16 +410,13 @@ H5VM_log2_of2(uint32_t n) /*------------------------------------------------------------------------- * Function: H5VM_power2up * - * Purpose: Round up a number to the next power of 2 + * Purpose: Round up a number to the next power of 2 * * Note: Although this routine is 'static' in this file, that's intended * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: Return the number which is a power of 2 - * - * Programmer: Vailin Choi; Nov 2014 - * + * Return: Return the number which is a power of 2 *------------------------------------------------------------------------- */ static inline H5_ATTR_CONST hsize_t @@ -488,10 +445,6 @@ H5VM_power2up(hsize_t n) * reflects its inclusion in a "private" header file. * * Return: Number of bytes needed - * - * Programmer: Quincey Koziol - * Thursday, March 13, 2008 - * *------------------------------------------------------------------------- */ static inline unsigned H5_ATTR_UNUSED @@ -520,10 +473,6 @@ static const unsigned char H5VM_bit_clear_g[8] = {0x7F, 0xBF, 0xDF, 0xEF, 0xF7, * reflects its inclusion in a "private" header file. * * Return: TRUE/FALSE - * - * Programmer: Quincey Koziol - * Tuesday, November 25, 2008 - * *------------------------------------------------------------------------- */ static inline hbool_t H5_ATTR_UNUSED @@ -549,11 +498,7 @@ H5VM_bit_get(const unsigned char *buf, size_t offset) * only as an optimization and the naming (with a single underscore) * reflects its inclusion in a "private" header file. * - * Return: None - * - * Programmer: Quincey Koziol - * Tuesday, November 25, 2008 - * + * Return: void *------------------------------------------------------------------------- */ static inline void H5_ATTR_UNUSED @@ -104,9 +104,15 @@ H5Z_init(void) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter") #endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SZIP - H5Z_SZIP->encoder_present = SZ_encoder_enabled(); - if (H5Z_register(H5Z_SZIP) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter") + { + int encoder_enabled = SZ_encoder_enabled(); + if (encoder_enabled < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "check for szip encoder failed") + + H5Z_SZIP->encoder_present = (unsigned)encoder_enabled; + if (H5Z_register(H5Z_SZIP) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter") + } #endif /* H5_HAVE_FILTER_SZIP */ done: diff --git a/src/H5Zdevelop.h b/src/H5Zdevelop.h index 346eb0e..cc53824 100644 --- a/src/H5Zdevelop.h +++ b/src/H5Zdevelop.h @@ -227,12 +227,12 @@ extern "C" { * descriptive name for the filter, and may be the null pointer. * * \c can_apply, described in detail below, is a user-defined callback - * function which determines whether the combination of the dataset + * function that determines whether the combination of the dataset * creation property list values, the datatype, and the dataspace * represent a valid combination to apply this filter to. * * \c set_local, described in detail below, is a user-defined callback - * function which sets any parameters that are specific to this + * function that sets any parameters that are specific to this * dataset, based on the combination of the dataset creation property * list values, the datatype, and the dataspace. * @@ -242,9 +242,9 @@ extern "C" { * The statistics associated with a filter are not reset by this * function; they accumulate over the life of the library. * - * #H5Z_class_t is a macro which maps to either H5Z_class1_t or + * #H5Z_class_t is a macro that maps to either H5Z_class1_t or * H5Z_class2_t, depending on the needs of the application. To affect - * only this macro, H5Z_class_t_vers may be defined to either 1 or 2. + * only this macro, H5Z_class_t_vers may be defined as either 1 or 2. * Otherwise, it will behave in the same manner as other API * compatibility macros. See API Compatibility Macros in HDF5 for more * information. H5Z_class1_t matches the #H5Z_class_t structure that is @@ -261,15 +261,15 @@ extern "C" { * defined as described in the HDF5 library header file H5Zpublic.h. * * When a filter is applied to the fractal heap for a group (e.g., - * when compressing group metadata) and if the can apply and set local - * callback functions have been defined for that filter, HDF5 passes + * when compressing group metadata) and if they can apply and set local + * callback functions that have been defined for that filter, HDF5 passes * the value -1 for all parameters for those callback functions. This * is done to ensure that the filter will not be applied to groups if * it relies on these parameters, as they are not applicable to group * fractal heaps; to operate on group fractal heaps, a filter must be * capable of operating on an opaque block of binary data. * - * The \Emph{can apply} callback function must return a positive value + * The \Emph{can-apply} callback function must return a positive value * for a valid combination, zero for an invalid combination, and a * negative value for an error. * \snippet this H5Z_can_apply_func_t_snip @@ -302,9 +302,9 @@ extern "C" { * \Emph{set local} callback functions for any filters used in the * dataset creation property list are called. These callbacks receive * \c dcpl_id, the dataset's private copy of the dataset creation - * property list passed in to H5Dcreate() (i.e. not the actual - * property list passed in to H5Dcreate()); \c type_id, the datatype - * identifier passed in to H5Dcreate(), which is not copied and should + * property list passed into H5Dcreate() (i.e. not the actual + * property list passed into H5Dcreate()); \c type_id, the datatype + * identifier passed into H5Dcreate(), which is not copied and should * not be modified; and \c space_id, a dataspace describing the chunk * (for chunked dataset storage), which should also not be modified. * @@ -345,13 +345,13 @@ extern "C" { * will work in many cases, but if there is a mismatch between the * memory allocators used in the library and any filter that * reallocates a buffer, there could be problems. This is most often - * the case with Windows and/or when debug memory allocators are being + * the case with Windows and/or when debugging memory allocators are being * used. In both cases, the "state" of the memory allocator lies in * different libraries and will get corrupted if you allocate in one * library and free in another. Windows adds the C standard library - * via dlls that can vary with Visual Studio version and debug vs + * via dlls that can vary with Visual Studio version and debug vs. * release builds. Static links to the MSVC CRT can also introduce - * new memory allocator state. + * a new memory allocator state. * * The library does provide H5allocate_memory() and H5free_memory() * functions that will use the library's allocation and free functions, @@ -398,7 +398,7 @@ H5_DLL herr_t H5Zregister(const void *cls); * sure that all cached data that may use this filter are written out. * * If the application is a parallel program, all processes that - * participate in collective data write should call this function to + * participate in collective data writing should call this function to * ensure that all data is flushed. * * After a call to H5Zunregister(), the filter specified in filter diff --git a/src/H5Zmodule.h b/src/H5Zmodule.h index ec21e50..8b1a0de 100644 --- a/src/H5Zmodule.h +++ b/src/H5Zmodule.h @@ -11,12 +11,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5Z package. Including this header means that the source file - * is part of the H5Z package. + * Purpose: This file contains declarations which define macros for the + * H5Z package. Including this header means that the source file + * is part of the H5Z package. */ #ifndef H5Zmodule_H #define H5Zmodule_H @@ -84,7 +81,7 @@ * * The HDF5 library does not support filters for contiguous datasets because of * the difficulty of implementing random access for partial I/O. Compact dataset - * filters are not supported because it would not produce significant results. + * filters are not supported because they would not produce significant results. * * Filter identifiers for the filters distributed with the HDF5 * Library are as follows: diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 7b70022..1662738 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -10,10 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Robb Matzke - * Thursday, April 16, 1998 - */ - #ifndef H5Zprivate_H #define H5Zprivate_H diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index ce67cd7..8a05987 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -10,10 +10,6 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Robb Matzke - * Thursday, April 16, 1998 - */ - #ifndef H5Zpublic_H #define H5Zpublic_H @@ -268,7 +264,7 @@ H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); * \details H5Zget_filter_info() retrieves information about a filter. At * present, this means that the function retrieves a filter's * configuration flags, indicating whether the filter is configured to - * decode data, to encode data, neither, or both. + * decode data, encode data, neither, or both. * * If \p filter_config_flags is not set to NULL prior to the function * call, the returned parameter contains a bit field specifying the @@ -305,8 +301,8 @@ H5_DLL htri_t H5Zfilter_avail(H5Z_filter_t id); * to read an existing file encoded with that filter. * * This function should be called, and the returned \p - * filter_config_flags analyzed, before calling any other function, - * such as H5Pset_szip() , that might require a particular filter + * filter_config_flags should be analyzed, before calling any other function, + * such as H5Pset_szip(), that might require a particular filter * configuration. * * \since 1.6.3 diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 18ae248..b03ca38 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -72,7 +72,7 @@ static htri_t H5Z__can_apply_szip(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSED space_id) { const H5T_t *type; /* Datatype */ - unsigned dtype_size; /* Datatype's size (in bits) */ + size_t dtype_size; /* Datatype's size (in bits) */ H5T_order_t dtype_order; /* Datatype's endianness order */ htri_t ret_value = TRUE; /* Return value */ @@ -130,7 +130,7 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) H5T_order_t dtype_order; /* Datatype's endianness order */ size_t dtype_size; /* Datatype's size (in bits) */ size_t dtype_precision; /* Datatype's precision (in bits) */ - size_t dtype_offset; /* Datatype's offset (in bits) */ + int dtype_offset; /* Datatype's offset (in bits) */ hsize_t scanline; /* Size of dataspace's fastest changing dimension */ herr_t ret_value = SUCCEED; /* Return value */ @@ -160,16 +160,16 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) dtype_offset = H5T_get_offset(type); if (dtype_offset != 0) dtype_precision = dtype_size; - } /* end if */ + } if (dtype_precision > 24) { if (dtype_precision <= 32) dtype_precision = 32; else if (dtype_precision <= 64) dtype_precision = 64; - } /* end if */ + } /* Set "local" parameter for this dataset's "bits-per-pixel" */ - cd_values[H5Z_SZIP_PARM_BPP] = dtype_precision; + cd_values[H5Z_SZIP_PARM_BPP] = (unsigned)dtype_precision; /* Get dataspace */ if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) @@ -199,7 +199,7 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) if (npoints < cd_values[H5Z_SZIP_PARM_PPB]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "pixels per block greater than total number of elements in the chunk") - scanline = MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), npoints); + scanline = (hsize_t)MIN((cd_values[H5Z_SZIP_PARM_PPB] * SZ_MAX_BLOCKS_PER_SCANLINE), npoints); } else { if (scanline <= SZ_MAX_PIXELS_PER_SCANLINE) @@ -217,7 +217,7 @@ H5Z__set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) /* Set the correct endianness flag for szip */ /* (Note: this may not handle non-atomic datatypes well) */ - cd_values[H5Z_SZIP_PARM_MASK] &= ~(SZ_LSB_OPTION_MASK | SZ_MSB_OPTION_MASK); + cd_values[H5Z_SZIP_PARM_MASK] &= ~((unsigned)SZ_LSB_OPTION_MASK | (unsigned)SZ_MSB_OPTION_MASK); switch (dtype_order) { case H5T_ORDER_LE: /* Little-endian byte order */ cd_values[H5Z_SZIP_PARM_MASK] |= SZ_LSB_OPTION_MASK; diff --git a/src/H5detect.c b/src/H5detect.c index a491343..daf7708 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -839,7 +839,7 @@ bit.\n"; fprintf(rawoutstream, " *\t\t\t"); } - fprintf(rawoutstream, " *\n * Modifications:\n *\n"); + fprintf(rawoutstream, " *\n"); fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); fprintf(rawoutstream, " *\tIt was generated by code in `H5detect.c'.\n"); diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index a428062..88a6d7d 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -230,7 +230,7 @@ information about the library build configuration\n"; HDfprintf(rawoutstream, " *\t\t\t"); } - HDfprintf(rawoutstream, " *\n * Modifications:\n *\n"); + HDfprintf(rawoutstream, " *\n"); HDfprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); HDfprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n"); diff --git a/src/H5private.h b/src/H5private.h index 45cf9ae..70aed8f 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -10,14 +10,11 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Robb Matzke - * Friday, October 30, 1998 - * - * Purpose: This file is included by all HDF5 library source files to - * define common things which are not defined in the HDF5 API. - * The configuration constants like H5_HAVE_UNISTD_H etc. are - * defined in H5config.h which is included by H5public.h. - * +/* + * Purpose: This file is included by all HDF5 library source files to + * define common things which are not defined in the HDF5 API. + * The configuration constants like H5_HAVE_UNISTD_H etc. are + * defined in H5config.h which is included by H5public.h. */ #ifndef H5private_H @@ -125,6 +122,7 @@ #include <direct.h> /* For _getcwd() */ #include <io.h> /* POSIX I/O */ #include <winsock2.h> /* For GetUserName() */ +#include <shlwapi.h> /* For StrStrIA */ #ifdef H5_HAVE_THREADSAFE #include <process.h> /* For _beginthread() */ @@ -1865,9 +1863,6 @@ H5_DLL herr_t H5_trace_args(struct H5RS_str_t *rs, const char *type, va_list ap) * use initializers that require special cleanup code to * execute if FUNC_ENTER() fails since a failing FUNC_ENTER() * returns immediately without branching to the `done' label. - * - * Programmer: Quincey Koziol - * *------------------------------------------------------------------------- */ @@ -1936,7 +1931,7 @@ typedef struct H5_api_struct { #define H5_FIRST_THREAD_INIT pthread_once(&H5TS_first_init_g, H5TS_pthread_first_thread_init); #endif -/* Macros for threadsafe HDF-5 Phase I locks */ +/* Macros for threadsafe HDF5 Phase I locks */ #define H5_API_LOCK H5TS_mutex_lock(&H5_g.init_lock); #define H5_API_UNLOCK H5TS_mutex_unlock(&H5_g.init_lock); @@ -2293,11 +2288,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); /*------------------------------------------------------------------------- - * Purpose: Register function exit for code profiling. This should be - * the last statement executed by a function. - * - * Programmer: Quincey Koziol - * + * Purpose: Register function exit for code profiling. This should be + * the last statement executed by a function. *------------------------------------------------------------------------- */ /* Threadsafety termination code for API routines */ diff --git a/src/H5public.h b/src/H5public.h index 8e5646d..185deb0 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -421,7 +421,7 @@ extern "C" { * issued. If one finds that an HDF5 library function is failing * inexplicably, H5open() can be called first. It is safe to call * H5open() before an application issues any other function calls to - * the HDF5 library as there are no damaging side effects in calling + * the HDF5 library, as there are no damaging side effects in calling * it more than once. */ H5_DLL herr_t H5open(void); @@ -434,13 +434,13 @@ H5_DLL herr_t H5open(void); * * \details H5atclose() registers a callback that the HDF5 library will invoke * when closing. The full capabilities of the HDF5 library are - * available to callbacks invoked through this mechanism, library + * available to callbacks invoked through this mechanism, and library * shutdown will only begin in earnest when all callbacks have been * invoked and have returned. * * Registered callbacks are invoked in LIFO order, similar to the * Standard C 'atexit' routine. For example, if 'func1' is registered, - * then 'func2', when the library is closing 'func2' will + * then 'func2', when the library is closing 'func2', will * be invoked first, then 'func1'. * * The \p ctx pointer will be passed to \p func when it's invoked. @@ -474,13 +474,13 @@ H5_DLL herr_t H5close(void); * function is in situations where the library is dynamically linked * into an application and is un-linked from the application before * exit() gets called. In those situations, a routine installed with - * atexit() would jump to a routine which was no longer in memory, + * atexit() would jump to a routine that was no longer in memory, * causing errors. * * \attention In order to be effective, this routine \Emph{must} be called * before any other HDF5 function calls, and must be called each * time the library is loaded/linked into the application (the first - * time and after it's been un-loaded). + * time and after it's been unloaded). */ H5_DLL herr_t H5dont_atexit(void); /** @@ -492,7 +492,7 @@ H5_DLL herr_t H5dont_atexit(void); * of the library, freeing any unused memory. * * It is not required that H5garbage_collect() be called at any - * particular time; it is only necessary in certain situations where + * particular time; it is only necessary for certain situations where * the application has performed actions that cause the library to * allocate many objects. The application should call * H5garbage_collect() if it eventually releases those objects and @@ -678,7 +678,7 @@ H5_DLL herr_t H5is_library_threadsafe(hbool_t *is_ts); * \param[in] mem Buffer to be freed. Can be NULL * \return \herr_t * - * \details H5free_memory() frees memory that has been allocated by the caller + * \details H5free_memory() frees the memory that has been allocated by the caller * with H5allocate_memory() or by the HDF5 library on behalf of the * caller. * @@ -728,7 +728,7 @@ H5_DLL herr_t H5free_memory(void *mem); * initialized. * * This function is intended to have the semantics of malloc() and - * calloc(). However, unlike malloc() and calloc() which allow for a + * calloc(). However, unlike malloc() and calloc(), which allow for a * "special" pointer to be returned instead of NULL, this function * always returns NULL on failure or when size is set to 0 (zero). * @@ -740,7 +740,7 @@ H5_DLL herr_t H5free_memory(void *mem); * the same library that initially allocated it. In most cases, the * HDF5 API uses resources that are allocated and freed either * entirely by the user or entirely by the library, so this is not a - * problem. In rare cases, however, HDF5 API calls will free memory + * problem. In rare cases, however, HDF5 API calls will free the memory * that the user allocated. This function allows the user to safely * allocate this memory.\n * It is particularly important to use this function to allocate |