summaryrefslogtreecommitdiffstats
path: root/src/H5Oflush.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Oflush.c')
-rw-r--r--src/H5Oflush.c242
1 files changed, 160 insertions, 82 deletions
diff --git a/src/H5Oflush.c b/src/H5Oflush.c
index e399c6c..e8e077e 100644
--- a/src/H5Oflush.c
+++ b/src/H5Oflush.c
@@ -5,12 +5,10 @@
* *
* 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. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*-------------------------------------------------------------------------
@@ -35,17 +33,24 @@
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Errors */
#include "H5Fprivate.h" /* Files */
-#include "H5Gprivate.h" /* Groups */
-#include "H5Iprivate.h" /* IDs */
+#include "H5Gprivate.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Objects */
+
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5O_oh_tag(const H5O_loc_t *oloc, hid_t dxpl_id, haddr_t *tag);
+static herr_t H5O__flush(hid_t obj_id);
+static herr_t H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag);
+static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc,
+ H5G_loc_t *obj_loc);
+static herr_t H5O__refresh(hid_t obj_id);
+
/*************/
/* Functions */
@@ -68,38 +73,24 @@ static herr_t H5O_oh_tag(const H5O_loc_t *oloc, hid_t dxpl_id, haddr_t *tag);
herr_t
H5Oflush(hid_t obj_id)
{
- H5O_loc_t *oloc; /* object location */
- void *obj_ptr; /* Pointer to object */
- const H5O_obj_class_t *obj_class = NULL; /* Class of object */
- herr_t ret_value = SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", obj_id);
- /* Check args */
- if(NULL == (oloc = H5O_get_loc(obj_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object")
-
- /* Get the object pointer */
- if(NULL == (obj_ptr = H5I_object(obj_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+ /* Set up collective metadata if appropriate */
+ if(H5CX_set_loc(obj_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
- /* Get the object class */
- if(NULL == (obj_class = H5O_obj_class(oloc, H5AC_ind_read_dxpl_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object class")
-
- /* Flush the object of this class */
- if(obj_class->flush && obj_class->flush(obj_ptr, H5AC_ind_read_dxpl_id) < 0)
+ /* Call internal routine */
+ if(H5O__flush(obj_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object")
- /* Flush the object metadata and invoke flush callback */
- if(H5O_flush_common(oloc, obj_id, H5AC_ind_read_dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object and object flush callback")
-
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Oflush() */
+
/*-------------------------------------------------------------------------
* Function: H5O_flush_common
*
@@ -113,7 +104,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id, hid_t dxpl_id)
+H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id)
{
haddr_t tag = 0;
herr_t ret_value = SUCCEED; /* Return value */
@@ -121,11 +112,11 @@ H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id, hid_t dxpl_id)
FUNC_ENTER_NOAPI(FAIL)
/* Retrieve tag for object */
- if(H5O_oh_tag(oloc, dxpl_id, &tag) < 0)
+ if(H5O__oh_tag(oloc, &tag) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object metadata")
/* Flush metadata based on tag value of the object */
- if(H5F_flush_tagged_metadata(oloc->file, tag, dxpl_id) < 0)
+ if(H5F_flush_tagged_metadata(oloc->file, tag) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata")
/* Check to invoke callback */
@@ -138,7 +129,58 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_oh_tag
+ * Function: H5O__flush
+ *
+ * Purpose: Internal routine to flush an object
+ *
+ * Note: This routine is needed so that there's a non-API routine
+ * that can set up VOL / SWMR info (which need a DXPL).
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * December 29, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O__flush(hid_t obj_id)
+{
+ H5O_loc_t *oloc; /* Object location */
+ void *obj_ptr; /* Pointer to object */
+ const H5O_obj_class_t *obj_class; /* Class of object */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC_VOL
+
+ /* Check args */
+ if(NULL == (oloc = H5O_get_loc(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object")
+
+ /* Get the object pointer */
+ if(NULL == (obj_ptr = H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* Get the object class */
+ if(NULL == (obj_class = H5O__obj_class(oloc)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object class")
+
+ /* Flush the object of this class */
+ if(obj_class->flush && obj_class->flush(obj_ptr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object")
+
+ /* Flush the object metadata and invoke flush callback */
+ if(H5O_flush_common(oloc, obj_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object and object flush callback")
+
+done:
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
+} /* end H5O__flush() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O__oh_tag
*
* Purpose: Get object header's address--tag value for the object
*
@@ -151,18 +193,18 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_oh_tag(const H5O_loc_t *oloc, hid_t dxpl_id, haddr_t *tag)
+H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag)
{
H5O_t *oh = NULL; /* Object header */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
/* Check args */
HDassert(oloc);
/* Get object header for object */
- if(NULL == (oh = H5O_protect(oloc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ if(NULL == (oh = H5O_protect(oloc, H5AC__READ_ONLY_FLAG, FALSE)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object's object header")
/* Get object header's address (i.e. the tag value for this object) */
@@ -171,11 +213,11 @@ H5O_oh_tag(const H5O_loc_t *oloc, hid_t dxpl_id, haddr_t *tag)
done:
/* Unprotect object header on failure */
- if(oh && H5O_unprotect(oloc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ if(oh && H5O_unprotect(oloc, oh, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_oh_tag() */
+} /* end H5O__oh_tag() */
/*-------------------------------------------------------------------------
@@ -193,18 +235,17 @@ done:
herr_t
H5Orefresh(hid_t oid)
{
- H5O_loc_t *oloc; /* object location */
- herr_t ret_value = SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", oid);
- /* Check args */
- if(NULL == (oloc = H5O_get_loc(oid)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object")
+ /* Set up collective metadata if appropriate */
+ if(H5CX_set_loc(oid) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info")
- /* Private function */
- if(H5O_refresh_metadata(oid, *oloc, H5AC_ind_read_dxpl_id) < 0)
+ /* Call internal routine */
+ if(H5O__refresh(oid) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
done:
@@ -233,7 +274,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id)
+H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc)
{
hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */
herr_t ret_value = SUCCEED; /* Return value */
@@ -258,11 +299,11 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc, hid_t dxpl_id)
objs_incr = TRUE;
/* Close object & evict its metadata */
- if((H5O_refresh_metadata_close(oid, oloc, &obj_loc, dxpl_id)) < 0)
+ if((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
/* Re-open the object, re-fetching its metadata */
- if((H5O_refresh_metadata_reopen(oid, &obj_loc, dxpl_id, FALSE)) < 0)
+ if((H5O_refresh_metadata_reopen(oid, &obj_loc, FALSE)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
} /* end if */
@@ -275,7 +316,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_refresh_metadata_close
+ * Function: H5O__refresh_metadata_close
*
* Purpose: This is the first part of the original routine H5O_refresh_metadata().
* (1) Save object location information.
@@ -293,14 +334,14 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t dxpl_id)
+static herr_t
+H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc)
{
haddr_t tag = 0; /* Tag for object */
hbool_t corked = FALSE; /* Whether object's metadata is corked */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
/* Make deep local copy of object's location information */
if(obj_loc) {
@@ -312,11 +353,11 @@ H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t
/* Get object's type */
if(H5I_get_type(oid) == H5I_DATASET)
- if(H5D_mult_refresh_close(oid, dxpl_id) < 0)
+ if(H5D_mult_refresh_close(oid) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to prepare refresh for dataset")
/* Retrieve tag for object */
- if(H5O_oh_tag(&oloc, dxpl_id, &tag) < 0)
+ if(H5O__oh_tag(&oloc, &tag) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to get object header address")
/* Get cork status of the object with tag */
@@ -328,11 +369,11 @@ H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to close object")
/* Flush metadata based on tag value of the object */
- if(H5F_flush_tagged_metadata(oloc.file, tag, dxpl_id) < 0)
+ if(H5F_flush_tagged_metadata(oloc.file, tag) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata")
/* Evict the object's tagged metadata */
- if(H5F_evict_tagged_metadata(oloc.file, tag, dxpl_id) < 0)
+ if(H5F_evict_tagged_metadata(oloc.file, tag) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict metadata")
/* Re-cork object with tag */
@@ -342,7 +383,7 @@ H5O_refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc, hid_t
done:
FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5O_refresh_metadata_close() */
+} /* end H5O__refresh_metadata_close() */
/*-------------------------------------------------------------------------
@@ -360,7 +401,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t start_swmr)
+H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hbool_t start_swmr)
{
void *object = NULL; /* Dataset for this operation */
H5I_type_t type; /* Type of object for the ID */
@@ -372,42 +413,42 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_
type = H5I_get_type(oid);
switch(type) {
- case(H5I_GROUP):
+ case H5I_GROUP:
/* Re-open the group */
- if(NULL == (object = H5G_open(obj_loc, dxpl_id)))
+ if(NULL == (object = H5G_open(obj_loc)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
break;
- case(H5I_DATATYPE):
+ case H5I_DATATYPE:
/* Re-open the named datatype */
- if(NULL == (object = H5T_open(obj_loc, dxpl_id)))
+ if(NULL == (object = H5T_open(obj_loc)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype")
break;
- case(H5I_DATASET):
+ case H5I_DATASET:
/* Re-open the dataset */
- if(NULL == (object = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT, dxpl_id)))
+ if(NULL == (object = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset")
- if(!start_swmr) /* No need to handle multiple opens when H5Fstart_swmr_write() */
- if(H5D_mult_refresh_reopen((H5D_t *)object, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset")
+ if(!start_swmr) /* No need to handle multiple opens when H5Fstart_swmr_write() */
+ if(H5D_mult_refresh_reopen((H5D_t *)object) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset")
break;
- case(H5I_UNINIT):
- case(H5I_BADID):
- case(H5I_FILE):
- case(H5I_DATASPACE):
- case(H5I_ATTR):
- case(H5I_REFERENCE):
- case(H5I_VFL):
- case(H5I_GENPROP_CLS):
- case(H5I_GENPROP_LST):
- case(H5I_ERROR_CLASS):
- case(H5I_ERROR_MSG):
- case(H5I_ERROR_STACK):
- case(H5I_NTYPES):
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_FILE:
+ case H5I_DATASPACE:
+ case H5I_ATTR:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
default:
- HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid file object ID (dataset, group, or datatype)")
break;
} /* end switch */
@@ -419,3 +460,40 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5O_refresh_metadata_reopen() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O__refresh
+ *
+ * Purpose: Internal routine to refresh an object
+ *
+ * Note: This routine is needed so that there's a non-API routine
+ * that can set up VOL / SWMR info (which need a DXPL).
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * December 29, 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O__refresh(hid_t obj_id)
+{
+ H5O_loc_t *oloc; /* Object location */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC_VOL
+
+ /* Check args */
+ if(NULL == (oloc = H5O_get_loc(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object")
+
+ /* Private function */
+ if(H5O_refresh_metadata(obj_id, *oloc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object")
+
+done:
+ FUNC_LEAVE_NOAPI_VOL(ret_value)
+} /* end H5O__refresh() */
+