summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2019-09-26 22:47:00 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2019-09-27 02:13:35 (GMT)
commit4fb64c89fe52a309150ca2d5bb97eb4763e598e9 (patch)
treeaf158b041bcbb357aca65fc0d780d1ed727d3d04
parentfbb0728f5423ba88de5a7bbe4f4d06825ed82aaa (diff)
downloadhdf5-4fb64c89fe52a309150ca2d5bb97eb4763e598e9.zip
hdf5-4fb64c89fe52a309150ca2d5bb97eb4763e598e9.tar.gz
hdf5-4fb64c89fe52a309150ca2d5bb97eb4763e598e9.tar.bz2
Converted H5O MD cache cork calls to use the VOL.
-rw-r--r--src/H5I.c50
-rw-r--r--src/H5Iprivate.h1
-rw-r--r--src/H5O.c210
-rw-r--r--src/H5Oprivate.h5
-rw-r--r--src/H5VLnative.h9
-rw-r--r--src/H5VLnative_object.c34
-rw-r--r--test/cork.c12
7 files changed, 259 insertions, 62 deletions
diff --git a/src/H5I.c b/src/H5I.c
index ab68e38..201ad9a 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -1086,6 +1086,56 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5I_is_file_object
+ *
+ * Purpose: Convenience function to determine if an ID represents
+ * a file object.
+ *
+ * In H5O calls, you can't use object_verify to ensure
+ * the ID was of the correct class since there's no
+ * H5I_OBJECT ID class.
+ *
+ * Return: Success: TRUE/FALSE
+ * Failure: FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5I_is_file_object(hid_t id)
+{
+ H5I_type_t id_type = H5I_get_type(id);
+ htri_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI(FAIL);
+
+ /* Fail if the ID type is out of range */
+ HDassert(id_type >= 1 && id_type < H5I_NTYPES);
+
+ /* Return TRUE if the ID is a file object (dataset, group, map, or committed
+ * datatype), FALSE otherwise.
+ */
+ if (H5I_DATASET == id_type || H5I_GROUP == id_type || H5I_MAP == id_type) {
+ ret_value = TRUE;
+ }
+ else if (H5I_DATATYPE == id_type) {
+
+ H5T_t *dt = NULL;
+
+ if(NULL == (dt = (H5T_t *)H5I_object(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get underlying datatype struct")
+
+ ret_value = H5T_is_named(dt);
+ }
+ else {
+ ret_value = FALSE;
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5I_is_file_object() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Iremove_verify
*
* Purpose: Removes the specified ID from its type, first checking that the
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index 9068b5f..cc1ce1f 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -92,6 +92,7 @@ H5_DLL void *H5I_object(hid_t id);
H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type);
H5_DLL void *H5I_remove(hid_t id);
H5_DLL void *H5I_subst(hid_t id, const void *new_object);
+H5_DLL htri_t H5I_is_file_object(hid_t id);
/* ID registration functions */
H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref);
diff --git a/src/H5O.c b/src/H5O.c
index bf2d799..ed68ed0 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1116,113 +1116,215 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Odisable_mdc_flushes
+ * Function: H5O_disable_mdc_flushes
*
- * Purpose: To "cork" an object:
- * --keep dirty entries associated with the object in the metadata cache
+ * Purpose: Private version of the metadata cache cork function.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_disable_mdc_flushes(H5O_loc_t *oloc)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL);
+
+ if (H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object");
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5O_disable_mdc_flushes() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Odisable_mdc_flushes
+ *
+ * Purpose: "Cork" an object, keeping dirty entries associated with the
+ * object in the metadata cache.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
*
- * Programmer: Vailin Choi
- * January 2014
+ * Programmer: Vailin Choi
+ * January 2014
*
*-------------------------------------------------------------------------
*/
herr_t
H5Odisable_mdc_flushes(hid_t object_id)
{
- H5O_loc_t *oloc; /* Object location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params; /* Location parameters */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(FAIL);
H5TRACE1("e", "i", object_id);
- /* Get the object's oloc */
- if(NULL == (oloc = H5O_get_loc(object_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID")
+ /* Make sure the ID is a file object */
+ if (H5I_is_file_object(object_id) != TRUE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object");
- if(H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork an object")
+ /* Get the VOL object */
+ if (NULL == (vol_obj = H5VL_vol_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID");
+
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(object_id);
+
+ /* Cork the object */
+ if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES, &loc_params) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object");
done:
- FUNC_LEAVE_API(ret_value)
+ FUNC_LEAVE_API(ret_value);
} /* H5Odisable_mdc_flushes() */
/*-------------------------------------------------------------------------
- * Function: H5Oenable_mdc_flushes
+ * Function: H5O_enable_mdc_flushes
*
- * Purpose: To "uncork" an object
- * --release keeping dirty entries associated with the object
- * in the metadata cache
+ * Purpose: Private version of the metadata cache uncork function.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_enable_mdc_flushes(H5O_loc_t *oloc)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL);
+
+ if (H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object");
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5O_enable_mdc_flushes() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Oenable_mdc_flushes
+ *
+ * Purpose: "Uncork" an object, allowing dirty entries associated with
+ * the object to be flushed.
*
- * Programmer: Vailin Choi
- * January 2014
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi
+ * January 2014
*
*-------------------------------------------------------------------------
*/
herr_t
H5Oenable_mdc_flushes(hid_t object_id)
{
- H5O_loc_t *oloc; /* Object location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params; /* Location parameters */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(FAIL);
H5TRACE1("e", "i", object_id);
- /* Get the object's oloc */
- if(NULL == (oloc = H5O_get_loc(object_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID")
+ /* Make sure the ID is a file object */
+ if (H5I_is_file_object(object_id) != TRUE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object");
+
+ /* Get the VOL object */
+ if (NULL == (vol_obj = H5VL_vol_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID");
+
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(object_id);
- /* Set the value */
- if(H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object")
+ /* Uncork the object */
+ if (H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES, &loc_params) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object");
done:
- FUNC_LEAVE_API(ret_value)
+ FUNC_LEAVE_API(ret_value);
} /* H5Oenable_mdc_flushes() */
/*-------------------------------------------------------------------------
- * Function: H5Oare_mdc_flushes_disabled
+ * Function: H5O_are_mdc_flushes_disabled
*
- * Purpose: Retrieve the object's "cork" status in the parameter "are_disabled":
- * TRUE if mdc flushes for the object is disabled
- * FALSE if mdc flushes for the object is not disabled
- * Return error if the parameter "are_disabled" is not supplied
+ * Purpose: Private version of cork status getter.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL);
+
+ HDassert(are_disabled);
+
+ if (H5AC_cork(oloc->file, oloc->addr, H5AC__GET_CORKED, are_disabled) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status");
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5O_are_mdc_flushes_disabled() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Oare_mdc_flushes_disabled
+ *
+ * Purpose: Retrieve the object's "cork" status in the parameter "are_disabled":
+ * TRUE if mdc flushes for the object is disabled
+ * FALSE if mdc flushes for the object is not disabled
*
- * Programmer: Vailin Choi
- * January 2014
+ * Return error if the parameter "are_disabled" is not supplied
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi
+ * January 2014
*
*-------------------------------------------------------------------------
*/
herr_t
H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled)
{
- H5O_loc_t *oloc; /* Object location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params; /* Location parameters */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(FAIL);
H5TRACE2("e", "i*b", object_id, are_disabled);
- /* Check args */
+ /* Sanity check */
+ if (!are_disabled)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from ID");
- /* Get the object's oloc */
- if(NULL == (oloc = H5O_get_loc(object_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID")
- if(!are_disabled)
- HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID")
+ /* Make sure the ID is a file object */
+ if (H5I_is_file_object(object_id) != TRUE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object");
+
+ /* Get the VOL object */
+ if (NULL == (vol_obj = H5VL_vol_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID");
+
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(object_id);
/* Get the cork status */
- if(H5AC_cork(oloc->file, oloc->addr, H5AC__GET_CORKED, are_disabled) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status")
+ if (H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED, &loc_params, are_disabled) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status");
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 354a00b..bcb8299 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -972,6 +972,11 @@ H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id);
H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc);
H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, hbool_t start_swmr);
+/* Cache corking functions */
+H5_DLL herr_t H5O_disable_mdc_flushes(H5O_loc_t *oloc);
+H5_DLL herr_t H5O_enable_mdc_flushes(H5O_loc_t *oloc);
+H5_DLL herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled);
+
/* Object copying routines */
H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
H5O_copy_t *cpy_info, hbool_t inc_depth,
diff --git a/src/H5VLnative.h b/src/H5VLnative.h
index 82a99e4..b2dd13d 100644
--- a/src/H5VLnative.h
+++ b/src/H5VLnative.h
@@ -83,9 +83,12 @@ typedef int H5VL_native_group_optional_t;
/* Typedef and values for native VOL connector object optional VOL operations */
typedef int H5VL_native_object_optional_t;
-#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */
-#define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */
-#define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */
+#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */
+#define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */
+#define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */
+#define H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES 3 /* H5Odisable_mdc_flushes */
+#define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 4 /* H5Oenable_mdc_flushes */
+#define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 5 /* H5Oare_mdc_flushes_disabled */
#ifdef __cplusplus
extern "C" {
diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c
index de2a8a5..49d4b2c 100644
--- a/src/H5VLnative_object.c
+++ b/src/H5VLnative_object.c
@@ -487,6 +487,40 @@ H5VL__native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id,
break;
}
+ /* H5Odisable_mdc_flushes */
+ case H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES:
+ {
+ H5O_loc_t *oloc = loc.oloc;
+
+ if (H5O_disable_mdc_flushes(oloc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork the metadata cache");
+
+ break;
+ }
+
+ /* H5Oenable_mdc_flushes */
+ case H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES:
+ {
+ H5O_loc_t *oloc = loc.oloc;
+
+ if (H5O_enable_mdc_flushes(oloc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork the metadata cache");
+
+ break;
+ }
+
+ /* H5Oare_mdc_flushes_disabled */
+ case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED:
+ {
+ H5O_loc_t *oloc = loc.oloc;
+ hbool_t *are_disabled = (hbool_t *)HDva_arg(arguments, hbool_t *);
+
+ if (H5O_are_mdc_flushes_disabled(oloc, are_disabled) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine metadata cache cork status");
+
+ break;
+ }
+
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object");
} /* end switch */
diff --git a/test/cork.c b/test/cork.c
index 09076d2..06a520d 100644
--- a/test/cork.c
+++ b/test/cork.c
@@ -1529,11 +1529,13 @@ error:
static unsigned
test_objs_cork(hbool_t swmr, hbool_t new_format)
{
- hid_t fid; /* HDF5 File ID */
- hid_t fapl; /* File access property list */
- hid_t gid, did, tid; /* Object IDs */
- hid_t sid; /* Dataspace ID */
- hid_t aid; /* Attribute ID */
+ hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ hid_t gid = H5I_INVALID_HID;
+ hid_t did = H5I_INVALID_HID;
+ hid_t tid = H5I_INVALID_HID; /* Object IDs */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t aid = H5I_INVALID_HID; /* Attribute ID */
hsize_t dims[RANK]; /* Dataset dimension sizes */
hbool_t corked; /* Cork status of an object */
unsigned flags; /* File access flags */