summaryrefslogtreecommitdiffstats
path: root/src/H5ESint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@lbl.gov>2021-06-02 20:29:46 (GMT)
committerGitHub <noreply@github.com>2021-06-02 20:29:46 (GMT)
commit4b7f34acc16c7d071a5c1d4519ba2a01354e51db (patch)
tree944c634b581e30979afd91ef05fcef4db4a062da /src/H5ESint.c
parent88a83d56c07f7c462d1866a2a2642a9f2e37dd22 (diff)
downloadhdf5-4b7f34acc16c7d071a5c1d4519ba2a01354e51db.zip
hdf5-4b7f34acc16c7d071a5c1d4519ba2a01354e51db.tar.gz
hdf5-4b7f34acc16c7d071a5c1d4519ba2a01354e51db.tar.bz2
Combo set of async and other changes (#161)
* Update API tracing for new H5VL_request_status_t typedef * Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure * Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation * Remove 'canceled' event status from Java constants * Be safer about releasing resources when inserting a newly opened/created object or file into an event set * Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate". * Remove H5ES_STATUS_CANCELED from Java wrappers also * Apply patch for dynamically registering optional VOL operations * (a) Add async APIs for H5O module as listed in jira issue ID-283. (b) Remove verification of name parameter in async related routines for H55A and H5L modules because it is checked in H5VL_setup* routine. (c) Modify h5dump expected output due to the async changes. * Corrections based on PR feedback. * Further changes to make based on PR feedback. * Remove H5Dwait & H5Fwait (moved to the async connector). Added H5atclose routine. Updated 'optional op' operations. * Fix missed merge marker, and reformatted line * Update API tracing infrastructure for H5atclose callback * Clean up some warnings * Normalize against develop branch * Correct level of indirection * Add doxygen info for H5is_library_terminating and regression tests for it and H5atclose * Relocate prototype (and doxygen info) for H5Aclose * Align w/changes on develop * Move group package initialization code to H5Gint.c, and update tracing macros * Change non-static function declarations to be static * Correct GCC diagnostic macro * Ensure that H5TSpublic.h header gets installed (#129) * Finish moving API routines that invoke VOL framework to main source files. * Fix position of H5Fmount and H5Funmount * Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information. * Add wrappers for dynamically registered optional operations * Fix typo * Update doxygen comment for H5atclose with additional detail. * Add H5VL\*_vararg versions of H5VL routines that use va_list parameters * Implement and test H5S_BLOCK * Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c. * Add H5Iregister_future routine and tests. * Correct return value for H5Lexists_async * Add H5_DLL macro to public H5ES API routines * Update supported -> flags parameter for introspect_query callback * Remove my email address. Update passthrough VOL connector ID. * Fix comment for post_open_api_common * Remove unused non-blocking VOL connector * Minor cleanup in async branch in preparation for merge to develop * Update CMake and the Autotools to use the new pass-through VOL ID * Finish another iteration on public H5ES routines, along with running the code reformatter * Another round of reformatting * Fix for SWMR daily test failures (#160) The H5I_register_using_existing_id() call did not initialize the future ID callbacks, causing the library to segfault when it tried to resolve those function pointers. * Added selective async APIs (#150) * Added selective async APIs Description: Added the following APIs: H5Ropen_attr_async H5Ropen_object_async H5Ropen_region_async H5Mcreate_async H5Mopen_async H5Mput_async H5Mget_async H5Mclose_async H5Tcommit_async H5Topen_async H5Tcopy_async H5Tclose_async - Updated an expected output file to include a new internal function in the error stack for the failure case. * Updated async APIs per reviews, including removing async version of H5Tcopy. * Removed statements that were added by mistake in the previous commit. * Fix compile issues in H5M and warnings elsewhere * Reformat code * Brings VOL_LIST changes from develop. (#163) * Remove H5Dwait and H5Fwait calls, which were incorrectly brought back in * Tiny cleanup of H5Lcreate_hard_async * Run source formatter * Allow for canceled operation in wait_cb * Attempt to fix switch on string value * Re-run source formatter * Add H5S_BLOCK testfile to CMake clean target * Add H5Pset_vol_async API routine and 'get_cap_flags' VOL introspection callback * Clean up warnings * Add H5P(set\|get)_vol_implicit_async API routines to allow \/ disallow implicit asynchronous operations (default is disallowed) * Run formatting script * Remove H5VL_REQUEST_WAIT\* * Warning cleanup * Eliminate strdup()s on statically allocated strings * Warning cleanup * Split H5VLrestore_lib_state into H5VLstart_lib_state and H5VLrestore_lib_state, and rename H5VLreset_lib_state to H5VLfinish_lib_state. * Duplicate strings when building err_info to return to applicatin * Move connector author routines into seperate header files, all included in the new hdf5dev.h header * Run bin/trace to add TRACE macros * Allow H5ES_NONE as a valid, but no-op, parameter to all H5ES API routines that accept an event set ID * Clean up formatting * Remove H5Pset/get_vol_implicit_async * Clean up warning * Remove H5Pget_vol_async and replace with more generic H5Pget_vol_cap_flags * Clean up warnings * Add H5ESfree_err_info convenience routine * Fix typo * Correct matching for cached VOL plugins * Add developer header file * Update for C99 compatibility * Add missing trace macro * Stop clang-format from messing with the trace macros. Don't set up VOL wrappers for 'infrastructure' objects like requests and blobs * Fix warning about formatting a directory * Clean up formatting for H5E_BEGIN_TRY / H5E_END_TRY * Reduce scope of H5ES__close * Enable CMake checks for various types on MacOS * Clean up properly when H5CX_retrieve_state() fails. Also clean up many compiler warnings. * Committing clang-format changes * Merge from develop * Fix mis-placed assert * Remove commented-out code * Re-add macro for unsetenv on Windows (I think it accidentally was merged out) * Strengthen sanity check from error report to assertion * Committing clang-format changes * Add units to the comments for a few fields * Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it. * Committing clang-format changes * Remove H5ESget_time_estimate * Committing clang-format changes * Create developer header for datatype routines and move type conversion register/unregister routines there. * Simplify internal H5VL_setup_name_args and H5VL_setup_idx_args routines * Add H5VLlink_optional_op, allowing dynamicly registered optional operations for the link VOL subclass, also added H5VL_loc_params argument to the link 'optional' callback to allow them to work correctly. * Run bin/format_source on current code * Add H5VLobject_optional_op, allowing dynamicly registered optional operations for the object VOL subclass, also added H5VL_loc_params argument to the object 'optional' callback to allow them to work correctly. * Run bin/format_source on current code * Committing clang-format changes * Revert "Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it." This reverts commit 5ac92014da2682bdba62d7a2524b8d90e38f6b19. * Committing clang-format changes * Convert attribute 'get' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Update tracing macros * Convert attribute 'specific' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert dataset 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to attribute 'get' and 'specific' operation parameters. * Convert datatype 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to H5O_refresh_metadata arguments. * Reduce warnings * Reduce warnings * Track change to datatype 'get' callback * Fix bug with file pointer getting invalidated when object closed * Reformat source * Convert file and group VOL classes 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also small cleanup to the attribute get name operation. Also moved 'mount' and 'unmount' operations to be group specific operations, instead of file specific, to better align with their behavior (mounted files are on groups, so a group is what is operated on). * Remove remainder of merge conflict marking * Convert link VOL class 'create' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Remove some unused local variables * Convert link VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor 'get name by idx' routines to return actual length of name with a parameter instead of the return value, and move some callback context structs for the link interface from the private header file into the source code module, to reduce their visibility scope. * Update tracing macros * Convert link VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert object VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert object VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor H5G_loc_exists, et al, to return 'exists' flag in a parameter and errors with the function return value, instead of overloading both into the return value. And, corrected logic error in test/links.c around non-existant objects in a file. * Convert request VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. * Convert blob VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also removes the H5VL_BLOB_GETSIZE operation, as it's unused in the library and the blob ID size for a container is now returned with H5VL_FILE_GET_CONT_INFO. * Add 'const' to several parameters that are only queried. * Convert all VOL classes' 'optional' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Convert several 'get' routines to return the length of an array in a parameter instead of combining it into the return value. Move several routines to be in less public namespace. Correct direct_chunk test to verify that parameters aren't modified on error. * Switch get/specific/optional VOL callback argument structures to be 'async-friendly'. Also other minor cleanups and bug-fixes. * Add H5Pset_dataset_io_hyperslab_selection / H5S_PLIST feature, to allow skipping H5Dget_space + H5Sselect_hyperslab for async operation * Add dynamic optional operations for request objects * Update dynamic operation test for optional request operations * Update a comment for an operation argument * Run trace and format_source scripts * Committing clang-format changes * Committing clang-format changes Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org> Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org> Co-authored-by: Dana Robinson <derobins@hdfgroup.org> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/H5ESint.c')
-rw-r--r--src/H5ESint.c434
1 files changed, 374 insertions, 60 deletions
diff --git a/src/H5ESint.c b/src/H5ESint.c
index da3f779..6f9efe9 100644
--- a/src/H5ESint.c
+++ b/src/H5ESint.c
@@ -53,11 +53,18 @@
/* Callback context for wait operations */
typedef struct H5ES_wait_ctx_t {
H5ES_t * es; /* Event set being operated on */
- uint64_t timeout; /* Timeout for wait operation */
+ uint64_t timeout; /* Timeout for wait operation (in ns) */
size_t * num_in_progress; /* Count of # of operations that have not completed */
hbool_t *op_failed; /* Flag to indicate an operation failed */
} H5ES_wait_ctx_t;
+/* Callback context for cancel operations */
+typedef struct H5ES_cancel_ctx_t {
+ H5ES_t * es; /* Event set being operated on */
+ size_t * num_not_canceled; /* Count of # of operations were not canceled */
+ hbool_t *op_failed; /* Flag to indicate an operation failed */
+} H5ES_cancel_ctx_t;
+
/* Callback context for get error info (gei) operations */
typedef struct H5ES_gei_ctx_t {
H5ES_t * es; /* Event set being operated on */
@@ -73,9 +80,14 @@ typedef struct H5ES_gei_ctx_t {
/********************/
/* Local Prototypes */
/********************/
+static herr_t H5ES__close(H5ES_t *es);
static herr_t H5ES__close_cb(void *es, void **request_token);
+static herr_t H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app_file,
+ const char *app_func, unsigned app_line, const char *caller, const char *api_args);
static herr_t H5ES__handle_fail(H5ES_t *es, H5ES_event_t *ev);
+static herr_t H5ES__op_complete(H5ES_t *es, H5ES_event_t *ev, H5VL_request_status_t ev_status);
static int H5ES__wait_cb(H5ES_event_t *ev, void *_ctx);
+static int H5ES__cancel_cb(H5ES_event_t *ev, void *_ctx);
static int H5ES__get_err_info_cb(H5ES_event_t *ev, void *_ctx);
static int H5ES__close_failed_cb(H5ES_event_t *ev, void *_ctx);
@@ -233,6 +245,81 @@ done:
} /* end H5ES__create() */
/*-------------------------------------------------------------------------
+ * Function: H5ES__insert
+ *
+ * Purpose: Insert a request token into an event set
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Friday, December 11, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app_file, const char *app_func,
+ unsigned app_line, const char *caller, const char *api_args)
+{
+ H5ES_event_t *ev = NULL; /* Event for request */
+ hbool_t ev_inserted = FALSE; /* Flag to indicate that event is in active list */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(es);
+
+ /* Create new event */
+ if (NULL == (ev = H5ES__event_new(connector, request_token)))
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCREATE, FAIL, "can't create event object")
+
+ /* Copy the app source information */
+ /* The 'app_func' & 'app_file' strings are statically allocated (by the compiler)
+ * there's no need to duplicate them.
+ */
+ ev->op_info.app_file_name = app_file;
+ ev->op_info.app_func_name = app_func;
+ ev->op_info.app_line_num = app_line;
+
+ /* Set the event's operation counter */
+ ev->op_info.op_ins_count = es->op_counter++;
+
+ /* Set the event's timestamp & execution time */
+ ev->op_info.op_ins_ts = H5_now_usec();
+ ev->op_info.op_exec_ts = UINT64_MAX;
+ ev->op_info.op_exec_time = UINT64_MAX;
+
+ /* Copy the API routine's name & arguments */
+ /* The 'caller' string is also statically allocated (by the compiler)
+ * there's no need to duplicate it.
+ */
+ ev->op_info.api_name = caller;
+ if (NULL == (ev->op_info.api_args = H5MM_xstrdup(api_args)))
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy API routine arguments")
+
+ /* Append fully initialized event onto the event set's 'active' list */
+ H5ES__list_append(&es->active, ev);
+ ev_inserted = TRUE;
+
+ /* Invoke the event set's 'insert' callback, if present */
+ if (es->ins_func)
+ if ((es->ins_func)(&ev->op_info, es->ins_ctx) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CALLBACK, FAIL, "'insert' callback for event set failed")
+
+done:
+ /* Release resources on error */
+ if (ret_value < 0)
+ if (ev) {
+ if (ev_inserted)
+ H5ES__list_remove(&es->active, ev);
+ if (H5ES__event_free(ev) < 0)
+ HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release event")
+ }
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5ES__insert() */
+
+/*-------------------------------------------------------------------------
* Function: H5ES_insert
*
* Purpose: Insert a request token into an event set
@@ -247,15 +334,15 @@ done:
herr_t
H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, const char *caller_args, ...)
{
- H5ES_t * es = NULL; /* Event set for the operation */
- H5ES_event_t *ev = NULL; /* Event for request */
- H5RS_str_t * rs = NULL; /* Ref-counted string to compose formatted argument string in */
- const char * app_file; /* Application source file name */
- const char * app_func; /* Application source function name */
- const char * s; /* Pointer to internal string from ref-counted string */
- va_list ap; /* Varargs for caller */
- hbool_t arg_started = FALSE; /* Whether the va_list has been started */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5ES_t * es = NULL; /* Event set for the operation */
+ const char *app_file; /* Application source file name */
+ const char *app_func; /* Application source function name */
+ unsigned app_line; /* Application source line number */
+ H5RS_str_t *rs = NULL; /* Ref-counted string to compose formatted argument string in */
+ const char *api_args; /* Pointer to api_args string from ref-counted string */
+ va_list ap; /* Varargs for caller */
+ hbool_t arg_started = FALSE; /* Whether the va_list has been started */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -273,10 +360,6 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con
if (es->err_occurred)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "event set has failed operations")
- /* Create new event */
- if (NULL == (ev = H5ES__event_new(connector, token)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCREATE, FAIL, "can't create event object")
-
/* Start working on the API routines arguments */
HDva_start(ap, caller_args);
arg_started = TRUE;
@@ -284,24 +367,10 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con
/* Copy the app source information */
(void)HDva_arg(ap, char *); /* Toss the 'app_file' parameter name */
app_file = HDva_arg(ap, char *);
- if (NULL == (ev->app_file = H5MM_strdup(app_file)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy app source file name")
(void)HDva_arg(ap, char *); /* Toss the 'app_func' parameter name */
app_func = HDva_arg(ap, char *);
- if (NULL == (ev->app_func = H5MM_strdup(app_func)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy app source function name")
(void)HDva_arg(ap, char *); /* Toss the 'app_line' parameter name */
- ev->app_line = HDva_arg(ap, unsigned);
-
- /* Set the event's operation counter */
- ev->ev_count = es->op_counter++;
-
- /* Set the event's timestamp */
- ev->ev_time = H5_now_usec();
-
- /* Copy the API routine's name */
- if (NULL == (ev->api_name = H5MM_strdup(caller)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy API routine name")
+ app_line = HDva_arg(ap, unsigned);
/* Create the string for the API routine's arguments */
if (NULL == (rs = H5RS_create(NULL)))
@@ -312,13 +381,12 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con
HDassert(0 == HDstrncmp(caller_args, "*s*sIu", 6));
if (H5_trace_args(rs, caller_args + 6, ap) < 0)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, FAIL, "can't create formatted API arguments")
- if (NULL == (s = H5RS_get_str(rs)))
+ if (NULL == (api_args = H5RS_get_str(rs)))
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL, "can't get pointer to formatted API arguments")
- if (NULL == (ev->api_args = H5MM_strdup(s)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy API routine arguments")
- /* Append fully initialized event onto the event set's 'active' list */
- H5ES__list_append(&es->active, ev);
+ /* Insert the operation into the event set */
+ if (H5ES__insert(es, connector, token, app_file, app_func, app_line, caller, api_args) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "event set has failed operations")
done:
/* Clean up */
@@ -327,15 +395,42 @@ done:
if (rs)
H5RS_decr(rs);
- /* Release resources on error */
- if (ret_value < 0)
- if (ev && H5ES__event_free(ev) < 0)
- HDONE_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release event")
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5ES_insert() */
/*-------------------------------------------------------------------------
+ * Function: H5ES__insert_request
+ *
+ * Purpose: Directly insert a request token into an event set
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Friday, December 11, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5ES__insert_request(H5ES_t *es, H5VL_t *connector, void *token)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(es);
+ HDassert(connector);
+ HDassert(token);
+
+ /* Insert an 'anonymous' operation into the event set */
+ if (H5ES__insert(es, connector, token, NULL, NULL, 0, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "event set has failed operations")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5ES__insert_request() */
+
+/*-------------------------------------------------------------------------
* Function: H5ES__handle_fail
*
* Purpose: Handle a failed event
@@ -370,6 +465,101 @@ H5ES__handle_fail(H5ES_t *es, H5ES_event_t *ev)
} /* end H5ES__handle_fail() */
/*-------------------------------------------------------------------------
+ * Function: H5ES__op_complete
+ *
+ * Purpose: Handle an operation completing
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Friday, December 11, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5ES__op_complete(H5ES_t *es, H5ES_event_t *ev, H5VL_request_status_t ev_status)
+{
+ H5VL_request_specific_args_t vol_cb_args; /* Arguments to VOL callback */
+ hid_t err_stack_id = H5I_INVALID_HID; /* Error stack for failed operation */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(es);
+ HDassert(ev);
+ HDassert(H5VL_REQUEST_STATUS_SUCCEED == ev_status || H5VL_REQUEST_STATUS_FAIL == ev_status ||
+ H5VL_REQUEST_STATUS_CANCELED == ev_status);
+
+ /* Handle each form of event completion */
+ if (H5VL_REQUEST_STATUS_SUCCEED == ev_status || H5VL_REQUEST_STATUS_CANCELED == ev_status) {
+ /* Invoke the event set's 'complete' callback, if present */
+ if (es->comp_func) {
+ H5ES_status_t op_status; /* Status for complete callback */
+
+ /* Set appropriate info for callback */
+ if (H5VL_REQUEST_STATUS_SUCCEED == ev_status) {
+ /* Translate status */
+ op_status = H5ES_STATUS_SUCCEED;
+
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_REQUEST_GET_EXEC_TIME;
+ vol_cb_args.args.get_exec_time.exec_ts = &ev->op_info.op_exec_ts;
+ vol_cb_args.args.get_exec_time.exec_time = &ev->op_info.op_exec_time;
+
+ /* Retrieve the execution time info */
+ if (H5VL_request_specific(ev->request, &vol_cb_args) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL,
+ "unable to retrieve execution time info for operation")
+ }
+ else
+ /* Translate status */
+ op_status = H5ES_STATUS_CANCELED;
+
+ if ((es->comp_func)(&ev->op_info, op_status, H5I_INVALID_HID, es->comp_ctx) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CALLBACK, FAIL, "'complete' callback for event set failed")
+ } /* end if */
+
+ /* Event success or cancellation */
+ if (H5ES__event_completed(ev, &es->active) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, FAIL, "unable to release completed event")
+ } /* end if */
+ else if (H5VL_REQUEST_STATUS_FAIL == ev_status) {
+ /* Invoke the event set's 'complete' callback, if present */
+ if (es->comp_func) {
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_REQUEST_GET_ERR_STACK;
+ vol_cb_args.args.get_err_stack.err_stack_id = H5I_INVALID_HID;
+
+ /* Retrieve the error stack for the operation */
+ if (H5VL_request_specific(ev->request, &vol_cb_args) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, FAIL, "unable to retrieve error stack for operation")
+
+ /* Set values */
+ err_stack_id = vol_cb_args.args.get_err_stack.err_stack_id;
+
+ if ((es->comp_func)(&ev->op_info, H5ES_STATUS_FAIL, err_stack_id, es->comp_ctx) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CALLBACK, FAIL, "'complete' callback for event set failed")
+ } /* end if */
+
+ /* Handle failure */
+ if (H5ES__handle_fail(es, ev) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, FAIL, "unable to handle failed event")
+ } /* end else-if */
+ else
+ HGOTO_ERROR(H5E_EVENTSET, H5E_BADVALUE, FAIL, "unknown event status?!?")
+
+done:
+ /* Clean up */
+ if (H5I_INVALID_HID != err_stack_id)
+ if (H5I_dec_ref(err_stack_id) < 0)
+ HDONE_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL,
+ "unable to decrement ref count on error stack for failed operation")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5ES__op_complete() */
+
+/*-------------------------------------------------------------------------
* Function: H5ES__wait_cb
*
* Purpose: Common routine for testing / waiting on an operation
@@ -405,9 +595,9 @@ H5ES__wait_cb(H5ES_event_t *ev, void *_ctx)
/* Check for status values that indicate we should break out of the loop */
if (ev_status == H5VL_REQUEST_STATUS_FAIL) {
- /* Handle failure */
- if (H5ES__handle_fail(ctx->es, ev) < 0)
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, H5_ITER_ERROR, "unable to handle failed event")
+ /* Handle event completion */
+ if (H5ES__op_complete(ctx->es, ev, ev_status) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event")
/* Record the error */
*ctx->op_failed = TRUE;
@@ -415,13 +605,15 @@ H5ES__wait_cb(H5ES_event_t *ev, void *_ctx)
/* Exit from the iteration */
ret_value = H5_ITER_STOP;
} /* end if */
- else if (ev_status == H5VL_REQUEST_STATUS_SUCCEED) {
- if (H5ES__event_completed(ev, &ctx->es->active) < 0)
+ else if (ev_status == H5VL_REQUEST_STATUS_SUCCEED || ev_status == H5VL_REQUEST_STATUS_CANCELED) {
+ /* Handle event completion */
+ if (H5ES__op_complete(ctx->es, ev, ev_status) < 0)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event")
} /* end else-if */
- else if (ev_status == H5VL_REQUEST_STATUS_CANCELED)
- /* Should never get a status of 'cancel' back from test / wait operation */
- HGOTO_ERROR(H5E_EVENTSET, H5E_BADVALUE, H5_ITER_ERROR, "received 'cancel' status for operation")
+ else if (ev_status == H5VL_REQUEST_STATUS_CANT_CANCEL)
+ /* Should never get a status of 'can't cancel' back from test / wait operation */
+ HGOTO_ERROR(H5E_EVENTSET, H5E_BADVALUE, H5_ITER_ERROR,
+ "received \"can't cancel\" status for operation")
else {
/* Sanity check */
HDassert(ev_status == H5VL_REQUEST_STATUS_IN_PROGRESS);
@@ -489,6 +681,114 @@ done:
} /* end H5ES__wait() */
/*-------------------------------------------------------------------------
+ * Function: H5ES__cancel_cb
+ *
+ * Purpose: Callback for canceling operations
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, December 10, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+H5ES__cancel_cb(H5ES_event_t *ev, void *_ctx)
+{
+ H5ES_cancel_ctx_t * ctx = (H5ES_cancel_ctx_t *)_ctx; /* Callback context */
+ H5VL_request_status_t ev_status = H5VL_REQUEST_STATUS_SUCCEED; /* Status from event's operation */
+ int ret_value = H5_ITER_CONT; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(ev);
+ HDassert(ctx);
+
+ /* Attempt to cancel the request */
+ if (H5VL_request_cancel(ev->request, &ev_status) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCANCEL, H5_ITER_ERROR, "unable to cancel operation")
+
+ /* Check for status values that indicate we should break out of the loop */
+ if (ev_status == H5VL_REQUEST_STATUS_FAIL) {
+ /* Handle event completion */
+ if (H5ES__op_complete(ctx->es, ev, ev_status) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTSET, H5_ITER_ERROR, "unable to handle failed event")
+
+ /* Record the error */
+ *ctx->op_failed = TRUE;
+
+ /* Exit from the iteration */
+ ret_value = H5_ITER_STOP;
+ } /* end if */
+ else if (ev_status == H5VL_REQUEST_STATUS_SUCCEED) {
+ /* Increment "not canceled" counter */
+ (*ctx->num_not_canceled)++;
+
+ /* Handle event completion */
+ if (H5ES__op_complete(ctx->es, ev, ev_status) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event")
+ } /* end else-if */
+ else if (ev_status == H5VL_REQUEST_STATUS_CANT_CANCEL || ev_status == H5VL_REQUEST_STATUS_IN_PROGRESS) {
+ /* Increment "not canceled" counter */
+ (*ctx->num_not_canceled)++;
+ } /* end else-if */
+ else {
+ /* Sanity check */
+ HDassert(ev_status == H5VL_REQUEST_STATUS_CANCELED);
+
+ /* Handle event completion */
+ if (H5ES__op_complete(ctx->es, ev, ev_status) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTRELEASE, H5_ITER_ERROR, "unable to release completed event")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5ES__cancel_cb() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5ES__cancel
+ *
+ * Purpose: Cancel operations in event set
+ *
+ * Return: SUCCEED / FAIL
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, December 10, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5ES__cancel(H5ES_t *es, size_t *num_not_canceled, hbool_t *op_failed)
+{
+ H5ES_cancel_ctx_t ctx; /* Iterator callback context info */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity check */
+ HDassert(es);
+ HDassert(num_not_canceled);
+ HDassert(op_failed);
+
+ /* Set user's parameters to known values */
+ *num_not_canceled = 0;
+ *op_failed = FALSE;
+
+ /* Set up context for iterator callbacks */
+ ctx.es = es;
+ ctx.num_not_canceled = num_not_canceled;
+ ctx.op_failed = op_failed;
+
+ /* Iterate over the events in the set, attempting to cancel them */
+ if (H5ES__list_iterate(&es->active, H5ES__cancel_cb, &ctx) < 0)
+ HGOTO_ERROR(H5E_EVENTSET, H5E_BADITER, FAIL, "iteration failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5ES__cancel() */
+
+/*-------------------------------------------------------------------------
* Function: H5ES__get_err_info_cb
*
* Purpose: Retrieve information about a failed operation
@@ -503,8 +803,9 @@ done:
static int
H5ES__get_err_info_cb(H5ES_event_t *ev, void *_ctx)
{
- H5ES_gei_ctx_t *ctx = (H5ES_gei_ctx_t *)_ctx; /* Callback context */
- int ret_value = H5_ITER_CONT; /* Return value */
+ H5VL_request_specific_args_t vol_cb_args; /* Arguments to VOL callback */
+ H5ES_gei_ctx_t * ctx = (H5ES_gei_ctx_t *)_ctx; /* Callback context */
+ int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_STATIC
@@ -513,22 +814,35 @@ H5ES__get_err_info_cb(H5ES_event_t *ev, void *_ctx)
HDassert(ctx);
/* Copy operation info for event */
- if (NULL == (ctx->curr_err_info->api_name = H5MM_strdup(ev->api_name)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API name")
- if (NULL == (ctx->curr_err_info->api_args = H5MM_strdup(ev->api_args)))
+ /* The 'app_func_name', 'app_file_name', and 'api_name' strings are statically allocated (by the compiler)
+ * so there's no need to duplicate them internally, but they are duplicated
+ * here, when they are given back to the user.
+ */
+ if (NULL == (ctx->curr_err_info->api_name = H5MM_strdup(ev->op_info.api_name)))
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API routine name")
+ if (NULL == (ctx->curr_err_info->api_args = H5MM_strdup(ev->op_info.api_args)))
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API routine arguments")
- if (NULL == (ctx->curr_err_info->app_file_name = H5MM_strdup(ev->app_file)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy app source file name")
- if (NULL == (ctx->curr_err_info->app_func_name = H5MM_strdup(ev->app_func)))
- HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy app function name")
- ctx->curr_err_info->app_line_num = ev->app_line;
- ctx->curr_err_info->op_ins_count = ev->ev_count;
- ctx->curr_err_info->op_ins_ts = ev->ev_time;
+ if (NULL == (ctx->curr_err_info->app_file_name = H5MM_strdup(ev->op_info.app_file_name)))
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 application file name")
+ if (NULL == (ctx->curr_err_info->app_func_name = H5MM_strdup(ev->op_info.app_func_name)))
+ HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 application function name")
+ ctx->curr_err_info->app_line_num = ev->op_info.app_line_num;
+ ctx->curr_err_info->op_ins_count = ev->op_info.op_ins_count;
+ ctx->curr_err_info->op_ins_ts = ev->op_info.op_ins_ts;
+ ctx->curr_err_info->op_exec_ts = ev->op_info.op_exec_ts;
+ ctx->curr_err_info->op_exec_time = ev->op_info.op_exec_time;
+
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_REQUEST_GET_ERR_STACK;
+ vol_cb_args.args.get_err_stack.err_stack_id = H5I_INVALID_HID;
/* Get error stack for event */
- if (H5VL_request_specific(ev->request, H5VL_REQUEST_GET_ERR_STACK, &ctx->curr_err_info->err_stack_id) < 0)
+ if (H5VL_request_specific(ev->request, &vol_cb_args) < 0)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTGET, H5_ITER_ERROR, "unable to retrieve error stack for operation")
+ /* Set value */
+ ctx->curr_err_info->err_stack_id = vol_cb_args.args.get_err_stack.err_stack_id;
+
/* Remove event from event set's failed list */
H5ES__list_remove(&ctx->es->failed, ev);