From d124a1fe47c03d850ccbb1a93b3c8f2262ecc918 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 6 Jun 2016 01:41:16 -0500 Subject: [svn-r30035] Description: Extract tagging routines into separate source module. Tested on: MacOSX/64 10.11.5 (amazon) w/serial & parallel (h5committest forthcoming) --- MANIFEST | 1 + src/CMakeLists.txt | 1 + src/H5C.c | 419 +--------------------------------------------- src/H5Cpkg.h | 9 + src/H5Ctag.c | 484 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 2 +- 6 files changed, 498 insertions(+), 418 deletions(-) create mode 100644 src/H5Ctag.c diff --git a/MANIFEST b/MANIFEST index 6b334b2..19a6d47 100644 --- a/MANIFEST +++ b/MANIFEST @@ -495,6 +495,7 @@ ./src/H5Cprivate.h ./src/H5Cpublic.h ./src/H5Cquery.c +./src/H5Ctag.c ./src/H5CS.c ./src/H5CSprivate.h ./src/H5D.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7f56e1..c7ae908 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,6 +86,7 @@ set (H5C_SOURCES ${HDF5_SRC_DIR}/H5Cepoch.c ${HDF5_SRC_DIR}/H5Cmpio.c ${HDF5_SRC_DIR}/H5Cquery.c + ${HDF5_SRC_DIR}/H5Ctag.c ) set (H5C_HDRS ${HDF5_SRC_DIR}/H5Cpkg.h diff --git a/src/H5C.c b/src/H5C.c index fa0f573..dbaee36 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -166,14 +166,6 @@ static herr_t H5C_make_space_in_cache(H5F_t * f, size_t space_needed, hbool_t write_permitted); -static herr_t H5C__tag_entry(H5C_t * cache_ptr, - H5C_cache_entry_t * entry_ptr, - hid_t dxpl_id); - -static herr_t H5C__mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag); - -static herr_t H5C__flush_marked_entries(H5F_t * f, hid_t dxpl_id); - static herr_t H5C__generate_image(const H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr, hid_t dxpl_id, int64_t *entry_size_change_ptr); @@ -8953,191 +8945,6 @@ done: /*------------------------------------------------------------------------- * - * Function: H5C_ignore_tags - * - * Purpose: Override all assertion frameworks associated with making - * 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 - * 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 - * use this function if they don't plan on setting up proper - * metadata tags. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Mike McGreevy - * December 1, 2009 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_ignore_tags(H5C_t * cache_ptr) -{ - FUNC_ENTER_NOAPI_NOERR - - /* Assertions */ - HDassert(cache_ptr != NULL); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* Set variable to ignore tag values upon assignment */ - cache_ptr->ignore_tags = TRUE; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5C_ignore_tags */ - - -/*------------------------------------------------------------------------- - * - * Function: H5C_get_ignore_tags - * - * Purpose: Retrieve the 'ignore_tags' field for the cache - * - * Return: 'ignore_tags' value (can't fail) - * - * Programmer: Quincey Koziol - * April 30, 2016 - * - *------------------------------------------------------------------------- - */ -hbool_t -H5C_get_ignore_tags(const H5C_t *cache_ptr) -{ - FUNC_ENTER_NOAPI_NOERR - - /* Sanity checks */ - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* Return ignore tag value */ - FUNC_LEAVE_NOAPI(cache_ptr->ignore_tags) -} /* H5C_get_ignore_tags */ - - -/*------------------------------------------------------------------------- - * - * 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 - * data access property list id before application. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Mike McGreevy - * January 14, 2010 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__tag_entry(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr, hid_t dxpl_id) -{ - H5P_genplist_t *dxpl; /* dataset transfer property list */ - H5C_tag_t tag; /* Tag structure */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Assertions */ - HDassert(cache_ptr != NULL); - HDassert(entry_ptr != NULL); - HDassert(cache_ptr->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, "H5C_tag", &tag)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value") - - if(cache_ptr->ignore_tags != TRUE) { -#if H5C_DO_TAGGING_SANITY_CHECKS - /* Perform some sanity checks to ensure that a correct tag is being applied */ - if(H5C_verify_tag(entry_ptr->type->id, tag.value, tag.globality) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "tag verification failed") -#endif - } else { - /* 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, - 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. - If the tag value is set, then we'll just let it get assigned without - additional checking for correctness. */ - if(!tag.value) { - tag.value = H5AC__IGNORE_TAG; - tag.globality = H5C_GLOBALITY_NONE; - } /* end if */ - } /* end if */ - - /* Apply the tag to the entry */ - entry_ptr->tag = tag.value; - - /* Apply the tag globality to the entry */ - entry_ptr->globality = tag.globality; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__tag_entry */ - - - -/*------------------------------------------------------------------------- - * - * Function: H5C__mark_tagged_entries - * - * Purpose: Set the flush marker on dirty entries in the cache that have - * the specified tag, as well as all globally tagged entries. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Mike McGreevy - * September 9, 2010 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) -{ - unsigned u; /* Local index variable */ - - FUNC_ENTER_STATIC_NOERR - - /* Sanity check */ - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - /* Iterate through hash table entries, marking those with specified tag, as - * well as any major global entries which should always be flushed - * when flushing based on tag value */ - for(u = 0; u < H5C__HASH_TABLE_LEN; u++) { - H5C_cache_entry_t *entry_ptr; /* Entry pointer */ - - entry_ptr = cache_ptr->index[u]; - while(entry_ptr != NULL) { - if((entry_ptr->tag == tag) || (entry_ptr->globality == H5C_GLOBALITY_MAJOR)) { - /* We only want to set the flush marker on entries that - * actually need flushed (i.e., dirty ones) */ - if(entry_ptr->is_dirty) - entry_ptr->flush_marker = TRUE; - } /* end if */ - - entry_ptr = entry_ptr->ht_next; - } /* end while */ - } /* end for */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5C__mark_tagged_entries */ - - -/*------------------------------------------------------------------------- - * * Function: H5C__flush_marked_entries * * Purpose: Flushes all marked entries in the cache. @@ -9149,12 +8956,12 @@ H5C__mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5C__flush_marked_entries(H5F_t * f, hid_t dxpl_id) { herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Assertions */ HDassert(f != NULL); @@ -9167,228 +8974,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__flush_marked_entries */ -#if H5C_DO_TAGGING_SANITY_CHECKS - -/*------------------------------------------------------------------------- - * - * Function: H5C_verify_tag - * - * Purpose: Performs sanity checking on an entrytype/tag pair. - * - * Return: SUCCEED or FAIL. - * - * Programmer: Mike McGreevy - * January 14, 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_verify_tag(int id, haddr_t tag, H5C_tag_globality_t globality) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Perform some sanity checks on tag value. Certain entry - * types require certain tag values, so check that these - * constraints are met. */ - if(tag == H5AC__IGNORE_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "cannot ignore a tag while doing verification.") - else if(tag == H5AC__INVALID_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "no metadata tag provided") - else { - /* Perform some sanity checks on tag value. Certain entry - * types require certain tag values, so check that these - * constraints are met. */ - - /* Superblock */ - if((id == H5AC_SUPERBLOCK_ID) || (id == H5AC_DRVRINFO_ID)) { - if(tag != H5AC__SUPERBLOCK_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock not tagged with H5AC__SUPERBLOCK_TAG") - if(globality != H5C_GLOBALITY_MAJOR) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock/driver-info globality not marked with H5C_GLOBALITY_MAJOR") - } /* end if */ - else { - 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((id == H5AC_FSPACE_HDR_ID) || (id == H5AC_FSPACE_SINFO_ID)) { - if(tag != H5AC__FREESPACE_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "freespace entry not tagged with H5AC__FREESPACE_TAG") - if(globality != H5C_GLOBALITY_MINOR) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "freespace entry globality not marked with H5C_GLOBALITY_MINOR") - } /* end if */ - else { - if(tag == H5AC__FREESPACE_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry") - } /* end else */ - - /* 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") - if(globality != H5C_GLOBALITY_MAJOR) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "sohm entry globality not marked with H5C_GLOBALITY_MAJOR") - } /* end if */ - - /* Global Heap */ - if(id == H5AC_GHEAP_ID) { - if(tag != H5AC__GLOBALHEAP_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap not tagged with H5AC__GLOBALHEAP_TAG") - if(globality != H5C_GLOBALITY_MAJOR) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap entry globality not marked with H5C_GLOBALITY_MAJOR") - } /* end if */ - else { - if(tag == H5AC__GLOBALHEAP_TAG) - HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__GLOBALHEAP_TAG applied to non-globalheap entry") - } /* end else */ - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_verify_tag */ -#endif - - -/*------------------------------------------------------------------------- - * - * Function: H5C_flush_tagged_entries - * - * Purpose: Flushes all entries with the specified tag to disk. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Mike McGreevy - * August 19, 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_flush_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag) -{ - /* Variable Declarations */ - H5C_t *cache_ptr = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Assertions */ - HDassert(f); - HDassert(f->shared); - - /* Get cache pointer */ - cache_ptr = f->shared->cache; - - /* Mark all entries with specified tag */ - if(H5C__mark_tagged_entries(cache_ptr, tag) < 0) - 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) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush marked entries") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_flush_tagged_entries */ - - -/*------------------------------------------------------------------------- - * - * Function: H5C_retag_entries - * - * Purpose: Searches through cache index for all entries with the - * value specified by src_tag and changes it to the value - * specified by dest_tag. - * - * Return: SUCCEED or FAIL. - * - * Programmer: Mike McGreevy - * March 17, 2010 - * - *------------------------------------------------------------------------- - */ -void -H5C_retag_entries(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag) -{ - unsigned u; /* Local index variable */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity check */ - HDassert(cache_ptr); - - /* Iterate through entries, retagging those with the src_tag tag */ - for(u = 0; u < H5C__HASH_TABLE_LEN; u++) { - H5C_cache_entry_t *entry_ptr; /* entry pointer */ - - entry_ptr = cache_ptr->index[u]; - while(entry_ptr) { - if(entry_ptr->tag == src_tag) - entry_ptr->tag = dest_tag; - entry_ptr = entry_ptr->ht_next; - } /* end while */ - } /* end for */ - - FUNC_LEAVE_NOAPI_VOID -} /* H5C_retag_entries */ - - -/*------------------------------------------------------------------------- - * - * Function: H5C_expunge_tag_type_metadata - * - * Purpose: Search and expunge from the cache entries associated - * with 'tag' and type id. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - * Programmer: Vailin Choi; May 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_expunge_tag_type_metadata(H5F_t *f, hid_t dxpl_id, haddr_t tag, int type_id, unsigned flags) -{ - unsigned u; /* Local index variable */ - H5C_t *cache_ptr = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(f); - HDassert(f->shared); - HDassert(f->shared->cache); - HDassert(f->shared->cache->magic == H5C__H5C_T_MAGIC); - - /* Get cache pointer */ - cache_ptr = f->shared->cache; - - /* Iterate through hash table entries, expunge those with specified tag and type id */ - for(u = 0; u < H5C__HASH_TABLE_LEN; u++) { - H5C_cache_entry_t *entry_ptr; /* Entry pointer */ - - entry_ptr = cache_ptr->index[u]; - while(entry_ptr != NULL) { - H5C_cache_entry_t *next_entry_ptr = entry_ptr->ht_next; - - /* Found one with the same tag and type id */ - if(entry_ptr->tag == tag && entry_ptr->type->id == type_id) { - - if(H5C_expunge_entry(f, dxpl_id, entry_ptr->type, entry_ptr->addr, flags) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_expunge_entry() failed.") - } /* end if */ - - entry_ptr = next_entry_ptr; - } /* end while */ - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_expunge_tag_type_metadata */ - /*------------------------------------------------------------------------- * Function: H5C__generate_image diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 5fb0ab3..d7da17b 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4272,8 +4272,17 @@ H5_DLLVAR const H5C_class_t H5C__epoch_marker_class; /******************************/ /* Package Private Prototypes */ /******************************/ + +/* General routines */ H5_DLL herr_t H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr, unsigned flags, int64_t *entry_size_change_ptr, H5SL_t *collective_write_list); +H5_DLL herr_t H5C__flush_marked_entries(H5F_t * f, hid_t dxpl_id); + +/* Routines for operating on entry tags */ +H5_DLL herr_t H5C__tag_entry(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr, + hid_t dxpl_id); +H5_DLL herr_t H5C__mark_tagged_entries_cork(H5C_t *cache_ptr, haddr_t obj_addr, + hbool_t val); #endif /* _H5Cpkg_H */ diff --git a/src/H5Ctag.c b/src/H5Ctag.c new file mode 100644 index 0000000..5a5b197 --- /dev/null +++ b/src/H5Ctag.c @@ -0,0 +1,484 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Ctag.c + * June 5 2016 + * Quincey Koziol + * + * Purpose: Functions in this file operate on tags for metadata + * cache entries. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5C__mark_tagged_entries(H5C_t *cache_ptr, haddr_t tag); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * + * Function: H5C_ignore_tags + * + * Purpose: Override all assertion frameworks associated with making + * 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 + * 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 + * use this function if they don't plan on setting up proper + * metadata tags. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + * Programmer: Mike McGreevy + * December 1, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_ignore_tags(H5C_t * cache_ptr) +{ + FUNC_ENTER_NOAPI_NOERR + + /* Assertions */ + HDassert(cache_ptr != NULL); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + + /* Set variable to ignore tag values upon assignment */ + cache_ptr->ignore_tags = TRUE; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5C_ignore_tags */ + + +/*------------------------------------------------------------------------- + * + * Function: H5C_get_ignore_tags + * + * Purpose: Retrieve the 'ignore_tags' field for the cache + * + * Return: 'ignore_tags' value (can't fail) + * + * Programmer: Quincey Koziol + * April 30, 2016 + * + *------------------------------------------------------------------------- + */ +hbool_t +H5C_get_ignore_tags(const H5C_t *cache_ptr) +{ + FUNC_ENTER_NOAPI_NOERR + + /* Sanity checks */ + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + + /* Return ignore tag value */ + FUNC_LEAVE_NOAPI(cache_ptr->ignore_tags) +} /* H5C_get_ignore_tags */ + + +/*------------------------------------------------------------------------- + * + * 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 + * data access property list id before application. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + * Programmer: Mike McGreevy + * January 14, 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5C__tag_entry(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr, hid_t dxpl_id) +{ + H5P_genplist_t *dxpl; /* dataset transfer property list */ + H5C_tag_t tag; /* Tag structure */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Assertions */ + HDassert(cache_ptr != NULL); + HDassert(entry_ptr != NULL); + HDassert(cache_ptr->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, "H5C_tag", &tag)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value") + + if(cache_ptr->ignore_tags != TRUE) { +#if H5C_DO_TAGGING_SANITY_CHECKS + /* Perform some sanity checks to ensure that a correct tag is being applied */ + if(H5C_verify_tag(entry_ptr->type->id, tag.value, tag.globality) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "tag verification failed") +#endif + } else { + /* 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, + 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. + If the tag value is set, then we'll just let it get assigned without + additional checking for correctness. */ + if(!tag.value) { + tag.value = H5AC__IGNORE_TAG; + tag.globality = H5C_GLOBALITY_NONE; + } /* end if */ + } /* end if */ + + /* Apply the tag to the entry */ + entry_ptr->tag = tag.value; + + /* Apply the tag globality to the entry */ + entry_ptr->globality = tag.globality; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__tag_entry */ + + +/*------------------------------------------------------------------------- + * + * Function: H5C__mark_tagged_entries + * + * Purpose: Set the flush marker on dirty entries in the cache that have + * the specified tag, as well as all globally tagged entries. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + * Programmer: Mike McGreevy + * September 9, 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) +{ + unsigned u; /* Local index variable */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(cache_ptr); + HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); + + /* Iterate through hash table entries, marking those with specified tag, as + * well as any major global entries which should always be flushed + * when flushing based on tag value */ + for(u = 0; u < H5C__HASH_TABLE_LEN; u++) { + H5C_cache_entry_t *entry_ptr; /* Entry pointer */ + + entry_ptr = cache_ptr->index[u]; + while(entry_ptr != NULL) { + if((entry_ptr->tag == tag) || (entry_ptr->globality == H5C_GLOBALITY_MAJOR)) { + /* We only want to set the flush marker on entries that + * actually need flushed (i.e., dirty ones) */ + if(entry_ptr->is_dirty) + entry_ptr->flush_marker = TRUE; + } /* end if */ + + entry_ptr = entry_ptr->ht_next; + } /* end while */ + } /* end for */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5C__mark_tagged_entries */ + +#if H5C_DO_TAGGING_SANITY_CHECKS + +/*------------------------------------------------------------------------- + * + * Function: H5C_verify_tag + * + * Purpose: Performs sanity checking on an entrytype/tag pair. + * + * Return: SUCCEED or FAIL. + * + * Programmer: Mike McGreevy + * January 14, 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_verify_tag(int id, haddr_t tag, H5C_tag_globality_t globality) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* Perform some sanity checks on tag value. Certain entry + * types require certain tag values, so check that these + * constraints are met. */ + if(tag == H5AC__IGNORE_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "cannot ignore a tag while doing verification.") + else if(tag == H5AC__INVALID_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "no metadata tag provided") + else { + /* Perform some sanity checks on tag value. Certain entry + * types require certain tag values, so check that these + * constraints are met. */ + + /* Superblock */ + if((id == H5AC_SUPERBLOCK_ID) || (id == H5AC_DRVRINFO_ID)) { + if(tag != H5AC__SUPERBLOCK_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock not tagged with H5AC__SUPERBLOCK_TAG") + if(globality != H5C_GLOBALITY_MAJOR) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock/driver-info globality not marked with H5C_GLOBALITY_MAJOR") + } /* end if */ + else { + 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((id == H5AC_FSPACE_HDR_ID) || (id == H5AC_FSPACE_SINFO_ID)) { + if(tag != H5AC__FREESPACE_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "freespace entry not tagged with H5AC__FREESPACE_TAG") + if(globality != H5C_GLOBALITY_MINOR) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "freespace entry globality not marked with H5C_GLOBALITY_MINOR") + } /* end if */ + else { + if(tag == H5AC__FREESPACE_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry") + } /* end else */ + + /* 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") + if(globality != H5C_GLOBALITY_MAJOR) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "sohm entry globality not marked with H5C_GLOBALITY_MAJOR") + } /* end if */ + + /* Global Heap */ + if(id == H5AC_GHEAP_ID) { + if(tag != H5AC__GLOBALHEAP_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap not tagged with H5AC__GLOBALHEAP_TAG") + if(globality != H5C_GLOBALITY_MAJOR) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap entry globality not marked with H5C_GLOBALITY_MAJOR") + } /* end if */ + else { + if(tag == H5AC__GLOBALHEAP_TAG) + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__GLOBALHEAP_TAG applied to non-globalheap entry") + } /* end else */ + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_verify_tag */ +#endif + + +/*------------------------------------------------------------------------- + * + * Function: H5C_flush_tagged_entries + * + * Purpose: Flushes all entries with the specified tag to disk. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + * Programmer: Mike McGreevy + * August 19, 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_flush_tagged_entries(H5F_t * f, hid_t dxpl_id, haddr_t tag) +{ + /* Variable Declarations */ + H5C_t *cache_ptr = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Assertions */ + HDassert(f); + HDassert(f->shared); + + /* Get cache pointer */ + cache_ptr = f->shared->cache; + + /* Mark all entries with specified tag */ + if(H5C__mark_tagged_entries(cache_ptr, tag) < 0) + 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) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush marked entries") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_flush_tagged_entries */ + + +/*------------------------------------------------------------------------- + * + * Function: H5C_retag_entries + * + * Purpose: Searches through cache index for all entries with the + * value specified by src_tag and changes it to the value + * specified by dest_tag. + * + * Return: SUCCEED or FAIL. + * + * Programmer: Mike McGreevy + * March 17, 2010 + * + *------------------------------------------------------------------------- + */ +void +H5C_retag_entries(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag) +{ + unsigned u; /* Local index variable */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(cache_ptr); + + /* Iterate through entries, retagging those with the src_tag tag */ + for(u = 0; u < H5C__HASH_TABLE_LEN; u++) { + H5C_cache_entry_t *entry_ptr; /* entry pointer */ + + entry_ptr = cache_ptr->index[u]; + while(entry_ptr) { + if(entry_ptr->tag == src_tag) + entry_ptr->tag = dest_tag; + entry_ptr = entry_ptr->ht_next; + } /* end while */ + } /* end for */ + + FUNC_LEAVE_NOAPI_VOID +} /* H5C_retag_entries */ + + +/*------------------------------------------------------------------------- + * + * Function: H5C_expunge_tag_type_metadata + * + * Purpose: Search and expunge from the cache entries associated + * with 'tag' and type id. + * + * Return: FAIL if error is detected, SUCCEED otherwise. + * + * Programmer: Vailin Choi; May 2016 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_expunge_tag_type_metadata(H5F_t *f, hid_t dxpl_id, haddr_t tag, int type_id, unsigned flags) +{ + unsigned u; /* Local index variable */ + H5C_t *cache_ptr = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + HDassert(f->shared->cache->magic == H5C__H5C_T_MAGIC); + + /* Get cache pointer */ + cache_ptr = f->shared->cache; + + /* Iterate through hash table entries, expunge those with specified tag and type id */ + for(u = 0; u < H5C__HASH_TABLE_LEN; u++) { + H5C_cache_entry_t *entry_ptr; /* Entry pointer */ + + entry_ptr = cache_ptr->index[u]; + while(entry_ptr != NULL) { + H5C_cache_entry_t *next_entry_ptr = entry_ptr->ht_next; + + /* Found one with the same tag and type id */ + if(entry_ptr->tag == tag && entry_ptr->type->id == type_id) { + + if(H5C_expunge_entry(f, dxpl_id, entry_ptr->type, entry_ptr->addr, flags) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_expunge_entry() failed.") + } /* end if */ + + entry_ptr = next_entry_ptr; + } /* end while */ + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_expunge_tag_type_metadata */ + diff --git a/src/Makefile.am b/src/Makefile.am index 5d961c4..1f3f00e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -45,7 +45,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5AC.c \ H5B.c H5Bcache.c H5Bdbg.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2hdr.c H5B2int.c H5B2stat.c H5B2test.c \ - H5C.c H5Cepoch.c H5Cquery.c \ + H5C.c H5Cepoch.c H5Cquery.c H5Ctag.c \ H5CS.c \ H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \ H5Ddeprec.c H5Dearray.c H5Defl.c H5Dfarray.c H5Dfill.c H5Dint.c \ -- cgit v0.12