From 33f70a817aba7a4dd020fb29a187c53ba05e157c Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 17 Apr 2012 16:54:02 -0500 Subject: [svn-r22292] remove unnecessary lookup for object locations into VOL add a public API routine to set a user defined VOL driver some fixes to allow vol plugins to be created and used outside the library --- src/H5G.c | 12 +----------- src/H5Pfapl.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/H5Ppublic.h | 2 ++ src/H5Tcommit.c | 2 +- src/H5VL.c | 1 - src/H5VLdummy.c | 6 +++--- src/H5VLnative.c | 20 ++++++++++++-------- src/H5VLpublic.h | 10 ++++++++++ src/hdf5.h | 5 +++++ 9 files changed, 74 insertions(+), 24 deletions(-) diff --git a/src/H5G.c b/src/H5G.c index 52ad222..2f3cea6 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -470,8 +470,6 @@ herr_t H5Gget_info(hid_t loc_id, H5G_info_t *grp_info) { H5I_type_t id_type; /* Type of ID */ - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -484,19 +482,11 @@ H5Gget_info(hid_t loc_id, H5G_info_t *grp_info) if(!grp_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP, &location) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - /* Get the group info through the VOL using the location token */ - if((ret_value = H5VL_group_get(loc_id, H5VL_GROUP_GET_INFO, grp_info, location)) < 0) + if((ret_value = H5VL_group_get(loc_id, H5VL_GROUP_GET_INFO, grp_info, NULL)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: - if (NULL != location) { - free (location); - location = NULL; - } FUNC_LEAVE_API(ret_value) } /* end H5Gget_info() */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 2d46ec7..a6f0ea9 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -2204,6 +2204,46 @@ done: /*------------------------------------------------------------------------- + * Function: H5Pset_vol + * + * Purpose: Set the file vol plugin (VOL_ID) for a file access + * property list (PLIST_ID) + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_vol(hid_t plist_id, hid_t new_vol_id) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_class_t *vol_cls; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", plist_id, new_vol_id); + + /* 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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(new_vol_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file vol ID") + + /* Set the vol */ + if(H5P_set_vol(plist, vol_cls) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_vol() */ + + +/*------------------------------------------------------------------------- * Function: H5Pset_file_image * * Purpose: Sets the initial file image. Some file drivers can initialize diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 6cba897..fc42339 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -291,6 +291,8 @@ H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); H5_DLL hid_t H5Pget_driver(hid_t plist_id); H5_DLL void *H5Pget_driver_info(hid_t plist_id); +H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id); + /* H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t vol_id, const void *vol_info); H5_DLL hid_t H5Pget_vol(hid_t plist_id); diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 7e90a2d..c2654b4 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -152,7 +152,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") - /* Open the object through the VOL */ + /* commite the datatype through the VOL */ if((ret_value = H5VL_datatype_commit(loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: diff --git a/src/H5VL.c b/src/H5VL.c index 353f36f..1c56910 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -365,7 +365,6 @@ H5VL_register(const void *_cls, size_t size, hbool_t app_ref) /* Check arguments */ HDassert(cls); - /*MSC - check required funciton pointers */ /* Copy the class structure so the caller can reuse or free it */ if(NULL == (saved = (H5VL_class_t *)H5MM_malloc(size))) diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index 5503351..4a0b40e 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -236,7 +236,7 @@ done: * *------------------------------------------------------------------------- */ -hid_t +static hid_t H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fapl_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -260,7 +260,7 @@ H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fapl_id) * *------------------------------------------------------------------------- */ -hid_t +static hid_t H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -284,7 +284,7 @@ H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fa * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5VL_dummy_file_close(hid_t file_id) { FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 69cf274..d752762 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -1929,15 +1929,19 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, va_list arguments if(H5G_loc(obj_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!H5F_addr_defined(obj_loc->oloc->addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") - - /* Retrieve the group's information */ - if(H5G__obj_info(obj_loc->oloc, grp_info, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + if (NULL == obj_loc) { + /* Retrieve the group's information */ + if(H5G__obj_info(loc.oloc, grp_info, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + else { + /* Retrieve the group's information */ + if(H5G__obj_info(obj_loc->oloc, grp_info, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - if(H5G_loc_free(obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if(H5G_loc_free(obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + } break; } default: diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index e6df32f..645b410 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -20,6 +20,8 @@ #ifndef _H5VLpublic_H #define _H5VLpublic_H +#include "stdarg.h" + #include "H5public.h" #include "H5Fpublic.h" #include "H5Lpublic.h" @@ -201,8 +203,16 @@ typedef struct H5VL_class_t { H5VL_object_class_t object_cls; } H5VL_class_t; +#ifdef __cplusplus +extern "C" { +#endif + /* Function prototypes */ H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); H5_DLL herr_t H5VLunregister(hid_t driver_id); +#ifdef __cplusplus +} +#endif + #endif /* _H5VLpublic_H */ diff --git a/src/hdf5.h b/src/hdf5.h index a37329d..f5bbf4c 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -38,6 +38,11 @@ #include "H5Spublic.h" /* Dataspaces */ #include "H5Tpublic.h" /* Datatypes */ #include "H5Zpublic.h" /* Data filters */ +#include "H5VLpublic.h" /* VOL plugins */ + +/* Predefined VOL plugins */ +#include "H5VLnative.h" /* Native HDF5 plugin */ +#include "H5VLdummy.h" /* Dummy plugin for testing */ /* Predefined file drivers */ #include "H5FDcore.h" /* Files stored entirely in memory */ -- cgit v0.12