From 63ead111fad0e28e95c84bab134e149f4e8cd0d0 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Wed, 28 Mar 2012 13:35:56 -0500 Subject: [svn-r22168] - switch VOL property to be a pointer rather than an ID - rename some utility routines --- src/H5.c | 1 + src/H5F.c | 30 +++--- src/H5Fpkg.h | 4 +- src/H5Fprivate.h | 3 +- src/H5I.c | 16 +-- src/H5Iprivate.h | 2 - src/H5Pfapl.c | 317 ++++++++---------------------------------------------- src/H5Pprivate.h | 8 +- src/H5VL.c | 185 ++++++++----------------------- src/H5VLdummy.c | 114 +++++++++++--------- src/H5VLdummy.h | 6 +- src/H5VLnative.c | 27 ++--- src/H5VLnative.h | 2 +- src/H5VLprivate.h | 8 +- src/H5VLpublic.h | 5 +- src/H5private.h | 1 + 16 files changed, 197 insertions(+), 532 deletions(-) diff --git a/src/H5.c b/src/H5.c index 654c730..ddc6fcb 100644 --- a/src/H5.c +++ b/src/H5.c @@ -130,6 +130,7 @@ H5_init_library(void) H5_debug_g.pkg[H5_PKG_S].name = "s"; H5_debug_g.pkg[H5_PKG_T].name = "t"; H5_debug_g.pkg[H5_PKG_V].name = "v"; + H5_debug_g.pkg[H5_PKG_VL].name = "vl"; H5_debug_g.pkg[H5_PKG_Z].name = "z"; #ifdef H5_HAVE_MPE diff --git a/src/H5F.c b/src/H5F.c index a25ee06..5d3abb1 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -323,13 +323,11 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") if(H5P_set(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &(f->shared->lf->driver_id)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") -#if 1 - /* Increment the reference count on the VOL ID and insert it into the property list */ - if(H5I_inc_ref(f->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL") - if(H5P_set(new_plist, H5F_ACS_VOL_ID_NAME, &(f->vol_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file VOL ID") -#endif + + /* Increment the reference count on the VOL struct and insert it into the property list */ + f->vol_cls->nrefs ++; + if(H5P_set(new_plist, H5F_ACS_VOL_NAME, &(f->vol_cls)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file VOL plugin") /* Set the driver "info" in the property list */ driver_info = H5FD_fapl_get(f->shared->lf); @@ -481,7 +479,7 @@ H5Fget_obj_ids(hid_t uid, unsigned types, size_t max_objs, hid_t *oid_list) /* H5F_get_objects doesn't fail */ ret_value = (ssize_t)H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE); - if (H5I_replace_with_uids (oid_list, ret_value) <= 0) + if (H5VL_replace_with_uids (oid_list, ret_value) <= 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get IDs") done: @@ -1331,9 +1329,9 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") - /* Store the VOL id in the file struct */ - if(H5P_get(a_plist, H5F_ACS_VOL_ID_NAME, &(file->vol_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID") + /* Store a pointer to the VOL plugin in the file struct */ + if(H5P_get(a_plist, H5F_ACS_VOL_NAME, &(file->vol_cls)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin") /* * Decide the file close degree. If it's the first time to open the @@ -1942,6 +1940,7 @@ H5Freopen(hid_t uid) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") new_uid_info->obj_id = new_file_id; new_uid_info->vol_plugin = uid_info->vol_plugin; + new_uid_info->vol_plugin->nrefs ++; if((ret_value = H5I_register(H5I_FILE_PUBLIC, new_uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -2020,11 +2019,8 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) if(NULL == (uid_info = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") uid_info->obj_id = file->file_id; - uid_info->vol_plugin = (H5VL_class_t *)H5I_object(file->vol_id); - - /* increment ref count on the VOL id */ - if(H5I_inc_ref(file->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") + uid_info->vol_plugin = file->vol_cls; + uid_info->vol_plugin->nrefs ++; if((H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -2034,7 +2030,7 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") /* Increment reference count on upper level ID. */ - if(H5I_inc_ref_uid(file->file_id, app_ref) < 0) + if(H5VL_inc_ref_uid(file->file_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing user ID failed") } /* end else */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index bb6cc4e..bdc01a6 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -33,6 +33,7 @@ /* Other public headers needed by this file */ #include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ +#include "H5VLpublic.h" /* Other private headers needed by this file */ #include "H5private.h" /* Generic Functions */ @@ -274,8 +275,7 @@ struct H5F_t { hbool_t closing; /* File is in the process of being closed */ struct H5F_t *parent; /* Parent file that this file is mounted to */ unsigned nmounts; /* Number of children mounted to this file */ - hid_t vol_id; /* id of the vol plugin used to open the file */ - //H5VL_class_t vol_cls; /* class of the VOL plugin */ + struct H5VL_class_t *vol_cls; /* class of the VOL plugin */ }; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 70f73c6..32ad227 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -407,9 +407,8 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ #define H5F_ACS_FILE_DRV_ID_NAME "driver_id" /* File driver ID */ -#define H5F_ACS_VOL_ID_NAME "vol_id" /* File VOL ID */ +#define H5F_ACS_VOL_NAME "vol_cls" /* File VOL plugin */ #define H5F_ACS_FILE_DRV_INFO_NAME "driver_info" /* File driver info */ -#define H5F_ACS_VOL_INFO_NAME "vol_info" /* File VOL info */ #define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ #define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ diff --git a/src/H5I.c b/src/H5I.c index f601b0b..dd0c7b0 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -2206,7 +2206,7 @@ H5Iget_file_id(hid_t uid) if((ret_value = H5I_get_file_id(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") - if (H5I_replace_with_uids (&ret_value, 1) < 0) + if (H5VL_replace_with_uids (&ret_value, 1) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") done: @@ -2244,7 +2244,7 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") /* Increment reference count on upper level ID. */ - if(H5I_inc_ref_uid(obj_id, app_ref) < 0) + if(H5VL_inc_ref_uid(obj_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing user ID failed") /* Set return value */ @@ -2271,7 +2271,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_replace_with_uids + * Function: H5VL_replace_with_uids * * Purpose: change the ids used by the HDF5 libraries to the UIDs that * are provided to the user @@ -2284,7 +2284,7 @@ done: *------------------------------------------------------------------------- */ int -H5I_replace_with_uids(hid_t *old_list, ssize_t num_ids) +H5VL_replace_with_uids(hid_t *old_list, ssize_t num_ids) { ssize_t j; H5I_type_t type; @@ -2342,11 +2342,11 @@ H5I_replace_with_uids(hid_t *old_list, ssize_t num_ids) } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_replace_with_uids() */ +} /* end H5VL_replace_with_uids() */ /*------------------------------------------------------------------------- - * Function: H5I_inc_ref_uid + * Function: H5VL_inc_ref_uid * * Purpose: increment the ref count on the high level ID given the low level ID * @@ -2358,7 +2358,7 @@ done: *------------------------------------------------------------------------- */ int -H5I_inc_ref_uid(hid_t id, hbool_t app_ref) +H5VL_inc_ref_uid(hid_t id, hbool_t app_ref) { H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_type_t type; @@ -2406,7 +2406,7 @@ H5I_inc_ref_uid(hid_t id, hbool_t app_ref) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_inc_ref_uid() */ +} /* end H5VL_inc_ref_uid() */ /*------------------------------------------------------------------------- diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 07f0d5d..3a9e2db 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -79,7 +79,5 @@ H5_DLL int H5I_dec_app_ref_always_close(hid_t id); H5_DLL int H5I_inc_type_ref(H5I_type_t type); H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); H5_DLL int H5I_get_type_ref(H5I_type_t type); -H5_DLL herr_t H5I_replace_with_uids(hid_t *oid_list, ssize_t num_ids); -H5_DLL int H5I_inc_ref_uid(hid_t fid, hbool_t app_ref); #endif /* _H5Iprivate_H */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index e606fc3..13effa6 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -125,13 +125,9 @@ /* Definition for external file cache size */ #define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned) #define H5F_ACS_EFC_SIZE_DEF 0 - -/* Definition for vol ID */ -#define H5F_ACS_VOL_ID_SIZE sizeof(hid_t) -#define H5F_ACS_VOL_ID_DEF H5_DEFAULT_VOL -/* Definition for vol info */ -#define H5F_ACS_VOL_INFO_SIZE sizeof(void*) -#define H5F_ACS_VOL_INFO_DEF NULL +/* Definition for VOL plugin */ +#define H5F_ACS_VOL_SIZE sizeof(void *) +#define H5F_ACS_VOL_DEF H5VL_NATIVE /******************/ /* Local Typedefs */ @@ -224,8 +220,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) hbool_t latest_format = H5F_ACS_LATEST_FORMAT_DEF; /* Default setting for "use the latest version of the format" flag */ hbool_t want_posix_fd = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ unsigned efc_size = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ - hid_t vol_id = H5F_ACS_VOL_ID_DEF; /* Default VOL plugin ID */ - void *vol_info = H5F_ACS_VOL_INFO_DEF; /* Default VOL plugin info */ + H5VL_class_t *vol_cls = H5F_ACS_VOL_DEF; /* Default VOL plugin */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -312,11 +307,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file VOL ID */ - if(H5P_register_real(pclass, H5F_ACS_VOL_ID_NAME, H5F_ACS_VOL_ID_SIZE, &vol_id, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the file VOL info */ - if(H5P_register_real(pclass, H5F_ACS_VOL_INFO_NAME, H5F_ACS_VOL_INFO_SIZE, &vol_info, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if(H5P_register_real(pclass, H5F_ACS_VOL_NAME, H5F_ACS_VOL_SIZE, &vol_cls, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: @@ -344,7 +335,8 @@ done: static herr_t H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data) { - hid_t driver_id, vol_id; + hid_t driver_id; + H5VL_class_t *vol_cls; H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; @@ -354,13 +346,18 @@ H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data) if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + /* Retrieve VOL plugin property */ + if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin") + + /* Set the vol for the property list */ + if(H5VL_fapl_open(plist, vol_cls) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + /* Retrieve driver ID property */ if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") - if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID") - if(driver_id > 0) { void *driver_info; @@ -373,18 +370,6 @@ H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } /* end if */ - if(vol_id > 0) { - void *vol_info; - - /* Retrieve driver info property */ - if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info") - - /* Set the vol for the property list */ - if(H5VL_fapl_open(plist, vol_id, vol_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") - } /* end if */ - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_facc_create() */ @@ -409,46 +394,39 @@ done: static herr_t H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void UNUSED *copy_data) { - hid_t driver_id, vol_id; + hid_t driver_id; + H5VL_class_t *vol_cls; H5P_genplist_t *src_plist; /* Source property list */ + H5P_genplist_t *dst_plist; /* Destination property list */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - /* Get driver ID from source property list */ + if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(H5P_get(src_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") - if(H5P_get(src_plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID") - - if(vol_id > 0) { - H5P_genplist_t *dst_plist; /* Destination property list */ - void *vol_info; - - /* Get vol info from source property list */ - if(H5P_get(src_plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info") + if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* get VOL plugin from source property list */ + if(H5P_get(src_plist, H5F_ACS_VOL_NAME, &vol_cls) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID") + if(NULL != vol_cls) { /* Set the vp; for the destination property list */ - if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(H5VL_fapl_open(dst_plist, vol_id, vol_info) < 0) + if(H5VL_fapl_open(dst_plist, vol_cls) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") } /* end if */ + /* Get driver ID from source property list */ + if(H5P_get(src_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") if(driver_id > 0) { - H5P_genplist_t *dst_plist; /* Destination property list */ void *driver_info; /* Get driver info from source property list */ if(H5P_get(src_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver info") - /* Set the driver for the destination property list */ - if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") if(H5FD_fapl_open(dst_plist, driver_id, driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } /* end if */ @@ -477,9 +455,10 @@ done: herr_t H5P_facc_close(hid_t fapl_id, void UNUSED *close_data) { - hid_t driver_id, vol_id; + hid_t driver_id; + H5VL_class_t *vol_cls; H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -487,26 +466,19 @@ H5P_facc_close(hid_t fapl_id, void UNUSED *close_data) if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - /* Get driver ID property */ - if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ - - /* Get vol ID property */ - if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + /* Get vol plugin */ + if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0) HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ - - if(vol_id > 0) { - void *vol_info; - - /* Get driver info property */ - if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) - HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ - + if(NULL != vol_cls) { /* Close the driver for the property list */ - if(H5VL_fapl_close(vol_id, vol_info) < 0) + if(H5VL_fapl_close(vol_cls) < 0) HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ } /* end if */ + /* Get driver ID property */ + if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ + if(driver_id > 0) { void *driver_info; @@ -2190,224 +2162,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5P_set_vol(H5P_genplist_t *plist, hid_t new_vol_id, const void *new_vol_info) +H5P_set_vol(H5P_genplist_t *plist, H5VL_class_t *vol_cls) { - hid_t vol_id; /* VFL vol ID */ - void *vol_info; /* VFL vol info */ + H5VL_class_t *old_vol_cls; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == H5I_object_verify(new_vol_id, H5I_VOL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file vol ID") - /* Get the current vol information */ - if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + if(H5P_get(plist, H5F_ACS_VOL_NAME, old_vol_cls) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID") - if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL,"can't get vol info") /* Close the vol for the property list */ - if(H5VL_fapl_close(vol_id, vol_info)<0) + if(H5VL_fapl_close(old_vol_cls)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset vol") /* Set the vol for the property list */ - if(H5VL_fapl_open(plist, new_vol_id, new_vol_info)<0) + if(H5VL_fapl_open(plist, vol_cls)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_set_vol() */ - - -/*------------------------------------------------------------------------- - * Function: H5P_get_vol - * - * Purpose: Return the ID of the vol plugin. PLIST_ID should - * be a file access property list. - * - * Return: Success: VOL ID - * - * Failure: Negative - * - * Programmer: Mohamad Chaarawi - * January, 2012 - * - *------------------------------------------------------------------------- - */ -hid_t -H5P_get_vol(H5P_genplist_t *plist) -{ - hid_t ret_value=FAIL; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL); - - /* Get the current vol ID */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { - if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &ret_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID"); - } else { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list"); - } - - if (H5VL_VOL_DEFAULT==ret_value) - ret_value = H5_DEFAULT_VOL; - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5P_get_vol_info - * - * Purpose: Returns a pointer directly to the vol-specific - * information of a fapl. - * Return: Success: Ptr to *uncopied* vol specific data - * structure if any. - * - * Failure: NULL. Null is also returned if the vol has - * not registered any vol-specific properties - * although no error is pushed on the stack in - * this case. - * - * Programmer: Mohamad Chaarawi - * January, 2012 - * - *------------------------------------------------------------------------- - */ -void * -H5P_get_vol_info(H5P_genplist_t *plist) -{ - void *ret_value=NULL; - - FUNC_ENTER_NOAPI(NULL); - - /* Get the current vol info */ - if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { - if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &ret_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,NULL,"can't get vol info"); - } else { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list"); - } - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5P_get_vol_info() */ - -#if 0 - -/*------------------------------------------------------------------------- - * Function: H5Pset_vol - * - * Purpose: Set the file vol (VOL_ID) for a file access property list - * (PLIST_ID) and supply an optional struct containing the - * vol-specific properites (VOL_INFO). The vol properties will - * be copied into the property list and the reference count on - * the vol will be incremented, allowing the caller to close the - * vol ID but still use the property list. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Mohamad Chaarawi - * January, 2012 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ii*x", plist_id, new_vol_id, new_vol_info); - - /* Check arguments */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(NULL == H5I_object_verify(new_vol_id, H5I_VFL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol ID") - - /* Set the vol */ - if(H5P_set_vol(plist, new_vol_id, new_vol_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol info") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_vol() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pget_vol_info - * - * Purpose: Returns a pointer directly to the vol-specific - * information of a fapl. - * Return: Success: Ptr to *uncopied* vol specific data - * structure if any. - * - * Failure: NULL. Null is also returned if the vol has - * not registered any vol-specific properties - * although no error is pushed on the stack in - * this case. - * - * Programmer: Mohamad Chaarawi - * January, 2012 - * - *------------------------------------------------------------------------- - */ -void * -H5Pget_vol_info(hid_t plist_id) -{ - H5P_genplist_t *plist; /* Property list pointer */ - void *ret_value; /* Return value */ - - FUNC_ENTER_API(NULL); - - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") - - if(NULL == (ret_value = H5P_get_vol_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol info") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pget_vol_info() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pget_vol - * - * Purpose: Return the ID of the vol plugin. PLIST_ID should - * be a file access property list. - * - * Return: Success: VOL ID - * - * Failure: Negative - * - * Programmer: Mohamad Chaarawi - * January, 2012 - * - *------------------------------------------------------------------------- - */ -hid_t -H5Pget_vol(hid_t plist_id) -{ - H5P_genplist_t *plist; /* Property list pointer */ - hid_t ret_value; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE1("i", "i", plist_id); - - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - ret_value = H5P_get_vol(plist); - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pget_vol() */ - -#endif diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 5fa35a7..bd7e690 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -22,6 +22,8 @@ /* Include package's public header */ #include "H5Ppublic.h" +#include "H5VLpublic.h" + /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Oprivate.h" /* Object headers */ @@ -42,7 +44,6 @@ typedef struct H5P_genplist_t H5P_genplist_t; typedef struct H5P_genclass_t H5P_genclass_t; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -74,10 +75,7 @@ H5_DLL hid_t H5P_get_driver(H5P_genplist_t *plist); H5_DLL void * H5P_get_driver_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); -H5_DLL hid_t H5P_get_vol(H5P_genplist_t *plist); -H5_DLL void * H5P_get_vol_info(H5P_genplist_t *plist); -H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t new_driver_id, - const void *new_driver_info); +H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, H5VL_class_t *vol_cls); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); diff --git a/src/H5VL.c b/src/H5VL.c index ddb5d67..d6696f0 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -28,6 +28,7 @@ /****************/ #define H5VL_PACKAGE /*suppress error about including H5VLpkg */ +#define H5I_PACKAGE /*suppress error about including H5Ipkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5VL_init_interface @@ -39,6 +40,7 @@ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ +#include "H5Ipkg.h" /* IDs Package header */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Oprivate.h" /* Object headers */ @@ -107,6 +109,7 @@ H5VL_init_interface(void) /* register VOL ID type */ if(H5I_register_type(H5I_VOL, (size_t)H5I_VOL_HASHSIZE, 0, (H5I_free_t)H5VL_free_cls)nrefs++; /* Set the vol properties for the list */ - if(H5P_set(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + if(H5P_set(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set vol ID") - if(H5P_set(plist, H5F_ACS_VOL_INFO_NAME, &copied_vol_info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set vol info") - copied_vol_info = NULL; done: - if(ret_value < 0) - if(copied_vol_info && H5VL_fapl_close(vol_id, copied_vol_info) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of vol info") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_fapl_open() */ /*------------------------------------------------------------------------- - * Function: H5VL_fapl_copy - * - * Purpose: Copies the vol-specific part of the file access property - * list. - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Mohamad Chaarawi - * January, 2012 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_fapl_copy(hid_t vol_id, const void *old_fapl, void **copied_fapl) -{ - H5VL_class_t *vol; - void *new_pl = NULL; /* Copy of property list */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - if(NULL == (vol = (H5VL_class_t *)H5I_object(vol_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol ID") - - /* Copy the file access property list */ - if(old_fapl) { - if(vol->fapl_copy) { - new_pl = (vol->fapl_copy)(old_fapl); - if(new_pl==NULL) - HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "property list copy failed") - } - else if(vol->fapl_size > 0) { - if((new_pl = H5MM_malloc(vol->fapl_size))==NULL) - HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "property list allocation failed") - HDmemcpy(new_pl, old_fapl, vol->fapl_size); - } else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "no way to copy vol property list") - } /* end if */ - - /* Set copied value */ - *copied_fapl=new_pl; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- * Function: H5VL_fapl_close * * Purpose: Closes a vol for a property list @@ -530,30 +466,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_fapl_close(hid_t vol_id, void *fapl) +H5VL_fapl_close(H5VL_class_t *vol_cls) { - H5VL_class_t *vol = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* Check args */ - if(vol_id > 0) { - if(NULL == (vol = (H5VL_class_t *)H5I_object(vol_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol ID") - - /* Allow driver to free or do it ourselves */ - if(fapl && vol->fapl_free) { - if((vol->fapl_free)(fapl) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "driver free request failed") - } /* end if */ - else - H5MM_xfree(fapl); - - /* Decrement reference count for driver */ - if(H5I_dec_ref(vol_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for vol plugin") - } /* end if */ + if(NULL != vol_cls) { + vol_cls->nrefs--; + //H5MM_xfree(vol_cls); + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -579,9 +501,8 @@ hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id) { H5VL_class_t *vol_plugin; /* VOL for file */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *uid_info; /* user id structure */ H5P_genplist_t *plist; /* Property list pointer */ - hid_t plugin_id = -1; /* VOL ID */ hid_t file_id; hid_t ret_value; /* Return value */ @@ -590,10 +511,8 @@ H5VL_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, h /* get the VOL info from the fapl */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin ID") - if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(plugin_id))) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file access property list") + if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_plugin) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin") /* check if the corresponding VOL open callback exists */ if(NULL == vol_plugin->file_cls.open) @@ -602,17 +521,13 @@ H5VL_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, h if((file_id = (vol_plugin->file_cls.open)(name, flags, fcpl_id, fapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - /* Create a new id that points to a struct that holds the file id and the VOL id */ + /* Create a new id that points to a struct that holds the file id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") uid_info->obj_id = file_id; - //uid_info->vol_id = plugin_id; uid_info->vol_plugin = vol_plugin; - - /* increment ref count on the VOL id */ - if(H5I_inc_ref(plugin_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") + vol_plugin->nrefs ++; if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -640,9 +555,8 @@ hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5VL_class_t *vol_plugin; /* VOL for file */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *uid_info; /* user id structure */ H5P_genplist_t *plist; /* Property list pointer */ - hid_t plugin_id = -1; /* VOL ID */ hid_t file_id; hid_t ret_value; /* Return value */ @@ -651,10 +565,8 @@ H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* get the VOL info from the fapl */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) + if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_plugin) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin ID") - if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(plugin_id))) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file access property list") /* check if the corresponding VOL create callback exists */ if(NULL == vol_plugin->file_cls.create) @@ -669,11 +581,7 @@ H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") uid_info->obj_id = file_id; uid_info->vol_plugin = vol_plugin; - //uid_info->vol_id = plugin_id; - - /* increment ref count on the VOL id */ - if(H5I_inc_ref(plugin_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") + vol_plugin->nrefs ++; if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -700,7 +608,7 @@ done: herr_t H5VL_file_close(hid_t uid) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *uid_info; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -713,21 +621,12 @@ H5VL_file_close(hid_t uid) if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") -#if 0 - /* get VOL plugin info */ - if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(uid_info->vol_id))) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file") -#endif if(NULL == uid_info->vol_plugin->file_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file close' method") if((ret_value = (uid_info->vol_plugin->file_cls.close)(uid_info->obj_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed") -#if 0 - /* decrement ref count on the VOL id */ - if(H5I_dec_ref(uid_info->vol_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on vol plugin") -#endif + uid_info->vol_plugin->nrefs--; if(H5I_dec_app_ref(uid) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to decrement ref count on user ID") @@ -753,7 +652,7 @@ done: herr_t H5VL_file_flush(hid_t uid, H5F_scope_t scope) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *uid_info; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -793,7 +692,7 @@ done: herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, int num_args, ...) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *uid_info; /* user id structure */ va_list arguments; /* argument list passed from the API call */ herr_t ret_value = SUCCEED; @@ -828,7 +727,7 @@ done: * Purpose: Creates a group through the VOL * * Return: Success: User ID of the new group. This ID is of type - * H5I_GROUP_PUBLIC which contains the VOL id and the actual group ID + * H5I_GROUP_PUBLIC which contains the VOL plugin and the actual group ID * * Failure: FAIL * @@ -840,8 +739,8 @@ done: hid_t H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the group will be created */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new created group*/ + H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the group will be created */ + H5VL_id_wrapper_t *uid_info2; /* user id structure of new created group*/ hid_t group_id; /* actual group ID */ hid_t ret_value; /* Return value */ @@ -860,7 +759,7 @@ H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid (uid_info1->obj_id, name, lcpl_id, gcpl_id, gapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") - /* Create a new id that points to a struct that holds the group id and the VOL id */ + /* Create a new id that points to a struct that holds the group id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -881,7 +780,7 @@ done: * Purpose: Opens a group through the VOL * * Return: Success: User ID of the new group. This ID is of type - * H5I_GROUP_PUBLIC which contains the VOL id and the actual group ID + * H5I_GROUP_PUBLIC which contains the VOL plugin and the actual group ID * * Failure: FAIL * @@ -893,8 +792,8 @@ done: hid_t H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the group will be opend */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new opend group*/ + H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the group will be opend */ + H5VL_id_wrapper_t *uid_info2; /* user id structure of new opend group*/ hid_t group_id; /* actual group ID */ hid_t ret_value; /* Return value */ @@ -912,7 +811,7 @@ H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id) (uid_info1->obj_id, name, gapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - /* Create a new id that points to a struct that holds the group id and the VOL id */ + /* Create a new id that points to a struct that holds the group id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -1023,7 +922,7 @@ done: * Purpose: Opens a object through the VOL * * Return: Success: User ID of the new object. This ID is of type - * H5I_OBJECT_PUBLIC which contains the VOL id and the actual object ID + * H5I_OBJECT_PUBLIC which contains the VOL plugin and the actual object ID * * Failure: FAIL * @@ -1056,7 +955,7 @@ H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id) (uid_info1->obj_id, obj_loc, lapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - /* Create a new id that points to a struct that holds the object id and the VOL id */ + /* Create a new id that points to a struct that holds the object id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -1282,7 +1181,7 @@ H5VL_datatype_commit(hid_t uid, const char *name, hid_t type_id, hid_t lcpl_id, HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "commit failed") #if 0 - /* Create a new id that points to a struct that holds the datatype id and the VOL id */ + /* Create a new id that points to a struct that holds the datatype id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -1304,7 +1203,7 @@ done: * Purpose: Opens a named datatype through the VOL * * Return: Success: User ID of the datatype. This ID is of type - * H5I_DATATYPE_PUBLIC which contains the VOL id and the actual datatype ID + * H5I_DATATYPE_PUBLIC which contains the VOL plugin and the actual datatype ID * * Failure: FAIL * @@ -1336,7 +1235,7 @@ H5VL_datatype_open(hid_t uid, const char *name, hid_t tapl_id) (uid_info1->obj_id, name, tapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - /* Create a new id that points to a struct that holds the datatype id and the VOL id */ + /* Create a new id that points to a struct that holds the datatype id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -1357,7 +1256,7 @@ done: * Purpose: Creates a dataset through the VOL * * Return: Success: User ID of the new dataset. This ID is of type - * H5I_DATASET_PUBLIC which contains the VOL id and the actual dataset ID + * H5I_DATASET_PUBLIC which contains the VOL plugin and the actual dataset ID * * Failure: FAIL * @@ -1390,7 +1289,7 @@ H5VL_dataset_create(hid_t uid, const char *name, hid_t dtype_id, hid_t space_id, (uid_info1->obj_id, name, dtype_id, space_id, lcpl_id, dcpl_id, dapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") - /* Create a new id that points to a struct that holds the dataset id and the VOL id */ + /* Create a new id that points to a struct that holds the dataset id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -1411,7 +1310,7 @@ done: * Purpose: Opens a dataset through the VOL * * Return: Success: User ID of the new dataset. This ID is of type - * H5I_DATASET_PUBLIC which contains the VOL id and the actual dataset ID + * H5I_DATASET_PUBLIC which contains the VOL plugin and the actual dataset ID * * Failure: FAIL * @@ -1442,7 +1341,7 @@ H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id) (uid_info1->obj_id, name, dapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - /* Create a new id that points to a struct that holds the dataset id and the VOL id */ + /* Create a new id that points to a struct that holds the dataset id and the VOL plugin */ /* Allocate new id structure */ if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index c381f8e..3444919 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -21,68 +21,81 @@ * using HDF5 VFDs. */ +#define H5D_PACKAGE /*suppress error about including H5Dpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5VL_dummy_init_interface #include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Dpkg.h" /* Dataset pkg */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5Fpkg.h" /* File pkg */ -#include "H5VLprivate.h" /* VOL plugins */ -#include "H5VLdummy.h" /* Dummy VOL plugin */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5MFprivate.h" /* File memory management */ #include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL plugins */ +#include "H5VLdummy.h" /* Dummy VOL plugin */ /* The driver identification number, initialized at runtime */ static hid_t H5VL_DUMMY_g = 0; - /* Prototypes */ -static herr_t H5VL_dummy_get(hid_t file_id, H5VL_file_get_t get_type, - void *data, int argc, void **argv); static herr_t H5VL_dummy_term(void); +static hid_t H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id); +static herr_t H5VL_dummy_file_close(hid_t fid); +static hid_t H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); -static const H5VL_class_t H5VL_dummy_g = { +H5VL_class_t H5VL_dummy_g = { "dummy", /* name */ - H5VL_dummy_term, /*terminate */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - { /* file_cls */ - H5VL_dummy_create, /* create */ - H5VL_dummy_open, /* open */ - NULL, /* flush */ - NULL, /* get */ - H5VL_dummy_close /* close */ - }, - { /* dataset_cls */ - NULL, /* open */ - NULL, /* close */ + 0, /* nrefs */ + H5VL_dummy_term, /*terminate */ + { /* attribute_cls */ NULL, /* create */ + NULL, /* open */ NULL, /* read */ NULL, /* write */ - NULL /* set_extent */ - }, - { /* attribute_cls */ - NULL, /* open */ - NULL, /* close */ - NULL, /* create */ NULL, /* delete */ - NULL, /* read */ - NULL /* write */ + NULL /* close */ }, { /* datatype_cls */ - NULL, /* commit */ - NULL /* open */ + NULL, /* commit */ + NULL /* open */ + }, + { /* dataset_cls */ + NULL, /* create */ + NULL, /* open */ + NULL, + NULL, + NULL, + NULL + }, + { /* group_cls */ + NULL, + NULL, + NULL, + NULL + }, + { /* file_cls */ + H5VL_dummy_file_create, /* create */ + H5VL_dummy_file_open, /* open */ + NULL, + NULL, + H5VL_dummy_file_close /* close */ }, { /* link_cls */ NULL, /* create */ @@ -91,13 +104,12 @@ static const H5VL_class_t H5VL_dummy_g = { NULL /* copy */ }, { /* object_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* close */ + NULL, NULL, /* move */ NULL, /* copy */ - NULL, /* lookup */ - NULL /* get */ + NULL, + NULL, + NULL } }; @@ -120,7 +132,7 @@ H5VL_dummy_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - FUNC_LEAVE_NOAPI(H5VL_dummy_init()) + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5VL_dummy_init_interface() */ @@ -138,20 +150,17 @@ H5VL_dummy_init_interface(void) * *------------------------------------------------------------------------- */ -hid_t +H5VL_class_t * H5VL_dummy_init(void) { - hid_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) + H5VL_class_t *ret_value = NULL; /* Return value */ - if(H5I_VOL != H5I_get_type(H5VL_DUMMY_g)) - H5VL_DUMMY_g = H5VL_register(&H5VL_dummy_g, sizeof(H5VL_class_t), FALSE); + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = H5VL_DUMMY_g; + ret_value = &H5VL_dummy_g; + ret_value->nrefs ++; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dummy_init() */ @@ -175,6 +184,7 @@ H5VL_dummy_term(void) /* Reset VOL ID */ H5VL_DUMMY_g = 0; + H5VL_dummy_g.nrefs = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL_dummy_term() */ @@ -205,7 +215,7 @@ H5Pset_fapl_dummy(hid_t fapl_id) if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - ret_value = H5P_set_vol(plist, H5VL_DUMMY, NULL); + ret_value = H5P_set_vol(plist, &H5VL_dummy_g); done: FUNC_LEAVE_API(ret_value) @@ -226,7 +236,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_dummy_open(const char *name, unsigned flags, hid_t fcpl_id, +H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -251,7 +261,7 @@ H5VL_dummy_open(const char *name, unsigned flags, hid_t fcpl_id, *------------------------------------------------------------------------- */ hid_t -H5VL_dummy_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) +H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -275,7 +285,7 @@ H5VL_dummy_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id *------------------------------------------------------------------------- */ herr_t -H5VL_dummy_close(hid_t file_id) +H5VL_dummy_file_close(hid_t file_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5VLdummy.h b/src/H5VLdummy.h index e95098d..86aa0ae 100644 --- a/src/H5VLdummy.h +++ b/src/H5VLdummy.h @@ -28,12 +28,8 @@ extern "C" { #endif -H5_DLL hid_t H5VL_dummy_init(void); +H5_DLL H5VL_class_t *H5VL_dummy_init(void); H5_DLL herr_t H5Pset_fapl_dummy(hid_t fapl_id); -H5_DLL hid_t H5VL_dummy_open(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, hid_t dxpl_id); -H5_DLL hid_t H5VL_dummy_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); -H5_DLL herr_t H5VL_dummy_close(hid_t fid); #ifdef __cplusplus } diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 6c804ef..9b78449 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -96,13 +96,10 @@ static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, int num_args, va_list arguments); -static const H5VL_class_t H5VL_native_g = { +H5VL_class_t H5VL_native_g = { "native", /* name */ - H5VL_native_term, /*terminate */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ + 0, /* nrefs */ + H5VL_native_term, /*terminate */ { /* attribute_cls */ NULL, /* create */ NULL, /* open */ @@ -171,7 +168,7 @@ H5VL_native_init_interface(void) { FUNC_ENTER_NOAPI_NOINIT_NOERR - FUNC_LEAVE_NOAPI(H5VL_native_init()) + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5VL_native_init_interface() */ @@ -189,20 +186,17 @@ H5VL_native_init_interface(void) * *------------------------------------------------------------------------- */ -hid_t +H5VL_class_t * H5VL_native_init(void) { - hid_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) + H5VL_class_t *ret_value = NULL; /* Return value */ - if(H5I_VOL != H5I_get_type(H5VL_NATIVE_g)) - H5VL_NATIVE_g = H5VL_register(&H5VL_native_g, sizeof(H5VL_class_t), FALSE); + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = H5VL_NATIVE_g; + ret_value = &H5VL_native_g; + ret_value->nrefs ++; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_init() */ @@ -226,6 +220,7 @@ H5VL_native_term(void) /* Reset VOL ID */ H5VL_NATIVE_g = 0; + H5VL_native_g.nrefs = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL_native_term() */ @@ -256,7 +251,7 @@ H5Pset_fapl_native(hid_t fapl_id) if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - ret_value = H5P_set_vol(plist, H5VL_NATIVE, NULL); + ret_value = H5P_set_vol(plist, &H5VL_native_g); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 36177ed..75ff687 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -28,7 +28,7 @@ extern "C" { #endif -H5_DLL hid_t H5VL_native_init(void); +H5_DLL H5VL_class_t *H5VL_native_init(void); H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id); #ifdef __cplusplus diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 949fd90..0880cf0 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -52,6 +52,9 @@ H5_DLL H5VL_class_t *H5VL_get_class(hid_t id); //H5_DLL hsize_t H5VL_sb_size(H5F_t *file); H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); +H5_DLL herr_t H5VL_replace_with_uids(hid_t *oid_list, ssize_t num_ids); +H5_DLL int H5VL_inc_ref_uid(hid_t fid, hbool_t app_ref); + H5_DLL hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id); H5_DLL hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); @@ -79,8 +82,7 @@ H5_DLL herr_t H5VL_object_close(hid_t uid); H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, int num_args, ...); H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, int num_args, ...); -H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); -H5_DLL herr_t H5VL_fapl_copy(hid_t vol_id, const void *fapl, void **copied_fapl); -H5_DLL herr_t H5VL_fapl_close(hid_t vol_id, void *fapl); +H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, H5VL_class_t *vol_cls); +H5_DLL herr_t H5VL_fapl_close(H5VL_class_t *vol_cls); #endif /* !_H5VLprivate_H */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index ede4358..31b1e88 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -149,11 +149,8 @@ typedef struct H5VL_object_class_t { /* Class information for each VOL driver */ typedef struct H5VL_class_t { const char *name; + unsigned nrefs; /* Ref count for times struct is pointed to */ herr_t (*terminate)(void); - size_t fapl_size; - void * (*fapl_get)(hid_t fid); - void * (*fapl_copy)(const void *fapl); - herr_t (*fapl_free)(void *fapl); H5VL_attribute_class_t attribute_cls; H5VL_datatype_class_t datatype_cls; H5VL_dataset_class_t dataset_cls; diff --git a/src/H5private.h b/src/H5private.h index e01edd2..77ceaca 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1535,6 +1535,7 @@ typedef enum { H5_PKG_S, /*Data spaces */ H5_PKG_T, /*Data types */ H5_PKG_V, /*Vector functions */ + H5_PKG_VL, /*VOL functions */ H5_PKG_Z, /*Raw data filters */ H5_NPKGS /*Must be last */ } H5_pkg_t; -- cgit v0.12