diff options
Diffstat (limited to 'src/H5C.c')
-rw-r--r-- | src/H5C.c | 549 |
1 files changed, 216 insertions, 333 deletions
@@ -229,6 +229,8 @@ const H5C_class_t epoch_marker_class = /* size = */ &H5C_epoch_marker_size }; + + /*************************************************************************** * Class functions for H5C__EPOCH_MAKER_TYPE: * @@ -239,10 +241,10 @@ const H5C_class_t epoch_marker_class = ***************************************************************************/ static void * -H5C_epoch_marker_load(H5F_t UNUSED * f, - hid_t UNUSED dxpl_id, - haddr_t UNUSED addr, - void UNUSED * udata) +H5C_epoch_marker_load(H5F_t H5_ATTR_UNUSED * f, + hid_t H5_ATTR_UNUSED dxpl_id, + haddr_t H5_ATTR_UNUSED addr, + void H5_ATTR_UNUSED * udata) { void * ret_value = NULL; /* Return value */ @@ -255,13 +257,15 @@ done: FUNC_LEAVE_NOAPI(ret_value) } + + static herr_t -H5C_epoch_marker_flush(H5F_t UNUSED *f, - hid_t UNUSED dxpl_id, - hbool_t UNUSED dest, - haddr_t UNUSED addr, - void UNUSED *thing, - unsigned UNUSED * flags_ptr) +H5C_epoch_marker_flush(H5F_t H5_ATTR_UNUSED *f, + hid_t H5_ATTR_UNUSED dxpl_id, + hbool_t H5_ATTR_UNUSED dest, + haddr_t H5_ATTR_UNUSED addr, + void H5_ATTR_UNUSED *thing, + unsigned H5_ATTR_UNUSED * flags_ptr) { herr_t ret_value = FAIL; /* Return value */ @@ -274,9 +278,11 @@ done: FUNC_LEAVE_NOAPI(ret_value) } + + static herr_t -H5C_epoch_marker_dest(H5F_t UNUSED * f, - void UNUSED * thing) +H5C_epoch_marker_dest(H5F_t H5_ATTR_UNUSED * f, + void H5_ATTR_UNUSED * thing) { herr_t ret_value = FAIL; /* Return value */ @@ -290,9 +296,9 @@ done: } static herr_t -H5C_epoch_marker_clear(H5F_t UNUSED * f, - void UNUSED * thing, - hbool_t UNUSED dest) +H5C_epoch_marker_clear(H5F_t H5_ATTR_UNUSED * f, + void H5_ATTR_UNUSED * thing, + hbool_t H5_ATTR_UNUSED dest) { herr_t ret_value = FAIL; /* Return value */ @@ -306,8 +312,8 @@ done: } static herr_t -H5C_epoch_marker_notify(H5C_notify_action_t UNUSED action, - void UNUSED * thing) +H5C_epoch_marker_notify(H5C_notify_action_t H5_ATTR_UNUSED action, + void H5_ATTR_UNUSED * thing) { herr_t ret_value = FAIL; /* Return value */ @@ -320,9 +326,9 @@ done: } static herr_t -H5C_epoch_marker_size(const H5F_t UNUSED * f, - const void UNUSED * thing, - size_t UNUSED * size_ptr) +H5C_epoch_marker_size(const H5F_t H5_ATTR_UNUSED * f, + const void H5_ATTR_UNUSED * thing, + size_t H5_ATTR_UNUSED * size_ptr) { herr_t ret_value = FAIL; /* Return value */ @@ -615,7 +621,7 @@ H5C_apply_candidate_list(H5F_t * f, (int)(cache_ptr->LRU_list_len)); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ - /* ====================================================================== * + /* ===================================================================== * * Now scan the LRU and PEL lists, flushing or clearing entries as * needed. * @@ -626,7 +632,7 @@ H5C_apply_candidate_list(H5F_t * f, * to account for this one case where they come into play. If these flags * are ever expanded upon, this function and the following flushing steps * should be reworked to account for additional cases. - * ====================================================================== */ + * ===================================================================== */ entries_examined = 0; initial_list_len = cache_ptr->LRU_list_len; @@ -784,7 +790,7 @@ H5C_apply_candidate_list(H5F_t * f, entries_flushed++; #if ( H5C_APPLY_CANDIDATE_LIST__DEBUG > 1 ) - HDfprintf(stdout, "%s:%d: flushing 0x%llx.\n", FUNC, mpi_rank, + HDfprintf(stdout, "%s:%d: flushing 0x%llx.\n", FUNC, mpi_rank, (long long)flush_ptr->addr); #endif /* H5C_APPLY_CANDIDATE_LIST__DEBUG */ @@ -1333,7 +1339,7 @@ H5C_def_auto_resize_rpt_fcn(H5C_t * cache_ptr, #ifndef NDEBUG int32_t version, #else /* NDEBUG */ - int32_t UNUSED version, + int32_t H5_ATTR_UNUSED version, #endif /* NDEBUG */ double hit_rate, enum H5C_resize_status status, @@ -1604,48 +1610,36 @@ H5C_expunge_entry(H5F_t * f, FUNC_ENTER_NOAPI(FAIL) - HDassert( f ); - HDassert( f->shared ); - + HDassert(f); + HDassert(f->shared); cache_ptr = f->shared->cache; - - HDassert( cache_ptr ); - HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - HDassert( type ); - HDassert( type->clear ); - HDassert( type->dest ); - HDassert( H5F_addr_defined(addr) ); + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + HDassert(type); + HDassert(type->clear); + HDassert(type->dest); + HDassert(H5F_addr_defined(addr)); #if H5C_DO_EXTREME_SANITY_CHECKS - if ( H5C_validate_lru_list(cache_ptr) < 0 ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "LRU extreme sanity check failed on entry.\n"); - } + if(H5C_validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "LRU extreme sanity check failed on entry.\n"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + /* Look for entry in cache */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) - - if ( ( entry_ptr == NULL ) || ( entry_ptr->type != type ) ) { - + if((entry_ptr == NULL) || (entry_ptr->type != type)) /* the target doesn't exist in the cache, so we are done. */ HGOTO_DONE(SUCCEED) - } - HDassert( entry_ptr->addr == addr ); - HDassert( entry_ptr->type == type ); - - if ( entry_ptr->is_protected ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ - "Target entry is protected.") - } + HDassert(entry_ptr->addr == addr); + HDassert(entry_ptr->type == type); - if ( entry_ptr->is_pinned ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, \ - "Target entry is pinned.") - } + /* Check for entry being pinned or protected */ + if(entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is protected.") + if(entry_ptr->is_pinned) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "Target entry is pinned.") /* Pass along 'free file space' flag to cache client */ entry_ptr->free_file_space_on_destroy = ( (flags & H5C__FREE_FILE_SPACE_FLAG) != 0 ); @@ -1670,17 +1664,13 @@ H5C_expunge_entry(H5F_t * f, } done: - #if H5C_DO_EXTREME_SANITY_CHECKS - if ( H5C_validate_lru_list(cache_ptr) < 0 ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "LRU extreme sanity check failed on exit.\n"); - } + if(H5C_validate_lru_list(cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "LRU extreme sanity check failed on exit.\n"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_expunge_entry() */ @@ -1728,10 +1718,10 @@ H5C_flush_cache(H5F_t *f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsign H5C_cache_entry_t * entry_ptr = NULL; H5C_cache_entry_t * next_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS - int64_t flushed_entries_count; - size_t flushed_entries_size; - int64_t initial_slist_len; - size_t initial_slist_size; + int64_t flushed_entries_count = 0; + int64_t flushed_entries_size = 0; + int64_t initial_slist_len = 0; + size_t initial_slist_size = 0; #endif /* H5C_DO_SANITY_CHECKS */ FUNC_ENTER_NOAPI(FAIL) @@ -1953,7 +1943,7 @@ H5C_flush_cache(H5F_t *f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsign if(entry_ptr->flush_dep_height == curr_flush_dep_height ) { #if H5C_DO_SANITY_CHECKS flushed_entries_count++; - flushed_entries_size += entry_ptr->size; + flushed_entries_size += (int64_t)entry_ptr->size; #endif /* H5C_DO_SANITY_CHECKS */ status = H5C_flush_single_entry(f, primary_dxpl_id, @@ -1965,8 +1955,8 @@ H5C_flush_cache(H5F_t *f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsign FALSE); if ( status < 0 ) { - /* This shouldn't happen -- if it does, we are toast - * so just scream and die. + /* This shouldn't happen -- if it does, + * we are toast so just scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "dirty pinned entry flush failed.") @@ -1983,10 +1973,10 @@ H5C_flush_cache(H5F_t *f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsign * aren't trying to do a destroy here, so that * is not an issue. */ - if(entry_ptr->flush_dep_height == curr_flush_dep_height ){ + if(entry_ptr->flush_dep_height == curr_flush_dep_height ) { #if H5C_DO_SANITY_CHECKS flushed_entries_count++; - flushed_entries_size += entry_ptr->size; + flushed_entries_size += (int64_t)entry_ptr->size; #endif /* H5C_DO_SANITY_CHECKS */ status = H5C_flush_single_entry(f, primary_dxpl_id, @@ -1998,8 +1988,8 @@ H5C_flush_cache(H5F_t *f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id, unsign FALSE); if ( status < 0 ) { - /* This shouldn't happen -- if it does, we are - * toast so just scream and die. + /* This shouldn't happen -- if it does, + * we are toast so just scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ "Can't flush entry.") @@ -2037,8 +2027,8 @@ end_of_inner_loop: HDassert( (initial_slist_len + cache_ptr->slist_len_increase - flushed_entries_count) == cache_ptr->slist_len ); - HDassert( (initial_slist_size + - (size_t)(cache_ptr->slist_size_increase) - + HDassert( (size_t)((int64_t)initial_slist_size + + cache_ptr->slist_size_increase - flushed_entries_size) == cache_ptr->slist_size ); #endif /* H5C_DO_SANITY_CHECKS */ @@ -2111,7 +2101,7 @@ H5C_flush_to_min_clean(H5F_t * f, hid_t primary_dxpl_id, hid_t secondary_dxpl_id) { - H5C_t * cache_ptr; + H5C_t * cache_ptr; herr_t result; hbool_t first_flush = TRUE; hbool_t write_permitted; @@ -2137,9 +2127,7 @@ H5C_flush_to_min_clean(H5F_t * f, if ( cache_ptr->check_write_permitted != NULL ) { - result = (cache_ptr->check_write_permitted)(f, - primary_dxpl_id, - &write_permitted); + result = (cache_ptr->check_write_permitted)(f, &write_permitted); if ( result < 0 ) { @@ -2396,41 +2384,28 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_get_cache_hit_rate(H5C_t * cache_ptr, - double * hit_rate_ptr) - +H5C_get_cache_hit_rate(H5C_t * cache_ptr, double * hit_rate_ptr) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { - + if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - } - - if ( hit_rate_ptr == NULL ) { - + if(hit_rate_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad hit_rate_ptr on entry.") - } - HDassert( cache_ptr->cache_hits >= 0 ); - HDassert( cache_ptr->cache_accesses >= cache_ptr->cache_hits ); - - if ( cache_ptr->cache_accesses > 0 ) { + HDassert(cache_ptr->cache_hits >= 0); + HDassert(cache_ptr->cache_accesses >= cache_ptr->cache_hits); + if(cache_ptr->cache_accesses > 0) *hit_rate_ptr = ((double)(cache_ptr->cache_hits)) / ((double)(cache_ptr->cache_accesses)); - - } else { - + else *hit_rate_ptr = 0.0f; - } done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_get_cache_hit_rate() */ @@ -2592,25 +2567,23 @@ done: * file logging is turned off), or contain a pointer to the * open file to which trace file data is to be written. * - * Return: Non-negative on success/Negative on failure + * Return: Non-NULL trace file pointer (can't fail) * * Programmer: John Mainzer * 1/20/06 * *------------------------------------------------------------------------- */ -herr_t -H5C_get_trace_file_ptr(const H5C_t *cache_ptr, FILE **trace_file_ptr_ptr) +FILE * +H5C_get_trace_file_ptr(const H5C_t *cache_ptr) { FUNC_ENTER_NOAPI_NOERR + /* Check arguments */ HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - HDassert(trace_file_ptr_ptr); - *trace_file_ptr_ptr = cache_ptr->trace_file_ptr; - - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI(cache_ptr->trace_file_ptr) } /* H5C_get_trace_file_ptr() */ @@ -2623,16 +2596,15 @@ H5C_get_trace_file_ptr(const H5C_t *cache_ptr, FILE **trace_file_ptr_ptr) * file logging is turned off), or contain a pointer to the * open file to which trace file data is to be written. * - * Return: Non-negative on success/Negative on failure + * Return: Non-NULL trace file pointer (can't fail) * * Programmer: Quincey Koziol * 6/9/08 * *------------------------------------------------------------------------- */ -herr_t -H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr, - FILE **trace_file_ptr_ptr) +FILE * +H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr) { FUNC_ENTER_NOAPI_NOERR @@ -2640,9 +2612,7 @@ H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr, HDassert(entry_ptr); HDassert(entry_ptr->cache_ptr); - H5C_get_trace_file_ptr(entry_ptr->cache_ptr, trace_file_ptr_ptr); - - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI(H5C_get_trace_file_ptr(entry_ptr->cache_ptr)) } /* H5C_get_trace_file_ptr_from_entry() */ @@ -2686,10 +2656,10 @@ H5C_insert_entry(H5F_t * f, herr_t result; hbool_t first_flush = TRUE; hbool_t insert_pinned; - hbool_t flush_last; + hbool_t flush_last; #ifdef H5_HAVE_PARALLEL - hbool_t flush_collectively; -#endif + hbool_t flush_collectively; +#endif /* H5_HAVE_PARALLEL */ hbool_t set_flush_marker; hbool_t write_permitted = TRUE; size_t empty_space; @@ -2731,7 +2701,7 @@ H5C_insert_entry(H5F_t * f, flush_last = ( (flags & H5C__FLUSH_LAST_FLAG) != 0 ); #ifdef H5_HAVE_PARALLEL flush_collectively = ( (flags & H5C__FLUSH_COLLECTIVELY_FLAG) != 0 ); -#endif +#endif /* H5_HAVE_PARALLEL */ entry_ptr = (H5C_cache_entry_t *)thing; @@ -2741,19 +2711,12 @@ H5C_insert_entry(H5F_t * f, H5C__SEARCH_INDEX(cache_ptr, addr, test_entry_ptr, FAIL) - if ( test_entry_ptr != NULL ) { - - if ( test_entry_ptr == entry_ptr ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ - "entry already in cache.") - - } else { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, \ - "duplicate entry in cache.") - } - } + if(test_entry_ptr != NULL) { + if(test_entry_ptr == entry_ptr) + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "entry already in cache.") + else + HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "duplicate entry in cache.") + } /* end if */ #ifndef NDEBUG entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC; @@ -2761,7 +2724,7 @@ H5C_insert_entry(H5F_t * f, entry_ptr->cache_ptr = cache_ptr; entry_ptr->addr = addr; entry_ptr->type = type; - + /* Apply tag to newly inserted entry */ if(H5C_tag_entry(cache_ptr, entry_ptr, primary_dxpl_id) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry") @@ -2829,28 +2792,17 @@ H5C_insert_entry(H5F_t * f, } } - 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; - } - - if ( ( cache_ptr->evictions_enabled ) - && + if ( ( cache_ptr->evictions_enabled ) && ( ( (cache_ptr->index_size + entry_ptr->size) > - cache_ptr->max_cache_size - ) + cache_ptr->max_cache_size) || - ( - ( ( empty_space + cache_ptr->clean_index_size ) < - cache_ptr->min_clean_size ) - ) - ) - ) { + ( ( ( empty_space + cache_ptr->clean_index_size ) < + cache_ptr->min_clean_size ) ) ) ) { size_t space_needed; @@ -2861,9 +2813,7 @@ H5C_insert_entry(H5F_t * f, if ( cache_ptr->check_write_permitted != NULL ) { - result = (cache_ptr->check_write_permitted)(f, - primary_dxpl_id, - &write_permitted); + result = (cache_ptr->check_write_permitted)(f, &write_permitted); if ( result < 0 ) { @@ -3364,11 +3314,6 @@ done: * Programmer: John Mainzer * 6/2/04 * - * JRM -- 11/5/08 - * On review this function looks like no change is needed to - * support the new clean_index_size and dirty_index_size - * fields of H5C_t. - * *------------------------------------------------------------------------- */ herr_t @@ -3377,11 +3322,11 @@ H5C_move_entry(H5C_t * cache_ptr, haddr_t old_addr, haddr_t new_addr) { + H5C_cache_entry_t * entry_ptr = NULL; + H5C_cache_entry_t * test_entry_ptr = NULL; #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS hbool_t was_dirty; #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - H5C_cache_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * test_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS hbool_t removed_entry_from_slist = FALSE; #endif /* H5C_DO_SANITY_CHECKS */ @@ -3513,7 +3458,7 @@ H5C_move_entry(H5C_t * cache_ptr, #endif /* H5C_DO_SANITY_CHECKS */ H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, FAIL) - } + } } H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr) @@ -3681,7 +3626,7 @@ H5C_pin_entry_from_client(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr) #else static herr_t -H5C_pin_entry_from_client(H5C_t UNUSED * cache_ptr, +H5C_pin_entry_from_client(H5C_t H5_ATTR_UNUSED * cache_ptr, H5C_cache_entry_t * entry_ptr) #endif { @@ -3881,10 +3826,7 @@ H5C_protect(H5F_t * f, } #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - if ( (flags & H5C__READ_ONLY_FLAG) != 0 ) - { - read_only = TRUE; - } + read_only = ( (flags & H5C__READ_ONLY_FLAG) != 0 ); /* first check to see if the target is in cache */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, NULL) @@ -3895,7 +3837,7 @@ H5C_protect(H5F_t * f, if(entry_ptr->type != type) HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "incorrect cache entry type") - #if H5C_DO_TAGGING_SANITY_CHECKS +#if H5C_DO_TAGGING_SANITY_CHECKS /* The entry is already in the cache, but make sure that the tag value being passed in via dxpl is still legal. This will ensure that had the entry NOT been in the cache, tagging was still set up correctly @@ -3918,8 +3860,8 @@ H5C_protect(H5F_t * f, HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "tag verification failed"); } /* end if */ - #endif - +#endif + hit = TRUE; thing = (void *)entry_ptr; @@ -3958,21 +3900,15 @@ H5C_protect(H5F_t * f, } } - 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; - } - /* try to free up if necceary and if evictions are permitted. Note * that if evictions are enabled, we will call H5C_make_space_in_cache() * regardless if the min_free_space requirement is not met. */ - if ( ( cache_ptr->evictions_enabled ) && ( ( (cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) @@ -3984,17 +3920,12 @@ H5C_protect(H5F_t * f, size_t space_needed; - if ( empty_space <= entry_ptr->size ) { - + if(empty_space <= entry_ptr->size) cache_ptr->cache_full = TRUE; - } - if ( cache_ptr->check_write_permitted != NULL ) { - result = (cache_ptr->check_write_permitted)(f, - primary_dxpl_id, - &write_permitted); + result = (cache_ptr->check_write_permitted)(f, &write_permitted); if ( result < 0 ) { @@ -4141,9 +4072,7 @@ H5C_protect(H5F_t * f, if ( cache_ptr->check_write_permitted != NULL ) { - result = (cache_ptr->check_write_permitted)(f, - primary_dxpl_id, - &write_permitted); + result = (cache_ptr->check_write_permitted)(f, &write_permitted); if ( result < 0 ) { @@ -4195,25 +4124,18 @@ H5C_protect(H5F_t * f, * into complience. */ - 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; - } - if ( ( cache_ptr->index_size > cache_ptr->max_cache_size ) || ( ( empty_space + cache_ptr->clean_index_size ) < cache_ptr->min_clean_size) ) { - if ( cache_ptr->index_size > cache_ptr->max_cache_size ) { - + if(cache_ptr->index_size > cache_ptr->max_cache_size) cache_ptr->cache_full = TRUE; - } result = H5C_make_space_in_cache(f, primary_dxpl_id, secondary_dxpl_id, @@ -4651,9 +4573,7 @@ H5C_set_prefix(H5C_t * cache_ptr, char * prefix) cache_ptr->prefix[H5C__PREFIX_LEN - 1] = '\0'; done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_set_prefix() */ @@ -4723,12 +4643,10 @@ H5C_stats(H5C_t * cache_ptr, const char * cache_name, hbool_t #if !H5C_COLLECT_CACHE_STATS - UNUSED + H5_ATTR_UNUSED #endif /* H5C_COLLECT_CACHE_STATS */ display_detailed_stats) { - herr_t ret_value = SUCCEED; /* Return value */ - #if H5C_COLLECT_CACHE_STATS int i; int64_t total_hits = 0; @@ -4760,11 +4678,12 @@ H5C_stats(H5C_t * cache_ptr, size_t aggregate_max_size = 0; int32_t aggregate_max_pins = 0; double hit_rate; - double average_successful_search_depth = 0.0; - double average_failed_search_depth = 0.0; - double average_entries_skipped_per_calls_to_msic = 0.0; - double average_entries_scanned_per_calls_to_msic = 0.0; + double average_successful_search_depth = 0.0f; + double average_failed_search_depth = 0.0f; + double average_entries_skipped_per_calls_to_msic = 0.0f; + double average_entries_scanned_per_calls_to_msic = 0.0f; #endif /* H5C_COLLECT_CACHE_STATS */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -4794,11 +4713,9 @@ H5C_stats(H5C_t * cache_ptr, total_clears += cache_ptr->clears[i]; total_flushes += cache_ptr->flushes[i]; total_evictions += cache_ptr->evictions[i]; - total_moves += cache_ptr->moves[i]; - total_entry_flush_moves - += cache_ptr->entry_flush_moves[i]; - total_cache_flush_moves - += cache_ptr->cache_flush_moves[i]; + total_moves += cache_ptr->moves[i]; + total_entry_flush_moves += cache_ptr->entry_flush_moves[i]; + total_cache_flush_moves += cache_ptr->cache_flush_moves[i]; total_size_increases += cache_ptr->size_increases[i]; total_size_decreases += cache_ptr->size_decreases[i]; total_entry_flush_size_changes @@ -4830,10 +4747,10 @@ H5C_stats(H5C_t * cache_ptr, if ( ( total_hits > 0 ) || ( total_misses > 0 ) ) { - hit_rate = 100.0 * ((double)(total_hits)) / + hit_rate = (double)100.0f * ((double)(total_hits)) / ((double)(total_hits + total_misses)); } else { - hit_rate = 0.0; + hit_rate = 0.0f; } if ( cache_ptr->successful_ht_searches > 0 ) { @@ -4954,14 +4871,14 @@ H5C_stats(H5C_t * cache_ptr, (long)total_evictions); HDfprintf(stdout, - "%s Total insertions(pinned) / moves = %ld(%ld) / %ld\n", + "%s Total insertions(pinned) / moves = %ld(%ld) / %ld\n", cache_ptr->prefix, (long)total_insertions, (long)total_pinned_insertions, (long)total_moves); HDfprintf(stdout, - "%s Total entry / cache flush moves = %ld / %ld\n", + "%s Total entry / cache flush moves = %ld / %ld\n", cache_ptr->prefix, (long)total_entry_flush_moves, (long)total_cache_flush_moves); @@ -5000,7 +4917,7 @@ H5C_stats(H5C_t * cache_ptr, HDfprintf(stdout, "%s MSIC: Average/max entries skipped = %lf / %ld\n", cache_ptr->prefix, - (float)average_entries_skipped_per_calls_to_msic, + (double)average_entries_skipped_per_calls_to_msic, (long)(cache_ptr->max_entries_skipped_in_msic)); if (cache_ptr->calls_to_msic > 0) { @@ -5011,7 +4928,7 @@ H5C_stats(H5C_t * cache_ptr, HDfprintf(stdout, "%s MSIC: Average/max entries scanned = %lf / %ld\n", cache_ptr->prefix, - (float)average_entries_scanned_per_calls_to_msic, + (double)average_entries_scanned_per_calls_to_msic, (long)(cache_ptr->max_entries_scanned_in_msic)); HDfprintf(stdout, "%s MSIC: Scanned to make space(evict) = %lld\n", @@ -5055,10 +4972,10 @@ H5C_stats(H5C_t * cache_ptr, if ( ( cache_ptr->hits[i] > 0 ) || ( cache_ptr->misses[i] > 0 ) ) { - hit_rate = 100.0 * ((double)(cache_ptr->hits[i])) / + hit_rate = (double)100.0f * ((double)(cache_ptr->hits[i])) / ((double)(cache_ptr->hits[i] + cache_ptr->misses[i])); } else { - hit_rate = 0.0; + hit_rate = 0.0f; } HDfprintf(stdout, @@ -5083,14 +5000,14 @@ H5C_stats(H5C_t * cache_ptr, (long)(cache_ptr->evictions[i])); HDfprintf(stdout, - "%s insertions(pinned) / moves = %ld(%ld) / %ld\n", + "%s insertions(pinned) / moves = %ld(%ld) / %ld\n", cache_ptr->prefix, (long)(cache_ptr->insertions[i]), (long)(cache_ptr->pinned_insertions[i]), (long)(cache_ptr->moves[i])); HDfprintf(stdout, - "%s entry / cache flush moves = %ld / %ld\n", + "%s entry / cache flush moves = %ld / %ld\n", cache_ptr->prefix, (long)(cache_ptr->entry_flush_moves[i]), (long)(cache_ptr->cache_flush_moves[i])); @@ -5115,7 +5032,7 @@ H5C_stats(H5C_t * cache_ptr, (long)(cache_ptr->unpins[i])); HDfprintf(stdout, - "%s entry dirty pins/pin'd flushes = %ld / %ld\n", + "%s entry dirty pins/pin'd flushes = %ld / %ld\n", cache_ptr->prefix, (long)(cache_ptr->dirty_pins[i]), (long)(cache_ptr->pinned_flushes[i])); @@ -5184,7 +5101,7 @@ H5C_stats__reset(H5C_t * cache_ptr) #if H5C_COLLECT_CACHE_STATS H5C_stats__reset(H5C_t * cache_ptr) #else /* H5C_COLLECT_CACHE_STATS */ -H5C_stats__reset(H5C_t UNUSED * cache_ptr) +H5C_stats__reset(H5C_t H5_ATTR_UNUSED * cache_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ #endif /* NDEBUG */ { @@ -5209,8 +5126,8 @@ H5C_stats__reset(H5C_t UNUSED * cache_ptr) cache_ptr->flushes[i] = 0; cache_ptr->evictions[i] = 0; cache_ptr->moves[i] = 0; - cache_ptr->entry_flush_moves[i] = 0; - cache_ptr->cache_flush_moves[i] = 0; + cache_ptr->entry_flush_moves[i] = 0; + cache_ptr->cache_flush_moves[i] = 0; cache_ptr->pins[i] = 0; cache_ptr->unpins[i] = 0; cache_ptr->dirty_pins[i] = 0; @@ -5564,7 +5481,7 @@ H5C_unprotect(H5F_t * f, void * thing, unsigned int flags) { - H5C_t * cache_ptr; + H5C_t * cache_ptr; hbool_t deleted; hbool_t dirtied; hbool_t set_flush_marker; @@ -5582,13 +5499,13 @@ H5C_unprotect(H5F_t * f, FUNC_ENTER_NOAPI(FAIL) - deleted = ( (flags & H5C__DELETED_FLAG) != 0 ); - dirtied = ( (flags & H5C__DIRTIED_FLAG) != 0 ); - set_flush_marker = ( (flags & H5C__SET_FLUSH_MARKER_FLAG) != 0 ); - pin_entry = ( (flags & H5C__PIN_ENTRY_FLAG) != 0 ); - unpin_entry = ( (flags & H5C__UNPIN_ENTRY_FLAG) != 0 ); - free_file_space = ( (flags & H5C__FREE_FILE_SPACE_FLAG) != 0 ); - take_ownership = ( (flags & H5C__TAKE_OWNERSHIP_FLAG) != 0 ); + deleted = ((flags & H5C__DELETED_FLAG) != 0); + dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); + set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); + pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); + free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); HDassert( f ); HDassert( f->shared ); @@ -5632,49 +5549,39 @@ H5C_unprotect(H5F_t * f, * the ro_ref_counter. Don't actually unprotect until the ref count * drops to zero. */ - if ( entry_ptr->ro_ref_count > 1 ) { - - HDassert( entry_ptr->is_protected ); - HDassert( entry_ptr->is_read_only ); - - if ( dirtied ) { + if(entry_ptr->ro_ref_count > 1) { + /* Sanity check */ + HDassert(entry_ptr->is_protected); + HDassert(entry_ptr->is_read_only); - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Read only entry modified(1)??") - } + if(dirtied) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") + /* Reduce the RO ref count */ (entry_ptr->ro_ref_count)--; /* Pin or unpin the entry as requested. */ - if ( pin_entry ) { - + 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 ) { - + } 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 ( entry_ptr->is_read_only ) { - - HDassert( entry_ptr->ro_ref_count == 1 ); - - if ( dirtied ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Read only entry modified(2)??") - } + if(dirtied) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Read only entry modified??") entry_ptr->is_read_only = FALSE; entry_ptr->ro_ref_count = 0; - } + } /* end if */ #ifdef H5_HAVE_PARALLEL /* When the H5C code is used to implement the metadata cache in the @@ -5692,47 +5599,36 @@ H5C_unprotect(H5F_t * f, * are contiguous, with only one dirty flag, we have to let the supplied * functions deal with the reseting the is_dirty flag. */ - if ( entry_ptr->clear_on_unprotect ) { - - HDassert( entry_ptr->is_dirty ); + if(entry_ptr->clear_on_unprotect) { + /* Sanity check */ + HDassert(entry_ptr->is_dirty); entry_ptr->clear_on_unprotect = FALSE; - - if ( ! dirtied ) { - + if(!dirtied) clear_entry = TRUE; - } - } + } /* end if */ #endif /* H5_HAVE_PARALLEL */ - if ( ! (entry_ptr->is_protected) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ - "Entry already unprotected??") - } - - /* mark the entry as dirty if appropriate */ - entry_ptr->is_dirty = ( (entry_ptr->is_dirty) || dirtied ); + if(!entry_ptr->is_protected) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Entry already unprotected??") - if ( ( was_clean ) && ( entry_ptr->is_dirty ) ) { + /* Mark the entry as dirty if appropriate */ + entry_ptr->is_dirty = (entry_ptr->is_dirty || dirtied); + /* Update index for newly dirtied entry */ + if(was_clean && entry_ptr->is_dirty) H5C__UPDATE_INDEX_FOR_ENTRY_DIRTY(cache_ptr, entry_ptr) - } /* Pin or unpin the entry as requested. */ - if ( pin_entry ) { - + 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 ) { - + } else if(unpin_entry) { /* Unpin the entry from a client */ if(H5C_unpin_entry_from_client(cache_ptr, entry_ptr, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "Can't unpin entry by client") - - } + } /* end if */ /* H5C__UPDATE_RP_FOR_UNPROTECT will place the unprotected entry on * the pinned entry list if entry_ptr->is_pinned is TRUE. @@ -5744,16 +5640,11 @@ H5C_unprotect(H5F_t * f, /* if the entry is dirty, 'or' its flush_marker with the set flush flag, * and then add it to the skip list if it isn't there already. */ - - if ( entry_ptr->is_dirty ) { - + if(entry_ptr->is_dirty) { entry_ptr->flush_marker |= set_flush_marker; - - if ( ! (entry_ptr->in_slist) ) { - + if(!entry_ptr->in_slist) H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL) - } - } + } /* end if */ /* this implementation of the "deleted" option is a bit inefficient, as * we re-insert the entry to be deleted into the replacement policy @@ -5798,10 +5689,8 @@ H5C_unprotect(H5F_t * f, entry_ptr->free_file_space_on_destroy = free_file_space; /* Set the "take ownership" flag for the flush, if needed */ - if ( take_ownership) { - + if(take_ownership) flush_flags |= H5C__TAKE_OWNERSHIP_FLAG; - } if ( H5C_flush_single_entry(f, primary_dxpl_id, @@ -7854,7 +7743,6 @@ H5C_flush_invalidate_cache(H5F_t * f, * may be created by the flush call backs. Thus it is possible * that the slist will not be empty after we finish the scan. */ - if ( cache_ptr->slist_len == 0 ) { node_ptr = NULL; @@ -7875,7 +7763,6 @@ H5C_flush_invalidate_cache(H5F_t * f, HDassert( next_entry_ptr->in_slist ); } - #if H5C_DO_SANITY_CHECKS /* Depending on circumstances, H5C_flush_single_entry() will * remove dirty entries from the slist as it flushes them. @@ -7886,10 +7773,12 @@ H5C_flush_invalidate_cache(H5F_t * f, initial_slist_size = cache_ptr->slist_size; /* There is also the possibility that entries will be - * dirtied, resized, and/or moved as the result of - * calls to the flush callbacks. We use the slist_len_increase - * and slist_size_increase increase fields in struct H5C_t - * to track these changes for purpose of sanity checking. + * dirtied, resized, moved, and/or removed from the cache + * as the result of calls to the flush callbacks. We use + * the slist_len_increase and slist_size_increase increase + * fields in struct H5C_t to track these changes for purpose + * of sanity checking. + * * To this end, we must zero these fields before we start * the pass through the slist. */ @@ -7988,7 +7877,7 @@ H5C_flush_invalidate_cache(H5F_t * f, ( cache_ptr->num_last_entries >= cache_ptr->slist_len ) ) ) { - #if H5C_DO_SANITY_CHECKS +#if H5C_DO_SANITY_CHECKS /* update actual_slist_len & actual_slist_size before * the flush. Note that the entry will be removed * from the slist after the flush, and thus may be @@ -8001,7 +7890,7 @@ H5C_flush_invalidate_cache(H5F_t * f, */ actual_slist_len++; actual_slist_size += entry_ptr->size; - #endif /* H5C_DO_SANITY_CHECKS */ +#endif /* H5C_DO_SANITY_CHECKS */ if ( entry_ptr->is_protected ) { @@ -8028,8 +7917,8 @@ H5C_flush_invalidate_cache(H5F_t * f, FALSE); if ( status < 0 ) { - /* This shouldn't happen -- if it does, we are toast - * so just scream and die. + /* This shouldn't happen -- if it does, we + * are toast so just scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ @@ -8054,8 +7943,8 @@ H5C_flush_invalidate_cache(H5F_t * f, TRUE); if ( status < 0 ) { - /* This shouldn't happen -- if it does, we are toast so - * just scream and die. + /* This shouldn't happen -- if it does, we + * are toast so just scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ @@ -8123,8 +8012,9 @@ H5C_flush_invalidate_cache(H5F_t * f, if ( entry_ptr->is_protected ) { - /* we have major problems -- but lets flush and destroy - * everything we can before we flag an error. + /* we have major problems -- but lets flush and + * destroy everything we can before we flag an + * error. */ protected_entries++; @@ -8148,8 +8038,8 @@ H5C_flush_invalidate_cache(H5F_t * f, TRUE); if ( status < 0 ) { - /* This shouldn't happen -- if it does, we are toast so - * just scream and die. + /* This shouldn't happen -- if it does, + * we are toast so just scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \ @@ -8304,10 +8194,10 @@ done: * primary_dxpl_id, and secondary_dxpl_id are all irrelevent, * and the call can't be part of a sequence of flushes. * - * If the caller knows the address of the TBBT node at + * If the caller knows the address of the skip list node at * which the target entry resides, it can avoid a lookup * by supplying that address in the tgt_node_ptr parameter. - * If this parameter is NULL, the function will do a TBBT + * If this parameter is NULL, the function will do a skip list * search for the entry instead. * * The function does nothing silently if there is no entry @@ -8332,13 +8222,12 @@ H5C_flush_single_entry(H5F_t * f, hbool_t del_entry_from_slist_on_destroy) { H5C_t * cache_ptr = f->shared->cache; - hbool_t destroy; - hbool_t clear_only; - hbool_t take_ownership; + hbool_t destroy; /* external flag */ + hbool_t clear_only; /* external flag */ + hbool_t take_ownership; /* external flag */ hbool_t was_dirty; hbool_t destroy_entry; herr_t status; - int type_id; unsigned flush_flags = H5C_CALLBACK__NO_FLAGS_SET; H5C_cache_entry_t * entry_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ @@ -8351,12 +8240,13 @@ H5C_flush_single_entry(H5F_t * f, HDassert( H5F_addr_defined(addr) ); HDassert( first_flush_ptr ); - destroy = ( (flags & H5C__FLUSH_INVALIDATE_FLAG) != 0 ); - clear_only = ( (flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); - take_ownership = ( (flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); + /* setup external flags from the flags parameter */ + destroy = ((flags & H5C__FLUSH_INVALIDATE_FLAG) != 0); + clear_only = ((flags & H5C__FLUSH_CLEAR_ONLY_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); /* Set the flag for destroying the entry, based on the 'take ownership' - * and 'destroy' flags + * and 'destroy' flags */ if(take_ownership) destroy_entry = FALSE; @@ -8366,6 +8256,7 @@ H5C_flush_single_entry(H5F_t * f, /* attempt to find the target entry in the hash table */ H5C__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + /* run initial sanity checks */ #if H5C_DO_SANITY_CHECKS if ( entry_ptr != NULL ) { @@ -8437,7 +8328,6 @@ H5C_flush_single_entry(H5F_t * f, #endif /* H5_HAVE_PARALLEL */ was_dirty = entry_ptr->is_dirty; - type_id = entry_ptr->type->id; entry_ptr->flush_marker = FALSE; @@ -8526,11 +8416,10 @@ H5C_flush_single_entry(H5F_t * f, #if H5C_DO_SANITY_CHECKS if ( ( entry_ptr->is_dirty ) && ( cache_ptr->check_write_permitted == NULL ) && - ( ! (cache_ptr->write_permitted) ) ) { + ( ! (cache_ptr->write_permitted) ) ) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ "Write when writes are always forbidden!?!?!") - } #endif /* H5C_DO_SANITY_CHECKS */ if ( destroy ) { @@ -8598,12 +8487,11 @@ H5C_flush_single_entry(H5F_t * f, * If that ceases to be the case, further * tests will be necessary. */ - if ( cache_ptr->aux_ptr != NULL ) { + if ( cache_ptr->aux_ptr != NULL ) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ "resize/move in serialize occured in parallel case.") - } } #endif /* H5_HAVE_PARALLEL */ } @@ -8701,13 +8589,13 @@ H5C_flush_single_entry(H5F_t * f, } + /* reset the flush_in progress flag */ entry_ptr->flush_in_progress = FALSE; } if ( cache_ptr->log_flush ) { - status = (cache_ptr->log_flush)(cache_ptr, addr, was_dirty, - flags, type_id); + status = (cache_ptr->log_flush)(cache_ptr, addr, was_dirty, flags); if ( status < 0 ) { @@ -8740,10 +8628,6 @@ done: * * Programmer: John Mainzer, 5/18/04 * - * QAK -- 1/31/08 - * Added initialization for the new free_file_space_on_destroy - * field. - * *------------------------------------------------------------------------- */ static void * @@ -8941,7 +8825,6 @@ H5C_make_space_in_cache(H5F_t * f, if ( write_permitted ) { initial_list_len = cache_ptr->LRU_list_len; - entry_ptr = cache_ptr->LRU_tail_ptr; if ( cache_ptr->index_size >= cache_ptr->max_cache_size ) { @@ -8997,6 +8880,7 @@ H5C_make_space_in_cache(H5F_t * f, cache_ptr->entries_scanned_to_make_space++; } #endif /* H5C_COLLECT_CACHE_STATS */ + result = H5C_flush_single_entry(f, primary_dxpl_id, secondary_dxpl_id, @@ -9038,7 +8922,6 @@ H5C_make_space_in_cache(H5F_t * f, total_entries_scanned++; #endif /* H5C_COLLECT_CACHE_STATS */ - } else { /* Skip epoch markers. Set result to SUCCEED to avoid |