summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2014-08-08 17:05:20 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2014-08-08 17:05:20 (GMT)
commite3e4c3710976810ed7a9109d9b4f9d842eca2954 (patch)
treec85f2d5dcb00b7ccb8f80774818cce25a89e3d0f
parent68067443e04f352aeca5b41243e77e4aacc4cd98 (diff)
downloadhdf5-e3e4c3710976810ed7a9109d9b4f9d842eca2954.zip
hdf5-e3e4c3710976810ed7a9109d9b4f9d842eca2954.tar.gz
hdf5-e3e4c3710976810ed7a9109d9b4f9d842eca2954.tar.bz2
[svn-r25521] major rework of the internal setup of VOL plugins to make it more
symmetrical to VFDs and allow new functionality to be implemented later. + some Bug fixes
-rw-r--r--src/H5.c4
-rw-r--r--src/H5A.c1
-rw-r--r--src/H5Aint.c1
-rw-r--r--src/H5D.c2
-rw-r--r--src/H5Dint.c1
-rw-r--r--src/H5F.c14
-rw-r--r--src/H5Fint.c20
-rw-r--r--src/H5Fprivate.h2
-rw-r--r--src/H5Gint.c1
-rw-r--r--src/H5Gtest.c1
-rw-r--r--src/H5Gtraverse.c4
-rw-r--r--src/H5I.c9
-rw-r--r--src/H5L.c1
-rw-r--r--src/H5Lexternal.c2
-rw-r--r--src/H5O.c7
-rw-r--r--src/H5Ocopy.c3
-rw-r--r--src/H5Pfapl.c58
-rw-r--r--src/H5Pprivate.h2
-rw-r--r--src/H5VLint.c466
-rw-r--r--src/H5VLnative.c96
-rw-r--r--src/H5VLnative.h5
-rw-r--r--src/H5VLpkg.h2
-rw-r--r--src/H5VLprivate.h12
-rw-r--r--src/H5VLpublic.h4
24 files changed, 323 insertions, 395 deletions
diff --git a/src/H5.c b/src/H5.c
index 61f8acd..ec82c5b 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -184,6 +184,8 @@ H5_init_library(void)
*/
if(H5E_init() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface")
+ if(H5VL_init() < 0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface")
if(H5P_init() < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface")
if(H5T_init() < 0)
@@ -278,11 +280,11 @@ H5_term_library(void)
* that depend on them. -QAK
*/
if(pending == 0) {
- pending += DOWN(VL);
pending += DOWN(AC);
pending += DOWN(Z);
pending += DOWN(FD);
pending += DOWN(P);
+ pending += DOWN(VL);
pending += DOWN(PL);
/* Don't shut down the error code until other APIs which use it are shut down */
if(pending == 0)
diff --git a/src/H5A.c b/src/H5A.c
index 2129a28..35f60d7 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -36,7 +36,6 @@
#include "H5Opkg.h" /* Object headers */
#include "H5Sprivate.h" /* Dataspace functions */
#include "H5SMprivate.h" /* Shared Object Header Messages */
-#include "H5VLnative.h" /* VOL native plugin */
#include "H5VLprivate.h" /* VOL plugins */
/****************/
diff --git a/src/H5Aint.c b/src/H5Aint.c
index b3136bd..f5c44cd 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -43,7 +43,6 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared Object Header Messages */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
diff --git a/src/H5D.c b/src/H5D.c
index b8fc0ed..58e39c5 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1063,7 +1063,7 @@ H5D_close_dataset(void *dset, H5VL_t *vol_plugin)
FUNC_ENTER_NOAPI_NOINIT
- /* Close the dataset through the VOL*/
+ /* Close the dataset through the VOL */
if((ret_value = H5VL_dataset_close(dset, vol_plugin, H5AC_dxpl_id, H5_EVENT_STACK_NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset")
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 22fb441..853240d 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -34,7 +34,6 @@
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
#include "H5MMprivate.h" /* Memory management */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
diff --git a/src/H5F.c b/src/H5F.c
index 6e0851e..ecce27d 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -32,7 +32,6 @@
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* VOL plugins */
@@ -253,9 +252,9 @@ H5Fget_access_plist(hid_t file_id)
{
H5VL_t *vol_plugin;
void *file;
- void *vol_info = NULL;
H5P_genplist_t *plist = NULL; /* Property list pointer */
- hid_t fapl_id = FAIL, ret_value; /* Return value */
+ hid_t fapl_id = FAIL;
+ hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", file_id);
@@ -268,17 +267,10 @@ H5Fget_access_plist(hid_t file_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
if(H5VL_file_get(file, vol_plugin, H5VL_FILE_GET_FAPL, H5AC_dxpl_id,
- H5_EVENT_STACK_NULL, &fapl_id, &vol_info) < 0)
+ H5_EVENT_STACK_NULL, &fapl_id) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties")
- /* Set the vol properties for the list */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
- if(H5P_set_vol(plist, vol_plugin->cls, vol_info) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
-
ret_value = fapl_id;
-
done:
if(ret_value < 0 && fapl_id != FAIL)
if(H5I_dec_ref(fapl_id) < 0)
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 1fe046f..a3c1e1e 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -40,7 +40,6 @@
#include "H5Pprivate.h" /* Property lists */
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5Tprivate.h" /* Datatypes */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* VOL plugins */
@@ -161,6 +160,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
H5P_genplist_t *old_plist; /* Old property list */
void *driver_info=NULL;
unsigned efc_size = 0;
+ hid_t driver_id;
hid_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
@@ -208,8 +208,22 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
* Since we're resetting the driver ID and info, close them if they
* exist in this new property list.
*/
- if(H5P_facc_close(ret_value, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information")
+ /* Get driver ID property */
+ if(H5P_get(new_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) {
+ /* Get driver info property */
+ if(H5P_get(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+
+ /* Close the driver for the property list */
+ if(H5FD_fapl_close(driver_id, driver_info) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+ } /* end if */
+
+ //if(H5P_facc_close(ret_value, NULL) < 0)
+ //HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information")
/* Increment the reference count on the driver ID and insert it into the property list */
if(H5I_inc_ref(f->shared->lf->driver_id, FALSE) < 0)
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 009dcd7..9eb37b2 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -459,7 +459,7 @@ typedef struct {
#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_FILE_DRV_INFO_NAME "driver_info" /* File driver info */
-#define H5F_ACS_VOL_NAME "vol_cls" /* File VOL plugin */
+#define H5F_ACS_VOL_ID_NAME "vol_id" /* File VOL ID */
#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 */
diff --git a/src/H5Gint.c b/src/H5Gint.c
index 114d58d..bfe0e93 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -45,7 +45,6 @@
#include "H5Lprivate.h" /* Links */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* VOL */
/****************/
diff --git a/src/H5Gtest.c b/src/H5Gtest.c
index 4bd87f5..1608447 100644
--- a/src/H5Gtest.c
+++ b/src/H5Gtest.c
@@ -558,6 +558,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign
case H5I_ATTR:
case H5I_REFERENCE:
case H5I_VFL:
+ case H5I_VOL:
case H5I_GENPROP_CLS:
case H5I_GENPROP_LST:
case H5I_ERROR_CLASS:
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 1658f8d..dbc52ba 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -45,8 +45,7 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Ppublic.h" /* Property Lists */
#include "H5WBprivate.h" /* Wrapped Buffers */
-#include "H5VLnative.h" /* Native Plugin */
-
+#include "H5VLprivate.h" /* VOL plugins */
/****************/
/* Local Macros */
@@ -208,6 +207,7 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
/* Create a group ID to pass to the user-defined callback */
if(NULL == (grp = H5G_open(&grp_loc_copy, dxpl_id)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
+
if((cur_grp = H5VL_native_register(H5I_GROUP, grp, FALSE)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group")
diff --git a/src/H5I.c b/src/H5I.c
index 50abc1e..c3d591a 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -2284,23 +2284,24 @@ H5Iget_file_id(hid_t obj_id)
/* Get the file through the VOL */
if(H5VL_file_get(obj, vol_plugin, H5VL_OBJECT_GET_FILE, H5AC_dxpl_id, H5_EVENT_STACK_NULL, type, &file) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to get file")
-
if (NULL == file)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
/* Check if the ID already exists and procceed accordingly */
if (FAIL == (ret_value = H5I_get_id(file, H5I_FILE))) {
- /* resurrect the ID - Register an ID with the native plugin */
+ /* resurrect the ID */
if((ret_value = H5I_register2(H5I_FILE, file, vol_plugin, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+ /* increment the ref count on the VOL plugin for the new ID */
+ vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin")
}
else {
/* Increment ref count on existing ID */
if(H5I_inc_ref(ret_value, TRUE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
}
- /* increment the ref count on the VOL plugin for the new ID */
- vol_plugin->nrefs ++;
}
else
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID")
diff --git a/src/H5L.c b/src/H5L.c
index 5d89525..ae46290 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -36,7 +36,6 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* File objects */
#include "H5Pprivate.h" /* Property lists */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index c00b44a..11968f1 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -28,7 +28,6 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Opublic.h" /* File objects */
#include "H5Pprivate.h" /* Property lists */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* Virtual Object Layer */
static hid_t H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
@@ -454,6 +453,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
{
void *temp_obj = NULL;
H5I_type_t obj_type;
+
obj_type = H5I_get_type(ext_obj);
if(NULL == (temp_obj = H5I_remove(ext_obj)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
diff --git a/src/H5O.c b/src/H5O.c
index 8a87ecf..077957b 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -46,7 +46,6 @@
#include "H5MFprivate.h" /* File memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared object header messages */
-#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
@@ -259,7 +258,7 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle")
done:
FUNC_LEAVE_API(ret_value)
@@ -337,7 +336,7 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle")
done:
FUNC_LEAVE_API(ret_value)
@@ -408,7 +407,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle")
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index 7d7d5eb..687a9e6 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -255,7 +255,8 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
if((ret_value = H5VL_object_copy(obj1, loc_params1, vol_plugin1, src_name,
obj2, loc_params2, vol_plugin2, dst_name,
ocpypl_id, lcpl_id, H5AC_dxpl_id, H5_EVENT_STACK_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to copy object")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Ocopy() */
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 8b71836..e2f728b 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -161,11 +161,11 @@
#define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned
/* Definition for VOL plugin */
-#define H5F_ACS_VOL_SIZE sizeof(void *)
-#define H5F_ACS_VOL_DEF H5VL_NATIVE
+#define H5F_ACS_VOL_ID_SIZE sizeof(hid_t)
+#define H5F_ACS_VOL_ID_DEF H5VL_NATIVE
/* Definition for vol info */
-#define H5F_ACS_VOL_INFO_SIZE sizeof(void*)
-#define H5F_ACS_VOL_INFO_DEF NULL
+#define H5F_ACS_VOL_INFO_SIZE sizeof(void*)
+#define H5F_ACS_VOL_INFO_DEF NULL
/* Definition of pointer to initial file image info */
#define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t)
@@ -290,7 +290,7 @@ static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE
static herr_t
H5P_facc_reg_prop(H5P_genclass_t *pclass)
{
- H5VL_class_t *vol_cls = H5F_ACS_VOL_DEF; /* Default VOL plugin */
+ const hid_t def_vol_id = H5F_ACS_VOL_ID_DEF; /* Default VOL plugin */
void *vol_info = H5F_ACS_VOL_INFO_DEF; /* Default VOL plugin information*/
const hid_t def_driver_id = H5F_ACS_FILE_DRV_ID_DEF; /* Default VFL driver ID (initialized from a variable) */
herr_t ret_value = SUCCEED; /* Return value */
@@ -419,7 +419,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_NAME, H5F_ACS_VOL_SIZE, &vol_cls,
+ if(H5P_register_real(pclass, H5F_ACS_VOL_ID_NAME, H5F_ACS_VOL_ID_SIZE, &def_vol_id,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
@@ -473,7 +473,7 @@ static herr_t
H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
{
hid_t driver_id;
- H5VL_class_t *vol_cls;
+ hid_t vol_id;
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED;
@@ -484,17 +484,17 @@ H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
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)
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin")
- if(NULL != vol_cls) {
+ if(vol_id > 0) {
void *vol_info;
/* Retrieve VOL plugin 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_cls, vol_info) < 0)
+ if(H5VL_fapl_open(plist, vol_id, vol_info) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
}
@@ -539,23 +539,23 @@ static herr_t
H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void UNUSED *copy_data)
{
hid_t driver_id;
- H5VL_class_t *vol_cls;
+ hid_t vol_id;
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
-
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(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)
+ 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(NULL != vol_cls) {
+
+ if(vol_id > 0) {
void *vol_info;
/* Retrieve VOL plugin property */
@@ -563,7 +563,7 @@ H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void UNUSED *copy_data)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info")
/* Set the vp; for the destination property list */
- if(H5VL_fapl_open(dst_plist, vol_cls, vol_info) < 0)
+ if(H5VL_fapl_open(dst_plist, vol_id, vol_info) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
} /* end if */
@@ -607,7 +607,7 @@ herr_t
H5P_facc_close(hid_t fapl_id, void UNUSED *close_data)
{
hid_t driver_id;
- H5VL_class_t *vol_cls;
+ hid_t vol_id;
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED;
@@ -618,15 +618,18 @@ H5P_facc_close(hid_t fapl_id, void UNUSED *close_data)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
/* Get vol plugin */
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0)
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
- if(NULL != vol_cls) {
+
+ if(vol_id > 0) {
void *vol_info;
+
/* Retrieve VOL plugin 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")
+
/* Close the driver for the property list */
- if(H5VL_fapl_close(vol_cls, vol_info) < 0)
+ if(H5VL_fapl_close(vol_id, vol_info) < 0)
HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
} /* end if */
@@ -2063,27 +2066,27 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5P_set_vol(H5P_genplist_t *plist, H5VL_class_t *vol_cls, const void *vol_info)
+H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info)
{
- H5VL_class_t *old_vol_cls;
+ hid_t old_vol_id;
void *old_vol_info;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
/* Get the current vol information */
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &old_vol_cls) < 0)
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &old_vol_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol class")
if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &old_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(old_vol_cls, old_vol_info)<0)
+ if(H5VL_fapl_close(old_vol_id, old_vol_info)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset vol")
/* Set the vol for the property list */
- if(H5VL_fapl_open(plist, vol_cls, vol_info)<0)
+ if(H5VL_fapl_open(plist, vol_id, vol_info)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
}
else
@@ -2113,7 +2116,6 @@ 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 */
- H5VL_class_t *vol_cls;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -2122,11 +2124,11 @@ H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(new_vol_id, H5I_VOL)))
+ if(NULL == 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, new_vol_info) < 0)
+ if(H5P_set_vol(plist, new_vol_id, new_vol_info) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
done:
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index 9e0a1a4..b74b1cd4 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -129,7 +129,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 herr_t H5P_set_vol(H5P_genplist_t *plist, H5VL_class_t *vol_cls, const void *vol_info);
+H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info);
H5_DLL void * H5P_get_vol_info(H5P_genplist_t *plist);
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,
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 9f2177b..b619b4b 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -119,54 +119,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5VL_get_class
- *
- * Purpose: Obtains a pointer to the vol plugin struct containing all the
- * callback pointers, etc. The PLIST_ID argument can be a file
- * access property list or a vol plugin identifier.
- *
- * Return: Success: Ptr to the vol plugin information. The pointer is
- * only valid as long as the vol plugin remains
- * registered or some file or property list
- * exists which references the vol plugin.
- *
- * Failure: NULL
- *
- * Programmer: Mohamad Chaarawi
- * January, 2012
- *
- *-------------------------------------------------------------------------
- */
-H5VL_class_t *
-H5VL_get_class(hid_t id)
-{
- H5VL_class_t *ret_value = NULL;
-
- FUNC_ENTER_NOAPI(NULL)
-
- if(H5I_VOL == H5I_get_type(id))
- ret_value = (H5VL_class_t *)H5I_object(id);
- else {
- H5P_genplist_t *plist; /* Property list pointer */
-
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
-
- if(TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) {
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &ret_value) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin")
- } else {
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a vol plugin id, file access property list")
- }
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_get_class() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5VL_fapl_open
*
* Purpose: Mark a vol as used by a file access property list
@@ -181,18 +133,21 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_fapl_open(H5P_genplist_t *plist, H5VL_class_t *vol_cls, const void *vol_info)
+H5VL_fapl_open(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info)
{
void *copied_vol_info = NULL; /* Temporary VOL driver info */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- if(H5VL_fapl_copy(vol_cls, vol_info, &copied_vol_info) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy VFL driver info")
+ /* increment the refcount on the plugin id */
+ if(H5I_inc_ref(vol_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin")
+ if(H5VL_fapl_copy(vol_id, vol_info, &copied_vol_info) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy VOL plugin info")
/* Set the vol properties for the list */
- if(H5P_set(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0)
+ if(H5P_set(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 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")
@@ -200,7 +155,7 @@ H5VL_fapl_open(H5P_genplist_t *plist, H5VL_class_t *vol_cls, const void *vol_inf
done:
if(ret_value < 0)
- if(copied_vol_info && H5VL_fapl_close(vol_cls, copied_vol_info) < 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 driver info")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_fapl_open() */
@@ -220,13 +175,17 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_fapl_copy(H5VL_class_t *vol_cls, const void *vol_info, void **copied_info)
+H5VL_fapl_copy(hid_t vol_id, const void *vol_info, void **copied_info)
{
+ H5VL_class_t *vol_cls;
void *new_info = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
+ if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL ID")
+
/* Copy old pl, if one exists */
if(vol_info) {
/* Allow the driver to copy or do it ourselves */
@@ -267,13 +226,17 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_fapl_close(H5VL_class_t *vol_cls, void *vol_info)
+H5VL_fapl_close(hid_t vol_id, void *vol_info)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_class_t *vol_cls;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- if(NULL != vol_cls) {
+ if(vol_id > 0) {
+ if(NULL == (vol_cls = (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(vol_info && vol_cls->fapl_free) {
if((vol_cls->fapl_free)(vol_info) < 0)
@@ -281,7 +244,12 @@ H5VL_fapl_close(H5VL_class_t *vol_cls, void *vol_info)
} /* end if */
else
H5MM_xfree(vol_info);
+
+ /* Decrement reference count for plugin */
+ if(H5I_dec_ref(vol_id) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for plugin")
}
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_fapl_close() */
@@ -301,12 +269,17 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_close(H5VL_class_t UNUSED *vol_plugin)
+H5VL_close(H5VL_class_t *cls)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
+ if(cls->terminate && cls->terminate() < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL plugin did not terminate cleanly")
+
+ H5MM_xfree(cls);
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_close() */
@@ -486,11 +459,14 @@ H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, co
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `attr create' method")
/* call the corresponding VOL create callback */
- if(NULL == (ret_value = (vol_plugin->cls->attr_cls.create) (obj, loc_params, name, acpl_id,
- aapl_id, dxpl_id, H5_REQUEST_NULL)))
+ if(NULL == (ret_value = (vol_plugin->cls->attr_cls.create)
+ (obj, loc_params, name, acpl_id, aapl_id, dxpl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed")
vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_attr_create() */
@@ -522,10 +498,14 @@ H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, cons
if(NULL == vol_plugin->cls->attr_cls.open)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `attr open' method")
/* call the corresponding VOL open callback */
- if(NULL == (ret_value = (vol_plugin->cls->attr_cls.open) (obj, loc_params, name, aapl_id, dxpl_id, H5_REQUEST_NULL)))
+ if(NULL == (ret_value = (vol_plugin->cls->attr_cls.open)
+ (obj, loc_params, name, aapl_id, dxpl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed")
vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_attr_open() */
@@ -554,6 +534,7 @@ herr_t H5VL_attr_read(void *attr, H5VL_t *vol_plugin, hid_t mem_type_id, void *b
if(NULL == vol_plugin->cls->attr_cls.read)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr read' method")
+
if((ret_value = (vol_plugin->cls->attr_cls.read)(attr, mem_type_id, buf, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "read failed")
@@ -617,8 +598,8 @@ H5VL_attr_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
if(NULL == vol_plugin->cls->attr_cls.iterate)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr iterate' method")
- if((ret_value = (vol_plugin->cls->attr_cls.iterate)(obj, loc_params, idx_type, order, n, op,
- op_data, dxpl_id, H5_REQUEST_NULL)) < 0)
+ if((ret_value = (vol_plugin->cls->attr_cls.iterate)
+ (obj, loc_params, idx_type, order, n, op, op_data, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "iteration failed")
done:
@@ -651,26 +632,13 @@ H5VL_attr_get(void *obj, H5VL_t *vol_plugin, H5VL_attr_get_t get_type,
if(NULL == vol_plugin->cls->attr_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr get' method")
+
va_start (arguments, estack_id);
- if((ret_value = (vol_plugin->cls->attr_cls.get)(obj, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->attr_cls.get)
+ (obj, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
-#if 0
- /* if the get_type is a named datatype, attach the vol info to it */
- if(H5VL_ATTR_GET_TYPE == get_type) {
- hid_t *ret_id;
- va_start (arguments, estack_id);
- ret_id = va_arg (arguments, hid_t *);
-
- if(H5Tcommitted(*ret_id)) {
- /* attach VOL information to the ID */
- if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
- }
- va_end (arguments);
- }
-#endif
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_attr_get() */
@@ -729,24 +697,16 @@ H5VL_attr_close(void *attr, H5VL_t *vol_plugin, hid_t dxpl_id, hid_t UNUSED esta
FUNC_ENTER_NOAPI(FAIL)
- /* if the VOL class does not implement a specific attr close
- callback, try the object close */
- if(NULL == vol_plugin->cls->attr_cls.close){
+ if(NULL == vol_plugin->cls->attr_cls.close)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr close' method")
- /*
- if(H5VL_object_close(id, dxpl_id, estack_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object")
- */
- }
- else if((ret_value = (vol_plugin->cls->attr_cls.close)(attr, dxpl_id, H5_REQUEST_NULL)) < 0)
+ if((ret_value = (vol_plugin->cls->attr_cls.close)(attr, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
vol_plugin->nrefs --;
-
- if (0 == vol_plugin->nrefs) {
- vol_plugin->container_name = (const char *)H5MM_xfree(vol_plugin->container_name);
+ if(H5I_dec_ref(vol_plugin->id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin")
+ if (0 == vol_plugin->nrefs)
vol_plugin = (H5VL_t *)H5MM_xfree(vol_plugin);
- }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -784,7 +744,10 @@ H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin
if(NULL == (ret_value = (vol_plugin->cls->datatype_cls.commit)
(obj, loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "commit failed")
+
vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -816,21 +779,15 @@ H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
/* check if the type specific corresponding VOL open callback exists */
if(NULL == vol_plugin->cls->datatype_cls.open)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback");
-#if 0
- H5VL_loc_params_t loc_params;
- 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 = tapl_id;
-
- /* Open the object class */
- if((ret_value = H5VL_object_open(id, loc_params, dxpl_id, estack_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to open object")
-#endif
/* call the corresponding VOL open callback */
- if(NULL == (ret_value = (vol_plugin->cls->datatype_cls.open)(obj, loc_params, name, tapl_id, dxpl_id, H5_REQUEST_NULL)))
+ if(NULL == (ret_value = (vol_plugin->cls->datatype_cls.open)
+ (obj, loc_params, name, tapl_id, dxpl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed")
+
vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -935,11 +892,11 @@ H5VL_datatype_close(void *dt, H5VL_t *vol_plugin, hid_t dxpl_id, hid_t UNUSED es
if((ret_value = (vol_plugin->cls->datatype_cls.close)(dt, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
+ if(H5I_dec_ref(vol_plugin->id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin")
vol_plugin->nrefs --;
- if (0 == vol_plugin->nrefs) {
- vol_plugin->container_name = (const char *)H5MM_xfree(vol_plugin->container_name);
+ if (0 == vol_plugin->nrefs)
vol_plugin = (H5VL_t *)H5MM_xfree(vol_plugin);
- }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -971,10 +928,15 @@ H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
/* check if the corresponding VOL create callback exists */
if(NULL == vol_plugin->cls->dataset_cls.create)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `dataset create' method")
+
/* call the corresponding VOL create callback */
- if(NULL == (ret_value = (vol_plugin->cls->dataset_cls.create)(obj, loc_params, name, dcpl_id, dapl_id, dxpl_id, H5_REQUEST_NULL)))
+ if(NULL == (ret_value = (vol_plugin->cls->dataset_cls.create)
+ (obj, loc_params, name, dcpl_id, dapl_id, dxpl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed")
+
vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1004,21 +966,18 @@ H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, c
FUNC_ENTER_NOAPI(NULL)
/* check if the type specific corresponding VOL open callback exists */
- if(NULL == vol_plugin->cls->dataset_cls.open) {
- ;
-#if 0
- /* Open the object class */
- if((ret_value = H5VL_object_open(id, loc_params, dxpl_id, estack_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to open object")
-#endif
- }
- else {
- /* call the corresponding VOL open callback */
- if(NULL == (ret_value = (vol_plugin->cls->dataset_cls.open)(obj, loc_params, name, dapl_id, dxpl_id, H5_REQUEST_NULL)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed")
- vol_plugin->nrefs ++;
+ if(NULL == vol_plugin->cls->dataset_cls.open)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no 'dset open' method")
+
+ /* call the corresponding VOL open callback */
+ if(NULL == (ret_value = (vol_plugin->cls->dataset_cls.open)
+ (obj, loc_params, name, dapl_id, dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed")
+
+ vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
- }
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_dataset_open() */
@@ -1153,23 +1112,6 @@ H5VL_dataset_get(void *dset, H5VL_t *vol_plugin, H5VL_dataset_get_t get_type,
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
-#if 0
- /* if the get_type is a named datatype, create a wrapper for it */
- if(H5VL_DATASET_GET_TYPE == get_type) {
- hid_t *ret_id;
-
- va_start (arguments, estack_id);
- ret_id = va_arg (arguments, hid_t *);
-
- if(H5Tcommitted(*ret_id)) {
- /* attach VOL information to the ID */
- if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
- }
- va_end (arguments);
- }
-#endif
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_dataset_get() */
@@ -1196,27 +1138,21 @@ H5VL_dataset_close(void *dset, H5VL_t *vol_plugin, hid_t dxpl_id, hid_t UNUSED e
FUNC_ENTER_NOAPI(FAIL)
- /* if the VOL class does not implement a specific dataset close
- callback, try the object close */
- if(NULL == vol_plugin->cls->dataset_cls.close){
- ;
-#if 0
- if(H5VL_object_close(id, dxpl_id, dxpl_id, estack_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object")
-#endif
- }
- else {
- if((ret_value = (vol_plugin->cls->dataset_cls.close)(dset, dxpl_id, H5_REQUEST_NULL)) < 0)
+ if(NULL == vol_plugin->cls->dataset_cls.close)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dset close' method")
+ if((ret_value = (vol_plugin->cls->dataset_cls.close)(dset, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
- }
+done:
+ /* MSC - Weird thing for datasets and filters:
+ Always decrement the ref count on the vol for datasets, since
+ the ID is removed even if the close fails */
vol_plugin->nrefs --;
- if (0 == vol_plugin->nrefs) {
- vol_plugin->container_name = (const char *)H5MM_xfree(vol_plugin->container_name);
+ if(H5I_dec_ref(vol_plugin->id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin")
+ if (0 == vol_plugin->nrefs)
vol_plugin = (H5VL_t *)H5MM_xfree(vol_plugin);
- }
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_dataset_close() */
@@ -1240,7 +1176,8 @@ H5VL_file_create(H5VL_t **plugin, const char *name, unsigned flags, hid_t fcpl_i
hid_t fapl_id, hid_t dxpl_id, hid_t UNUSED estack_id)
{
H5P_genplist_t *plist; /* Property list pointer */
- H5VL_class_t *vol_cls; /* VOL class attached to fapl_id */
+ hid_t vol_id; /* VOL plugin identigier attached to fapl_id */
+ H5VL_class_t *vol_cls = NULL; /* VOL class of vol_id */
H5VL_t *vol_plugin = NULL; /* the public VOL struct */
void *ret_value; /* Return value */
@@ -1249,9 +1186,12 @@ H5VL_file_create(H5VL_t **plugin, const char *name, unsigned flags, hid_t fcpl_i
/* get the VOL info from the fapl */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0)
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID")
+ if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL ID")
+
/* check if the corresponding VOL create callback exists */
if(NULL == vol_cls->file_cls.create)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file create' method")
@@ -1266,8 +1206,9 @@ H5VL_file_create(H5VL_t **plugin, const char *name, unsigned flags, hid_t fcpl_i
vol_plugin = *plugin;
vol_plugin->cls = vol_cls;
vol_plugin->nrefs = 1;
- if((vol_plugin->container_name = H5MM_xstrdup(name)) == NULL)
- HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,NULL,"memory allocation failed")
+ vol_plugin->id = vol_id;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1293,7 +1234,8 @@ H5VL_file_open(H5VL_t **plugin, const char *name, unsigned flags, hid_t fapl_id,
hid_t dxpl_id, hid_t UNUSED estack_id)
{
H5P_genplist_t *plist; /* Property list pointer */
- H5VL_class_t *vol_cls; /* VOL class attached to fapl_id */
+ hid_t vol_id; /* VOL plugin identigier attached to fapl_id */
+ H5VL_class_t *vol_cls = NULL; /* VOL class of vol_id */
H5VL_t *vol_plugin = NULL; /* the public VOL struct */
void *ret_value; /* Return value */
@@ -1302,9 +1244,12 @@ H5VL_file_open(H5VL_t **plugin, const char *name, unsigned flags, 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, NULL, "not a file access property list")
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0)
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID")
+ if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL ID")
+
/* check if the corresponding VOL create callback exists */
if(NULL == vol_cls->file_cls.open)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file open' method")
@@ -1319,8 +1264,9 @@ H5VL_file_open(H5VL_t **plugin, const char *name, unsigned flags, hid_t fapl_id,
vol_plugin = *plugin;
vol_plugin->cls = vol_cls;
vol_plugin->nrefs = 1;
- if((vol_plugin->container_name = H5MM_xstrdup(name)) == NULL)
- HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,NULL,"memory allocation failed")
+ vol_plugin->id = vol_id;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1419,7 +1365,8 @@ H5VL_file_misc(void *file, H5VL_t *vol_plugin, H5VL_file_misc_t misc_type,
if (misc_type == H5VL_FILE_IS_ACCESSIBLE) {
H5P_genplist_t *plist; /* Property list pointer */
- H5VL_class_t *vol_cls; /* VOL class attached to fapl_id */
+ hid_t vol_id; /* VOL plugin identigier attached to fapl_id */
+ H5VL_class_t *vol_cls; /* VOL class of vol_id */
va_list tmp_args; /* argument list passed from the API call */
hid_t fapl_id;
@@ -1430,11 +1377,15 @@ H5VL_file_misc(void *file, H5VL_t *vol_plugin, H5VL_file_misc_t misc_type,
/* 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_NAME, &vol_cls) < 0)
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin")
+ if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL ID")
+
va_start (arguments, estack_id);
- if((ret_value = (vol_cls->file_cls.misc)(file, misc_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
+ if((ret_value = (vol_cls->file_cls.misc)
+ (file, misc_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "misc failed")
va_end (arguments);
}
@@ -1443,7 +1394,8 @@ H5VL_file_misc(void *file, H5VL_t *vol_plugin, H5VL_file_misc_t misc_type,
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file misc' method")
va_start (arguments, estack_id);
- if((ret_value = (vol_plugin->cls->file_cls.misc)(file, misc_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->file_cls.misc)
+ (file, misc_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "misc failed")
va_end (arguments);
}
@@ -1486,6 +1438,8 @@ H5VL_file_optional(void *file, H5VL_t *vol_plugin, H5VL_file_optional_t optional
/* if the get_type is a named datatype, attach the vol info to it */
if(H5VL_FILE_REOPEN == optional_type) {
vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin")
}
done:
@@ -1520,10 +1474,10 @@ H5VL_file_close(void *file, H5VL_t *vol_plugin, hid_t dxpl_id, hid_t UNUSED esta
HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed")
vol_plugin->nrefs --;
- if (0 == vol_plugin->nrefs) {
- vol_plugin->container_name = (const char *)H5MM_xfree(vol_plugin->container_name);
+ if(H5I_dec_ref(vol_plugin->id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin")
+ if (0 == vol_plugin->nrefs)
vol_plugin = (H5VL_t *)H5MM_xfree(vol_plugin);
- }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1555,10 +1509,15 @@ H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, c
/* check if the corresponding VOL create callback exists */
if(NULL == vol_plugin->cls->group_cls.create)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `group create' method")
+
/* call the corresponding VOL create callback */
- if(NULL == (ret_value = (vol_plugin->cls->group_cls.create)(obj, loc_params, name, gcpl_id, gapl_id, dxpl_id, H5_REQUEST_NULL)))
+ if(NULL == (ret_value = (vol_plugin->cls->group_cls.create)
+ (obj, loc_params, name, gcpl_id, gapl_id, dxpl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed")
+
vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1587,21 +1546,17 @@ H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, con
FUNC_ENTER_NOAPI(NULL)
- /* check if the type specific corresponding VOL open callback exists */
- if(NULL == vol_plugin->cls->group_cls.open) {
- ;
-#if 0
- /* Open the object class */
- if((ret_value = H5VL_object_open(id, loc_params, dxpl_id, estack_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to open object")
-#endif
- }
- else {
- /* call the corresponding VOL open callback */
- if(NULL == (ret_value = (vol_plugin->cls->group_cls.open)(obj, loc_params, name, gapl_id, dxpl_id, H5_REQUEST_NULL)))
- HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed")
- vol_plugin->nrefs ++;
- }
+ if(NULL == vol_plugin->cls->group_cls.open)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `group open' method")
+
+ if(NULL == (ret_value = (vol_plugin->cls->group_cls.open)
+ (obj, loc_params, name, gapl_id, dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed")
+
+ vol_plugin->nrefs ++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_group_open() */
@@ -1632,8 +1587,10 @@ H5VL_group_get(void *obj, H5VL_t *vol_plugin, H5VL_group_get_t get_type,
if(NULL == vol_plugin->cls->group_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method")
+
va_start (arguments, estack_id);
- if((ret_value = (vol_plugin->cls->group_cls.get)(obj, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->group_cls.get)
+ (obj, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
@@ -1663,25 +1620,16 @@ H5VL_group_close(void *grp, H5VL_t *vol_plugin, hid_t dxpl_id, hid_t UNUSED esta
FUNC_ENTER_NOAPI(FAIL)
- /* if the VOL class does not implement a specific group close
- callback, try the object close */
- if(NULL == vol_plugin->cls->group_cls.close) {
- ;
-#if 0
- if(H5VL_object_close(id, dxpl_id, estack_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object")
-#endif
- }
- else {
- if((ret_value = (vol_plugin->cls->group_cls.close)(grp, dxpl_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
- }
+ if(NULL == vol_plugin->cls->group_cls.close)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group close' method")
+ if((ret_value = (vol_plugin->cls->group_cls.close)(grp, dxpl_id, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
vol_plugin->nrefs --;
- if (0 == vol_plugin->nrefs) {
- vol_plugin->container_name = (const char *)H5MM_xfree(vol_plugin->container_name);
+ if(H5I_dec_ref(vol_plugin->id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin")
+ if (0 == vol_plugin->nrefs)
vol_plugin = (H5VL_t *)H5MM_xfree(vol_plugin);
- }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1745,9 +1693,11 @@ H5VL_link_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj,
/* check if the corresponding VOL move callback exists */
if(NULL == vol_plugin->cls->link_cls.move)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link move' method")
+
/* call the corresponding VOL move callback */
if((ret_value = (vol_plugin->cls->link_cls.move)
- (src_obj, loc_params1, dst_obj, loc_params2, copy_flag, lcpl_id, lapl_id, dxpl_id, H5_REQUEST_NULL)) < 0)
+ (src_obj, loc_params1, dst_obj, loc_params2, copy_flag, lcpl_id,
+ lapl_id, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link move failed")
done:
@@ -1779,8 +1729,9 @@ H5VL_link_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
if(NULL == vol_plugin->cls->link_cls.iterate)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link iterate' method")
- if((ret_value = (vol_plugin->cls->link_cls.iterate)(obj, loc_params, recursive, idx_type,
- order, idx, op, op_data, dxpl_id, H5_REQUEST_NULL)) < 0)
+
+ if((ret_value = (vol_plugin->cls->link_cls.iterate)
+ (obj, loc_params, recursive, idx_type, order, idx, op, op_data, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "iteration failed")
done:
@@ -1813,8 +1764,10 @@ H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_
if(NULL == vol_plugin->cls->link_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link get' method")
+
va_start (arguments, estack_id);
- if((ret_value = (vol_plugin->cls->link_cls.get)(obj, loc_params, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->link_cls.get)
+ (obj, loc_params, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
@@ -1846,6 +1799,7 @@ H5VL_link_remove(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
/* check if the corresponding VOL remove callback exists */
if(NULL == vol_plugin->cls->link_cls.remove)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link remove' method")
+
/* call the corresponding VOL remove callback */
if((ret_value = (vol_plugin->cls->link_cls.remove)(obj, loc_params, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link remove failed")
@@ -1880,10 +1834,15 @@ H5VL_object_open(void *obj, H5VL_loc_params_t params, H5VL_t *vol_plugin, H5I_ty
/* check if the corresponding VOL open callback exists */
if(NULL == vol_plugin->cls->object_cls.open)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `object open' method")
+
/* call the corresponding VOL open callback */
- if(NULL == (ret_value = (vol_plugin->cls->object_cls.open)(obj, params, opened_type, dxpl_id, H5_REQUEST_NULL)))
+ if(NULL == (ret_value = (vol_plugin->cls->object_cls.open)
+ (obj, params, opened_type, dxpl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed")
+
vol_plugin->nrefs++;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1913,13 +1872,15 @@ H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, H5VL_t *vol_plugi
FUNC_ENTER_NOAPI(FAIL)
/* check if both objects are associated with the same VOL plugin */
- if(vol_plugin1->cls != vol_plugin2->cls)
+ if(vol_plugin1->cls->value != vol_plugin2->cls->value)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be copied")
if(NULL == vol_plugin1->cls->object_cls.copy)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object copy' method")
+
if((ret_value = (vol_plugin1->cls->object_cls.copy)
- (src_obj, loc_params1, src_name, dst_obj, loc_params2, dst_name, ocpypl_id, lcpl_id, dxpl_id, H5_REQUEST_NULL)) < 0)
+ (src_obj, loc_params1, src_name, dst_obj, loc_params2, dst_name, ocpypl_id,
+ lcpl_id, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "copy failed")
done:
@@ -1951,90 +1912,14 @@ herr_t H5VL_object_visit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_pl
if(NULL == vol_plugin->cls->object_cls.visit)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object visit' method")
- if((ret_value = (vol_plugin->cls->object_cls.visit)(obj, loc_params, idx_type, order, op,
- op_data, dxpl_id, H5_REQUEST_NULL)) < 0)
+ if((ret_value = (vol_plugin->cls->object_cls.visit)
+ (obj, loc_params, idx_type, order, op, op_data, dxpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "object visitation failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_object_visit() */
-#if 0
-
-/*-------------------------------------------------------------------------
- * Function: H5VL_object_lookup
- *
- * Purpose: Lookup the object location in the file
- *
- * Return: Success: non negative
- *
- * Failure: negative
- *
- * Programmer: Mohamad Chaarawi
- * March, 2012
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5VL_object_lookup(hid_t id, H5VL_loc_type_t lookup_type, void **location,
- hid_t dxpl_id, hid_t estack_id, ...)
-{
- va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI(FAIL)
-
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->object_cls.lookup)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object lookup' method")
-
- va_start (arguments, estack_id);
- if((ret_value = (vol_plugin->object_cls.lookup)(id, lookup_type, location, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "lookup of object location failed")
- va_end (arguments);
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_object_lookup() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5VL_object_free_loc
- *
- * Purpose: Free the location token
- *
- * Return: Success: non negative
- * Failure: negative
- *
- * Programmer: Mohamad Chaarawi
- * May, 2012
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5VL_object_free_loc(hid_t id, void *location, hid_t dxpl_id, hid_t UNUSED estack_id)
-{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI(FAIL)
-
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->object_cls.free_loc)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object free_loc' method")
-
- if((ret_value = (vol_plugin->object_cls.free_loc)(location, dxpl_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "freeing location token of object location failed")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_object_free_loc() */
-#endif
-
/*-------------------------------------------------------------------------
* Function: H5VL_object_get
@@ -2063,9 +1948,11 @@ H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5V
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method")
va_start (arguments, estack_id);
- if((ret_value = (vol_plugin->cls->object_cls.get)(obj, loc_params, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->object_cls.get)
+ (obj, loc_params, get_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_object_get() */
@@ -2097,7 +1984,8 @@ H5VL_object_misc(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object misc' method")
va_start (arguments, estack_id);
- if((ret_value = (vol_plugin->cls->object_cls.misc)(obj, loc_params, misc_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->object_cls.misc)
+ (obj, loc_params, misc_type, dxpl_id, H5_REQUEST_NULL, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "misc failed")
va_end (arguments);
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index a351b14..ccf6a58 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -33,7 +33,6 @@
/* Interface initialization */
#define H5_INTERFACE_INIT_FUNC H5VL_native_init_interface
-
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attribute pkg */
#include "H5Dpkg.h" /* Dataset pkg */
@@ -53,9 +52,17 @@
#include "H5VLprivate.h" /* VOL plugins */
#include "H5VLnative.h" /* Native VOL plugin */
+/*
+ * The vol identification number.
+ */
+static hid_t H5VL_NATIVE_g = 0;
+
+
/* Prototypes */
static H5F_t *H5VL_native_get_file(void *obj, H5I_type_t type);
+static herr_t H5VL_native_term(void);
+
/* Atrribute callbacks */
static void *H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
static void *H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req);
@@ -129,7 +136,7 @@ static H5VL_class_t H5VL_native_g = {
NATIVE,
"native", /* name */
NULL, /* initialize */
- NULL, /* terminate */
+ H5VL_native_term, /* terminate */
0, /* fapl_size */
NULL, /* fapl_copy */
NULL, /* fapl_free */
@@ -215,7 +222,7 @@ static herr_t
H5VL_native_init_interface(void)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
-
+ H5VL_native_init();
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5VL_native_init_interface() */
@@ -234,21 +241,50 @@ H5VL_native_init_interface(void)
*
*-------------------------------------------------------------------------
*/
-H5VL_class_t *
+hid_t
H5VL_native_init(void)
{
- H5VL_class_t *ret_value = NULL; /* Return value */
+ hid_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Register the Native VOL, if it isn't already */
+ if(H5I_VOL != H5I_get_type(H5VL_NATIVE_g)) {
+ if((H5VL_NATIVE_g = H5VL_register((const H5VL_class_t *)&H5VL_native_g,
+ sizeof(H5VL_class_t), FALSE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't create ID for native plugin")
+ }
/* Set return value */
- ret_value = &H5VL_native_g;
+ ret_value = H5VL_NATIVE_g;
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_init() */
/*---------------------------------------------------------------------------
+ * Function: H5VL_native_term
+ *
+ * Purpose: Shut down the VOL plugin
+ *
+ * Returns: SUCCEED (Can't fail)
+ *
+ *---------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_native_term(void)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Reset VFL ID */
+ H5VL_NATIVE_g = 0;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5VL_native_term() */
+
+
+/*---------------------------------------------------------------------------
* Function: H5VL_native_get_file
*
* Purpose: utility routine to get file object
@@ -347,7 +383,6 @@ hid_t
H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref)
{
H5VL_t *vol_plugin; /* VOL plugin information */
- H5T_t *dt = NULL;
hid_t ret_value = FAIL;
FUNC_ENTER_NOAPI_NOINIT
@@ -359,25 +394,21 @@ H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
vol_plugin->cls = &H5VL_native_g;
vol_plugin->nrefs = 1;
+ vol_plugin->id = H5VL_NATIVE_g;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin")
- /* if this is a named datatype, we need to create the two-fold datatype
- to be comaptible with the VOL */
- if(H5I_DATATYPE == type) {
- /* Copy the dataset's datatype */
- if(NULL == (dt = H5T_copy((H5T_t *)obj, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype")
-
- H5T_set_vol_object(dt, obj);
- obj = (void *) dt;
- }
-
- /* Get an atom for the object with the VOL information as the auxilary struct*/
- if((ret_value = H5I_register2(type, obj, (void *)vol_plugin, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
+ if ((ret_value = H5VL_object_register(obj, type, vol_plugin, app_ref)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle")
done:
- if(ret_value < 0 && dt && H5T_close(dt) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
+ if(ret_value < 0) {
+ if(vol_plugin) {
+ if(vol_plugin->id && H5I_dec_ref(vol_plugin->id) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for plugin")
+ H5MM_xfree(vol_plugin);
+ }
+ }
FUNC_LEAVE_NOAPI(ret_value)
} /* H5VL_native_register */
@@ -407,7 +438,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_g, NULL);
+ ret_value = H5P_set_vol(plist, H5VL_NATIVE_g, NULL);
done:
FUNC_LEAVE_API(ret_value)
@@ -671,13 +702,16 @@ static herr_t H5VL_native_attr_iterate(void *obj, H5VL_loc_params_t loc_params,
/* Call attribute iteration routine */
last_attr = start_idx = (idx ? *idx : 0);
- /* Iterate over the links */
+ /* Iterate over the attributess */
if(loc_params.type == H5VL_OBJECT_BY_SELF) {
/* Build the vol plugin struct */
if(NULL == (vol_plugin = (H5VL_t *)H5MM_calloc(sizeof(H5VL_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- vol_plugin->cls = &H5VL_native_g;
+ vol_plugin->cls = &H5VL_native_g;
vol_plugin->nrefs = 1;
+ vol_plugin->id = H5VL_NATIVE_g;
+ if(H5I_inc_ref(vol_plugin->id, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin")
/* Get an atom for the object */
if((obj_loc_id = H5I_register2(loc_params.obj_type, obj, vol_plugin, TRUE)) < 0)
@@ -729,6 +763,8 @@ done:
HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to free identifier");
vol_plugin->nrefs--;
+ if(H5I_dec_ref(vol_plugin->id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin")
if(0 == vol_plugin->nrefs)
H5MM_free(vol_plugin);
}
@@ -1898,17 +1934,13 @@ H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t UNUSED dxpl_id,
hid_t *plist_id = va_arg (arguments, hid_t *);
f = (H5F_t *)obj;
+
/* Retrieve the file's access property list */
if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list")
if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
-
- /* Set the VOL class in the property list - we don't
- have a VOL info for the native plugin */
- if(H5P_set(new_plist, H5F_ACS_VOL_NAME, &H5VL_native_g) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file VOL plugin")
break;
}
/* H5Fget_create_plist */
diff --git a/src/H5VLnative.h b/src/H5VLnative.h
index 37eb93b..36177ed 100644
--- a/src/H5VLnative.h
+++ b/src/H5VLnative.h
@@ -28,10 +28,9 @@
extern "C" {
#endif
-H5_DLL H5VL_class_t *H5VL_native_init(void);
+H5_DLL hid_t H5VL_native_init(void);
H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id);
- //H5_DLL herr_t H5VL_native_register_aux(hid_t obj_id);
-H5_DLL hid_t H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h
index 3739689..1b1d7b7 100644
--- a/src/H5VLpkg.h
+++ b/src/H5VLpkg.h
@@ -52,7 +52,7 @@
/******************************/
/* Package Private Prototypes */
/******************************/
-H5_DLL herr_t H5VL_init(void);
+
/*
H5_DLL haddr_t H5VL_alloc_real(H5VL_t *file, hid_t dxpl_id, H5VL_mem_t type,
diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h
index 6c4e850..73916df 100644
--- a/src/H5VLprivate.h
+++ b/src/H5VLprivate.h
@@ -30,7 +30,7 @@
/* Library Private Typedefs */
/****************************/
#define H5_REQUEST_NULL NULL
-#define H5_EVENT_STACK_NULL -1
+#define H5_EVENT_STACK_NULL ((hid_t)-1)
/*****************************/
/* Library Private Variables */
@@ -44,8 +44,8 @@
struct H5P_genplist_t;
struct H5F_t;
+H5_DLL herr_t H5VL_init(void);
H5_DLL int H5VL_term_interface(void);
-H5_DLL H5VL_class_t *H5VL_get_class(hid_t id);
H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref);
H5_DLL hid_t H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin, hbool_t app_ref);
H5_DLL ssize_t H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size);
@@ -116,9 +116,9 @@ H5_DLL herr_t H5VL_request_cancel(void **req, H5VL_t *vol_plugin, H5ES_status_t
H5_DLL herr_t H5VL_request_test(void **req, H5VL_t *vol_plugin, H5ES_status_t *status);
H5_DLL herr_t H5VL_request_wait(void **req, H5VL_t *vol_plugin, H5ES_status_t *status);
-H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, H5VL_class_t *vol_cls, const void *vol_info);
-H5_DLL herr_t H5VL_fapl_copy(H5VL_class_t *vol_cls, const void *vol_info, void **copied_info);
-H5_DLL herr_t H5VL_fapl_close(H5VL_class_t *vol_cls, void *vol_info);
+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 *vol_info, void **copied_info);
+H5_DLL herr_t H5VL_fapl_close(hid_t vol_id, void *vol_info);
H5_DLL herr_t H5F_close_file(void *file, H5VL_t *vol_plugin);
H5_DLL herr_t H5A_close_attr(void *attr, H5VL_t *vol_plugin);
@@ -126,4 +126,6 @@ H5_DLL herr_t H5D_close_dataset(void *dset, H5VL_t *vol_plugin);
H5_DLL herr_t H5G_close_group(void *grp, H5VL_t *vol_plugin);
H5_DLL herr_t H5T_close_datatype(void *dt, H5VL_t *vol_plugin);
+H5_DLL hid_t H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref);
+
#endif /* _H5VLprivate_H */
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index 982e1fc..bc5824f 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -327,10 +327,10 @@ typedef struct H5VL_class_t {
* memory.
*/
typedef struct H5VL_t {
- const H5VL_class_t *cls; /*constant class info */
- const char *container_name; /* name of the underlying storage container */
+ const H5VL_class_t *cls; /* constant class info */
unsigned long feature_flags; /* VOL Driver feature Flags */
int nrefs; /* number of references by objects using this struct */
+ hid_t id; /* identifier for the VOL class */
} H5VL_t;
#ifdef __cplusplus