From 75bb8add458930420b1d0856605ecc55ff2e12de Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 26 Sep 2019 01:19:13 -0700 Subject: Marked up H5Fget/set_mpi_atomicity() to use the VOL. --- src/H5Fmpi.c | 106 +++++++++++++++++++++++++++++++++++++++----------- src/H5Fprivate.h | 2 + src/H5VLnative.h | 2 + src/H5VLnative_file.c | 18 +++++++++ 4 files changed, 105 insertions(+), 23 deletions(-) diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 7eb4231..1630d6b 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -38,6 +38,8 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -234,6 +236,38 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_set_mpi_atomicity + * + * Purpose: Private call to set the atomicity mode + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + + /* Check args */ + HDassert(file); + + /* Check VFD */ + if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode"); + + /* Set atomicity value */ + if (H5FD_set_mpio_atomicity(file->shared->lf, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set atomicity flag"); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_set_mpi_atomicity() */ + + +/*------------------------------------------------------------------------- * Function: H5Fset_mpi_atomicity * * Purpose: Sets the atomicity mode @@ -249,27 +283,57 @@ done: herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) { - H5F_t *file; - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + int va_flag = (int)flag; /* C is grumpy about passing hbool_t via va_arg */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL); H5TRACE2("e", "ib", file_id, flag); + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + + /* Set atomicity value */ + if (H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_MPI_ATOMICITY, va_flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set MPI atomicity"); + +done: + FUNC_LEAVE_API(ret_value); +} /* end H5Fset_mpi_atomicity() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_mpi_atomicity + * + * Purpose: Private call to get the atomicity mode + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + /* Check args */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + HDassert(file); + HDassert(flag); /* Check VFD */ if (!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode"); - /* set atomicity value */ - if (H5FD_set_mpio_atomicity (file->shared->lf, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set atomicity flag") + /* Get atomicity value */ + if (H5FD_get_mpio_atomicity(file->shared->lf, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get atomicity flag"); done: - FUNC_LEAVE_API(ret_value) -} + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_get_mpi_atomicity() */ /*------------------------------------------------------------------------- @@ -288,27 +352,23 @@ done: herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag) { - H5F_t *file; - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL); H5TRACE2("e", "i*b", file_id, flag); - /* Check args */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - - /* Check VFD */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect VFL driver, does not support MPI atomicity mode") + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); - /* get atomicity value */ - if (H5FD_get_mpio_atomicity (file->shared->lf, flag) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get atomicity flag") + /* Get atomicity value */ + if (H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MPI_ATOMICITY, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MPI atomicity"); done: - FUNC_LEAVE_API(ret_value) -} + FUNC_LEAVE_API(ret_value); +} /* end H5Fget_mpi_atomicity() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index e15025b..c9a1b25 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -859,6 +859,8 @@ H5_DLL int H5F_shared_mpi_get_size(const H5F_shared_t *f_sh); H5_DLL int H5F_mpi_get_size(const H5F_t *f); H5_DLL herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm); H5_DLL herr_t H5F_get_mpi_info(const H5F_t *f, MPI_Info **f_info); +H5_DLL herr_t H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag); +H5_DLL herr_t H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag); #endif /* H5_HAVE_PARALLEL */ /* External file cache routines */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h index ec0ecbc..14e2bdb 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -74,6 +74,8 @@ typedef int H5VL_native_file_optional_t; #define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 24 /* H5Fset_latest_format/libver_bounds */ #define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 25 /* H5Fget_dset_no_attrs_hint */ #define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 26 /* H5Fset_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_GET_MPI_ATOMICITY 27 /* H5Fget_mpi_atomicity */ +#define H5VL_NATIVE_FILE_SET_MPI_ATOMICITY 28 /* H5Fset_mpi_atomicity */ /* Typedef and values for native VOL connector group optional VOL operations */ typedef int H5VL_native_group_optional_t; diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 3c3712a..81cb507 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -800,6 +800,24 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR break; } + /* H5Fget_mpi_atomicity */ + case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: + { + hbool_t *flag = (hbool_t *)HDva_arg(arguments, hbool_t *); + if (H5F_get_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "cannot get MPI atomicity"); + break; + } + + /* H5Fset_mpi_atomicity */ + case H5VL_NATIVE_FILE_SET_MPI_ATOMICITY: + { + hbool_t flag = (hbool_t)HDva_arg(arguments, int); + if (H5F_set_mpi_atomicity(f, flag) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set MPI atomicity"); + break; + } + default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") } /* end switch */ -- cgit v0.12 From 71f36b343ac758029de343c0afa2d6269eb56468 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 26 Sep 2019 15:47:00 -0700 Subject: Converted H5O MD cache cork calls to use the VOL. --- src/H5I.c | 50 ++++++++++++ src/H5Iprivate.h | 1 + src/H5O.c | 210 +++++++++++++++++++++++++++++++++++------------- src/H5Oprivate.h | 5 ++ src/H5VLnative.h | 9 ++- src/H5VLnative_object.c | 34 ++++++++ 6 files changed, 252 insertions(+), 57 deletions(-) diff --git a/src/H5I.c b/src/H5I.c index ab68e38..201ad9a 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -1086,6 +1086,56 @@ done: /*------------------------------------------------------------------------- + * Function: H5I_is_file_object + * + * Purpose: Convenience function to determine if an ID represents + * a file object. + * + * In H5O calls, you can't use object_verify to ensure + * the ID was of the correct class since there's no + * H5I_OBJECT ID class. + * + * Return: Success: TRUE/FALSE + * Failure: FAIL + * + *------------------------------------------------------------------------- + */ +htri_t +H5I_is_file_object(hid_t id) +{ + H5I_type_t id_type = H5I_get_type(id); + htri_t ret_value = FAIL; + + FUNC_ENTER_NOAPI(FAIL); + + /* Fail if the ID type is out of range */ + HDassert(id_type >= 1 && id_type < H5I_NTYPES); + + /* Return TRUE if the ID is a file object (dataset, group, map, or committed + * datatype), FALSE otherwise. + */ + if (H5I_DATASET == id_type || H5I_GROUP == id_type || H5I_MAP == id_type) { + ret_value = TRUE; + } + else if (H5I_DATATYPE == id_type) { + + H5T_t *dt = NULL; + + if(NULL == (dt = (H5T_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get underlying datatype struct") + + ret_value = H5T_is_named(dt); + } + else { + ret_value = FALSE; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5I_is_file_object() */ + + +/*------------------------------------------------------------------------- * Function: H5Iremove_verify * * Purpose: Removes the specified ID from its type, first checking that the diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 9068b5f..cc1ce1f 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -92,6 +92,7 @@ H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); H5_DLL void *H5I_remove(hid_t id); H5_DLL void *H5I_subst(hid_t id, const void *new_object); +H5_DLL htri_t H5I_is_file_object(hid_t id); /* ID registration functions */ H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref); diff --git a/src/H5O.c b/src/H5O.c index e1d0751..0c999ba 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1116,113 +1116,215 @@ done: /*------------------------------------------------------------------------- - * Function: H5Odisable_mdc_flushes + * Function: H5O_disable_mdc_flushes * - * Purpose: To "cork" an object: - * --keep dirty entries associated with the object in the metadata cache + * Purpose: Private version of the metadata cache cork function. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_disable_mdc_flushes(H5O_loc_t *oloc) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + + if (H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5O_disable_mdc_flushes() */ + + +/*------------------------------------------------------------------------- + * Function: H5Odisable_mdc_flushes + * + * Purpose: "Cork" an object, keeping dirty entries associated with the + * object in the metadata cache. + * + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Vailin Choi - * January 2014 + * Programmer: Vailin Choi + * January 2014 * *------------------------------------------------------------------------- */ herr_t H5Odisable_mdc_flushes(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE1("e", "i", object_id); - /* Get the object's oloc */ - if(NULL == (oloc = H5O_get_loc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") + /* Make sure the ID is a file object */ + if (H5I_is_file_object(object_id) != TRUE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); - if(H5AC_cork(oloc->file, oloc->addr, H5AC__SET_CORK, NULL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork an object") + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); + + /* Cork the object */ + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES, &loc_params) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork object"); done: - FUNC_LEAVE_API(ret_value) + FUNC_LEAVE_API(ret_value); } /* H5Odisable_mdc_flushes() */ /*------------------------------------------------------------------------- - * Function: H5Oenable_mdc_flushes + * Function: H5O_enable_mdc_flushes * - * Purpose: To "uncork" an object - * --release keeping dirty entries associated with the object - * in the metadata cache + * Purpose: Private version of the metadata cache uncork function. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_enable_mdc_flushes(H5O_loc_t *oloc) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + + if (H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5O_enable_mdc_flushes() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oenable_mdc_flushes + * + * Purpose: "Uncork" an object, allowing dirty entries associated with + * the object to be flushed. * - * Programmer: Vailin Choi - * January 2014 + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * January 2014 * *------------------------------------------------------------------------- */ herr_t H5Oenable_mdc_flushes(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE1("e", "i", object_id); - /* Get the object's oloc */ - if(NULL == (oloc = H5O_get_loc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") + /* Make sure the ID is a file object */ + if (H5I_is_file_object(object_id) != TRUE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); - /* Set the value */ - if(H5AC_cork(oloc->file, oloc->addr, H5AC__UNCORK, NULL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object") + /* Uncork the object */ + if (H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES, &loc_params) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork object"); done: - FUNC_LEAVE_API(ret_value) + FUNC_LEAVE_API(ret_value); } /* H5Oenable_mdc_flushes() */ /*------------------------------------------------------------------------- - * Function: H5Oare_mdc_flushes_disabled + * Function: H5O_are_mdc_flushes_disabled * - * Purpose: Retrieve the object's "cork" status in the parameter "are_disabled": - * TRUE if mdc flushes for the object is disabled - * FALSE if mdc flushes for the object is not disabled - * Return error if the parameter "are_disabled" is not supplied + * Purpose: Private version of cork status getter. * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL); + + HDassert(are_disabled); + + if (H5AC_cork(oloc->file, oloc->addr, H5AC__GET_CORKED, are_disabled) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5O_are_mdc_flushes_disabled() */ + + +/*------------------------------------------------------------------------- + * Function: H5Oare_mdc_flushes_disabled + * + * Purpose: Retrieve the object's "cork" status in the parameter "are_disabled": + * TRUE if mdc flushes for the object is disabled + * FALSE if mdc flushes for the object is not disabled * - * Programmer: Vailin Choi - * January 2014 + * Return error if the parameter "are_disabled" is not supplied + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi + * January 2014 * *------------------------------------------------------------------------- */ herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; /* Location parameters */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE2("e", "i*b", object_id, are_disabled); - /* Check args */ + /* Sanity check */ + if (!are_disabled) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from ID"); - /* Get the object's oloc */ - if(NULL == (oloc = H5O_get_loc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") - if(!are_disabled) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unable to get object location from ID") + /* Make sure the ID is a file object */ + if (H5I_is_file_object(object_id) != TRUE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID is not a file object"); + + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_vol_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object ID"); + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); /* Get the cork status */ - if(H5AC_cork(oloc->file, oloc->addr, H5AC__GET_CORKED, are_disabled) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") + if (H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED, &loc_params, are_disabled) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve object's cork status"); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 5f34fcd..54e8ec8 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -972,6 +972,11 @@ H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc); H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, hbool_t start_swmr); +/* Cache corking functions */ +H5_DLL herr_t H5O_disable_mdc_flushes(H5O_loc_t *oloc); +H5_DLL herr_t H5O_enable_mdc_flushes(H5O_loc_t *oloc); +H5_DLL herr_t H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled); + /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, H5O_copy_t *cpy_info, hbool_t inc_depth, diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 14e2bdb..5b51e66 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -86,9 +86,12 @@ typedef int H5VL_native_group_optional_t; /* Typedef and values for native VOL connector object optional VOL operations */ typedef int H5VL_native_object_optional_t; -#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ -#define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */ -#define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ +#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ +#define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */ +#define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ +#define H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES 3 /* H5Odisable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES 4 /* H5Oenable_mdc_flushes */ +#define H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED 5 /* H5Oare_mdc_flushes_disabled */ #ifdef __cplusplus extern "C" { diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c index 3f56334..64d3978 100644 --- a/src/H5VLnative_object.c +++ b/src/H5VLnative_object.c @@ -454,6 +454,40 @@ H5VL__native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, break; } + /* H5Odisable_mdc_flushes */ + case H5VL_NATIVE_OBJECT_DISABLE_MDC_FLUSHES: + { + H5O_loc_t *oloc = loc.oloc; + + if (H5O_disable_mdc_flushes(oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCORK, FAIL, "unable to cork the metadata cache"); + + break; + } + + /* H5Oenable_mdc_flushes */ + case H5VL_NATIVE_OBJECT_ENABLE_MDC_FLUSHES: + { + H5O_loc_t *oloc = loc.oloc; + + if (H5O_enable_mdc_flushes(oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork the metadata cache"); + + break; + } + + /* H5Oare_mdc_flushes_disabled */ + case H5VL_NATIVE_OBJECT_ARE_MDC_FLUSHES_DISABLED: + { + H5O_loc_t *oloc = loc.oloc; + hbool_t *are_disabled = (hbool_t *)HDva_arg(arguments, hbool_t *); + + if (H5O_are_mdc_flushes_disabled(oloc, are_disabled) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine metadata cache cork status"); + + break; + } + default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); } /* end switch */ -- cgit v0.12 From c3da9fe70ecf5e3fa11a54702b2ea9884d2d68ef Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 27 Sep 2019 14:25:04 -0700 Subject: Corrected missing parallel #ifdefs. --- src/H5VLnative_file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 81cb507..63574c6 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -800,6 +800,7 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR break; } +#ifdef H5_HAVE_PARALLEL /* H5Fget_mpi_atomicity */ case H5VL_NATIVE_FILE_GET_MPI_ATOMICITY: { @@ -817,6 +818,7 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set MPI atomicity"); break; } +#endif /* H5_HAVE_PARALLEL */ default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") -- cgit v0.12 From e6065c44f73ae237545127f116704e83c19f60de Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 3 Oct 2019 12:12:23 -0700 Subject: Fixed the java assert issue with H5O cache corking calls. --- src/H5I.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/H5I.c b/src/H5I.c index 201ad9a..76faab1 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -1109,7 +1109,8 @@ H5I_is_file_object(hid_t id) FUNC_ENTER_NOAPI(FAIL); /* Fail if the ID type is out of range */ - HDassert(id_type >= 1 && id_type < H5I_NTYPES); + if (id_type < 1 || id_type >= H5I_NTYPES) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID type out of range"); /* Return TRUE if the ID is a file object (dataset, group, map, or committed * datatype), FALSE otherwise. @@ -1122,7 +1123,7 @@ H5I_is_file_object(hid_t id) H5T_t *dt = NULL; if(NULL == (dt = (H5T_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get underlying datatype struct") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to get underlying datatype struct"); ret_value = H5T_is_named(dt); } @@ -1131,7 +1132,7 @@ H5I_is_file_object(hid_t id) } done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value); } /* H5I_is_file_object() */ -- cgit v0.12 From 75f2ed6167b094431fce2b4b700b3cf9da564c51 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 4 Oct 2019 02:03:11 -0700 Subject: Fixed a bug (HDFFV-10899) where the behavior of the deprecated H5Gget_objinfo() call had changed and passing in a non-existing soft link with a statbuf of NULL passed instead of failed (as it should as per the RM). The HDF5 1.8 and 1.10 behavior was restored and H5Gget_objinfo() will now fail and return -1 as before. --- src/H5Gdeprec.c | 159 +++++++++++++++++++++++++++++--------------------------- test/links.c | 9 +++- 2 files changed, 88 insertions(+), 80 deletions(-) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 97a3ccf..fcb16d3 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -926,41 +926,38 @@ herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(FAIL); H5TRACE4("e", "i*sbx", loc_id, name, follow_link, statbuf); /* Check arguments */ - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Set up collective metadata if appropriate */ - if(H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info"); - /* Retrieve object info, if pointer to struct is given */ - if(statbuf) { - H5VL_object_t *vol_obj; /* Object token of loc_id */ - H5VL_loc_params_t loc_params; - - /* Fill out location struct */ - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = name; - loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; - loc_params.obj_type = H5I_get_type(loc_id); + /* Retrieve object info */ + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); - /* Get the location object */ - if(NULL == (vol_obj = H5VL_vol_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the location object */ + if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); - /* Retrieve the object's information */ - if(H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_GROUP_GET_OBJINFO, &loc_params, (unsigned)follow_link, statbuf) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) - } /* end if */ + /* Retrieve the object's information */ + if (H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_GROUP_GET_OBJINFO, &loc_params, (unsigned)follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name); done: - FUNC_LEAVE_API(ret_value) + FUNC_LEAVE_API(ret_value); } /* end H5Gget_objinfo() */ @@ -982,60 +979,64 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { H5G_trav_goi_t *udata = (H5G_trav_goi_t *)_udata; /* User data passed in */ - H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC; /* Check if the name in this group resolved to a valid link */ - if(lnk == NULL && obj_loc == NULL) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name) - - /* Common code to retrieve the file's fileno */ - if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno") - - /* Info for soft and UD links is gotten by H5L_get_info. If we have - * a hard link, follow it and get info on the object - */ - if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { - H5O_info_t oinfo; /* Object information */ - - /* Go retrieve the object information */ - /* (don't need index & heap info) */ - HDassert(obj_loc); - if(H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") - - /* Get mapped object type */ - statbuf->type = H5G_map_obj_type(oinfo.type); - - /* Get object number (i.e. address) for object */ - statbuf->objno[0] = (unsigned long)(oinfo.addr); + if (lnk == NULL && obj_loc == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name); + + /* Only modify user's buffer if it's available */ + if (udata->statbuf) { + H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ + + /* Common code to retrieve the file's fileno */ + if (H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno"); + + /* Info for soft and UD links is gotten by H5L_get_info. If we have + * a hard link, follow it and get info on the object + */ + if (udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { + H5O_info_t oinfo; /* Object information */ + + /* Go retrieve the object information */ + /* (don't need index & heap info) */ + HDassert(obj_loc); + if (H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info"); + + /* Get mapped object type */ + statbuf->type = H5G_map_obj_type(oinfo.type); + + /* Get object number (i.e. address) for object */ + statbuf->objno[0] = (unsigned long)(oinfo.addr); #if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long)); + statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long)); #else - statbuf->objno[1] = 0; + statbuf->objno[1] = 0; #endif - /* Get # of hard links pointing to object */ - statbuf->nlink = oinfo.rc; - - /* Get modification time for object */ - statbuf->mtime = oinfo.ctime; - - /* Retrieve the object header information */ - statbuf->ohdr.size = oinfo.hdr.space.total; - statbuf->ohdr.free = oinfo.hdr.space.free; - statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs; - statbuf->ohdr.nchunks = oinfo.hdr.nchunks; - } /* end if */ + /* Get # of hard links pointing to object */ + statbuf->nlink = oinfo.rc; + + /* Get modification time for object */ + statbuf->mtime = oinfo.ctime; + + /* Retrieve the object header information */ + statbuf->ohdr.size = oinfo.hdr.space.total; + statbuf->ohdr.free = oinfo.hdr.space.free; + statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs; + statbuf->ohdr.nchunks = oinfo.hdr.nchunks; + } + } done: /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value); } /* end H5G__get_objinfo_cb() */ @@ -1062,15 +1063,15 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5G_trav_goi_t udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE; /* Sanity checks */ HDassert(loc); HDassert(name && *name); - HDassert(statbuf); /* Reset stat buffer */ - HDmemset(statbuf, 0, sizeof(H5G_stat_t)); + if (statbuf) + HDmemset(statbuf, 0, sizeof(H5G_stat_t)); /* Set up user data for retrieving information */ udata.statbuf = statbuf; @@ -1078,11 +1079,11 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, udata.loc_file = loc->oloc->file; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : (H5G_TARGET_SLINK | H5G_TARGET_UDLINK)), H5G__get_objinfo_cb, &udata) < 0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + if (H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : (H5G_TARGET_SLINK | H5G_TARGET_UDLINK)), H5G__get_objinfo_cb, &udata) < 0) + HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist"); /* If we're pointing at a soft or UD link, get the real link length and type */ - if(follow_link == 0) { + if (statbuf && follow_link == 0) { H5L_info_t linfo; /* Link information buffer */ herr_t ret; @@ -1090,21 +1091,23 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, * because the object is ".", just treat the object as a hard link. */ H5E_BEGIN_TRY { ret = H5L_get_info(loc, name, &linfo); - } H5E_END_TRY + } H5E_END_TRY; - if(ret >= 0 && linfo.type != H5L_TYPE_HARD) { + if (ret >= 0 && linfo.type != H5L_TYPE_HARD) { statbuf->linklen = linfo.u.val_size; - if(linfo.type == H5L_TYPE_SOFT) + if (linfo.type == H5L_TYPE_SOFT) { statbuf->type = H5G_LINK; - else { /* UD link. H5L_get_info checked for invalid link classes */ + } + else { + /* UD link. H5L_get_info checked for invalid link classes */ HDassert(linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX); statbuf->type = H5G_UDLINK; - } /* end else */ - } /* end if */ - } /* end if */ + } + } + } done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value); } /* end H5G__get_objinfo() */ diff --git a/test/links.c b/test/links.c index 4eb4126..916ad88 100644 --- a/test/links.c +++ b/test/links.c @@ -1576,6 +1576,10 @@ test_deprec(hid_t fapl, hbool_t new_format) if(H5Gget_linkval(group2_id, "soft_link_to_group1", sb_soft1.linklen, tmpstr) < 0) FAIL_STACK_ERROR if(HDstrcmp("link_to_group1", tmpstr)) TEST_ERROR + /* Test non-existing links with H5Gget_objinfo */ + H5E_BEGIN_TRY { + if(H5Gget_objinfo(file_id, "/group2/soft_link_no_exist", TRUE, NULL) >= 0) FAIL_STACK_ERROR + } H5E_END_TRY; /* Test the dangling soft link */ if(H5Gget_objinfo(file_id, "/group2/dangle_soft_link", FALSE, &sb_soft2) < 0) FAIL_STACK_ERROR @@ -14103,7 +14107,8 @@ main(void) nerrors += group_info_old(fapl) < 0 ? 1 : 0; if (minimize_dset_oh) { - if (H5Pclose(dcpl_g) < 0) TEST_ERROR; + if (H5Pclose(dcpl_g) < 0) + TEST_ERROR; dcpl_g = -1; } } /* [un]minimized dataset object headers */ @@ -14141,5 +14146,5 @@ main(void) error: HDputs("*** TESTS FAILED ***"); HDexit(EXIT_FAILURE); -} +} /* end main() */ -- cgit v0.12