summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c202
1 files changed, 29 insertions, 173 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 5950d9e..05dbf99 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -69,7 +69,6 @@ static int H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNU
static int H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key);
/* Helper routines for sync/async API calls */
-static herr_t H5F__post_open_api_common(H5VL_object_t *vol_obj, void **token_ptr);
static hid_t H5F__create_api_common(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
void **token_ptr);
static hid_t H5F__open_api_common(const char *filename, unsigned flags, hid_t fapl_id, void **token_ptr);
@@ -510,43 +509,6 @@ done:
} /* end H5Fis_accessible() */
/*-------------------------------------------------------------------------
- * Function: H5F__post_open_api_common
- *
- * Purpose: This is the common function for 'post open' operations
- *
- * Return: SUCCEED/FAIL
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5F__post_open_api_common(H5VL_object_t *vol_obj, void **token_ptr)
-{
- uint64_t supported; /* Whether 'post open' operation is supported by VOL connector */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_STATIC
-
- /* Check for 'post open' callback */
- supported = 0;
- if (H5VL_introspect_opt_query(vol_obj, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't check for 'post open' operation")
- if (supported & H5VL_OPT_QUERY_SUPPORTED) {
- H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */
-
- /* Set up VOL callback arguments */
- vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN;
- vol_cb_args.args = NULL;
-
- /* Make the 'post open' callback */
- if (H5VL_file_optional(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to make file 'post open' callback")
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F__post_open_api_common() */
-
-/*-------------------------------------------------------------------------
* Function: H5F__create_api_common
*
* Purpose: This is the common function for creating new HDF5 files.
@@ -558,9 +520,6 @@ done:
static hid_t
H5F__create_api_common(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id, void **token_ptr)
{
- void * new_file = NULL; /* File struct for new file */
- H5P_genplist_t * plist; /* Property list pointer */
- H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_STATIC
@@ -589,18 +548,6 @@ H5F__create_api_common(const char *filename, unsigned flags, hid_t fcpl_id, hid_
if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
- /* Get the VOL info from the fapl */
- if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list")
- if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info")
-
- /* Stash a copy of the "top-level" connector property, before any pass-through
- * connectors modify or unwrap it.
- */
- if (H5CX_set_vol_connector_prop(&connector_prop) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context")
-
/* Adjust bit flags by turning on the creation bit and making sure that
* the EXCL or TRUNC bit is set. All newly-created files are opened for
* reading and writing.
@@ -610,14 +557,9 @@ H5F__create_api_common(const char *filename, unsigned flags, hid_t fcpl_id, hid_
flags |= H5F_ACC_RDWR | H5F_ACC_CREAT;
/* Create a new file or truncate an existing file through the VOL */
- if (NULL == (new_file = H5VL_file_create(&connector_prop, filename, flags, fcpl_id, fapl_id,
- H5P_DATASET_XFER_DEFAULT, token_ptr)))
+ if ((ret_value = H5VL_file_create(filename, flags, fcpl_id, fapl_id, H5P_DATASET_XFER_DEFAULT, token_ptr)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file")
- /* Get an ID for the file */
- if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle")
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F__create_api_common() */
@@ -650,7 +592,6 @@ done:
hid_t
H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
{
- H5VL_object_t *vol_obj = NULL; /* File object */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
@@ -660,14 +601,6 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if ((ret_value = H5F__create_api_common(filename, flags, fcpl_id, fapl_id, NULL)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, H5I_INVALID_HID, "unable to synchronously create file")
- /* Get the file object */
- if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
- HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier")
-
- /* Perform 'post open' operation */
- if (H5F__post_open_api_common(vol_obj, NULL) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "'post open' operation failed")
-
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fcreate() */
@@ -687,7 +620,6 @@ hid_t
H5Fcreate_async(const char *app_file, const char *app_func, unsigned app_line, const char *filename,
unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t es_id)
{
- H5VL_object_t *vol_obj = NULL; /* File object */
void * token = NULL; /* Request token for async operation */
void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -703,12 +635,14 @@ H5Fcreate_async(const char *app_file, const char *app_func, unsigned app_line, c
if ((ret_value = H5F__create_api_common(filename, flags, fcpl_id, fapl_id, token_ptr)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, H5I_INVALID_HID, "unable to asynchronously create file")
- /* Get the file object */
- if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
- HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier")
-
/* If a token was created, add the token to the event set */
- if (NULL != token)
+ if (NULL != token) {
+ H5VL_object_t *vol_obj; /* File object */
+
+ /* Get the file object */
+ if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
+ HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier")
+
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE8(FUNC, "*s*sIu*sIuiii", app_file, app_func, app_line, filename, flags, fcpl_id, fapl_id, es_id)) < 0) {
@@ -717,22 +651,7 @@ H5Fcreate_async(const char *app_file, const char *app_func, unsigned app_line, c
HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID")
HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */
-
- /* Reset token for 'post open' operation */
- /* (Unnecessary if create operation didn't change it, but not worth checking -QAK) */
- token = NULL;
-
- /* Perform 'post open' operation */
- if (H5F__post_open_api_common(vol_obj, token_ptr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "'post open' operation failed")
-
- /* If a token was created, add the token to the event set */
- if (NULL != token)
- /* clang-format off */
- if (H5ES_insert(es_id, vol_obj->connector, token,
- H5ARG_TRACE8(FUNC, "*s*sIu*sIuiii", app_file, app_func, app_line, filename, flags, fcpl_id, fapl_id, es_id)) < 0)
- /* clang-format on */
- HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
+ } /* end if */
done:
FUNC_LEAVE_API(ret_value)
@@ -752,9 +671,7 @@ done:
static hid_t
H5F__open_api_common(const char *filename, unsigned flags, hid_t fapl_id, void **token_ptr)
{
- void * new_file = NULL; /* File struct for new file */
- H5P_genplist_t * plist; /* Property list pointer */
- H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
+ hid_t file_id = H5I_INVALID_HID; /* File ID */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_STATIC
@@ -779,26 +696,12 @@ H5F__open_api_common(const char *filename, unsigned flags, hid_t fapl_id, void *
if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info")
- /* Get the VOL info from the fapl */
- if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list")
- if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info")
-
- /* Stash a copy of the "top-level" connector property, before any pass-through
- * connectors modify or unwrap it.
- */
- if (H5CX_set_vol_connector_prop(&connector_prop) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context")
-
/* Open the file through the VOL layer */
- if (NULL == (new_file = H5VL_file_open(&connector_prop, filename, flags, fapl_id,
- H5P_DATASET_XFER_DEFAULT, token_ptr)))
+ if (NULL == H5VL_file_open(filename, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, token_ptr, &file_id))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file")
- /* Get an ID for the file */
- if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle")
+ /* Set return value */
+ ret_value = file_id;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -826,7 +729,6 @@ done:
hid_t
H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
{
- H5VL_object_t *vol_obj = NULL; /* File object */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
@@ -836,14 +738,6 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
if ((ret_value = H5F__open_api_common(filename, flags, fapl_id, NULL)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to synchronously open file")
- /* Get the file object */
- if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
- HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier")
-
- /* Perform 'post open' operation */
- if (H5F__post_open_api_common(vol_obj, NULL) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "'post open' operation failed")
-
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fopen() */
@@ -864,7 +758,6 @@ hid_t
H5Fopen_async(const char *app_file, const char *app_func, unsigned app_line, const char *filename,
unsigned flags, hid_t fapl_id, hid_t es_id)
{
- H5VL_object_t *vol_obj = NULL; /* File object */
void * token = NULL; /* Request token for async operation */
void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -880,12 +773,14 @@ H5Fopen_async(const char *app_file, const char *app_func, unsigned app_line, con
if ((ret_value = H5F__open_api_common(filename, flags, fapl_id, token_ptr)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to asynchronously open file")
- /* Get the file object */
- if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
- HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier")
-
/* If a token was created, add the token to the event set */
- if (NULL != token)
+ if (NULL != token) {
+ H5VL_object_t *vol_obj = NULL; /* File object */
+
+ /* Get the file object */
+ if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
+ HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, H5I_INVALID_HID, "invalid object identifier")
+
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE7(FUNC, "*s*sIu*sIuii", app_file, app_func, app_line, filename, flags, fapl_id, es_id)) < 0) {
@@ -894,22 +789,7 @@ H5Fopen_async(const char *app_file, const char *app_func, unsigned app_line, con
HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID")
HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */
-
- /* Reset token for 'post open' operation */
- /* (Unnecessary if create operation didn't change it, but not worth checking -QAK) */
- token = NULL;
-
- /* Perform 'post open' operation */
- if (H5F__post_open_api_common(vol_obj, token_ptr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "'post open' operation failed")
-
- /* If a token was created, add the token to the event set */
- if (NULL != token)
- /* clang-format off */
- if (H5ES_insert(es_id, vol_obj->connector, token,
- H5ARG_TRACE7(FUNC, "*s*sIu*sIuii", app_file, app_func, app_line, filename, flags, fapl_id, es_id)) < 0)
- /* clang-format on */
- HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
+ } /* end if */
done:
FUNC_LEAVE_API(ret_value)
@@ -1462,7 +1342,6 @@ done:
hid_t
H5Freopen(hid_t file_id)
{
- H5VL_object_t *vol_obj = NULL; /* File object */
hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
@@ -1472,16 +1351,7 @@ H5Freopen(hid_t file_id)
if ((ret_value = H5F__reopen_api_common(file_id, NULL)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to synchronously reopen file")
- /* Get the file object */
- if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get handle for re-opened file")
-
- /* Perform 'post open' operation */
- if (H5F__post_open_api_common(vol_obj, NULL) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "'post open' operation failed")
-
done:
- /* XXX (VOL MERGE): If registration fails, file will not be closed */
FUNC_LEAVE_API(ret_value)
} /* end H5Freopen() */
@@ -1500,7 +1370,6 @@ done:
hid_t
H5Freopen_async(const char *app_file, const char *app_func, unsigned app_line, hid_t file_id, hid_t es_id)
{
- H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
void * token = NULL; /* Request token for async operation */
void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */
hid_t ret_value; /* Return value */
@@ -1516,12 +1385,14 @@ H5Freopen_async(const char *app_file, const char *app_func, unsigned app_line, h
if ((ret_value = H5F__reopen_api_common(file_id, token_ptr)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to asynchronously reopen file")
- /* Get the file object */
- if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get handle for re-opened file")
-
/* If a token was created, add the token to the event set */
- if (NULL != token)
+ if (NULL != token) {
+ H5VL_object_t *vol_obj = NULL; /* Object for loc_id */
+
+ /* Get the file object */
+ if (NULL == (vol_obj = H5VL_vol_object(ret_value)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't get handle for re-opened file")
+
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE5(FUNC, "*s*sIuii", app_file, app_func, app_line, file_id, es_id)) < 0) {
@@ -1530,22 +1401,7 @@ H5Freopen_async(const char *app_file, const char *app_func, unsigned app_line, h
HDONE_ERROR(H5E_FILE, H5E_CANTDEC, H5I_INVALID_HID, "can't decrement count on file ID")
HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
} /* end if */
-
- /* Reset token for 'post open' operation */
- /* (Unnecessary if create operation didn't change it, but not worth checking -QAK) */
- token = NULL;
-
- /* Perform 'post open' operation */
- if (H5F__post_open_api_common(vol_obj, token_ptr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "'post open' operation failed")
-
- /* If a token was created, add the token to the event set */
- if (NULL != token)
- /* clang-format off */
- if (H5ES_insert(es_id, vol_obj->connector, token,
- H5ARG_TRACE5(FUNC, "*s*sIuii", app_file, app_func, app_line, file_id, es_id)) < 0)
- /* clang-format on */
- HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set")
+ } /* end if */
done:
FUNC_LEAVE_API(ret_value)