summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McGreevy <mamcgree@hdfgroup.org>2010-11-11 21:10:30 (GMT)
committerMike McGreevy <mamcgree@hdfgroup.org>2010-11-11 21:10:30 (GMT)
commit1b8033b5946e43613c98f40fb23282bdc4b49d0a (patch)
tree94fa65f7e96e6e2b5c982a680f729de0c75f9f30
parenta32d6d79a3f1e30401aa7077949ff4c38e967587 (diff)
downloadhdf5-1b8033b5946e43613c98f40fb23282bdc4b49d0a.zip
hdf5-1b8033b5946e43613c98f40fb23282bdc4b49d0a.tar.gz
hdf5-1b8033b5946e43613c98f40fb23282bdc4b49d0a.tar.bz2
[svn-r19765] Purpose:
fix a few minor issues related to flush/refresh code Description: - Replaced the globality macros with an enum typedef, to better encapsulate of the values that can be assigned to the variable. - Combined 'tag' and 'globality' properties into a single property by creating a new structure housing both values, since they are always accessed at the same time anyways. - Added an extra parameter check to H5Tflush/H5Trefresh routines to make sure the supplied datatype is a committed datatype. - Renamed and reworked some code to move "metadata" (H5AC) specific things out of the generic cache (H5C) level of code. Tested: h5committest
-rw-r--r--src/H5AC.c60
-rw-r--r--src/H5ACprivate.h5
-rw-r--r--src/H5C.c34
-rw-r--r--src/H5Cprivate.h28
-rw-r--r--src/H5Pdxpl.c11
-rw-r--r--src/H5T.c4
6 files changed, 64 insertions, 78 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index e0813be..6d865e4 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -5240,8 +5240,8 @@ herr_t
H5AC_tag(hid_t dxpl_id, haddr_t metadata_tag, haddr_t * prev_tag)
{
/* Variable Declarations */
+ H5C_tag_t tag; /* tag structure */
H5P_genplist_t *dxpl = NULL; /* dataset transfer property list */
- int globality = 0; /* global tag value */
herr_t ret_value = SUCCEED; /* return value */
/* Function Enter Macro */
@@ -5253,31 +5253,31 @@ H5AC_tag(hid_t dxpl_id, haddr_t metadata_tag, haddr_t * prev_tag)
/* Get the current tag value and return that (if prev_tag is NOT null)*/
if(prev_tag) {
- if((H5P_get(dxpl, "H5AC_metadata_tag", prev_tag)) < 0)
+ if((H5P_get(dxpl, "H5C_tag", &tag)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query dxpl")
+ *prev_tag = tag.value;
} /* end if */
- /* Set the provided tag value in the dxpl_id. */
- if(H5P_set(dxpl, "H5AC_metadata_tag", &metadata_tag) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set property in dxpl")
-
+ /* Add metadata_tag to tag structure */
+ tag.value = metadata_tag;
+
/* Determine globality of tag */
switch(metadata_tag) {
case H5AC__SUPERBLOCK_TAG:
case H5AC__SOHM_TAG:
case H5AC__GLOBALHEAP_TAG:
- globality = H5C_GLOBALITY_MAJOR;
+ tag.globality = H5C_GLOBALITY_MAJOR;
break;
case H5AC__FREESPACE_TAG:
- globality = H5C_GLOBALITY_MINOR;
+ tag.globality = H5C_GLOBALITY_MINOR;
break;
default:
- globality = H5C_GLOBALITY_NONE;
+ tag.globality = H5C_GLOBALITY_NONE;
break;
} /* end switch */
- /* Set globality in dxpl */
- if(H5P_set(dxpl, "H5C_tag_globality", &globality) < 0)
+ /* Set the provided tag in the dxpl_id. */
+ if(H5P_set(dxpl, "H5C_tag", &tag) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set property in dxpl")
done:
@@ -5312,7 +5312,7 @@ H5AC_retag_copied_metadata(H5F_t * f, haddr_t metadata_tag)
HDassert(f->shared);
/* Call cache-level function to re-tag entries with the COPIED tag */
- H5C_retag_metadata(f->shared->cache, H5AC__COPIED_TAG, metadata_tag);
+ H5C_retag_entries(f->shared->cache, H5AC__COPIED_TAG, metadata_tag);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -5337,7 +5337,6 @@ H5AC_flush_tagged_metadata(H5F_t * f, haddr_t metadata_tag, hid_t dxpl_id)
{
/* Variable Declarations */
herr_t ret_value = SUCCEED;
- herr_t result;
/* Function Enter Macro */
FUNC_ENTER_NOAPI(H5AC_flush_tagged_metadata, FAIL)
@@ -5410,8 +5409,7 @@ done:
static herr_t
H5AC_verify_tag(hid_t dxpl_id, H5AC_class_t * type)
{
- haddr_t tag = HADDR_UNDEF;
- int globality = -1;
+ H5C_tag_t tag;
H5P_genplist_t * dxpl;
herr_t ret_value = SUCCEED;
@@ -5422,19 +5420,15 @@ H5AC_verify_tag(hid_t dxpl_id, H5AC_class_t * type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
/* Get the tag from the DXPL */
- if( (H5P_get(dxpl, "H5AC_metadata_tag", &tag)) < 0 )
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value");
-
- /* Get the tag globality from the DXPL */
- if( (H5P_get(dxpl, "H5C_tag_globality", &globality)) < 0 )
+ if( (H5P_get(dxpl, "H5C_tag", &tag)) < 0 )
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value");
/* 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)
+ if(tag.value == H5AC__IGNORE_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "cannot ignore a tag while doing verification.")
- else if(tag == H5AC__INVALID_TAG)
+ else if(tag.value == H5AC__INVALID_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "no metadata tag provided")
else {
@@ -5444,45 +5438,45 @@ H5AC_verify_tag(hid_t dxpl_id, H5AC_class_t * type)
/* Superblock */
if(type->id == H5AC_SUPERBLOCK_ID) {
- if(tag != H5AC__SUPERBLOCK_TAG)
+ if(tag.value != H5AC__SUPERBLOCK_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock not tagged with H5AC__SUPERBLOCK_TAG")
- if(globality != H5C_GLOBALITY_MAJOR)
+ if(tag.globality != H5C_GLOBALITY_MAJOR)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "superblock globality not marked with H5C_GLOBALITY_MAJOR")
}
else {
- if(tag == H5AC__SUPERBLOCK_TAG)
+ if(tag.value == H5AC__SUPERBLOCK_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__SUPERBLOCK_TAG applied to non-superblock entry")
}
/* Free Space Manager */
if((type->id == H5AC_FSPACE_HDR_ID) || (type->id == H5AC_FSPACE_SINFO_ID)) {
- if(tag != H5AC__FREESPACE_TAG)
+ if(tag.value != H5AC__FREESPACE_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "freespace entry not tagged with H5AC__FREESPACE_TAG")
- if(globality != H5C_GLOBALITY_MINOR)
+ if(tag.globality != H5C_GLOBALITY_MINOR)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "freespace entry globality not marked with H5C_GLOBALITY_MINOR")
}
else {
- if(tag == H5AC__FREESPACE_TAG)
+ if(tag.value == H5AC__FREESPACE_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__FREESPACE_TAG applied to non-freespace entry")
}
/* SOHM */
if((type->id == H5AC_SOHM_TABLE_ID) || (type->id == H5AC_SOHM_LIST_ID)) {
- if(tag != H5AC__SOHM_TAG)
+ if(tag.value != H5AC__SOHM_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "sohm entry not tagged with H5AC__SOHM_TAG")
- if(globality != H5C_GLOBALITY_MAJOR)
+ if(tag.globality != H5C_GLOBALITY_MAJOR)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "sohm entry globality not marked with H5C_GLOBALITY_MAJOR")
}
/* Global Heap */
if(type->id == H5AC_GHEAP_ID) {
- if(tag != H5AC__GLOBALHEAP_TAG)
+ if(tag.value != H5AC__GLOBALHEAP_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap not tagged with H5AC__GLOBALHEAP_TAG")
- if(globality != H5C_GLOBALITY_MAJOR)
+ if(tag.globality != H5C_GLOBALITY_MAJOR)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "global heap entry globality not marked with H5C_GLOBALITY_MAJOR")
}
else {
- if(tag == H5AC__GLOBALHEAP_TAG)
+ if(tag.value == H5AC__GLOBALHEAP_TAG)
HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "H5AC__GLOBALHEAP_TAG applied to non-globalheap entry")
}
} /* end else */
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 2c1e383..2987c16 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -213,11 +213,6 @@ typedef H5C_t H5AC_t;
#define H5AC_LIBRARY_INTERNAL_DEF 0
#endif /* H5_HAVE_PARALLEL */
-/* Definitiions for "metadata tag" property */
-#define H5AC_METADATA_TAG_NAME "H5AC_metadata_tag"
-#define H5AC_METADATA_TAG_SIZE sizeof(haddr_t)
-#define H5AC_METADATA_TAG_DEF H5AC__INVALID_TAG
-
/* Dataset transfer property list for flush calls */
/* (Collective set, "block before metadata write" set and "library internal" set) */
/* (Global variable declaration, definition is in H5AC.c) */
diff --git a/src/H5C.c b/src/H5C.c
index 2ff26e6..ebc3272 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -2592,7 +2592,7 @@ H5C_insert_entry(H5F_t * f,
/* 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")
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag entry")
entry_ptr->is_protected = FALSE;
entry_ptr->is_read_only = FALSE;
@@ -3609,9 +3609,6 @@ H5C_protect(H5F_t * f,
size_t empty_space;
void * thing;
H5C_cache_entry_t * entry_ptr;
- haddr_t tag = HADDR_UNDEF;
- int globality = -1;
- H5P_genplist_t *dxpl; /* dataset transfer property list */
void * ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5C_protect, NULL)
@@ -3672,7 +3669,7 @@ H5C_protect(H5F_t * f,
/* Apply tag to newly protected entry */
if(H5C_tag_entry(cache_ptr, entry_ptr, primary_dxpl_id) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Cannot tag metadata entry")
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Cannot tag entry")
/* If the entry is very large, and we are configured to allow it,
* we may wish to perform a flash cache size increase.
@@ -9081,7 +9078,7 @@ done:
* Function: H5C_ignore_tags
*
* Purpose: Override all assertion frameworks associated with making
- * sure proper tags are applied to metadata.
+ * 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
@@ -9089,7 +9086,7 @@ done:
* 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.
+ * tags.
*
* Return: FAIL if error is detected, SUCCEED otherwise.
*
@@ -9136,8 +9133,7 @@ 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 */
- haddr_t tag; /* Tag address */
- int globality; /* Tag globality */
+ H5C_tag_t tag; /* Tag structure */
hid_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5C_tag_entry, FAIL)
@@ -9152,18 +9148,14 @@ H5C_tag_entry(H5C_t * cache_ptr, H5C_cache_entry_t * entry_ptr, hid_t dxpl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
/* Get the tag from the DXPL */
- if((H5P_get(dxpl, "H5AC_metadata_tag", &tag)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value")
-
- /* Get globality from the DXPL */
- if((H5P_get(dxpl, "H5C_tag_globality", &globality)) < 0)
+ if((H5P_get(dxpl, "H5C_tag", &tag)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value")
/* Apply the tag to the entry */
- entry_ptr->tag = tag;
+ entry_ptr->tag = tag.value;
/* Apply the tag globality to the entry */
- entry_ptr->globality = globality;
+ entry_ptr->globality = tag.globality;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -9284,9 +9276,7 @@ H5C_mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag, hbool_t mark_clean)
{
/* Variable Declarations */
int u; /* Iterator */
- herr_t result; /* Result */
H5C_cache_entry_t *entry_ptr = NULL; /* entry pointer */
- herr_t ret_value = SUCCEED; /* Return Value */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5C_mark_tagged_entries)
@@ -9472,7 +9462,7 @@ done:
/*-------------------------------------------------------------------------
*
- * Function: H5C_retag_metadata
+ * 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
@@ -9486,12 +9476,12 @@ done:
*-------------------------------------------------------------------------
*/
void
-H5C_retag_metadata(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag)
+H5C_retag_entries(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag)
{
unsigned u; /* Local index variable */
H5C_cache_entry_t *entry_ptr = NULL; /* entry pointer */
- FUNC_ENTER_NOAPI_NOFUNC(H5C_retag_metadata)
+ FUNC_ENTER_NOAPI_NOFUNC(H5C_retag_entries)
/* Iterate through entries, retagging those with the src_tag tag */
for(u = 0; u < H5C__HASH_TABLE_LEN; u++) {
@@ -9507,5 +9497,5 @@ H5C_retag_metadata(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag)
} /* end for */
FUNC_LEAVE_NOAPI_VOID
-} /* H5C_retag_metadata */
+} /* H5C_retag_entries */
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h
index 06f110b..8eb7113 100644
--- a/src/H5Cprivate.h
+++ b/src/H5Cprivate.h
@@ -92,15 +92,23 @@
typedef struct H5C_t H5C_t;
-/* Define metadata tag 'globality' values */
-#define H5C_GLOBALITY_NONE 0
-#define H5C_GLOBALITY_MINOR 1
-#define H5C_GLOBALITY_MAJOR 2
-
-/* Definitions for metadata tag 'globality' property */
-#define H5C_GLOBALITY_NAME "H5C_tag_globality"
-#define H5C_GLOBALITY_SIZE sizeof(int)
-#define H5C_GLOBALITY_DEF H5C_GLOBALITY_NONE
+/* Cache entry tag structure */
+typedef struct H5C_tag_t {
+ haddr_t value;
+ int globality;
+} H5C_tag_t;
+
+/* Define enum for cache entry tag 'globality' value */
+typedef enum {
+ H5C_GLOBALITY_NONE=0, /* Non-global tag */
+ H5C_GLOBALITY_MINOR, /* global, not flushed during single object flush */
+ H5C_GLOBALITY_MAJOR /* global, needs flushed during single obect flush */
+} H5C_tag_globality_t;
+
+/* Definitions for cache "tag" property */
+#define H5C_TAG_NAME "H5C_tag"
+#define H5C_TAG_SIZE sizeof(H5C_tag_t)
+#define H5C_TAG_DEF {(haddr_t)0, H5C_GLOBALITY_NONE}
/*
* Class methods pertaining to caching. Each type of cached object will
@@ -1219,7 +1227,7 @@ H5_DLL herr_t H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr,
H5_DLL herr_t H5C_ignore_tags(H5C_t * cache_ptr);
-H5_DLL void H5C_retag_metadata(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag);
+H5_DLL void H5C_retag_entries(H5C_t * cache_ptr, haddr_t src_tag, haddr_t dest_tag);
#endif /* !_H5Cprivate_H */
diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c
index 054ec6a..0e81727 100644
--- a/src/H5Pdxpl.c
+++ b/src/H5Pdxpl.c
@@ -195,8 +195,7 @@ H5P_dxfr_reg_prop(H5P_genclass_t *pclass)
hid_t def_vfl_id = H5D_XFER_VFL_ID_DEF; /* Default value for file driver ID */
void *def_vfl_info = H5D_XFER_VFL_INFO_DEF; /* Default value for file driver info */
size_t def_hyp_vec_size = H5D_XFER_HYPER_VECTOR_SIZE_DEF; /* Default value for vector size */
- haddr_t metadata_tag = H5AC_METADATA_TAG_DEF; /* Default value for metadata tag */
- int globality = H5C_GLOBALITY_DEF; /* Default value for metadata tag globality value */
+ H5C_tag_t tag = H5C_TAG_DEF; /* Default value for cache entry tag */
#ifdef H5_HAVE_PARALLEL
H5FD_mpio_xfer_t def_io_xfer_mode = H5D_XFER_IO_XFER_MODE_DEF; /* Default value for I/O transfer mode */
H5FD_mpio_chunk_opt_t def_mpio_chunk_opt_mode = H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF;
@@ -216,12 +215,8 @@ H5P_dxfr_reg_prop(H5P_genclass_t *pclass)
if(H5P_register_real(pclass, H5D_XFER_MAX_TEMP_BUF_NAME, H5D_XFER_MAX_TEMP_BUF_SIZE, &def_max_temp_buf, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
- /* Register the metadata tag property */
- if(H5P_register_real(pclass, H5AC_METADATA_TAG_NAME, H5AC_METADATA_TAG_SIZE, &metadata_tag, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
-
- /* Register the tag globality property */
- if(H5P_register_real(pclass, H5C_GLOBALITY_NAME, H5C_GLOBALITY_SIZE, &globality, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ /* Register the cache tag property */
+ if(H5P_register_real(pclass, H5C_TAG_NAME, H5C_TAG_SIZE, &tag, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the type conversion buffer property */
diff --git a/src/H5T.c b/src/H5T.c
index 130921c..b6ecc50 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -5298,6 +5298,8 @@ H5Tflush(hid_t type_id)
/* Check args */
if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(!H5T_is_named(dt))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
/* Call private function to flush datatype object */
if (H5O_flush_metadata(&dt->oloc, H5AC_dxpl_id) < 0)
@@ -5332,6 +5334,8 @@ H5Trefresh(hid_t type_id)
/* Check args */
if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(!H5T_is_named(dt))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a committed datatype")
/* Call private function to refresh datatype object */
if ((H5O_refresh_metadata(type_id, dt->oloc, H5AC_dxpl_id)) < 0)