From 7d289e8a697aba2f537a62d3b6352e357b3bd83b Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Wed, 23 May 2012 11:59:53 -0500 Subject: [svn-r22395] remove the high level ID implementation that wraps the actual ID, and store the VOL plugin in an auxilary structure in the ID pointer. --- src/H5A.c | 36 +- src/H5Adeprec.c | 6 +- src/H5D.c | 9 +- src/H5Dint.c | 6 +- src/H5F.c | 205 +++------ src/H5Ftest.c | 39 +- src/H5G.c | 2 +- src/H5Gint.c | 36 +- src/H5Gloc.c | 15 - src/H5Gtest.c | 15 - src/H5Gtraverse.c | 18 +- src/H5I.c | 190 ++------- src/H5Iprivate.h | 7 +- src/H5Ipublic.h | 5 - src/H5L.c | 22 +- src/H5O.c | 21 +- src/H5Olink.c | 11 +- src/H5Sselect.c | 2 +- src/H5T.c | 15 +- src/H5Tcommit.c | 28 +- src/H5Tvlen.c | 2 +- src/H5VL.c | 1188 ++++++++++++++++------------------------------------- src/H5VLnative.c | 29 +- src/H5VLprivate.h | 10 +- test/dtypes.c | 10 - test/links.c | 12 +- test/objcopy.c | 33 -- test/tattr.c | 23 +- test/tfile.c | 6 +- test/th5o.c | 26 +- 30 files changed, 578 insertions(+), 1449 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index 930eb9a..2ec3ce0 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -225,7 +225,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, H5TRACE6("i", "i*siiii", loc_id, attr_name, type_id, space_id, acpl_id, aapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id) || H5I_DATATYPE == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") @@ -251,10 +251,6 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute") done: - if (NULL != location) { - free (location); - location = NULL; - } FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ @@ -305,7 +301,7 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, acpl_id, aapl_id, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id) || H5I_DATATYPE == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -543,7 +539,7 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) H5TRACE3("i", "i*si", loc_id, attr_name, aapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") @@ -590,7 +586,7 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5TRACE5("i", "i*s*sii", loc_id, obj_name, attr_name, aapl_id, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -655,7 +651,7 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -1519,7 +1515,7 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -1656,7 +1652,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5TRACE5("e", "i*s*s*xi", loc_id, obj_name, attr_name, ainfo, lapl_id); /* Check args */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -1730,7 +1726,7 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -1840,7 +1836,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) /* check arguments */ if(!old_name || !new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "name is nil") - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") /* Avoid thrashing things if the names are the same */ @@ -1878,7 +1874,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -2055,7 +2051,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, op_data, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -2129,7 +2125,7 @@ H5Adelete(hid_t loc_id, const char *name) H5TRACE2("e", "i*s", loc_id, name); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -2170,7 +2166,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5TRACE4("e", "i*s*si", loc_id, obj_name, attr_name, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -2235,7 +2231,7 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5TRACE6("e", "i*sIiIohi", loc_id, obj_name, idx_type, order, n, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") @@ -2587,7 +2583,7 @@ H5Aexists(hid_t obj_id, const char *attr_name) H5TRACE2("t", "i*s", obj_id, attr_name); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(obj_id)) + if(H5I_ATTR == H5I_get_type(obj_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") @@ -2625,7 +2621,7 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5TRACE4("t", "i*s*si", loc_id, obj_name, attr_name, lapl_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 437cef8..b045bb6 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -147,7 +147,7 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, plist_id); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -208,7 +208,7 @@ H5Aopen_name(hid_t loc_id, const char *name) H5TRACE2("i", "i*s", loc_id, name); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -253,7 +253,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) H5TRACE2("i", "iIu", loc_id, idx); /* check arguments */ - if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(H5VL_object_generic(loc_id, H5VL_ATTR_OPEN_BY_IDX, H5_REQUEST_NULL, &ret_value, ".", H5_INDEX_CRT_ORDER, diff --git a/src/H5D.c b/src/H5D.c index 1e1e061..fe5522d 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -649,7 +649,7 @@ H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator") if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") - if(H5I_DATATYPE != H5I_get_type(type_id) && H5I_DATATYPE_PUBLIC != H5I_get_type(type_id)) + if(H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype") if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") @@ -688,7 +688,7 @@ H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf) H5TRACE4("e", "iii*x", type_id, space_id, plist_id, buf); /* Check args */ - if((H5I_DATATYPE != H5I_get_type(type_id) && H5I_DATATYPE_PUBLIC != H5I_get_type(type_id)) || + if((H5I_DATATYPE != H5I_get_type(type_id)) || buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) @@ -750,9 +750,8 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, H5TRACE4("e", "iii*h", dataset_id, type_id, space_id, size); /* Check args */ - if(H5I_DATASET_PUBLIC != H5I_get_type(dataset_id) || - (H5I_DATATYPE != H5I_get_type(type_id) && H5I_DATATYPE_PUBLIC != H5I_get_type(type_id)) || - size == NULL) + if(H5I_DATASET != H5I_get_type(dataset_id) || + (H5I_DATATYPE != H5I_get_type(type_id)) || size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") diff --git a/src/H5Dint.c b/src/H5Dint.c index a70ce2b..b1bf39d 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1919,7 +1919,7 @@ H5D__iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t op, /* Check args */ HDassert(buf); - HDassert(H5I_DATATYPE == H5I_get_type(type_id) || H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)); + HDassert(H5I_DATATYPE == H5I_get_type(type_id)); HDassert(space); HDassert(H5S_has_extent(space)); HDassert(op); @@ -1955,7 +1955,7 @@ H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id, void *buf) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - HDassert(H5I_DATATYPE == H5I_get_type(type_id) || H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)); + HDassert(H5I_DATATYPE == H5I_get_type(type_id)); HDassert(space); HDassert(H5P_isa_class(plist_id, H5P_DATASET_XFER)); HDassert(buf); @@ -2042,7 +2042,7 @@ H5D__vlen_get_buf_size(void UNUSED *elem, hid_t type_id, unsigned UNUSED ndim, c FUNC_ENTER_PACKAGE HDassert(op_data); - HDassert(H5I_DATATYPE == H5I_get_type(type_id) || H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)); + HDassert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object(type_id))) diff --git a/src/H5F.c b/src/H5F.c index a040b34..3972a08 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -199,14 +199,14 @@ H5F_term_interface(void) *------------------------------------------------------------------------- */ hid_t -H5Fget_create_plist(hid_t uid) +H5Fget_create_plist(hid_t file_id) { hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("i", "i", uid); + H5TRACE1("i", "i", file_id); - if(H5VL_file_get(uid, H5VL_FILE_GET_FCPL, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_file_get(file_id, H5VL_FILE_GET_FCPL, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties") done: @@ -236,14 +236,14 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Fget_access_plist(hid_t uid) +H5Fget_access_plist(hid_t file_id) { hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("i", "i", uid); + H5TRACE1("i", "i", file_id); - if(H5VL_file_get(uid, H5VL_FILE_GET_FAPL, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_file_get(file_id, H5VL_FILE_GET_FAPL, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties") done: @@ -394,7 +394,7 @@ H5Fget_obj_count(hid_t file_id, unsigned types) udata.obj_count = &ret_value; udata.types = types | H5F_OBJ_LOCAL; - if(H5I_iterate(H5I_FILE_PUBLIC, H5F_get_obj_count_cb, &udata, TRUE) < 0) + if(H5I_iterate(H5I_FILE, H5F_get_obj_count_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") } @@ -513,13 +513,10 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) udata.oid_list = oid_list; udata.obj_count = &ret_value; - if(H5I_iterate(H5I_FILE_PUBLIC, H5F_get_obj_ids_cb, &udata, TRUE) < 0) + if(H5I_iterate(H5I_FILE, H5F_get_obj_ids_cb, &udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") } - if (H5VL_replace_with_uids (oid_list, ret_value) <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get IDs") - done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_obj_ids() */ @@ -822,18 +819,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_vfd_handle(hid_t uid, hid_t fapl, void **file_handle) +H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ii**x", uid, fapl, file_handle); + H5TRACE3("e", "ii**x", file_id, fapl, file_handle); /* Check args */ if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer") - if((ret_value = H5VL_file_generic(uid, H5VL_FILE_GET_VFD_HANDLE, H5_REQUEST_NULL, file_handle, fapl)) < 0) + if((ret_value = H5VL_file_generic(file_id, H5VL_FILE_GET_VFD_HANDLE, H5_REQUEST_NULL, file_handle, fapl)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle") done: @@ -2028,24 +2025,15 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Freopen(hid_t uid) +H5Freopen(hid_t file_id) { H5F_t *old_file = NULL; H5F_t *new_file = NULL; - H5VL_id_wrapper_t *id_wrapper, *new_id_wrapper; - hid_t file_id, new_file_id, ret_value; + hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", file_id); - /* Get the file */ - if(H5I_FILE_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - file_id = id_wrapper->obj_id; - /* Check arguments */ if(NULL == (old_file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") @@ -2061,21 +2049,23 @@ H5Freopen(hid_t uid) new_file->open_name = H5MM_xstrdup(old_file->open_name); new_file->actual_name = H5MM_xstrdup(old_file->actual_name); - if((new_file_id = H5I_register(H5I_FILE, new_file, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") /* Keep this ID in file object structure */ - new_file->file_id = new_file_id; + new_file->file_id = ret_value; #if 1 /*MSC - This needs to go through the VOL */ - if(NULL == (new_id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - new_id_wrapper->obj_id = new_file_id; - new_id_wrapper->vol_plugin = id_wrapper->vol_plugin; - new_id_wrapper->vol_plugin->nrefs ++; - - if((ret_value = H5I_register(H5I_FILE_PUBLIC, new_id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + { + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; + } #endif done: @@ -2101,16 +2091,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_intent(hid_t uid, unsigned *intent_flags) +H5Fget_intent(hid_t file_id, unsigned *intent_flags) { herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*Iu", uid, intent_flags); + H5TRACE2("e", "i*Iu", file_id, intent_flags); /* If no intent flags were passed in, exit quietly */ if(intent_flags) { - if((ret_value = H5VL_file_get(uid, H5VL_FILE_GET_INTENT, H5_REQUEST_NULL, intent_flags)) < 0) + if((ret_value = H5VL_file_get(file_id, H5VL_FILE_GET_INTENT, H5_REQUEST_NULL, intent_flags)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file intent") } @@ -2142,28 +2132,18 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) HDassert(file); if(file->file_id == -1) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ /* Get an atom for the file */ if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") - /* Create a new id that points to a struct that holds the file id and the VOL id */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper->obj_id = file->file_id; - id_wrapper->vol_plugin = file->vol_cls; - id_wrapper->vol_plugin->nrefs ++; - - if((H5I_register(H5I_FILE_PUBLIC, id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(file->file_id, file->vol_cls, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + file->vol_cls->nrefs++; } else { /* Increment reference count on atom. */ if(H5I_inc_ref(file->file_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") - - /* Increment reference count on upper level ID. */ - if(H5VL_inc_ref_uid(file->file_id, app_ref) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing user ID failed") } /* end else */ ret_value = file->file_id; @@ -2523,14 +2503,14 @@ H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*o *------------------------------------------------------------------------- */ hssize_t -H5Fget_freespace(hid_t uid) +H5Fget_freespace(hid_t file_id) { hssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("Hs", "i", uid); + H5TRACE1("Hs", "i", file_id); - if(H5VL_file_get(uid, H5VL_FILE_GET_FREE_SPACE, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_file_get(file_id, H5VL_FILE_GET_FREE_SPACE, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file free space") done: @@ -2557,14 +2537,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_filesize(hid_t uid, hsize_t *size) +H5Fget_filesize(hid_t file_id, hsize_t *size) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*h", uid, size); + H5TRACE2("e", "i*h", file_id, size); - if((ret_value = H5VL_file_get(uid, H5VL_FILE_GET_SIZE, H5_REQUEST_NULL, size)) < 0) + if((ret_value = H5VL_file_get(file_id, H5VL_FILE_GET_SIZE, H5_REQUEST_NULL, size)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file size") done: @@ -2724,18 +2704,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_config(hid_t uid, H5AC_cache_config_t *config_ptr) +H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", uid, config_ptr); + H5TRACE2("e", "i*x", file_id, config_ptr); /* check args */ if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr") - if((ret_value = H5VL_file_get(uid, H5VL_FILE_GET_MDC_CONF, H5_REQUEST_NULL, config_ptr)) < 0) + if((ret_value = H5VL_file_get(file_id, H5VL_FILE_GET_MDC_CONF, H5_REQUEST_NULL, config_ptr)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get mdc config") done: @@ -2759,22 +2739,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fset_mdc_config(hid_t uid, H5AC_cache_config_t *config_ptr) +H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { H5F_t *file; /* File object for file ID */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", uid, config_ptr); - - if(H5I_FILE_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + H5TRACE2("e", "i*x", file_id, config_ptr); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(id_wrapper->obj_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* set the resize configuration */ @@ -2803,17 +2777,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_hit_rate(hid_t uid, double *hit_rate_ptr) +H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*d", uid, hit_rate_ptr); + H5TRACE2("e", "i*d", file_id, hit_rate_ptr); if(NULL == hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer") - if((ret_value = H5VL_file_get(uid, H5VL_FILE_GET_MDC_HR, H5_REQUEST_NULL, hit_rate_ptr)) < 0) + if((ret_value = H5VL_file_get(file_id, H5VL_FILE_GET_MDC_HR, H5_REQUEST_NULL, hit_rate_ptr)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: @@ -2839,16 +2813,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_mdc_size(hid_t uid, size_t *max_size_ptr, size_t *min_clean_size_ptr, +H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, int *cur_num_entries_ptr) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "i*z*z*z*Is", uid, max_size_ptr, min_clean_size_ptr, + H5TRACE5("e", "i*z*z*z*Is", file_id, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr); - if((ret_value = H5VL_file_get(uid, H5VL_FILE_GET_MDC_SIZE, H5_REQUEST_NULL, max_size_ptr, + if((ret_value = H5VL_file_get(file_id, H5VL_FILE_GET_MDC_SIZE, H5_REQUEST_NULL, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC hit rate") @@ -2878,22 +2852,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Freset_mdc_hit_rate_stats(hid_t uid) +H5Freset_mdc_hit_rate_stats(hid_t file_id) { H5F_t *file; /* File object for file ID */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", uid); - - if(H5I_FILE_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(id_wrapper->obj_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Reset the hit rate statistic */ @@ -2928,51 +2896,16 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Fget_name(hid_t uid, char *name/*out*/, size_t size) +H5Fget_name(hid_t file_id, char *name/*out*/, size_t size) { ssize_t ret_value; FUNC_ENTER_API(FAIL) - H5TRACE3("Zs", "ixz", uid, name, size); - - /* MSC - temp fix to handle later when all user level ids are of type UID */ - if (H5I_FILE_PUBLIC == H5I_get_type(uid) || H5I_GROUP_PUBLIC == H5I_get_type(uid) || - H5I_DATATYPE_PUBLIC == H5I_get_type(uid) || H5I_DATASET_PUBLIC == H5I_get_type(uid) || - H5I_ATTR_PUBLIC == H5I_get_type(uid)) { - if(H5VL_file_get(uid, H5VL_FILE_GET_NAME, H5_REQUEST_NULL,name, &ret_value, size) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name") - } - else { - H5F_t *f; /* Top file in mount hierarchy */ - size_t len; - /* For file IDs, get the file object directly */ - /* (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(H5I_get_type(uid) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - } /* end if */ - else { - H5G_loc_t loc; /* Object location */ - - /* Get symbol table entry */ - if(H5G_loc(uid, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") - f = loc.oloc->file; - } /* end else */ + H5TRACE3("Zs", "ixz", file_id, name, size); - len = HDstrlen(H5F_OPEN_NAME(f)); + if(H5VL_file_get(file_id, H5VL_FILE_GET_NAME, H5_REQUEST_NULL,name, &ret_value, size) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name") - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ - - /* Set return value */ - ret_value = (ssize_t)len; - } done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_name() */ @@ -2996,18 +2929,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_info2(hid_t uid, H5F_info2_t *finfo) +H5Fget_info2(hid_t file_id, H5F_info2_t *finfo) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", uid, finfo); + H5TRACE2("e", "i*x", file_id, finfo); /* Check args */ if(!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if((ret_value = H5VL_file_get(uid, H5VL_FILE_GET_INFO, H5_REQUEST_NULL, finfo)) < 0) + if((ret_value = H5VL_file_get(file_id, H5VL_FILE_GET_INFO, H5_REQUEST_NULL, finfo)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file info") done: FUNC_LEAVE_API(ret_value) @@ -3030,19 +2963,19 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Fget_free_sections(hid_t uid, H5F_mem_t type, size_t nsects, +H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/) { ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE4("Zs", "iFmzx", uid, type, nsects, sect_info); + H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info); /* Check args */ if(sect_info && nsects == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nsects must be > 0") - if(H5VL_file_get(uid, H5VL_FILE_GET_FREE_SECTIONS, H5_REQUEST_NULL, sect_info, &ret_value, + if(H5VL_file_get(file_id, H5VL_FILE_GET_FREE_SECTIONS, H5_REQUEST_NULL, sect_info, &ret_value, type, nsects) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file info") done: @@ -3065,22 +2998,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fclear_elink_file_cache(hid_t uid) +H5Fclear_elink_file_cache(hid_t file_id) { H5F_t *file; /* File */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", uid); + H5TRACE1("e", "i", file_id); /* Check args */ - if(H5I_FILE_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == (file = (H5F_t *)H5I_object_verify(id_wrapper->obj_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Release the EFC */ diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 7c15757..0073db7 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -96,25 +96,14 @@ *------------------------------------------------------------------------- */ herr_t -H5F_get_sohm_mesg_count_test(hid_t uid, unsigned type_id, +H5F_get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_count) { H5F_t *file; /* File info */ - H5VL_id_wrapper_t *id_wrapper; - hid_t file_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - file_id = id_wrapper->obj_id; - } - else { - file_id = uid; - } - /* Check arguments */ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") @@ -145,24 +134,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_check_cached_stab_test(hid_t uid) +H5F_check_cached_stab_test(hid_t file_id) { H5F_t *file; /* File info */ - H5VL_id_wrapper_t *id_wrapper; - hid_t file_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - file_id = id_wrapper->obj_id; - } - else { - file_id = uid; - } - /* Check arguments */ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") @@ -190,24 +168,13 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_get_maxaddr_test(hid_t uid, haddr_t *maxaddr) +H5F_get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) { H5F_t *file; /* File info */ - H5VL_id_wrapper_t *id_wrapper; - hid_t file_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - file_id = id_wrapper->obj_id; - } - else { - file_id = uid; - } - /* Check arguments */ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") diff --git a/src/H5G.c b/src/H5G.c index e9211ec..7c347b6 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -477,7 +477,7 @@ H5Gget_info(hid_t loc_id, H5G_info_t *grp_info) /* Check args */ id_type = H5I_get_type(loc_id); - if(!(H5I_GROUP_PUBLIC == id_type || H5I_FILE_PUBLIC == id_type)) + if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(!grp_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") diff --git a/src/H5Gint.c b/src/H5Gint.c index ca60a6a..1e204d8 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -814,7 +814,7 @@ H5G_iterate(hid_t loc_id, const char *group_name, hid_t gid = -1; /* ID of group to iterate over */ H5G_t *grp = NULL; /* Pointer to group data structure to iterate over */ H5G_iter_appcall_ud_t udata; /* User data for callback */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure of new opend group*/ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -835,15 +835,11 @@ H5G_iterate(hid_t loc_id, const char *group_name, if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") - /* MSC - Create a new id that points to a struct that holds the group id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper->obj_id = gid; - id_wrapper->vol_plugin = H5F_get_vol_cls(loc.oloc->file); - - if((gid = H5I_register(H5I_GROUP_PUBLIC, id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* attach VOL information to the ID */ + vol_plugin = H5F_get_vol_cls(loc.oloc->file); + if (H5I_register_aux(gid, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; /* Set up user data for callback */ udata.gid = gid; @@ -857,7 +853,7 @@ H5G_iterate(hid_t loc_id, const char *group_name, done: /* Release the group opened */ if(gid > 0) { - if(H5I_dec_app_ref(id_wrapper->obj_id) < 0 && H5I_dec_app_ref(gid) < 0) + if(H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } /* end if */ else if(grp && H5G_close(grp) < 0) @@ -1095,7 +1091,7 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_loc_t loc; /* Location of group passed in */ H5G_loc_t start_loc; /* Location of starting group */ unsigned rc; /* Reference count of object */ - H5VL_id_wrapper_t *id_wrapper; /* wrapper for the group ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ @@ -1119,15 +1115,11 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5G_loc(gid, &start_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* MSC - Create a new id that points to a struct that holds the group id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper->obj_id = gid; - id_wrapper->vol_plugin = H5F_get_vol_cls(loc.oloc->file); - - if((gid = H5I_register(H5I_GROUP_PUBLIC, id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* attach VOL information to the ID */ + vol_plugin = H5F_get_vol_cls(loc.oloc->file); + if (H5I_register_aux(gid, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; /* Set up user data */ udata.gid = gid; @@ -1204,7 +1196,7 @@ done: /* Release the group opened */ if(gid > 0) { - if(H5I_dec_app_ref(id_wrapper->obj_id) < 0 && H5I_dec_app_ref(gid) < 0) + if(H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } /* end if */ else if(grp && H5G_close(grp) < 0) diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 1080add..e513d17 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -159,25 +159,10 @@ static herr_t H5G_loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc) { - H5I_type_t id_type; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(loc_id); - /* get the actual ID from an upper ID level */ - /* MSC - this is a workaround to allow the test suite to pass and - at some point needs to be removed once all high level operations - that needs to go through the VOL actually go through the VOL*/ - if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || - H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || - H5I_ATTR_PUBLIC == id_type) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - loc_id = id_wrapper->obj_id; - } - switch(H5I_get_type(loc_id)) { case H5I_FILE: { diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 86730a7..0af43f4 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -515,7 +515,6 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign { void *obj_ptr; /* Pointer to object for ID */ H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ - H5I_type_t id_type; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -524,20 +523,6 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HDassert(user_path_len); HDassert(obj_hidden); - id_type = H5I_get_type(obj_id); - /* get the actual OBJ_ID from an upper ID level */ - /* MSC - this is a workaround to allow the test suite to pass and - at some point needs to be removed once all high level operations - that needs to go through the VOL actually go through the VOL*/ - if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || - H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || - H5I_ATTR_PUBLIC == id_type) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - obj_id = id_wrapper->obj_id; - } - /* Get pointer to object for ID */ if(NULL == (obj_ptr = H5I_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID") diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 6411175..2ff5477 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -180,7 +180,7 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, hid_t lapl_id = (-1); /* LAPL local to this routine */ H5P_genplist_t *lapl; /* LAPL with nlinks set */ hid_t cur_grp = (-1); - H5VL_id_wrapper_t *id_wrapper; /* wrapper for the group ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -211,15 +211,11 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, if((cur_grp = H5I_register(H5I_GROUP, grp, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") - /* MSC - Create a new id that points to a struct that holds the group id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper->obj_id = cur_grp; - id_wrapper->vol_plugin = H5F_get_vol_cls(grp_loc->oloc->file); - - if((cur_grp = H5I_register(H5I_GROUP_PUBLIC, id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* attach VOL information to the ID */ + vol_plugin = H5F_get_vol_cls(grp_loc->oloc->file); + if (H5I_register_aux(cur_grp, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; /* Check for generic default property list and use link access default if so */ if(_lapl_id == H5P_DEFAULT) { @@ -291,7 +287,7 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, done: /* Close location given to callback. */ - if(cur_grp > 0 && H5I_dec_ref(id_wrapper->obj_id) < 0 && H5I_dec_ref(cur_grp) < 0) + if(cur_grp > 0 && H5I_dec_ref(cur_grp) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom for current location") if(ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0) diff --git a/src/H5I.c b/src/H5I.c index 7b33533..f4b308f 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -94,6 +94,8 @@ typedef struct H5I_id_info_t { unsigned count; /* ref. count for this atom */ unsigned app_count; /* ref. count of application visible atoms */ const void *obj_ptr; /* pointer associated with the atom */ + const void *aux_ptr; /* auxilary pointer associated with the atom */ + H5I_free_t free_aux; /*release auxilary structure method */ struct H5I_id_info_t *next; /* link to next atom (in case of hash-clash)*/ } H5I_id_info_t; @@ -823,6 +825,8 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) id_ptr->count = 1; /*initial reference count*/ id_ptr->app_count = !!app_ref; id_ptr->obj_ptr = object; + id_ptr->aux_ptr = NULL; + id_ptr->free_aux = NULL; id_ptr->next = NULL; /* hash bucket already full, prepend to front of chain */ @@ -1018,26 +1022,12 @@ void * H5I_object_verify(hid_t id, H5I_type_t id_type) { H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ void *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(NULL) HDassert(id_type >= 1 && id_type < H5I_next_type); - /* Temp workaround for tests to pass */ -#if 1 - if ((H5I_FILE_PUBLIC == H5I_get_type(id) && H5I_FILE_PUBLIC != id_type) || - (H5I_GROUP_PUBLIC == H5I_get_type(id) && H5I_GROUP_PUBLIC != id_type) || - (H5I_DATATYPE_PUBLIC == H5I_get_type(id) && H5I_DATATYPE_PUBLIC != id_type) || - (H5I_DATASET_PUBLIC == H5I_get_type(id) && H5I_DATASET_PUBLIC != id_type) || - (H5I_ATTR_PUBLIC == H5I_get_type(id) && H5I_ATTR_PUBLIC != id_type)) { - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = id_wrapper->obj_id; - } -#endif - /* Verify that the type of the ID is correct & lookup the ID */ if(id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I_find_id(id))) { /* Get the object pointer to return */ @@ -1352,7 +1342,8 @@ H5I_dec_ref(hid_t id) */ if(1 == id_ptr->count) { /* (Casting away const OK -QAK) */ - if(!type_ptr->free_func || (type_ptr->free_func)((void *)id_ptr->obj_ptr) >= 0) { + if((!type_ptr->free_func || (type_ptr->free_func)((void *)id_ptr->obj_ptr) >= 0) && + (!id_ptr->free_aux || (id_ptr->free_aux)((void *)id_ptr->aux_ptr) >= 0)) { H5I_remove(id); ret_value = 0; } /* end if */ @@ -2227,9 +2218,6 @@ H5Iget_file_id(hid_t id) if((ret_value = H5I_get_file_id(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") - if (H5VL_replace_with_uids (&ret_value, 1) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") - done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_file_id() */ @@ -2259,18 +2247,6 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) FUNC_ENTER_NOAPI_NOINIT id_type = H5I_get_type(obj_id); - /* get the actual OBJ_ID from an upper ID level */ - /* MSC - this is a workaround to allow the test suite to pass and - at some point needs to be removed once all high level operations - that needs to go through the VOL actually go through the VOL*/ - if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || - H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || - H5I_ATTR_PUBLIC == id_type) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - obj_id = id_wrapper->obj_id; - } /* Get object type */ type = H5I_TYPE(obj_id); @@ -2279,10 +2255,6 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) if(H5I_inc_ref(obj_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") - /* Increment reference count on upper level ID. */ - if(H5VL_inc_ref_uid(obj_id, app_ref) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing user ID failed") - /* Set return value */ ret_value = obj_id; } /* end if */ @@ -2307,157 +2279,65 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_replace_with_uids + * Function: H5I_register_aux * - * Purpose: change the ids used by the HDF5 libraries to the UIDs that - * are provided to the user + * Purpose: increment the ref count on the high level ID given the low level ID * - * Return: How many IDs were replaced. + * Return: Success: postive + * Failure: FAIL * * Programmer: Mohamad Chaarawi - * Feb 2012 + * May 2012 * *------------------------------------------------------------------------- */ -int -H5VL_replace_with_uids(hid_t *old_list, ssize_t num_ids) +herr_t +H5I_register_aux(hid_t id, void *aux_ptr, H5I_free_t free_func) { - ssize_t j; - H5I_type_t type; - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - for (j=0 ; jcount <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Only iterate through hash table if there are IDs in group */ - if(type_ptr->ids > 0) { - H5I_id_info_t *id_ptr; /*ptr to the new ID */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - unsigned i; /*counter */ - - /* Start at the beginning of the array */ - for(i = 0; i < type_ptr->hash_size; i++) { - id_ptr = type_ptr->id_list[i]; - while(id_ptr) { - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id_ptr->id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if (id_wrapper->obj_id == old_list[j]) { - old_list[j] = id_ptr->id; - ret_value ++; - replaced = TRUE; - break; - } - id_ptr = id_ptr->next; - } /* end while */ - if (replaced) - break; - } /* end for */ - } /* end if */ + if(NULL != (id_ptr = H5I_find_id(id))) { + id_ptr->aux_ptr = aux_ptr; + id_ptr->free_aux = free_func; } + done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_replace_with_uids() */ +} /* end H5I_register_aux() */ /*------------------------------------------------------------------------- - * Function: H5VL_inc_ref_uid + * Function: H5I_get_aux * - * Purpose: increment the ref count on the high level ID given the low level ID + * Purpose: return the aux ptr * - * Return: How many IDs were replaced. + * Return: Success: Non-null auxilary pointer associated with the + * specified ID. + * Failure: NULL * * Programmer: Mohamad Chaarawi - * Feb 2012 + * May 2012 * *------------------------------------------------------------------------- */ -int -H5VL_inc_ref_uid(hid_t id, hbool_t app_ref) +void * +H5I_get_aux(hid_t id) { - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_type_t type; - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ + void * ret_value = NULL; /*return value */ - FUNC_ENTER_NOAPI(FAIL) - - type = H5I_get_type(id); + FUNC_ENTER_NOAPI_NOINIT - if (H5I_FILE == type) { - type_ptr = H5I_id_type_list_g[H5I_FILE_PUBLIC]; - } - else if (H5I_GROUP == type) { - type_ptr = H5I_id_type_list_g[H5I_GROUP_PUBLIC]; - } - else if (H5I_DATASET == type) { - type_ptr = H5I_id_type_list_g[H5I_DATASET_PUBLIC]; - } - else if (H5I_DATATYPE == type) { - type_ptr = H5I_id_type_list_g[H5I_DATATYPE_PUBLIC]; - } - else if (H5I_ATTR == type) { - type_ptr = H5I_id_type_list_g[H5I_ATTR_PUBLIC]; - } - else { - HGOTO_DONE(ret_value) + if(NULL != (id_ptr = H5I_find_id(id))) { + ret_value = (void *)id_ptr->aux_ptr; } - if(type_ptr == NULL || type_ptr->count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - - /* Only iterate through hash table if there are IDs in group */ - if(type_ptr->ids > 0) { - H5I_id_info_t *id_ptr; /*ptr to the new ID */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - unsigned i; /*counter */ - - /* Start at the beginning of the array */ - for(i = 0; i < type_ptr->hash_size; i++) { - id_ptr = type_ptr->id_list[i]; - while(id_ptr) { - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id_ptr->id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if (id_wrapper->obj_id == id) { - /* Increment reference count on atom. */ - if((ret_value = H5I_inc_ref(id_ptr->id, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") - HGOTO_DONE(ret_value) - } - id_ptr = id_ptr->next; - } /* end while */ - } /* end for */ - } /* end if */ - done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_inc_ref_uid() */ +} /* end H5I_get_aux() */ /*------------------------------------------------------------------------- diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index ee938df..faa91f9 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -46,11 +46,6 @@ #define H5I_REFID_HASHSIZE 64 #define H5I_VFL_HASHSIZE 64 #define H5I_VOL_HASHSIZE 64 -#define H5I_FILE_PUBLIC_HASHSIZE 64 -#define H5I_GROUP_PUBLIC_HASHSIZE 64 -#define H5I_DATASET_PUBLIC_HASHSIZE 64 -#define H5I_ATTR_PUBLIC_HASHSIZE 64 -#define H5I_DATATYPE_PUBLIC_HASHSIZE 64 #define H5I_GENPROPCLS_HASHSIZE 64 #define H5I_GENPROPOBJ_HASHSIZE 128 #define H5I_ERRCLS_HASHSIZE 64 @@ -79,5 +74,7 @@ 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_register_aux(hid_t id, void *aux_ptr, H5I_free_t free_func); +H5_DLL void *H5I_get_aux(hid_t id); #endif /* _H5Iprivate_H */ diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 1673f60..a1b483d 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -45,11 +45,6 @@ typedef enum H5I_type_t { H5I_REFERENCE, /*type ID for Reference objects */ H5I_VFL, /*type ID for virtual file layer */ H5I_VOL, /*type ID for virtual object layer */ - H5I_FILE_PUBLIC, /*type ID for upper level file ID objects */ - H5I_GROUP_PUBLIC, /*type ID for upper level group ID objects */ - H5I_DATASET_PUBLIC, /*type ID for upper level dataset ID objects */ - H5I_ATTR_PUBLIC, /*type ID for upper level attribute ID objects */ - H5I_DATATYPE_PUBLIC, /*type ID for upper level datatype ID objects */ H5I_GENPROP_CLS, /*type ID for generic property list classes */ H5I_GENPROP_LST, /*type ID for generic property lists */ H5I_ERROR_CLASS, /*type ID for error classes */ diff --git a/src/H5L.c b/src/H5L.c index e0c5f9c..3f48431 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -1133,7 +1133,7 @@ H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order, /* Check arguments */ id_type = H5I_get_type(id); - if(!(H5I_GROUP_PUBLIC == id_type || H5I_FILE_PUBLIC == id_type)) + if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") @@ -1276,7 +1276,7 @@ H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, id_type = H5I_get_type(grp_id); /* Check args */ - if(!(H5I_GROUP_PUBLIC == id_type || H5I_FILE_PUBLIC == id_type)) + if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") @@ -1637,7 +1637,7 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED H5G_loc_t temp_loc; /* For UD callback */ hbool_t temp_loc_init = FALSE; /* Temporary location for UD callback (temp_loc) has been initialized */ hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */ - H5VL_id_wrapper_t *id_wrapper; /* wrapper for the group ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1732,15 +1732,11 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register ID for group") - /* MSC - Create a new id that points to a struct that holds the group id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper->obj_id = grp_id; - id_wrapper->vol_plugin = H5F_get_vol_cls(grp_loc->oloc->file); - - if((grp_id = H5I_register(H5I_GROUP_PUBLIC, id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* attach VOL information to the ID */ + vol_plugin = H5F_get_vol_cls(grp_loc->oloc->file); + if (H5I_register_aux(grp_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; /* Make callback */ if((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, H5P_DEFAULT) < 0) @@ -1765,7 +1761,7 @@ done: /* Close the location given to the user callback if it was created */ if(grp_id >= 0) { - if(H5I_dec_app_ref(id_wrapper->obj_id) < 0 && H5I_dec_app_ref(grp_id) < 0) + if(H5I_dec_app_ref(grp_id) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") } /* end if */ else if(grp != NULL) { diff --git a/src/H5O.c b/src/H5O.c index b6e1447..204046b 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -2395,31 +2395,12 @@ done: *------------------------------------------------------------------------- */ H5O_loc_t * -H5O_get_loc(hid_t id) +H5O_get_loc(hid_t object_id) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - hid_t object_id; - H5I_type_t id_type; H5O_loc_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - id_type = H5I_get_type(id); - - /* get the actual ID from an upper ID level */ - /* MSC - this is a workaround to allow the test suite to pass and - at some point needs to be removed once all high level operations - that needs to go through the VOL actually go through the VOL*/ - if (H5I_GROUP_PUBLIC == id_type || H5I_DATASET_PUBLIC == id_type || - H5I_DATATYPE_PUBLIC == id_type) { - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, NULL, "invalid user identifier") - object_id = id_wrapper->obj_id; - } - else { - object_id = id; - } - switch(H5I_get_type(object_id)) { case H5I_GROUP: if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) diff --git a/src/H5Olink.c b/src/H5Olink.c index 12171b2..88c9e28 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -636,26 +636,19 @@ H5O_link_delete(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh, void *_mesg) /* Check for delete callback */ if(link_class->del_func) { hid_t file_id; /* ID for the file the link is located in (passed to user callback) */ - hid_t wrapper_id; /* Get a file ID for the file the link is in */ if((file_id = H5F_get_id(f, FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get file ID") - wrapper_id = file_id; - - if (H5VL_replace_with_uids (&wrapper_id, 1) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") - /* Call user-defined link's 'delete' callback */ - if((link_class->del_func)(lnk->name, wrapper_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) { + if((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) { H5I_dec_ref(file_id); - H5I_dec_ref(wrapper_id); HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "link deletion callback returned failure") } /* end if */ /* Release the file ID */ - if(H5I_dec_ref(file_id) < 0 && H5I_dec_ref(wrapper_id) < 0) + if(H5I_dec_ref(file_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") } /* end if */ } /* end if */ diff --git a/src/H5Sselect.c b/src/H5Sselect.c index b1d1058..91aed1e 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -1240,7 +1240,7 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t /* Check args */ HDassert(buf); - HDassert(H5I_DATATYPE == H5I_get_type(type_id) || H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)); + HDassert(H5I_DATATYPE == H5I_get_type(type_id)); HDassert(space); HDassert(op); diff --git a/src/H5T.c b/src/H5T.c index 3345b43..5442098 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1637,22 +1637,12 @@ H5Tcopy(hid_t type_id) { H5T_t *dt; /* Pointer to the datatype to copy */ H5T_t *new_dt = NULL; - H5I_type_t id_type; hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", type_id); - id_type = H5I_get_type(type_id); - if (H5I_DATATYPE_PUBLIC == id_type || H5I_DATASET_PUBLIC == id_type) { - H5VL_id_wrapper_t *id_wrapper; - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(type_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - type_id = id_wrapper->obj_id; - id_type = H5I_get_type(type_id); - } - - switch(id_type) { + switch(H5I_get_type(type_id)) { case H5I_DATATYPE: /* The argument is a datatype handle */ if(NULL == (dt = (H5T_t *)H5I_object(type_id))) @@ -1730,7 +1720,8 @@ H5Tclose(hid_t type_id) H5TRACE1("e", "i", type_id); /* if this is a named datatype, go through the VOL layer */ - if (H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)) { + + if(NULL != H5I_get_aux(type_id)) { if(H5VL_datatype_close(type_id, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to free datatype") } diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 9ad67b9..cd4701c 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -154,7 +154,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, /* commite the datatype through the VOL */ if((ret_value = H5VL_datatype_commit(loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit2() */ @@ -271,12 +271,6 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) FUNC_ENTER_API(FAIL) H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Get correct property list */ if(H5P_DEFAULT == tcpl_id) tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; @@ -291,22 +285,10 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") - /* Commit the type */ - if(H5T__commit(loc.oloc->file, type, tcpl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") - - /* Release the datatype's object header */ - { - H5O_loc_t *oloc; /* Object location for datatype */ - - /* Get the new committed datatype's object location */ - if(NULL == (oloc = H5T_oloc(type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype") - - /* Decrement refcount on committed datatype's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - } /* end if */ + /* commite the datatype through the VOL */ + if((ret_value = H5VL_datatype_commit(loc_id, NULL, type_id, 0, tcpl_id, tapl_id, + H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 05fccf2..f497d1e 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -1164,7 +1164,7 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned UNUSED ndim, const hsize_t HDassert(elem); HDassert(vl_alloc_info); - HDassert(H5I_DATATYPE == H5I_get_type(type_id) || H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)); + HDassert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ if(NULL == (dt = H5I_object_verify(type_id, H5I_DATATYPE))) diff --git a/src/H5VL.c b/src/H5VL.c index ab675df..09f895e 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -52,7 +52,6 @@ /* Local Prototypes */ /********************/ static herr_t H5VL_free_cls(H5VL_class_t *cls); -static herr_t H5VL_free_id_wrapper(H5VL_id_wrapper_t *id_struct); /*------------------------------------------------------------------------- @@ -108,22 +107,6 @@ H5VL_init_interface(void) if(H5I_register_type(H5I_VOL, (size_t)H5I_VOL_HASHSIZE, 0, (H5I_free_t)H5VL_free_cls)obj_id, TRUE); - while (ref_count > 0) { - if((ref_count = H5I_dec_app_ref(id_struct->obj_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") - } - - /* decrement the number of reference on the VOL plugin */ - id_struct->vol_plugin->nrefs --; - - /* free the ID wrapper */ - H5MM_xfree(id_struct); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_free_id_wrapper() */ - - -/*------------------------------------------------------------------------- * Function: H5VLregister * * Purpose: Registers a new vol plugin as a member of the virtual object @@ -539,12 +439,41 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_close + * + * Purpose: decrements the ref count on the number of references + * outstanding for a VOL plugin + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_close(H5VL_class_t *vol_plugin) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + vol_plugin->nrefs--; + + if(0 == vol_plugin->nrefs) + H5MM_xfree(vol_plugin); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_close() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_attr_create * * Purpose: Creates an attribute through the VOL * - * Return: Success: User ID of the new attr. This ID is of type - * H5I_ATTR_PUBLIC which contains the VOL plugin and the actual attr ID + * Return: Success: User ID of the new attr. * * Failure: FAIL * @@ -554,44 +483,28 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_attr_create(hid_t uid, const char *name, hid_t acpl_id, hid_t aapl_id, hid_t req) +H5VL_attr_create(hid_t id, const char *name, hid_t acpl_id, hid_t aapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the attr will be created */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new created attr*/ - H5I_type_t id_type; - hid_t loc_id; /* actual attr ID */ - hid_t ret_value; /* Return value */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check id */ - if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the corresponding VOL create callback exists */ - if(NULL == id_wrapper1->vol_plugin->attr_cls.create) + if(NULL == vol_plugin->attr_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr create' method") /* call the corresponding VOL create callback */ - if((loc_id = (id_wrapper1->vol_plugin->attr_cls.create) - (id_wrapper1->obj_id, name, acpl_id, aapl_id, req)) < 0) + if((ret_value = (vol_plugin->attr_cls.create) (id, name, acpl_id, aapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") - /* Create a new id that points to a struct that holds the attr id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = loc_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - if((ret_value = H5I_register(H5I_ATTR_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attr handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -603,8 +516,7 @@ done: * * Purpose: Opens an attribute through the VOL * - * Return: Success: User ID of the new attr. This ID is of type - * H5I_ATTR_PUBLIC which contains the VOL plugin and the actual attr ID + * Return: Success: User ID of the new attr. * * Failure: FAIL * @@ -614,46 +526,29 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_attr_open(hid_t loc_id, void *location, const char *name, hid_t aapl_id, hid_t req) +H5VL_attr_open(hid_t id, void *location, const char *name, hid_t aapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the attr will be opend */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend attr*/ - H5I_type_t id_type; - hid_t attr_id; /* actual attr ID */ - hid_t ret_value; /* Return value */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(loc_id); - /* Check id */ - if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && - H5I_ATTR_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the type specific corresponding VOL open callback exists */ - if(NULL == id_wrapper1->vol_plugin->attr_cls.open) { + if(NULL == vol_plugin->attr_cls.open) { HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr open' method") } /* call the corresponding VOL open callback */ - if((attr_id = (id_wrapper1->vol_plugin->attr_cls.open) - (id_wrapper1->obj_id, location, name, aapl_id, req)) < 0) + if((ret_value = (vol_plugin->attr_cls.open) (id, location, name, aapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - /* Create a new id that points to a struct that holds the attr id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = attr_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - if((ret_value = H5I_register(H5I_ATTR_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attr handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -674,25 +569,19 @@ done: * *------------------------------------------------------------------------- */ -herr_t H5VL_attr_read(hid_t uid, hid_t mem_type_id, void *buf, hid_t req) +herr_t H5VL_attr_read(hid_t id, hid_t mem_type_id, void *buf, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_ATTR_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->attr_cls.read) + if(NULL == vol_plugin->attr_cls.read) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr read' method") - if((ret_value = (id_wrapper->vol_plugin->attr_cls.read) - (id_wrapper->obj_id, mem_type_id, buf, req)) < 0) + if((ret_value = (vol_plugin->attr_cls.read)(id, mem_type_id, buf, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "read failed") done: @@ -714,25 +603,19 @@ done: * *------------------------------------------------------------------------- */ -herr_t H5VL_attr_write(hid_t uid, hid_t mem_type_id, const void *buf, hid_t req) +herr_t H5VL_attr_write(hid_t id, hid_t mem_type_id, const void *buf, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_ATTR_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == id_wrapper->vol_plugin->attr_cls.write) + if(NULL == vol_plugin->attr_cls.write) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr write' method") - if((ret_value = (id_wrapper->vol_plugin->attr_cls.write) - (id_wrapper->obj_id, mem_type_id, buf, req)) < 0) + if((ret_value = (vol_plugin->attr_cls.write)(id, mem_type_id, buf, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "write failed") done: @@ -755,56 +638,41 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_get(hid_t uid, H5VL_attr_get_t get_type, hid_t req, ...) +H5VL_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ - H5I_type_t id_type; /* Type of ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check id */ - if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && - H5I_ATTR_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->attr_cls.get) + if(NULL == vol_plugin->attr_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr get' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->attr_cls.get)(id_wrapper->obj_id, get_type, req, - arguments)) < 0) + if((ret_value = (vol_plugin->attr_cls.get)(id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); - /* if the get_type is a named datatype, create a wrapper for it */ + /* if the get_type is a named datatype, attach the vol info to it */ if(H5VL_ATTR_GET_TYPE == get_type) { - H5VL_id_wrapper_t *temp_id_wrapper; /* user id structure */ - hid_t *ret_id; + hid_t *ret_id; va_start (arguments, req); ret_id = va_arg (arguments, hid_t *); - if(H5T_committed((H5T_t *)H5I_object_verify(*ret_id, H5I_DATATYPE))) { - /* Create a new id that points to a struct that holds the attr id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (temp_id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - temp_id_wrapper->obj_id = *ret_id; - temp_id_wrapper->vol_plugin = id_wrapper->vol_plugin; - - if((*ret_id = H5I_register(H5I_DATATYPE_PUBLIC, temp_id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attr handle") + 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") + vol_plugin->nrefs++; } va_end (arguments); } + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_attr_get() */ @@ -825,24 +693,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_remove(hid_t loc_id, void *location, const char *attr_name, hid_t req) +H5VL_attr_remove(hid_t id, void *location, const char *attr_name, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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((ret_value = (id_wrapper->vol_plugin->attr_cls.remove) - (id_wrapper->obj_id, location, attr_name, req)) < 0) + if((ret_value = (vol_plugin->attr_cls.remove)(id, location, attr_name, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDELETE, FAIL, "remove failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_close() */ +} /* end H5VL_attr_remove() */ /*------------------------------------------------------------------------- @@ -860,34 +726,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_attr_close(hid_t uid, hid_t req) +H5VL_attr_close(hid_t id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_ATTR_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 the VOL class does not implement a specific attr close callback, try the generic object close */ - if(NULL == id_wrapper->vol_plugin->attr_cls.close){ - if(H5VL_object_close(uid, req) < 0) + if(NULL == vol_plugin->attr_cls.close){ + if(H5VL_object_close(id, req) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object") } else { - if((ret_value = (id_wrapper->vol_plugin->attr_cls.close)(id_wrapper->obj_id, req)) < 0) + if((ret_value = (vol_plugin->attr_cls.close)(id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") - - id_wrapper->vol_plugin->nrefs--; - if(H5I_dec_app_ref(uid) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") } done: FUNC_LEAVE_NOAPI(ret_value) @@ -909,42 +766,29 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_commit(hid_t uid, const char *name, hid_t type_id, hid_t lcpl_id, +H5VL_datatype_commit(hid_t id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* wrapper object of the location where the datatype will be commitd */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the corresponding VOL commit callback exists */ - if(NULL == id_wrapper1->vol_plugin->datatype_cls.commit) + if(NULL == vol_plugin->datatype_cls.commit) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype commit' method") /* call the corresponding VOL commit callback */ - if((ret_value = (id_wrapper1->vol_plugin->datatype_cls.commit) - (id_wrapper1->obj_id, name, type_id, lcpl_id, tcpl_id, tapl_id, req)) < 0) + if((ret_value = (vol_plugin->datatype_cls.commit) + (id, name, type_id, lcpl_id, tcpl_id, tapl_id, req)) < 0) 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - if((id_wrapper2->obj_id = H5I_register(H5I_DATATYPE, H5I_object(type_id), TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - H5I_register_cb(type_id, H5VL_get_wrapper_struct, id_wrapper2); - //H5I_subst(type_id, id_wrapper2); - //H5I_remove_verify(type_id, H5I_DATATYPE); - -#endif + if (H5I_register_aux(type_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -956,8 +800,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 plugin and the actual datatype ID + * Return: Success: User ID of the datatype. * * Failure: FAIL * @@ -967,53 +810,43 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id, hid_t req) +H5VL_datatype_open(hid_t id, const char *name, hid_t tapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the datatype will be opend */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend datatype*/ - hid_t datatype_id; /* actual datatype ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the type specific corresponding VOL open callback exists */ - if(NULL == id_wrapper1->vol_plugin->datatype_cls.open) { + if(NULL == vol_plugin->datatype_cls.open) { void *location = NULL; /* a pointer to VOL specific token that indicates the location of the object */ /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, req, &location, name, tapl_id) < 0) + if(H5VL_object_lookup (id, H5VL_OBJECT_LOOKUP_BY_NAME, req, &location, name, tapl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(loc_id, location, tapl_id, req)) < 0) + if((ret_value = H5VL_object_open_by_loc(id, location, tapl_id, req)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") if (NULL != location) { /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) + if(H5VL_object_free_loc (id, location, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") } } else { /* call the corresponding VOL open callback */ - if((datatype_id = (id_wrapper1->vol_plugin->datatype_cls.open) - (id_wrapper1->obj_id, name, tapl_id, req)) < 0) + if((ret_value = (vol_plugin->datatype_cls.open)(id, name, tapl_id, req)) < 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = datatype_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1034,23 +867,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_datatype_close(hid_t uid, hid_t req) +H5VL_datatype_close(hid_t id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* wrapper object of the datatype to be closed */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the corresponding VOL close callback exists */ - if(NULL == id_wrapper->vol_plugin->datatype_cls.close) + if(NULL == vol_plugin->datatype_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype close' method") /* call the corresponding VOL close callback */ - if((ret_value = (id_wrapper->vol_plugin->datatype_cls.close)(id_wrapper->obj_id, req)) < 0) + if((ret_value = (vol_plugin->datatype_cls.close)(id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") done: @@ -1063,8 +895,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 plugin and the actual dataset ID + * Return: Success: User ID of the new dataset. * * Failure: FAIL * @@ -1074,59 +905,28 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_dataset_create(hid_t uid, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req) +H5VL_dataset_create(hid_t id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the dataset will be created */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new created dataset*/ - hid_t dataset_id; /* actual dataset ID */ - hid_t ret_value; /* Return value */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* unwrap the datatype id if it is a named datatype */ - { - H5VL_id_wrapper_t *id_wrapper; - hid_t type_id; - H5P_genplist_t *plist; - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* get creation properties */ - if(H5P_get(plist, H5D_CRT_TYPE_ID_NAME, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") - - if(H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)) { - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(type_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(H5P_set(plist, H5D_CRT_TYPE_ID_NAME, &(id_wrapper->obj_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") - } - } - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the corresponding VOL create callback exists */ - if(NULL == id_wrapper1->vol_plugin->dataset_cls.create) + if(NULL == vol_plugin->dataset_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset create' method") /* call the corresponding VOL create callback */ - if((dataset_id = (id_wrapper1->vol_plugin->dataset_cls.create) - (id_wrapper1->obj_id, name, dcpl_id, dapl_id, req)) < 0) + if((ret_value = (vol_plugin->dataset_cls.create)(id, name, dcpl_id, dapl_id, req)) < 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = dataset_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - if((ret_value = H5I_register(H5I_DATASET_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1138,8 +938,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 plugin and the actual dataset ID + * Return: Success: User ID of the new dataset. * * Failure: FAIL * @@ -1149,53 +948,44 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id, hid_t req) +H5VL_dataset_open(hid_t id, const char *name, hid_t dapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the dataset will be opend */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend dataset*/ - hid_t dataset_id; /* actual dataset ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the type specific corresponding VOL open callback exists */ - if(NULL == id_wrapper1->vol_plugin->dataset_cls.open) { + if(NULL == vol_plugin->dataset_cls.open) { void *location = NULL; /* a pointer to VOL specific token that indicates the location of the object */ /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, req, &location, name, dapl_id) < 0) + if(H5VL_object_lookup (id, H5VL_OBJECT_LOOKUP_BY_NAME, req, &location, name, dapl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(loc_id, location, dapl_id, req)) < 0) + if((ret_value = H5VL_object_open_by_loc(id, location, dapl_id, req)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") if (NULL != location) { /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) + if(H5VL_object_free_loc (id, location, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") } } else { /* call the corresponding VOL open callback */ - if((dataset_id = (id_wrapper1->vol_plugin->dataset_cls.open) - (id_wrapper1->obj_id, name, dapl_id, req)) < 0) + if((ret_value = (vol_plugin->dataset_cls.open)(id, name, dapl_id, req)) < 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = dataset_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - if((ret_value = H5I_register(H5I_DATASET_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1216,26 +1006,22 @@ done: * *------------------------------------------------------------------------- */ -herr_t H5VL_dataset_read(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, +herr_t H5VL_dataset_read(hid_t id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->dataset_cls.read) + if(NULL == vol_plugin->dataset_cls.read) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset read' method") - if((ret_value = (id_wrapper->vol_plugin->dataset_cls.read) - (id_wrapper->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) + + if((ret_value = (vol_plugin->dataset_cls.read) + (id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "read failed") done: @@ -1257,26 +1043,22 @@ done: * *------------------------------------------------------------------------- */ -herr_t H5VL_dataset_write(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, +herr_t H5VL_dataset_write(hid_t id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->dataset_cls.write) + if(NULL == vol_plugin->dataset_cls.write) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset write' method") - if((ret_value = (id_wrapper->vol_plugin->dataset_cls.write) - (id_wrapper->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) + + if((ret_value = (vol_plugin->dataset_cls.write) + (id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") done: @@ -1298,24 +1080,20 @@ done: * *------------------------------------------------------------------------- */ -herr_t H5VL_dataset_set_extent(hid_t uid, const hsize_t size[], hid_t req) +herr_t H5VL_dataset_set_extent(hid_t id, const hsize_t size[], hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->dataset_cls.set_extent) + if(NULL == vol_plugin->dataset_cls.set_extent) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset set_extent' method") - if((ret_value = (id_wrapper->vol_plugin->dataset_cls.set_extent)(id_wrapper->obj_id, size, req)) < 0) + + if((ret_value = (vol_plugin->dataset_cls.set_extent)(id, size, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "set_extent failed") done: @@ -1338,49 +1116,37 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, hid_t req, ...) +H5VL_dataset_get(hid_t id, H5VL_dataset_get_t get_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ 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) - /* Check id */ - if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == id_wrapper->vol_plugin->dataset_cls.get) + if(NULL == vol_plugin->dataset_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset get' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->dataset_cls.get)(id_wrapper->obj_id, get_type, req, - arguments)) < 0) + if((ret_value = (vol_plugin->dataset_cls.get)(id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); /* if the get_type is a named datatype, create a wrapper for it */ if(H5VL_DATASET_GET_TYPE == get_type) { - H5VL_id_wrapper_t *temp_id_wrapper; /* user id structure */ - hid_t *ret_id; + hid_t *ret_id; va_start (arguments, req); ret_id = va_arg (arguments, hid_t *); - if(H5T_committed((H5T_t *)H5I_object_verify(*ret_id, H5I_DATATYPE))) { - /* Create a new id that points to a struct that holds the attr id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (temp_id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - temp_id_wrapper->obj_id = *ret_id; - temp_id_wrapper->vol_plugin = id_wrapper->vol_plugin; - - if((*ret_id = H5I_register(H5I_DATATYPE_PUBLIC, temp_id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attr handle") + 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") + vol_plugin->nrefs++; } va_end (arguments); } @@ -1405,34 +1171,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_close(hid_t uid, hid_t req) +H5VL_dataset_close(hid_t id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 the VOL class does not implement a specific dataset close callback, try the generic object close */ - if(NULL == id_wrapper->vol_plugin->dataset_cls.close){ - if(H5VL_object_close(uid, req) < 0) + if(NULL == vol_plugin->dataset_cls.close){ + if(H5VL_object_close(id, req) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object") } else { - if((ret_value = (id_wrapper->vol_plugin->dataset_cls.close)(id_wrapper->obj_id, req)) < 0) + if((ret_value = (vol_plugin->dataset_cls.close)(id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") - - id_wrapper->vol_plugin->nrefs--; - if(H5I_dec_app_ref(uid) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1444,8 +1201,7 @@ done: * * Purpose: Opens a file through the VOL. * - * Return: Success: User ID of the new file. This ID is of type - * H5I_FILE_PUBLIC which contains the VOL id and the actual file ID + * Return: Success: User ID of the new file. * * Failure: FAIL * @@ -1457,11 +1213,9 @@ done: hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req) { - H5VL_class_t *vol_plugin; /* VOL for file */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - H5P_genplist_t *plist; /* Property list pointer */ - hid_t file_id; - hid_t ret_value; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1475,19 +1229,14 @@ H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req) if(NULL == vol_plugin->file_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file open' method") /* call the corresponding VOL open callback */ - if((file_id = (vol_plugin->file_cls.open)(name, flags, fapl_id, req)) < 0) + if((ret_value = (vol_plugin->file_cls.open)(name, flags, fapl_id, req)) < 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper->obj_id = file_id; - id_wrapper->vol_plugin = vol_plugin; - vol_plugin->nrefs ++; + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; - if((ret_value = H5I_register(H5I_FILE_PUBLIC, id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_open() */ @@ -1498,8 +1247,7 @@ done: * * Purpose: Creates a file through the VOL * - * Return: Success: User ID of the new file. This ID is of type - * H5I_FILE_PUBLIC which contains the VOL id and the actual file ID + * Return: Success: User ID of the new file. * * Failure: FAIL * @@ -1511,10 +1259,8 @@ done: hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req) { - H5VL_class_t *vol_plugin; /* VOL for file */ - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - H5P_genplist_t *plist; /* Property list pointer */ - hid_t file_id; + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1529,19 +1275,13 @@ H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(NULL == vol_plugin->file_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file create' method") /* call the corresponding VOL create callback */ - if((file_id = (vol_plugin->file_cls.create)(name, flags, fcpl_id, fapl_id, req)) < 0) + if((ret_value = (vol_plugin->file_cls.create)(name, flags, fcpl_id, fapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") - /* Create a new id that points to a struct that holds the file id and the VOL id */ - /* Allocate new id structure */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper->obj_id = file_id; - id_wrapper->vol_plugin = vol_plugin; - vol_plugin->nrefs ++; - - if((ret_value = H5I_register(H5I_FILE_PUBLIC, id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1563,24 +1303,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_flush(hid_t uid, H5F_scope_t scope, hid_t req) +H5VL_file_flush(hid_t id, H5F_scope_t scope, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_FILE_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == id_wrapper->vol_plugin->file_cls.flush) + if(NULL == vol_plugin->file_cls.flush) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file flush' method") - if((ret_value = (id_wrapper->vol_plugin->file_cls.flush)(id_wrapper->obj_id, scope, req)) < 0) + if((ret_value = (vol_plugin->file_cls.flush)(id, scope, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTFLUSH, FAIL, "flush failed") done: @@ -1603,32 +1338,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, hid_t req, ...) +H5VL_file_get(hid_t id, H5VL_file_get_t get_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ - H5I_type_t id_type; /* Type of ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check/fix arguments. */ - if (H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATATYPE_PUBLIC != id_type && H5I_DATASET_PUBLIC != id_type && - H5I_ATTR_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->file_cls.get) + if(NULL == vol_plugin->file_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method") va_start(arguments, req); - if((ret_value = (id_wrapper->vol_plugin->file_cls.get)(id_wrapper->obj_id, get_type, req, - arguments)) < 0) + if((ret_value = (vol_plugin->file_cls.get)(id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end(arguments); @@ -1651,32 +1376,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_generic(hid_t uid, H5VL_file_generic_t generic_type, hid_t req, ...) +H5VL_file_generic(hid_t id, H5VL_file_generic_t generic_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ - H5I_type_t id_type; + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check id */ - if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && - H5I_FILE_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == id_wrapper->vol_plugin->file_cls.generic) + if(NULL == vol_plugin->file_cls.generic) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file generic' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->file_cls.generic)(id_wrapper->obj_id, generic_type, req, - arguments)) < 0) + if((ret_value = (vol_plugin->file_cls.generic)(id, generic_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "generic failed") va_end (arguments); @@ -1700,30 +1415,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_close(hid_t uid, hid_t req) +H5VL_file_close(hid_t id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_FILE_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->file_cls.close) + if(NULL == vol_plugin->file_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file close' method") - if((ret_value = (id_wrapper->vol_plugin->file_cls.close)(id_wrapper->obj_id, req)) < 0) + if((ret_value = (vol_plugin->file_cls.close)(id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed") - id_wrapper->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") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_close() */ @@ -1734,8 +1440,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 plugin and the actual group ID + * Return: Success: User ID of the new group. * * Failure: FAIL * @@ -1745,37 +1450,28 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_group_create(hid_t uid, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req) +H5VL_group_create(hid_t id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the group will be created */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new created group*/ - hid_t group_id; /* actual group ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the corresponding VOL create callback exists */ - if(NULL == id_wrapper1->vol_plugin->group_cls.create) + if(NULL == vol_plugin->group_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group create' method") /* call the corresponding VOL create callback */ - if((group_id = (id_wrapper1->vol_plugin->group_cls.create) - (id_wrapper1->obj_id, name, gcpl_id, gapl_id, req)) < 0) + if((ret_value = (vol_plugin->group_cls.create)(id, name, gcpl_id, gapl_id, req)) < 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = group_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - if((ret_value = H5I_register(H5I_GROUP_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1787,8 +1483,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 plugin and the actual group ID + * Return: Success: User ID of the new group. * * Failure: FAIL * @@ -1798,53 +1493,44 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_group_open(hid_t loc_id, const char *name, hid_t gapl_id, hid_t req) +H5VL_group_open(hid_t id, const char *name, hid_t gapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the group will be opend */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend group*/ - hid_t group_id; /* actual group ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the type specific corresponding VOL open callback exists */ - if(NULL == id_wrapper1->vol_plugin->group_cls.open) { + if(NULL == vol_plugin->group_cls.open) { void *location = NULL; /* a pointer to VOL specific token that indicates the location of the object */ /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, req, &location, name, gapl_id) < 0) + if(H5VL_object_lookup (id, H5VL_OBJECT_LOOKUP_BY_NAME, req, &location, name, gapl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(loc_id, location, gapl_id, req)) < 0) + if((ret_value = H5VL_object_open_by_loc(id, location, gapl_id, req)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") if (NULL != location) { /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) + if(H5VL_object_free_loc (id, location, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") } } else { /* call the corresponding VOL open callback */ - if((group_id = (id_wrapper1->vol_plugin->group_cls.open) - (id_wrapper1->obj_id, name, gapl_id, req)) < 0) + if((ret_value = (vol_plugin->group_cls.open)(id, name, gapl_id, req)) < 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = group_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - if((ret_value = H5I_register(H5I_GROUP_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1866,30 +1552,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, hid_t req, ...) +H5VL_group_get(hid_t id, H5VL_group_get_t get_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ - H5I_type_t id_type; /* Type of ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check/fix arguments. */ - if(H5I_GROUP_PUBLIC != id_type && H5I_FILE_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == id_wrapper->vol_plugin->group_cls.get) + if(NULL == vol_plugin->group_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->group_cls.get) - (id_wrapper->obj_id, get_type, req, arguments)) < 0) + if((ret_value = (vol_plugin->group_cls.get)(id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); @@ -1913,35 +1591,25 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_close(hid_t uid, hid_t req) +H5VL_group_close(hid_t id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_GROUP_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 the VOL class does not implement a specific group close callback, try the generic object close */ - if(NULL == id_wrapper->vol_plugin->group_cls.close) { - if(H5VL_object_close(uid, req) < 0) + if(NULL == vol_plugin->group_cls.close) { + if(H5VL_object_close(id, req) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object") } else { - if((ret_value = (id_wrapper->vol_plugin->group_cls.close)(id_wrapper->obj_id, req)) < 0) + if((ret_value = (vol_plugin->group_cls.close)(id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") - - id_wrapper->vol_plugin->nrefs--; - - if(H5I_dec_app_ref(uid) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1961,17 +1629,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const char *new_name, +H5VL_link_create(H5VL_link_create_type_t create_type, hid_t id, const char *new_name, hid_t lcpl_id, hid_t lapl_id, hid_t req) { - H5VL_class_t *vol_plugin = NULL; /* VOL plugin */ - hid_t new_id; /* unwrapped IDs */ + H5VL_class_t *vol_plugin = NULL; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* unwrap the target high level ID if the creation call is H5Lcreate_hard */ - if(H5VL_LINK_CREATE_HARD == create_type) { + /* get VOL plugin */ + if(H5L_SAME_LOC != id) { + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + } + else if(H5VL_LINK_CREATE_HARD == create_type && NULL == vol_plugin) { H5P_genplist_t *plist; /* Property list pointer */ hid_t cur_id; @@ -1982,38 +1653,11 @@ H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const char * if(H5P_get(plist, H5L_CRT_TARGET_ID_NAME, &cur_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") - /* Only one of the IDs can be H5L_SAME_LOC, and the other one must - be of the wrapper type. Get the VOL plugin struct in case the - link id is H5L_SAME_LOC*/ - if (H5L_SAME_LOC != cur_id && H5I_DATATYPE != H5I_get_type(cur_id)) { - H5VL_id_wrapper_t *id_wrapper; - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(cur_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - vol_plugin = id_wrapper->vol_plugin; - if(H5P_set(plist, H5L_CRT_TARGET_ID_NAME, &(id_wrapper->obj_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") - } - } - - /* unwrap the higher level user ids. */ - if(H5L_SAME_LOC != loc_id && H5I_DATATYPE != H5I_get_type(loc_id)) { - H5VL_id_wrapper_t *id_wrapper; - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - /* set the vol plugin sturcture if it hasn't been done yet */ - if (NULL == vol_plugin) - vol_plugin = id_wrapper->vol_plugin; - - new_id = id_wrapper->obj_id; + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(cur_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") } else { - new_id = loc_id; + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") } /* check if the corresponding VOL create callback exists */ @@ -2022,7 +1666,7 @@ H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const char * /* call the corresponding VOL create callback */ if((ret_value = (vol_plugin->link_cls.create) - (create_type, new_id, new_name, lcpl_id, lapl_id, req)) < 0) + (create_type, id, new_name, lcpl_id, lapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link create failed") done: @@ -2047,35 +1691,21 @@ H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_l hid_t lcpl_id, hid_t lapl_id, hid_t req) { H5VL_class_t *vol_plugin = NULL; /* VOL plugin */ - H5VL_id_wrapper_t *id_wrapper; - hid_t new_src_id, new_dst_id; /* unwrapped IDs */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* unwrap the higher level user ids. */ if(H5L_SAME_LOC != src_loc_id) { - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(src_loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - vol_plugin = id_wrapper->vol_plugin; - new_src_id = id_wrapper->obj_id; + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") } - else { - new_src_id = src_loc_id; - } - - if(H5L_SAME_LOC != dst_loc_id) { - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(dst_loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == vol_plugin) - vol_plugin = id_wrapper->vol_plugin; - new_dst_id = id_wrapper->obj_id; + else if(H5L_SAME_LOC != dst_loc_id) { + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") } else { - new_dst_id = dst_loc_id; + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") } /* check if the corresponding VOL move callback exists */ @@ -2084,7 +1714,7 @@ H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_l /* call the corresponding VOL move callback */ if((ret_value = (vol_plugin->link_cls.move) - (new_src_id, src_name, new_dst_id, dst_name, copy_flag, lcpl_id, lapl_id, req)) < 0) + (src_loc_id, src_name, dst_loc_id, dst_name, copy_flag, lcpl_id, lapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link move failed") done: @@ -2107,24 +1737,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_link_get(hid_t uid, H5VL_link_get_t get_type, hid_t req, ...) +H5VL_link_get(hid_t id, H5VL_link_get_t get_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ 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) - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->link_cls.get) + if(NULL == vol_plugin->link_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link get' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->link_cls.get) - (id_wrapper->obj_id, get_type, req, arguments)) < 0) + if((ret_value = (vol_plugin->link_cls.get)(id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); @@ -2145,23 +1773,22 @@ done: * *------------------------------------------------------------------------- */ -H5_DLL herr_t H5VL_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req) +H5_DLL herr_t H5VL_link_remove(hid_t id, const char *name, void *udata, hid_t lapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the corresponding VOL remove callback exists */ - if(NULL == id_wrapper->vol_plugin->link_cls.remove) + if(NULL == vol_plugin->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 = (id_wrapper->vol_plugin->link_cls.remove) - (id_wrapper->obj_id, name, udata, lapl_id, req)) < 0) + if((ret_value = (vol_plugin->link_cls.remove)(id, name, udata, lapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link remove failed") done: @@ -2174,8 +1801,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 plugin and the actual object ID + * Return: Success: User ID of the new object. * * Failure: FAIL * @@ -2185,53 +1811,28 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_object_open_by_loc(hid_t uid, void *obj_loc, hid_t lapl_id, hid_t req) +H5VL_object_open_by_loc(hid_t id, void *obj_loc, hid_t lapl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the object will be opend */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend object*/ - H5I_type_t id_type; - hid_t object_id; /* actual object ID */ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - /* get the ID struct */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* check if the corresponding VOL open callback exists */ - if(NULL == id_wrapper1->vol_plugin->object_cls.open) + if(NULL == vol_plugin->object_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object open' method") /* call the corresponding VOL open callback */ - if((object_id = (id_wrapper1->vol_plugin->object_cls.open) - (id_wrapper1->obj_id, obj_loc, lapl_id, req)) < 0) + if((ret_value = (vol_plugin->object_cls.open)(id, obj_loc, lapl_id, req)) < 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 plugin */ - /* Allocate new id structure */ - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - id_wrapper2->obj_id = object_id; - id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - - id_type = H5I_get_type(object_id); - - if (H5I_GROUP == id_type) { - if((ret_value = H5I_register(H5I_GROUP_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") - } - else if (H5I_DATATYPE == id_type) { - if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") - } - else if (H5I_DATASET == id_type) { - if((ret_value = H5I_register(H5I_DATASET_PUBLIC, id_wrapper2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") - } - else { - ret_value = object_id; - } + /* attach VOL information to the ID */ + if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -2255,25 +1856,25 @@ herr_t H5VL_object_copy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the object will be opend */ - H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend object*/ + H5VL_class_t *vol_plugin1; /* VOL structure attached to src id */ + H5VL_class_t *vol_plugin2; /* VOL structure attached to dest id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* unwrap the IDs and return an error if they belong to different VOL plugins */ - if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(src_loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5I_object(dst_loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (NULL == (vol_plugin1 = (H5VL_class_t *)H5I_get_aux(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + if (NULL == (vol_plugin2 = (H5VL_class_t *)H5I_get_aux(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - if (id_wrapper1->vol_plugin != id_wrapper2->vol_plugin) + /* check if both objects are associated with the same VOL plugin */ + if (vol_plugin1 != vol_plugin2) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be copied") - if(NULL == id_wrapper1->vol_plugin->object_cls.copy) + if(NULL == vol_plugin1->object_cls.copy) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object copy' method") - if((ret_value = (id_wrapper1->vol_plugin->object_cls.copy) - (id_wrapper1->obj_id, src_name, id_wrapper2->obj_id, dst_name, ocpypl_id, lcpl_id, req)) < 0) + if((ret_value = (vol_plugin1->object_cls.copy) + (src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "copy failed") done: @@ -2296,32 +1897,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, hid_t req, ...) +H5VL_object_lookup(hid_t id, H5VL_object_lookup_t lookup_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ - H5I_type_t id_type; + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check id */ - if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && - H5I_ATTR_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* lookup the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->object_cls.lookup) + if(NULL == vol_plugin->object_cls.lookup) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object lookup' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->object_cls.lookup)(id_wrapper->obj_id, lookup_type, req, - arguments)) < 0) + if((ret_value = (vol_plugin->object_cls.lookup)(id, lookup_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "lookup of object location failed") va_end (arguments); done: @@ -2343,29 +1934,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_free_loc(hid_t loc_id, void *location, hid_t req) +H5VL_object_free_loc(hid_t id, void *location, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - H5I_type_t id_type; + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(loc_id); - /* Check id */ - if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && - H5I_ATTR_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* unwrap the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->object_cls.free_loc) + 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 = (id_wrapper->vol_plugin->object_cls.free_loc)(location, req)) < 0) + if((ret_value = (vol_plugin->object_cls.free_loc)(location, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "freeing location token of object location failed") done: @@ -2388,32 +1970,22 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, hid_t req, ...) +H5VL_object_get(hid_t id, H5VL_object_get_t get_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ - H5I_type_t id_type; + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check id */ - if(H5I_GROUP_PUBLIC != id_type && H5I_DATASET_PUBLIC != id_type && - H5I_DATATYPE_PUBLIC != id_type && H5I_FILE_PUBLIC != id_type && - H5I_ATTR_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == id_wrapper->vol_plugin->object_cls.get) + if(NULL == vol_plugin->object_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->object_cls.get)(id_wrapper->obj_id, get_type, req, - arguments)) < 0) + if((ret_value = (vol_plugin->object_cls.get)(id, get_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); done: @@ -2435,51 +2007,36 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_generic(hid_t uid, H5VL_object_generic_t generic_type, hid_t req, ...) +H5VL_object_generic(hid_t id, H5VL_object_generic_t generic_type, hid_t req, ...) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ - H5I_type_t id_type; + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - /* Check id */ - if(H5I_FILE_PUBLIC != id_type && H5I_GROUP_PUBLIC != id_type && - H5I_DATASET_PUBLIC != id_type && H5I_DATATYPE_PUBLIC != id_type && - H5I_ATTR_PUBLIC != id_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + 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 == id_wrapper->vol_plugin->object_cls.generic) + if(NULL == vol_plugin->object_cls.generic) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object generic' method") va_start (arguments, req); - if((ret_value = (id_wrapper->vol_plugin->object_cls.generic)(id_wrapper->obj_id, generic_type, req, - arguments)) < 0) + if((ret_value = (vol_plugin->object_cls.generic)(id, generic_type, req, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "generic failed") va_end (arguments); if(H5VL_ATTR_OPEN_BY_IDX == generic_type) { - H5VL_id_wrapper_t *temp_id_wrapper; /* user id structure */ hid_t *ret_id; va_start (arguments, req); ret_id = va_arg (arguments, hid_t *); - /* Create a new id that points to a struct that holds the attr id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (temp_id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - temp_id_wrapper->obj_id = *ret_id; - temp_id_wrapper->vol_plugin = id_wrapper->vol_plugin; + /* 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") + vol_plugin->nrefs++; - if((*ret_id = H5I_register(H5I_ATTR_PUBLIC, temp_id_wrapper, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attr handle") va_end (arguments); } done: @@ -2502,46 +2059,21 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_close(hid_t uid, hid_t req) +H5VL_object_close(hid_t id, hid_t req) { - H5VL_id_wrapper_t *id_wrapper; /* user id structure */ - H5I_type_t id_type; + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - id_type = H5I_get_type(uid); - - /* In case of a named datatype being closed with H5Oopen after an - H5Tcommit, the id is still of type H5I_DATATYPE and not - H5I_DATATYPE_PUBLIC. In that case we just fall back to the - native implementation */ - if(H5I_DATATYPE == id_type) { - if(H5I_object(uid) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") - if(H5I_dec_app_ref(uid) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") - HGOTO_DONE(ret_value) - } - - /* Check id */ - if(H5I_GROUP_PUBLIC != H5I_get_type(uid) && H5I_DATASET_PUBLIC != H5I_get_type(uid) && - H5I_DATATYPE_PUBLIC != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") - /* get the ID struct */ - if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - - if(NULL == id_wrapper->vol_plugin->object_cls.close) + if(NULL == vol_plugin->object_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object close' method") - if((ret_value = (id_wrapper->vol_plugin->object_cls.close)(id_wrapper->obj_id, req)) < 0) + if((ret_value = (vol_plugin->object_cls.close)(id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") - id_wrapper->vol_plugin->nrefs--; - if(H5I_dec_app_ref(uid) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_close() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 77c8679..3e942b1 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -717,9 +717,29 @@ H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Commit the type */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + if (NULL != name) { /* H5Tcommit */ + /* Commit the type */ + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + } + else { /* H5Tcommit_anon */ + /* Commit the type */ + if(H5T__commit(loc.oloc->file, type, tcpl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + + /* Release the datatype's object header */ + { + H5O_loc_t *oloc; /* Object location for datatype */ + + /* Get the new committed datatype's object location */ + if(NULL == (oloc = H5T_oloc(type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype") + + /* Decrement refcount on committed datatype's object header in memory */ + if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + } /* end if */ + } done: @@ -1821,12 +1841,11 @@ H5VL_native_file_close(hid_t file_id, hid_t UNUSED req) if(H5F_flush(f, H5AC_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ - /* * Decrement reference count on atom. When it reaches zero the file will * be closed. */ - if(H5I_dec_ref(f->file_id) < 0) + if(H5I_dec_app_ref(f->file_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") done: diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 6f0897d..44a20a4 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -31,12 +31,6 @@ /****************************/ #define H5_REQUEST_NULL -1 -/* type of the ID passed to users */ -typedef struct H5VL_id_wrapper_t { - hid_t obj_id; /* actual id for object */ - H5VL_class_t *vol_plugin; /* pointer to the VOL structure */ -} H5VL_id_wrapper_t; - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -53,9 +47,7 @@ H5_DLL int H5VL_term_interface(void); 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 herr_t H5VL_close(H5VL_class_t *vol_plugin); H5_DLL hid_t H5VL_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req); H5_DLL hid_t H5VL_attr_open(hid_t loc_id, void *location, const char *name, hid_t aapl_id, hid_t req); diff --git a/test/dtypes.c b/test/dtypes.c index 88fcc51..23a7bac 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -2987,11 +2987,6 @@ test_compound_16(void) if((int_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR if(H5Tcommit2(file, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* MSC - workaround datatypes */ - if(H5Tclose(int_id) < 0) goto error; - if((int_id = H5Topen2(file, "int", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - /* Create file compound datatype */ if((cmpd_f_tid = H5Tcreate(H5T_COMPOUND, 2 * sizeof(int) + 2)) < 0) TEST_ERROR if(H5Tinsert(cmpd_f_tid, "i1", (size_t)0, int_id) < 0) TEST_ERROR @@ -3739,11 +3734,6 @@ test_named (hid_t fapl) goto error; } - /* MSC - workaround datatypes */ - if(H5Tclose(type) < 0) goto error; - if((type = H5Topen2(file, "native-int", H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - /* It should be possible to define an attribute for the named type */ if((attr1 = H5Acreate2(type, "attr1", H5T_NATIVE_UCHAR, space, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; diff --git a/test/links.c b/test/links.c index 6d69fea..329b9a2 100644 --- a/test/links.c +++ b/test/links.c @@ -7380,17 +7380,17 @@ done: /* Close the target object if we opened it */ if(target_obj >= 0) { switch(H5Iget_type(target_obj)) { - case H5I_GROUP_PUBLIC: + case H5I_GROUP: if(H5Gclose(target_obj) < 0) ret_value = -1; break; - case H5I_DATASET_PUBLIC: + case H5I_DATASET: if(H5Dclose(target_obj) < 0) ret_value = -1; break; - case H5I_DATATYPE_PUBLIC: + case H5I_DATATYPE: if(H5Tclose(target_obj) < 0) ret_value = -1; break; @@ -7467,17 +7467,17 @@ done: /* Close the target object if we opened it */ if(target_obj >= 0) { switch(H5Iget_type(target_obj)) { - case H5I_GROUP_PUBLIC: + case H5I_GROUP: if(H5Gclose(target_obj) < 0) ret_value = -1; break; - case H5I_DATASET_PUBLIC: + case H5I_DATASET: if(H5Dclose(target_obj) < 0) ret_value = -1; break; - case H5I_DATATYPE_PUBLIC: + case H5I_DATATYPE: if(H5Tclose(target_obj) < 0) ret_value = -1; break; diff --git a/test/objcopy.c b/test/objcopy.c index 53ccebd..ce0f3d3 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -1850,11 +1850,6 @@ test_copy_named_datatype_attr_self(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* create named datatype */ if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround named datatypes */ - if(H5Tclose(tid) < 0) goto error; - if((tid = H5Topen2(fid_src, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR - /* create dataspace */ if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR @@ -9634,10 +9629,6 @@ test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds if((tid3 = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR if((H5Tcommit2(fid_src, SRC_NDT_INT, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround committed datatypes */ - if(H5Tclose(tid3) < 0) TEST_ERROR - if((tid3 = H5Topen2(fid_src, SRC_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR - /* set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -9657,10 +9648,6 @@ test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds if((tid5 = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR if((H5Tcommit_anon(fid_src, tid5, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround committed datatypes */ - if(H5Tclose(tid4) < 0) TEST_ERROR - if((tid4 = H5Topen2(fid_src, SRC_NDT_DOUBLE, H5P_DEFAULT)) < 0) TEST_ERROR - /* create an attribute of anon ndt (short); attach to committed datatype (double) */ if((aid = H5Acreate2(tid4, SRC_ATTR, tid5, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -9689,10 +9676,6 @@ test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds if((tid2 = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) TEST_ERROR if((H5Tcommit2(fid_dst, DST_NDT_FLOAT, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround committed datatypes */ - if(H5Tclose(tid2) < 0) TEST_ERROR - if((tid2 = H5Topen2(fid_dst, DST_NDT_FLOAT, H5P_DEFAULT)) < 0) TEST_ERROR - /* create an attribute of native integer; attach to committed datatype (float) */ if((aid = H5Acreate2(tid2, DST_ATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -9706,10 +9689,6 @@ test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds if((tid4 = H5Tcopy(H5T_NATIVE_SHORT)) < 0) TEST_ERROR if((H5Tcommit_anon(fid_dst, tid4, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround committed datatypes */ - if(H5Tclose(tid3) < 0) TEST_ERROR - if((tid3 = H5Topen2(fid_dst, DST_NDT_DOUBLE, H5P_DEFAULT)) < 0) TEST_ERROR - /* create an attribute of anon ndt (short); attach to ndt (double) */ if((aid = H5Acreate2(tid3, DST_ATTR, tid4, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -10468,10 +10447,6 @@ test_copy_cdt_merge_all_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)TEST_ERROR if((H5Tcommit2(fid_dst, DST_NDT_INT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround committed datatypes */ - if(H5Tclose(tid) < 0) TEST_ERROR - if((tid = H5Topen2(fid_dst, DST_NDT_INT, H5P_DEFAULT)) < 0) TEST_ERROR - /* create an attribute attached to committed datatype */ if((aid = H5Acreate2(tid, DST_ATTR, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -10485,10 +10460,6 @@ test_copy_cdt_merge_all_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if((tid = H5Tcopy(H5T_NATIVE_FLOAT)) < 0)TEST_ERROR if((H5Tcommit2(fid_dst, DST_NDT_FLOAT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround committed datatypes */ - if(H5Tclose(tid) < 0) TEST_ERROR - if((tid = H5Topen2(fid_dst, DST_NDT_FLOAT, H5P_DEFAULT)) < 0) TEST_ERROR - /* create an attribute attached to committed datatype */ if((aid = H5Acreate2(tid, DST_ATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -10545,10 +10516,6 @@ test_copy_cdt_merge_all_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if((tid = H5Tcopy(H5T_NATIVE_DOUBLE)) < 0)TEST_ERROR if((H5Tcommit2(fid_dst, DST_NDT_DOUBLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* MSC - workaround committed datatypes */ - if(H5Tclose(tid) < 0) TEST_ERROR - if((tid = H5Topen2(fid_dst, DST_NDT_DOUBLE, H5P_DEFAULT)) < 0) TEST_ERROR - /* get datatype */ if((tid_short = H5Topen2(fid_dst, "/" DST_GRP2 "/" DST_NDT_SHORT, H5P_DEFAULT)) < 0) TEST_ERROR diff --git a/test/tattr.c b/test/tattr.c index ee6707f..6556e09 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -9832,12 +9832,6 @@ test_attr_bug3(hid_t fcpl, hid_t fapl) did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate2"); - /* MSC - workaround committed datatypes */ - ret = H5Tclose(tid1); - CHECK(ret, FAIL, "H5Tclose"); - tid1 = H5Topen2(fid, "dtype", H5P_DEFAULT); - CHECK(tid1, FAIL, "H5Topen2"); - /* Create attribute on datatype, using that datatype as its datatype */ aid1 = H5Acreate2(tid1, "attr", tid1, sid1, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid1, FAIL, "H5Acreate2"); @@ -9979,12 +9973,6 @@ test_attr_bug4(hid_t fcpl, hid_t fapl) aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid2, FAIL, "H5Acreate2"); - /* MSC - workaround committed datatypes */ - ret = H5Tclose(tid); - CHECK(ret, FAIL, "H5Tclose"); - tid = H5Topen2(fid, "dtype", H5P_DEFAULT); - CHECK(tid, FAIL, "H5Topen2"); - /* Create attribute on datatype (this is the main test) */ aid3 = H5Acreate2(tid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid3, FAIL, "H5Acreate2"); @@ -10069,11 +10057,6 @@ test_attr_bug5(hid_t fcpl, hid_t fapl) aidd1 = H5Acreate2(did1, BUG3_ATTR_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aidd1, FAIL, "H5Acreate2"); - /* MSC - workaround committed datatypes */ - ret = H5Tclose(tid1); - CHECK(ret, FAIL, "H5Tclose"); - tid1 = H5Topen2(fid1, BUG3_DT_NAME, H5P_DEFAULT); - CHECK(tid1, FAIL, "H5Topen2"); /* Create attribute on datatype */ aidt1 = H5Acreate2(tid1, BUG3_ATTR_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aidt1, FAIL, "H5Acreate2"); @@ -10278,11 +10261,7 @@ test_attr_bug7(hid_t fcpl, hid_t fapl) */ sid = H5Screate_simple(1, &dims_s, NULL); CHECK(sid, FAIL, "H5Screate_simple"); - /* MSC - workaround committed datatypes */ - ret = H5Tclose(tid); - CHECK(ret, FAIL, "H5Tclose"); - tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT); - CHECK(tid, FAIL, "H5Topen2"); + aid = H5Acreate2(tid, ATTR1_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate2"); diff --git a/test/tfile.c b/test/tfile.c index 773ff1d..1cfcdbd 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1166,19 +1166,19 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, id_type = H5Iget_type(oid_list[i]); switch(id_type) { - case H5I_FILE_PUBLIC: + case H5I_FILE: if(oid_list[i] != fid1 && oid_list[i] != fid2 && oid_list[i] != fid3 && oid_list[i] != fid4) ERROR("H5Fget_obj_ids"); break; - case H5I_GROUP_PUBLIC: + case H5I_GROUP: if(oid_list[i] != gid1 && oid_list[i] != gid2 && oid_list[i] != gid3) ERROR("H5Fget_obj_ids"); break; - case H5I_DATASET_PUBLIC: + case H5I_DATASET: VERIFY(oid_list[i], did, "H5Fget_obj_ids"); break; diff --git a/test/th5o.c b/test/th5o.c index f504690..7dc21b1 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -93,11 +93,11 @@ test_h5o_open(void) /* Make sure that each is the right kind of ID */ id_type = H5Iget_type(grp); - VERIFY(id_type, H5I_GROUP_PUBLIC, "H5Iget_type for group ID"); + VERIFY(id_type, H5I_GROUP, "H5Iget_type for group ID"); id_type = H5Iget_type(dtype); - VERIFY(id_type, H5I_DATATYPE_PUBLIC, "H5Iget_type for datatype ID"); + VERIFY(id_type, H5I_DATATYPE, "H5Iget_type for datatype ID"); id_type = H5Iget_type(dset); - VERIFY(id_type, H5I_DATASET_PUBLIC, "H5Iget_type for dataset ID"); + VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID"); /* Do something more complex with each of the IDs to make sure they "work" */ ret = H5Gget_info(grp, &ginfo); @@ -162,7 +162,7 @@ test_h5o_close(void) /* Create the group and close it with H5Oclose */ grp = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(grp, FAIL, "H5Gcreate2"); - VERIFY(H5Iget_type(grp), H5I_GROUP_PUBLIC, "H5Iget_type"); + VERIFY(H5Iget_type(grp), H5I_GROUP, "H5Iget_type"); ret = H5Oclose(grp); CHECK(ret, FAIL, "H5Oclose"); @@ -306,11 +306,11 @@ test_h5o_open_by_addr(void) /* Make sure that each is the right kind of ID */ id_type = H5Iget_type(grp); - VERIFY(id_type, H5I_GROUP_PUBLIC, "H5Iget_type for group ID"); + VERIFY(id_type, H5I_GROUP, "H5Iget_type for group ID"); id_type = H5Iget_type(dtype); - VERIFY(id_type, H5I_DATATYPE_PUBLIC, "H5Iget_type for datatype ID"); + VERIFY(id_type, H5I_DATATYPE, "H5Iget_type for datatype ID"); id_type = H5Iget_type(dset); - VERIFY(id_type, H5I_DATASET_PUBLIC, "H5Iget_type for dataset ID"); + VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID"); /* Do something more complex with each of the IDs to make sure they "work" */ ret = H5Gget_info(grp, &ginfo); @@ -395,12 +395,6 @@ test_h5o_refcount(void) ret = H5Tcommit2(fid, "datatype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); - /* MSC - workaround committed datatypes */ - ret = H5Tclose(dtype); - CHECK(ret, FAIL, "H5Tclose"); - dtype = H5Topen2(fid, "datatype", H5P_DEFAULT); - CHECK(dtype, FAIL, "H5Topen2"); - /* Create the data space for the dataset. */ dims[0] = DIM0; dims[1] = DIM1; @@ -966,12 +960,6 @@ test_h5o_comment(void) ret = H5Tcommit2(fid, "group/datatype", dtype, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit2"); - /* MSC - workaround committed datatypes */ - ret = H5Tclose(dtype); - CHECK(ret, FAIL, "H5Tclose"); - dtype = H5Topen2(fid, "group/datatype", H5P_DEFAULT); - CHECK(dtype, FAIL, "H5Topen2"); - /* Putting a comment on the committed data type */ ret = H5Oset_comment(dtype, dtype_comment); CHECK(ret, FAIL, "H5Oset_comment"); -- cgit v0.12