diff options
-rw-r--r-- | src/H5CX.c | 223 | ||||
-rw-r--r-- | src/H5CXprivate.h | 8 | ||||
-rw-r--r-- | src/H5D.c | 15 | ||||
-rw-r--r-- | src/H5Ddeprec.c | 9 | ||||
-rw-r--r-- | src/H5Dint.c | 40 |
5 files changed, 42 insertions, 253 deletions
@@ -281,12 +281,6 @@ typedef struct H5CX_t { /* Cached DCPL properties */ hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ hbool_t do_min_dset_ohdr_valid; /* Whether minimize dataset object header flag is valid */ - hid_t vl_prop_dset_type_id; - hbool_t vl_prop_dset_type_id_valid; - hid_t vl_prop_dset_space_id; - hbool_t vl_prop_dset_space_id_valid; - hid_t vl_prop_dset_lcpl_id; - hbool_t vl_prop_dset_lcpl_id_valid; /* Cached DAPL properties */ char *extfile_prefix; @@ -352,9 +346,6 @@ typedef struct H5CX_lapl_cache_t { /* (Same as the cached DXPL struct, above, except for the default DCPL) */ typedef struct H5CX_dcpl_cache_t { hbool_t do_min_dset_ohdr; /* Whether to minimize dataset object header */ - hid_t vl_prop_dset_type_id; - hid_t vl_prop_dset_space_id; - hid_t vl_prop_dset_lcpl_id; } H5CX_dcpl_cache_t; /* Typedef for cached default dataset access property list information */ @@ -540,14 +531,6 @@ H5CX__init_package(void) if(H5P_get(dc_plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &H5CX_def_dcpl_cache.do_min_dset_ohdr) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "Can't retrieve dataset minimize flag") - if(H5P_get(dc_plist, H5VL_PROP_DSET_TYPE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") - if(H5P_get(dc_plist, H5VL_PROP_DSET_SPACE_ID, &H5CX_def_dcpl_cache.vl_prop_dset_space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id") - if(H5P_get(dc_plist, H5VL_PROP_DSET_LCPL_ID, &H5CX_def_dcpl_cache.vl_prop_dset_lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") - - /* Reset the "default DAPL cache" information */ HDmemset(&H5CX_def_dapl_cache, 0, sizeof(H5CX_dapl_cache_t)); @@ -2388,112 +2371,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_type_id - * - * Purpose: Retrieves the datatype ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_type_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_type_id); - - /* Get the value */ - *dset_type_id = (*head)->ctx.vl_prop_dset_type_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_type_id */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_space_id - * - * Purpose: Retrieves the space ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_space_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_SPACE_ID, vl_prop_dset_space_id); - - /* Get the value */ - *dset_space_id = (*head)->ctx.vl_prop_dset_space_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_space_id */ - - -/*------------------------------------------------------------------------- - * Function: H5CX_get_vl_prop_dset_space_id - * - * Purpose: Retrieves the LCPL ID of the dataset for VOL connector - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(dset_lcpl_id); - HDassert(head && *head); - HDassert(H5P_DEFAULT != (*head)->ctx.dcpl_id); - - H5CX_RETRIEVE_PROP_VALID(dcpl, H5P_DATASET_CREATE_DEFAULT, H5VL_PROP_DSET_TYPE_ID, vl_prop_dset_lcpl_id); - - /* Get the value */ - *dset_lcpl_id = (*head)->ctx.vl_prop_dset_lcpl_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_get_vl_prop_dset_lcpl_id */ - - - -/*------------------------------------------------------------------------- * Function: H5CX_get_ext_file_prefix * * Purpose: Retrieves the prefix for external file @@ -2877,106 +2754,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_set_nlinks() */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_type_id - * - * Purpose: Sets the datatype ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_type_id = dset_type_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_type_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_set_vl_prop_dset_type_id */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_space_id - * - * Purpose: Sets the data space ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_space_id = dset_space_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_space_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5CX_set_vl_prop_dset_space_id */ - -/*------------------------------------------------------------------------- - * Function: H5CX_set_vl_prop_dset_lcpl_id - * - * Purpose: Sets the LCPL ID of the dataset for the current API call context. - * - * Return: Non-negative on success / Negative on failure - * - * Programmer: Raymond Lu - * March 12, 2019 - * - *------------------------------------------------------------------------- - */ -herr_t -H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id) -{ - H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity check */ - HDassert(head && *head); - - /* Set the API context value */ - (*head)->ctx.vl_prop_dset_lcpl_id = dset_lcpl_id; - - /* Mark the value as valid */ - (*head)->ctx.vl_prop_dset_lcpl_id_valid = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index f022d8e..2248ac9 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -126,9 +126,6 @@ H5_DLL herr_t H5CX_get_nlinks(size_t *nlinks); /* "Getter" routines for DCPL properties cached in API context */ H5_DLL herr_t H5CX_get_dset_min_ohdr_flag(hbool_t *dset_min_ohdr_flag); -H5_DLL herr_t H5CX_get_vl_prop_dset_type_id(hid_t *dset_type_id); -H5_DLL herr_t H5CX_get_vl_prop_dset_space_id(hid_t *dset_space_id); -H5_DLL herr_t H5CX_get_vl_prop_dset_lcpl_id(hid_t *dset_lcpl_id); /* "Getter" routines for DAPL properties cached in API context */ H5_DLL herr_t H5CX_get_ext_file_prefix(char **prefix_extfile); @@ -152,11 +149,6 @@ H5_DLL herr_t H5CX_set_io_xfer_mode(H5FD_mpio_xfer_t io_xfer_mode); H5_DLL herr_t H5CX_set_vlen_alloc_info(H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); -/* "Setter" routines for DCPL properties cached in API context */ -H5_DLL herr_t H5CX_set_vl_prop_dset_type_id(hid_t dset_type_id); -H5_DLL herr_t H5CX_set_vl_prop_dset_space_id(hid_t dset_space_id); -H5_DLL herr_t H5CX_set_vl_prop_dset_lcpl_id(hid_t dset_lcpl_id); - /* "Setter" routines for LAPL properties cached in API context */ H5_DLL herr_t H5CX_set_nlinks(size_t nlinks); @@ -151,9 +151,12 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); - H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; @@ -244,8 +247,10 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 70e6f70..85371ae 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -148,9 +148,12 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* set creation properties */ - H5CX_set_vl_prop_dset_type_id(type_id); - H5CX_set_vl_prop_dset_space_id(space_id); - H5CX_set_vl_prop_dset_lcpl_id(lcpl_id); + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; diff --git a/src/H5Dint.c b/src/H5Dint.c index ae9a40e..7367613 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -43,6 +43,12 @@ /* Local Typedefs */ /******************/ +/* Type of prefix for file */ +typedef enum { + H5D_PREFIX_TYPE_UNKNOWN=0, + H5D_PREFIX_TYPE_EXT=1, + H5D_PREFIX_TYPE_VDS=2 +} H5D_prefix_type_t; /********************/ /* Local Prototypes */ @@ -54,7 +60,7 @@ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, cons static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); -static herr_t H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix); +static herr_t H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); @@ -112,6 +118,10 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ /* Flag indicating "top" of interface has been initialized */ static hbool_t H5D_top_package_initialize_s = FALSE; +/* Prefixes of VDS and external file from the environment variables + * HDF5_EXTFILE_PREFIX and HDF5_VDS_PREFIX */ +static char *H5D_prefix_ext_env = NULL; +static char *H5D_prefix_vds_env = NULL; /*------------------------------------------------------------------------- @@ -188,6 +198,10 @@ H5D__init_package(void) /* Mark "top" of interface as initialized, too */ H5D_top_package_initialize_s = TRUE; + /* Retrieve the prefixes of VDS and external file from the environment variable */ + H5D_prefix_vds_env = HDgetenv("HDF5_VDS_PREFIX"); + H5D_prefix_ext_env = HDgetenv("HDF5_EXTFILE_PREFIX"); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__init_package() */ @@ -1080,7 +1094,7 @@ done: *-------------------------------------------------------------------------- */ static herr_t -H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type, char **file_prefix /*out*/) +H5D__build_file_prefix(const H5D_t *dset, H5D_prefix_type_t prefix_type, char **file_prefix /*out*/) { char *prefix = NULL; /* prefix used to look for the file */ char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ @@ -1101,15 +1115,15 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type /* XXX: Future thread-safety note - getenv is not required * to be reentrant. */ - if(HDstrcmp(prefix_type, H5D_ACS_VDS_PREFIX_NAME) == 0) { - prefix = HDgetenv("HDF5_VDS_PREFIX"); + if(H5D_PREFIX_TYPE_VDS == prefix_type) { + prefix = H5D_prefix_vds_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_vds_prefix(&prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get the prefix for vds file") } - } else if(HDstrcmp(prefix_type, H5D_ACS_EFILE_PREFIX_NAME) == 0) { - prefix = HDgetenv("HDF5_EXTFILE_PREFIX"); + } else if(H5D_PREFIX_TYPE_EXT == prefix_type) { + prefix = H5D_prefix_ext_env; if(prefix == NULL || *prefix == '\0') { if(H5CX_get_ext_file_prefix(&prefix) < 0) @@ -1324,11 +1338,11 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ - if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &new_dset->shared->extfile_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_EXT, &new_dset->shared->extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Set the VDS file prefix */ - if(H5D__build_file_prefix(new_dset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &new_dset->shared->vds_prefix) < 0) + if(H5D__build_file_prefix(new_dset, H5D_PREFIX_TYPE_VDS, &new_dset->shared->vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Add the dataset to the list of opened objects in the file */ @@ -1483,11 +1497,11 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy path") /* Get the external file prefix */ - if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_EFILE_PREFIX_NAME, &extfile_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_EXT, &extfile_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize external file prefix") /* Get the VDS prefix */ - if(H5D__build_file_prefix(dataset, dapl_id, H5D_ACS_VDS_PREFIX_NAME, &vds_prefix) < 0) + if(H5D__build_file_prefix(dataset, H5D_PREFIX_TYPE_VDS, &vds_prefix) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize VDS prefix") /* Check if dataset was already open */ @@ -1550,10 +1564,8 @@ H5D_open(const H5G_loc_t *loc, hid_t dapl_id) ret_value = dataset; done: - if(extfile_prefix) - extfile_prefix = (char *)H5MM_xfree(extfile_prefix); - if(vds_prefix) - vds_prefix = (char *)H5MM_xfree(vds_prefix); + extfile_prefix = (char *)H5MM_xfree(extfile_prefix); + vds_prefix = (char *)H5MM_xfree(vds_prefix); if(ret_value == NULL) { /* Free the location--casting away const*/ |