diff options
Diffstat (limited to 'src/H5Ctag.c')
-rw-r--r-- | src/H5Ctag.c | 140 |
1 files changed, 78 insertions, 62 deletions
diff --git a/src/H5Ctag.c b/src/H5Ctag.c index a9b2ec0..e92d0e4 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -37,6 +37,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files */ #include "H5Iprivate.h" /* IDs */ @@ -54,26 +55,24 @@ /* Typedef for tagged entry iterator callback context - evict tagged entries */ typedef struct { - H5F_t * f; /* File pointer for evicting entry */ - hid_t dxpl_id; /* DXPL for evicting entry */ - hbool_t evicted_entries_last_pass; /* Flag to indicate that an entry - * was evicted when iterating over - * cache + H5F_t *f; /* File pointer for evicting entry */ + hbool_t evicted_entries_last_pass; /* Flag to indicate that an entry + * was evicted when iterating over + * cache */ - hbool_t pinned_entries_need_evicted;/* Flag to indicate that a pinned - * entry was attempted to be evicted + hbool_t pinned_entries_need_evicted;/* Flag to indicate that a pinned + * entry was attempted to be evicted */ - hbool_t skipped_pf_dirty_entries; /* Flag indicating that one or more + hbool_t skipped_pf_dirty_entries; /* Flag indicating that one or more * entries marked prefetched_dirty - * were encountered and not + * were encountered and not * evicted. */ } H5C_tag_iter_evict_ctx_t; /* Typedef for tagged entry iterator callback context - expunge tag type metadata */ typedef struct { - H5F_t * f; /* File pointer for evicting entry */ - hid_t dxpl_id; /* DXPL for evicting entry */ + H5F_t *f; /* File pointer for evicting entry */ int type_id; /* Cache entry type to expunge */ unsigned flags; /* Flags for expunging entry */ } H5C_tag_iter_ettm_ctx_t; @@ -114,10 +113,10 @@ H5FL_EXTERN(H5C_tag_info_t); * Function: H5C_ignore_tags * * Purpose: Override all assertion frameworks associated with making - * sure proper tags are applied to cache entries. + * sure proper tags are applied to cache entries. * - * NOTE: This should really only be used in tests that need - * to access internal functions without going through + * NOTE: This should really only be used in tests that need + * to access internal functions without going through * standard API paths. Since tags are set inside dxpl_id's * before coming into the cache, any external functions that * use the internal library functions (i.e., tests) should @@ -176,11 +175,37 @@ H5C_get_ignore_tags(const H5C_t *cache_ptr) /*------------------------------------------------------------------------- * + * Function: H5C_get_num_objs_corked + * + * Purpose: Retrieve the 'num_objs_corked' field for the cache + * + * Return: 'num_objs_corked' value (can't fail) + * + * Programmer: Vailin Choi; Feb 2019 + * + *------------------------------------------------------------------------- + */ +uint32_t +H5C_get_num_objs_corked(const H5C_t *cache_ptr) +{ + FUNC_ENTER_NOAPI_NOERR + + /* Sanity checks */ + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + + /* Return value for num_objs_corked */ + FUNC_LEAVE_NOAPI(cache_ptr->num_objs_corked) +} /* H5C_get_num_objs_corked */ + + +/*------------------------------------------------------------------------- + * * Function: H5C__tag_entry * - * Purpose: Tags an entry with the provided tag (contained in the dxpl_id). - * If sanity checking is enabled, this function will perform - * validation that a proper tag is contained within the provided + * Purpose: Tags an entry with the provided tag (contained in the API context). + * If sanity checking is enabled, this function will perform + * validation that a proper tag is contained within the provided * data access property list id before application. * * Return: FAIL if error is detected, SUCCEED otherwise. @@ -191,9 +216,8 @@ H5C_get_ignore_tags(const H5C_t *cache_ptr) *------------------------------------------------------------------------- */ herr_t -H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry, hid_t dxpl_id) +H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) { - H5P_genplist_t *dxpl; /* dataset transfer property list */ H5C_tag_info_t *tag_info; /* Points to a tag info struct */ haddr_t tag; /* Tag value */ herr_t ret_value = SUCCEED; /* Return value */ @@ -205,20 +229,15 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry, hid_t dxpl_id) HDassert(entry != NULL); HDassert(cache->magic == H5C__H5C_T_MAGIC); - /* Get the dataset transfer property list */ - if(NULL == (dxpl = (H5P_genplist_t *)H5I_object_verify(dxpl_id, H5I_GENPROP_LST))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Get the tag from the DXPL */ - if((H5P_get(dxpl, H5AC_TAG_NAME, &tag)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value") + /* Get the tag */ + tag = H5CX_get_tag(); if(cache->ignore_tags) { /* if we're ignoring tags, it's because we're running - tests on internal functions and may not have inserted a tag - value into a given dxpl_id before creating some metadata. Thus, + tests on internal functions and may not have inserted a tag + value into a given API context before creating some metadata. Thus, in this case only, if a tag value has not been set, we can - arbitrarily set it to something for the sake of passing the tests. + arbitrarily set it to something for the sake of passing the tests. If the tag value is set, then we'll just let it get assigned without additional checking for correctness. */ if(!H5F_addr_defined(tag)) @@ -380,7 +399,7 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, /* Make callback for entry */ if((cb)(entry, cb_ctx) != H5_ITER_CONT) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "tagged entry iteration callback failed") - + /* Advance to next entry */ entry = next_entry; } /* end while */ @@ -422,11 +441,11 @@ H5C__iter_tagged_entries(H5C_t *cache, haddr_t tag, hbool_t match_global, HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") /* Check for iterating over global metadata */ - if(match_global) { + if(match_global) { /* Iterate over the entries for SOHM entries */ if(H5C__iter_tagged_entries_real(cache, H5AC__SOHM_TAG, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") - + /* Iterate over the entries for global heap entries */ if(H5C__iter_tagged_entries_real(cache, H5AC__GLOBALHEAP_TAG, cb, cb_ctx) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "iteration of tagged entries failed") @@ -475,12 +494,12 @@ H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) ctx->pinned_entries_need_evicted = TRUE; else if(!entry->prefetched_dirty) { /* Evict the Entry */ - if(H5C__flush_single_entry(ctx->f, ctx->dxpl_id, entry, H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) + if(H5C__flush_single_entry(ctx->f, entry, H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, H5_ITER_ERROR, "Entry eviction failed.") ctx->evicted_entries_last_pass = TRUE; - } else { - ctx->skipped_pf_dirty_entries = TRUE; } + else + ctx->skipped_pf_dirty_entries = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) @@ -501,7 +520,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag, hbool_t match_global) +H5C_evict_tagged_entries(H5F_t * f, haddr_t tag, hbool_t match_global) { H5C_t *cache; /* Pointer to cache structure */ H5C_tag_iter_evict_ctx_t ctx; /* Context for iterator callback */ @@ -519,7 +538,6 @@ H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag, hbool_t match_gl /* Construct context for iterator callbacks */ ctx.f = f; - ctx.dxpl_id = dxpl_id; /* Start evicting entries */ do { @@ -535,29 +553,29 @@ H5C_evict_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag, hbool_t match_gl /* Keep doing this until we have stopped evicted entries */ } while(TRUE == ctx.evicted_entries_last_pass); - /* In most cases, fail if we have finished evicting entries and pinned - * entries still need evicted + /* In most cases, fail if we have finished evicting entries and pinned + * entries still need evicted * - * However, things can get strange if the file was opened R/O and - * the file contains a cache image and the cache image contains dirty - * entries. + * However, things can get strange if the file was opened R/O and + * the file contains a cache image and the cache image contains dirty + * entries. * - * Since the file was opened read only, dirty entries in the cache + * Since the file was opened read only, dirty entries in the cache * image were marked as clean when they were inserted into the metadata * cache. This is necessary, as if they are marked dirty, the metadata - * cache will attempt to write them on file close, which is frowned + * cache will attempt to write them on file close, which is frowned * upon when the file is opened R/O. * - * On the other hand, such entries (marked prefetched_dirty) must not + * On the other hand, such entries (marked prefetched_dirty) must not * be evicted, as should the cache be asked to re-load them, the cache * will attempt to read them from the file, and at best load an outdated * version. - * - * To avoid this, H5C__evict_tagged_entries_cb has been modified to - * skip such entries. However, by doing so, it may prevent pinned + * + * To avoid this, H5C__evict_tagged_entries_cb has been modified to + * skip such entries. However, by doing so, it may prevent pinned * entries from becoming unpinned. * - * Thus we must ignore ctx.pinned_entries_need_evicted if + * Thus we must ignore ctx.pinned_entries_need_evicted if * ctx.skipped_pf_dirty_entries is TRUE. */ if((!ctx.skipped_pf_dirty_entries) && (ctx.pinned_entries_need_evicted)) @@ -613,7 +631,7 @@ H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) * *------------------------------------------------------------------------- */ -static herr_t +static herr_t H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) { herr_t ret_value = SUCCEED; /* Return value */ @@ -680,16 +698,16 @@ H5C_verify_tag(int id, haddr_t tag) if(tag == H5AC__SUPERBLOCK_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__SUPERBLOCK_TAG applied to non-superblock entry") } /* end else */ - + /* Free Space Manager */ if(tag == H5AC__FREESPACE_TAG && ((id != H5AC_FSPACE_HDR_ID) && (id != H5AC_FSPACE_SINFO_ID))) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry") - + /* SOHM */ if((id == H5AC_SOHM_TABLE_ID) || (id == H5AC_SOHM_LIST_ID)) if(tag != H5AC__SOHM_TAG) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "sohm entry not tagged with H5AC__SOHM_TAG") - + /* Global Heap */ if(id == H5AC_GHEAP_ID) { if(tag != H5AC__GLOBALHEAP_TAG) @@ -721,7 +739,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_flush_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag) +H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) { /* Variable Declarations */ H5C_t *cache_ptr = NULL; @@ -741,7 +759,7 @@ H5C_flush_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't mark tagged entries") /* Flush all marked entries */ - if(H5C__flush_marked_entries(f, dxpl_id) < 0) + if(H5C__flush_marked_entries(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush marked entries") done: @@ -765,7 +783,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) +H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) { H5C_tag_info_t *tag_info; /* Points to a tag info struct */ herr_t ret_value = SUCCEED; /* Return value */ @@ -820,7 +838,7 @@ H5C__expunge_tag_type_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) /* Found one with the same tag and type id */ if(entry->type->id == ctx->type_id) - if(H5C_expunge_entry(ctx->f, ctx->dxpl_id, entry->type, entry->addr, ctx->flags) < 0) + if(H5C_expunge_entry(ctx->f, entry->type, entry->addr, ctx->flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, H5_ITER_ERROR, "can't expunge entry") done: @@ -842,9 +860,8 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5C_expunge_tag_type_metadata(H5F_t *f, hid_t dxpl_id, haddr_t tag, int type_id, - unsigned flags) +herr_t +H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags) { H5C_t *cache; /* Pointer to cache structure */ H5C_tag_iter_ettm_ctx_t ctx; /* Context for iterator callback */ @@ -862,7 +879,6 @@ H5C_expunge_tag_type_metadata(H5F_t *f, hid_t dxpl_id, haddr_t tag, int type_id, /* Construct context for iterator callbacks */ ctx.f = f; - ctx.dxpl_id = dxpl_id; ctx.type_id = type_id; ctx.flags = flags; @@ -888,7 +904,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +herr_t H5C_get_tag(const void *thing, haddr_t *tag /*OUT*/) { const H5C_cache_entry_t *entry = (const H5C_cache_entry_t *)thing; /* Pointer to cache entry */ |