Skip to content

Commit c4b61ee

Browse files
committed
Filter callbacks use internal API
1 parent a28947b commit c4b61ee

File tree

1 file changed

+66
-21
lines changed

1 file changed

+66
-21
lines changed

src/H5Z.c

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -487,15 +487,28 @@ H5Z__check_unregister(hid_t ocpl_id, H5Z_filter_t filter_id)
487487
static int
488488
H5Z__check_unregister_group_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key)
489489
{
490-
hid_t ocpl_id = -1;
491-
H5Z_object_t *object = (H5Z_object_t *)key;
492-
htri_t filter_in_pline = false;
493-
int ret_value = false; /* Return value */
490+
hid_t ocpl_id = -1;
491+
H5Z_object_t *object = (H5Z_object_t *)key;
492+
H5VL_object_t *vol_obj; /* Object for loc_id */
493+
H5VL_group_get_args_t vol_cb_args; /* Arguments to VOL callback */
494+
htri_t filter_in_pline = false;
495+
int ret_value = false; /* Return value */
494496

495497
FUNC_ENTER_PACKAGE
496498

497499
/* Get the group creation property */
498-
if ((ocpl_id = H5Gget_create_plist(obj_id)) < 0)
500+
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_GROUP)))
501+
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid group identifier");
502+
503+
/* Set up VOL callback arguments */
504+
vol_cb_args.op_type = H5VL_GROUP_GET_GCPL;
505+
vol_cb_args.args.get_gcpl.gcpl_id = H5I_INVALID_HID;
506+
507+
/* Get the group creation property list */
508+
if (H5VL_group_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
509+
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, H5I_INVALID_HID, "unable to get group creation properties");
510+
511+
if ((ocpl_id = vol_cb_args.args.get_gcpl.gcpl_id) < 0)
499512
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get group creation property list");
500513

501514
/* Check if the filter is in the group creation property list */
@@ -533,17 +546,30 @@ H5Z__check_unregister_group_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void
533546
*-------------------------------------------------------------------------
534547
*/
535548
static int
536-
H5Z__check_unregister_dset_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key)
549+
H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t obj_id, void *key)
537550
{
538-
hid_t ocpl_id = -1;
539-
H5Z_object_t *object = (H5Z_object_t *)key;
540-
htri_t filter_in_pline = false;
541-
int ret_value = false; /* Return value */
551+
hid_t ocpl_id = -1;
552+
H5Z_object_t *object = (H5Z_object_t *)key;
553+
H5VL_object_t *vol_obj; /* Object for loc_id */
554+
H5VL_dataset_get_args_t vol_cb_args; /* Arguments to VOL callback */
555+
htri_t filter_in_pline = false;
556+
int ret_value = false; /* Return value */
542557

543558
FUNC_ENTER_PACKAGE
544559

545560
/* Get the dataset creation property */
546-
if ((ocpl_id = H5Dget_create_plist(obj_id)) < 0)
561+
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(obj_id, H5I_DATASET)))
562+
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier");
563+
564+
/* Set up VOL callback arguments */
565+
vol_cb_args.op_type = H5VL_DATASET_GET_DCPL;
566+
vol_cb_args.args.get_dcpl.dcpl_id = H5I_INVALID_HID;
567+
568+
/* Get the dataset creation property list */
569+
if (H5VL_dataset_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
570+
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset creation properties");
571+
572+
if ((ocpl_id = vol_cb_args.args.get_dcpl.dcpl_id) < 0)
547573
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get dataset creation property list");
548574

549575
/* Check if the filter is in the dataset creation property list */
@@ -577,29 +603,42 @@ H5Z__check_unregister_dset_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *
577603
*-------------------------------------------------------------------------
578604
*/
579605
static int
580-
H5Z__flush_file_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_PARALLEL_USED *key)
606+
H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_PARALLEL_USED *key)
581607
{
582608

583609
#ifdef H5_HAVE_PARALLEL
584610
H5Z_object_t *object = (H5Z_object_t *)key;
585-
#endif /* H5_HAVE_PARALLEL */
586-
int ret_value = false; /* Return value */
611+
#endif /* H5_HAVE_PARALLEL */
612+
int ret_value = false; /* Return value */
613+
H5VL_file_specific_args_t vol_cb_args_specific; /* Arguments to VOL callback */
614+
H5VL_object_t *vol_obj; /* File for file_id */
615+
H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */
616+
587617
unsigned int intent = 0;
588618

589619
FUNC_ENTER_PACKAGE
590620

591621
/* Sanity checks */
592622
assert(key);
593623

594-
/* Do a global flush if the file is opened for write */
595-
if (H5Fget_intent(obj_id, &intent) < 0)
596-
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Failed to get file intent");
624+
/* Get the internal file structure */
625+
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(obj_id)))
626+
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier");
627+
628+
/* Get intent */
629+
vol_cb_args.op_type = H5VL_FILE_GET_INTENT;
630+
vol_cb_args.args.get_intent.flags = &intent;
597631

632+
/* Get the flags */
633+
if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
634+
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's intent flags");
635+
636+
/* Do a global flush if the file is opened for write */
598637
if (H5F_ACC_RDWR & intent) {
599638

600639
#ifdef H5_HAVE_PARALLEL
601640
H5G_loc_t loc;
602-
H5F_t *f = NULL;
641+
H5F_t *f = NULL;
603642

604643
/* Check if MPIO driver is used */
605644
if (H5G_loc(obj_id, &loc) < 0)
@@ -608,7 +647,7 @@ H5Z__flush_file_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, vo
608647
assert(f);
609648

610649
if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) {
611-
650+
612651
/* Sanity check for collectively calling H5Zunregister, if requested */
613652
/* (Sanity check assumes that a barrier on one file's comm
614653
* is sufficient (i.e. that there aren't different comms for
@@ -632,8 +671,14 @@ H5Z__flush_file_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, vo
632671
#endif /* H5_HAVE_PARALLEL */
633672

634673
/* Call the flush routine for mounted file hierarchies */
635-
if (H5Fflush(obj_id, H5F_SCOPE_GLOBAL) < 0)
636-
HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy");
674+
vol_cb_args_specific.op_type = H5VL_FILE_FLUSH;
675+
vol_cb_args_specific.args.flush.obj_type = H5I_FILE;
676+
vol_cb_args_specific.args.flush.scope = H5F_SCOPE_GLOBAL;
677+
678+
/* Flush the object */
679+
if (H5VL_file_specific(vol_obj, &vol_cb_args_specific, H5P_DATASET_XFER_DEFAULT, NULL) < 0)
680+
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy");
681+
637682
} /* end if */
638683

639684
done:

0 commit comments

Comments
 (0)