diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/H5CX.c | 102 | ||||
-rw-r--r-- | src/H5CXprivate.h | 1 | ||||
-rw-r--r-- | src/H5Dprivate.h | 1 | ||||
-rw-r--r-- | src/H5F.c | 202 | ||||
-rw-r--r-- | src/H5Fefc.c | 132 | ||||
-rw-r--r-- | src/H5Fint.c | 94 | ||||
-rw-r--r-- | src/H5Fpkg.h | 6 | ||||
-rw-r--r-- | src/H5Fprivate.h | 3 | ||||
-rw-r--r-- | src/H5Fquery.c | 23 | ||||
-rw-r--r-- | src/H5Ldeprec.c | 12 | ||||
-rw-r--r-- | src/H5O.c | 4 | ||||
-rw-r--r-- | src/H5Odeprec.c | 12 | ||||
-rw-r--r-- | src/H5Pdxpl.c | 89 | ||||
-rw-r--r-- | src/H5Pprivate.h | 3 | ||||
-rw-r--r-- | src/H5Rdeprec.c | 6 | ||||
-rw-r--r-- | src/H5Rint.c | 54 | ||||
-rw-r--r-- | src/H5T.c | 32 | ||||
-rw-r--r-- | src/H5Tconv.c | 548 | ||||
-rw-r--r-- | src/H5Tpkg.h | 20 | ||||
-rw-r--r-- | src/H5Tref.c | 210 | ||||
-rw-r--r-- | src/H5Tvlen.c | 112 | ||||
-rw-r--r-- | src/H5VL.c | 2 | ||||
-rw-r--r-- | src/H5VLcallback.c | 972 | ||||
-rw-r--r-- | src/H5VLint.c | 65 | ||||
-rw-r--r-- | src/H5VLnative.c | 4 | ||||
-rw-r--r-- | src/H5VLnative.h | 8 | ||||
-rw-r--r-- | src/H5VLnative_file.c | 9 | ||||
-rw-r--r-- | src/H5VLprivate.h | 13 | ||||
-rw-r--r-- | src/H5VLtest.c | 10 | ||||
-rw-r--r-- | src/H5private.h | 37 | ||||
-rw-r--r-- | src/Makefile.am | 2 |
32 files changed, 1734 insertions, 1055 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff47c8e..dbd2c62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -520,6 +520,7 @@ set (H5P_SOURCES ) set (H5P_HDRS + ${HDF5_SRC_DIR}/H5Pdevelop.h ${HDF5_SRC_DIR}/H5Ppublic.h ) IDE_GENERATED_PROPERTIES ("H5P" "${H5P_HDRS}" "${H5P_SOURCES}" ) @@ -664,7 +664,7 @@ done: * Failure: Negative. * * Programmer: Quincey Koziol - * Februrary 22, 2018 + * February 22, 2018 * *------------------------------------------------------------------------- */ @@ -754,7 +754,7 @@ H5CX__get_context(void) * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 22, 2018 + * February 22, 2018 * *------------------------------------------------------------------------- */ @@ -795,7 +795,7 @@ H5CX__push_common(H5CX_node_t *cnode) * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 19, 2018 + * February 19, 2018 * *------------------------------------------------------------------------- */ @@ -828,7 +828,7 @@ done: * Return: <none> * * Programmer: Quincey Koziol - * Februrary 22, 2018 + * February 22, 2018 * *------------------------------------------------------------------------- */ @@ -850,6 +850,52 @@ H5CX_push_special(void) } /* end H5CX_push_special() */ /*------------------------------------------------------------------------- + * Function: H5CX_test_and_push + * + * Purpose: Pushes a context for an API call, if one isn't already pushed. + * + * Return: <none> + * + * Programmer: Quincey Koziol + * June 9, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_test_and_push(hbool_t *pushed) +{ + H5CX_node_t **head = NULL; /* Pointer to head of API context list */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(pushed); + + /* Check for API context already pushed */ + head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + if(NULL == *head) { + H5CX_node_t *cnode = NULL; /* Context node */ + + /* Allocate & clear API context node */ + if (NULL == (cnode = H5FL_CALLOC(H5CX_node_t))) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTALLOC, FAIL, "unable to allocate new struct") + + /* Set context info */ + H5CX__push_common(cnode); + + /* Indicate that the context was pushed */ + *pushed = TRUE; + } /* end if */ + else + /* Context was not pushed */ + *pushed = FALSE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_test_and_push() */ + +/*------------------------------------------------------------------------- * Function: H5CX_retrieve_state * * Purpose: Retrieve the state of an API context, for later resumption. @@ -1312,7 +1358,7 @@ H5CX_set_lapl(hid_t lapl_id) * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 19, 2018 + * February 19, 2018 * *------------------------------------------------------------------------- */ @@ -1567,7 +1613,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 20, 2018 + * February 20, 2018 * *------------------------------------------------------------------------- */ @@ -1699,7 +1745,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 20, 2018 + * February 20, 2018 * *------------------------------------------------------------------------- */ @@ -1729,7 +1775,7 @@ H5CX_get_tag(void) * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 22, 2018 + * February 22, 2018 * *------------------------------------------------------------------------- */ @@ -1761,7 +1807,7 @@ H5CX_get_ring(void) * Return: TRUE / FALSE on success / <can't fail> * * Programmer: Quincey Koziol - * Februrary 23, 2018 + * February 23, 2018 * *------------------------------------------------------------------------- */ @@ -1793,7 +1839,7 @@ H5CX_get_coll_metadata_read(void) * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -1889,7 +1935,7 @@ H5CX_get_mpio_rank0_bcast(void) * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 23, 2018 + * February 23, 2018 * *------------------------------------------------------------------------- */ @@ -1925,7 +1971,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 25, 2018 + * February 25, 2018 * *------------------------------------------------------------------------- */ @@ -1960,7 +2006,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 25, 2018 + * February 25, 2018 * *------------------------------------------------------------------------- */ @@ -1995,7 +2041,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 25, 2018 + * February 25, 2018 * *------------------------------------------------------------------------- */ @@ -2030,7 +2076,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 25, 2018 + * February 25, 2018 * *------------------------------------------------------------------------- */ @@ -2065,7 +2111,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 25, 2018 + * February 25, 2018 * *------------------------------------------------------------------------- */ @@ -2102,7 +2148,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 25, 2018 + * February 25, 2018 * *------------------------------------------------------------------------- */ @@ -2137,7 +2183,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -2353,7 +2399,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -2388,7 +2434,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -2423,7 +2469,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -2878,7 +2924,7 @@ done: * Return: <none> * * Programmer: Quincey Koziol - * Februrary 20, 2018 + * February 20, 2018 * *------------------------------------------------------------------------- */ @@ -2906,7 +2952,7 @@ H5CX_set_tag(haddr_t tag) * Return: <none> * * Programmer: Quincey Koziol - * Februrary 20, 2018 + * February 20, 2018 * *------------------------------------------------------------------------- */ @@ -2936,7 +2982,7 @@ H5CX_set_ring(H5AC_ring_t ring) * Return: <none> * * Programmer: Quincey Koziol - * Februrary 23, 2018 + * February 23, 2018 * *------------------------------------------------------------------------- */ @@ -2966,7 +3012,7 @@ H5CX_set_coll_metadata_read(hbool_t cmdr) * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -2999,7 +3045,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -3033,7 +3079,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 26, 2018 + * February 26, 2018 * *------------------------------------------------------------------------- */ @@ -3658,7 +3704,7 @@ done: * Return: Non-negative on success / Negative on failure * * Programmer: Quincey Koziol - * Februrary 19, 2018 + * February 19, 2018 * *------------------------------------------------------------------------- */ diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index c500356..53bcc4c 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -63,6 +63,7 @@ typedef struct H5CX_state_t { /* Library private routines */ #ifndef H5private_H H5_DLL herr_t H5CX_push(void); +H5_DLL herr_t H5CX_test_and_push(hbool_t *pushed); H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); #endif /* H5private_H */ H5_DLL void H5CX_push_special(void); diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index ad9794d..20065d7 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -85,6 +85,7 @@ #define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ #define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ #define H5D_XFER_DSET_IO_SEL_NAME "dset_io_selection" /* Dataset I/O selection */ +#define H5D_XFER_PLUGIN_NEW_API_CTX_NAME "plugin_new_api_context" /* Plugin new API context */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /* Collective chunk instrumentation properties */ #define H5D_XFER_COLL_CHUNK_LINK_HARD_NAME "coll_chunk_link_hard" @@ -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) diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 3f9a22f..50f8a7d 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -63,6 +63,7 @@ struct H5F_efc_t { }; /* Private prototypes */ +static H5F_t *H5F__efc_open_real(const char *name, unsigned flags, hid_t fapl_id); static herr_t H5F__efc_release_real(H5F_efc_t *efc); static herr_t H5F__efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent); static void H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail); @@ -119,6 +120,80 @@ done: } /* end H5F__efc_create() */ /*------------------------------------------------------------------------- + * Function: H5F__efc_open_real + * + * Purpose: Opens a file for the external file cache 'open' operation. + * + * Return: Pointer to open file on success + * NULL on failure + * + * Programmer: Quincey Koziol + * Saturday, June 12, 2021 + * + *------------------------------------------------------------------------- + */ +static H5F_t * +H5F__efc_open_real(const char *name, unsigned flags, hid_t fapl_id) +{ + H5VL_object_t *file_obj = NULL; /* Pointer to file VOL object */ + H5F_t *file = NULL; /* Pointer to opened file */ + hbool_t is_native; /* Whether the file VOL object is using the native VOL connector */ + H5F_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(name); + + /* The data structures and algorithms that use this routine currently depend on + * having a native file object (H5F_t*). It seems possible to convert + * them to using a file VOL object (H5VL_object_t*), but that appears to + * be a fairly intensive task, so fail if the file VOL object is not using + * a "trivial" VOL connector stack, composed of only the native connector + * as the terminal connector, without any pass-through connectors. + */ + is_native = FALSE; + if (H5VL_fapl_is_native(fapl_id, &is_native) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't check for native VOL connector") + if (!is_native) + HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, NULL, "can't open files w/non-native VOL connector") + + /* Open the file VOL object */ + if (NULL == (file_obj = H5VL_file_open(name, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, NULL, NULL))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") + + /* Get native file pointer from VOL object */ + if (NULL == (file = H5VL_object_data(file_obj))) { + /* Close opened file */ + if (H5F__close_obj(file_obj, NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close file") + + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get native file pointer") + } /* end if */ + + /* Release VOL object */ + if (H5VL_free_object(file_obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't release file VOL object") + file_obj = NULL; + + /* Increment the number of open objects to prevent the file from being + * closed out from under us - "simulate" having an open file id. Note + * that this behaviour replaces the calls to H5F_incr_nopen_objs() and + * H5F_decr_nopen_objs() in H5L_extern_traverse(). + */ + /* NOTE: This assumes that file object is a _native_ file object and + * won't work with passthrough VOL connectors. + */ + file->nopen_objs++; + + /* Set return value */ + ret_value = file; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__efc_open_real() */ + +/*------------------------------------------------------------------------- * Function: H5F__efc_open * * Purpose: Opens a file using the external file cache. The target @@ -138,13 +213,11 @@ done: *------------------------------------------------------------------------- */ H5F_t * -H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) +H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fapl_id) { H5F_efc_t * efc = NULL; /* External file cache for parent file */ H5F_efc_ent_t * ent = NULL; /* Entry for target file in efc */ hbool_t open_file = FALSE; /* Whether ent->file needs to be closed in case of error */ - H5P_genplist_t * plist; /* Property list pointer for FAPL */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ H5F_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -154,38 +227,16 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi HDassert(parent->shared); HDassert(name); - /* Get the VOL info from the fapl */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, NULL, "not a file access property list") - if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "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, NULL, "can't set VOL connector info in API context") - /* Get external file cache */ efc = parent->shared->efc; - /* Check if the EFC exists. If it does not, just call H5F_open(). We + /* Check if the EFC exists. If it does not, just open the file. We * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ if (!efc) { - if (NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (ret_value = H5F__efc_open_real(name, flags, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") - /* Make file post open call */ - if (H5F__post_open(ret_value) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") - - /* Increment the number of open objects to prevent the file from being - * closed out from under us - "simulate" having an open file id. Note - * that this behaviour replaces the calls to H5F_incr_nopen_objs() and - * H5F_decr_nopen_objs() in H5L_extern_traverse(). */ - ret_value->nopen_objs++; - HGOTO_DONE(ret_value) } /* end if */ @@ -250,18 +301,9 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi } /* end if */ else { /* Cannot cache file, just open file and return */ - if (NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (ret_value = H5F__efc_open_real(name, flags, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") - /* Make file post open call */ - if (H5F__post_open(ret_value) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") - - /* Increment the number of open objects to prevent the file from - * being closed out from under us - "simulate" having an open - * file id */ - ret_value->nopen_objs++; - HGOTO_DONE(ret_value) } /* end else */ } /* end if */ @@ -275,18 +317,10 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Open the file */ - if (NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id))) + if (NULL == (ent->file = H5F__efc_open_real(name, flags, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") open_file = TRUE; - /* Make file post open call */ - if (H5F__post_open(ent->file) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't finish opening file") - - /* Increment the number of open objects to prevent the file from being - * closed out from under us - "simulate" having an open file id */ - ent->file->nopen_objs++; - /* Add the file to the cache */ /* Skip list */ if (H5SL_insert(efc->slist, ent, ent->name) < 0) @@ -372,6 +406,9 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ if (!efc) { + /* NOTE: This assumes that file object is a _native_ file object and + * won't work with passthrough VOL connectors. + */ file->nopen_objs--; if (H5F_try_close(file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") @@ -387,6 +424,9 @@ H5F_efc_close(H5F_t *parent, H5F_t *file) for (ent = efc->LRU_head; ent && ent->file != file; ent = ent->LRU_next) ; if (!ent) { + /* NOTE: This assumes that file object is a _native_ file object and + * won't work with passthrough VOL connectors. + */ file->nopen_objs--; if (H5F_try_close(file, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file") diff --git a/src/H5Fint.c b/src/H5Fint.c index c2d3e77..4118beb 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -218,6 +218,38 @@ H5F_term_package(void) } /* end H5F_term_package() */ /*------------------------------------------------------------------------- + * Function: H5F__close_obj + * + * Purpose: Close a file VOL object, possibly asynchronously. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5F__close_obj(H5VL_object_t *file_vol_obj, void **request) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(file_vol_obj); + + /* Close the file */ + if (H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + + /* Free the VOL object; it is unnecessary to unwrap the VOL + * object before freeing it, as the object was not wrapped */ + if (H5VL_free_object(file_vol_obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__close_obj() */ + +/*------------------------------------------------------------------------- * Function: H5F__close_cb * * Purpose: Closes a file or causes the close operation to be pended. @@ -244,15 +276,10 @@ H5F__close_cb(H5VL_object_t *file_vol_obj, void **request) /* Sanity check */ HDassert(file_vol_obj); - /* Close the file */ - if (H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, request) < 0) + /* Close the file object */ + if (H5F__close_obj(file_vol_obj, request) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") - /* Free the VOL object; it is unnecessary to unwrap the VOL - * object before freeing it, as the object was not wrapped */ - if (H5VL_free_object(file_vol_obj) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__close_cb() */ @@ -302,6 +329,7 @@ static herr_t H5F__set_vol_conn(H5F_t *file) { H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + const H5VL_class_t *vol_cls; /* Pointer to VOL connector class for the container */ void * new_connector_info = NULL; /* Copy of connector info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -320,13 +348,12 @@ H5F__set_vol_conn(H5F_t *file) HDassert(0 != connector_prop.connector_id); /* Retrieve the connector for the ID */ - if (NULL == (file->shared->vol_cls = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) + if (NULL == (vol_cls = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID") /* Allocate and copy connector info, if it exists */ if (connector_prop.connector_info) - if (H5VL_copy_connector_info(file->shared->vol_cls, &new_connector_info, - connector_prop.connector_info) < 0) + if (H5VL_copy_connector_info(vol_cls, &new_connector_info, connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed") /* Cache the connector ID & info for the container */ @@ -858,7 +885,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Target file_name is an absolute pathname: see RM for detailed description */ if (H5_CHECK_ABSOLUTE(file_name) || H5_CHECK_ABS_PATH(file_name)) { /* Try opening file */ - src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, file_name, file_intent, fapl_id); /* Adjust temporary file name if file not opened */ if (NULL == src_file) { @@ -881,7 +908,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c } /* end if */ else if (H5_CHECK_ABS_DRIVE(file_name)) { /* Try opening file */ - src_file = H5F__efc_open(primary_file, file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, file_name, file_intent, fapl_id); /* Adjust temporary file name if file not opened */ if (NULL == src_file) { @@ -926,8 +953,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c } /* end if */ /* Try opening file */ - src_file = - H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, full_name, file_intent, fapl_id); /* Release copy of file name */ full_name = (char *)H5MM_xfree(full_name); @@ -939,7 +965,6 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Leave if file was opened */ else break; - H5E_clear_stack(NULL); } /* end if */ } /* end while */ @@ -954,7 +979,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") /* Try opening file */ - src_file = H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, full_name, file_intent, fapl_id); /* Release name */ full_name = (char *)H5MM_xfree(full_name); @@ -975,7 +1000,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't prepend prefix to filename") /* Try opening file */ - src_file = H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, full_name, file_intent, fapl_id); /* Release name */ full_name = (char *)H5MM_xfree(full_name); @@ -990,7 +1015,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c /* Try the relative file_name stored in temp_file_name */ if (src_file == NULL) { /* Try opening file */ - src_file = H5F__efc_open(primary_file, temp_file_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, temp_file_name, file_intent, fapl_id); /* Check for file not opened */ if (NULL == src_file) @@ -1018,7 +1043,7 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c actual_file_name = (char *)H5MM_xfree(actual_file_name); /* Try opening with the resolved name */ - src_file = H5F__efc_open(primary_file, full_name, file_intent, H5P_FILE_CREATE_DEFAULT, fapl_id); + src_file = H5F__efc_open(primary_file, full_name, file_intent, fapl_id); /* Release name */ full_name = (char *)H5MM_xfree(full_name); @@ -1121,7 +1146,6 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F if (NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->id_exists = FALSE; if (shared) { HDassert(lf == NULL); @@ -1596,7 +1620,6 @@ H5F__dest(H5F_t *f, hbool_t flush) if (H5I_dec_ref(f->shared->vol_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID") - f->shared->vol_cls = NULL; /* Close the file */ if (H5FD_close(f->shared->lf) < 0) @@ -1630,15 +1653,15 @@ H5F__dest(H5F_t *f, hbool_t flush) f->open_name = (char *)H5MM_xfree(f->open_name); f->actual_name = (char *)H5MM_xfree(f->actual_name); if (f->vol_obj) { - void *vol_wrap_ctx = NULL; +// void *vol_wrap_ctx = NULL; /* If a VOL wrapping context is available, retrieve it * and unwrap file VOL object */ - if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL object wrap context") - if (vol_wrap_ctx && (NULL == H5VL_object_unwrap(f->vol_obj))) - HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't unwrap VOL object") +// if (H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) +// HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL object wrap context") +// if (vol_wrap_ctx && (NULL == H5VL_object_unwrap(f->vol_obj))) +// HDONE_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't unwrap VOL object") if (H5VL_free_object(f->vol_obj) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") @@ -2124,21 +2147,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F__post_open(H5F_t *f) +H5F__post_open(H5F_t *f, H5VL_object_t *vol_obj, hbool_t id_exists) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Sanity check arguments */ HDassert(f); + HDassert(vol_obj); - /* Store a vol object in the file struct */ - if (NULL == (f->vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, f, f->shared->vol_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't create VOL object") + /* Have an ID now? */ + f->id_exists = id_exists; -done: - FUNC_LEAVE_NOAPI(ret_value) + /* Store a VOL object in the file struct */ + (void)H5VL_object_inc_rc(vol_obj); + f->vol_obj = vol_obj; + + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5F__post_open() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index b016696..c9557d6 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -310,7 +310,6 @@ struct H5F_shared_t { /* Cached VOL connector ID & info */ hid_t vol_id; /* ID of VOL connector for the container */ - const H5VL_class_t *vol_cls; /* Pointer to VOL connector class for the container */ void * vol_info; /* Copy of VOL connector info for container */ /* File space allocation information */ @@ -404,7 +403,7 @@ H5_DLLVAR htri_t use_locks_env_g; /******************************/ /* General routines */ -H5_DLL herr_t H5F__post_open(H5F_t *f); +H5_DLL herr_t H5F__post_open(H5F_t *f, H5VL_object_t *vol_obj, hbool_t id_exists); H5_DLL H5F_t *H5F__reopen(H5F_t *f); H5_DLL herr_t H5F__flush(H5F_t *f); H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); @@ -413,6 +412,7 @@ H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); H5_DLL herr_t H5F__format_convert(H5F_t *f); H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); H5_DLL herr_t H5F__close(H5F_t *f); +H5_DLL herr_t H5F__close_obj(H5VL_object_t *file_vol_obj, void **request); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); H5_DLL herr_t H5F__get_cont_info(const H5F_t *f, H5VL_file_cont_info_t *info); H5_DLL herr_t H5F__parse_file_lock_env_var(htri_t *use_locks); @@ -456,7 +456,7 @@ H5_DLL herr_t H5F__set_mpi_atomicity(H5F_t *file, hbool_t flag); /* External file cache routines */ H5_DLL H5F_efc_t *H5F__efc_create(unsigned max_nfiles); -H5_DLL H5F_t * H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL H5F_t * H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fapl_id); H5_DLL unsigned H5F__efc_max_nfiles(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 051abd9..7298b17 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -379,7 +379,6 @@ typedef struct H5F_t H5F_t; #define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr) #define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) #define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) -#define H5F_VOL_CLS(F) ((F)->shared->vol_cls) #define H5F_VOL_OBJ(F) ((F)->vol_obj) #define H5F_USE_FILE_LOCKING(F) ((F)->shared->use_file_locking) #else /* H5F_MODULE */ @@ -442,7 +441,6 @@ typedef struct H5F_t H5F_t; #define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F)) #define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) #define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) -#define H5F_VOL_CLS(F) (H5F_get_vol_cls(F)) #define H5F_VOL_OBJ(F) (H5F_get_vol_obj(F)) #define H5F_USE_FILE_LOCKING(F) (H5F_get_use_file_locking(F)) #endif /* H5F_MODULE */ @@ -859,7 +857,6 @@ H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); H5_DLL hbool_t H5F_get_null_fsm_addr(const H5F_t *f); H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); -H5_DLL const H5VL_class_t *H5F_get_vol_cls(const H5F_t *f); H5_DLL H5VL_object_t *H5F_get_vol_obj(const H5F_t *f); H5_DLL hbool_t H5F_get_file_locking(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 04792b4..e57744c 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -1222,29 +1222,6 @@ H5F_get_null_fsm_addr(const H5F_t *f) } /* end H5F_get_null_fsm_addr() */ /*------------------------------------------------------------------------- - * Function: H5F_get_vol_cls - * - * Purpose: Get the VOL class for the file - * - * Return: VOL class pointer for file, can't fail - * - * Programmer: Quincey Koziol - * Saturday, August 17, 2019 - * - *------------------------------------------------------------------------- - */ -const H5VL_class_t * -H5F_get_vol_cls(const H5F_t *f) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(f); - HDassert(f->shared); - - FUNC_LEAVE_NOAPI(f->shared->vol_cls) -} /* end H5F_get_vol_cls */ - -/*------------------------------------------------------------------------- * Function: H5F_get_vol_obj * * Purpose: Get the VOL object for the file diff --git a/src/H5Ldeprec.c b/src/H5Ldeprec.c index 01e77f9..6fa6401 100644 --- a/src/H5Ldeprec.c +++ b/src/H5Ldeprec.c @@ -168,7 +168,7 @@ H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, @@ -259,7 +259,7 @@ H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, @@ -340,7 +340,7 @@ H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t l HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, @@ -435,7 +435,7 @@ H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, @@ -538,7 +538,7 @@ H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterat HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, @@ -631,7 +631,7 @@ H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, @@ -120,9 +120,9 @@ H5O__open_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token H5P_DATASET_XFER_DEFAULT, token_ptr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") - /* Get an atom for the object */ + /* Get an ID for the object */ if ((ret_value = H5VL_register(opened_type, opened_obj, (*vol_obj_ptr)->connector, TRUE)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get ID for object handle") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 7def20a..136260c 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -365,7 +365,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") if (is_native_vol_obj) { @@ -584,7 +584,7 @@ H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo /*out*/, unsigned fields) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) @@ -650,7 +650,7 @@ H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo /*out*/, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) @@ -722,7 +722,7 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) @@ -976,7 +976,7 @@ H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) @@ -1081,7 +1081,7 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_it HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check if the VOL object is a native VOL connector object */ - if (H5VL_object_is_native(vol_obj, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "can't determine if VOL object is native connector object") if (!is_native_vol_obj) diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 046b046..54ce509 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -169,6 +169,11 @@ #define H5D_XFER_DSET_IO_SEL_ENC H5P__dxfr_edc_enc #define H5D_XFER_DSET_IO_SEL_DEC H5P__dxfr_edc_dec #endif /* QAK */ +/* Definition for property */ +#define H5D_XFER_PLUGIN_NEW_API_CTX_SIZE sizeof(hbool_t) +#define H5D_XFER_PLUGIN_NEW_API_CTX_DEF FALSE +#define H5D_XFER_PLUGIN_NEW_API_CTX_ENC H5P__encode_hbool_t +#define H5D_XFER_PLUGIN_NEW_API_CTX_DEC H5P__decode_hbool_t /******************/ /* Local Typedefs */ @@ -278,6 +283,8 @@ static const H5T_conv_cb_t H5D_def_conv_cb_g = static const void * H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */ static const H5S_t *H5D_def_dset_io_sel_g = H5D_XFER_DSET_IO_SEL_DEF; /* Default value for dataset I/O selection */ +static const hbool_t H5D_def_new_api_ctx_g = + H5D_XFER_PLUGIN_NEW_API_CTX_DEF; /* Default value for plugin new API context */ /*------------------------------------------------------------------------- * Function: H5P__dxfr_reg_prop @@ -442,6 +449,13 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass) H5D_XFER_DSET_IO_SEL_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the plugin new API context property */ + if (H5P__register_real(pclass, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, H5D_XFER_PLUGIN_NEW_API_CTX_SIZE, + &H5D_def_new_api_ctx_g, NULL, NULL, NULL, + H5D_XFER_PLUGIN_NEW_API_CTX_ENC, H5D_XFER_PLUGIN_NEW_API_CTX_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dxfr_reg_prop() */ @@ -2281,7 +2295,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 */ @@ -2379,3 +2393,76 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_dataset_io_hyperslab_selection() */ + +/*------------------------------------------------------------------------- + * Function: H5Pset_plugin_new_api_context + * + * Purpose: Set flag to indicate that an API wrapper for a plugin's + * public wrapper API call (e.g. H5VLfile_create, H5FDopen, etc) + * should open a new API context for the API call. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Jun 11, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_plugin_new_api_context(hid_t plist_id, hbool_t new_api_ctx) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ib", plist_id, new_api_ctx); + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID") + + /* Update property list */ + if (H5P_set(plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &new_api_ctx) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_plugin_new_api_context() */ + +/*------------------------------------------------------------------------- + * Function: H5Pget_plugin_new_api_context + * + * Purpose: Retrieve "new API context" flag for plugin wrapper API calls. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Jun 11, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_plugin_new_api_context(hid_t plist_id, hbool_t *new_api_ctx /*out*/) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ix", plist_id, new_api_ctx); + + /* Check argument */ + if (NULL == new_api_ctx) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "'new_api_ctx' pointer is NULL") + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_PLIST, H5E_BADID, FAIL, "can't find object for ID") + + /* Query property list */ + if (H5P_get(plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, new_api_ctx) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_plugin_new_api_context() */ + diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 6ebe5d3..42e1d6e 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -20,7 +20,8 @@ /* Early typedefs to avoid circular dependencies */ typedef struct H5P_genplist_t H5P_genplist_t; -/* Include package's public header */ +/* Include package's public headers */ +#include "H5Pdevelop.h" #include "H5Ppublic.h" /* Private headers needed by this file */ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 3f1d70f..e18b7f9 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -104,7 +104,7 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(vol_obj, &is_native) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -409,7 +409,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(vol_obj, &is_native) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -659,7 +659,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(vol_obj, &is_native) < 0) + if (H5VL_object_is_native(vol_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "can't query if file uses native VOL connector") diff --git a/src/H5Rint.c b/src/H5Rint.c index e1a5dcd..78b6b38 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -542,12 +542,8 @@ H5R__get_loc_id(const H5R_ref_priv_t *ref) hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) { - H5P_genplist_t * plist; /* Property list for FAPL */ - void * new_file = NULL; /* File object opened */ - H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_object_t * vol_obj = NULL; /* VOL object for file */ - uint64_t supported; /* Whether 'post open' operation is supported by VOL connector */ - hid_t ret_value = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; /* New file's ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_PACKAGE @@ -557,54 +553,18 @@ H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, 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_REFERENCE, 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_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, - "can't set VOL connector info in API context") - /* Open the file */ /* (Must open file read-write to allow for object modifications) */ - if (NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == H5VL_file_open(H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &file_id)) HGOTO_ERROR(H5E_REFERENCE, 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_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle") - - /* Get the file object */ - if (NULL == (vol_obj = H5VL_vol_object(ret_value))) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "invalid object identifier") - - /* Make the '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_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "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, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5I_INVALID_HID, - "unable to make file 'post open' callback") - } /* end if */ - /* Attach loc_id to reference */ - if (H5R__set_loc_id((H5R_ref_priv_t *)ref, ret_value, FALSE, TRUE) < 0) + if (H5R__set_loc_id((H5R_ref_priv_t *)ref, file_id, FALSE, TRUE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, H5I_INVALID_HID, "unable to attach location id to reference") + /* Set return value */ + ret_value = file_id; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__reopen_file() */ @@ -253,7 +253,7 @@ H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \ H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \ dt->shared->force_conv = TRUE; \ - dt->shared->u.atomic.u.r.file = NULL; \ + dt->shared->u.atomic.u.r.file_obj = NULL; \ dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; \ dt->shared->u.atomic.u.r.cls = NULL; \ } @@ -4821,9 +4821,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) } /* Don't allow VL types in different files to compare as equal */ - if (dt1->shared->u.vlen.file < dt2->shared->u.vlen.file) + if (dt1->shared->u.vlen.file_obj < dt2->shared->u.vlen.file_obj) HGOTO_DONE(-1); - if (dt1->shared->u.vlen.file > dt2->shared->u.vlen.file) + if (dt1->shared->u.vlen.file_obj > dt2->shared->u.vlen.file_obj) HGOTO_DONE(1); break; @@ -4970,9 +4970,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) HGOTO_DONE(-1); if (dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc) HGOTO_DONE(1); - if (dt1->shared->u.atomic.u.r.file < dt2->shared->u.atomic.u.r.file) + if (dt1->shared->u.atomic.u.r.file_obj < dt2->shared->u.atomic.u.r.file_obj) HGOTO_DONE(-1); - if (dt1->shared->u.atomic.u.r.file > dt2->shared->u.atomic.u.r.file) + if (dt1->shared->u.atomic.u.r.file_obj > dt2->shared->u.atomic.u.r.file_obj) HGOTO_DONE(1); break; @@ -5832,7 +5832,7 @@ done: USAGE htri_t H5T_set_loc(dt,f,loc) H5T_t *dt; IN/OUT: Pointer to the datatype to mark - H5F_t *f; IN: Pointer to the file the datatype is in + H5VL_object_t *file_obj; IN: Pointer to the VOL file object the datatype is in H5T_loc_t loc IN: location of type RETURNS @@ -5846,7 +5846,7 @@ done: -------------------------------------------------------------------------- */ htri_t -H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) +H5T_set_loc(H5T_t *dt, H5VL_object_t *file_obj, H5T_loc_t loc) { htri_t changed; /* Whether H5T_set_loc changed the type (even if the size didn't change) */ htri_t ret_value = 0; /* Indicate that success, but no location change */ @@ -5871,7 +5871,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) old_size = dt->shared->parent->shared->size; /* Mark the VL, compound or array type */ - if ((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) + if ((changed = H5T_set_loc(dt->shared->parent, file_obj, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if (changed > 0) ret_value = changed; @@ -5912,7 +5912,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) old_size = memb_type->shared->size; /* Mark the VL, compound, enum or array type */ - if ((changed = H5T_set_loc(memb_type, file, loc)) < 0) + if ((changed = H5T_set_loc(memb_type, file_obj, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if (changed > 0) ret_value = changed; @@ -5951,14 +5951,14 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) if (dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type) && (dt->shared->parent->shared->type != H5T_REFERENCE)) { - if ((changed = H5T_set_loc(dt->shared->parent, file, loc)) < 0) + if ((changed = H5T_set_loc(dt->shared->parent, file_obj, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if (changed > 0) ret_value = changed; } /* end if */ /* Mark this VL sequence */ - if ((changed = H5T__vlen_set_loc(dt, file, loc)) < 0) + if ((changed = H5T__vlen_set_loc(dt, file_obj, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); if (changed > 0) ret_value = changed; @@ -5966,7 +5966,7 @@ H5T_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) case H5T_REFERENCE: /* Reference types go through type conversion */ - if ((ret_value = H5T__ref_set_loc(dt, file, loc)) < 0) + if ((ret_value = H5T__ref_set_loc(dt, file_obj, loc)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "Unable to set reference location"); break; @@ -6308,17 +6308,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file) +H5T_patch_vlen_file(H5T_t *dt, H5VL_object_t *file_obj) { FUNC_ENTER_NOAPI_NOINIT_NOERR /* Sanity check */ HDassert(dt); HDassert(dt->shared); - HDassert(file); + HDassert(file_obj); - if ((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.file != file) - dt->shared->u.vlen.file = file; + if ((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.file_obj != file_obj) + dt->shared->u.vlen.file_obj = file_obj; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5T_patch_vlen_file() */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 0c98633..f4796c8 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -3161,283 +3161,283 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si /* QAK - Nothing to do currently */ break; - case H5T_CONV_CONV: - /* - * Conversion. - */ - if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - /* Initialize source & destination strides */ - if (buf_stride) { - HDassert(buf_stride >= src->shared->size); - HDassert(buf_stride >= dst->shared->size); - H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); - s_stride = d_stride = (ssize_t)buf_stride; - } /* end if */ - else { - H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); - H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); - s_stride = (ssize_t)src->shared->size; - d_stride = (ssize_t)dst->shared->size; - } /* end else */ - if (bkg) { - if (bkg_stride) - b_stride = (ssize_t)bkg_stride; - else - b_stride = d_stride; - } /* end if */ - else - b_stride = 0; - - /* Get the size of the base types in src & dst */ - src_base_size = H5T_get_size(src->shared->parent); - dst_base_size = H5T_get_size(dst->shared->parent); - - /* Set up conversion path for base elements */ - if (NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unable to convert between src and dest datatypes") - else if (!H5T_path_noop(tpath)) { - H5T_t *tsrc_cpy = NULL, *tdst_cpy = NULL; - - if (NULL == (tsrc_cpy = H5T_copy(src->shared->parent, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy src type for conversion") - /* References need to know about the src file */ - if (tsrc_cpy->shared->type == H5T_REFERENCE) - if (H5T_set_loc(tsrc_cpy, src->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); - - if (NULL == (tdst_cpy = H5T_copy(dst->shared->parent, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy dst type for conversion") - /* References need to know about the dst file */ - if (tdst_cpy->shared->type == H5T_REFERENCE) - if (H5T_set_loc(tdst_cpy, dst->shared->u.vlen.file, H5T_LOC_MEMORY) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); - - if (((tsrc_id = H5I_register(H5I_DATATYPE, tsrc_cpy, FALSE)) < 0) || - ((tdst_id = H5I_register(H5I_DATATYPE, tdst_cpy, FALSE)) < 0)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, - "unable to register types for conversion") - } /* end else-if */ - else - noop_conv = TRUE; - - /* Check if we need a temporary buffer for this conversion */ - if ((parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_SYSTEM, FAIL, - "internal error when detecting variable-length class") - if (tpath->cdata.need_bkg || parent_is_vlen) { - /* Set up initial background buffer */ - tmp_buf_size = MAX(src_base_size, dst_base_size); - if (NULL == (tmp_buf = H5FL_BLK_CALLOC(vlen_seq, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "memory allocation failed for type conversion") - } /* end if */ - - /* Get the allocation info */ - if (H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") + case H5T_CONV_CONV: { + H5T_vlen_t *src_vl; /* Source VL type info */ + H5T_vlen_t *dst_vl; /* Destination VL type info */ - /* Set flags to indicate we are writing to or reading from the file */ - if (dst->shared->u.vlen.file != NULL) - write_to_file = TRUE; + /* + * Conversion. + */ + if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + src_vl = &src->shared->u.vlen; + dst_vl = &dst->shared->u.vlen; - /* Set the flag for nested VL case */ - if (write_to_file && parent_is_vlen && bkg != NULL) - nested = TRUE; + /* Initialize source & destination strides */ + if (buf_stride) { + HDassert(buf_stride >= src->shared->size); + HDassert(buf_stride >= dst->shared->size); + H5_CHECK_OVERFLOW(buf_stride, size_t, ssize_t); + s_stride = d_stride = (ssize_t)buf_stride; + } /* end if */ + else { + H5_CHECK_OVERFLOW(src->shared->size, size_t, ssize_t); + H5_CHECK_OVERFLOW(dst->shared->size, size_t, ssize_t); + s_stride = (ssize_t)src->shared->size; + d_stride = (ssize_t)dst->shared->size; + } /* end else */ + if (bkg) { + if (bkg_stride) + b_stride = (ssize_t)bkg_stride; + else + b_stride = d_stride; + } /* end if */ + else + b_stride = 0; - /* The outer loop of the type conversion macro, controlling which */ - /* direction the buffer is walked */ - while (nelmts > 0) { - /* Check if we need to go backwards through the buffer */ - if (d_stride > s_stride) { - /* Sanity check */ - HDassert(s_stride > 0); - HDassert(d_stride > 0); - HDassert(b_stride >= 0); + /* Get the size of the base types in src & dst */ + src_base_size = H5T_get_size(src->shared->parent); + dst_base_size = H5T_get_size(dst->shared->parent); - /* Compute the number of "safe" destination elements at */ - /* the end of the buffer (Those which don't overlap with */ - /* any source elements at the beginning of the buffer) */ - safe = - nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); - - /* If we're down to the last few elements, just wrap up */ - /* with a "real" reverse copy */ - if (safe < 2) { - s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; - d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; - b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; - s_stride = -s_stride; - d_stride = -d_stride; - b_stride = -b_stride; + /* Set up conversion path for base elements */ + if (NULL == (tpath = H5T_path_find(src->shared->parent, dst->shared->parent))) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatypes") + else if (!H5T_path_noop(tpath)) { + H5T_t *tsrc_cpy = NULL, *tdst_cpy = NULL; + + if (NULL == (tsrc_cpy = H5T_copy(src->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy src type for conversion") + /* References need to know about the src file */ + if (tsrc_cpy->shared->type == H5T_REFERENCE) + if (H5T_set_loc(tsrc_cpy, src_vl->file_obj, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); + + if (NULL == (tdst_cpy = H5T_copy(dst->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy dst type for conversion") + /* References need to know about the dst file */ + if (tdst_cpy->shared->type == H5T_REFERENCE) + if (H5T_set_loc(tdst_cpy, dst_vl->file_obj, H5T_LOC_MEMORY) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set datatype location"); + + if (((tsrc_id = H5I_register(H5I_DATATYPE, tsrc_cpy, FALSE)) < 0) || + ((tdst_id = H5I_register(H5I_DATATYPE, tdst_cpy, FALSE)) < 0)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + "unable to register types for conversion") + } /* end else-if */ + else + noop_conv = TRUE; + + /* Check if we need a temporary buffer for this conversion */ + if ((parent_is_vlen = H5T_detect_class(dst->shared->parent, H5T_VLEN, FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_SYSTEM, FAIL, + "internal error when detecting variable-length class") + if (tpath->cdata.need_bkg || parent_is_vlen) { + /* Set up initial background buffer */ + tmp_buf_size = MAX(src_base_size, dst_base_size); + if (NULL == (tmp_buf = H5FL_BLK_CALLOC(vlen_seq, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for type conversion") + } /* end if */ - safe = nelmts; - } /* end if */ + /* Get the allocation info */ + if (H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") + + /* Set flags to indicate we are writing to or reading from the file */ + if (dst_vl->file_obj != NULL) + write_to_file = TRUE; + + /* Set the flag for nested VL case */ + if (write_to_file && parent_is_vlen && bkg != NULL) + nested = TRUE; + + /* The outer loop of the type conversion macro, controlling which */ + /* direction the buffer is walked */ + while (nelmts > 0) { + /* Check if we need to go backwards through the buffer */ + if (d_stride > s_stride) { + /* Sanity check */ + HDassert(s_stride > 0); + HDassert(d_stride > 0); + HDassert(b_stride >= 0); + + /* Compute the number of "safe" destination elements at */ + /* the end of the buffer (Those which don't overlap with */ + /* any source elements at the beginning of the buffer) */ + safe = + nelmts - (((nelmts * (size_t)s_stride) + ((size_t)d_stride - 1)) / (size_t)d_stride); + + /* If we're down to the last few elements, just wrap up */ + /* with a "real" reverse copy */ + if (safe < 2) { + s = (uint8_t *)buf + (nelmts - 1) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - 1) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - 1) * (size_t)b_stride; + s_stride = -s_stride; + d_stride = -d_stride; + b_stride = -b_stride; + + safe = nelmts; + } /* end if */ + else { + s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride; + d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride; + b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride; + } /* end else */ + } /* end if */ else { - s = (uint8_t *)buf + (nelmts - safe) * (size_t)s_stride; - d = (uint8_t *)buf + (nelmts - safe) * (size_t)d_stride; - b = (uint8_t *)bkg + (nelmts - safe) * (size_t)b_stride; + /* Single forward pass over all data */ + s = d = (uint8_t *)buf; + b = (uint8_t *)bkg; + safe = nelmts; } /* end else */ - } /* end if */ - else { - /* Single forward pass over all data */ - s = d = (uint8_t *)buf; - b = (uint8_t *)bkg; - safe = nelmts; - } /* end else */ - for (elmtno = 0; elmtno < safe; elmtno++) { - hbool_t is_nil; /* Whether sequence is "nil" */ - - /* Check for "nil" source sequence */ - if ((*(src->shared->u.vlen.cls->isnull))(src->shared->u.vlen.file, s, &is_nil) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if VL data is 'nil'") - else if (is_nil) { - /* Write "nil" sequence to destination location */ - if ((*(dst->shared->u.vlen.cls->setnull))(dst->shared->u.vlen.file, d, b) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'") - } /* end else-if */ - else { - size_t seq_len; /* The number of elements in the current sequence */ - - /* Get length of element sequences */ - if ((*(src->shared->u.vlen.cls->getlen))(src->shared->u.vlen.file, s, &seq_len) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") - - /* If we are reading from memory and there is no conversion, just get the pointer to - * sequence */ - if (write_to_file && noop_conv) { - /* Get direct pointer to sequence */ - if (NULL == (conv_buf = (*(src->shared->u.vlen.cls->getptr))(s))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer") - } /* end if */ + for (elmtno = 0; elmtno < safe; elmtno++) { + hbool_t is_nil; /* Whether sequence is "nil" */ + + /* Check for "nil" source sequence */ + if ((*(src_vl->cls->isnull))(src_vl->file_obj, s, &is_nil) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if VL data is 'nil'") + else if (is_nil) { + /* Write "nil" sequence to destination location */ + if ((*(dst_vl->cls->setnull))(dst_vl->file_obj, d, b) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'") + } /* end else-if */ else { - size_t src_size, dst_size; /*source & destination total size in bytes*/ - - src_size = seq_len * src_base_size; - dst_size = seq_len * dst_base_size; - - /* Check if conversion buffer is large enough, resize if - * necessary. If the SEQ_LEN is 0, allocate a minimal size buffer. - */ - if (!seq_len && !conv_buf) { - conv_buf_size = H5T_VLEN_MIN_CONF_BUF_SIZE; - if (NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for type conversion") + size_t seq_len; /* The number of elements in the current sequence */ + + /* Get length of element sequences */ + if ((*(src_vl->cls->getlen))(src_vl->file_obj, s, &seq_len) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") + + /* If we are reading from memory and there is no conversion, just get the pointer to + * sequence */ + if (write_to_file && noop_conv) { + /* Get direct pointer to sequence */ + if (NULL == (conv_buf = (*(src_vl->cls->getptr))(s))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer") } /* end if */ - else if (conv_buf_size < MAX(src_size, dst_size)) { - /* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */ - conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * - H5T_VLEN_MIN_CONF_BUF_SIZE; - if (NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for type conversion") - HDmemset(conv_buf, 0, conv_buf_size); - } /* end else-if */ - - /* Read in VL sequence */ - if ((*(src->shared->u.vlen.cls->read))(src->shared->u.vlen.file, s, conv_buf, - src_size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") - } /* end else */ + else { + size_t src_size, dst_size; /*source & destination total size in bytes*/ - if (!noop_conv) { - /* Check if temporary buffer is large enough, resize if necessary */ - /* (Chain off the conversion buffer size) */ - if (tmp_buf && tmp_buf_size < conv_buf_size) { - /* Set up initial background buffer */ - tmp_buf_size = conv_buf_size; - if (NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for type conversion") - HDmemset(tmp_buf, 0, tmp_buf_size); - } /* end if */ + src_size = seq_len * src_base_size; + dst_size = seq_len * dst_base_size; + + /* Check if conversion buffer is large enough, resize if + * necessary. If the SEQ_LEN is 0, allocate a minimal size buffer. + */ + if (!seq_len && !conv_buf) { + conv_buf_size = H5T_VLEN_MIN_CONF_BUF_SIZE; + if (NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") + } /* end if */ + else if (conv_buf_size < MAX(src_size, dst_size)) { + /* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */ + conv_buf_size = ((MAX(src_size, dst_size) / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * + H5T_VLEN_MIN_CONF_BUF_SIZE; + if (NULL == (conv_buf = H5FL_BLK_REALLOC(vlen_seq, conv_buf, conv_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") + HDmemset(conv_buf, 0, conv_buf_size); + } /* end else-if */ + + /* Read in VL sequence */ + if ((*(src_vl->cls->read))(src_vl->file_obj, s, conv_buf, src_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") + } /* end else */ + + if (!noop_conv) { + /* Check if temporary buffer is large enough, resize if necessary */ + /* (Chain off the conversion buffer size) */ + if (tmp_buf && tmp_buf_size < conv_buf_size) { + /* Set up initial background buffer */ + tmp_buf_size = conv_buf_size; + if (NULL == (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") + HDmemset(tmp_buf, 0, tmp_buf_size); + } /* end if */ - /* If we are writing and there is a nested VL type, read - * the sequence into the background buffer */ - if (nested) { - /* Sanity check */ - HDassert(write_to_file); - - /* Get length of background element sequence */ - if ((*(dst->shared->u.vlen.cls->getlen))(dst->shared->u.vlen.file, b, - &bg_seq_len) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") - - /* Read sequence if length > 0 */ - if (bg_seq_len > 0) { - if (tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) { - tmp_buf_size = (bg_seq_len * MAX(src_base_size, dst_base_size)); - if (NULL == - (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for type conversion") - HDmemset(tmp_buf, 0, tmp_buf_size); + /* If we are writing and there is a nested VL type, read + * the sequence into the background buffer */ + if (nested) { + /* Sanity check */ + HDassert(write_to_file); + + /* Get length of background element sequence */ + if ((*(dst_vl->cls->getlen))(dst_vl->file_obj, b, &bg_seq_len) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "bad sequence length") + + /* Read sequence if length > 0 */ + if (bg_seq_len > 0) { + if (tmp_buf_size < (bg_seq_len * MAX(src_base_size, dst_base_size))) { + tmp_buf_size = (bg_seq_len * MAX(src_base_size, dst_base_size)); + if (NULL == + (tmp_buf = H5FL_BLK_REALLOC(vlen_seq, tmp_buf, tmp_buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for type conversion") + HDmemset(tmp_buf, 0, tmp_buf_size); + } /* end if */ + + /* Read in background VL sequence */ + if ((*(dst_vl->cls->read))(dst_vl->file_obj, b, tmp_buf, bg_seq_len * dst_base_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") } /* end if */ - /* Read in background VL sequence */ - if ((*(dst->shared->u.vlen.cls->read))(dst->shared->u.vlen.file, b, - tmp_buf, - bg_seq_len * dst_base_size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data") + /* If the sequence gets shorter, pad out the original sequence with zeros */ + if (bg_seq_len < seq_len) + HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, + (seq_len - bg_seq_len) * dst_base_size); } /* end if */ - /* If the sequence gets shorter, pad out the original sequence with zeros */ - if (bg_seq_len < seq_len) - HDmemset((uint8_t *)tmp_buf + dst_base_size * bg_seq_len, 0, - (seq_len - bg_seq_len) * dst_base_size); + /* Convert VL sequence */ + if (H5T_convert(tpath, tsrc_id, tdst_id, seq_len, (size_t)0, (size_t)0, conv_buf, + tmp_buf) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") } /* end if */ - /* Convert VL sequence */ - if (H5T_convert(tpath, tsrc_id, tdst_id, seq_len, (size_t)0, (size_t)0, conv_buf, - tmp_buf) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") - } /* end if */ - - /* Write sequence to destination location */ - if ((*(dst->shared->u.vlen.cls->write))(dst->shared->u.vlen.file, &vl_alloc_info, d, - conv_buf, b, seq_len, dst_base_size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data") - - if (!noop_conv) { - /* For nested VL case, free leftover heap objects from the deeper level if the - * length of new data elements is shorter than the old data elements.*/ - if (nested && seq_len < bg_seq_len) { - const uint8_t *tmp; - size_t u; - - /* Sanity check */ - HDassert(write_to_file); - - tmp = (uint8_t *)tmp_buf + seq_len * dst_base_size; - for (u = seq_len; u < bg_seq_len; u++, tmp += dst_base_size) { - /* Delete sequence in destination location */ - if ((*(dst->shared->u.vlen.cls->del))(dst->shared->u.vlen.file, tmp) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, - "unable to remove heap object") - } /* end for */ - } /* end if */ - } /* end if */ - } /* end else */ - - /* Advance pointers */ - s += s_stride; - d += d_stride; - b += b_stride; - } /* end for */ + /* Write sequence to destination location */ + if ((*(dst_vl->cls->write))(dst_vl->file_obj, &vl_alloc_info, d, conv_buf, b, seq_len, dst_base_size) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data") + + if (!noop_conv) { + /* For nested VL case, free leftover heap objects from the deeper level if the + * length of new data elements is shorter than the old data elements.*/ + if (nested && seq_len < bg_seq_len) { + const uint8_t *tmp; + size_t u; + + /* Sanity check */ + HDassert(write_to_file); + + tmp = (uint8_t *)tmp_buf + seq_len * dst_base_size; + for (u = seq_len; u < bg_seq_len; u++, tmp += dst_base_size) { + /* Delete sequence in destination location */ + if ((*(dst_vl->cls->del))(dst_vl->file_obj, tmp) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove heap object") + } /* end for */ + } /* end if */ + } /* end if */ + } /* end else */ + + /* Advance pointers */ + s += s_stride; + d += d_stride; + b += b_stride; + } /* end for */ - /* Decrement number of elements left to convert */ - nelmts -= safe; - } /* end while */ + /* Decrement number of elements left to convert */ + nelmts -= safe; + } /* end while */ - /* Release the temporary datatype IDs used */ - if (tsrc_id >= 0) - H5I_dec_ref(tsrc_id); - if (tdst_id >= 0) - H5I_dec_ref(tdst_id); + /* Release the temporary datatype IDs used */ + if (tsrc_id >= 0) + H5I_dec_ref(tsrc_id); + if (tdst_id >= 0) + H5I_dec_ref(tdst_id); + } /* end case */ break; default: /* Some other command we don't know about yet.*/ @@ -3667,13 +3667,19 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz break; case H5T_CONV_CONV: { + H5T_atomic_ref_t *src_ref; /* Source reference type info */ + H5T_atomic_ref_t *dst_ref; /* Destination reference type info */ + /* * Conversion. */ if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + src_ref = &src->shared->u.atomic.u.r; + dst_ref = &dst->shared->u.atomic.u.r; - HDassert(src->shared->u.atomic.u.r.cls); + HDassert(src_ref->cls); + HDassert(dst_ref->cls); /* Initialize source & destination strides */ if (buf_stride) { @@ -3744,22 +3750,17 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz hbool_t is_nil; /* Whether reference is "nil" */ /* Check for "nil" source reference */ - if ((*(src->shared->u.atomic.u.r.cls->isnull))(src->shared->u.atomic.u.r.file, s, - &is_nil) < 0) + if ((*(src_ref->cls->isnull))(src_ref->file_obj, s, &is_nil) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check if reference data is 'nil'") if (is_nil) { /* Write "nil" reference to destination location */ - if ((*(dst->shared->u.atomic.u.r.cls->setnull))(dst->shared->u.atomic.u.r.file, d, - b) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, - "can't set reference data to 'nil'") + if ((*(dst_ref->cls->setnull))(dst_ref->file_obj, d, b) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set reference data to 'nil'") } /* end else-if */ else { /* Get size of references */ - if (0 == (buf_size = src->shared->u.atomic.u.r.cls->getsize( - src->shared->u.atomic.u.r.file, s, src->shared->size, - dst->shared->u.atomic.u.r.file, &dst_copy))) + if (0 == (buf_size = src_ref->cls->getsize(src_ref->file_obj, s, src->shared->size, dst_ref->file_obj, &dst_copy))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to obtain size of reference") /* Check if conversion buffer is large enough, resize if necessary. */ @@ -3771,24 +3772,19 @@ H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz HDmemset(conv_buf, 0, conv_buf_size); } /* end if */ - if (dst_copy && (src->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) + if (dst_copy && (src_ref->loc == H5T_LOC_DISK)) H5MM_memcpy(conv_buf, s, buf_size); else { /* Read reference */ - if (src->shared->u.atomic.u.r.cls->read( - src->shared->u.atomic.u.r.file, s, src->shared->size, - dst->shared->u.atomic.u.r.file, conv_buf, buf_size) < 0) + if (src_ref->cls->read(src_ref->file_obj, s, src->shared->size, dst_ref->file_obj, conv_buf, buf_size) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read reference data") } /* end else */ - if (dst_copy && (dst->shared->u.atomic.u.r.loc == H5T_LOC_DISK)) + if (dst_copy && (dst_ref->loc == H5T_LOC_DISK)) H5MM_memcpy(d, conv_buf, buf_size); else { /* Write reference to destination location */ - if (dst->shared->u.atomic.u.r.cls->write( - src->shared->u.atomic.u.r.file, conv_buf, buf_size, - src->shared->u.atomic.u.r.rtype, dst->shared->u.atomic.u.r.file, d, - dst->shared->size, b) < 0) + if (dst_ref->cls->write(src_ref->file_obj, conv_buf, buf_size, src_ref->rtype, dst_ref->file_obj, d, dst->shared->size, b) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write reference data") } /* end else */ } /* end else */ diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 51ecaca..877aa21 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -199,6 +199,15 @@ typedef struct H5T_ref_class_t { H5T_ref_writefunc_t write; /* write reference from buffer */ } H5T_ref_class_t; +typedef struct H5T_atomic_ref_t { + H5R_type_t rtype; /* type of reference stored */ + unsigned version; /* version of encoded reference */ + hbool_t opaque; /* opaque reference type */ + H5T_loc_t loc; /* location of data in buffer */ + H5VL_object_t *file_obj; /* File VOL object (if data is on disk) */ + const H5T_ref_class_t *cls; /* Pointer to ref class callbacks */ +} H5T_atomic_ref_t; + typedef struct H5T_atomic_t { H5T_order_t order; /* byte order */ size_t prec; /* precision in bits */ @@ -226,14 +235,7 @@ typedef struct H5T_atomic_t { H5T_str_t pad; /* space or null padding of extra bytes */ } s; /* string types */ - struct { - H5R_type_t rtype; /* type of reference stored */ - unsigned version; /* version of encoded reference */ - hbool_t opaque; /* opaque reference type */ - H5T_loc_t loc; /* location of data in buffer */ - H5VL_object_t * file; /* file VOL pointer (if data is on disk) */ - const H5T_ref_class_t *cls; /* Pointer to ref class callbacks */ - } r; /* reference types */ + H5T_atomic_ref_t r; /* Reference type info */ } u; } H5T_atomic_t; @@ -307,7 +309,7 @@ typedef struct H5T_vlen_t { H5T_cset_t cset; /* For VL string: character set */ H5T_str_t pad; /* For VL string: space or null padding of * extra bytes */ - H5VL_object_t * file; /* File object (if VL data is on disk) */ + H5VL_object_t *file_obj; /* File VOL object (if VL data is on disk) */ const H5T_vlen_class_t *cls; /* Pointer to VL class callbacks */ } H5T_vlen_t; diff --git a/src/H5Tref.c b/src/H5Tref.c index cac8cf6..85c62c0 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -70,39 +70,39 @@ struct H5Tref_dsetreg { /* Local Prototypes */ /********************/ -static herr_t H5T__ref_mem_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); -static herr_t H5T__ref_mem_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf); -static size_t H5T__ref_mem_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_mem_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); -static herr_t H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, size_t dst_size, +static herr_t H5T__ref_mem_isnull(const H5VL_object_t *src_file_obj, const void *src_buf, hbool_t *isnull); +static herr_t H5T__ref_mem_setnull(H5VL_object_t *dst_file_obj, void *dst_buf, void *bg_buf); +static size_t H5T__ref_mem_getsize(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, hbool_t *dst_copy); +static herr_t H5T__ref_mem_read(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size); +static herr_t H5T__ref_mem_write(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size, void *bg_buf); -static herr_t H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); -static herr_t H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf); -static size_t H5T__ref_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); -static herr_t H5T__ref_disk_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5R_type_t src_type, H5VL_object_t *dst_file, void *dst_buf, +static herr_t H5T__ref_disk_isnull(const H5VL_object_t *src_file_obj, const void *src_buf, hbool_t *isnull); +static herr_t H5T__ref_disk_setnull(H5VL_object_t *dst_file_obj, void *dst_buf, void *bg_buf); +static size_t H5T__ref_disk_getsize(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, hbool_t *dst_copy); +static herr_t H5T__ref_disk_read(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size); +static herr_t H5T__ref_disk_write(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5R_type_t src_type, H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size, void *bg_buf); /* For compatibility */ -static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull); -static size_t H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +static herr_t H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file_obj, const void *src_buf, hbool_t *isnull); +static size_t H5T__ref_obj_disk_getsize(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, hbool_t *dst_copy); +static herr_t H5T__ref_obj_disk_read(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size); -static herr_t H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, +static herr_t H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file_obj, const void *src_buf, hbool_t *isnull); -static size_t H5T__ref_dsetreg_disk_getsize(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, hbool_t *dst_copy); -static herr_t H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t *dst_file, void *dst_buf, size_t dst_size); +static size_t H5T__ref_dsetreg_disk_getsize(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, hbool_t *dst_copy); +static herr_t H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size); /*******************/ /* Local Variables */ @@ -156,7 +156,7 @@ static const H5T_ref_class_t H5T_ref_dsetreg_disk_g = { *------------------------------------------------------------------------- */ htri_t -H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) +H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file_obj, H5T_loc_t loc) { htri_t ret_value = FALSE; /* Indicate success, but no location change */ @@ -168,7 +168,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Only change the location if it's different */ - if (loc == dt->shared->u.atomic.u.r.loc && file == dt->shared->u.atomic.u.r.file) + if (loc == dt->shared->u.atomic.u.r.loc && file_obj == dt->shared->u.atomic.u.r.file_obj) HGOTO_DONE(FALSE) switch (loc) { @@ -188,7 +188,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) } /* end if */ /* Reset file ID (since this reference is in memory) */ - dt->shared->u.atomic.u.r.file = file; /* file is NULL */ + dt->shared->u.atomic.u.r.file_obj = file_obj; /* file is NULL */ if (dt->shared->u.atomic.u.r.opaque) { /* Size in memory, disk size is different */ @@ -219,16 +219,16 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) break; case H5T_LOC_DISK: /* Disk based reference datatype */ - HDassert(file); + HDassert(file_obj); /* Mark this type as being stored on disk */ dt->shared->u.atomic.u.r.loc = H5T_LOC_DISK; - /* Set file pointer (since this reference is on disk) */ - dt->shared->u.atomic.u.r.file = file; + /* Set VOL file object (since this reference is on disk) */ + dt->shared->u.atomic.u.r.file_obj = file_obj; /* dt now owns a reference to file */ - if (H5T_own_vol_obj(dt, file) < 0) + if (H5T_own_vol_obj(dt, file_obj) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "can't give ownership of VOL object") if (dt->shared->u.atomic.u.r.rtype == H5R_OBJECT1) { @@ -239,7 +239,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(file, &is_native) < 0) + if (H5VL_object_is_native(file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") @@ -249,7 +249,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (f = (H5F_t *)H5VL_object_data(file))) + if (NULL == (f = (H5F_t *)H5VL_object_data(file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Size on disk, memory size is different */ @@ -267,7 +267,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) hbool_t is_native = FALSE; /* Whether the file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(file, &is_native) < 0) + if (H5VL_object_is_native(file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") @@ -277,7 +277,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (f = (H5F_t *)H5VL_object_data(file))) + if (NULL == (f = (H5F_t *)H5VL_object_data(file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Size on disk, memory size is different */ @@ -298,7 +298,7 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) vol_cb_args.args.get_cont_info.info = &cont_info; /* Get container info */ - if (H5VL_file_get(file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_get(file_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") /* Retrieve min encode size (when references have no vlen part) */ @@ -327,8 +327,8 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) */ dt->shared->u.atomic.u.r.loc = H5T_LOC_BADLOC; - /* Reset file pointer */ - dt->shared->u.atomic.u.r.file = NULL; + /* Reset VOL file object */ + dt->shared->u.atomic.u.r.file_obj = NULL; /* Reset the function pointers */ dt->shared->u.atomic.u.r.cls = NULL; @@ -357,7 +357,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, hbool_t *isnull) +H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file_obj, const void *src_buf, hbool_t *isnull) { const unsigned char zeros[H5T_REF_MEM_SIZE] = {0}; herr_t ret_value = SUCCEED; @@ -384,7 +384,7 @@ H5T__ref_mem_isnull(const H5VL_object_t H5_ATTR_UNUSED *src_file, const void *sr *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, H5_ATTR_UNUSED void *bg_buf) +H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, void *dst_buf, H5_ATTR_UNUSED void *bg_buf) { herr_t ret_value = SUCCEED; @@ -406,8 +406,8 @@ H5T__ref_mem_setnull(H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, H5_A *------------------------------------------------------------------------- */ static size_t -H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, - size_t H5_ATTR_UNUSED src_size, H5VL_object_t *dst_file, hbool_t *dst_copy) +H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file_obj, const void *src_buf, + size_t H5_ATTR_UNUSED src_size, H5VL_object_t *dst_file_obj, hbool_t *dst_copy) { H5VL_object_t * vol_obj = NULL; /* VOL object for src ref's location */ const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; @@ -423,7 +423,7 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf HDassert(src_buf); HDassert(src_size == H5T_REF_MEM_SIZE); - if (NULL != dst_file) { + if (NULL != dst_file_obj) { hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */ /* Retrieve VOL object */ @@ -431,7 +431,7 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") /* Set external flag if referenced file is not destination file */ - if (H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) + if (H5VL_file_is_same(vol_obj, dst_file_obj, &files_equal) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, 0, "can't check if files are equal") flags |= !files_equal ? H5R_IS_EXTERNAL : 0; } @@ -449,14 +449,14 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(dst_file, &is_native) < 0) + if (H5VL_object_is_native(dst_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Set the file's libver bounds if using the native VOL connector */ if (is_native) { H5F_t *dst_f; /* Native file struct */ - if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) + if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") H5CX_set_libver_bounds(dst_f); } /* end if */ @@ -523,8 +523,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t H5_ATTR_UNUSED src_size, - H5VL_object_t *dst_file, void *dst_buf, size_t dst_size) +H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file_obj, const void *src_buf, size_t H5_ATTR_UNUSED src_size, + H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size) { H5VL_object_t * vol_obj; /* VOL object for src ref's location */ const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf; @@ -546,7 +546,7 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s HDassert(dst_size); /* Memory-to-memory conversion to support vlen conversion */ - if (NULL == dst_file) { + if (NULL == dst_file_obj) { H5MM_memcpy(dst_buf, src_buf, dst_size); HGOTO_DONE(ret_value); } @@ -556,7 +556,7 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid location identifier") /* Set external flag if referenced file is not destination file */ - if (H5VL_file_is_same(vol_obj, dst_file, &files_equal) < 0) + if (H5VL_file_is_same(vol_obj, dst_file_obj, &files_equal) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "can't check if files are equal") flags |= !files_equal ? H5R_IS_EXTERNAL : 0; @@ -566,14 +566,14 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s hbool_t is_native = FALSE; /* Whether the dest. file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(dst_file, &is_native) < 0) + if (H5VL_object_is_native(dst_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Set the file's libver bounds if using the native VOL connector */ if (is_native) { H5F_t *dst_f; - if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file))) + if (NULL == (dst_f = (H5F_t *)H5VL_object_data(dst_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") H5CX_set_libver_bounds(dst_f); } /* end if */ @@ -637,8 +637,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size, H5R_type_t src_type, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size, +H5T__ref_mem_write(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, H5R_type_t src_type, + H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, void *dst_buf, size_t dst_size, void H5_ATTR_UNUSED *bg_buf) { H5F_t * src_f = NULL; @@ -658,7 +658,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size HDcompile_assert(sizeof(*dst_ref) == sizeof(tmp_ref)); /* Memory-to-memory conversion to support vlen conversion */ - if (NULL == src_file) { + if (NULL == src_file_obj) { H5MM_memcpy(dst_buf, src_buf, src_size); HGOTO_DONE(ret_value); } @@ -668,7 +668,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -677,7 +677,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Make sure reference buffer is correctly initialized */ @@ -726,7 +726,7 @@ H5T__ref_mem_write(H5VL_object_t *src_file, const void *src_buf, size_t src_size /* If no filename set, this is not an external reference */ if (NULL == H5R_REF_FILENAME(&tmp_ref)) { /* TODO temporary hack to retrieve file object */ - if ((file_id = H5F_get_file_id(src_file, H5I_FILE, FALSE)) < 0) + if ((file_id = H5F_get_file_id(src_file_obj, H5I_FILE, FALSE)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Attach loc ID to reference and hold reference to it, this is a @@ -754,7 +754,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) +H5T__ref_disk_isnull(const H5VL_object_t *src_file_obj, const void *src_buf, hbool_t *isnull) { const uint8_t *p = (const uint8_t *)src_buf; H5R_type_t ref_type; @@ -764,7 +764,7 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t H5T_REF_LOG_DEBUG(""); /* Check parameters */ - HDassert(src_file); + HDassert(src_file_obj); HDassert(src_buf); HDassert(isnull); @@ -785,7 +785,7 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t vol_cb_args.args.is_null.isnull = isnull; /* Check if blob ID is "nil" */ - if (H5VL_blob_specific(src_file, (void *)p, &vol_cb_args) < 0) + if (H5VL_blob_specific(src_file_obj, (void *)p, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") } @@ -803,7 +803,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) +H5T__ref_disk_setnull(H5VL_object_t *dst_file_obj, void *dst_buf, void *bg_buf) { H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ uint8_t * q = (uint8_t *)dst_buf; @@ -813,7 +813,7 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) FUNC_ENTER_STATIC H5T_REF_LOG_DEBUG(""); - HDassert(dst_file); + HDassert(dst_file_obj); HDassert(dst_buf); /* TODO Should get rid of bg stuff */ @@ -825,7 +825,7 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) vol_cb_args.op_type = H5VL_BLOB_DELETE; /* Remove blob for old data */ - if (H5VL_blob_specific(dst_file, (void *)p_bg, &vol_cb_args) < 0) + if (H5VL_blob_specific(dst_file_obj, (void *)p_bg, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ @@ -840,7 +840,7 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf) vol_cb_args.op_type = H5VL_BLOB_SETNULL; /* Set blob ID to "nil" */ - if (H5VL_blob_specific(dst_file, q, &vol_cb_args) < 0) + if (H5VL_blob_specific(dst_file_obj, q, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") done: @@ -857,8 +857,8 @@ done: *------------------------------------------------------------------------- */ static size_t -H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, hbool_t *dst_copy) +H5T__ref_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, hbool_t *dst_copy) { const uint8_t *p = (const uint8_t *)src_buf; unsigned flags; @@ -906,8 +906,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_NDEBUG_UNUSED src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t dst_size) +H5T__ref_disk_read(H5VL_object_t *src_file_obj, const void *src_buf, size_t H5_ATTR_NDEBUG_UNUSED src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, void *dst_buf, size_t dst_size) { const uint8_t *p = (const uint8_t *)src_buf; uint8_t * q = (uint8_t *)dst_buf; @@ -917,7 +917,7 @@ H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_ FUNC_ENTER_STATIC H5T_REF_LOG_DEBUG(""); - HDassert(src_file); + HDassert(src_file_obj); HDassert(src_buf); HDassert(dst_buf); HDassert(dst_size); @@ -933,7 +933,7 @@ H5T__ref_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t H5_ATTR_ HDassert(src_size > (H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T)); /* Retrieve blob */ - if (H5VL_blob_get(src_file, p, q, blob_size, NULL) < 0) + if (H5VL_blob_get(src_file_obj, p, q, blob_size, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob") done: @@ -950,8 +950,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, size_t src_size, - H5R_type_t H5_ATTR_UNUSED src_type, H5VL_object_t *dst_file, void *dst_buf, +H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file_obj, const void *src_buf, size_t src_size, + H5R_type_t H5_ATTR_UNUSED src_type, H5VL_object_t *dst_file_obj, void *dst_buf, size_t dst_size, void *bg_buf) { const uint8_t *p = (const uint8_t *)src_buf; @@ -965,7 +965,7 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, HDassert(src_buf); HDassert(src_size); - HDassert(dst_file); + HDassert(dst_file_obj); HDassert(dst_buf); /* TODO Should get rid of bg stuff */ @@ -982,7 +982,7 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, vol_cb_args.op_type = H5VL_BLOB_DELETE; /* Remove blob for old data */ - if (H5VL_blob_specific(dst_file, (void *)p_bg, &vol_cb_args) < 0) + if (H5VL_blob_specific(dst_file_obj, (void *)p_bg, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ @@ -999,7 +999,7 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, buf_size_left -= H5_SIZEOF_UINT32_T; /* Store blob */ - if (H5VL_blob_put(dst_file, p, src_size, q, NULL) < 0) + if (H5VL_blob_put(dst_file_obj, p, src_size, q, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob") done: @@ -1016,7 +1016,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) +H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file_obj, const void *src_buf, hbool_t *isnull) { H5F_t * src_f; const uint8_t *p = (const uint8_t *)src_buf; @@ -1027,7 +1027,7 @@ H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbo H5T_REF_LOG_DEBUG(""); /* Check parameters */ - HDassert(src_file); + HDassert(src_file_obj); HDassert(src_buf); HDassert(isnull); @@ -1036,7 +1036,7 @@ H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbo hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1045,7 +1045,7 @@ H5T__ref_obj_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbo #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Get the object address */ @@ -1068,8 +1068,8 @@ done: *------------------------------------------------------------------------- */ static size_t -H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *src_buf, - size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, +H5T__ref_obj_disk_getsize(H5VL_object_t *src_file_obj, const void H5_ATTR_UNUSED *src_buf, + size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, hbool_t H5_ATTR_UNUSED *dst_copy) { H5F_t *src_f; @@ -1078,7 +1078,7 @@ H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *sr FUNC_ENTER_STATIC H5T_REF_LOG_DEBUG(""); - HDassert(src_file); + HDassert(src_file_obj); HDassert(src_buf); #ifndef NDEBUG @@ -1086,7 +1086,7 @@ H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *sr hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1095,7 +1095,7 @@ H5T__ref_obj_disk_getsize(H5VL_object_t *src_file, const void H5_ATTR_UNUSED *sr #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f)); @@ -1116,8 +1116,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, size_t H5_ATTR_UNUSED dst_size) +H5T__ref_obj_disk_read(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, void *dst_buf, size_t H5_ATTR_UNUSED dst_size) { H5F_t *src_f; herr_t ret_value = SUCCEED; @@ -1125,7 +1125,7 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_ FUNC_ENTER_STATIC H5T_REF_LOG_DEBUG(""); - HDassert(src_file); + HDassert(src_file_obj); HDassert(src_buf); HDassert(dst_buf); @@ -1134,7 +1134,7 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_ hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1143,7 +1143,7 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_ #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f)); @@ -1168,7 +1168,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t *isnull) +H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file_obj, const void *src_buf, hbool_t *isnull) { H5F_t * src_f; const uint8_t *p = (const uint8_t *)src_buf; @@ -1179,7 +1179,7 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, H5T_REF_LOG_DEBUG(""); /* Check parameters */ - HDassert(src_file); + HDassert(src_file_obj); HDassert(src_buf); HDassert(isnull); @@ -1188,7 +1188,7 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1197,7 +1197,7 @@ H5T__ref_dsetreg_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") /* Get the heap address */ @@ -1220,8 +1220,8 @@ done: *------------------------------------------------------------------------- */ static size_t -H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void H5_ATTR_UNUSED *src_buf, - size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file, +H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file_obj, const void H5_ATTR_UNUSED *src_buf, + size_t H5_ATTR_UNUSED src_size, H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, hbool_t H5_ATTR_UNUSED *dst_copy) { size_t ret_value = sizeof(struct H5Tref_dsetreg); @@ -1241,14 +1241,14 @@ H5T__ref_dsetreg_disk_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ HDassert(is_native); /* Retrieve file from VOL object */ - if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid VOL object") HDassert(src_size == H5T_REF_DSETREG_DISK_SIZE(src_f)); @@ -1271,8 +1271,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_size, - H5VL_object_t H5_ATTR_UNUSED *dst_file, void *dst_buf, +H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file_obj, const void *src_buf, size_t src_size, + H5VL_object_t H5_ATTR_UNUSED *dst_file_obj, void *dst_buf, size_t H5_ATTR_UNUSED dst_size) { H5F_t * src_f; @@ -1282,7 +1282,7 @@ H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t FUNC_ENTER_STATIC H5T_REF_LOG_DEBUG(""); - HDassert(src_file); + HDassert(src_file_obj); HDassert(src_buf); HDassert(dst_buf); HDassert(dst_size == sizeof(struct H5Tref_dsetreg)); @@ -1292,7 +1292,7 @@ H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */ /* Check if using native VOL connector */ - if (H5VL_object_is_native(src_file, &is_native) < 0) + if (H5VL_object_is_native(src_file_obj, H5VL_GET_CONN_LVL_TERM, &is_native) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector") /* Must use native VOL connector for this operation */ @@ -1301,7 +1301,7 @@ H5T__ref_dsetreg_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t #endif /* NDEBUG */ /* Retrieve file from VOL object */ - if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file))) + if (NULL == (src_f = (H5F_t *)H5VL_object_data(src_file_obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object") HDassert(src_size == H5T_REF_DSETREG_DISK_SIZE(src_f)); diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 080d725..068ec3b 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -52,31 +52,31 @@ /********************/ /* Memory-based VL sequence callbacks */ -static herr_t H5T__vlen_mem_seq_getlen(H5VL_object_t *file, const void *_vl, size_t *len); +static herr_t H5T__vlen_mem_seq_getlen(H5VL_object_t *file_obj, const void *_vl, size_t *len); static void * H5T__vlen_mem_seq_getptr(void *_vl); -static herr_t H5T__vlen_mem_seq_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); -static herr_t H5T__vlen_mem_seq_setnull(H5VL_object_t *file, void *_vl, void *_bg); -static herr_t H5T__vlen_mem_seq_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); -static herr_t H5T__vlen_mem_seq_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, +static herr_t H5T__vlen_mem_seq_isnull(const H5VL_object_t *file_obj, void *_vl, hbool_t *isnull); +static herr_t H5T__vlen_mem_seq_setnull(H5VL_object_t *file_obj, void *_vl, void *_bg); +static herr_t H5T__vlen_mem_seq_read(H5VL_object_t *file_obj, void *_vl, void *_buf, size_t len); +static herr_t H5T__vlen_mem_seq_write(H5VL_object_t *file_obj, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); /* Memory-based VL string callbacks */ -static herr_t H5T__vlen_mem_str_getlen(H5VL_object_t *file, const void *_vl, size_t *len); +static herr_t H5T__vlen_mem_str_getlen(H5VL_object_t *file_obj, const void *_vl, size_t *len); static void * H5T__vlen_mem_str_getptr(void *_vl); -static herr_t H5T__vlen_mem_str_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); -static herr_t H5T__vlen_mem_str_setnull(H5VL_object_t *file, void *_vl, void *_bg); -static herr_t H5T__vlen_mem_str_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); -static herr_t H5T__vlen_mem_str_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, +static herr_t H5T__vlen_mem_str_isnull(const H5VL_object_t *file_obj, void *_vl, hbool_t *isnull); +static herr_t H5T__vlen_mem_str_setnull(H5VL_object_t *file_obj, void *_vl, void *_bg); +static herr_t H5T__vlen_mem_str_read(H5VL_object_t *file_obj, void *_vl, void *_buf, size_t len); +static herr_t H5T__vlen_mem_str_write(H5VL_object_t *file_obj, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); /* Disk-based VL sequence (and string) callbacks */ -static herr_t H5T__vlen_disk_getlen(H5VL_object_t *file, const void *_vl, size_t *len); -static herr_t H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull); -static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *_bg); -static herr_t H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len); -static herr_t H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, +static herr_t H5T__vlen_disk_getlen(H5VL_object_t *file_obj, const void *_vl, size_t *len); +static herr_t H5T__vlen_disk_isnull(const H5VL_object_t *file_obj, void *_vl, hbool_t *isnull); +static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file_obj, void *_vl, void *_bg); +static herr_t H5T__vlen_disk_read(H5VL_object_t *file_obj, void *_vl, void *_buf, size_t len); +static herr_t H5T__vlen_disk_write(H5VL_object_t *file_obj, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); -static herr_t H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl); +static herr_t H5T__vlen_disk_delete(H5VL_object_t *file_obj, const void *_vl); /*********************/ /* Public Variables */ @@ -245,7 +245,7 @@ done: *------------------------------------------------------------------------- */ htri_t -H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) +H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file_obj, H5T_loc_t loc) { htri_t ret_value = FALSE; /* Indicate success, but no location change */ @@ -256,10 +256,10 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Only change the location if it's different */ - if (loc != dt->shared->u.vlen.loc || file != dt->shared->u.vlen.file) { + if (loc != dt->shared->u.vlen.loc || file_obj != dt->shared->u.vlen.file_obj) { switch (loc) { case H5T_LOC_MEMORY: /* Memory based VL datatype */ - HDassert(NULL == file); + HDassert(NULL == file_obj); /* Mark this type as being stored in memory */ dt->shared->u.vlen.loc = H5T_LOC_MEMORY; @@ -288,8 +288,8 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) dt->shared->owned_vol_obj = NULL; } /* end if */ - /* Reset file pointer (since this VL is in memory) */ - dt->shared->u.vlen.file = NULL; + /* Reset VOL object (since this VL is in memory) */ + dt->shared->u.vlen.file_obj = NULL; break; /* Disk based VL datatype */ @@ -297,7 +297,7 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */ - HDassert(file); + HDassert(file_obj); /* Mark this type as being stored on disk */ dt->shared->u.vlen.loc = H5T_LOC_DISK; @@ -307,7 +307,7 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) vol_cb_args.args.get_cont_info.info = &cont_info; /* Get container info */ - if (H5VL_file_get(file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_file_get(file_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info") /* The datatype size is equal to 4 bytes for the sequence length @@ -318,11 +318,11 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* VL sequences and VL strings are stored identically on disk, so use the same functions */ dt->shared->u.vlen.cls = &H5T_vlen_disk_g; - /* Set file ID (since this VL is on disk) */ - dt->shared->u.vlen.file = file; + /* Set VOL object (since this VL is on disk) */ + dt->shared->u.vlen.file_obj = file_obj; /* dt now owns a reference to file */ - if (H5T_own_vol_obj(dt, file) < 0) + if (H5T_own_vol_obj(dt, file_obj) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't give ownership of VOL object") break; } @@ -336,8 +336,8 @@ H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc) /* Reset the function pointers to access the VL information */ dt->shared->u.vlen.cls = NULL; - /* Reset file pointer */ - dt->shared->u.vlen.file = NULL; + /* Reset VOL object pointer */ + dt->shared->u.vlen.file_obj = NULL; break; case H5T_LOC_MAXLOC: @@ -367,7 +367,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_seq_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *len) +H5T__vlen_mem_seq_getlen(H5VL_object_t H5_ATTR_UNUSED *file_obj, const void *_vl, size_t *len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ @@ -441,7 +441,7 @@ H5T__vlen_mem_seq_getptr(void *_vl) *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull) +H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file_obj, void *_vl, hbool_t *isnull) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ @@ -478,7 +478,7 @@ H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg) +H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file_obj, void *_vl, void H5_ATTR_UNUSED *_bg) { hvl_t vl; /* Temporary hvl_t to use during operation */ @@ -510,7 +510,7 @@ H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5 *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len) +H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file_obj, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ @@ -550,7 +550,7 @@ H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_seq_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info, +H5T__vlen_mem_seq_write(H5VL_object_t H5_ATTR_UNUSED *file_obj, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { hvl_t vl; /* Temporary hvl_t to use during operation */ @@ -604,7 +604,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_str_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *len) +H5T__vlen_mem_str_getlen(H5VL_object_t H5_ATTR_UNUSED *file_obj, const void *_vl, size_t *len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS const char *s = *(const char *const *)_vl; /* Pointer to the user's string information */ @@ -673,7 +673,7 @@ H5T__vlen_mem_str_getptr(void *_vl) *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull) +H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file_obj, void *_vl, hbool_t *isnull) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS char *s = *(char **)_vl; /* Pointer to the user's string information */ @@ -705,7 +705,7 @@ H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg) +H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file_obj, void *_vl, void H5_ATTR_UNUSED *_bg) { char *t = NULL; /* Pointer to temporary buffer allocated */ @@ -730,7 +730,7 @@ H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5 *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len) +H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file_obj, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS char *s = *(char **)_vl; /* Pointer to the user's string information */ @@ -769,7 +769,7 @@ H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_mem_str_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info, +H5T__vlen_mem_str_write(H5VL_object_t H5_ATTR_UNUSED *file_obj, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { char * t; /* Pointer to temporary buffer allocated */ @@ -817,7 +817,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *seq_len) +H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file_obj, const void *_vl, size_t *seq_len) { const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ @@ -846,7 +846,7 @@ H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_ *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) +H5T__vlen_disk_isnull(const H5VL_object_t *file_obj, void *_vl, hbool_t *isnull) { H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ @@ -855,7 +855,7 @@ H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) FUNC_ENTER_STATIC /* Check parameters */ - HDassert(file); + HDassert(file_obj); HDassert(vl); HDassert(isnull); @@ -867,7 +867,7 @@ H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull) vol_cb_args.args.is_null.isnull = isnull; /* Check if blob ID is "nil" */ - if (H5VL_blob_specific(file, vl, &vol_cb_args) < 0) + if (H5VL_blob_specific(file_obj, vl, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'") done: @@ -887,7 +887,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) +H5T__vlen_disk_setnull(H5VL_object_t *file_obj, void *_vl, void *bg) { H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */ uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ @@ -896,13 +896,13 @@ H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) FUNC_ENTER_STATIC /* check parameters */ - HDassert(file); + HDassert(file_obj); HDassert(vl); /* Free heap object for old data */ if (bg != NULL) /* Delete sequence in destination location */ - if (H5T__vlen_disk_delete(file, bg) < 0) + if (H5T__vlen_disk_delete(file_obj, bg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object") /* Set the length of the sequence */ @@ -912,7 +912,7 @@ H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg) vol_cb_args.op_type = H5VL_BLOB_SETNULL; /* Set blob ID to "nil" */ - if (H5VL_blob_specific(file, vl, &vol_cb_args) < 0) + if (H5VL_blob_specific(file_obj, vl, &vol_cb_args) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'") done: @@ -932,7 +932,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *buf, size_t len) +H5T__vlen_disk_read(H5VL_object_t *file_obj, void *_vl, void *buf, size_t len) { const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ herr_t ret_value = SUCCEED; /* Return value */ @@ -940,7 +940,7 @@ H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *buf, size_t len) FUNC_ENTER_STATIC /* Check parameters */ - HDassert(file); + HDassert(file_obj); HDassert(vl); HDassert(buf); @@ -948,7 +948,7 @@ H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *buf, size_t len) vl += 4; /* Retrieve blob */ - if (H5VL_blob_get(file, vl, buf, len, NULL) < 0) + if (H5VL_blob_get(file_obj, vl, buf, len, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob") done: @@ -968,7 +968,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, +H5T__vlen_disk_write(H5VL_object_t *file_obj, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) { uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ @@ -980,18 +980,18 @@ H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t H5_ATTR_UN /* check parameters */ HDassert(vl); HDassert(seq_len == 0 || buf); - HDassert(file); + HDassert(file_obj); /* Free heap object for old data, if non-NULL */ if (bg != NULL) - if (H5T__vlen_disk_delete(file, bg) < 0) + if (H5T__vlen_disk_delete(file_obj, bg) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object") /* Set the length of the sequence */ UINT32ENCODE(vl, seq_len); /* Store blob */ - if (H5VL_blob_put(file, buf, (seq_len * base_size), vl, NULL) < 0) + if (H5VL_blob_put(file_obj, buf, (seq_len * base_size), vl, NULL) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob") done: @@ -1011,7 +1011,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl) +H5T__vlen_disk_delete(H5VL_object_t *file_obj, const void *_vl) { const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1019,7 +1019,7 @@ H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl) FUNC_ENTER_STATIC /* Check parameters */ - HDassert(file); + HDassert(file_obj); /* Free heap object for old data */ if (vl != NULL) { @@ -1035,7 +1035,7 @@ H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl) /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_BLOB_DELETE; - if (H5VL_blob_specific(file, (void *)vl, &vol_cb_args) < 0) /* Casting away 'const' OK -QAK */ + if (H5VL_blob_specific(file_obj, (void *)vl, &vol_cb_args) < 0) /* Casting away 'const' OK -QAK */ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob") } /* end if */ } /* end if */ @@ -686,7 +686,7 @@ H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id) /* Create VOL object for file if necessary (force_conv will be TRUE if and * only if file needs to be passed to H5T_set_loc) */ if (H5T_GET_FORCE_CONV(dtype) && - (NULL == (file_vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file_obj, connector_id)))) + (NULL == (file_vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file_obj, connector_id, TRUE)))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") /* Copy the datatype */ diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index baedbf1..cef0b6f 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -28,6 +28,8 @@ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5ESprivate.h" /* Event Sets */ #include "H5Fprivate.h" /* File access */ @@ -60,6 +62,49 @@ typedef struct H5VL_file_open_find_connector_t { typedef herr_t (*H5VL_reg_opt_oper_t)(void *obj, const H5VL_class_t *cls, H5VL_optional_args_t *args, hid_t dxpl_id, void **req); +/* Typedef for common callback form of API operations */ +typedef herr_t (*H5VL_api_oper_t)(void *ctx); + +/* + * Context data structures for common callbacks for API operations + */ + +/* Attribute create "common" callback context data */ +typedef struct H5VL_attr_create_ctx_t { + /* DOWN: API routine parameters */ + void *obj; + const H5VL_loc_params_t *loc_params; + H5VL_class_t *cls; + const char *name; + hid_t type_id; + hid_t space_id; + hid_t acpl_id; + hid_t aapl_id; + hid_t dxpl_id; + void **req; + + /* UP: API routine return value */ + void *ret_value; +} H5VL_attr_create_ctx_t; + +/* Attribute open "common" callback context data */ +typedef struct H5VL_attr_open_ctx_t { + /* DOWN: API routine parameters */ + void *obj; + const H5VL_loc_params_t *loc_params; + H5VL_class_t *cls; + const char *name; + hid_t type_id; + hid_t space_id; + hid_t acpl_id; + hid_t aapl_id; + hid_t dxpl_id; + void **req; + + /* UP: API routine return value */ + void *ret_value; +} H5VL_attr_open_ctx_t; + /********************/ /* Package Typedefs */ /********************/ @@ -70,8 +115,10 @@ typedef herr_t (*H5VL_reg_opt_oper_t)(void *obj, const H5VL_class_t *cls, H5VL_o static void * H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__attr_create_api_op(void *ctx); static void * H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__attr_open_api_op(void *ctx); static herr_t H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); static herr_t H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, @@ -219,7 +266,7 @@ H5VLinitialize(hid_t connector_id, hid_t vipl_id) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE2("e", "ii", connector_id, vipl_id); /* Check args */ @@ -231,7 +278,7 @@ H5VLinitialize(hid_t connector_id, hid_t vipl_id) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not initialize") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLinitialize() */ /*------------------------------------------------------------------------- @@ -250,7 +297,7 @@ H5VLterminate(hid_t connector_id) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE1("e", "i", connector_id); /* Check args */ @@ -262,7 +309,7 @@ H5VLterminate(hid_t connector_id) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLterminate() */ /*--------------------------------------------------------------------------- @@ -281,7 +328,7 @@ H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags /*out*/) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE2("e", "ix", connector_id, cap_flags); /* Check args */ @@ -293,7 +340,7 @@ H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags /*out*/) *cap_flags = cls->cap_flags; done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLget_cap_flags */ /*--------------------------------------------------------------------------- @@ -312,7 +359,7 @@ H5VLget_value(hid_t connector_id, H5VL_class_value_t *value /*out*/) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE2("e", "ix", connector_id, value); /* Check args */ @@ -324,7 +371,7 @@ H5VLget_value(hid_t connector_id, H5VL_class_value_t *value /*out*/) *value = cls->value; done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLget_value */ /*------------------------------------------------------------------------- @@ -372,6 +419,68 @@ done: } /* end H5VL__common_optional_op() */ /*------------------------------------------------------------------------- + * Function: H5VL__common_api_op + * + * Purpose: Provide common wrapping for VOL callback API routines. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__common_api_op(hid_t dxpl_id, H5VL_api_oper_t wrap_op, void *wrap_ctx) +{ + H5P_genplist_t * dxpl_plist = NULL; /* DXPL property list pointer */ + hbool_t new_api_ctx = FALSE; /* Whether to start a new API context */ + hbool_t api_pushed = FALSE; /* Indicate that a new API context was pushed */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check for non-default DXPL */ + if (!(H5P_DEFAULT == dxpl_id || H5P_DATASET_XFER_DEFAULT == dxpl_id)) { + /* Check for 'new API context' flag */ + if (NULL == (dxpl_plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + if (H5P_get(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &new_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get value") + + /* Start a new API context, if requested */ + if (new_api_ctx) { + hbool_t reset_api_ctx = FALSE; /* Flag to reset the 'new API context' */ + + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context") \ + api_pushed = TRUE; + + /* Reset 'new API context' flag for next layer down */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &reset_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + } /* end if */ + } /* end if */ + + /* Call the corresponding internal bounce routine */ + if ((*wrap_op)(wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute bounce operation callback") + +done: + /* Pop the API context, if it was pushed */ + if(api_pushed) { + hbool_t undo_api_ctx = TRUE; /* Flag to reset the 'new API context' */ + + /* Undo change to 'new API context' flag */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &undo_api_ctx) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + + (void)H5CX_pop(FALSE); \ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__common_api_op() */ + +/*------------------------------------------------------------------------- * Function: H5VL_copy_connector_info * * Purpose: Copy the VOL info for a connector @@ -431,7 +540,7 @@ H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_i H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "i**x*x", connector_id, dst_vol_info, src_vol_info); /* Check args and get class pointer */ @@ -443,7 +552,7 @@ H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_i HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy VOL connector info object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLcopy_connector_info() */ /*------------------------------------------------------------------------- @@ -593,7 +702,7 @@ H5VLfree_connector_info(hid_t connector_id, void *info) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE2("e", "i*x", connector_id, info); /* Free the VOL connector info object */ @@ -601,7 +710,7 @@ H5VLfree_connector_info(hid_t connector_id, void *info) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLfree_connector_info() */ /*--------------------------------------------------------------------------- @@ -619,7 +728,7 @@ H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "*xi**s", info, connector_id, str); /* Only serialize info object, if it's non-NULL */ @@ -642,7 +751,7 @@ H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) *str = NULL; done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLconnector_info_to_str() */ /*--------------------------------------------------------------------------- @@ -660,7 +769,7 @@ H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info /*out { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "*six", str, connector_id, info); /* Call internal routine */ @@ -668,7 +777,7 @@ H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info /*out HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLconnector_str_to_info() */ /*--------------------------------------------------------------------------- @@ -687,7 +796,7 @@ H5VLget_object(void *obj, hid_t connector_id) H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE2("*x", "*xi", obj, connector_id); /* Check args */ @@ -703,7 +812,7 @@ H5VLget_object(void *obj, hid_t connector_id) ret_value = obj; done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLget_object */ /*------------------------------------------------------------------------- @@ -760,7 +869,7 @@ H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx /*out*/) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "*xix", obj, connector_id, wrap_ctx); /* Check args and get class pointer */ @@ -772,7 +881,7 @@ H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx /*out*/) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to retrieve VOL connector object wrap context") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLget_wrap_ctx() */ /*------------------------------------------------------------------------- @@ -825,7 +934,7 @@ H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_c H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE4("*x", "*xIti*x", obj, obj_type, connector_id, wrap_ctx); /* Check args and get class pointer */ @@ -839,7 +948,7 @@ H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_c HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLwrap_object */ /*------------------------------------------------------------------------- @@ -892,7 +1001,7 @@ H5VLunwrap_object(void *obj, hid_t connector_id) H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE2("*x", "*xi", obj, connector_id); /* Check args and get class pointer */ @@ -906,7 +1015,7 @@ H5VLunwrap_object(void *obj, hid_t connector_id) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to unwrap object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLunwrap_object */ /*------------------------------------------------------------------------- @@ -956,7 +1065,7 @@ H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE2("e", "*xi", wrap_ctx, connector_id); /* Check args and get class pointer */ @@ -968,7 +1077,7 @@ H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* H5VLfree_wrap_ctx() */ /*------------------------------------------------------------------------- @@ -1040,6 +1149,36 @@ done: } /* end H5VL_attr_create() */ /*------------------------------------------------------------------------- + * Function: H5VL__attr_create_api_op + * + * Purpose: Callback for common API wrapper to create an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_create_api_op(void *_ctx) +{ + H5VL_attr_create_ctx_t *ctx = (H5VL_attr_create_ctx_t *)_ctx; /* Get pointer to context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(ctx); + + /* Call the corresponding internal VOL routine */ + if (NULL == (ctx->ret_value = H5VL__attr_create(ctx->obj, ctx->loc_params, ctx->cls, ctx->name, ctx->type_id, ctx->space_id, ctx->acpl_id, + ctx->aapl_id, ctx->dxpl_id, ctx->req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_create_api_op() */ + +/*------------------------------------------------------------------------- * Function: H5VLattr_create * * Purpose: Creates an attribute @@ -1054,10 +1193,11 @@ H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_ hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req /*out*/) { + H5VL_attr_create_ctx_t ctx; /* Context for common API wrapper call */ H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE10("*x", "*x*#i*siiiiix", obj, loc_params, connector_id, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req); @@ -1067,13 +1207,27 @@ H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") - /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, type_id, space_id, acpl_id, - aapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create attribute") + /* Set up context */ + ctx.obj = obj; + ctx.loc_params = loc_params; + ctx.cls = cls; + ctx.name = name; + ctx.type_id = type_id; + ctx.space_id = space_id; + ctx.acpl_id = acpl_id; + ctx.aapl_id = aapl_id; + ctx.dxpl_id = dxpl_id; + ctx.req = req; + + /* Invoke bounce routine */ + if (H5VL__common_api_op(dxpl_id, H5VL__attr_create_api_op, &ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, NULL, "unable to execute bounce operation") + + /* Set return value */ + ret_value = ctx.ret_value; done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_create() */ /*------------------------------------------------------------------------- @@ -1144,6 +1298,35 @@ done: } /* end H5VL_attr_open() */ /*------------------------------------------------------------------------- + * Function: H5VL__attr_open_api_op + * + * Purpose: Callback for common API wrapper to open an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_open_api_op(void *_ctx) +{ + H5VL_attr_open_ctx_t *ctx = (H5VL_attr_open_ctx_t *)_ctx; /* Get pointer to context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(ctx); + + /* Call the corresponding internal VOL routine */ + if (NULL == (ctx->ret_value = H5VL__attr_open(ctx->obj, ctx->loc_params, ctx->cls, ctx->name, ctx->aapl_id, ctx->dxpl_id, ctx->req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_open_api_op() */ + +/*------------------------------------------------------------------------- * Function: H5VLattr_open * * Purpose: Opens an attribute @@ -1157,10 +1340,11 @@ void * H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req /*out*/) { + H5VL_attr_open_ctx_t ctx; /* Context for common API wrapper call */ H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE7("*x", "*x*#i*siix", obj, loc_params, connector_id, name, aapl_id, dxpl_id, req); /* Check args and get class pointer */ @@ -1169,12 +1353,24 @@ H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") - /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__attr_open(obj, loc_params, cls, name, aapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + /* Set up context */ + ctx.obj = obj; + ctx.loc_params = loc_params; + ctx.cls = cls; + ctx.name = name; + ctx.aapl_id = aapl_id; + ctx.dxpl_id = dxpl_id; + ctx.req = req; + + /* Invoke bounce routine */ + if (H5VL__common_api_op(dxpl_id, H5VL__attr_open_api_op, &ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, NULL, "unable to execute bounce operation") + + /* Set return value */ + ret_value = ctx.ret_value; done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_open() */ /*------------------------------------------------------------------------- @@ -1255,9 +1451,12 @@ herr_t H5VLattr_read(void *obj, hid_t connector_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ + H5P_genplist_t * dxpl_plist = NULL; /* DXPL property list pointer */ + hbool_t new_api_ctx = FALSE; /* Whether to start a new API context */ + hbool_t api_pushed = FALSE; /* Indicate that a new API context was pushed */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*xii*xix", obj, connector_id, mem_type_id, buf, dxpl_id, req); /* Check args and get class pointer */ @@ -1266,12 +1465,46 @@ H5VLattr_read(void *obj, hid_t connector_id, hid_t mem_type_id, void *buf, hid_t if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + /* Check for non-default DXPL */ + if (!(H5P_DEFAULT == dxpl_id || H5P_DATASET_XFER_DEFAULT == dxpl_id)) { + /* Check for 'new API context' flag */ + if (NULL == (dxpl_plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + if (H5P_get(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &new_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get value") + + /* Start a new API context, if requested */ + if (new_api_ctx) { + hbool_t reset_api_ctx = FALSE; /* Flag to reset the 'new API context' */ + + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context") \ + api_pushed = TRUE; + + /* Reset 'new API context' flag for next layer down */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &reset_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + } /* end if */ + } /* end if */ + /* Call the corresponding internal VOL routine */ if (H5VL__attr_read(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read attribute") done: - FUNC_LEAVE_API_NOINIT(ret_value) + /* Pop the API context, if it was pushed */ + if(api_pushed) { + hbool_t undo_api_ctx = TRUE; /* Flag to reset the 'new API context' */ + + /* Undo change to 'new API context' flag */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &undo_api_ctx) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + + (void)H5CX_pop(FALSE); \ + } /* end if */ + + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_read() */ /*------------------------------------------------------------------------- @@ -1354,9 +1587,12 @@ H5VLattr_write(void *obj, hid_t connector_id, hid_t mem_type_id, const void *buf void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ + H5P_genplist_t * dxpl_plist = NULL; /* DXPL property list pointer */ + hbool_t new_api_ctx = FALSE; /* Whether to start a new API context */ + hbool_t api_pushed = FALSE; /* Indicate that a new API context was pushed */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*xii*xix", obj, connector_id, mem_type_id, buf, dxpl_id, req); /* Check args and get class pointer */ @@ -1365,12 +1601,46 @@ H5VLattr_write(void *obj, hid_t connector_id, hid_t mem_type_id, const void *buf if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + /* Check for non-default DXPL */ + if (!(H5P_DEFAULT == dxpl_id || H5P_DATASET_XFER_DEFAULT == dxpl_id)) { + /* Check for 'new API context' flag */ + if (NULL == (dxpl_plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + if (H5P_get(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &new_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get value") + + /* Start a new API context, if requested */ + if (new_api_ctx) { + hbool_t reset_api_ctx = FALSE; /* Flag to reset the 'new API context' */ + + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context") \ + api_pushed = TRUE; + + /* Reset 'new API context' flag for next layer down */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &reset_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + } /* end if */ + } /* end if */ + /* Call the corresponding internal VOL routine */ if (H5VL__attr_write(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write attribute") done: - FUNC_LEAVE_API_NOINIT(ret_value) + /* Pop the API context, if it was pushed */ + if(api_pushed) { + hbool_t undo_api_ctx = TRUE; /* Flag to reset the 'new API context' */ + + /* Undo change to 'new API context' flag */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &undo_api_ctx) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + + (void)H5CX_pop(FALSE); \ + } /* end if */ + + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_write() */ /*------------------------------------------------------------------------- @@ -1451,9 +1721,12 @@ herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { H5VL_class_t *cls; /* VOL connector's class struct */ + H5P_genplist_t * dxpl_plist = NULL; /* DXPL property list pointer */ + hbool_t new_api_ctx = FALSE; /* Whether to start a new API context */ + hbool_t api_pushed = FALSE; /* Indicate that a new API context was pushed */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -1464,12 +1737,46 @@ H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_args_t *args, hid_t dx if (NULL == args) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument struct") + /* Check for non-default DXPL */ + if (!(H5P_DEFAULT == dxpl_id || H5P_DATASET_XFER_DEFAULT == dxpl_id)) { + /* Check for 'new API context' flag */ + if (NULL == (dxpl_plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + if (H5P_get(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &new_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get value") + + /* Start a new API context, if requested */ + if (new_api_ctx) { + hbool_t reset_api_ctx = FALSE; /* Flag to reset the 'new API context' */ + + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set API context") \ + api_pushed = TRUE; + + /* Reset 'new API context' flag for next layer down */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &reset_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + } /* end if */ + } /* end if */ + /* Call the corresponding internal VOL routine */ if (H5VL__attr_get(obj, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get attribute information") done: - FUNC_LEAVE_API_NOINIT(ret_value) + /* Pop the API context, if it was pushed */ + if(api_pushed) { + hbool_t undo_api_ctx = TRUE; /* Flag to reset the 'new API context' */ + + /* Undo change to 'new API context' flag */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &undo_api_ctx) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to set value") + + (void)H5CX_pop(FALSE); \ + } /* end if */ + + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_get() */ /*------------------------------------------------------------------------- @@ -1558,7 +1865,7 @@ H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -1573,7 +1880,7 @@ H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute 'specific' callback"); done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_specific() */ /*------------------------------------------------------------------------- @@ -1659,7 +1966,7 @@ H5VLattr_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -1674,7 +1981,7 @@ H5VLattr_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute optional callback"); done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_optional() */ /*------------------------------------------------------------------------- @@ -1793,7 +2100,7 @@ H5VLattr_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiix", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ @@ -1807,7 +2114,7 @@ H5VLattr_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close attribute") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLattr_close() */ /*------------------------------------------------------------------------- @@ -1899,7 +2206,7 @@ H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connect H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE11("*x", "*x*#i*siiiiiix", obj, loc_params, connector_id, name, lcpl_id, type_id, space_id, dcpl_id, dapl_id, dxpl_id, req); @@ -1915,7 +2222,7 @@ H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connect HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create dataset") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_create() */ /*------------------------------------------------------------------------- @@ -2002,7 +2309,7 @@ H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE7("*x", "*x*#i*siix", obj, loc_params, connector_id, name, dapl_id, dxpl_id, req); /* Check args and get class pointer */ @@ -2016,7 +2323,7 @@ H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open dataset") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_open() */ /*------------------------------------------------------------------------- @@ -2103,7 +2410,7 @@ H5VLdataset_read(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_spa H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE8("e", "*xiiiii*xx", obj, connector_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req); @@ -2118,7 +2425,7 @@ H5VLdataset_read(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_spa HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read dataset") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_read() */ /*------------------------------------------------------------------------- @@ -2205,7 +2512,7 @@ H5VLdataset_write(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_sp H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE8("e", "*xiiiii*xx", obj, connector_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req); @@ -2220,7 +2527,7 @@ H5VLdataset_write(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_sp HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write dataset") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_write() */ /*------------------------------------------------------------------------- @@ -2305,7 +2612,7 @@ H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_args_t *args, hi H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -2319,7 +2626,7 @@ H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_args_t *args, hi HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute dataset get callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_get() */ /*------------------------------------------------------------------------- @@ -2405,7 +2712,7 @@ H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_args_t H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -2419,7 +2726,7 @@ H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_args_t HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_specific() */ /*------------------------------------------------------------------------- @@ -2504,7 +2811,7 @@ H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -2518,7 +2825,7 @@ H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_optional() */ /*------------------------------------------------------------------------- @@ -2654,7 +2961,7 @@ H5VLdataset_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiix", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ @@ -2668,7 +2975,7 @@ H5VLdataset_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close dataset") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdataset_close() */ /*------------------------------------------------------------------------- @@ -2758,7 +3065,7 @@ H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE10("*x", "*x*#i*siiiiix", obj, loc_params, connector_id, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req); @@ -2774,7 +3081,7 @@ H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to commit datatype") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdatatype_commit() */ /*------------------------------------------------------------------------- @@ -2861,7 +3168,7 @@ H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE7("*x", "*x*#i*siix", obj, loc_params, connector_id, name, tapl_id, dxpl_id, req); /* Check args and get class pointer */ @@ -2875,7 +3182,7 @@ H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open datatype") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdatatype_open() */ /*------------------------------------------------------------------------- @@ -2960,7 +3267,7 @@ H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_args_t *args, H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -2974,7 +3281,7 @@ H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_args_t *args, HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute datatype get callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdatatype_get() */ /*------------------------------------------------------------------------- @@ -3060,7 +3367,7 @@ H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_args H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -3074,7 +3381,7 @@ H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_args HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdatatype_specific() */ /*------------------------------------------------------------------------- @@ -3203,7 +3510,7 @@ H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -3217,7 +3524,7 @@ H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdatatype_optional() */ /*------------------------------------------------------------------------- @@ -3347,7 +3654,7 @@ H5VLdatatype_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*ou H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiix", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ @@ -3361,7 +3668,7 @@ H5VLdatatype_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*ou HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close datatype") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLdatatype_close() */ /*------------------------------------------------------------------------- @@ -3405,27 +3712,69 @@ done: * Note: Does not have a 'static' version of the routine, since there's * no objects in the container before this operation completes. * - * Return: Success: Pointer to new file - * Failure: NULL + * Return: Success: A file ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ -void * -H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, hid_t dxpl_id, void **req) +hid_t +H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL Class structure for callback info */ - void * ret_value = NULL; /* Return value */ + H5P_genplist_t * fapl_plist; /* Property list pointer */ + H5VL_class_t *cls; /* VOL class structure for callback info */ + H5VL_object_t *vol_obj = NULL; /* Temporary VOL object for file */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + uint64_t supported; /* Whether 'post open' operation is supported by VOL connector */ + void * file = NULL; /* New file created */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI(FAIL) + + /* Get the VOL info from the fapl */ + if (NULL == (fapl_plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") + if (H5P_peek(fapl_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") + + /* Stash a copy of the connector property */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context") /* Get the connector's class */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") + if (NULL == (file = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "file create failed") + + /* Create a temporary VOL object for the file struct */ + if (NULL == (vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file, connector_prop.connector_id, FALSE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "can't create VOL object") + + /* Check for 'post open' callback */ + supported = 0; + if (H5VL__introspect_opt_query(file, cls, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't query optional operation support") + if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + + /* Set up VOL callback arguments */ + file_opt_args.post_open.vol_obj = vol_obj; + file_opt_args.post_open.id_exists = TRUE; + vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN; + vol_cb_args.args = &file_opt_args; + + /* Make the 'post open' callback */ + if (H5VL__file_optional(file, cls, &vol_cb_args, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, H5I_INVALID_HID, "file optional failed") + } /* end if */ + + /* Register ID for VOL object, for future API calls */ + if ((ret_value = H5I_register(H5I_FILE, vol_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file ID") done: FUNC_LEAVE_NOAPI(ret_value) @@ -3445,19 +3794,50 @@ void * H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req /*out*/) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t * fapl_plist = NULL; /* FAPL property list pointer */ + H5P_genplist_t * dxpl_plist = NULL; /* DXPL property list pointer */ + H5VL_object_t *vol_obj = NULL; /* Temporary VOL object for file */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ H5VL_class_t * cls; /* VOL connector's class struct */ + hbool_t new_api_ctx = FALSE; /* Whether to start a new API context */ + hbool_t api_pushed = FALSE; /* Indicate that a new API context was pushed */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE6("*x", "*sIuiiix", name, flags, fcpl_id, fapl_id, dxpl_id, req); /* Get the VOL info from the fapl */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") + if (H5P_peek(fapl_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't get VOL connector info") + + /* Check for non-default DXPL */ + if (!(H5P_DEFAULT == dxpl_id || H5P_DATASET_XFER_DEFAULT == dxpl_id)) { + /* Check for 'new API context' flag */ + if (NULL == (dxpl_plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a dataset transfer property list") + if (H5P_get(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &new_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to get value") + + /* Start a new API context, if requested */ + if (new_api_ctx) { + hbool_t reset_api_ctx = FALSE; /* Flag to reset the 'new API context' */ + + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set API context") \ + api_pushed = TRUE; + + /* Reset 'new API context' flag for next layer down */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &reset_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "unable to set value") + + /* Stash a copy of the connector property */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL connector info in API context") + } /* end if */ + } /* end if */ /* Get class pointer */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) @@ -3467,8 +3847,51 @@ H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create file") + /* Attempt 'post open' callback, for new API contexts */ + if(new_api_ctx) { + uint64_t supported; /* Whether 'post open' operation is supported by VOL connector */ + + /* Check for 'post open' callback */ + supported = 0; + if (H5VL__introspect_opt_query(ret_value, cls, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't query optional operation support") + if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + + /* Create a temporary VOL object for the file struct */ + if (NULL == (vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, ret_value, connector_prop.connector_id, FALSE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "can't create VOL object") + + /* Set up VOL callback arguments */ + file_opt_args.post_open.vol_obj = vol_obj; + file_opt_args.post_open.id_exists = TRUE; + vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN; + vol_cb_args.args = &file_opt_args; + + /* Make the 'post open' callback */ + if (H5VL__file_optional(ret_value, cls, &vol_cb_args, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, NULL, "file optional failed") + } /* end if */ + } /* end if */ + done: - FUNC_LEAVE_API_NOINIT(ret_value) + /* Destroy temporary VOL file object */ + if (vol_obj && H5VL_free_object(vol_obj) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, NULL, "unable to free VOL object") + + /* Pop the API context, if it was pushed */ + if(api_pushed) { + hbool_t undo_api_ctx = TRUE; /* Flag to reset the 'new API context' */ + + /* Undo change to 'new API context' flag */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &undo_api_ctx) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTSET, NULL, "unable to set value") + + (void)H5CX_pop(FALSE); \ + } /* end if */ + + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLfile_create() */ /*------------------------------------------------------------------------- @@ -3607,26 +4030,43 @@ done: * Note: Does not have a 'static' version of the routine, since there's * no objects in the container before this operation completes. * - * Return: Success: Pointer to file. + * Return: Success: Pointer to file VOL object * Failure: NULL * *------------------------------------------------------------------------- */ -void * -H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fapl_id, - hid_t dxpl_id, void **req) +H5VL_object_t * +H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req, hid_t *ret_id /*out*/) { - H5VL_class_t *cls; /* VOL Class structure for callback info */ - void * ret_value = NULL; /* Return value */ + H5P_genplist_t * fapl_plist; /* Property list pointer */ + H5VL_class_t *cls; /* VOL class structure for callback info */ + H5VL_object_t *vol_obj = NULL; /* Temporary VOL object for file */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + void * file = NULL; /* File pointer */ + uint64_t supported; /* Whether 'post open' operation is supported by VOL connector */ + H5VL_object_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) + /* Get the VOL info from the fapl */ + if (NULL == (fapl_plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a file access property list") + if (H5P_peek(fapl_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "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_VOL, H5E_CANTSET, NULL, "can't set VOL connector info in API context") + /* Get the connector's class */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a VOL connector ID") /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) { + if (NULL == (file = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) { hbool_t is_default_conn = TRUE; /* Opening the file failed - Determine whether we should search @@ -3634,13 +4074,13 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned * to attempt to open the file with. This only occurs if the default * VOL connector was used for the initial file open attempt. */ - H5VL__is_default_conn(fapl_id, connector_prop->connector_id, &is_default_conn); + H5VL__is_default_conn(fapl_id, connector_prop.connector_id, &is_default_conn); if (is_default_conn) { H5VL_file_open_find_connector_t find_connector_ud; herr_t iter_ret; - find_connector_ud.connector_prop = connector_prop; + find_connector_ud.connector_prop = &connector_prop; find_connector_ud.filename = name; find_connector_ud.cls = NULL; find_connector_ud.fapl_id = fapl_id; @@ -3659,7 +4099,13 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned */ H5E_clear_stack(NULL); - if (NULL == (ret_value = H5VL__file_open(find_connector_ud.cls, name, flags, + /* Update 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_VOL, H5E_CANTSET, NULL, "can't set VOL connector info in API context") + + if (NULL == (file = H5VL__file_open(find_connector_ud.cls, name, flags, find_connector_ud.fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "can't open file '%s' with VOL connector '%s'", name, @@ -3672,6 +4118,44 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") } /* end if */ + /* Create a VOL object for the file struct */ + if (NULL == (vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file, connector_prop.connector_id, FALSE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "can't create VOL object") + + /* Check for 'post open' callback */ + supported = 0; + if (H5VL__introspect_opt_query(file, cls, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't query optional operation support") + if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + + /* Set up VOL callback arguments */ + file_opt_args.post_open.vol_obj = vol_obj; + file_opt_args.post_open.id_exists = (ret_id != NULL); /* Set the 'id_exists' flag to TRUE when returning an ID */ + vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN; + vol_cb_args.args = &file_opt_args; + + /* Make the 'post open' callback */ + if (H5VL__file_optional(file, cls, &vol_cb_args, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, NULL, "file optional failed") + } /* end if */ + + /* Check for registering ID for file */ + if (ret_id) { + hid_t file_id; /* File ID for file pointer */ + + /* Register ID for VOL object, for future API calls */ + if ((file_id = H5I_register(H5I_FILE, vol_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "unable to register file ID") + + /* Set file ID to return */ + *ret_id = file_id; + } /* end if */ + + /* Set return value */ + ret_value = vol_obj; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_open() */ @@ -3689,20 +4173,51 @@ done: void * H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req /*out*/) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t * fapl_plist = NULL; /* FAPL property list pointer */ + H5P_genplist_t * dxpl_plist = NULL; /* DXPL property list pointer */ + H5VL_object_t *vol_obj = NULL; /* Temporary VOL object for file */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ H5VL_class_t * cls; /* VOL connector's class struct */ + hbool_t new_api_ctx = FALSE; /* Whether to start a new API context */ + hbool_t api_pushed = FALSE; /* Indicate that a new API context was pushed */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE5("*x", "*sIuiix", name, flags, fapl_id, dxpl_id, req); /* Get the VOL info from the fapl */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + if (H5P_peek(fapl_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") + /* Check for non-default DXPL */ + if (!(H5P_DEFAULT == dxpl_id || H5P_DATASET_XFER_DEFAULT == dxpl_id)) { + /* Check for 'new API context' flag */ + if (NULL == (dxpl_plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a dataset transfer property list") + if (H5P_get(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &new_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to get value") + + /* Start a new API context, if requested */ + if (new_api_ctx) { + hbool_t reset_api_ctx = FALSE; /* Flag to reset the 'new API context' */ + + /* Push the API context */ \ + if (H5CX_push() < 0) \ + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set API context") \ + api_pushed = TRUE; + + /* Reset 'new API context' flag for next layer down */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &reset_api_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "unable to set value") + + /* Stash a copy of the connector property */ + if (H5CX_set_vol_connector_prop(&connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL connector info in API context") + } /* end if */ + } /* end if */ + /* Get class pointer */ if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") @@ -3711,8 +4226,51 @@ H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, vo if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open file") + /* Attempt 'post open' callback, for new API contexts */ + if(new_api_ctx) { + uint64_t supported; /* Whether 'post open' operation is supported by VOL connector */ + + /* Check for 'post open' callback */ + supported = 0; + if (H5VL__introspect_opt_query(ret_value, cls, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't query optional operation support") + if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + + /* Create a temporary VOL object for the file struct */ + if (NULL == (vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, ret_value, connector_prop.connector_id, FALSE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "can't create VOL object") + + /* Set up VOL callback arguments */ + file_opt_args.post_open.vol_obj = vol_obj; + file_opt_args.post_open.id_exists = TRUE; + vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN; + vol_cb_args.args = &file_opt_args; + + /* Make the 'post open' callback */ + if (H5VL__file_optional(ret_value, cls, &vol_cb_args, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, NULL, "file optional failed") + } /* end if */ + } /* end if */ + done: - FUNC_LEAVE_API_NOINIT(ret_value) + /* Destroy temporary VOL file object */ + if (vol_obj && H5VL_free_object(vol_obj) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, NULL, "unable to free VOL object") + + /* Pop the API context, if it was pushed */ + if(api_pushed) { + hbool_t undo_api_ctx = TRUE; /* Flag to reset the 'new API context' */ + + /* Undo change to 'new API context' flag */ + if (H5P_set(dxpl_plist, H5D_XFER_PLUGIN_NEW_API_CTX_NAME, &undo_api_ctx) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTSET, NULL, "unable to set value") + + (void)H5CX_pop(FALSE); \ + } /* end if */ + + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLfile_open() */ /*------------------------------------------------------------------------- @@ -3795,7 +4353,7 @@ H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_args_t *args, hid_t dx H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -3809,7 +4367,7 @@ H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_args_t *args, hid_t dx HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute file get callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLfile_get() */ /*------------------------------------------------------------------------- @@ -3856,6 +4414,7 @@ herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args, hid_t dxpl_id, void **req) { const H5VL_class_t *cls; /* VOL connector's class struct */ + H5VL_object_t *reopen_vol_obj = NULL; /* Temporary VOL object for file */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3903,7 +4462,44 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args if (H5VL__file_specific(vol_obj ? vol_obj->data : NULL, cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") + /* Special treatment of file re-open operation */ + if (args->op_type == H5VL_FILE_REOPEN) { + void *reopen_file; /* Pointer to re-opened file */ + uint64_t supported; /* Whether 'post open' operation is supported by VOL connector */ + + /* Get pointer to re-opened file */ + reopen_file = *args->args.reopen.file; + HDassert(reopen_file); + + /* Check for 'post open' callback */ + supported = 0; + if (H5VL__introspect_opt_query(reopen_file, cls, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_POST_OPEN, &supported) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") + if (supported & H5VL_OPT_QUERY_SUPPORTED) { + H5VL_optional_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_native_file_optional_args_t file_opt_args; /* Arguments for optional operation */ + + /* Create a temporary VOL object for the file struct */ + if (NULL == (reopen_vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, reopen_file, vol_obj->connector->id, TRUE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't create VOL object") + + /* Set up VOL callback arguments */ + file_opt_args.post_open.vol_obj = reopen_vol_obj; + file_opt_args.post_open.id_exists = TRUE; + vol_cb_args.op_type = H5VL_NATIVE_FILE_POST_OPEN; + vol_cb_args.args = &file_opt_args; + + /* Make the 'post open' callback */ + if (H5VL__file_optional(reopen_file, cls, &vol_cb_args, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") + } /* end if */ + } /* end if */ + done: + /* Destroy temporary VOL file object */ + if (reopen_vol_obj && H5VL_free_object(reopen_vol_obj) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to free VOL object") + /* 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") @@ -3930,7 +4526,7 @@ H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_args_t *args H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -3942,7 +4538,7 @@ H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_args_t *args HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file specific callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLfile_specific() */ /*------------------------------------------------------------------------- @@ -4026,7 +4622,7 @@ H5VLfile_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -4040,7 +4636,7 @@ H5VLfile_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file optional callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLfile_optional() */ /*------------------------------------------------------------------------- @@ -4170,7 +4766,7 @@ H5VLfile_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiix", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ @@ -4184,7 +4780,7 @@ H5VLfile_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLfile_close() */ /*------------------------------------------------------------------------- @@ -4272,7 +4868,7 @@ H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE9("*x", "*x*#i*siiiix", obj, loc_params, connector_id, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req); @@ -4288,7 +4884,7 @@ H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create group") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLgroup_create() */ /*------------------------------------------------------------------------- @@ -4375,7 +4971,7 @@ H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_i H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE7("*x", "*x*#i*siix", obj, loc_params, connector_id, name, gapl_id, dxpl_id, req); /* Check args and get class pointer */ @@ -4389,7 +4985,7 @@ H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_i HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open group") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLgroup_open() */ /*------------------------------------------------------------------------- @@ -4472,7 +5068,7 @@ H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_args_t *args, hid_t H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -4486,7 +5082,7 @@ H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_args_t *args, hid_t HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute group get callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLgroup_get() */ /*------------------------------------------------------------------------- @@ -4571,7 +5167,7 @@ H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_args_t *ar H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -4585,7 +5181,7 @@ H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_args_t *ar HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLgroup_specific() */ /*------------------------------------------------------------------------- @@ -4672,7 +5268,7 @@ H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hi H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -4687,7 +5283,7 @@ H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hi HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute group optional callback"); done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLgroup_optional() */ /*------------------------------------------------------------------------- @@ -4817,7 +5413,7 @@ H5VLgroup_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/ H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiix", obj, connector_id, dxpl_id, req); /* Check args and get class pointer */ @@ -4831,7 +5427,7 @@ H5VLgroup_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/ HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close group") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLgroup_close() */ /*------------------------------------------------------------------------- @@ -4932,7 +5528,7 @@ H5VLlink_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_ H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE8("e", "*!*x*#iiiix", args, obj, loc_params, connector_id, lcpl_id, lapl_id, dxpl_id, req); /* Get class pointer */ @@ -4944,7 +5540,7 @@ H5VLlink_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_ HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create link") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLlink_create() */ /*------------------------------------------------------------------------- @@ -5038,7 +5634,7 @@ H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE9("e", "*x*#*x*#iiiix", src_obj, loc_params1, dst_obj, loc_params2, connector_id, lcpl_id, lapl_id, dxpl_id, req); @@ -5051,7 +5647,7 @@ H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLlink_copy() */ /*------------------------------------------------------------------------- @@ -5145,7 +5741,7 @@ H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE9("e", "*x*#*x*#iiiix", src_obj, loc_params1, dst_obj, loc_params2, connector_id, lcpl_id, lapl_id, dxpl_id, req); @@ -5158,7 +5754,7 @@ H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "unable to move object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLlink_move() */ /*------------------------------------------------------------------------- @@ -5244,7 +5840,7 @@ H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -5258,7 +5854,7 @@ H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute link get callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLlink_get() */ /*------------------------------------------------------------------------- @@ -5347,7 +5943,7 @@ H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -5362,7 +5958,7 @@ H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute link specific callback"); done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLlink_specific() */ /*------------------------------------------------------------------------- @@ -5448,7 +6044,7 @@ H5VLlink_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -5462,7 +6058,7 @@ H5VLlink_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connecto HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLlink_optional() */ /*------------------------------------------------------------------------- @@ -5610,7 +6206,7 @@ H5VLobject_open(void *obj, const H5VL_loc_params_t *params, hid_t connector_id, H5VL_class_t *cls; /* VOL connector's class struct */ void * ret_value = NULL; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(NULL) H5TRACE6("*x", "*x*#i*Itix", obj, params, connector_id, opened_type, dxpl_id, req); /* Check args and get class pointer */ @@ -5624,7 +6220,7 @@ H5VLobject_open(void *obj, const H5VL_loc_params_t *params, hid_t connector_id, HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLobject_open() */ /*------------------------------------------------------------------------- @@ -5720,7 +6316,7 @@ H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const ch H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE11("e", "*x*#*s*x*#*siiiix", src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, connector_id, ocpypl_id, lcpl_id, dxpl_id, req); @@ -5736,7 +6332,7 @@ H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const ch HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLobject_copy() */ /*------------------------------------------------------------------------- @@ -5822,7 +6418,7 @@ H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_i H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -5836,7 +6432,7 @@ H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_i HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute object get callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLobject_get() */ /*------------------------------------------------------------------------- @@ -5925,7 +6521,7 @@ H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -5940,7 +6536,7 @@ H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute object specific callback"); done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLobject_specific() */ /*------------------------------------------------------------------------- @@ -6026,7 +6622,7 @@ H5VLobject_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*x*#i*!ix", obj, loc_params, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -6040,7 +6636,7 @@ H5VLobject_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLobject_optional() */ /*------------------------------------------------------------------------- @@ -6197,7 +6793,7 @@ H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t l H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiVLx", obj, connector_id, lvl, conn_cls); /* Check args */ @@ -6215,7 +6811,7 @@ H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t l HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLintrospect_get_conn_cls() */ /*------------------------------------------------------------------------- @@ -6269,7 +6865,7 @@ H5VLintrospect_get_cap_flags(const void *info, hid_t connector_id, unsigned *cap H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "*xix", info, connector_id, cap_flags); /* Check args */ @@ -6285,7 +6881,7 @@ H5VLintrospect_get_cap_flags(const void *info, hid_t connector_id, unsigned *cap HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector's capability flags") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLintrospect_get_cap_flags() */ /*------------------------------------------------------------------------- @@ -6373,7 +6969,7 @@ H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xiVSIsx", obj, connector_id, subcls, opt_type, flags); /* Get class pointer */ @@ -6385,7 +6981,7 @@ H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLintrospect_opt_query() */ /*------------------------------------------------------------------------- @@ -6466,7 +7062,7 @@ H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5VL_request_s H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiULx", req, connector_id, timeout, status); /* Get class pointer */ @@ -6478,7 +7074,7 @@ H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5VL_request_s HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLrequest_wait() */ /*------------------------------------------------------------------------- @@ -6561,7 +7157,7 @@ H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xiVN*x", req, connector_id, cb, ctx); /* Get class pointer */ @@ -6573,7 +7169,7 @@ H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to register notify callback for request") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLrequest_notify() */ /*------------------------------------------------------------------------- @@ -6653,7 +7249,7 @@ H5VLrequest_cancel(void *req, hid_t connector_id, H5VL_request_status_t *status H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "*xix", req, connector_id, status); /* Get class pointer */ @@ -6665,7 +7261,7 @@ H5VLrequest_cancel(void *req, hid_t connector_id, H5VL_request_status_t *status HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLrequest_cancel() */ /*------------------------------------------------------------------------- @@ -6747,7 +7343,7 @@ H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_args_t H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "*xi*!", req, connector_id, args); /* Get class pointer */ @@ -6760,7 +7356,7 @@ H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_args_t "unable to execute asynchronous request specific callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLrequest_specific() */ /*------------------------------------------------------------------------- @@ -6842,7 +7438,7 @@ H5VLrequest_optional(void *req, hid_t connector_id, H5VL_optional_args_t *args) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE3("e", "*xi*!", req, connector_id, args); /* Get class pointer */ @@ -6855,7 +7451,7 @@ H5VLrequest_optional(void *req, hid_t connector_id, H5VL_optional_args_t *args) "unable to execute asynchronous request optional callback") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLrequest_optional() */ /*------------------------------------------------------------------------- @@ -6972,7 +7568,7 @@ H5VLrequest_free(void *req, hid_t connector_id) H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE2("e", "*xi", req, connector_id); /* Get class pointer */ @@ -6984,7 +7580,7 @@ H5VLrequest_free(void *req, hid_t connector_id) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to free request") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLrequest_free() */ /*------------------------------------------------------------------------- @@ -7068,7 +7664,7 @@ H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void * H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*xi*xz*x*x", obj, connector_id, buf, size, blob_id, ctx); /* Get class pointer */ @@ -7082,7 +7678,7 @@ H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void * HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLblob_put() */ /*------------------------------------------------------------------------- @@ -7163,7 +7759,7 @@ H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf /*out H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE6("e", "*xi*xxz*x", obj, connector_id, blob_id, buf, size, ctx); /* Get class pointer */ @@ -7177,7 +7773,7 @@ H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf /*out HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLblob_get() */ /*------------------------------------------------------------------------- @@ -7260,7 +7856,7 @@ H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specif H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xi*x*!", obj, connector_id, blob_id, args); /* Get class pointer */ @@ -7274,7 +7870,7 @@ H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specif HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob specific operation failed") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLblob_specific() */ /*------------------------------------------------------------------------- @@ -7357,7 +7953,7 @@ H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_optional_ar H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE4("e", "*xi*x*!", obj, connector_id, blob_id, args); /* Get class pointer */ @@ -7371,7 +7967,7 @@ H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_optional_ar HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob optional operation failed") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLblob_optional() */ /*------------------------------------------------------------------------- @@ -7479,7 +8075,7 @@ H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, const H5 H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*k*k*Is", obj, connector_id, token1, token2, cmp_value); /* Check args and get class pointer */ @@ -7495,7 +8091,7 @@ H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, const H5 HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLtoken_cmp() */ /*------------------------------------------------------------------------- @@ -7584,7 +8180,7 @@ H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_t H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xIti*k**s", obj, obj_type, connector_id, token, token_str); /* Check args and get class pointer */ @@ -7602,7 +8198,7 @@ H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_t HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token to string failed") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLtoken_to_str() */ /*------------------------------------------------------------------------- @@ -7691,7 +8287,7 @@ H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const cha H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xIti*s*k", obj, obj_type, connector_id, token_str, token); /* Check args and get class pointer */ @@ -7709,7 +8305,7 @@ H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const cha HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token from string failed") done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLtoken_from_str() */ /*------------------------------------------------------------------------- @@ -7792,7 +8388,7 @@ H5VLoptional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dx H5VL_class_t *cls; /* VOL connector's class struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API_NOINIT + FUNC_ENTER_API_WRAPPER(FAIL) H5TRACE5("e", "*xi*!ix", obj, connector_id, args, dxpl_id, req); /* Check args and get class pointer */ @@ -7806,5 +8402,5 @@ H5VLoptional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dx HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute optional callback"); done: - FUNC_LEAVE_API_NOINIT(ret_value) + FUNC_LEAVE_API_WRAPPER(ret_value) } /* end H5VLoptional() */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 70c8112..5fe2c5a 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -917,7 +917,8 @@ done: *------------------------------------------------------------------------- */ H5VL_object_t * -H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id) +H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, + hbool_t wrap_obj) { H5VL_class_t * cls = NULL; /* VOL connector class */ H5VL_t * connector = NULL; /* VOL connector struct */ @@ -940,8 +941,7 @@ H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id) conn_id_incr = TRUE; /* Set up VOL object for the passed-in data */ - /* (Wraps object, since it's a library object) */ - if (NULL == (ret_value = H5VL__new_vol_obj(type, obj, connector, TRUE))) + if (NULL == (ret_value = H5VL__new_vol_obj(type, obj, connector, wrap_obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't create VOL object") done: @@ -1041,7 +1041,7 @@ done: * *------------------------------------------------------------------------- */ -hsize_t +size_t H5VL_object_inc_rc(H5VL_object_t *vol_obj) { FUNC_ENTER_NOAPI_NOERR_NOFS @@ -1086,6 +1086,59 @@ done: } /* end H5VL_free_object() */ /*------------------------------------------------------------------------- + * Function: H5VL_fapl_is_native + * + * Purpose: Query if a FAPL will use the native VOL connector. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * Jun 17, 2021 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_fapl_is_native(hid_t fapl_id, hbool_t *is_native) +{ + H5P_genplist_t * fapl_plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_class_t *cls; /* VOL class structure for callback info */ + const H5VL_class_t *native_cls; /* Native VOL connector class structs */ + int cmp_value; /* Comparison result */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check for default property list value */ + if (H5P_DEFAULT == fapl_id) + fapl_id = H5P_FILE_ACCESS_DEFAULT; + + /* Get the VOL info from the fapl */ + if (NULL == (fapl_plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a file access property list") + if (H5P_peek(fapl_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector info") + + /* Get the connector's class */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Retrieve the native connector class */ + if (NULL == (native_cls = (H5VL_class_t *)H5I_object_verify(H5VL_NATIVE, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve native VOL connector class") + + /* Compare connector classes */ + if (H5VL_cmp_connector_cls(&cmp_value, cls, native_cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") + + /* If classes compare equal, then the object is / is in a native connector's file */ + *is_native = (cmp_value == 0); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_fapl_is_native() */ + +/*------------------------------------------------------------------------- * Function: H5VL_object_is_native * * Purpose: Query if an object is (if it's a file object) / is in (if its @@ -1099,7 +1152,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native) +H5VL_object_is_native(const H5VL_object_t *obj, H5VL_get_conn_lvl_t lvl, hbool_t *is_native) { const H5VL_class_t *cls; /* VOL connector class structs for object */ const H5VL_class_t *native_cls; /* Native VOL connector class structs */ @@ -1114,7 +1167,7 @@ H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native) /* Retrieve the terminal connector class for the object */ cls = NULL; - if (H5VL_introspect_get_conn_cls(obj, H5VL_GET_CONN_LVL_TERM, &cls) < 0) + if (H5VL_introspect_get_conn_cls(obj, lvl, &cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class") /* Retrieve the native connector class */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 18b5b9c..bdac930 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -385,7 +385,7 @@ H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t *token) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL object is a native connector object */ - if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj_container, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") @@ -479,7 +479,7 @@ H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Make sure that the VOL object is a native connector object */ - if (H5VL_object_is_native(vol_obj_container, &is_native_vol_obj) < 0) + if (H5VL_object_is_native(vol_obj_container, H5VL_GET_CONN_LVL_TERM, &is_native_vol_obj) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't determine if VOL object is native connector object") diff --git a/src/H5VLnative.h b/src/H5VLnative.h index fe8ede2..5a9c1d3 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -281,6 +281,12 @@ typedef struct H5VL_native_file_set_libver_bounds_t { H5F_libver_t high; /* Highest version possible */ } H5VL_native_file_set_libver_bounds_t; +/* Parameters for native connector's file 'post open' operation */ +typedef struct H5VL_native_file_post_open_t { + void *vol_obj; /* VOL object for "top" file object */ + hbool_t id_exists; /* Whether an ID (will) exists for this file */ +} H5VL_native_file_post_open_t; + /* Parameters for native connector's file 'optional' operations */ typedef union H5VL_native_file_optional_args_t { /* H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE */ @@ -392,7 +398,7 @@ typedef union H5VL_native_file_optional_args_t { #endif /* H5_HAVE_PARALLEL */ /* H5VL_NATIVE_FILE_POST_OPEN */ - /* No args */ + H5VL_native_file_post_open_t post_open; } H5VL_native_file_optional_args_t; /* Values for native VOL connector group optional VOL operations */ diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 1e674dc..64e18e9 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -92,7 +92,6 @@ H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t /* Create the file */ if (NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") - new_file->id_exists = TRUE; ret_value = (void *)new_file; @@ -126,7 +125,6 @@ H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t H5 /* Open the file */ if (NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - new_file->id_exists = TRUE; ret_value = (void *)new_file; @@ -719,7 +717,7 @@ H5VL__native_file_optional(void *obj, H5VL_optional_args_t *args, hid_t H5_ATTR_ /* Finalize H5Fopen */ case H5VL_NATIVE_FILE_POST_OPEN: { /* Call package routine */ - if (H5F__post_open(f) < 0) + if (H5F__post_open(f, opt_args->post_open.vol_obj, opt_args->post_open.id_exists) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't finish opening file") break; } @@ -752,15 +750,12 @@ H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_U FUNC_ENTER_PACKAGE - /* This routine should only be called when a file ID's ref count drops to zero */ - HDassert(H5F_ID_EXISTS(f)); - /* Flush file if this is the last reference to this id and we have write * intent, unless it will be flushed by the "shared" file being closed. * This is only necessary to replicate previous behaviour, and could be * disabled by an option/property to improve performance. */ - if ((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + if (H5F_ID_EXISTS(f) && (H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { /* Get the file ID corresponding to the H5F_t struct */ if (H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) HGOTO_ERROR(H5E_ID, H5E_CANTGET, FAIL, "invalid ID") diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index f929d03..6550387 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -97,10 +97,11 @@ H5_DLL void *H5VL_object_unwrap(const H5VL_object_t *vol_obj); H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type); H5_DLL H5VL_object_t *H5VL_vol_object(hid_t id); H5_DLL H5VL_object_t *H5VL_create_object(void *object, H5VL_t *vol_connector); -H5_DLL H5VL_object_t *H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id); -H5_DLL hsize_t H5VL_object_inc_rc(H5VL_object_t *obj); +H5_DLL H5VL_object_t *H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t wrap_obj); +H5_DLL size_t H5VL_object_inc_rc(H5VL_object_t *obj); H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); -H5_DLL herr_t H5VL_object_is_native(const H5VL_object_t *obj, hbool_t *is_native); +H5_DLL herr_t H5VL_fapl_is_native(hid_t fapl_id, hbool_t *is_native); +H5_DLL herr_t H5VL_object_is_native(const H5VL_object_t *obj, H5VL_get_conn_lvl_t lvl, hbool_t *is_native); H5_DLL herr_t H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, hbool_t *same_file); @@ -206,10 +207,8 @@ H5_DLL herr_t H5VL_datatype_optional_op(H5VL_object_t *vol_obj, H5VL_optional_ar H5_DLL herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* File functions */ -H5_DLL void * H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, - hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL void * H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, - hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL H5VL_object_t * H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req, hid_t *ret_id); H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args, hid_t dxpl_id, diff --git a/src/H5VLtest.c b/src/H5VLtest.c index 1f99ce5..0769fff 100644 --- a/src/H5VLtest.c +++ b/src/H5VLtest.c @@ -31,9 +31,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5VLpkg.h" /* Virtual Object Layer */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLpkg.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -94,3 +97,4 @@ H5VL__reparse_def_vol_conn_variable_test(void) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__reparse_def_vol_conn_variable_test() */ + diff --git a/src/H5private.h b/src/H5private.h index ed17d4c..4f74d16 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2092,6 +2092,7 @@ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ /* Forward declaration of H5CXpush() / H5CXpop() */ /* (Including H5CXprivate.h creates bad circular dependencies - QAK, 3/18/2018) */ H5_DLL herr_t H5CX_push(void); +H5_DLL herr_t H5CX_test_and_push(hbool_t *pushed); H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); #ifndef NDEBUG @@ -2250,6 +2251,28 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ { +/* + * Use this macro for public API functions for the various "plugin" wrappers. + * Examples are: public VOL callback wrappers (e.g. H5VLfile_create, + * H5VLdataset_read, etc.), public VFD callback wrappers (e.g. H5FDopen, + * H5FDread, etc.), etc. + * + */ +#define FUNC_ENTER_API_WRAPPER(err) \ + { \ + { \ + { \ + hbool_t pushed = FALSE; \ + \ + FUNC_ENTER_API_COMMON \ + H5_PUSH_FUNC \ + /* Push an API context, if there isn't already one */ \ + if (H5CX_test_and_push(&pushed) < 0) \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context") \ + \ + BEGIN_MPE_LOG \ + { + /* Note: this macro only works when there's _no_ interface initialization routine for the module */ #define FUNC_ENTER_NOAPI_INIT(err) \ /* Initialize the package, if appropriate */ \ @@ -2507,6 +2530,20 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props); } \ } /*end scope from beginning of FUNC_ENTER*/ +/* Use this macro to match the FUNC_ENTER_API_WRAPPER macro */ +#define FUNC_LEAVE_API_WRAPPER(ret_value) \ + FUNC_LEAVE_API_COMMON(ret_value); \ + if (pushed) \ + (void)H5CX_pop(TRUE); \ + H5_POP_FUNC \ + if (err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ + FUNC_LEAVE_API_THREADSAFE \ + return (ret_value); \ + } \ + } \ + } /*end scope from beginning of FUNC_ENTER*/ + #define FUNC_LEAVE_NOAPI(ret_value) \ ; \ } /*end scope from end of FUNC_ENTER*/ \ diff --git a/src/Makefile.am b/src/Makefile.am index ce6e3b1..c0a98ce 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -157,7 +157,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers # Public component author headers include_HEADERS += H5ESdevelop.h H5FDdevelop.h H5Idevelop.h H5Ldevelop.h \ - H5Tdevelop.h H5TSdevelop.h H5Zdevelop.h + H5Pdevelop.h H5Tdevelop.h H5TSdevelop.h H5Zdevelop.h # install libhdf5.settings in lib directory settingsdir=$(libdir) |