summaryrefslogtreecommitdiffstats
path: root/src/H5Oint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Oint.c')
-rw-r--r--src/H5Oint.c163
1 files changed, 93 insertions, 70 deletions
diff --git a/src/H5Oint.c b/src/H5Oint.c
index b97ff30..d5a3a71 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -31,6 +31,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* File access */
#include "H5FLprivate.h" /* Free lists */
@@ -42,6 +43,8 @@
#include "H5Opkg.h" /* Object headers */
#include "H5VLprivate.h" /* Virtual Object Layer */
+#include "H5VLnative_private.h" /* Native VOL connector */
+
/****************/
/* Local Macros */
@@ -55,9 +58,9 @@
/* User data for recursive traversal over objects from a group */
typedef struct {
hid_t obj_id; /* The ID for the starting group */
- H5G_loc_t *start_loc; /* Location of starting group */
+ H5G_loc_t *start_loc; /* Location of starting group */
H5SL_t *visited; /* Skip list for tracking visited nodes */
- H5O_iterate_t op; /* Application callback */
+ H5O_iterate2_t op; /* Application callback */
void *op_data; /* Application's op data */
unsigned fields; /* Selection of object info */
} H5O_iter_visit_ud_t;
@@ -77,9 +80,11 @@ static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type);
static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr);
static herr_t H5O__free_visit_visited(void *item, void *key,
void *operator_data/*in,out*/);
-static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *linfo,
+static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo,
void *_udata);
static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh);
+static herr_t H5O__reset_info2(H5O_info2_t *oinfo);
+
/*********************/
/* Package Variables */
@@ -150,6 +155,13 @@ H5FL_BLK_DEFINE(chunk_image);
/* Declare external the free list for H5O_cont_t sequences */
H5FL_SEQ_EXTERN(H5O_cont_t);
+/* The canonical 'undefined' token */
+const H5O_token_t H5O_TOKEN_UNDEF_g = {{
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255}};
+
/*****************************/
/* Library Private Variables */
@@ -239,7 +251,7 @@ H5O_set_version(H5F_t *f, H5O_t *oh, uint8_t oh_flags, hbool_t store_msg_crt_idx
version = H5O_VERSION_1;
/* Upgrade to the version indicated by the file's low bound if higher */
- version = MAX(version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]);
+ version = (uint8_t)MAX(version, (uint8_t)H5O_obj_ver_bounds[H5F_LOW_BOUND(f)]);
/* Version bounds check */
if(version > H5O_obj_ver_bounds[H5F_HIGH_BOUND(f)])
@@ -2154,9 +2166,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
/*-------------------------------------------------------------------------
* Function: H5O_get_info
*
- * Purpose: Retrieve the information for an object
- *
- * Note: Add a parameter "fields" to indicate selection of object info.
+ * Purpose: Retrieve the data model information for an object
*
* Return: Success: Non-negative
* Failure: Negative
@@ -2167,7 +2177,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
+H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields)
{
const H5O_obj_class_t *obj_class; /* Class of object for header */
H5O_t *oh = NULL; /* Object header */
@@ -2188,15 +2198,17 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
/* Reset the object info structure */
- HDmemset(oinfo, 0, sizeof(*oinfo));
+ if(H5O__reset_info2(oinfo) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct")
/* Get basic information, if requested */
if(fields & H5O_INFO_BASIC) {
/* Retrieve the file's fileno */
H5F_GET_FILENO(loc->file, oinfo->fileno);
- /* Set the object's address */
- oinfo->addr = loc->addr;
+ /* Set the object's address into the token */
+ if(H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token")
/* Retrieve the type of the object */
oinfo->type = obj_class->type;
@@ -2248,31 +2260,11 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
} /* end else */
} /* end if */
- /* Get the information for the object header, if requested */
- if(fields & H5O_INFO_HDR)
- if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
-
/* Retrieve # of attributes */
if(fields & H5O_INFO_NUM_ATTRS)
if(H5O__attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count")
- /* Get B-tree & heap metadata storage size, if requested */
- if(fields & H5O_INFO_META_SIZE) {
- /* Check for 'bh_info' callback for this type of object */
- if(obj_class->bh_info)
- /* Call the object's class 'bh_info' routine */
- if((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
-
- /* Get B-tree & heap info for any attributes */
- if(!(fields & H5O_INFO_NUM_ATTRS) || oinfo->num_attrs > 0) {
- if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
- } /* end if */
- } /* end if */
-
done:
if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
@@ -2282,60 +2274,66 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O__get_info_by_idx
+ * Function: H5O_get_native_info
*
- * Purpose: Internal routine to retrieve an object's info according to
- * an index within a group.
- *
- *
- * Note: Add a parameter "fields" to indicate selection of object info.
+ * Purpose: Retrieve the native file-format information for an object
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
- * December 28, 2017
+ * November 21 2006
*
*-------------------------------------------------------------------------
*/
herr_t
-H5O__get_info_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx_type,
- H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields)
+H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields)
{
- H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
- hbool_t loc_found = FALSE; /* Entry at 'name' found */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5O_obj_class_t *obj_class; /* Class of object for header */
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_PACKAGE
+ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL)
- /* Check arguments */
+ /* Check args */
HDassert(loc);
- HDassert(group_name && *group_name);
HDassert(oinfo);
- /* Set up opened group location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
- /* Find the object's location, according to the order in the index */
- if(H5G_loc_find_by_idx(loc, group_name, idx_type, order, n, &obj_loc/*out*/) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
- loc_found = TRUE;
+ /* Get class for object */
+ if(NULL == (obj_class = H5O__obj_class_real(oh)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
+
+ /* Reset the object info structure */
+ HDmemset(oinfo, 0, sizeof(*oinfo));
- /* Retrieve the object's information */
- if(H5O_get_info(obj_loc.oloc, oinfo, fields) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info")
+ /* Get the information for the object header, if requested */
+ if(fields & H5O_NATIVE_INFO_HDR)
+ if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
+
+ /* Get B-tree & heap metadata storage size, if requested */
+ if(fields & H5O_NATIVE_INFO_META_SIZE) {
+ /* Check for 'bh_info' callback for this type of object */
+ if(obj_class->bh_info)
+ /* Call the object's class 'bh_info' routine */
+ if((obj_class->bh_info)(loc, oh, &oinfo->meta_size.obj) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
+
+ /* Get B-tree & heap info for any attributes */
+ if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
+ } /* end if */
done:
- /* Release the object location */
- if(loc_found && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
+ if(oh && H5O_unprotect(loc, 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__get_info_by_idx() */
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
+} /* end H5O_get_native_info() */
/*-------------------------------------------------------------------------
@@ -2378,7 +2376,7 @@ H5O_get_create_plist(const H5O_loc_t *loc, H5P_genplist_t *oc_plist)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list")
/* Mask off non-"user visible" flags */
- ohdr_flags = oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES);
+ H5_CHECKED_ASSIGN(ohdr_flags, uint8_t, oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES), int);
/* Set object header flags */
if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0)
@@ -2649,7 +2647,7 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo,
+H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo,
void *_udata)
{
H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */
@@ -2687,7 +2685,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li
/* Check if we've seen the object the link references before */
if(NULL == H5SL_search(udata->visited, &obj_pos)) {
- H5O_info_t oinfo; /* Object info */
+ H5O_info2_t oinfo; /* Object info */
/* Get the object's info */
if(H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0)
@@ -2763,14 +2761,14 @@ done:
*/
herr_t
H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields)
+ H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields)
{
H5O_iter_visit_ud_t udata; /* User data for callback */
H5G_loc_t obj_loc; /* Location used to open object */
H5G_name_t obj_path; /* Opened object group hier. path */
H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'name' found */
- H5O_info_t oinfo; /* Object info struct */
+ H5O_info2_t oinfo; /* Object info struct */
void *obj = NULL; /* Object */
H5I_type_t opened_type; /* ID type of object */
hid_t obj_id = H5I_INVALID_HID; /* ID of object */
@@ -2846,7 +2844,10 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
/* Construct unique "position" for this object */
obj_pos->fileno = oinfo.fileno;
- obj_pos->addr = oinfo.addr;
+
+ /* De-serialize object token into an object address */
+ if(H5VL_native_token_to_addr(loc->oloc->file, H5I_FILE, oinfo.token, &(obj_pos->addr)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address")
/* Add to list of visited objects */
if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0)
@@ -3083,3 +3084,25 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__free() */
+/*-------------------------------------------------------------------------
+ * Function: H5O__reset_info2
+ *
+ * Purpose: Resets/initializes an H5O_info2_t struct.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O__reset_info2(H5O_info2_t *oinfo)
+{
+ FUNC_ENTER_STATIC_NOERR;
+
+ /* Reset the passed-in info struct */
+ HDmemset(oinfo, 0, sizeof(H5O_info2_t));
+ oinfo->type = H5O_TYPE_UNKNOWN;
+ oinfo->token = H5O_TOKEN_UNDEF;
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* end H5O__reset_info2() */
+