summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c163
1 files changed, 126 insertions, 37 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 1a0c8b9..fe387a5 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -37,8 +37,8 @@
#include "H5Pprivate.h" /* Property lists */
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5Tprivate.h" /* Datatypes */
-#include "H5VLprivate.h" /* VOL drivers */
-#include "H5VLnative_private.h" /* Native VOL driver */
+#include "H5VLprivate.h" /* VOL plugins */
+#include "H5VLnative_private.h" /* Native VOL plugin */
/****************/
@@ -307,11 +307,11 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id
if(types & H5F_OBJ_LOCAL) {
olist.file_info.local = TRUE;
olist.file_info.ptr.file = f;
- }
+ } /* end if */
else {
olist.file_info.local = FALSE;
olist.file_info.ptr.shared = f ? f->shared : NULL;
- }
+ } /* end else */
/* Iterate through file IDs to count the number, and put their
* IDs on the object list. */
@@ -319,7 +319,7 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id
olist.obj_type = H5I_FILE;
if(H5I_iterate(H5I_FILE, H5F__get_objects_cb, &olist, app_ref) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)")
- }
+ } /* end if */
/* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero),
* or the caller wants to get the list of IDs and the list isn't full,
@@ -330,8 +330,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id
olist.obj_type = H5I_DATASET;
if(H5I_iterate(H5I_DATASET, H5F__get_objects_cb, &olist, app_ref) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(2)")
- }
- }
+ } /* end if */
+ } /* end if */
/* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero),
* or the caller wants to get the list of IDs and the list isn't full,
@@ -342,8 +342,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id
olist.obj_type = H5I_GROUP;
if(H5I_iterate(H5I_GROUP, H5F__get_objects_cb, &olist, app_ref) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(3)")
- }
- }
+ } /* end if */
+ } /* end if */
/* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero),
* or the caller wants to get the list of IDs and the list isn't full,
@@ -354,8 +354,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id
olist.obj_type = H5I_DATATYPE;
if(H5I_iterate(H5I_DATATYPE, H5F__get_objects_cb, &olist, app_ref) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(4)")
- }
- }
+ } /* end if */
+ } /* end if */
/* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero),
* or the caller wants to get the list of IDs and the list isn't full,
@@ -366,8 +366,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id
olist.obj_type = H5I_ATTR;
if(H5I_iterate(H5I_ATTR, H5F__get_objects_cb, &olist, app_ref) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(5)")
- }
- }
+ } /* end if */
+ } /* end if */
/* Set the number of objects currently open */
*obj_id_count_ptr = obj_id_count;
@@ -409,8 +409,8 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
(!olist->file_info.ptr.shared ||
(olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared)))) {
add_obj = TRUE;
- }
- }
+ } /* end if */
+ } /* end if */
else { /* Either count opened object IDs or put the IDs on the list */
H5O_loc_t *oloc; /* Group entry info for object */
@@ -460,7 +460,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
(!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) ||
(oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) {
add_obj = TRUE;
- }
+ } /* end if */
} /* end else */
if(add_obj) {
@@ -468,7 +468,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
if(olist->obj_id_list) {
olist->obj_id_list[olist->list_index] = obj_id;
olist->list_index++;
- }
+ } /* end if */
/* Increment the number of open objects */
if(olist->obj_id_count)
@@ -481,7 +481,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
*/
if(olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs)
HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */
- }
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2166,7 +2166,7 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5F_get_id(H5F_t *file, hbool_t app_ref)
+H5F_get_id(H5F_t *file)
{
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -2176,15 +2176,23 @@ H5F_get_id(H5F_t *file, hbool_t app_ref)
if(H5I_find_id(file, H5I_FILE, &ret_value) < 0 || H5I_INVALID_HID == ret_value) {
/* resurrect the ID - Register an ID with the native driver */
- if((ret_value = H5VL_native_register(H5I_FILE, file, app_ref)) < 0)
+{
+void *vol_wrap_ctx = NULL; /* Object wrapping context */
+
+/* Retrieve the VOL object wrap context */
+if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context")
+HDassert(vol_wrap_ctx);
+}
+ if((ret_value = H5VL_wrap_register(H5I_FILE, file, FALSE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group")
file->id_exists = TRUE;
- }
+ } /* end if */
else {
/* Increment reference count on existing ID */
- if(H5I_inc_ref(ret_value, app_ref) < 0)
+ if(H5I_inc_ref(ret_value, FALSE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed")
- }
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2999,6 +3007,7 @@ H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr)
HDassert(f->shared);
/* Dispatch to driver */
+ /* (H5FD_set_eoa() will add base_addr to addr) */
if(H5FD_set_eoa(f->shared->lf, type, addr) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed")
@@ -3234,7 +3243,8 @@ H5F__start_swmr_write(H5F_t *f)
H5G_name_t *obj_paths = NULL; /* Group hierarchy path */
size_t u; /* Local index variable */
hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */
- H5VL_t *vol_driver = NULL; /* VOL driver for the file */
+ H5VL_t *vol_plugin = NULL; /* VOL plugin for the file */
+ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -3274,16 +3284,16 @@ H5F__start_swmr_write(H5F_t *f)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
/* Get the # of opened named datatypes and attributes */
- if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE|H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0)
+ if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
- if(nt_attr_count)
+ if(nt_attr_count > 0)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "named datatypes and/or attributes opened in the file")
/* Get the # of opened datasets and groups */
- if(H5F_get_obj_count(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0)
+ if(H5F_get_obj_count(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
- if(grp_dset_count) {
+ if(grp_dset_count > 0) {
/* Allocate space for group and object locations */
if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL)
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t")
@@ -3298,17 +3308,25 @@ H5F__start_swmr_write(H5F_t *f)
if(H5F_get_obj_ids(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed")
- /* Save the VOL driver for the refresh step */
+ /* Save the VOL plugin and the object wrapping context for the refresh step */
if(grp_dset_count > 0) {
- H5VL_object_t *vol_obj = NULL;
+ H5VL_object_t *vol_obj;
+ /* Get the VOL object for one of the IDs */
if(NULL == (vol_obj = H5VL_vol_object(obj_ids[0])))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+ HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "invalid object identifier")
- vol_driver = vol_obj->driver;
- }
+ /* Set wrapper info in API context */
+ if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set VOL wrapper info")
+ vol_wrapper_set = TRUE;
- /* Refresh opened objects (groups, datasets) in the file */
+ /* Get the (top) plugin for the ID */
+ vol_plugin = vol_obj->plugin;
+ } /* end if */
+
+ /* Gather information about opened objects (groups, datasets) in the file */
+ /* (For refresh later on) */
for(u = 0; u < grp_dset_count; u++) {
H5O_loc_t *oloc; /* object location */
H5G_loc_t tmp_loc;
@@ -3369,16 +3387,19 @@ H5F__start_swmr_write(H5F_t *f)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict file's cached information")
/* Refresh (reopen) the objects (groups & datasets) in the file */
- for(u = 0; u < grp_dset_count; u++) {
- if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_driver, TRUE) < 0)
+ for(u = 0; u < grp_dset_count; u++)
+ if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_plugin, TRUE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object")
- }
/* Unlock the file */
if(H5FD_unlock(f->shared->lf) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to unlock the file")
done:
+ /* Reset object wrapping info in API context */
+ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset VOL wrapper info")
+
if(ret_value < 0 && setup) {
/* Re-enable accumulator */
@@ -3482,3 +3503,71 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F__format_convert() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_get_file_id
+ *
+ * Purpose: The private version of H5Iget_file_id(), obtains the file
+ * ID given an object ID.
+ *
+ * Return: Success: The file ID associated with the object
+ * Failure: H5I_INVALID_HID
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5F_get_file_id(hid_t obj_id, H5I_type_t type)
+{
+ H5VL_object_t *vol_obj;
+ void *file = NULL;
+ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5I_INVALID_HID)
+
+ /* Get the object pointer */
+ if(NULL == (vol_obj = H5VL_vol_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid identifier")
+
+ /* Get the file through the VOL */
+ if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_FILE_GET_FILE, type, &file) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get file")
+ if(NULL == file)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the file through the VOL")
+
+ /* Check if the file's ID already exists */
+ if(H5I_find_id(file, H5I_FILE, &ret_value) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "getting file ID failed")
+
+ /* If the ID does not exist, register it with the VOL plugin */
+ if(H5I_INVALID_HID == ret_value) {
+ /* Set wrapper info in API context */
+ if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->plugin) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL wrapper info")
+ vol_wrapper_set = TRUE;
+
+{
+void *vol_wrap_ctx = NULL; /* Object wrapping context */
+
+/* Retrieve the VOL object wrap context */
+if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context")
+HDassert(vol_wrap_ctx);
+}
+ if ((ret_value = H5VL_wrap_register(H5I_FILE, file, TRUE)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle")
+ } /* end if */
+ else {
+ /* Increment ref count on existing ID */
+ if(H5I_inc_ref(ret_value, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed")
+ } /* end else */
+
+done:
+ /* Reset object wrapping info in API context */
+ if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't reset VOL wrapper info")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_get_file_id() */
+