diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2019-09-19 19:55:03 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2019-10-08 19:30:24 (GMT) |
commit | fa6fdde1bfb8a29cfc86a4b441c49a63f15fd109 (patch) | |
tree | f177a35a87255c46747e497c4281d4843967eee6 /src/H5VLcallback.c | |
parent | eaa65c862b09b399fc4727e664b56b648cfb37d2 (diff) | |
download | hdf5-fa6fdde1bfb8a29cfc86a4b441c49a63f15fd109.zip hdf5-fa6fdde1bfb8a29cfc86a4b441c49a63f15fd109.tar.gz hdf5-fa6fdde1bfb8a29cfc86a4b441c49a63f15fd109.tar.bz2 |
Fix H5VL_blob_get to return size of blob
Fix const in blob API
Add H5HG_HEAP_ID_SIZE macro to return native blob size
Add maximum size for blobs
Fix blob API callbacks to pass VOL file object
Add public wrappers for blob VOL API
Implement passthrough blob callbacks
Update H5Tvlen after callback changes
Update trace information for H5VL blob routines
Fix public header inclusion in native and passthru headers
Diffstat (limited to 'src/H5VLcallback.c')
-rw-r--r-- | src/H5VLcallback.c | 288 |
1 files changed, 259 insertions, 29 deletions
diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index 43739a6..5400356 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -177,7 +177,12 @@ static herr_t H5VL__request_specific(void *req, const H5VL_class_t *cls, static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, va_list arguments); static herr_t H5VL__request_free(void *req, const H5VL_class_t *cls); - +static herr_t H5VL__blob_put(void *obj, const H5VL_class_t *cls, + const void *buf, size_t size, void *blob_id, void *ctx); +static herr_t H5VL__blob_get(void *obj, const H5VL_class_t *cls, + const void *blob_id, void *buf, size_t *size, void *ctx); +static herr_t H5VL__blob_specific(void *obj, const H5VL_class_t *cls, + void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments); /*********************/ /* Package Variables */ @@ -6564,81 +6569,230 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_blob_put + * Function: H5VL__blob_put * * Purpose: Put a blob through the VOL * * Return: SUCCEED / FAIL * - * Programmer: Quincey Koziol - * Wednesday, August 21, 2019 - * *------------------------------------------------------------------------- */ -herr_t -H5VL_blob_put(const H5VL_class_t *cls, void *blob, size_t size, void *ctx, void *id) +static herr_t +H5VL__blob_put(void *obj, const H5VL_class_t *cls, const void *buf, size_t size, + void *blob_id, void *ctx) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity check */ + HDassert(obj); HDassert(cls); - HDassert(size == 0 || blob); - HDassert(id); + HDassert(size == 0 || buf); + HDassert(blob_id); /* Check if the corresponding VOL callback exists */ if(NULL == cls->blob_cls.put) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob put' method") /* Call the corresponding VOL callback */ - if((cls->blob_cls.put)(blob, size, ctx, id) < 0) + if((cls->blob_cls.put)(obj, buf, size, blob_id, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put callback failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_blob_put() */ +} /* end H5VL__blob_put() */ /*------------------------------------------------------------------------- - * Function: H5VL_blob_get + * Function: H5VL_blob_put * - * Purpose: Get a blob through the VOL + * Purpose: Put a blob through the VOL * * Return: SUCCEED / FAIL * * Programmer: Quincey Koziol - * Friday, August 16, 2019 + * Wednesday, August 21, 2019 * *------------------------------------------------------------------------- */ herr_t -H5VL_blob_get(const H5VL_class_t *cls, const void *id, void *ctx, void *buf) +H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, + void *blob_id, void *ctx) { + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ + HDassert(vol_obj); + HDassert(size == 0 || buf); + HDassert(blob_id); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding VOL callback */ + if(H5VL__blob_put(vol_obj->data, vol_obj->connector->cls, buf, size, blob_id, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_blob_put() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLblob_put + * + * Purpose: Put a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, + void *blob_id, void *ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xi*xz*x*x", obj, connector_id, buf, size, blob_id, ctx); + + /* Get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + 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") + + /* Call the corresponding VOL callback */ + if(H5VL__blob_put(obj, cls, buf, size, blob_id, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLblob_put() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__blob_get + * + * Purpose: Get a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__blob_get(void *obj, const H5VL_class_t *cls, const void *blob_id, + void *buf, size_t *size, void *ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); HDassert(cls); - HDassert(id); - HDassert(buf); + HDassert(blob_id); + HDassert(size || buf); /* Check if the corresponding VOL callback exists */ if(NULL == cls->blob_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob get' method") /* Call the corresponding VOL callback */ - if((cls->blob_cls.get)(id, ctx, buf) < 0) + if((cls->blob_cls.get)(obj, blob_id, buf, size, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get callback failed") done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__blob_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_blob_get + * + * Purpose: Get a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, + size_t *size, void *ctx) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(blob_id); + HDassert(size || buf); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding VOL callback */ + if(H5VL__blob_get(vol_obj->data, vol_obj->connector->cls, blob_id, buf, size, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_blob_get() */ /*------------------------------------------------------------------------- - * Function: H5VL_blob_specific + * Function: H5VLblob_get + * + * Purpose: Get a blob through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf, + size_t *size, void *ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xi*x*x*z*x", obj, connector_id, blob_id, buf, size, ctx); + + /* Get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + 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") + + /* Call the corresponding VOL callback */ + if(H5VL__blob_get(obj, cls, blob_id, buf, size, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLblob_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__blob_specific * * Purpose: Specific operation on blobs through the VOL * @@ -6649,28 +6803,66 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5VL_blob_specific(const H5VL_class_t *cls, void *id, - H5VL_blob_specific_t specific_type, ...) +static herr_t +H5VL__blob_specific(void *obj, const H5VL_class_t *cls, void *blob_id, + H5VL_blob_specific_t specific_type, va_list arguments) { - va_list arguments; /* Argument list passed from the API call */ - hbool_t arg_started = FALSE; /* Whether the va_list has been started */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity check */ + HDassert(obj); HDassert(cls); - HDassert(id); + HDassert(blob_id); /* Check if the corresponding VOL callback exists */ if(NULL == cls->blob_cls.specific) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'blob specific' method") /* Call the corresponding VOL callback */ + if((cls->blob_cls.specific)(obj, blob_id, specific_type, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__blob_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_blob_specific + * + * Purpose: Specific operation on blobs through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, + H5VL_blob_specific_t specific_type, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(blob_id); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ HDva_start(arguments, specific_type); arg_started = TRUE; - if((cls->blob_cls.specific)(id, specific_type, arguments) < 0) + if((ret_value = H5VL__blob_specific(vol_obj->data, vol_obj->connector->cls, blob_id, specific_type, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute blob specific callback") done: @@ -6678,8 +6870,46 @@ done: if(arg_started) HDva_end(arguments); + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_blob_get() */ +} /* end H5VL_blob_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLblob_specific + * + * Purpose: Specific operation on blobs through the VOL + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, + H5VL_blob_specific_t specific_type, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xi*xVBx", obj, connector_id, blob_id, specific_type, arguments); + + /* Get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + 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") + + /* Call the corresponding VOL callback */ + if(H5VL__blob_specific(obj, cls, blob_id, specific_type, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob specific operation failed") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLblob_specific() */ /*------------------------------------------------------------------------- |