Skip to content

Commit

Permalink
Brings over VOL props changes
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins committed Sep 4, 2021
1 parent 28d2593 commit b8ae3df
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 55 deletions.
6 changes: 3 additions & 3 deletions src/H5Pdxpl.c
Expand Up @@ -68,7 +68,7 @@
#define H5D_XFER_BTREE_SPLIT_RATIO_SIZE sizeof(double[3])
#define H5D_XFER_BTREE_SPLIT_RATIO_DEF \
{ \
0.1f, 0.5f, 0.9f \
0.1, 0.5, 0.9 \
}
#define H5D_XFER_BTREE_SPLIT_RATIO_ENC H5P__dxfr_btree_split_ratio_enc
#define H5D_XFER_BTREE_SPLIT_RATIO_DEC H5P__dxfr_btree_split_ratio_dec
Expand Down Expand Up @@ -2281,7 +2281,7 @@ herr_t
H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper_t op, const hsize_t start[],
const hsize_t stride[], const hsize_t count[], const hsize_t block[])
{
H5P_genplist_t *plist; /* Property list pointer */
H5P_genplist_t *plist = NULL; /* Property list pointer */
H5S_t * space; /* Dataspace to hold selection */
hbool_t space_created = FALSE; /* Whether a new dataspace has been created */
hbool_t reset_prop_on_error = FALSE; /* Whether to reset the property on failure */
Expand Down Expand Up @@ -2371,7 +2371,7 @@ H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper
done:
/* Cleanup on failure */
if (ret_value < 0) {
if (reset_prop_on_error && H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
if (reset_prop_on_error && plist && H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection")
if (space_created && H5S_close(space) < 0)
HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
Expand Down
58 changes: 58 additions & 0 deletions src/H5Pfapl.c
Expand Up @@ -5929,6 +5929,64 @@ H5Pget_vol_info(hid_t plist_id, void **vol_info /*out*/)
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_vol_info() */

/*-------------------------------------------------------------------------
* Function: H5Pget_vol_cap_flags
*
* Purpose: Queries the current VOL connector information for a FAPL to
* retrieve the capability flags for the VOL connector stack, as will
* be used by a file open or create operation that uses this FAPL.
*
* Current capability flags are:
* H5VL_CAP_FLAG_THREADSAFE - Connector is threadsafe
* H5VL_CAP_FLAG_ASYNC - Connector performs operations asynchronously
* H5VL_CAP_FLAG_NATIVE_FILES - Connector produces native file format
*
* Note: This routine supports the use of the HDF5_VOL_CONNECTOR environment
* environment variable to override the VOL connector set programmatically
* for the FAPL (with H5Pset_vol).
*
* Note: The H5VL_CAP_FLAG_ASYNC flag can be checked to see if asynchronous
* operations are supported by the VOL connector stack.
*
* Return: Success: Non-negative
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_vol_cap_flags(hid_t plist_id, unsigned *cap_flags)
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*Iu", plist_id, cap_flags);

/* Get the 'cap_flags' from the connector */
if (cap_flags) {
if (TRUE == H5P_isa_class(plist_id, H5P_FILE_ACCESS)) {
H5P_genplist_t * plist; /* Property list pointer */
H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */

/* Get property list for ID */
if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")

/* Get the connector property */
if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property")

/* Query the capability flags */
if (H5VL_get_cap_flags(&connector_prop, cap_flags) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector capability flags")
} /* end if */
else
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
} /* end if */

done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_vol_cap_flags() */

/*-------------------------------------------------------------------------
* Function: H5P__facc_vol_create
*
Expand Down
49 changes: 39 additions & 10 deletions src/H5Ppublic.h
Expand Up @@ -22,16 +22,17 @@

/* Public headers needed by this file */
#include "H5public.h"
#include "H5ACpublic.h"
#include "H5Dpublic.h"
#include "H5Fpublic.h"
#include "H5FDpublic.h"
#include "H5Ipublic.h"
#include "H5Lpublic.h"
#include "H5Opublic.h"
#include "H5MMpublic.h"
#include "H5Tpublic.h"
#include "H5Zpublic.h"
#include "H5ACpublic.h" /* Metadata cache */
#include "H5Dpublic.h" /* Datasets */
#include "H5Fpublic.h" /* Files */
#include "H5FDpublic.h" /* File drivers */
#include "H5Ipublic.h" /* ID management */
#include "H5Lpublic.h" /* Links */
#include "H5MMpublic.h" /* Memory management */
#include "H5Opublic.h" /* Object headers */
#include "H5Spublic.h" /* Dataspaces */
#include "H5Tpublic.h" /* Datatypes */
#include "H5Zpublic.h" /* Data filters */

/*****************/
/* Public Macros */
Expand Down Expand Up @@ -5212,6 +5213,34 @@ H5_DLL herr_t H5Pset_small_data_block_size(hid_t fapl_id, hsize_t size);
*/
H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info);

/**
* \ingroup FAPL
*
* \brief Query the capability flags for the VOL connector that will be used
* with this file access property list (FAPL).
*
* \fapl_id{plist_id}
* \param[out] cap_flags Flags that indicate the VOL connector capabilities
*
* \return \herr_t
*
* \details H5Pget_vol_cap_flags() queries the current VOL connector information
* for a FAPL to retrieve the capability flags for the VOL
* connector stack, as will be used by a file open or create
* operation that uses this FAPL.
*
* \note This routine supports the use of the HDF5_VOL_CONNECTOR environment
* variable to override the VOL connector set programmatically for the
* FAPL (with H5Pset_vol).
*
* \note The H5VL_CAP_FLAG_ASYNC flag can be checked to see if asynchronous
* operations are supported by the VOL connector stack.
*
* \since 1.13.0
*
*/
H5_DLL herr_t H5Pget_vol_cap_flags(hid_t plist_id, unsigned *cap_flags);

#ifdef H5_HAVE_PARALLEL
/**
* \ingroup GACPL
Expand Down
44 changes: 6 additions & 38 deletions src/H5VLcallback.c
Expand Up @@ -7358,29 +7358,19 @@ herr_t
H5VL_token_cmp(const H5VL_object_t *vol_obj, const H5O_token_t *token1, const H5O_token_t *token2,
int *cmp_value)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)

/* Sanity checks */
HDassert(vol_obj);
HDassert(cmp_value);

/* Set wrapper info in API context */
if (H5VL_set_vol_wrapper(vol_obj) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info")
vol_wrapper_set = TRUE;

/* Call the corresponding internal VOL routine */
if ((ret_value = H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value)) < 0)
if (H5VL__token_cmp(vol_obj->data, vol_obj->connector->cls, token1, token2, cmp_value) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "token compare failed")

done:
/* Reset object wrapping info in API context */
if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info")

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_token_cmp() */

Expand Down Expand Up @@ -7477,8 +7467,7 @@ herr_t
H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_token_t *token,
char **token_str)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)

Expand All @@ -7487,21 +7476,11 @@ H5VL_token_to_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const H5O_t
HDassert(token);
HDassert(token_str);

/* Set wrapper info in API context */
if (H5VL_set_vol_wrapper(vol_obj) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info")
vol_wrapper_set = TRUE;

/* Call the corresponding internal VOL routine */
if ((ret_value = H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str)) <
0)
if (H5VL__token_to_str(vol_obj->data, obj_type, vol_obj->connector->cls, token, token_str) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "token serialization failed")

done:
/* Reset object wrapping info in API context */
if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info")

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_token_to_str() */

Expand Down Expand Up @@ -7595,8 +7574,7 @@ herr_t
H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const char *token_str,
H5O_token_t *token)
{
hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
herr_t ret_value = SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)

Expand All @@ -7605,21 +7583,11 @@ H5VL_token_from_str(const H5VL_object_t *vol_obj, H5I_type_t obj_type, const cha
HDassert(token);
HDassert(token_str);

/* Set wrapper info in API context */
if (H5VL_set_vol_wrapper(vol_obj) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info")
vol_wrapper_set = TRUE;

/* Call the corresponding internal VOL routine */
if ((ret_value =
H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token)) < 0)
if (H5VL__token_from_str(vol_obj->data, obj_type, vol_obj->connector->cls, token_str, token) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "token deserialization failed")

done:
/* Reset object wrapping info in API context */
if (vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info")

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_token_from_str() */

Expand Down
3 changes: 3 additions & 0 deletions src/H5VLconnector.h
Expand Up @@ -1123,6 +1123,9 @@ H5_DLL hid_t H5VLpeek_connector_id_by_name(const char *name);
H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value);

/* User-defined optional operations */
H5_DLL herr_t H5VLregister_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val);
H5_DLL herr_t H5VLfind_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val);
H5_DLL herr_t H5VLunregister_opt_operation(H5VL_subclass_t subcls, const char *op_name);
H5_DLL herr_t H5VLattr_optional_op(const char *app_file, const char *app_func, unsigned app_line,
hid_t attr_id, H5VL_optional_args_t *args, hid_t dxpl_id, hid_t es_id);
H5_DLL herr_t H5VLgroup_optional_op(const char *app_file, const char *app_func, unsigned app_line,
Expand Down
42 changes: 42 additions & 0 deletions src/H5VLint.c
Expand Up @@ -2855,3 +2855,45 @@ H5VL_setup_token_args(hid_t loc_id, H5O_token_t *obj_token, H5VL_object_t **vol_
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_setup_token_args() */

/*-------------------------------------------------------------------------
* Function: H5VL_get_cap_flags
*
* Purpose: Query capability flags for connector property.
*
* Note: VOL connector set with HDF5_VOL_CONNECTOR overrides the
* property passed in.
*
* Return: Success: Non-negative
* Failure: Negative
*
*-------------------------------------------------------------------------
*/
herr_t
H5VL_get_cap_flags(const H5VL_connector_prop_t *connector_prop, unsigned *cap_flags)
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)

/* Sanity check */
HDassert(connector_prop);

/* Copy the connector ID & info, if there is one */
if (connector_prop->connector_id > 0) {
H5VL_class_t *connector; /* Pointer to connector */

/* Retrieve the connector for the ID */
if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id)))
HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID")

/* Query the connector's capability flags */
if (H5VL_introspect_get_cap_flags(connector_prop->connector_info, connector, cap_flags) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector's capability flags")
} /* end if */
else
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector ID not set?")

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_get_cap_flags() */
6 changes: 4 additions & 2 deletions src/H5VLpassthru.c
Expand Up @@ -212,6 +212,7 @@ static herr_t H5VL_pass_through_object_optional(void *obj, H5VL_object_optional_
/* Container/connector introspection callbacks */
static herr_t H5VL_pass_through_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl,
const H5VL_class_t **conn_cls);
static herr_t H5VL_pass_through_introspect_get_cap_flags(const void *info, unsigned *cap_flags);
static herr_t H5VL_pass_through_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type,
uint64_t *flags);

Expand Down Expand Up @@ -340,8 +341,9 @@ static const H5VL_class_t H5VL_pass_through_g = {
},
{
/* introspect_cls */
H5VL_pass_through_introspect_get_conn_cls, /* get_conn_cls */
H5VL_pass_through_introspect_opt_query, /* opt_query */
H5VL_pass_through_introspect_get_conn_cls, /* get_conn_cls */
H5VL_pass_through_introspect_get_cap_flags, /* get_cap_flags */
H5VL_pass_through_introspect_opt_query, /* opt_query */
},
{
/* request_cls */
Expand Down

0 comments on commit b8ae3df

Please sign in to comment.