From 767282f68a4881dcec14ad61268d1a167a470d5b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 3 Oct 2024 14:19:33 -0500 Subject: [PATCH] VOL refactor and cleanup (#4856) Cleanup and prepare for thread-safety changes. Big ideas: * Wrap H5VL_class_t with H5VL_connector_t, so use of the class can be refcounted within the H5VL package, instead of relying on storing an ID within the H5VL_t struct and incrementing & decrementing the ID's refcount. * Register H5VL_connector_t* for VOL connector IDs, instead of the H5VL_class_t* * Stop other packages from rummaging around inside H5VL_connector_t and H5VL_object_t data structures, so that the H5VL package can change implementation details without coupled changes throughout the library Small things: * Simplified the coding for creating links * Moved some routines into more logical locations --- doxygen/dox/VOLConnGuide.dox | 56 -- fortran/src/H5VLff.F90 | 35 + fortran/src/hdf5_fortrandll.def.in | 1 + fortran/test/vol_connector.F90 | 17 +- java/src/hdf/hdf5lib/H5.java | 18 + java/src/jni/h5vlImp.c | 24 + java/src/jni/h5vlImp.h | 7 + java/test/TestH5VL.java | 9 +- release_docs/RELEASE.txt | 65 +- src/CMakeLists.txt | 2 + src/H5A.c | 40 +- src/H5Adeprec.c | 6 +- src/H5CX.c | 33 +- src/H5D.c | 84 +- src/H5Ddeprec.c | 4 +- src/H5Dint.c | 6 +- src/H5Dvirtual.c | 2 +- src/H5ES.c | 18 +- src/H5ESevent.c | 2 +- src/H5ESint.c | 20 +- src/H5ESpkg.h | 4 +- src/H5ESprivate.h | 4 +- src/H5F.c | 60 +- src/H5Fint.c | 57 +- src/H5Fpkg.h | 5 +- src/H5Fprivate.h | 9 +- src/H5Fquery.c | 20 - src/H5G.c | 30 +- src/H5Gdeprec.c | 16 +- src/H5Gloc.c | 2 +- src/H5Idbg.c | 11 +- src/H5L.c | 132 ++- src/H5M.c | 28 +- src/H5O.c | 52 +- src/H5Odeprec.c | 2 +- src/H5Oflush.c | 23 +- src/H5Oprivate.h | 4 +- src/H5Pfapl.c | 103 +-- src/H5Pprivate.h | 3 +- src/H5R.c | 14 +- src/H5Rdeprec.c | 4 +- src/H5Rint.c | 6 +- src/H5T.c | 16 +- src/H5Tcommit.c | 22 +- src/H5Tdeprec.c | 4 +- src/H5VL.c | 214 ++--- src/H5VLcallback.c | 1077 ++++++++++++------------ src/H5VLconnector.h | 8 - src/H5VLint.c | 1242 +++++++++++++--------------- src/H5VLnative.c | 60 +- src/H5VLnative.h | 19 +- src/H5VLnative_private.h | 18 +- src/H5VLpassthru.c | 29 +- src/H5VLpassthru.h | 13 +- src/H5VLpassthru_int.c | 97 +++ src/H5VLpassthru_private.h | 48 ++ src/H5VLpkg.h | 60 +- src/H5VLprivate.h | 98 ++- src/H5VLquery.c | 149 ++++ src/H5VLtest.c | 66 ++ src/H5private.h | 4 +- src/Makefile.am | 3 +- test/event_set.c | 99 ++- test/testfiles/err_compat_1 | 45 +- test/tmisc.c | 12 +- test/ttsafe_error.c | 9 +- test/vol.c | 12 +- test/vol_plugin.c | 11 +- tools/lib/h5tools.c | 12 +- 69 files changed, 2405 insertions(+), 2080 deletions(-) create mode 100644 src/H5VLpassthru_int.c create mode 100644 src/H5VLpassthru_private.h create mode 100644 src/H5VLquery.c diff --git a/doxygen/dox/VOLConnGuide.dox b/doxygen/dox/VOLConnGuide.dox index c693980be1a..9781261e58c 100644 --- a/doxygen/dox/VOLConnGuide.dox +++ b/doxygen/dox/VOLConnGuide.dox @@ -4110,62 +4110,6 @@ Retrieves a pointer to the VOL object from an HDF5 file or object identifier. Returns a copy of the dtype_id parameter but with the location set to be in the file. Returns a negative value (#H5I_INVALID_HID) on errors. -\subsubsection subsubsecVOLNewConnpeek_name H5VLpeek_connector_id_by_name - - - - - - - - - - - - - -
Signature:
-\code - hid_t H5VLpeek_connector_id_by_name(const char *name); -\endcode -
Arguments:
-\code - name (IN): name of the connector to query. -\endcode -
-Retrieves the ID for a registered VOL connector based on a connector name. This is done without duplicating -the ID and transferring ownership to the caller (as it normally the case in the HDF5 library). The ID returned -from this operation should not be closed. This is intended for use by VOL connectors to find their own ID. -Returns a negative value (#H5I_INVALID_HID) on errors. - -\subsubsection subsubsecVOLNewConnpeek_value H5VLpeek_connector_id_by_value - - - - - - - - - - - - - -
Signature:
-\code - hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); -\endcode -
Arguments:
-\code - value (IN): value of the connector to query. -\endcode -
-Retrieves the ID for a registered VOL connector based on a connector value. This is done without duplicating -the ID and transferring ownership to the caller (as it normally the case in the HDF5 library). The ID returned -from this operation should not be closed. This is intended for use by VOL connectors to find their own ID. -Returns a negative value (#H5I_INVALID_HID) on errors. - \subsection subsecVOLNewPass H5VLconnector_passthru.h This functionality is intended for VOL connector authors who are writing pass-through connectors and includes helper functions that are useful for writing such connectors. Callback equivalent functions can be diff --git a/fortran/src/H5VLff.F90 b/fortran/src/H5VLff.F90 index 66d098bfab6..b07e1389f21 100644 --- a/fortran/src/H5VLff.F90 +++ b/fortran/src/H5VLff.F90 @@ -401,6 +401,41 @@ END FUNCTION H5VLunregister_connector END SUBROUTINE H5VLunregister_connector_f +!> +!! \ingroup FH5VL +!! +!! \brief Determines whether two connector identifiers refer to the same connector. +!! +!! \param conn_id1 A valid identifier of the first connector to check +!! \param conn_id2 A valid identifier of the second connector to check +!! \param are_same Whether connector IDs refer to the same connector +!! \param hdferr \fortran_error +!! +!! See C API: @ref H5VLcmp_connector_cls() +!! + SUBROUTINE H5VLcmp_connector_cls_f(are_same, conn_id1, conn_id2, hdferr) + IMPLICIT NONE + LOGICAL, INTENT(OUT) :: are_same + INTEGER(HID_T), INTENT(IN) :: conn_id1 + INTEGER(HID_T), INTENT(IN) :: conn_id2 + INTEGER, INTENT(OUT) :: hdferr + INTEGER :: are_same_c + + INTERFACE + INTEGER(C_INT) FUNCTION H5VLcmp_connector_cls(cmp_value, conn_id1, conn_id2) BIND(C, NAME='H5VLcmp_connector_cls') + IMPORT :: HID_T, C_INT + INTEGER(C_INT), INTENT(OUT) :: cmp_value + INTEGER(HID_T), VALUE :: conn_id1 + INTEGER(HID_T), VALUE :: conn_id2 + END FUNCTION H5VLcmp_connector_cls + END INTERFACE + + are_same = .FALSE. + hdferr = INT(H5VLcmp_connector_cls(are_same_c, conn_id1, conn_id2)) + IF(are_same_c .EQ. 0) are_same = .TRUE. + + END SUBROUTINE H5VLcmp_connector_cls_f + !> !! \ingroup FH5VL !! diff --git a/fortran/src/hdf5_fortrandll.def.in b/fortran/src/hdf5_fortrandll.def.in index ae5465f73a2..5bc4a274c42 100644 --- a/fortran/src/hdf5_fortrandll.def.in +++ b/fortran/src/hdf5_fortrandll.def.in @@ -593,6 +593,7 @@ H5VL_mp_H5VLGET_CONNECTOR_ID_BY_NAME_F H5VL_mp_H5VLGET_CONNECTOR_ID_BY_VALUE_F H5VL_mp_H5VLGET_CONNECTOR_NAME_F H5VL_mp_H5VLCLOSE_F +H5VL_mp_H5VLCMP_CONNECTOR_CLS_F H5VL_mp_H5VLUNREGISTER_CONNECTOR_F H5VL_mp_H5VLNATIVE_ADDR_TO_TOKEN_F H5VL_mp_H5VLNATIVE_TOKEN_TO_ADDR_F diff --git a/fortran/test/vol_connector.F90 b/fortran/test/vol_connector.F90 index 7394a31d6af..44446ddf361 100644 --- a/fortran/test/vol_connector.F90 +++ b/fortran/test/vol_connector.F90 @@ -160,6 +160,7 @@ SUBROUTINE test_registration_by_fapl(total_error) INTEGER(hid_t) :: file_id INTEGER(hid_t) :: fapl_id TYPE(C_PTR) :: f_ptr + LOGICAL :: are_same = .FALSE. CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error) @@ -189,7 +190,9 @@ SUBROUTINE test_registration_by_fapl(total_error) CALL H5Pget_vol_id_f(fapl_id, vol_id_out, error) CALL check("H5Pget_vol_id_f",error,total_error) - CALL VERIFY("H5Pget_vol_id_f", vol_id_out, vol_id, total_error) + CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error) + CALL check("H5VLcmp_connector_cls_f",error,total_error) + CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error) f_ptr = C_NULL_PTR CALL H5Pset_vol_f(fapl_id, vol_id, error, f_ptr) @@ -197,14 +200,20 @@ SUBROUTINE test_registration_by_fapl(total_error) CALL H5Pget_vol_id_f(fapl_id, vol_id_out, error) CALL check("H5Pget_vol_id_f",error,total_error) - CALL VERIFY("H5Pget_vol_id_f", vol_id_out, vol_id, total_error) + are_same = .FALSE. + CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error) + CALL check("H5VLcmp_connector_cls_f",error,total_error) + CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error) ENDIF CALL H5VLget_connector_id_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id_out, error) CALL check("H5VLget_connector_id_by_name_f",error,total_error) - CALL VERIFY("H5VLget_connector_id_by_name_f", vol_id_out, vol_id, total_error) - CALL H5Fcreate_f("voltest.h5",H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl_id) + are_same = .FALSE. + CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error) + CALL check("H5VLcmp_connector_cls_f",error,total_error) + CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error) + CALL H5Fcreate_f("voltest.h5",H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl_id) CALL check("H5F_create_f",error,total_error) CALL H5VLclose_f(vol_id_out, error) diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 9d64e7ffcc4..54c51798cf7 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -15497,6 +15497,24 @@ public synchronized static native String H5VLget_connector_name(long object_id) public synchronized static native void H5VLunregister_connector(long connector_id) throws HDF5LibraryException; + /** + * @ingroup JH5VL + * + * H5VLcmp_connector_cls Determines whether two connector identifiers refer to the same connector. + * + * @param conn_id1 + * IN: Identifier of connector to compare. + * @param conn_id2 + * IN: Identifier of connector to compare. + * + * @return true if the connector identifiers refer to the same connector, else false. + * + * @exception HDF5LibraryException + * Error from the HDF5 Library. + **/ + public synchronized static native boolean H5VLcmp_connector_cls(long conn_id1, long conn_id2) + throws HDF5LibraryException; + // /////// unimplemented //////// // hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c index 47e532a5609..b2fc6a1aebf 100644 --- a/java/src/jni/h5vlImp.c +++ b/java/src/jni/h5vlImp.c @@ -19,6 +19,7 @@ extern "C" { #include "hdf5.h" #include "h5jni.h" #include "h5vlImp.h" +#include "H5VLconnector_passthru.h" /* * Class: hdf_hdf5lib_H5 @@ -272,6 +273,29 @@ Java_hdf_hdf5lib_H5_H5VLunregister_1connector(JNIEnv *env, jclass clss, jlong co return; } /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLcmp_connector_cls + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5VLcmp_1connector_1cls(JNIEnv *env, jclass clss, jlong conn_id1, jlong conn_id2) +{ + int cmp_value = 0; + jboolean bval = JNI_FALSE; + herr_t retValue = FAIL; + + UNUSED(clss); + + if ((retValue = H5VLcmp_connector_cls(&cmp_value, (hid_t)conn_id1, (hid_t)conn_id2)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (cmp_value == 0) ? JNI_TRUE : JNI_FALSE; + +done: + return bval; +} /* end Java_hdf_hdf5lib_H5_H5VLcmp_connector_cls */ + #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h index a17807f9380..d3248f53d13 100644 --- a/java/src/jni/h5vlImp.h +++ b/java/src/jni/h5vlImp.h @@ -93,6 +93,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLclose(JNIEnv *, jclass, jlong); */ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLunregister_1connector(JNIEnv *, jclass, jlong); +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLcmp_connector_cls + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5VLcmp_1connector_1cls(JNIEnv *, jclass, jlong, jlong); + #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/test/TestH5VL.java b/java/test/TestH5VL.java index 99505ae8e51..666219114fe 100644 --- a/java/test/TestH5VL.java +++ b/java/test/TestH5VL.java @@ -98,7 +98,8 @@ public void testH5VLget_connector_id() */ String connector = System.getenv("HDF5_VOL_CONNECTOR"); if (connector == null) - assertEquals(HDF5Constants.H5VL_NATIVE, native_id); + assertTrue("H5.H5VLcmp_connector_cls(H5VL_NATIVE_NAME, native_id)", + H5.H5VLcmp_connector_cls(HDF5Constants.H5VL_NATIVE, native_id)); } catch (Throwable err) { err.printStackTrace(); @@ -122,7 +123,8 @@ public void testH5VLget_connector_id_by_name() try { long native_id = H5.H5VLget_connector_id_by_name(HDF5Constants.H5VL_NATIVE_NAME); assertTrue("H5.H5VLget_connector_id_by_name H5VL_NATIVE_NAME", native_id >= 0); - assertEquals(HDF5Constants.H5VL_NATIVE, native_id); + assertTrue("H5.H5VLcmp_connector_cls(H5VL_NATIVE_NAME, native_id)", + H5.H5VLcmp_connector_cls(HDF5Constants.H5VL_NATIVE, native_id)); } catch (Throwable err) { err.printStackTrace(); @@ -136,7 +138,8 @@ public void testH5VLget_connector_id_by_value() try { long native_id = H5.H5VLget_connector_id_by_value(HDF5Constants.H5VL_NATIVE_VALUE); assertTrue("H5.H5VLget_connector_id_by_value H5VL_NATIVE_VALUE", native_id >= 0); - assertEquals(HDF5Constants.H5VL_NATIVE, native_id); + assertTrue("H5.H5VLcmp_connector_cls(H5VL_NATIVE_NAME, native_id)", + H5.H5VLcmp_connector_cls(HDF5Constants.H5VL_NATIVE, native_id)); } catch (Throwable err) { err.printStackTrace(); diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 6459e806cff..d2056bddf9a 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -708,6 +708,7 @@ New Features Fortran Library: ---------------- + - Add Fortran H5VLcmp_connector_cls_f API routine. - Add Fortran H5R APIs: h5rcreate_attr_f, h5rcreate_object_f, h5rcreate_region_f, @@ -778,7 +779,7 @@ New Features Java Library: ------------- - - + - Add H5VLcmp_connector_cls API routine. Tools: @@ -820,13 +821,14 @@ New Features -------------- - Documented that leaving HDF5 threads running at termination is unsafe - Added doc/threadsafety-warning.md as a warning that threads which use HDF5 - resources must be closed before either process exit or library close. - If HDF5 threads are alive during either of these operations, their resources - will not be cleaned up properly and undefined behavior is possible. - - This document also includes a discussion on potential ways to mitigate this issue. + Added doc/threadsafety-warning.md as a warning that threads which use + HDF5 resources must be closed before either process exit or library + close. If HDF5 threads are alive during either of these operations, + their resources will not be cleaned up properly and undefined behavior + is possible. + This document also includes a discussion on potential ways to mitigate + this issue. Support for new platforms, languages and compilers @@ -837,6 +839,15 @@ Bug Fixes since HDF5-1.14.0 release =================================== Library ------- + - Removed the H5VLpeek_connector_id_by_name and + H5VLpeek_connector_id_by_value routines from the VOL connector public + API. VOL connector authors should use the H5VLget_connector_id_by_name + and H5VLget_connector_id_by_value routines instead. Note that the + H5VLpeek_connector_id_by_name and H5VLpeek_connector_id_by_value routines + required that connector authors _not_ close the IDs returned and that + the IDs returned from H5VLget_connector_id_by_name and + and H5VLget_connector_id_by_value should be closed to avoid resource + leaks. - Fixed a memory leak in H5F__accum_write() @@ -984,10 +995,10 @@ Bug Fixes since HDF5-1.14.0 release The library's metadata cache calls the "get_final_load_size" client callback to find out the actual size of the object header. As the size obtained exceeds the file's EOA, it throws an error but the object header structure - allocated through the client callback is not freed hence causing the + allocated through the client callback is not freed hence causing the issue described. - (1) Free the structure allocated in the object header client callback after + (1) Free the structure allocated in the object header client callback after saving the needed information in udata. (2) Deserialize the object header prefix in the object header's "deserialize" callback regardless. @@ -1490,7 +1501,7 @@ Bug Fixes since HDF5-1.14.0 release This behavior is not generally observed when creating a dataset and then performing I/O on it, as the relevant metadata will usually be in the metadata cache as a side effect of creating - the chunk index structures during dataset creation. + the chunk index structures during dataset creation. This issue has been fixed by adding callbacks to the different chunk indexing structure classes that allow more explicit control @@ -1737,8 +1748,8 @@ Bug Fixes since HDF5-1.14.0 release When attempting to read layout, pline, and efl information for a dataset, memory leaks could occur if attempting to read pline/efl - information threw an error, which is due to the memory that was - allocated for pline and efl not being properly cleaned up on error. + information threw an error, which is due to the memory that was + allocated for pline and efl not being properly cleaned up on error. Fixes GitHub issue #2602 @@ -1746,11 +1757,11 @@ Bug Fixes since HDF5-1.14.0 release H5O__ginfo_decode could sometimes read past allocated memory when parsing a group info message from the header of a malformed file. - + It now checks buffer size before each read to properly throw an error in these cases. - + Fixes GitHub issue #2601 - + - Fixed potential buffer overrun issues in some object header decode routines Several checks were added to H5O__layout_decode and H5O__sdspace_decode to @@ -1804,7 +1815,7 @@ Bug Fixes since HDF5-1.14.0 release lead to issues if only 1 I/O concentrator was requested Also added a regression test for these two I/O concentrator selection - strategies to prevent future issues. + strategies to prevent future issues. - Fix CVE-2021-37501 / GHSA-rfgw-5vq3-wrjf @@ -1830,7 +1841,7 @@ Bug Fixes since HDF5-1.14.0 release The assertion failure was fixed by updating collective metadata writes to treat global heap metadata as raw data, as done elsewhere in the - library. + library. Fixes GitHub issue #2433 @@ -1840,7 +1851,7 @@ Bug Fixes since HDF5-1.14.0 release buffer, which is called many times from the function responsible for image decoding. The length of the buffer is known in the image decoding function, but no checks are produced, so the buffer overflow can occur in many places, - including callee functions for address decoding. + including callee functions for address decoding. The error was fixed by inserting corresponding checks for buffer overflow. @@ -1861,8 +1872,8 @@ Bug Fixes since HDF5-1.14.0 release - Fixed a segfault when using a user-defined conversion function between compound datatypes During type info initialization for compound datatype conversion, the library checked if the - datatypes are subsets of one another in order to perform special conversion handling. - This check uses information that is only defined if a library conversion function is in use. + datatypes are subsets of one another in order to perform special conversion handling. + This check uses information that is only defined if a library conversion function is in use. The library now skips this check for user-defined conversion functions. Fixes Github issue #3840 @@ -1882,9 +1893,9 @@ Bug Fixes since HDF5-1.14.0 release Configuration ------------- - - Changed name of libhdf5hl_fortran installed by autotools to libhdf5_hl_fortran. The - new name is consistent with the name of the lib when installed by CMake and with the - other hl libs. + - Changed name of libhdf5hl_fortran installed by autotools to libhdf5_hl_fortran. The + new name is consistent with the name of the lib when installed by CMake and with the + other hl libs. Fixes GitHub issue #4811 @@ -1902,7 +1913,7 @@ Bug Fixes since HDF5-1.14.0 release library in a find_package call. - Corrected usage of FetchContent in the HDFLibMacros.cmake file. - + CMake version 3.30 changed the behavior of the FetchContent module to deprecate the use of FetchContent_Populate() in favor of FetchContent_MakeAvailable(). Therefore, the copying of HDF specialized CMakeLists.txt files to the dependent project's source @@ -2092,13 +2103,13 @@ Bug Fixes since HDF5-1.14.0 release variable-length datatypes, but this can be problematic if the global heap addresses involved do not match exactly between the old and new files. These addresses could change for a variety of reasons, such as the command-line options - provided to h5repack, how h5repack allocate space in the repacked file, etc. + provided to h5repack, how h5repack allocate space in the repacked file, etc. Since H5Ocopy does not currently perform any translation when these addresses change, datasets that were repacked with H5Ocopy could become unreadable in the new file. H5repack has been fixed to repack variable-length typed datasets without using H5Ocopy to ensure that the new datasets always have the correct global heap addresses. - + - Names of objects with square brackets will have trouble without the special argument, --no-compact-subset, on the h5dump command line. @@ -2159,7 +2170,7 @@ Bug Fixes since HDF5-1.14.0 release C++ APIs -------- - - + - Testing diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47fc1dcf751..438d60fffc7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -687,6 +687,8 @@ set (H5VL_SOURCES ${HDF5_SRC_DIR}/H5VLnative_object.c ${HDF5_SRC_DIR}/H5VLnative_token.c ${HDF5_SRC_DIR}/H5VLpassthru.c + ${HDF5_SRC_DIR}/H5VLpassthru_int.c + ${HDF5_SRC_DIR}/H5VLquery.c ${HDF5_SRC_DIR}/H5VLtest.c ) set (H5VL_HDRS diff --git a/src/H5A.c b/src/H5A.c index 10475919fbe..6c9cfd9f50d 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -125,7 +125,7 @@ H5A__create_common(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, const HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute"); /* Register the new attribute and get an ID for it */ - if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID"); done: @@ -267,7 +267,7 @@ H5Acreate_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIui*siiiii", app_file, app_func, app_line, loc_id, attr_name, type_id, space_id, acpl_id, aapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -413,7 +413,7 @@ H5Acreate_by_name_async(const char *app_file, const char *app_func, unsigned app /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE12(__func__, "*s*sIui*s*siiiiii", app_file, app_func, app_line, loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -454,7 +454,7 @@ H5A__open_common(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, const ch HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", attr_name); /* Register the attribute and get an ID for it */ - if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID"); done: @@ -574,7 +574,7 @@ H5Aopen_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, attr_name, aapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -702,7 +702,7 @@ H5Aopen_by_name_async(const char *app_file, const char *app_func, unsigned app_l /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE9(__func__, "*s*sIui*s*siii", app_file, app_func, app_line, loc_id, obj_name, attr_name, aapl_id, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -839,7 +839,7 @@ H5Aopen_by_idx_async(const char *app_file, const char *app_func, unsigned app_li /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE11(__func__, "*s*sIui*sIiIohiii", app_file, app_func, app_line, loc_id, obj_name, idx_type, order, n, aapl_id, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -949,7 +949,7 @@ H5Awrite_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIuii*xi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1055,7 +1055,7 @@ H5Aread_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIuii*xi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1678,7 +1678,7 @@ H5Arename_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*s*si", app_file, app_func, app_line, loc_id, old_name, new_name, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1792,7 +1792,7 @@ H5Arename_by_name_async(const char *app_file, const char *app_func, unsigned app /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE9(__func__, "*s*sIui*s*s*sii", app_file, app_func, app_line, loc_id, obj_name, old_attr_name, new_attr_name, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -2214,11 +2214,11 @@ H5Aclose(hid_t attr_id) herr_t H5Aclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t attr_id, hid_t es_id) { - H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - H5VL_t *connector = NULL; /* VOL connector */ - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2234,7 +2234,7 @@ H5Aclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* Increase connector's refcount, so it doesn't get closed if closing * the attribute closes the file */ - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); H5VL_conn_inc_rc(connector); /* Point at token for operation to set up */ @@ -2250,7 +2250,7 @@ H5Aclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, attr_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -2401,7 +2401,7 @@ H5Aexists_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*s*bi", app_file, app_func, app_line, obj_id, attr_name, attr_exists, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -2514,7 +2514,7 @@ H5Aexists_by_name_async(const char *app_file, const char *app_func, unsigned app /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE9(__func__, "*s*sIui*s*s*bii", app_file, app_func, app_line, loc_id, obj_name, attr_name, attr_exists, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index a63470a0eca..0d878d34e48 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -138,7 +138,7 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute"); /* Register the new attribute and get an ID for it */ - if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID"); done: @@ -202,7 +202,7 @@ H5Aopen_name(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute"); /* Register the attribute and get an ID for it */ - if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute handle"); done: @@ -269,7 +269,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute"); /* Register the attribute and get an ID for it */ - if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, attr, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute handle"); done: diff --git a/src/H5CX.c b/src/H5CX.c index 643c77f9c31..dbcb49e2e6b 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -931,33 +931,27 @@ H5CX_retrieve_state(H5CX_state_t **api_state) } /* end if */ /* Keep a copy of the VOL connector property, if there is one */ - if ((*head)->ctx.vol_connector_prop_valid && (*head)->ctx.vol_connector_prop.connector_id > 0) { + if ((*head)->ctx.vol_connector_prop_valid && (*head)->ctx.vol_connector_prop.connector) { /* Get the connector property */ H5MM_memcpy(&(*api_state)->vol_connector_prop, &(*head)->ctx.vol_connector_prop, sizeof(H5VL_connector_prop_t)); /* Check for actual VOL connector property */ - if ((*api_state)->vol_connector_prop.connector_id) { + if ((*api_state)->vol_connector_prop.connector) { /* Copy connector info, if it exists */ if ((*api_state)->vol_connector_prop.connector_info) { - H5VL_class_t *connector; /* Pointer to connector */ - void *new_connector_info = NULL; /* Copy of connector info */ - - /* Retrieve the connector for the ID */ - if (NULL == - (connector = (H5VL_class_t *)H5I_object((*api_state)->vol_connector_prop.connector_id))) - HGOTO_ERROR(H5E_CONTEXT, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + void *new_connector_info = NULL; /* Copy of connector info */ /* Allocate and copy connector info */ - if (H5VL_copy_connector_info(connector, &new_connector_info, + if (H5VL_copy_connector_info((*api_state)->vol_connector_prop.connector, &new_connector_info, (*api_state)->vol_connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTCOPY, FAIL, "connector info copy failed"); (*api_state)->vol_connector_prop.connector_info = new_connector_info; } /* end if */ - /* Increment the refcount on the connector ID */ - if (H5I_inc_ref((*api_state)->vol_connector_prop.connector_id, false) < 0) - HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed"); + /* Increment the refcount on the connector */ + if (H5VL_conn_inc_rc((*api_state)->vol_connector_prop.connector) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTINC, FAIL, "incrementing VOL connector refcount failed"); } /* end if */ } /* end if */ @@ -1028,7 +1022,7 @@ H5CX_restore_state(const H5CX_state_t *api_state) (*head)->ctx.vol_wrap_ctx_valid = true; /* Restore the VOL connector info */ - if (api_state->vol_connector_prop.connector_id) { + if (api_state->vol_connector_prop.connector) { H5MM_memcpy(&(*head)->ctx.vol_connector_prop, &api_state->vol_connector_prop, sizeof(H5VL_connector_prop_t)); (*head)->ctx.vol_connector_prop_valid = true; @@ -1087,16 +1081,17 @@ H5CX_free_state(H5CX_state_t *api_state) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't decrement refcount on VOL wrapping context"); /* Release the VOL connector property, if it was set */ - if (api_state->vol_connector_prop.connector_id) { + if (api_state->vol_connector_prop.connector) { /* Clean up any VOL connector info */ if (api_state->vol_connector_prop.connector_info) - if (H5VL_free_connector_info(api_state->vol_connector_prop.connector_id, + if (H5VL_free_connector_info(api_state->vol_connector_prop.connector, api_state->vol_connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_CONTEXT, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object"); - /* Decrement connector ID */ - if (H5I_dec_ref(api_state->vol_connector_prop.connector_id) < 0) - HDONE_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't close VOL connector ID"); + + /* Decrement connector refcount */ + if (H5VL_conn_dec_rc(api_state->vol_connector_prop.connector) < 0) + HDONE_ERROR(H5E_CONTEXT, H5E_CANTDEC, FAIL, "can't close VOL connector"); } /* end if */ /* Free the state */ diff --git a/src/H5D.c b/src/H5D.c index a50a2aceda6..7673acc0711 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -135,7 +135,7 @@ H5D__create_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t spac HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create dataset"); /* Get an ID for the dataset */ - if ((ret_value = H5VL_register(H5I_DATASET, dset, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset"); done: @@ -222,7 +222,7 @@ H5Dcreate_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE11(__func__, "*s*sIui*siiiiii", app_file, app_func, app_line, loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -309,7 +309,7 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset"); /* Get an ID for the dataset */ - if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset"); done: @@ -360,7 +360,7 @@ H5D__open_api_common(hid_t loc_id, const char *name, hid_t dapl_id, void **token HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset"); /* Register an atom for the dataset */ - if ((ret_value = H5VL_register(H5I_DATASET, dset, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset ID"); done: @@ -433,7 +433,7 @@ H5Dopen_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, dapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -489,11 +489,11 @@ H5Dclose(hid_t dset_id) herr_t H5Dclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t dset_id, hid_t es_id) { - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - H5VL_object_t *vol_obj = NULL; /* VOL object of dset_id */ - H5VL_t *connector = NULL; /* VOL connector */ - herr_t ret_value = SUCCEED; /* Return value */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + H5VL_object_t *vol_obj = NULL; /* VOL object of dset_id */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -509,7 +509,7 @@ H5Dclose_async(const char *app_file, const char *app_func, unsigned app_line, hi if (H5ES_NONE != es_id) { /* Increase connector's refcount, so it doesn't get closed if closing * the dataset closes the file */ - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); H5VL_conn_inc_rc(connector); /* Point at token for operation to set up */ @@ -525,7 +525,7 @@ H5Dclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, dset_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -639,7 +639,7 @@ H5Dget_space_async(const char *app_file, const char *app_func, unsigned app_line /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, dset_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -929,11 +929,11 @@ H5D__read_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t m H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - void *obj_local; /* Local buffer for obj */ - void **obj = &obj_local; /* Array of object pointers */ - H5VL_t *connector; /* VOL connector pointer */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + void *obj_local; /* Local buffer for obj */ + void **obj = &obj_local; /* Array of object pointers */ + H5VL_connector_t *connector; /* VOL connector pointer */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -954,7 +954,7 @@ H5D__read_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t m /* Allocate obj array if necessary */ if (count > 1) if (NULL == (obj = (void **)H5MM_malloc(count * sizeof(void *)))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate space for object array"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate space for object array"); /* Get vol_obj_ptr (return just the first dataset to caller if requested) */ if (NULL == (*vol_obj_ptr = H5VL_vol_object_verify(dset_id[0], H5I_DATASET))) @@ -963,18 +963,22 @@ H5D__read_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t m /* Save the connector of the first dataset. Unpack the connector and call * the "direct" read function here to avoid allocating an array of count * H5VL_object_ts. */ - connector = (*vol_obj_ptr)->connector; + connector = H5VL_OBJ_CONNECTOR(*vol_obj_ptr); /* Build obj array */ - obj[0] = (*vol_obj_ptr)->data; + obj[0] = H5VL_OBJ_DATA(*vol_obj_ptr); for (i = 1; i < count; i++) { + htri_t cls_cmp; + /* Get the object */ if (NULL == (tmp_vol_obj = H5VL_vol_object_verify(dset_id[i], H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID"); - obj[i] = tmp_vol_obj->data; + obj[i] = H5VL_OBJ_DATA(tmp_vol_obj); /* Make sure the class matches */ - if (tmp_vol_obj->connector->cls->value != connector->cls->value) + if ((cls_cmp = H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(tmp_vol_obj), connector)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOMPARE, FAIL, "can't compare VOL connectors"); + if (!cls_cmp) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datasets are accessed through different VOL connectors and can't be used in the " "same I/O call"); @@ -1079,7 +1083,7 @@ H5Dread_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIuiiiii*xi", app_file, app_func, app_line, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1152,7 +1156,7 @@ H5Dread_multi_async(const char *app_file, const char *app_func, unsigned app_lin /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE11(__func__, "*s*sIuz*i*i*i*ii**xi", app_file, app_func, app_line, count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1231,11 +1235,11 @@ H5D__write_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t H5VL_object_t *tmp_vol_obj = NULL; /* Object for loc_id */ H5VL_object_t **vol_obj_ptr = (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj); /* Ptr to object ptr for loc_id */ - void *obj_local; /* Local buffer for obj */ - void **obj = &obj_local; /* Array of object pointers */ - H5VL_t *connector; /* VOL connector pointer */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + void *obj_local; /* Local buffer for obj */ + void **obj = &obj_local; /* Array of object pointers */ + H5VL_connector_t *connector; /* VOL connector pointer */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1256,7 +1260,7 @@ H5D__write_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t /* Allocate obj array if necessary */ if (count > 1) if (NULL == (obj = (void **)H5MM_malloc(count * sizeof(void *)))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate space for object array"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate space for object array"); /* Get vol_obj_ptr (return just the first dataset to caller if requested) */ if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(dset_id[0], H5I_DATASET))) @@ -1265,18 +1269,22 @@ H5D__write_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t /* Save the connector of the first dataset. Unpack the connector and call * the "direct" write function here to avoid allocating an array of count * H5VL_object_ts. */ - connector = (*vol_obj_ptr)->connector; + connector = H5VL_OBJ_CONNECTOR(*vol_obj_ptr); /* Build obj array */ - obj[0] = (*vol_obj_ptr)->data; + obj[0] = H5VL_OBJ_DATA(*vol_obj_ptr); for (i = 1; i < count; i++) { + htri_t cls_cmp; + /* Get the object */ if (NULL == (tmp_vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id[i], H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID"); - obj[i] = tmp_vol_obj->data; + obj[i] = H5VL_OBJ_DATA(tmp_vol_obj); /* Make sure the class matches */ - if (tmp_vol_obj->connector->cls->value != connector->cls->value) + if ((cls_cmp = H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(tmp_vol_obj), connector)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOMPARE, FAIL, "can't compare VOL connectors"); + if (!cls_cmp) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datasets are accessed through different VOL connectors and can't be used in the " "same I/O call"); @@ -1383,7 +1391,7 @@ H5Dwrite_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIuiiiii*xi", app_file, app_func, app_line, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1456,7 +1464,7 @@ H5Dwrite_multi_async(const char *app_file, const char *app_func, unsigned app_li /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE11(__func__, "*s*sIuz*i*i*i*ii**xi", app_file, app_func, app_line, count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -2012,7 +2020,7 @@ H5Dset_extent_async(const char *app_file, const char *app_func, unsigned app_lin /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE6(__func__, "*s*sIui*hi", app_file, app_func, app_line, dset_id, size, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set"); diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 51d6e4323c0..a8f92fe5c55 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -137,7 +137,7 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset"); /* Register the new dataset to get an ID for it */ - if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset"); done: @@ -192,7 +192,7 @@ H5Dopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset"); /* Get an ID for the dataset */ - if ((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_DATASET, dset, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset ID"); done: diff --git a/src/H5Dint.c b/src/H5Dint.c index 700d8306604..2b1d0c7e20b 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -2791,6 +2791,7 @@ H5D__vlen_get_buf_size_gen_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned { H5D_vlen_bufsize_generic_t *vlen_bufsize = (H5D_vlen_bufsize_generic_t *)op_data; H5T_t *dt; /* Datatype for operation */ + void *vol_obj_data; /* VOL object's data pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2813,8 +2814,9 @@ H5D__vlen_get_buf_size_gen_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't select point"); /* Read in the point (with the custom VL memory allocator) */ - if (H5VL_dataset_read(1, &vlen_bufsize->dset_vol_obj->data, vlen_bufsize->dset_vol_obj->connector, - &type_id, &vlen_bufsize->mspace_id, &vlen_bufsize->fspace_id, vlen_bufsize->dxpl_id, + vol_obj_data = H5VL_OBJ_DATA(vlen_bufsize->dset_vol_obj); + if (H5VL_dataset_read(1, &vol_obj_data, H5VL_OBJ_CONNECTOR(vlen_bufsize->dset_vol_obj), &type_id, + &vlen_bufsize->mspace_id, &vlen_bufsize->fspace_id, vlen_bufsize->dxpl_id, &vlen_bufsize->common.fl_tbuf, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point"); diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index ac31231b1e8..d10f4af8520 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -3124,7 +3124,7 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't unregister source dataset ID"); if (NULL == (*dset = (H5D_t *)H5VL_object_unwrap(vol_obj))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve library object from VOL object"); - vol_obj->data = NULL; + H5VL_OBJ_DATA_RESET(vol_obj); done: if (vol_obj && H5VL_free_object(vol_obj) < 0) diff --git a/src/H5ES.c b/src/H5ES.c index a354db3016d..7b830b5f740 100644 --- a/src/H5ES.c +++ b/src/H5ES.c @@ -111,9 +111,9 @@ H5EScreate(void) herr_t H5ESinsert_request(hid_t es_id, hid_t connector_id, void *request) { - H5ES_t *es; /* Event set */ - H5VL_t *connector = NULL; /* VOL connector */ - herr_t ret_value = SUCCEED; /* Return value */ + H5ES_t *es; /* Event set */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -122,22 +122,14 @@ H5ESinsert_request(hid_t es_id, hid_t connector_id, void *request) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid event set identifier"); if (NULL == request) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL request pointer"); - - /* Create new VOL connector object, using the connector ID */ - if (NULL == (connector = H5VL_new_connector(connector_id))) - HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCREATE, FAIL, "can't create VOL connector object"); + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Insert request into event set */ if (H5ES__insert_request(es, connector, request) < 0) HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "can't insert request into event set"); done: - /* Clean up on error */ - if (ret_value < 0) - /* Release newly created connector */ - if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector"); - FUNC_LEAVE_API(ret_value) } /* end H5ESinsert_request() */ diff --git a/src/H5ESevent.c b/src/H5ESevent.c index 3286424ff13..d925fb407d8 100644 --- a/src/H5ESevent.c +++ b/src/H5ESevent.c @@ -79,7 +79,7 @@ H5FL_DEFINE_STATIC(H5ES_event_t); *------------------------------------------------------------------------- */ H5ES_event_t * -H5ES__event_new(H5VL_t *connector, void *token) +H5ES__event_new(H5VL_connector_t *connector, void *token) { H5ES_event_t *ev = NULL; /* New event */ H5VL_object_t *request = NULL; /* Async request token VOL object */ diff --git a/src/H5ESint.c b/src/H5ESint.c index dab683913d6..eef68d579c2 100644 --- a/src/H5ESint.c +++ b/src/H5ESint.c @@ -39,6 +39,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5RSprivate.h" /* Reference-counted strings */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -88,7 +89,7 @@ typedef struct H5ES_gei_ctx_t { /********************/ static herr_t H5ES__close(H5ES_t *es); static herr_t H5ES__close_cb(void *es, void **request_token); -static herr_t H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app_file, +static herr_t H5ES__insert(H5ES_t *es, H5VL_connector_t *connector, void *request_token, const char *app_file, const char *app_func, unsigned app_line, const char *caller, const char *api_args); static int H5ES__get_requests_cb(H5ES_event_t *ev, void *_ctx); static herr_t H5ES__handle_fail(H5ES_t *es, H5ES_event_t *ev); @@ -240,8 +241,8 @@ H5ES__create(void) *------------------------------------------------------------------------- */ static herr_t -H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app_file, const char *app_func, - unsigned app_line, const char *caller, const char *api_args) +H5ES__insert(H5ES_t *es, H5VL_connector_t *connector, void *request_token, const char *app_file, + const char *app_func, unsigned app_line, const char *caller, const char *api_args) { H5ES_event_t *ev = NULL; /* Event for request */ bool ev_inserted = false; /* Flag to indicate that event is in active list */ @@ -313,7 +314,8 @@ H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app *------------------------------------------------------------------------- */ herr_t -H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, const char *caller_args, ...) +H5ES_insert(hid_t es_id, H5VL_connector_t *connector, void *token, const char *caller, + const char *caller_args, ...) { H5ES_t *es = NULL; /* Event set for the operation */ const char *app_file; /* Application source file name */ @@ -389,7 +391,7 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con *------------------------------------------------------------------------- */ herr_t -H5ES__insert_request(H5ES_t *es, H5VL_t *connector, void *token) +H5ES__insert_request(H5ES_t *es, H5VL_connector_t *connector, void *token) { herr_t ret_value = SUCCEED; /* Return value */ @@ -424,7 +426,7 @@ H5ES__get_requests_cb(H5ES_event_t *ev, void *_ctx) H5ES_get_requests_ctx_t *ctx = (H5ES_get_requests_ctx_t *)_ctx; /* Callback context */ int ret_value = H5_ITER_CONT; /* Return value */ - FUNC_ENTER_PACKAGE_NOERR + FUNC_ENTER_PACKAGE /* Sanity check */ assert(ev); @@ -433,16 +435,18 @@ H5ES__get_requests_cb(H5ES_event_t *ev, void *_ctx) /* Get the connector ID for the event */ if (ctx->connector_ids) - ctx->connector_ids[ctx->i] = ev->request->connector->id; + if ((ctx->connector_ids[ctx->i] = H5VL_conn_register(H5VL_OBJ_CONNECTOR(ev->request))) < 0) + HGOTO_ERROR(H5E_EVENTSET, H5E_CANTREGISTER, H5_ITER_ERROR, "unable to register VOL connector ID"); /* Get the request for the event */ if (ctx->requests) - ctx->requests[ctx->i] = ev->request->data; + ctx->requests[ctx->i] = H5VL_OBJ_DATA(ev->request); /* Check if we've run out of room in the arrays */ if (++ctx->i == ctx->array_len) ret_value = H5_ITER_STOP; +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5ES__get_requests_cb() */ diff --git a/src/H5ESpkg.h b/src/H5ESpkg.h index 1da58a68679..853f39fefad 100644 --- a/src/H5ESpkg.h +++ b/src/H5ESpkg.h @@ -76,7 +76,7 @@ typedef int (*H5ES_list_iter_func_t)(H5ES_event_t *ev, void *ctx); /* Package Private Prototypes */ /******************************/ H5_DLL H5ES_t *H5ES__create(void) H5_ATTR_MALLOC; -H5_DLL herr_t H5ES__insert_request(H5ES_t *es, H5VL_t *connector, void *token); +H5_DLL herr_t H5ES__insert_request(H5ES_t *es, H5VL_connector_t *connector, void *token); H5_DLL herr_t H5ES__wait(H5ES_t *es, uint64_t timeout, size_t *num_in_progress, bool *op_failed); H5_DLL herr_t H5ES__get_requests(H5ES_t *es, H5_iter_order_t order, hid_t *connector_ids, void **requests, size_t array_len); @@ -92,7 +92,7 @@ H5_DLL int H5ES__list_iterate(H5ES_event_list_t *el, H5_iter_order_t order, H H5_DLL void H5ES__list_remove(H5ES_event_list_t *el, const H5ES_event_t *ev); /* Event operations */ -H5_DLL H5ES_event_t *H5ES__event_new(H5VL_t *connector, void *token); +H5_DLL H5ES_event_t *H5ES__event_new(H5VL_connector_t *connector, void *token); H5_DLL herr_t H5ES__event_free(H5ES_event_t *ev); H5_DLL herr_t H5ES__event_completed(H5ES_event_t *ev, H5ES_event_list_t *el); diff --git a/src/H5ESprivate.h b/src/H5ESprivate.h index 52392fbfd44..2de833de459 100644 --- a/src/H5ESprivate.h +++ b/src/H5ESprivate.h @@ -47,8 +47,8 @@ typedef struct H5ES_t H5ES_t; /***************************************/ /* Library-private Function Prototypes */ /***************************************/ -herr_t H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, const char *caller_args, - ...); +herr_t H5ES_insert(hid_t es_id, H5VL_connector_t *connector, void *token, const char *caller, + const char *caller_args, ...); H5_DLL herr_t H5ES_init(void); #endif /* H5ESprivate_H */ diff --git a/src/H5F.c b/src/H5F.c index 5dd7bda3903..b35ed2ef7c3 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -88,12 +88,6 @@ static herr_t H5F__flush_api_common(hid_t object_id, H5F_scope_t scope, void **t /* Local Variables */ /*******************/ -/* Declare a free list to manage the H5VL_t struct */ -H5FL_EXTERN(H5VL_t); - -/* Declare a free list to manage the H5VL_object_t struct */ -H5FL_EXTERN(H5VL_object_t); - /*------------------------------------------------------------------------- * Function: H5Fget_create_plist * @@ -603,12 +597,12 @@ H5F__create_api_common(const char *filename, unsigned flags, hid_t fcpl_id, hid_ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* Create a new file or truncate an existing file through the VOL */ - if (NULL == (new_file = H5VL_file_create(&connector_prop, filename, flags, fcpl_id, fapl_id, + if (NULL == (new_file = H5VL_file_create(connector_prop.connector, filename, flags, fcpl_id, fapl_id, H5P_DATASET_XFER_DEFAULT, token_ptr))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file"); /* Get an ID for the file */ - if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, true)) < 0) + if ((ret_value = H5VL_register(H5I_FILE, new_file, connector_prop.connector, true)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle"); done: @@ -701,7 +695,7 @@ H5Fcreate_async(const char *app_file, const char *app_func, unsigned app_line, c /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE8(__func__, "*s*sIu*sIuiii", app_file, app_func, app_line, filename, flags, fcpl_id, fapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -720,7 +714,7 @@ H5Fcreate_async(const char *app_file, const char *app_func, unsigned app_line, c /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE8(__func__, "*s*sIu*sIuiii", app_file, app_func, app_line, filename, flags, fcpl_id, fapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set"); @@ -783,12 +777,12 @@ H5F__open_api_common(const char *filename, unsigned flags, hid_t fapl_id, void * HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector info in API context"); /* Open the file through the VOL layer */ - if (NULL == (new_file = H5VL_file_open(&connector_prop, filename, flags, fapl_id, + if (NULL == (new_file = H5VL_file_open(connector_prop.connector, filename, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, token_ptr))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file"); /* Get an ID for the file */ - if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, true)) < 0) + if ((ret_value = H5VL_register(H5I_FILE, new_file, connector_prop.connector, true)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle"); done: @@ -876,7 +870,7 @@ H5Fopen_async(const char *app_file, const char *app_func, unsigned app_line, con /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIu*sIuii", app_file, app_func, app_line, filename, flags, fapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -895,7 +889,7 @@ H5Fopen_async(const char *app_file, const char *app_func, unsigned app_line, con /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIu*sIuii", app_file, app_func, app_line, filename, flags, fapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set"); @@ -1006,7 +1000,7 @@ H5Fflush_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE6(__func__, "*s*sIuiFsi", app_file, app_func, app_line, object_id, scope, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1062,11 +1056,11 @@ H5Fclose(hid_t file_id) herr_t H5Fclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t file_id, hid_t es_id) { - H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - H5VL_t *connector = NULL; /* VOL connector */ - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1082,7 +1076,7 @@ H5Fclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* Increase connector's refcount, so it doesn't get closed if closing * this file ID closes the file */ - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); H5VL_conn_inc_rc(connector); /* Point at token for operation to set up */ @@ -1098,7 +1092,7 @@ H5Fclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, file_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1193,8 +1187,8 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) H5VL_group_specific_args_t vol_cb_args; /* Arguments to VOL callback */ void *grp = NULL; /* Root group opened */ H5I_type_t loc_type; /* ID type of location */ - int same_connector = 0; /* Whether parent and child files use the same connector */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t same_connector; /* Whether parent and child files use the same connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1239,7 +1233,7 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open group"); /* Create a VOL object for the root group */ - if (NULL == (loc_vol_obj = H5VL_create_object(grp, vol_obj->connector))) + if (NULL == (loc_vol_obj = H5VL_create_object(grp, H5VL_OBJ_CONNECTOR(vol_obj)))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "can't create VOL object for root group"); } /* end if */ else { @@ -1253,10 +1247,10 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object"); /* Check if both objects are associated with the same VOL connector */ - if (H5VL_cmp_connector_cls(&same_connector, loc_vol_obj->connector->cls, child_vol_obj->connector->cls) < - 0) + if ((same_connector = + H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(loc_vol_obj), H5VL_OBJ_CONNECTOR(child_vol_obj))) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); - if (same_connector) + if (!same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't mount file onto object from different VOL connector"); @@ -1264,7 +1258,7 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) vol_cb_args.op_type = H5VL_GROUP_MOUNT; vol_cb_args.args.mount.name = name; vol_cb_args.args.mount.child_file = - child_vol_obj->data; /* Don't unwrap fully, so each connector can see its object */ + H5VL_OBJ_DATA(child_vol_obj); /* Don't unwrap fully, so each connector can see its object */ vol_cb_args.args.mount.fmpl_id = plist_id; /* Perform the mount operation */ @@ -1349,7 +1343,7 @@ H5Funmount(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open group"); /* Create a VOL object for the root group */ - if (NULL == (loc_vol_obj = H5VL_create_object(grp, vol_obj->connector))) + if (NULL == (loc_vol_obj = H5VL_create_object(grp, H5VL_OBJ_CONNECTOR(vol_obj)))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "can't create VOL object for root group"); } /* end if */ else { @@ -1420,7 +1414,7 @@ H5F__reopen_api_common(hid_t file_id, void **token_ptr) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file"); /* Get an ID for the file */ - if ((ret_value = H5VL_register(H5I_FILE, reopen_file, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_FILE, reopen_file, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle"); done: @@ -1504,7 +1498,7 @@ H5Freopen_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, file_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref(ret_value) < 0) @@ -1523,7 +1517,7 @@ H5Freopen_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, file_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_FILE, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert token into event set"); diff --git a/src/H5Fint.c b/src/H5Fint.c index 3a9c65f1783..0764bb43beb 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -296,23 +296,19 @@ H5F__set_vol_conn(H5F_t *file) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get VOL connector info from API context"); /* Sanity check */ - assert(0 != connector_prop.connector_id); - - /* Retrieve the connector for the ID */ - if (NULL == (file->shared->vol_cls = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) - HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + assert(connector_prop.connector); /* Allocate and copy connector info, if it exists */ if (connector_prop.connector_info) - if (H5VL_copy_connector_info(file->shared->vol_cls, &new_connector_info, + if (H5VL_copy_connector_info(connector_prop.connector, &new_connector_info, connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed"); - /* Cache the connector ID & info for the container */ - file->shared->vol_id = connector_prop.connector_id; + /* Cache the connector & info for the container */ + file->shared->vol_conn = connector_prop.connector; file->shared->vol_info = new_connector_info; - if (H5I_inc_ref(file->shared->vol_id, false) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed"); + if (H5VL_conn_inc_rc(file->shared->vol_conn) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "incrementing VOL connector refcount failed"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -452,7 +448,7 @@ H5F_get_access_plist(H5F_t *f, bool app_ref) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver ID & info"); /* Set the VOL connector property */ - connector_prop.connector_id = f->shared->vol_id; + connector_prop.connector = f->shared->vol_conn; connector_prop.connector_info = f->shared->vol_info; if (H5P_set(new_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector ID & info"); @@ -1580,14 +1576,13 @@ H5F__dest(H5F_t *f, bool flush, bool free_on_failure) /* Clean up the cached VOL connector ID & info */ if (f->shared->vol_info) - if (H5VL_free_connector_info(f->shared->vol_id, f->shared->vol_info) < 0) + if (H5VL_free_connector_info(f->shared->vol_conn, f->shared->vol_info) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object"); - if (f->shared->vol_id > 0) - if (H5I_dec_ref(f->shared->vol_id) < 0) + if (f->shared->vol_conn) + if (H5VL_conn_dec_rc(f->shared->vol_conn) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID"); - f->shared->vol_cls = NULL; + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector"); /* Close the file */ if (H5FD_close(f->shared->lf) < 0) @@ -2242,7 +2237,7 @@ H5F__post_open(H5F_t *f) assert(f); /* Store a vol object in the file struct */ - if (NULL == (f->vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, f, f->shared->vol_id))) + if (NULL == (f->vol_obj = H5VL_new_vol_obj(H5I_FILE, f, f->shared->vol_conn, true))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "can't create VOL object"); done: @@ -3723,19 +3718,19 @@ H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) herr_t H5F__start_swmr_write(H5F_t *f) { - bool ci_load = false; /* whether MDC ci load requested */ - bool ci_write = false; /* whether MDC CI write requested */ - size_t grp_dset_count = 0; /* # of open objects: groups & datasets */ - size_t nt_attr_count = 0; /* # of opened named datatypes + opened attributes */ - hid_t *obj_ids = NULL; /* List of ids */ - hid_t *obj_apl_ids = NULL; /* List of access property lists */ - H5G_loc_t *obj_glocs = NULL; /* Group location of the object */ - H5O_loc_t *obj_olocs = NULL; /* Object location */ - H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ - size_t u; /* Local index variable */ - bool setup = false; /* Boolean flag to indicate whether SWMR setting is enabled */ - H5VL_t *vol_connector = NULL; /* VOL connector for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + bool ci_load = false; /* whether MDC ci load requested */ + bool ci_write = false; /* whether MDC CI write requested */ + size_t grp_dset_count = 0; /* # of open objects: groups & datasets */ + size_t nt_attr_count = 0; /* # of opened named datatypes + opened attributes */ + hid_t *obj_ids = NULL; /* List of ids */ + hid_t *obj_apl_ids = NULL; /* List of access property lists */ + H5G_loc_t *obj_glocs = NULL; /* Group location of the object */ + H5O_loc_t *obj_olocs = NULL; /* Object location */ + H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ + size_t u; /* Local index variable */ + bool setup = false; /* Boolean flag to indicate whether SWMR setting is enabled */ + H5VL_connector_t *vol_connector = NULL; /* VOL connector for the file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3816,7 +3811,7 @@ H5F__start_swmr_write(H5F_t *f) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "invalid object identifier"); /* Get the (top) connector for the ID */ - vol_connector = vol_obj->connector; + vol_connector = H5VL_OBJ_CONNECTOR(vol_obj); } /* end if */ /* Gather information about opened objects (groups, datasets) in the file */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 7acd243aa82..275fa378f0e 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -311,9 +311,8 @@ struct H5F_shared_t { uint64_t rfic_flags; /* Relaxed file integrity check (RFIC) flags */ /* Cached VOL connector ID & info */ - hid_t vol_id; /* ID of VOL connector for the container */ - const H5VL_class_t *vol_cls; /* Pointer to VOL connector class for the container */ - void *vol_info; /* Copy of VOL connector info for container */ + H5VL_connector_t *vol_conn; /* VOL connector for the container */ + void *vol_info; /* Copy of VOL connector info for container */ /* File space allocation information */ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index a4ad311a189..5d9f5011927 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -98,7 +98,6 @@ typedef struct H5F_t H5F_t; #define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr) #define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) #define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) -#define H5F_VOL_CLS(F) ((F)->shared->vol_cls) #define H5F_VOL_OBJ(F) ((F)->vol_obj) #define H5F_USE_FILE_LOCKING(F) ((F)->shared->use_file_locking) #define H5F_RFIC_FLAGS(F) ((F)->shared->rfic_flags) @@ -163,7 +162,6 @@ typedef struct H5F_t H5F_t; #define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F)) #define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) #define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) -#define H5F_VOL_CLS(F) (H5F_get_vol_cls(F)) #define H5F_VOL_OBJ(F) (H5F_get_vol_obj(F)) #define H5F_USE_FILE_LOCKING(F) (H5F_get_use_file_locking(F)) #define H5F_RFIC_FLAGS(F) (H5F_get_rfic_flags(F)) @@ -527,10 +525,9 @@ H5_DLL bool H5F_get_point_of_no_return(const H5F_t *f); H5_DLL bool H5F_get_null_fsm_addr(const H5F_t *f); H5_DLL bool H5F_get_min_dset_ohdr(const H5F_t *f); H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, bool minimize); -H5_DLL const H5VL_class_t *H5F_get_vol_cls(const H5F_t *f); -H5_DLL H5VL_object_t *H5F_get_vol_obj(const H5F_t *f); -H5_DLL bool H5F_get_use_file_locking(const H5F_t *f); -H5_DLL uint64_t H5F_get_rfic_flags(const H5F_t *f); +H5_DLL H5VL_object_t *H5F_get_vol_obj(const H5F_t *f); +H5_DLL bool H5F_get_use_file_locking(const H5F_t *f); +H5_DLL uint64_t H5F_get_rfic_flags(const H5F_t *f); /* Functions than retrieve values set/cached from the superblock/FCPL */ H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 63c96d531d0..526795a9870 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -1280,26 +1280,6 @@ H5F_get_null_fsm_addr(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->null_fsm_addr) } /* end H5F_get_null_fsm_addr() */ -/*------------------------------------------------------------------------- - * Function: H5F_get_vol_cls - * - * Purpose: Get the VOL class for the file - * - * Return: VOL class pointer for file, can't fail - * - *------------------------------------------------------------------------- - */ -const H5VL_class_t * -H5F_get_vol_cls(const H5F_t *f) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - assert(f); - assert(f->shared); - - FUNC_LEAVE_NOAPI(f->shared->vol_cls) -} /* end H5F_get_vol_cls */ - /*------------------------------------------------------------------------- * Function: H5F_get_vol_obj * diff --git a/src/H5G.c b/src/H5G.c index 88d617afc3d..8919788c809 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -184,7 +184,7 @@ H5G__create_api_common(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group"); /* Get an ID for the group */ - if ((ret_value = H5VL_register(H5I_GROUP, grp, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get ID for group handle"); done: @@ -266,7 +266,7 @@ H5Gcreate_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE9(__func__, "*s*sIui*siiii", app_file, app_func, app_line, loc_id, name, lcpl_id, gcpl_id, gapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -349,7 +349,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group"); /* Get an ID for the group */ - if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get ID for group handle"); done: @@ -399,7 +399,7 @@ H5G__open_api_common(hid_t loc_id, const char *name, hid_t gapl_id, void **token HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group"); /* Register an ID for the group */ - if ((ret_value = H5VL_register(H5I_GROUP, grp, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group"); done: @@ -472,7 +472,7 @@ H5Gopen_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, gapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -624,7 +624,7 @@ H5Gget_info_async(const char *app_file, const char *app_func, unsigned app_line, /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE6(__func__, "*s*sIui*GIi", app_file, app_func, app_line, loc_id, group_info, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -730,7 +730,7 @@ H5Gget_info_by_name_async(const char *app_file, const char *app_func, unsigned a /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE8(__func__, "*s*sIui*s*GIii", app_file, app_func, app_line, loc_id, name, group_info, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -841,7 +841,7 @@ H5Gget_info_by_idx_async(const char *app_file, const char *app_func, unsigned ap /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE11(__func__, "*s*sIui*sIiIoh*GIii", app_file, app_func, app_line, loc_id, group_name, idx_type, order, n, group_info, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -893,11 +893,11 @@ H5Gclose(hid_t group_id) herr_t H5Gclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t group_id, hid_t es_id) { - H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - H5VL_t *connector = NULL; /* VOL connector */ - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -913,7 +913,7 @@ H5Gclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* Increase connector's refcount, so it doesn't get closed if closing * the group closes the file */ - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); H5VL_conn_inc_rc(connector); /* Point at token for operation to set up */ @@ -929,7 +929,7 @@ H5Gclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, group_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert token into event set"); diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 5f9ad63756e..287f609553e 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -214,7 +214,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group"); /* Get an ID for the group */ - if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group"); done: @@ -271,7 +271,7 @@ H5Gopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group"); /* Get an ID for the group */ - if ((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_GROUP, grp, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group"); done: @@ -312,10 +312,10 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new if (type == H5L_TYPE_HARD) { H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t new_loc_params; - H5VL_object_t tmp_vol_obj; /* Temporary object */ /* Set up new location struct */ new_loc_params.type = H5VL_OBJECT_BY_NAME; + new_loc_params.obj_type = H5I_get_type(cur_loc_id); new_loc_params.loc_data.loc_by_name.name = new_name; new_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; @@ -323,20 +323,16 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new if (NULL == (vol_obj = H5VL_vol_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier"); - /* Construct a temporary VOL object */ - tmp_vol_obj.data = NULL; - tmp_vol_obj.connector = vol_obj->connector; - /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; - vol_cb_args.args.hard.curr_obj = vol_obj->data; + vol_cb_args.args.hard.curr_obj = H5VL_OBJ_DATA(vol_obj); vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_NAME; vol_cb_args.args.hard.curr_loc_params.obj_type = H5I_get_type(cur_loc_id); vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.name = cur_name; vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; /* Create the link through the VOL */ - if (H5VL_link_create(&vol_cb_args, &tmp_vol_obj, &new_loc_params, H5P_LINK_CREATE_DEFAULT, + if (H5VL_link_create(&vol_cb_args, vol_obj, &new_loc_params, H5P_LINK_CREATE_DEFAULT, H5P_LINK_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link"); } /* end if */ @@ -416,7 +412,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_ /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; - vol_cb_args.args.hard.curr_obj = vol_obj1->data; + vol_cb_args.args.hard.curr_obj = H5VL_OBJ_DATA(vol_obj1); vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_NAME; vol_cb_args.args.hard.curr_loc_params.obj_type = H5I_get_type(cur_loc_id); vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.name = cur_name; diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 8f9f74fd368..7bb59ea9e2f 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -233,7 +233,7 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) case H5I_BADID: case H5I_NTYPES: default: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid location ID"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid location type"); } /* end switch */ done: diff --git a/src/H5Idbg.c b/src/H5Idbg.c index 7910b1ce43d..ee963fd1823 100644 --- a/src/H5Idbg.c +++ b/src/H5Idbg.c @@ -78,6 +78,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ const H5G_name_t *path = NULL; /* Path to file object */ void *object = NULL; /* Pointer to VOL connector object */ + bool is_native; /* Whether an object using the native VOL connector */ FUNC_ENTER_PACKAGE_NOERR @@ -91,8 +92,9 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) case H5I_GROUP: { const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->u.c_object; - object = H5VL_object_data(vol_obj); - if (H5_VOL_NATIVE == vol_obj->connector->cls->value) + is_native = false; + H5VL_object_is_native(vol_obj, &is_native); + if (is_native) path = H5G_nameof(object); break; } @@ -100,8 +102,9 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) case H5I_DATASET: { const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->u.c_object; - object = H5VL_object_data(vol_obj); - if (H5_VOL_NATIVE == vol_obj->connector->cls->value) + is_native = false; + H5VL_object_is_native(vol_obj, &is_native); + if (is_native) path = H5D_nameof(object); break; } diff --git a/src/H5L.c b/src/H5L.c index 3616cb75a59..6b1e7fe9947 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -48,7 +48,7 @@ static herr_t H5L__create_soft_api_common(const char *link_target, hid_t link_lo H5VL_object_t **_vol_obj_ptr); static herr_t H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id, - void **token_ptr, H5VL_object_t **_vol_obj_ptr); + void **token_ptr, H5VL_connector_t **conn); static herr_t H5L__delete_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr); static herr_t H5L__delete_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx_type, @@ -94,7 +94,6 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *ds H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object */ H5I_type_t src_id_type = H5I_BADID, dst_id_type = H5I_BADID; herr_t ret_value = SUCCEED; /* Return value */ @@ -157,31 +156,19 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *ds /* Make sure that the VOL connectors are the same */ if (vol_obj1 && vol_obj2) { - int same_connector = 0; + htri_t same_connector; /* Check if both objects are associated with the same VOL connector */ - if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); - if (same_connector) + if ((same_connector = + H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(vol_obj1), H5VL_OBJ_CONNECTOR(vol_obj2))) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + if (!same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked"); } - /* Construct a temporary source VOL object */ - if (vol_obj1) { - tmp_vol_obj.connector = vol_obj1->connector; - tmp_vol_obj.data = vol_obj1->data; - } - else { - if (NULL == vol_obj2) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "NULL VOL object"); - - tmp_vol_obj.connector = vol_obj2->connector; - tmp_vol_obj.data = NULL; - } - /* Move the link */ - if (H5VL_link_move(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, + if (H5VL_link_move(vol_obj1, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link"); @@ -208,7 +195,6 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *ds H5VL_loc_params_t loc_params1; H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; - H5VL_object_t tmp_vol_obj; /* Temporary object */ H5I_type_t src_id_type = H5I_BADID, dst_id_type = H5I_BADID; herr_t ret_value = SUCCEED; /* Return value */ @@ -271,31 +257,19 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *ds /* Make sure that the VOL connectors are the same */ if (vol_obj1 && vol_obj2) { - int same_connector = 0; + htri_t same_connector; /* Check if both objects are associated with the same VOL connector */ - if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); - if (same_connector) + if ((same_connector = + H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(vol_obj1), H5VL_OBJ_CONNECTOR(vol_obj2))) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + if (!same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked"); } /* end if */ - /* Construct a temporary source VOL object */ - if (vol_obj1) { - tmp_vol_obj.connector = vol_obj1->connector; - tmp_vol_obj.data = vol_obj1->data; - } /* end if */ - else { - if (NULL == vol_obj2) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "NULL VOL object pointer"); - - tmp_vol_obj.connector = vol_obj2->connector; - tmp_vol_obj.data = NULL; - } /* end else */ - /* Copy the link */ - if (H5VL_link_copy(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, + if (H5VL_link_copy(vol_obj1, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to copy link"); @@ -427,7 +401,7 @@ H5Lcreate_soft_async(const char *app_file, const char *app_func, unsigned app_li /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE9(__func__, "*s*sIu*si*siii", app_file, app_func, app_line, link_target, link_loc_id, link_name, lcpl_id, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -447,15 +421,11 @@ H5Lcreate_soft_async(const char *app_file, const char *app_func, unsigned app_li */ static herr_t H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t link_loc_id, const char *link_name, - hid_t lcpl_id, hid_t lapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr) + hid_t lcpl_id, hid_t lapl_id, void **token_ptr, H5VL_connector_t **connector) { - H5VL_object_t *curr_vol_obj = NULL; /* Object of cur_loc_id */ - H5VL_object_t *link_vol_obj = NULL; /* Object of link_loc_id */ - H5VL_object_t tmp_vol_obj; /* Temporary object */ - H5VL_object_t *tmp_vol_obj_ptr = &tmp_vol_obj; /* Ptr to temporary object */ - H5VL_object_t **tmp_vol_obj_ptr_ptr = - (_vol_obj_ptr ? _vol_obj_ptr : &tmp_vol_obj_ptr); /* Ptr to ptr to temporary object */ - H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ + H5VL_object_t *curr_vol_obj = NULL; /* Object of cur_loc_id */ + H5VL_object_t *link_vol_obj = NULL; /* Object of link_loc_id */ + H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ H5VL_loc_params_t link_loc_params; /* Location parameters for link_loc_id object access */ herr_t ret_value = SUCCEED; /* Return value */ @@ -486,12 +456,6 @@ H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t link_l if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, true) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info"); - /* Set up new location struct */ - link_loc_params.type = H5VL_OBJECT_BY_NAME; - link_loc_params.obj_type = H5I_get_type(link_loc_id); - link_loc_params.loc_data.loc_by_name.name = link_name; - link_loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - if (H5L_SAME_LOC != cur_loc_id) /* Get the current location object */ if (NULL == (curr_vol_obj = H5VL_vol_object(cur_loc_id))) @@ -503,34 +467,26 @@ H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t link_l /* Make sure that the VOL connectors are the same */ if (curr_vol_obj && link_vol_obj) { - int same_connector = 0; + htri_t same_connector; /* Check if both objects are associated with the same VOL connector */ - if (H5VL_cmp_connector_cls(&same_connector, curr_vol_obj->connector->cls, - link_vol_obj->connector->cls) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); - if (same_connector) + if ((same_connector = H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(curr_vol_obj), + H5VL_OBJ_CONNECTOR(link_vol_obj))) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + if (!same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked"); } /* end if */ - /* Construct a temporary VOL object */ - if (curr_vol_obj) - (*tmp_vol_obj_ptr_ptr)->connector = curr_vol_obj->connector; - else { - if (NULL == link_vol_obj) - HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, FAIL, "NULL VOL object pointer"); - - (*tmp_vol_obj_ptr_ptr)->connector = link_vol_obj->connector; - } /* end else */ - if (link_vol_obj) - (*tmp_vol_obj_ptr_ptr)->data = link_vol_obj->data; - else - (*tmp_vol_obj_ptr_ptr)->data = NULL; + /* Set up new location struct */ + link_loc_params.type = H5VL_OBJECT_BY_NAME; + link_loc_params.obj_type = (link_vol_obj ? H5I_get_type(link_loc_id) : H5I_get_type(cur_loc_id)); + link_loc_params.loc_data.loc_by_name.name = link_name; + link_loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; - vol_cb_args.args.hard.curr_obj = (curr_vol_obj ? curr_vol_obj->data : NULL); + vol_cb_args.args.hard.curr_obj = (curr_vol_obj ? H5VL_OBJ_DATA(curr_vol_obj) : NULL); vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_NAME; vol_cb_args.args.hard.curr_loc_params.obj_type = (H5L_SAME_LOC != cur_loc_id ? H5I_get_type(cur_loc_id) : H5I_BADID); @@ -538,10 +494,14 @@ H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t link_l vol_cb_args.args.hard.curr_loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Create the link */ - if (H5VL_link_create(&vol_cb_args, *tmp_vol_obj_ptr_ptr, &link_loc_params, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) + if (H5VL_link_create(&vol_cb_args, (link_vol_obj ? link_vol_obj : curr_vol_obj), &link_loc_params, + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, token_ptr) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link"); + /* Set the connector to use for async operations */ + if (connector) + *connector = (link_vol_obj ? H5VL_OBJ_CONNECTOR(link_vol_obj) : H5VL_OBJ_CONNECTOR(curr_vol_obj)); + done: FUNC_LEAVE_NOAPI(ret_value) } /* H5L__create_hard_api_common() */ @@ -595,11 +555,10 @@ H5Lcreate_hard_async(const char *app_file, const char *app_func, unsigned app_li const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id, hid_t es_id) { - H5VL_object_t vol_obj; /* Object for loc_id */ - H5VL_object_t *vol_obj_ptr = &vol_obj; /* Pointer to object for loc_id */ - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for operation */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -609,13 +568,14 @@ H5Lcreate_hard_async(const char *app_file, const char *app_func, unsigned app_li /* Creates a hard link asynchronously */ if (H5L__create_hard_api_common(cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id, token_ptr, - &vol_obj_ptr) < 0) + &connector) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to asynchronously create hard link"); + assert(connector); /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj_ptr->connector, token, + if (H5ES_insert(es_id, connector, token, H5ARG_TRACE10(__func__, "*s*sIui*si*siii", app_file, app_func, app_line, cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -897,7 +857,7 @@ H5Ldelete_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1019,7 +979,7 @@ H5Ldelete_by_idx_async(const char *app_file, const char *app_func, unsigned app_ /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIui*sIiIohii", app_file, app_func, app_line, loc_id, group_name, idx_type, order, n, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1250,7 +1210,7 @@ H5Lexists_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, /* clang-format off */ H5ARG_TRACE8(__func__, "*s*sIui*s*bii", app_file, app_func, app_line, loc_id, name, exists, lapl_id, es_id)) < 0) /* clang-format on */ @@ -1690,7 +1650,7 @@ H5Literate_async(const char *app_file, const char *app_func, unsigned app_line, /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIuiIiIo*hLI*xi", app_file, app_func, app_line, group_id, idx_type, order, idx_p, op, op_data, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_LINK, H5E_CANTINSERT, FAIL, "can't insert token into event set"); diff --git a/src/H5M.c b/src/H5M.c index bb8b4d9882b..c55f881d6d5 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -253,7 +253,7 @@ H5M__create_api_common(hid_t loc_id, const char *name, hid_t key_type_id, hid_t map = map_args.create.map; /* Get an ID for the map */ - if ((ret_value = H5VL_register(H5I_MAP, map, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_MAP, map, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register map handle"); done: @@ -339,7 +339,7 @@ H5Mcreate_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE11(__func__, "*s*sIui*siiiiii", app_file, app_func, app_line, loc_id, name, key_type_id, val_type_id, lcpl_id, mcpl_id, mapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -420,7 +420,7 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id map = map_args.create.map; /* Get an ID for the map */ - if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_MAP, map, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register map"); done: @@ -484,7 +484,7 @@ H5M__open_api_common(hid_t loc_id, const char *name, hid_t mapl_id, void **token map = map_args.open.map; /* Register an ID for the map */ - if ((ret_value = H5VL_register(H5I_MAP, map, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_MAP, map, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register map ID"); done: @@ -564,7 +564,7 @@ H5Mopen_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, mapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -620,11 +620,11 @@ H5Mclose(hid_t map_id) herr_t H5Mclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t map_id, hid_t es_id) { - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - H5VL_object_t *vol_obj = NULL; /* VOL object of dset_id */ - H5VL_t *connector = NULL; /* VOL connector */ - herr_t ret_value = SUCCEED; /* Return value */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + H5VL_object_t *vol_obj = NULL; /* VOL object of dset_id */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -640,7 +640,7 @@ H5Mclose_async(const char *app_file, const char *app_func, unsigned app_line, hi if (H5ES_NONE != es_id) { /* Increase connector's refcount, so it doesn't get closed if closing * the dataset closes the file */ - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); H5VL_conn_inc_rc(connector); /* Point at token for operation to set up */ @@ -656,7 +656,7 @@ H5Mclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, map_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_MAP, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1017,7 +1017,7 @@ H5Mput_async(const char *app_file, const char *app_func, unsigned app_line, hid_ /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIuii*xi*xii", app_file, app_func, app_line, map_id, key_mem_type_id, key, val_mem_type_id, value, dxpl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_MAP, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1149,7 +1149,7 @@ H5Mget_async(const char *app_file, const char *app_func, unsigned app_line, hid_ /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIuii*xi*xii", app_file, app_func, app_line, map_id, key_mem_type_id, key, val_mem_type_id, value, dxpl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_MAP, H5E_CANTINSERT, FAIL, "can't insert token into event set"); diff --git a/src/H5O.c b/src/H5O.c index 39887b51a29..14118668d03 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -119,7 +119,7 @@ H5O__open_api_common(hid_t loc_id, const char *name, hid_t lapl_id, void **token HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object"); /* Get an atom for the object */ - if ((ret_value = H5VL_register(opened_type, opened_obj, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle"); done: @@ -193,7 +193,7 @@ H5Oopen_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -242,7 +242,7 @@ H5O__open_by_idx_api_common(hid_t loc_id, const char *group_name, H5_index_t idx HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object"); /* Get an ID for the object */ - if ((ret_value = H5VL_register(opened_type, opened_obj, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); done: @@ -320,7 +320,7 @@ H5Oopen_by_idx_async(const char *app_file, const char *app_func, unsigned app_li /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIui*sIiIohii", app_file, app_func, app_line, loc_id, group_name, idx_type, order, n, lapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -376,7 +376,7 @@ H5Oopen_by_token(hid_t loc_id, H5O_token_t token) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object"); /* Register the object's ID */ - if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); done: @@ -573,7 +573,7 @@ H5Ocopy_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIui*si*siii", app_file, app_func, app_line, src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -674,7 +674,7 @@ H5Oflush_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, obj_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -775,7 +775,7 @@ H5Orefresh_async(const char *app_file, const char *app_func, unsigned app_line, /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, oid, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -807,7 +807,6 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid { H5VL_object_t *vol_obj1 = NULL; /* object of obj_id */ H5VL_object_t *vol_obj2 = NULL; /* object of new_loc_id */ - H5VL_object_t tmp_vol_obj; /* Temporary object */ H5VL_link_create_args_t vol_cb_args; /* Arguments to VOL callback */ H5VL_loc_params_t new_loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -855,29 +854,26 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid /* Make sure that the VOL connectors are the same */ if (vol_obj1 && vol_obj2) { - int same_connector = 0; + htri_t same_connector; /* Check if both objects are associated with the same VOL connector */ - if (H5VL_cmp_connector_cls(&same_connector, vol_obj1->connector->cls, vol_obj2->connector->cls) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); - if (same_connector) + if ((same_connector = + H5VL_conn_same_class(H5VL_OBJ_CONNECTOR(vol_obj1), H5VL_OBJ_CONNECTOR(vol_obj2))) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + if (!same_connector) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked"); } /* end if */ - /* Construct a temporary VOL object */ - tmp_vol_obj.data = vol_obj2->data; - tmp_vol_obj.connector = vol_obj1->connector; - /* Set up VOL callback arguments */ vol_cb_args.op_type = H5VL_LINK_CREATE_HARD; - vol_cb_args.args.hard.curr_obj = vol_obj1->data; + vol_cb_args.args.hard.curr_obj = H5VL_OBJ_DATA(vol_obj1); vol_cb_args.args.hard.curr_loc_params.type = H5VL_OBJECT_BY_SELF; vol_cb_args.args.hard.curr_loc_params.obj_type = H5I_get_type(obj_id); /* Create a link to the object */ - if (H5VL_link_create(&vol_cb_args, &tmp_vol_obj, &new_loc_params, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if (H5VL_link_create(&vol_cb_args, vol_obj2, &new_loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link"); done: @@ -1193,7 +1189,7 @@ H5Oget_info_by_name_async(const char *app_file, const char *app_func, unsigned a /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE9(__func__, "*s*sIui*s*!Iuii", app_file, app_func, app_line, loc_id, name, oinfo, fields, lapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -1925,11 +1921,11 @@ H5Oclose(hid_t object_id) herr_t H5Oclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t object_id, hid_t es_id) { - H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - H5VL_t *connector = NULL; /* VOL connector */ - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - herr_t ret_value = SUCCEED; + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -1945,7 +1941,7 @@ H5Oclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* Increase connector's refcount, so it doesn't get closed if closing * this object ID closes the file */ - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); H5VL_conn_inc_rc(connector); /* Point at token for operation to set up */ @@ -1961,7 +1957,7 @@ H5Oclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, object_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert token into event set"); diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 37a3996c1e6..f56480392e4 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -378,7 +378,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object"); /* Register the object's ID */ - if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); done: diff --git a/src/H5Oflush.c b/src/H5Oflush.c index dd11c25e7ca..7bd38f0eb89 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -194,11 +194,11 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) /* If the file is opened with write access, no need to perform refresh actions. */ if (!(H5F_INTENT(oloc->file) & H5F_ACC_RDWR)) { - H5G_loc_t obj_loc; - H5O_loc_t obj_oloc; - H5G_name_t obj_path; - H5O_shared_t cached_H5O_shared; - H5VL_t *connector = NULL; + H5G_loc_t obj_loc; + H5O_loc_t obj_oloc; + H5G_name_t obj_path; + H5O_shared_t cached_H5O_shared; + H5VL_connector_t *connector = NULL; /* Hold a copy of the object's file pointer, since closing the object will * invalidate the file pointer in the oloc. @@ -227,27 +227,28 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) */ if (NULL == (vol_obj = H5VL_vol_object(oid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier"); - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); /* Bump the number of references on the VOL connector. * If you don't do this, VDS refreshes can accidentally close the connector. */ - connector->nrefs++; + H5VL_conn_inc_rc(connector); /* Close object & evict its metadata */ if (H5O__refresh_metadata_close(oloc, &obj_loc, oid) < 0) { - connector->nrefs--; + H5VL_conn_dec_rc(connector); HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object"); } /* Re-open the object, re-fetching its metadata */ if (H5O_refresh_metadata_reopen(oid, H5P_DEFAULT, &obj_loc, connector, false) < 0) { - connector->nrefs--; + H5VL_conn_dec_rc(connector); HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object"); } /* Restore the number of references on the VOL connector */ - connector->nrefs--; + if (H5VL_conn_dec_rc(connector) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count for connector"); /* Restore important datatype state */ if (H5I_get_type(oid) == H5I_DATATYPE) @@ -347,7 +348,7 @@ H5O__refresh_metadata_close(H5O_loc_t *oloc, H5G_loc_t *obj_loc, hid_t oid) *------------------------------------------------------------------------- */ herr_t -H5O_refresh_metadata_reopen(hid_t oid, hid_t apl_id, H5G_loc_t *obj_loc, H5VL_t *vol_connector, +H5O_refresh_metadata_reopen(hid_t oid, hid_t apl_id, H5G_loc_t *obj_loc, H5VL_connector_t *vol_connector, bool start_swmr) { void *object = NULL; /* Object for this operation */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 3f0ff07cd13..a5eebcf3985 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -980,8 +980,8 @@ H5_DLL herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t H5_DLL herr_t H5O_flush(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid); -H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, hid_t apl_id, H5G_loc_t *obj_loc, H5VL_t *vol_driver, - bool start_swmr); +H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, hid_t apl_id, H5G_loc_t *obj_loc, + H5VL_connector_t *connector, bool start_swmr); /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 03a65fb7870..f726f63e7b4 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -5748,20 +5748,20 @@ H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size /*out*/, unsigned *min_ *------------------------------------------------------------------------- */ herr_t -H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) +H5P_set_vol(H5P_genplist_t *plist, H5VL_connector_t *connector, const void *vol_info) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if (NULL == H5I_object_verify(vol_id, H5I_VOL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + /* Sanity check */ + assert(connector); if (true == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { H5VL_connector_prop_t vol_prop; /* Property for VOL ID & info */ /* Prepare the VOL connector property */ - vol_prop.connector_id = vol_id; + vol_prop.connector = connector; vol_prop.connector_info = vol_info; /* Set the connector ID & info property */ @@ -5822,19 +5822,20 @@ H5P_reset_vol_class(const H5P_genclass_t *pclass, const H5VL_connector_prop_t *v herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info) { - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) /* Check arguments */ if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if (NULL == H5I_object_verify(new_vol_id, H5I_VOL)) + if (NULL == (connector = H5I_object_verify(new_vol_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file VOL ID"); /* Set the VOL */ - if (H5P_set_vol(plist, new_vol_id, new_vol_info) < 0) + if (H5P_set_vol(plist, connector, new_vol_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL"); done: @@ -5875,12 +5876,9 @@ H5Pget_vol_id(hid_t plist_id, hid_t *vol_id /*out*/) if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector info"); - /* Increment the VOL ID's ref count */ - if (H5I_inc_ref(connector_prop.connector_id, true) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID"); - - /* Set the connector ID to return */ - *vol_id = connector_prop.connector_id; + /* Register an ID for the connector */ + if ((*vol_id = H5VL_conn_register(connector_prop.connector)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector"); } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -5922,17 +5920,11 @@ H5Pget_vol_info(hid_t plist_id, void **vol_info /*out*/) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property"); /* Copy connector info, if it exists */ - if (connector_prop.connector_info) { - H5VL_class_t *connector; /* Pointer to connector */ - - /* Retrieve the connector for the ID */ - if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID"); - + if (connector_prop.connector_info) /* Allocate and copy connector info */ - if (H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0) + if (H5VL_copy_connector_info(connector_prop.connector, &new_connector_info, + connector_prop.connector_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed"); - } /* end if */ /* Set the connector info */ *vol_info = new_connector_info; @@ -5993,7 +5985,7 @@ H5Pget_vol_cap_flags(hid_t plist_id, uint64_t *cap_flags) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property"); /* Query the capability flags */ - if (H5VL_get_cap_flags(&connector_prop, cap_flags) < 0) + if (H5VL_conn_prop_get_cap_flags(&connector_prop, cap_flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector capability flags"); } else @@ -6021,8 +6013,8 @@ H5P__facc_vol_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size FUNC_ENTER_PACKAGE - /* Make copy of the VOL connector */ - if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + /* Make copy of the VOL connector property */ + if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector"); done: @@ -6050,8 +6042,8 @@ H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, /* Sanity check */ assert(value); - /* Make copy of VOL connector ID & info */ - if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + /* Make copy of VOL connector property */ + if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector"); done: @@ -6079,8 +6071,8 @@ H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, /* Sanity check */ assert(value); - /* Make copy of VOL connector */ - if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + /* Make copy of VOL connector property */ + if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector"); done: @@ -6105,8 +6097,8 @@ H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, FUNC_ENTER_PACKAGE - /* Free the VOL connector ID & info */ - if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + /* Free the VOL connector property */ + if (H5VL_conn_prop_free((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector"); done: @@ -6130,8 +6122,8 @@ H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, FUNC_ENTER_PACKAGE - /* Make copy of VOL connector */ - if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + /* Make copy of VOL connector property */ + if (H5VL_conn_prop_copy((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector"); done: @@ -6152,48 +6144,25 @@ H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, *------------------------------------------------------------------------- */ static int -H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) +H5P__facc_vol_cmp(const void *_prop1, const void *_prop2, size_t H5_ATTR_UNUSED size) { - const H5VL_connector_prop_t *info1 = - (const H5VL_connector_prop_t *)_info1; /* Create local aliases for values */ - const H5VL_connector_prop_t *info2 = (const H5VL_connector_prop_t *)_info2; - H5VL_class_t *cls1, *cls2; /* connector class for each property */ - int cmp_value = 0; /* Value from comparison */ + const H5VL_connector_prop_t *prop1 = + (const H5VL_connector_prop_t *)_prop1; /* Create local aliases for values */ + const H5VL_connector_prop_t *prop2 = (const H5VL_connector_prop_t *)_prop2; herr_t H5_ATTR_NDEBUG_UNUSED status; /* Status from info comparison */ int ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ - assert(info1); - assert(info2); + assert(prop1); + assert(prop2); assert(size == sizeof(H5VL_connector_prop_t)); - /* Compare connectors */ - if (NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->connector_id))) - HGOTO_DONE(-1); - if (NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->connector_id))) - HGOTO_DONE(1); - status = H5VL_cmp_connector_cls(&cmp_value, cls1, cls2); + /* Compare properties */ + status = H5VL_conn_prop_cmp(&ret_value, prop1, prop2); assert(status >= 0); - if (cmp_value != 0) - HGOTO_DONE(cmp_value); - /* At this point, we should be able to assume that we are dealing with - * the same connector class struct (or a copies of the same class struct) - */ - - /* Use one of the classes (cls1) info comparison routines to compare the - * info objects - */ - assert(cls1->info_cls.cmp == cls2->info_cls.cmp); - status = H5VL_cmp_connector_info(cls1, &cmp_value, info1->connector_info, info2->connector_info); - assert(status >= 0); - - /* Set return value */ - ret_value = cmp_value; - -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_cmp() */ @@ -6214,8 +6183,8 @@ H5P__facc_vol_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, FUNC_ENTER_PACKAGE - /* Free the VOL connector */ - if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + /* Free the VOL connector property */ + if (H5VL_conn_prop_free((H5VL_connector_prop_t *)value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector"); done: diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 36c24579959..0671ed5952e 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -153,6 +153,7 @@ H5_DLLVAR const struct H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ /* Forward declaration of structs used below */ struct H5O_fill_t; struct H5T_t; +struct H5VL_connector_t; struct H5VL_connector_prop_t; /* Package initialization routines */ @@ -188,7 +189,7 @@ H5_DLL herr_t H5P_set_driver_by_name(H5P_genplist_t *plist, const char *dri const char *driver_config, bool app_ref); H5_DLL herr_t H5P_set_driver_by_value(H5P_genplist_t *plist, H5FD_class_value_t driver_value, const char *driver_config, bool app_ref); -H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); +H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, struct H5VL_connector_t *connector, const void *vol_info); H5_DLL herr_t H5P_reset_vol_class(const H5P_genclass_t *pclass, const struct H5VL_connector_prop_t *vol_prop); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); diff --git a/src/H5R.c b/src/H5R.c index ed589801db9..b532bf7426d 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -535,7 +535,7 @@ H5R__open_object_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id, vo HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token"); /* Register object */ - if ((ret_value = H5VL_register(opened_type, opened_obj, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); done: @@ -598,7 +598,7 @@ H5Ropen_object_async(const char *app_file, const char *app_func, unsigned app_li /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIu*Rriii", app_file, app_func, app_line, ref_ptr, rapl_id, oapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -672,7 +672,7 @@ H5R__open_region_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id, vo HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token"); /* Register object */ - if ((opened_obj_id = H5VL_register(opened_type, opened_obj, (*vol_obj_ptr)->connector, false)) < 0) + if ((opened_obj_id = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), false)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); /* Get VOL object object */ @@ -764,7 +764,7 @@ H5Ropen_region_async(const char *app_file, const char *app_func, unsigned app_li /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIu*Rriii", app_file, app_func, app_line, ref_ptr, rapl_id, oapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -840,7 +840,7 @@ H5R__open_attr_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id, void HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token"); /* Register object */ - if ((opened_obj_id = H5VL_register(opened_type, opened_obj, (*vol_obj_ptr)->connector, false)) < 0) + if ((opened_obj_id = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), false)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); /* Verify access property list and set up collective metadata if appropriate */ @@ -863,7 +863,7 @@ H5R__open_attr_api_common(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id, void H5R_REF_ATTRNAME((const H5R_ref_priv_t *)ref_ptr)); /* Register the attribute and get an ID for it */ - if ((ret_value = H5VL_register(H5I_ATTR, opened_attr, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_ATTR, opened_attr, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute handle"); done: @@ -932,7 +932,7 @@ H5Ropen_attr_async(const char *app_file, const char *app_func, unsigned app_line /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIu*Rriii", app_file, app_func, app_line, ref_ptr, rapl_id, aapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 154d47cb508..921693770a2 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -368,7 +368,7 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token"); /* Register object */ - if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); done: @@ -641,7 +641,7 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *re HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token"); /* Register object */ - if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(opened_type, opened_obj, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); done: diff --git a/src/H5Rint.c b/src/H5Rint.c index 35fc78d83e7..cbfa910d247 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -484,12 +484,12 @@ H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) /* Open the file */ /* (Must open file read-write to allow for object modifications) */ - if (NULL == (new_file = H5VL_file_open(&connector_prop, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, fapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if (NULL == (new_file = H5VL_file_open(connector_prop.connector, H5R_REF_FILENAME(ref), H5F_ACC_RDWR, + fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file"); /* Get an ID for the file */ - if ((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, true)) < 0) + if ((ret_value = H5VL_register(H5I_FILE, new_file, connector_prop.connector, true)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file handle"); /* Get the file object */ diff --git a/src/H5T.c b/src/H5T.c index 754f3762155..1728132cf6b 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -2087,12 +2087,12 @@ H5Tclose(hid_t type_id) herr_t H5Tclose_async(const char *app_file, const char *app_func, unsigned app_line, hid_t type_id, hid_t es_id) { - H5T_t *dt; /* Pointer to datatype to close */ - void *token = NULL; /* Request token for async operation */ - void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ - H5VL_object_t *vol_obj = NULL; /* VOL object of dset_id */ - H5VL_t *connector = NULL; /* VOL connector */ - herr_t ret_value = SUCCEED; /* Return value */ + H5T_t *dt; /* Pointer to datatype to close */ + void *token = NULL; /* Request token for async operation */ + void **token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + H5VL_object_t *vol_obj = NULL; /* VOL object of dset_id */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2110,7 +2110,7 @@ H5Tclose_async(const char *app_file, const char *app_func, unsigned app_line, hi if (H5ES_NONE != es_id) { /* Increase connector's refcount, so it doesn't get closed if closing * the dataset closes the file */ - connector = vol_obj->connector; + connector = H5VL_OBJ_CONNECTOR(vol_obj); H5VL_conn_inc_rc(connector); /* Point at token for operation to set up */ @@ -2123,7 +2123,7 @@ H5Tclose_async(const char *app_file, const char *app_func, unsigned app_line, hi /* If a token was created, add the token to the event set */ if (NULL != token) - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE5(__func__, "*s*sIuii", app_file, app_func, app_line, type_id, es_id)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "can't insert token into event set"); diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 92853c63058..d30ddd00bd4 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -59,7 +59,7 @@ static herr_t H5T__commit_api_common(hid_t loc_id, const char *name, hid_t type_ static hid_t H5T__open_api_common(hid_t loc_id, const char *name, hid_t tapl_id, void **token_ptr, H5VL_object_t **_vol_obj_ptr); static H5T_t *H5T__open_oid(const H5G_loc_t *loc); -static herr_t H5T_destruct_datatype(void *datatype, H5VL_t *vol_connector); +static herr_t H5T_destruct_datatype(void *datatype, H5VL_connector_t *vol_connector); /*********************/ /* Public Variables */ @@ -77,12 +77,6 @@ static herr_t H5T_destruct_datatype(void *datatype, H5VL_t *vol_connector); /* Local Variables */ /*******************/ -/* Declare a free list to manage the H5VL_t struct */ -H5FL_EXTERN(H5VL_t); - -/* Declare a free list to manage the H5VL_object_t struct */ -H5FL_EXTERN(H5VL_object_t); - /*------------------------------------------------------------------------- * Function: H5T__commit_api_common * @@ -142,7 +136,7 @@ H5T__commit_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype"); /* Set up VOL object */ - if (NULL == (new_obj = H5VL_create_object(data, (*vol_obj_ptr)->connector))) + if (NULL == (new_obj = H5VL_create_object(data, H5VL_OBJ_CONNECTOR(*vol_obj_ptr)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't create VOL object for committed datatype"); /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ @@ -210,7 +204,7 @@ H5Tcommit_async(const char *app_file, const char *app_func, unsigned app_line, h /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE10(__func__, "*s*sIui*siiiii", app_file, app_func, app_line, loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id, es_id)) < 0) /* clang-format on */ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "can't insert token into event set"); @@ -358,7 +352,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype"); /* Setup VOL object */ - if (NULL == (new_obj = H5VL_create_object(dt, vol_obj->connector))) + if (NULL == (new_obj = H5VL_create_object(dt, H5VL_OBJ_CONNECTOR(vol_obj)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't create VOL object for committed datatype"); /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ @@ -657,13 +651,13 @@ H5T__open_api_common(hid_t loc_id, const char *name, hid_t tapl_id, void **token HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype"); /* Register the type and return the ID */ - if ((ret_value = H5VL_register(H5I_DATATYPE, dt, (*vol_obj_ptr)->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_DATATYPE, dt, H5VL_OBJ_CONNECTOR(*vol_obj_ptr), true)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype"); done: /* Cleanup on error */ if (H5I_INVALID_HID == ret_value) - if (dt && H5T_destruct_datatype(dt, (*vol_obj_ptr)->connector) < 0) + if (dt && H5T_destruct_datatype(dt, H5VL_OBJ_CONNECTOR(*vol_obj_ptr)) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype"); FUNC_LEAVE_NOAPI(ret_value) @@ -730,7 +724,7 @@ H5Topen_async(const char *app_file, const char *app_func, unsigned app_line, hid /* If a token was created, add the token to the event set */ if (NULL != token) /* clang-format off */ - if (H5ES_insert(es_id, vol_obj->connector, token, + if (H5ES_insert(es_id, H5VL_OBJ_CONNECTOR(vol_obj), token, H5ARG_TRACE7(__func__, "*s*sIui*sii", app_file, app_func, app_line, loc_id, name, tapl_id, es_id)) < 0) { /* clang-format on */ if (H5I_dec_app_ref_always_close(ret_value) < 0) @@ -1276,7 +1270,7 @@ H5T_construct_datatype(H5VL_object_t *vol_obj) *------------------------------------------------------------------------- */ static herr_t -H5T_destruct_datatype(void *datatype, H5VL_t *vol_connector) +H5T_destruct_datatype(void *datatype, H5VL_connector_t *vol_connector) { H5VL_object_t *vol_obj = NULL; herr_t ret_value = FAIL; diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 3483597346e..2545858f760 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -126,7 +126,7 @@ H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype"); /* Set up VOL object */ - if (NULL == (new_obj = H5VL_create_object(data, vol_obj->connector))) + if (NULL == (new_obj = H5VL_create_object(data, H5VL_OBJ_CONNECTOR(vol_obj)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't create VOL object for committed datatype"); /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ @@ -176,7 +176,7 @@ H5Topen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype"); /* Register the type and return the ID */ - if ((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, true)) < 0) + if ((ret_value = H5VL_register(H5I_DATATYPE, dt, H5VL_OBJ_CONNECTOR(vol_obj), true)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype"); done: diff --git a/src/H5VL.c b/src/H5VL.c index 9eb4ab36daf..c3e737a1942 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -35,7 +35,7 @@ #include "H5VLpkg.h" /* Virtual Object Layer */ /* VOL connectors */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ /* Local Macros */ @@ -81,7 +81,8 @@ hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -92,10 +93,20 @@ H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list"); /* Register connector */ - if ((ret_value = H5VL__register_connector_by_class(cls, true, vipl_id)) < 0) + if (NULL == (connector = H5VL__register_connector_by_class(cls, vipl_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL class"); + + /* Get ID for connector */ + if ((ret_value = H5I_register(H5I_VOL, connector, true)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector"); done: + if (ret_value < 0) + /* Decrement refcount on connector */ + if (connector && H5VL_conn_dec_rc(connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector"); + FUNC_LEAVE_API(ret_value) } /* end H5VLregister_connector() */ @@ -119,7 +130,8 @@ H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id) hid_t H5VLregister_connector_by_name(const char *name, hid_t vipl_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -137,10 +149,20 @@ H5VLregister_connector_by_name(const char *name, hid_t vipl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list"); /* Register connector */ - if ((ret_value = H5VL__register_connector_by_name(name, true, vipl_id)) < 0) + if (NULL == (connector = H5VL__register_connector_by_name(name, vipl_id))) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector"); + /* Get ID for connector */ + if ((ret_value = H5I_register(H5I_VOL, connector, true)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); + done: + if (ret_value < 0) + /* Decrement refcount on connector */ + if (connector && H5VL_conn_dec_rc(connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector"); + FUNC_LEAVE_API(ret_value) } /* end H5VLregister_connector_by_name() */ @@ -164,7 +186,8 @@ H5VLregister_connector_by_name(const char *name, hid_t vipl_id) hid_t H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -180,10 +203,20 @@ H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL initialize property list"); /* Register connector */ - if ((ret_value = H5VL__register_connector_by_value(value, true, vipl_id)) < 0) + if (NULL == (connector = H5VL__register_connector_by_value(value, vipl_id))) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector"); + /* Get ID for connector */ + if ((ret_value = H5I_register(H5I_VOL, connector, true)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); + done: + if (ret_value < 0) + /* Decrement refcount on connector */ + if (connector && H5VL_conn_dec_rc(connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector"); + FUNC_LEAVE_API(ret_value) } /* end H5VLregister_connector_by_value() */ @@ -256,13 +289,18 @@ H5VLis_connector_registered_by_value(H5VL_class_value_t connector_value) hid_t H5VLget_connector_id(hid_t obj_id) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) - /* Get connector ID */ - if ((ret_value = H5VL__get_connector_id(obj_id, true)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id"); + /* Get the underlying VOL object for the object ID */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier"); + + /* Register an ID for the connector */ + if ((ret_value = H5VL_conn_register(vol_obj->connector)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "can't get VOL ID"); done: FUNC_LEAVE_API(ret_value) @@ -285,15 +323,26 @@ H5VLget_connector_id(hid_t obj_id) hid_t H5VLget_connector_id_by_name(const char *name) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) /* Get connector ID with this name */ - if ((ret_value = H5VL__get_connector_id_by_name(name, true)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id"); + if (NULL == (connector = H5VL__get_connector_by_name(name))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector"); + + /* Get ID for connector */ + if ((ret_value = H5I_register(H5I_VOL, connector, true)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); done: + if (ret_value < 0) + /* Decrement refcount on connector */ + if (connector && H5VL_conn_dec_rc(connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector"); + FUNC_LEAVE_API(ret_value) } /* end H5VLget_connector_id_by_name() */ @@ -314,77 +363,28 @@ H5VLget_connector_id_by_name(const char *name) hid_t H5VLget_connector_id_by_value(H5VL_class_value_t connector_value) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) /* Get connector ID with this value */ - if ((ret_value = H5VL__get_connector_id_by_value(connector_value, true)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id"); - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLget_connector_id_by_value() */ + if (NULL == (connector = H5VL__get_connector_by_value(connector_value))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector"); -/*------------------------------------------------------------------------- - * Function: H5VLpeek_connector_id_by_name - * - * Purpose: Retrieves the ID for a registered VOL connector. - * - * Return: A valid VOL connector ID if a connector by that name has - * been registered. This ID is *not* owned by the caller and - * H5VLclose() should not be called. Intended for use by VOL - * connectors to find their own ID. - * - * H5I_INVALID_HID on error or if a VOL connector of that - * name has not been registered. - * - *------------------------------------------------------------------------- - */ -hid_t -H5VLpeek_connector_id_by_name(const char *name) -{ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_API(H5I_INVALID_HID) - - /* Get connector ID with this name */ - if ((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id"); + /* Get ID for connector */ + if ((ret_value = H5I_register(H5I_VOL, connector, true)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLpeek_connector_id_by_name() */ + if (ret_value < 0) + /* Decrement refcount on connector */ + if (connector && H5VL_conn_dec_rc(connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement ref count on VOL connector"); -/*------------------------------------------------------------------------- - * Function: H5VLpeek_connector_id_by_value - * - * Purpose: Retrieves the ID for a registered VOL connector. - * - * Return: A valid VOL connector ID if a connector with that value - * has been registered. This ID is *not* owned by the caller - * and H5VLclose() should not be called. Intended for use by - * VOL connectors to find their own ID. - * - * H5I_INVALID_HID on error or if a VOL connector with that - * value has not been registered. - * - *------------------------------------------------------------------------- - */ -hid_t -H5VLpeek_connector_id_by_value(H5VL_class_value_t value) -{ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_API(H5I_INVALID_HID) - - /* Get connector ID with this value */ - if ((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL id"); - -done: FUNC_LEAVE_API(ret_value) -} /* end H5VLpeek_connector_id_by_value() */ +} /* end H5VLget_connector_id_by_value() */ /*------------------------------------------------------------------------- * Function: H5VLget_connector_name @@ -406,13 +406,17 @@ H5VLpeek_connector_id_by_value(H5VL_class_value_t value) ssize_t H5VLget_connector_name(hid_t obj_id, char *name /*out*/, size_t size) { - ssize_t ret_value = -1; + H5VL_object_t *vol_obj; + ssize_t ret_value = -1; FUNC_ENTER_API(FAIL) + /* Get the object pointer */ + if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid VOL identifier"); + /* Call internal routine */ - if ((ret_value = H5VL__get_connector_name(obj_id, name, size)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get connector name"); + ret_value = (ssize_t)H5VL__get_connector_name(vol_obj->connector, name, size); done: FUNC_LEAVE_API(ret_value) @@ -462,7 +466,6 @@ H5VLclose(hid_t vol_id) * to do so are considered an error. * * Return: Success: Non-negative - * * Failure: Negative * *------------------------------------------------------------------------- @@ -470,30 +473,28 @@ H5VLclose(hid_t vol_id) herr_t H5VLunregister_connector(hid_t vol_id) { - hid_t native_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *native, *connector; + int cmp_value; /* Comparison result */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) /* Check arguments */ - if (NULL == H5I_object_verify(vol_id, H5I_VOL)) + if (NULL == (connector = H5I_object_verify(vol_id, H5I_VOL))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* For the time being, we disallow unregistering the native VOL connector */ - if (H5I_INVALID_HID == (native_id = H5VL__get_connector_id_by_name(H5VL_NATIVE_NAME, false))) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to find the native VOL connector ID"); - if (vol_id == native_id) + native = H5VL_NATIVE_conn_g; + if (H5VL_cmp_connector_cls(&cmp_value, connector->cls, native->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + if (0 == cmp_value) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "unregistering the native VOL connector is not allowed"); - /* The H5VL_class_t struct will be freed by this function */ + /* The H5VL_connector_t struct will be freed by this function */ if (H5I_dec_app_ref(vol_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector"); done: - if (native_id != H5I_INVALID_HID) - if (H5I_dec_ref(native_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement count on native_id"); - FUNC_LEAVE_API(ret_value) } /* end H5VLunregister_connector() */ @@ -514,19 +515,19 @@ H5VLunregister_connector(hid_t vol_id) herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2) { - H5VL_class_t *cls1, *cls2; /* connectors for IDs */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *conn1, *conn2; /* Connectors for IDs */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) /* Check args and get class pointers */ - if (NULL == (cls1 = (H5VL_class_t *)H5I_object_verify(connector_id1, H5I_VOL))) + if (NULL == (conn1 = H5I_object_verify(connector_id1, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); - if (NULL == (cls2 = (H5VL_class_t *)H5I_object_verify(connector_id2, H5I_VOL))) + if (NULL == (conn2 = H5I_object_verify(connector_id2, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Compare the two VOL connector classes */ - if (H5VL_cmp_connector_cls(cmp, cls1, cls2) < 0) + if (H5VL_cmp_connector_cls(cmp, conn1->cls, conn2->cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); done: @@ -674,25 +675,28 @@ H5VLobject_is_native(hid_t obj_id, hbool_t *is_native) hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id) { - H5T_t *dtype; /* unregistered type */ - H5T_t *file_type = NULL; /* copied file type */ - hid_t file_type_id = -1; /* copied file type id */ - H5VL_object_t *file_vol_obj = NULL; /* VOL object for file */ - hid_t ret_value = -1; /* Return value */ + H5T_t *dtype; /* unregistered type */ + H5T_t *file_type = NULL; /* copied file type */ + hid_t file_type_id = -1; /* copied file type id */ + H5VL_connector_t *connector; /* VOL connector */ + H5VL_object_t *file_vol_obj = NULL; /* VOL object for file */ + hid_t ret_value = -1; /* Return value */ FUNC_ENTER_API(FAIL) /* Check args */ if (!file_obj) HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "no file object supplied"); - if (NULL == (dtype = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if (NULL == (dtype = H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file VOL ID"); /* Create VOL object for file if necessary (force_conv will be true if and * only if file needs to be passed to H5T_set_loc) */ - if (H5T_GET_FORCE_CONV(dtype) && - (NULL == (file_vol_obj = H5VL_create_object_using_vol_id(H5I_FILE, file_obj, connector_id)))) - HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object"); + if (H5T_GET_FORCE_CONV(dtype)) + if (NULL == (file_vol_obj = H5VL_new_vol_obj(H5I_FILE, file_obj, connector, true))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object"); /* Copy the datatype */ if (NULL == (file_type = H5T_copy(dtype, H5T_COPY_TRANSIENT))) diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index 0e696088ebf..497e53908d5 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -50,10 +50,9 @@ * VOL connector to open a given file with. */ typedef struct H5VL_file_open_find_connector_t { - const char *filename; - const H5VL_class_t *cls; - H5VL_connector_prop_t *connector_prop; - hid_t fapl_id; + const char *filename; + const H5VL_class_t *cls; + hid_t fapl_id; } H5VL_file_open_find_connector_t; /* Typedef for common callback form of registered optional operations */ @@ -67,6 +66,12 @@ typedef herr_t (*H5VL_reg_opt_oper_t)(void *obj, const H5VL_class_t *cls, H5VL_o /********************/ /* Local Prototypes */ /********************/ +/* Helper routines */ +static herr_t H5VL__common_optional_op(hid_t id, H5I_type_t id_type, H5VL_reg_opt_oper_t reg_opt_op, + H5VL_optional_args_t *args, hid_t dxpl_id, void **req, + H5VL_object_t **_vol_obj_ptr); + +/* VOL connector callback equivalents */ static void *H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); @@ -218,17 +223,17 @@ static herr_t H5VL__optional(void *obj, const H5VL_class_t *cls, H5VL_optional_a herr_t H5VLinitialize(hid_t connector_id, hid_t vipl_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT /* Check args */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Invoke class' callback, if there is one */ - if (cls->initialize && cls->initialize(vipl_id) < 0) + if (connector->cls->initialize && connector->cls->initialize(vipl_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not initialize"); done: @@ -248,17 +253,17 @@ H5VLinitialize(hid_t connector_id, hid_t vipl_id) herr_t H5VLterminate(hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT /* Check args */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Invoke class' callback, if there is one */ - if (cls->terminate && cls->terminate() < 0) + if (connector->cls->terminate && connector->cls->terminate() < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly"); done: @@ -278,18 +283,18 @@ H5VLterminate(hid_t connector_id) herr_t H5VLget_cap_flags(hid_t connector_id, uint64_t *cap_flags /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT /* Check args */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Retrieve capability flags */ if (cap_flags) - *cap_flags = cls->cap_flags; + *cap_flags = connector->cls->cap_flags; done: FUNC_LEAVE_API_NOINIT(ret_value) @@ -308,18 +313,18 @@ H5VLget_cap_flags(hid_t connector_id, uint64_t *cap_flags /*out*/) herr_t H5VLget_value(hid_t connector_id, H5VL_class_value_t *value /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT /* Check args */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Retrieve connector value */ if (value) - *value = cls->value; + *value = connector->cls->value; done: FUNC_LEAVE_API_NOINIT(ret_value) @@ -380,7 +385,7 @@ H5VL__common_optional_op(hid_t id, H5I_type_t id_type, H5VL_reg_opt_oper_t reg_o *------------------------------------------------------------------------- */ herr_t -H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const void *src_info) +H5VL_copy_connector_info(const H5VL_connector_t *connector, void **dst_info, const void *src_info) { void *new_connector_info = NULL; /* Copy of connector info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -393,14 +398,14 @@ H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const v /* Check for actual source info */ if (src_info) { /* Allow the connector to copy or do it ourselves */ - if (connector->info_cls.copy) { - if (NULL == (new_connector_info = (connector->info_cls.copy)(src_info))) + if (connector->cls->info_cls.copy) { + if (NULL == (new_connector_info = (connector->cls->info_cls.copy)(src_info))) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "connector info copy callback failed"); } /* end if */ - else if (connector->info_cls.size > 0) { - if (NULL == (new_connector_info = H5MM_malloc(connector->info_cls.size))) + else if (connector->cls->info_cls.size > 0) { + if (NULL == (new_connector_info = H5MM_malloc(connector->cls->info_cls.size))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "connector info allocation failed"); - H5MM_memcpy(new_connector_info, src_info, connector->info_cls.size); + H5MM_memcpy(new_connector_info, src_info, connector->cls->info_cls.size); } /* end else-if */ else HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "no way to copy connector info"); @@ -426,17 +431,17 @@ H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const v herr_t H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Check args and get VOL connector */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Copy the VOL connector's info object */ - if (H5VL_copy_connector_info(cls, dst_vol_info, src_vol_info) < 0) + if (H5VL_copy_connector_info(connector, dst_vol_info, src_vol_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy VOL connector info object"); done: @@ -457,7 +462,8 @@ H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_i *------------------------------------------------------------------------- */ herr_t -H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const void *info1, const void *info2) +H5VL_cmp_connector_info(const H5VL_connector_t *connector, int *cmp_value, const void *info1, + const void *info2) { herr_t ret_value = SUCCEED; /* Return value */ @@ -485,13 +491,13 @@ H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const voi * if there is a callback, otherwise just compare the info objects as * memory buffers */ - if (connector->info_cls.cmp) { - if ((connector->info_cls.cmp)(cmp_value, info1, info2) < 0) + if (connector->cls->info_cls.cmp) { + if ((connector->cls->info_cls.cmp)(cmp_value, info1, info2) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector info"); } /* end if */ else { - assert(connector->info_cls.size > 0); - *cmp_value = memcmp(info1, info2, connector->info_cls.size); + assert(connector->cls->info_cls.size > 0); + *cmp_value = memcmp(info1, info2, connector->cls->info_cls.size); } /* end else */ done: @@ -516,18 +522,18 @@ H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const voi herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, const void *info2) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Check args and get VOL connector */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Compare the two VOL connector info objects */ if (cmp) - H5VL_cmp_connector_info(cls, cmp, info1, info2); + H5VL_cmp_connector_info(connector, cmp, info1, info2); done: FUNC_LEAVE_API(ret_value) @@ -544,26 +550,21 @@ H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, const vo *------------------------------------------------------------------------- */ herr_t -H5VL_free_connector_info(hid_t connector_id, const void *info) +H5VL_free_connector_info(const H5VL_connector_t *connector, const void *info) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ - assert(connector_id > 0); - - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + assert(connector); /* Only free info object, if it's non-NULL */ if (info) { /* Allow the connector to free info or do it ourselves */ - if (cls->info_cls.free) { + if (connector->cls->info_cls.free) { /* Cast through uintptr_t to de-const memory */ - if ((cls->info_cls.free)((void *)(uintptr_t)info) < 0) + if ((connector->cls->info_cls.free)((void *)(uintptr_t)info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector info free request failed"); } else @@ -587,12 +588,17 @@ H5VL_free_connector_info(hid_t connector_id, const void *info) herr_t H5VLfree_connector_info(hid_t connector_id, void *info) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT + /* Check args and get VOL connector */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + /* Free the VOL connector info object */ - if (H5VL_free_connector_info(connector_id, info) < 0) + if (H5VL_free_connector_info(connector, info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object"); done: @@ -618,15 +624,15 @@ H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) /* Only serialize info object, if it's non-NULL */ if (info) { - H5VL_class_t *cls; /* VOL connector's class struct */ + H5VL_connector_t *connector; /* VOL connector */ - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Check args and get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Allow the connector to serialize info */ - if (cls->info_cls.to_str) { - if ((cls->info_cls.to_str)(info, str) < 0) + if (connector->cls->info_cls.to_str) { + if ((connector->cls->info_cls.to_str)(info, str) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize connector info"); } /* end if */ else @@ -639,6 +645,40 @@ H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLconnector_info_to_str() */ +/*------------------------------------------------------------------------- + * Function: H5VL__connector_str_to_info + * + * Purpose: Deserializes a string into a connector's info object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__connector_str_to_info(const char *str, H5VL_connector_t *connector, void **info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Only deserialize string, if it's non-NULL */ + if (str) { + /* Allow the connector to deserialize info */ + if (connector->cls->info_cls.from_str) { + if ((connector->cls->info_cls.from_str)(str, info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize connector info"); + } /* end if */ + else + *info = NULL; + } /* end if */ + else + *info = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__connector_str_to_info() */ + /*--------------------------------------------------------------------------- * Function: H5VLconnector_str_to_info * @@ -652,12 +692,17 @@ H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) herr_t H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT + /* Check args and get VOL connector */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + /* Call internal routine */ - if (H5VL__connector_str_to_info(str, connector_id, info) < 0) + if (H5VL__connector_str_to_info(str, connector, info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info"); done: @@ -677,20 +722,20 @@ H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info /*out void * H5VLget_object(void *obj, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT /* Check args */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Check for 'get_object' callback in connector */ - if (cls->wrap_cls.get_object) - ret_value = (cls->wrap_cls.get_object)(obj); + if (connector->cls->wrap_cls.get_object) + ret_value = (connector->cls->wrap_cls.get_object)(obj); else ret_value = obj; @@ -698,44 +743,6 @@ H5VLget_object(void *obj, hid_t connector_id) FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLget_object */ -/*------------------------------------------------------------------------- - * Function: H5VL_get_wrap_ctx - * - * Purpose: Retrieve the VOL object wrapping context for a connector - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(connector); - assert(obj); - assert(wrap_ctx); - - /* Allow the connector to copy or do it ourselves */ - if (connector->wrap_cls.get_wrap_ctx) { - /* Sanity check */ - assert(connector->wrap_cls.free_wrap_ctx); - - /* Invoke connector's callback */ - if ((connector->wrap_cls.get_wrap_ctx)(obj, wrap_ctx) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector wrap context callback failed"); - } /* end if */ - else - *wrap_ctx = NULL; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_get_wrap_ctx() */ - /*--------------------------------------------------------------------------- * Function: H5VLget_wrap_ctx * @@ -752,18 +759,26 @@ H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx) herr_t H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Check args and get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); - /* Get the VOL connector's object wrapper */ - if (H5VL_get_wrap_ctx(cls, obj, wrap_ctx) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to retrieve VOL connector object wrap context"); + /* Allow the connector to wrap */ + if (connector->cls->wrap_cls.get_wrap_ctx) { + /* Sanity check */ + assert(connector->cls->wrap_cls.free_wrap_ctx); + + /* Invoke cls's callback */ + if ((connector->cls->wrap_cls.get_wrap_ctx)(obj, wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector wrap context callback failed"); + } /* end if */ + else + *wrap_ctx = NULL; done: FUNC_LEAVE_API_NOINIT(ret_value) @@ -780,20 +795,20 @@ H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx /*out*/) *------------------------------------------------------------------------- */ void * -H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, H5I_type_t obj_type) +H5VL_wrap_object(const H5VL_class_t *cls, void *wrap_ctx, void *obj, H5I_type_t obj_type) { void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Sanity checks */ - assert(connector); + assert(cls); assert(obj); /* Only wrap object if there's a wrap context */ if (wrap_ctx) { /* Ask the connector to wrap the object */ - if (NULL == (ret_value = (connector->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx))) + if (NULL == (ret_value = (cls->wrap_cls.wrap_object)(obj, obj_type, wrap_ctx))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object"); } /* end if */ else @@ -816,19 +831,19 @@ H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, H5I_t void * H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Wrap the object */ - if (NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj, obj_type))) + if (NULL == (ret_value = H5VL_wrap_object(connector->cls, wrap_ctx, obj, obj_type))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object"); done: @@ -846,20 +861,20 @@ H5VLwrap_object(void *obj, H5I_type_t obj_type, hid_t connector_id, void *wrap_c *------------------------------------------------------------------------- */ void * -H5VL_unwrap_object(const H5VL_class_t *connector, void *obj) +H5VL_unwrap_object(const H5VL_class_t *cls, void *obj) { void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Sanity checks */ - assert(connector); + assert(cls); assert(obj); /* Only unwrap object if there's an unwrap callback */ - if (connector->wrap_cls.wrap_object) { + if (cls->wrap_cls.wrap_object) { /* Ask the connector to unwrap the object */ - if (NULL == (ret_value = (connector->wrap_cls.unwrap_object)(obj))) + if (NULL == (ret_value = (cls->wrap_cls.unwrap_object)(obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't unwrap object"); } /* end if */ else @@ -882,56 +897,25 @@ H5VL_unwrap_object(const H5VL_class_t *connector, void *obj) void * H5VLunwrap_object(void *obj, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Unwrap the object */ - if (NULL == (ret_value = H5VL_unwrap_object(cls, obj))) + if (NULL == (ret_value = H5VL_unwrap_object(connector->cls, obj))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to unwrap object"); done: FUNC_LEAVE_API_NOINIT(ret_value) } /* H5VLunwrap_object */ -/*------------------------------------------------------------------------- - * Function: H5VL_free_wrap_ctx - * - * Purpose: Free object wrapping context for a connector - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - assert(connector); - - /* Only free wrap context, if it's non-NULL */ - if (wrap_ctx) { - /* Free the connector's object wrapping context */ - if ((connector->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed"); - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_free_wrap_ctx() */ - /*--------------------------------------------------------------------------- * Function: H5VLfree_wrap_ctx * @@ -945,18 +929,20 @@ H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx) herr_t H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Check args and get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); - /* Release the VOL connector's object wrapper */ - if (H5VL_free_wrap_ctx(cls, wrap_ctx) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context"); + /* Only free wrap context, if it's non-NULL */ + if (wrap_ctx) + /* Free the connector's object wrapping context */ + if ((connector->cls->wrap_cls.free_wrap_ctx)(wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed"); done: FUNC_LEAVE_API_NOINIT(ret_value) @@ -1045,20 +1031,20 @@ H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_ hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, type_id, space_id, acpl_id, - aapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__attr_create(obj, loc_params, connector->cls, name, type_id, space_id, + acpl_id, aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create attribute"); done: @@ -1146,19 +1132,19 @@ void * H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__attr_open(obj, loc_params, cls, name, aapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__attr_open(obj, loc_params, connector->cls, name, aapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open attribute"); done: @@ -1242,19 +1228,19 @@ H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, void *buf, hid_t herr_t H5VLattr_read(void *obj, hid_t connector_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__attr_read(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + if (H5VL__attr_read(obj, connector->cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read attribute"); done: @@ -1340,19 +1326,19 @@ herr_t H5VLattr_write(void *obj, hid_t connector_id, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__attr_write(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + if (H5VL__attr_write(obj, connector->cls, mem_type_id, buf, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write attribute"); done: @@ -1436,21 +1422,21 @@ H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_args_t *args, hid_t dx herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); if (NULL == args) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument struct"); /* Call the corresponding internal VOL routine */ - if (H5VL__attr_get(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__attr_get(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get attribute information"); done: @@ -1540,20 +1526,20 @@ herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_attr_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ /* (Must return value from callback, for iterators) */ - if ((ret_value = H5VL__attr_specific(obj, loc_params, cls, args, dxpl_id, req)) < 0) + if ((ret_value = H5VL__attr_specific(obj, loc_params, connector->cls, args, dxpl_id, req)) < 0) HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute 'specific' callback"); done: @@ -1640,20 +1626,20 @@ herr_t H5VLattr_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ /* (Must return value from callback, for iterators) */ - if ((ret_value = H5VL__attr_optional(obj, cls, args, dxpl_id, req)) < 0) + if ((ret_value = H5VL__attr_optional(obj, connector->cls, args, dxpl_id, req)) < 0) HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute attribute optional callback"); done: @@ -1782,19 +1768,19 @@ H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) herr_t H5VLattr_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__attr_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__attr_close(obj, connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close attribute"); done: @@ -1887,20 +1873,20 @@ H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connect hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__dataset_create(obj, loc_params, cls, name, lcpl_id, type_id, space_id, - dcpl_id, dapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__dataset_create(obj, loc_params, connector->cls, name, lcpl_id, type_id, + space_id, dcpl_id, dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create dataset"); done: @@ -1988,19 +1974,20 @@ void * H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__dataset_open(obj, loc_params, cls, name, dapl_id, dxpl_id, req))) + if (NULL == + (ret_value = H5VL__dataset_open(obj, loc_params, connector->cls, name, dapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open dataset"); done: @@ -2042,7 +2029,7 @@ H5VL__dataset_read(size_t count, void *obj[], const H5VL_class_t *cls, hid_t mem * * Purpose: Reads data from dataset through the VOL. This is like * H5VL_dataset_read, but takes an array of void * for the - * objects and a class pointer instead of an array of + * objects and a connector pointer instead of an array of * H5VL_object_t. This allows us to avoid allocating and * copying an extra array (of H5VL_object_ts). * @@ -2052,8 +2039,8 @@ H5VL__dataset_read(size_t count, void *obj[], const H5VL_class_t *cls, hid_t mem *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_read(size_t count, void *obj[], H5VL_t *connector, hid_t mem_type_id[], hid_t mem_space_id[], - hid_t file_space_id[], hid_t dxpl_id, void *buf[], void **req) +H5VL_dataset_read(size_t count, void *obj[], H5VL_connector_t *connector, hid_t mem_type_id[], + hid_t mem_space_id[], hid_t file_space_id[], hid_t dxpl_id, void *buf[], void **req) { bool vol_wrapper_set = false; /* Whether the VOL object wrapping context was set up */ H5VL_object_t tmp_vol_obj; /* Temporary VOL object for setting VOL wrapper */ @@ -2099,13 +2086,13 @@ herr_t H5VLdataset_read(size_t count, void *obj[], hid_t connector_id, hid_t mem_type_id[], hid_t mem_space_id[], hid_t file_space_id[], hid_t dxpl_id, void *buf[], void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj array not provided"); for (i = 1; i < count; i++) @@ -2119,11 +2106,12 @@ H5VLdataset_read(size_t count, void *obj[], hid_t connector_id, hid_t mem_type_i HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file_space_id array not provided"); if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf array not provided"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_read(count, obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if (H5VL__dataset_read(count, obj, connector->cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, + req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read dataset"); done: @@ -2165,7 +2153,7 @@ H5VL__dataset_write(size_t count, void *obj[], const H5VL_class_t *cls, hid_t me * * Purpose: Writes data from dataset through the VOL. This is like * H5VL_dataset_write, but takes an array of void * for the - * objects and a class pointer instead of an array of + * objects and a connector pointer instead of an array of * H5VL_object_t. This allows us to avoid allocating and * copying an extra array (of H5VL_object_ts). * @@ -2175,8 +2163,8 @@ H5VL__dataset_write(size_t count, void *obj[], const H5VL_class_t *cls, hid_t me *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_write(size_t count, void *obj[], H5VL_t *connector, hid_t mem_type_id[], hid_t mem_space_id[], - hid_t file_space_id[], hid_t dxpl_id, const void *buf[], void **req) +H5VL_dataset_write(size_t count, void *obj[], H5VL_connector_t *connector, hid_t mem_type_id[], + hid_t mem_space_id[], hid_t file_space_id[], hid_t dxpl_id, const void *buf[], void **req) { bool vol_wrapper_set = false; /* Whether the VOL object wrapping context was set up */ H5VL_object_t tmp_vol_obj; /* Temporary VOL object for setting VOL wrapper */ @@ -2222,13 +2210,13 @@ herr_t H5VLdataset_write(size_t count, void *obj[], hid_t connector_id, hid_t mem_type_id[], hid_t mem_space_id[], hid_t file_space_id[], hid_t dxpl_id, const void *buf[], void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - size_t i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj array not provided"); for (i = 1; i < count; i++) @@ -2242,11 +2230,12 @@ H5VLdataset_write(size_t count, void *obj[], hid_t connector_id, hid_t mem_type_ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file_space_id array not provided"); if (NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf array not provided"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_write(count, obj, cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, req) < 0) + if (H5VL__dataset_write(count, obj, connector->cls, mem_type_id, mem_space_id, file_space_id, dxpl_id, + buf, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write dataset"); done: @@ -2332,19 +2321,19 @@ herr_t H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_get(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__dataset_get(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute dataset get callback"); done: @@ -2431,19 +2420,19 @@ herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_specific(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__dataset_specific(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback"); done: @@ -2529,19 +2518,19 @@ herr_t H5VLdataset_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_optional(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__dataset_optional(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback"); done: @@ -2677,19 +2666,19 @@ H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) herr_t H5VLdataset_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__dataset_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__dataset_close(obj, connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close dataset"); done: @@ -2780,20 +2769,20 @@ H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connec hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__datatype_commit(obj, loc_params, cls, name, type_id, lcpl_id, tcpl_id, - tapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__datatype_commit(obj, loc_params, connector->cls, name, type_id, lcpl_id, + tcpl_id, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to commit datatype"); done: @@ -2881,19 +2870,20 @@ void * H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__datatype_open(obj, loc_params, cls, name, tapl_id, dxpl_id, req))) + if (NULL == + (ret_value = H5VL__datatype_open(obj, loc_params, connector->cls, name, tapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open datatype"); done: @@ -2979,19 +2969,19 @@ herr_t H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__datatype_get(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__datatype_get(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute datatype get callback"); done: @@ -3078,19 +3068,19 @@ herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__datatype_specific(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__datatype_specific(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback"); done: @@ -3220,19 +3210,19 @@ herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__datatype_optional(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__datatype_optional(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback"); done: @@ -3262,7 +3252,7 @@ H5VLdatatype_optional_op(const char *app_file, const char *app_func, unsigned ap FUNC_ENTER_API(FAIL) /* Check args */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); /* Set up request token pointer for asynchronous operation */ @@ -3362,19 +3352,19 @@ H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) herr_t H5VLdatatype_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__datatype_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__datatype_close(obj, connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close datatype"); done: @@ -3428,20 +3418,15 @@ H5VL__file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid *------------------------------------------------------------------------- */ void * -H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fcpl_id, +H5VL_file_create(const H5VL_connector_t *connector, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) { - H5VL_class_t *cls; /* VOL Class structure for callback info */ - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - /* Get the connector's class */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); - /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__file_create(connector->cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed"); done: @@ -3464,23 +3449,19 @@ H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, { H5P_genplist_t *plist; /* Property list pointer */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_class_t *cls; /* VOL connector's class struct */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT /* Get the VOL info from the fapl */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list"); if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info"); - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); - /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__file_create(connector_prop.connector->cls, name, flags, fcpl_id, fapl_id, + dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create file"); done: @@ -3535,13 +3516,16 @@ H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t *------------------------------------------------------------------------- */ static herr_t -H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_info, void *op_data) +H5VL__file_open_find_connector_cb(H5PL_type_t H5_ATTR_UNUSED plugin_type, + const void H5_ATTR_UNUSED *plugin_info, void *op_data) { H5VL_file_open_find_connector_t *udata = (H5VL_file_open_find_connector_t *)op_data; H5VL_file_specific_args_t vol_cb_args; /* Arguments to VOL callback */ - const H5VL_class_t *cls = (const H5VL_class_t *)plugin_info; + H5VL_connector_t *connector = NULL; + const H5VL_class_t *cls = (const H5VL_class_t *)plugin_info; H5P_genplist_t *fapl_plist; H5P_genplist_t *fapl_plist_copy; + herr_t status; bool is_accessible = false; /* Whether file is accessible */ hid_t connector_id = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; @@ -3551,27 +3535,21 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in assert(udata); assert(udata->filename); - assert(udata->connector_prop); assert(cls); assert(plugin_type == H5PL_TYPE_VOL); - /* Silence compiler */ - (void)plugin_type; - - udata->cls = cls; - /* Attempt to register plugin as a VOL connector */ - if ((connector_id = H5VL__register_connector_by_class(cls, true, H5P_VOL_INITIALIZE_DEFAULT)) < 0) + if (NULL == (connector = H5VL__register_connector_by_class(cls, H5P_VOL_INITIALIZE_DEFAULT))) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5_ITER_ERROR, "unable to register VOL connector"); /* Setup FAPL with registered VOL connector */ - if (NULL == (fapl_plist = (H5P_genplist_t *)H5I_object_verify(udata->fapl_id, H5I_GENPROP_LST))) + if (NULL == (fapl_plist = H5I_object_verify(udata->fapl_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "not a property list"); if ((fapl_id = H5P_copy_plist(fapl_plist, true)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy fapl"); - if (NULL == (fapl_plist_copy = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST))) + if (NULL == (fapl_plist_copy = H5I_object_verify(fapl_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "not a property list"); - if (H5P_set_vol(fapl_plist_copy, connector_id, NULL) < 0) + if (H5P_set_vol(fapl_plist_copy, connector, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5_ITER_ERROR, "can't set VOL connector on fapl"); /* Set up VOL callback arguments */ @@ -3580,32 +3558,28 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in vol_cb_args.args.is_accessible.fapl_id = fapl_id; vol_cb_args.args.is_accessible.accessible = &is_accessible; - if (H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5_ITER_ERROR, "error when checking for accessible HDF5 file"); + H5E_PAUSE_ERRORS + { + status = H5VL_file_specific(NULL, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL); + } + H5E_RESUME_ERRORS - if (is_accessible) { + if (status >= 0 && is_accessible) { /* If the file was accessible with the current VOL connector, return * the FAPL with that VOL connector set on it. */ - - /* Modify 'connector_prop' to point to the VOL connector that - * was actually used to open the file, rather than the original - * VOL connector that was requested. - */ - udata->connector_prop->connector_id = connector_id; - udata->connector_prop->connector_info = NULL; - udata->fapl_id = fapl_id; + udata->cls = cls; ret_value = H5_ITER_STOP; } done: - if (ret_value != H5_ITER_STOP) { + if (connector && H5I_dec_app_ref(connector_id) < 0) + HDONE_ERROR(H5E_ID, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close VOL connector ID"); + + if (ret_value != H5_ITER_STOP) if (fapl_id >= 0 && H5I_dec_app_ref(fapl_id) < 0) HDONE_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close fapl"); - if (connector_id >= 0 && H5I_dec_app_ref(connector_id) < 0) - HDONE_ERROR(H5E_ID, H5E_CANTCLOSEOBJ, H5_ITER_ERROR, "can't close VOL connector ID"); - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__file_open_find_connector_cb() */ @@ -3624,20 +3598,15 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in *------------------------------------------------------------------------- */ void * -H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fapl_id, - hid_t dxpl_id, void **req) +H5VL_file_open(H5VL_connector_t *connector, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req) { - H5VL_class_t *cls; /* VOL Class structure for callback info */ - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - /* Get the connector's class */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); - /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) { + if (NULL == (ret_value = H5VL__file_open(connector->cls, name, flags, fapl_id, dxpl_id, req))) { bool is_default_conn = true; /* Opening the file failed - Determine whether we should search @@ -3645,16 +3614,15 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned * to attempt to open the file with. This only occurs if the default * VOL connector was used for the initial file open attempt. */ - H5VL__is_default_conn(fapl_id, connector_prop->connector_id, &is_default_conn); + H5VL__is_default_conn(fapl_id, connector, &is_default_conn); if (is_default_conn) { H5VL_file_open_find_connector_t find_connector_ud; herr_t iter_ret; - find_connector_ud.connector_prop = connector_prop; - find_connector_ud.filename = name; - find_connector_ud.cls = NULL; - find_connector_ud.fapl_id = fapl_id; + find_connector_ud.filename = name; + find_connector_ud.cls = NULL; + find_connector_ud.fapl_id = fapl_id; iter_ret = H5PL_iterate(H5PL_ITER_TYPE_VOL, H5VL__file_open_find_connector_cb, (void *)&find_connector_ud); @@ -3663,13 +3631,8 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned "failed to iterate over available VOL connector plugins"); else if (iter_ret) { /* If one of the available VOL connector plugins is - * able to open the file, clear the error stack from any - * previous file open failures and then open the file. - * Otherwise, if no VOL connectors are available, throw - * error from original file open failure. + * able to open the file, open the file with it. */ - H5E_clear_stack(); - if (NULL == (ret_value = H5VL__file_open(find_connector_ud.cls, name, flags, find_connector_ud.fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, @@ -3677,6 +3640,9 @@ H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned find_connector_ud.cls->name); } else + /* Otherwise, if no VOL connectors are available, throw + * error from original file open failure. + */ HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed"); } /* end if */ else @@ -3702,23 +3668,19 @@ H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, vo { H5P_genplist_t *plist; /* Property list pointer */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_class_t *cls; /* VOL connector's class struct */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT /* Get the VOL info from the fapl */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list"); if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info"); - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); - /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) + if (NULL == + (ret_value = H5VL__file_open(connector_prop.connector->cls, name, flags, fapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open file"); done: @@ -3802,19 +3764,19 @@ H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_args_t *args, hid_t dx herr_t H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__file_get(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__file_get(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute file get callback"); done: @@ -3886,14 +3848,13 @@ H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args } /* Get the VOL info from the FAPL */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + if (NULL == (plist = H5I_object(fapl_id))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a file access property list"); if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector info"); /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + cls = connector_prop.connector->cls; } /* end if */ /* Set wrapper info in API context, for all other operations */ else { @@ -3936,17 +3897,17 @@ herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Check args and get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__file_specific(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__file_specific(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file specific callback"); done: @@ -4031,19 +3992,19 @@ herr_t H5VLfile_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__file_optional(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__file_optional(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file optional callback"); done: @@ -4173,19 +4134,19 @@ H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) herr_t H5VLfile_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__file_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__file_close(obj, connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "unable to close file"); done: @@ -4274,20 +4235,20 @@ void * H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == - (ret_value = H5VL__group_create(obj, loc_params, cls, name, lcpl_id, gcpl_id, gapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__group_create(obj, loc_params, connector->cls, name, lcpl_id, gcpl_id, + gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create group"); done: @@ -4375,19 +4336,19 @@ void * H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__group_open(obj, loc_params, cls, name, gapl_id, dxpl_id, req))) + if (NULL == (ret_value = H5VL__group_open(obj, loc_params, connector->cls, name, gapl_id, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open group"); done: @@ -4471,19 +4432,19 @@ H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_args_t *args, hid_t herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__group_get(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__group_get(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute group get callback"); done: @@ -4569,19 +4530,19 @@ herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__group_specific(obj, cls, args, dxpl_id, req) < 0) + if (H5VL__group_specific(obj, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback"); done: @@ -4669,20 +4630,20 @@ herr_t H5VLgroup_optional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ /* (Must return value from callback, for iterators) */ - if ((ret_value = H5VL__group_optional(obj, cls, args, dxpl_id, req)) < 0) + if ((ret_value = H5VL__group_optional(obj, connector->cls, args, dxpl_id, req)) < 0) HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute group optional callback"); done: @@ -4812,19 +4773,19 @@ H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) herr_t H5VLgroup_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__group_close(obj, cls, dxpl_id, req) < 0) + if (H5VL__group_close(obj, connector->cls, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close group"); done: @@ -4926,17 +4887,17 @@ herr_t H5VLlink_create(H5VL_link_create_args_t *args, void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__link_create(args, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + if (H5VL__link_create(args, obj, loc_params, connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create link"); done: @@ -5031,17 +4992,18 @@ H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__link_copy(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + if (H5VL__link_copy(src_obj, loc_params1, dst_obj, loc_params2, connector->cls, lcpl_id, lapl_id, dxpl_id, + req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object"); done: @@ -5140,17 +5102,18 @@ H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__link_move(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + if (H5VL__link_move(src_obj, loc_params1, dst_obj, loc_params2, connector->cls, lcpl_id, lapl_id, dxpl_id, + req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "unable to move object"); done: @@ -5237,19 +5200,19 @@ herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__link_get(obj, loc_params, cls, args, dxpl_id, req) < 0) + if (H5VL__link_get(obj, loc_params, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute link get callback"); done: @@ -5339,20 +5302,20 @@ herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ /* (Must return value from callback, for iterators) */ - if ((ret_value = H5VL__link_specific(obj, loc_params, cls, args, dxpl_id, req)) < 0) + if ((ret_value = H5VL__link_specific(obj, loc_params, connector->cls, args, dxpl_id, req)) < 0) HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute link specific callback"); done: @@ -5439,19 +5402,19 @@ herr_t H5VLlink_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__link_optional(obj, loc_params, cls, args, dxpl_id, req) < 0) + if (H5VL__link_optional(obj, loc_params, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback"); done: @@ -5598,19 +5561,19 @@ void * H5VLobject_open(void *obj, const H5VL_loc_params_t *params, hid_t connector_id, H5I_type_t *opened_type, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - void *ret_value = NULL; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (NULL == (ret_value = H5VL__object_open(obj, params, cls, opened_type, dxpl_id, req))) + if (NULL == (ret_value = H5VL__object_open(obj, params, connector->cls, opened_type, dxpl_id, req))) HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open object"); done: @@ -5707,20 +5670,20 @@ H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const ch const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointers */ + /* Check args and get connector pointers */ if (NULL == src_obj || NULL == dst_obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__object_copy(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, cls, - ocpypl_id, lcpl_id, dxpl_id, req) < 0) + if (H5VL__object_copy(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, + connector->cls, ocpypl_id, lcpl_id, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object"); done: @@ -5807,19 +5770,19 @@ herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__object_get(obj, loc_params, cls, args, dxpl_id, req) < 0) + if (H5VL__object_get(obj, loc_params, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute object get callback"); done: @@ -5909,20 +5872,20 @@ herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_specific_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); - /* Bypass the H5VLint layer, calling the VOL callback directly */ + /* Call the corresponding internal VOL routine */ /* (Must return value from callback, for iterators) */ - if ((ret_value = (cls->object_cls.specific)(obj, loc_params, args, dxpl_id, req)) < 0) + if ((ret_value = H5VL__object_specific(obj, loc_params, connector->cls, args, dxpl_id, req)) < 0) HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute object specific callback"); done: @@ -6009,19 +5972,19 @@ herr_t H5VLobject_optional(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__object_optional(obj, loc_params, cls, args, dxpl_id, req) < 0) + if (H5VL__object_optional(obj, loc_params, connector->cls, args, dxpl_id, req) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback"); done: @@ -6177,8 +6140,8 @@ herr_t H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT @@ -6188,12 +6151,12 @@ H5VLintrospect_get_conn_cls(void *obj, hid_t connector_id, H5VL_get_conn_lvl_t l if (NULL == conn_cls) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL conn_cls pointer"); - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__introspect_get_conn_cls(obj, cls, lvl, conn_cls) < 0) + if (H5VL__introspect_get_conn_cls(obj, connector->cls, lvl, conn_cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector class"); done: @@ -6248,8 +6211,8 @@ H5VL_introspect_get_cap_flags(const void *info, const H5VL_class_t *cls, uint64_ herr_t H5VLintrospect_get_cap_flags(const void *info, hid_t connector_id, uint64_t *cap_flags /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT @@ -6257,12 +6220,12 @@ H5VLintrospect_get_cap_flags(const void *info, hid_t connector_id, uint64_t *cap if (NULL == cap_flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL conn_cls pointer"); - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL_introspect_get_cap_flags(info, cls, cap_flags) < 0) + if (H5VL_introspect_get_cap_flags(info, connector->cls, cap_flags) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector's capability flags"); done: @@ -6351,17 +6314,17 @@ herr_t H5VLintrospect_opt_query(void *obj, hid_t connector_id, H5VL_subclass_t subcls, int opt_type, uint64_t *flags /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__introspect_opt_query(obj, cls, subcls, opt_type, flags) < 0) + if (H5VL__introspect_opt_query(obj, connector->cls, subcls, opt_type, flags) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query optional operation support"); done: @@ -6453,17 +6416,17 @@ H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5VL_request_s herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5VL_request_status_t *status /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__request_wait(req, cls, timeout, status) < 0) + if (H5VL__request_wait(req, connector->cls, timeout, status) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request"); done: @@ -6557,17 +6520,17 @@ H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void herr_t H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__request_notify(req, cls, cb, ctx) < 0) + if (H5VL__request_notify(req, connector->cls, cb, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to register notify callback for request"); done: @@ -6658,17 +6621,17 @@ H5VL_request_cancel(const H5VL_object_t *vol_obj, H5VL_request_status_t *status) herr_t H5VLrequest_cancel(void *req, hid_t connector_id, H5VL_request_status_t *status /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__request_cancel(req, cls, status) < 0) + if (H5VL__request_cancel(req, connector->cls, status) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request"); done: @@ -6761,17 +6724,17 @@ H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_args_t herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_args_t *args) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__request_specific(req, cls, args) < 0) + if (H5VL__request_specific(req, connector->cls, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback"); @@ -6865,17 +6828,17 @@ H5VL_request_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args) herr_t H5VLrequest_optional(void *req, hid_t connector_id, H5VL_optional_args_t *args) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__request_optional(req, cls, args) < 0) + if (H5VL__request_optional(req, connector->cls, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback"); @@ -6896,8 +6859,8 @@ H5VLrequest_optional(void *req, hid_t connector_id, H5VL_optional_args_t *args) herr_t H5VLrequest_optional_op(void *req, hid_t connector_id, H5VL_optional_args_t *args) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -6907,12 +6870,12 @@ H5VLrequest_optional_op(void *req, hid_t connector_id, H5VL_optional_args_t *arg if (NULL == args) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid arguments"); - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__request_optional(req, cls, args) < 0) + if (H5VL__request_optional(req, connector->cls, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute request optional callback"); done: @@ -7003,17 +6966,17 @@ H5VL_request_free(const H5VL_object_t *vol_obj) herr_t H5VLrequest_free(void *req, hid_t connector_id) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + /* Get connector pointer */ + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if (H5VL__request_free(req, cls) < 0) + if (H5VL__request_free(req, connector->cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to free request"); done: @@ -7095,19 +7058,19 @@ H5VL_blob_put(const H5VL_object_t *vol_obj, const void *buf, size_t size, void * herr_t H5VLblob_put(void *obj, hid_t connector_id, const void *buf, size_t size, void *blob_id, void *ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ + /* Get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding VOL callback */ - if (H5VL__blob_put(obj, cls, buf, size, blob_id, ctx) < 0) + if (H5VL__blob_put(obj, connector->cls, buf, size, blob_id, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "blob put failed"); done: @@ -7189,19 +7152,19 @@ H5VL_blob_get(const H5VL_object_t *vol_obj, const void *blob_id, void *buf, size herr_t H5VLblob_get(void *obj, hid_t connector_id, const void *blob_id, void *buf /*out*/, size_t size, void *ctx) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ + /* Get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding VOL callback */ - if (H5VL__blob_get(obj, cls, blob_id, buf, size, ctx) < 0) + if (H5VL__blob_get(obj, connector->cls, blob_id, buf, size, ctx) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "blob get failed"); done: @@ -7282,19 +7245,19 @@ H5VL_blob_specific(const H5VL_object_t *vol_obj, void *blob_id, H5VL_blob_specif herr_t H5VLblob_specific(void *obj, hid_t connector_id, void *blob_id, H5VL_blob_specific_args_t *args) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ + /* Get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding VOL callback */ - if (H5VL__blob_specific(obj, cls, blob_id, args) < 0) + if (H5VL__blob_specific(obj, connector->cls, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob specific operation failed"); done: @@ -7375,19 +7338,19 @@ H5VL_blob_optional(const H5VL_object_t *vol_obj, void *blob_id, H5VL_optional_ar herr_t H5VLblob_optional(void *obj, hid_t connector_id, void *blob_id, H5VL_optional_args_t *args) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Get class pointer */ + /* Get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding VOL callback */ - if (H5VL__blob_optional(obj, cls, blob_id, args) < 0) + if (H5VL__blob_optional(obj, connector->cls, blob_id, args) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "blob optional operation failed"); done: @@ -7496,21 +7459,21 @@ herr_t H5VLtoken_cmp(void *obj, hid_t connector_id, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); if (NULL == cmp_value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid cmp_value pointer"); /* Call the corresponding internal VOL routine */ - if (H5VL__token_cmp(obj, cls, token1, token2, cmp_value) < 0) + if (H5VL__token_cmp(obj, connector->cls, token1, token2, cmp_value) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "object token comparison failed"); done: @@ -7600,15 +7563,15 @@ herr_t H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_token_t *token, char **token_str) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); if (NULL == token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer"); @@ -7616,7 +7579,7 @@ H5VLtoken_to_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const H5O_t HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer"); /* Call the corresponding internal VOL routine */ - if (H5VL__token_to_str(obj, obj_type, cls, token, token_str) < 0) + if (H5VL__token_to_str(obj, obj_type, connector->cls, token, token_str) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "object token to string failed"); done: @@ -7706,15 +7669,15 @@ herr_t H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const char *token_str, H5O_token_t *token) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); if (NULL == token) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token pointer"); @@ -7722,7 +7685,7 @@ H5VLtoken_from_str(void *obj, H5I_type_t obj_type, hid_t connector_id, const cha HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid token_str pointer"); /* Call the corresponding internal VOL routine */ - if (H5VL__token_from_str(obj, obj_type, cls, token_str, token) < 0) + if (H5VL__token_from_str(obj, obj_type, connector->cls, token_str, token) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "object token from string failed"); done: @@ -7806,19 +7769,19 @@ H5VL_optional(const H5VL_object_t *vol_obj, H5VL_optional_args_t *args, hid_t dx herr_t H5VLoptional(void *obj, hid_t connector_id, H5VL_optional_args_t *args, hid_t dxpl_id, void **req /*out*/) { - H5VL_class_t *cls; /* VOL connector's class struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_connector_t *connector; /* VOL connector */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT - /* Check args and get class pointer */ + /* Check args and get connector pointer */ if (NULL == obj) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object"); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + if (NULL == (connector = H5I_object_verify(connector_id, H5I_VOL))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID"); /* Call the corresponding internal VOL routine */ - if ((ret_value = H5VL__optional(obj, cls, args, dxpl_id, req)) < 0) + if ((ret_value = H5VL__optional(obj, connector->cls, args, dxpl_id, req)) < 0) HERROR(H5E_VOL, H5E_CANTOPERATE, "unable to execute optional callback"); done: diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h index 4bf082397f8..19e5e11999c 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -1105,14 +1105,6 @@ H5_DLL void *H5VLobject(hid_t obj_id); * \ingroup H5VLDEV */ H5_DLL hid_t H5VLget_file_type(void *file_obj, hid_t connector_id, hid_t dtype_id); -/** - * \ingroup H5VLDEV - */ -H5_DLL hid_t H5VLpeek_connector_id_by_name(const char *name); -/** - * \ingroup H5VLDEV - */ -H5_DLL hid_t H5VLpeek_connector_id_by_value(H5VL_class_value_t value); /* User-defined optional operations */ H5_DLL herr_t H5VLregister_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); diff --git a/src/H5VLint.c b/src/H5VLint.c index 19a11e9b6b8..e3e2b28e1a9 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -44,8 +44,8 @@ #include "H5VLpkg.h" /* Virtual Object Layer */ /* VOL connectors */ -#include "H5VLnative.h" /* Native VOL connector */ -#include "H5VLpassthru.h" /* Pass-through VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ +#include "H5VLpassthru_private.h" /* Pass-through VOL connector */ /****************/ /* Local Macros */ @@ -66,9 +66,9 @@ * VOL connector, and the ID of the next VOL connector. */ typedef struct H5VL_wrap_ctx_t { - unsigned rc; /* Ref. count for the # of times the context was set / reset */ - H5VL_t *connector; /* VOL connector for "outermost" class to start wrap */ - void *obj_wrap_ctx; /* "wrap context" for outermost connector */ + unsigned rc; /* Ref. count for the # of times the context was set / reset */ + H5VL_connector_t *connector; /* VOL connector for "outermost" class to start wrap */ + void *obj_wrap_ctx; /* "wrap context" for outermost connector */ } H5VL_wrap_ctx_t; /* Information needed for iterating over the registered VOL connector hid_t IDs. @@ -92,12 +92,14 @@ typedef struct { /********************/ /* Local Prototypes */ /********************/ -static herr_t H5VL__free_cls(H5VL_class_t *cls, void **request); -static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data); -static void *H5VL__wrap_obj(void *obj, H5I_type_t obj_type); -static H5VL_object_t *H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, bool wrap_obj); -static void *H5VL__object(hid_t id, H5I_type_t obj_type); -static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); +static herr_t H5VL__free_cls(H5VL_class_t *cls); +static void *H5VL__wrap_obj(void *obj, H5I_type_t obj_type); +static H5VL_connector_t *H5VL__conn_create(H5VL_class_t *cls); +static herr_t H5VL__conn_find(H5PL_vol_key_t *key, H5VL_connector_t **connector); +static herr_t H5VL__conn_free(H5VL_connector_t *connector); +static herr_t H5VL__conn_free_id(H5VL_connector_t *connector, void H5_ATTR_UNUSED **request); +static void *H5VL__object(hid_t id, H5I_type_t obj_type); +static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); /*********************/ /* Package Variables */ @@ -113,17 +115,17 @@ static herr_t H5VL__free_vol_wrapper(H5VL_wrap_ctx_t *vol_wrap_ctx); /* VOL ID class */ static const H5I_class_t H5I_VOL_CLS[1] = {{ - H5I_VOL, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5VL__free_cls /* Callback routine for closing objects of this class */ + H5I_VOL, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5VL__conn_free_id /* Callback routine for closing objects of this class */ }}; /* Declare a free list to manage the H5VL_class_t struct */ H5FL_DEFINE_STATIC(H5VL_class_t); -/* Declare a free list to manage the H5VL_t struct */ -H5FL_DEFINE(H5VL_t); +/* Declare a free list to manage the H5VL_connector_t struct */ +H5FL_DEFINE_STATIC(H5VL_connector_t); /* Declare a free list to manage the H5VL_object_t struct */ H5FL_DEFINE(H5VL_object_t); @@ -131,8 +133,11 @@ H5FL_DEFINE(H5VL_object_t); /* Declare a free list to manage the H5VL_wrap_ctx_t struct */ H5FL_DEFINE_STATIC(H5VL_wrap_ctx_t); +/* List of currently active VOL connectors */ +static H5VL_connector_t *H5VL_conn_list_head_g = NULL; + /* Default VOL connector */ -static H5VL_connector_prop_t H5VL_def_conn_s = {-1, NULL}; +static H5VL_connector_prop_t H5VL_def_conn_s = {NULL, NULL}; /*------------------------------------------------------------------------- * Function: H5VL_init_phase1 @@ -212,8 +217,14 @@ H5VL_init_phase2(void) /* clang-format on */ + /* Register internal VOL connectors */ + if (H5VL__native_register() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to register native VOL connector"); + if (H5VL__passthru_register() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to register passthru VOL connector"); + /* Sanity check default VOL connector */ - assert(H5VL_def_conn_s.connector_id == (-1)); + assert(H5VL_def_conn_s.connector == NULL); assert(H5VL_def_conn_s.connector_info == NULL); /* Set up the default VOL connector in the default FAPL */ @@ -242,10 +253,10 @@ H5VL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5VL_def_conn_s.connector_id > 0) { + if (H5VL_def_conn_s.connector) { /* Release the default VOL connector */ - (void)H5VL_conn_free(&H5VL_def_conn_s); - H5VL_def_conn_s.connector_id = -1; + (void)H5VL_conn_prop_free(&H5VL_def_conn_s); + H5VL_def_conn_s.connector = NULL; H5VL_def_conn_s.connector_info = NULL; n++; } /* end if */ @@ -253,6 +264,11 @@ H5VL_term_package(void) if (H5I_nmembers(H5I_VOL) > 0) { /* Unregister all VOL connectors */ (void)H5I_clear_type(H5I_VOL, true, false); + + /* Reset internal VOL connectors' global vars */ + (void)H5VL__native_unregister(); + (void)H5VL__passthru_unregister(); + n++; } /* end if */ else { @@ -284,7 +300,7 @@ H5VL_term_package(void) *------------------------------------------------------------------------- */ static herr_t -H5VL__free_cls(H5VL_class_t *cls, void H5_ATTR_UNUSED **request) +H5VL__free_cls(H5VL_class_t *cls) { herr_t ret_value = SUCCEED; @@ -305,43 +321,6 @@ H5VL__free_cls(H5VL_class_t *cls, void H5_ATTR_UNUSED **request) FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__free_cls() */ -/*------------------------------------------------------------------------- - * Function: H5VL__get_connector_cb - * - * Purpose: Callback routine to search through registered VOLs - * - * Return: Success: H5_ITER_STOP if the class and op_data name - * members match. H5_ITER_CONT otherwise. - * Failure: Can't fail - * - *------------------------------------------------------------------------- - */ -static int -H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) -{ - H5VL_get_connector_ud_t *op_data = (H5VL_get_connector_ud_t *)_op_data; /* User data for callback */ - H5VL_class_t *cls = (H5VL_class_t *)obj; - int ret_value = H5_ITER_CONT; /* Callback return value */ - - FUNC_ENTER_PACKAGE_NOERR - - if (H5VL_GET_CONNECTOR_BY_NAME == op_data->key.kind) { - if (0 == strcmp(cls->name, op_data->key.u.name)) { - op_data->found_id = id; - ret_value = H5_ITER_STOP; - } /* end if */ - } /* end if */ - else { - assert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->key.kind); - if (cls->value == op_data->key.u.value) { - op_data->found_id = id; - ret_value = H5_ITER_STOP; - } /* end if */ - } /* end else */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__get_connector_cb() */ - /*------------------------------------------------------------------------- * Function: H5VL__set_def_conn * @@ -359,22 +338,22 @@ H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) herr_t H5VL__set_def_conn(void) { - H5P_genplist_t *def_fapl; /* Default file access property list */ - H5P_genclass_t *def_fapclass; /* Default file access property class */ - const char *env_var; /* Environment variable for default VOL connector */ - char *buf = NULL; /* Buffer for tokenizing string */ - hid_t connector_id = -1; /* VOL connector ID */ - void *vol_info = NULL; /* VOL connector info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *def_fapl; /* Default file access property list */ + H5P_genclass_t *def_fapclass; /* Default file access property class */ + const char *env_var; /* Environment variable for default VOL connector */ + char *buf = NULL; /* Buffer for tokenizing string */ + H5VL_connector_t *connector = NULL; /* VOL connector */ + void *vol_info = NULL; /* VOL connector info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Reset default VOL connector, if it's set already */ /* (Can happen during testing -QAK) */ - if (H5VL_def_conn_s.connector_id > 0) { + if (H5VL_def_conn_s.connector) { /* Release the default VOL connector */ - (void)H5VL_conn_free(&H5VL_def_conn_s); - H5VL_def_conn_s.connector_id = -1; + (void)H5VL_conn_prop_free(&H5VL_def_conn_s); + H5VL_def_conn_s.connector = NULL; H5VL_def_conn_s.connector_info = NULL; } /* end if */ @@ -403,51 +382,51 @@ H5VL__set_def_conn(void) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't check if VOL connector already registered"); else if (connector_is_registered) { /* Retrieve the ID of the already-registered VOL connector */ - if ((connector_id = H5VL__get_connector_id_by_name(tok, false)) < 0) + if (NULL == (connector = H5VL__get_connector_by_name(tok))) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector ID"); } /* end else-if */ else { /* Check for VOL connectors that ship with the library */ if (!strcmp(tok, "native")) { - connector_id = H5VL_NATIVE; - if (H5I_inc_ref(connector_id, false) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount"); + connector = H5VL_NATIVE_conn_g; + + /* Inc. refcount on connector object, so it can be uniformly released */ + H5VL_conn_inc_rc(connector); } /* end if */ else if (!strcmp(tok, "pass_through")) { - connector_id = H5VL_PASSTHRU; - if (H5I_inc_ref(connector_id, false) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount"); + connector = H5VL_PASSTHRU_conn_g; + + /* Inc. refcount on connector object, so it can be uniformly released */ + H5VL_conn_inc_rc(connector); } /* end else-if */ else { /* Register the VOL connector */ /* (NOTE: No provisions for vipl_id currently) */ - if ((connector_id = H5VL__register_connector_by_name(tok, true, H5P_VOL_INITIALIZE_DEFAULT)) < - 0) + if (NULL == (connector = H5VL__register_connector_by_name(tok, H5P_VOL_INITIALIZE_DEFAULT))) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register connector"); } /* end else */ } /* end else */ /* Was there any connector info specified in the environment variable? */ if (NULL != (tok = HDstrtok_r(NULL, "\n\r", &lasts))) - if (H5VL__connector_str_to_info(tok, connector_id, &vol_info) < 0) + if (H5VL__connector_str_to_info(tok, connector, &vol_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDECODE, FAIL, "can't deserialize connector info"); /* Set the default VOL connector */ - H5VL_def_conn_s.connector_id = connector_id; + H5VL_def_conn_s.connector = connector; H5VL_def_conn_s.connector_info = vol_info; } /* end if */ else { /* Set the default VOL connector */ - H5VL_def_conn_s.connector_id = H5_DEFAULT_VOL; + H5VL_def_conn_s.connector = H5_DEFAULT_VOL; H5VL_def_conn_s.connector_info = NULL; /* Increment the ref count on the default connector */ - if (H5I_inc_ref(H5VL_def_conn_s.connector_id, false) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "can't increment VOL connector refcount"); + H5VL_conn_inc_rc(H5VL_def_conn_s.connector); } /* end else */ /* Get default file access pclass */ - if (NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS))) + if (NULL == (def_fapclass = H5I_object(H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_VOL, H5E_BADID, FAIL, "can't find object for default file access property class ID"); /* Change the default VOL for the default file access pclass */ @@ -456,22 +435,22 @@ H5VL__set_def_conn(void) "can't set default VOL connector for default file access property class"); /* Get default file access plist */ - if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + if (NULL == (def_fapl = H5I_object(H5P_FILE_ACCESS_DEFAULT))) HGOTO_ERROR(H5E_VOL, H5E_BADID, FAIL, "can't find object for default fapl ID"); /* Change the default VOL for the default FAPL */ - if (H5P_set_vol(def_fapl, H5VL_def_conn_s.connector_id, H5VL_def_conn_s.connector_info) < 0) + if (H5P_set_vol(def_fapl, H5VL_def_conn_s.connector, H5VL_def_conn_s.connector_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set default VOL connector for default FAPL"); done: /* Clean up on error */ if (ret_value < 0) { if (vol_info) - if (H5VL_free_connector_info(connector_id, vol_info) < 0) + if (H5VL_free_connector_info(connector, vol_info) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free VOL connector info"); - if (connector_id >= 0) - /* The H5VL_class_t struct will be freed by this function */ - if (H5I_dec_ref(connector_id) < 0) + if (connector) + /* The H5VL_connector_t struct will be freed by this function */ + if (H5VL_conn_dec_rc(connector) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector"); } /* end if */ @@ -522,7 +501,7 @@ H5VL__wrap_obj(void *obj, H5I_type_t obj_type) } /* end H5VL__wrap_obj() */ /*------------------------------------------------------------------------- - * Function: H5VL__new_vol_obj + * Function: H5VL_new_vol_obj * * Purpose: Creates a new VOL object, to use when registering an ID. * @@ -531,18 +510,18 @@ H5VL__wrap_obj(void *obj, H5I_type_t obj_type) * *------------------------------------------------------------------------- */ -static H5VL_object_t * -H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, bool wrap_obj) +H5VL_object_t * +H5VL_new_vol_obj(H5I_type_t type, void *object, H5VL_connector_t *connector, bool wrap_obj) { H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ bool conn_rc_incr = false; /* Whether the VOL connector refcount has been incremented */ H5VL_object_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(NULL) /* Check arguments */ assert(object); - assert(vol_connector); + assert(connector); /* Make sure type number is valid */ if (type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE && type != H5I_FILE && @@ -552,7 +531,7 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, bool wra /* Create the new VOL object */ if (NULL == (new_vol_obj = H5FL_CALLOC(H5VL_object_t))) HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate memory for VOL object"); - new_vol_obj->connector = vol_connector; + new_vol_obj->connector = connector; if (wrap_obj) { if (NULL == (new_vol_obj->data = H5VL__wrap_obj(object, type))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't wrap library object"); @@ -562,7 +541,7 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, bool wra new_vol_obj->rc = 1; /* Bump the reference count on the VOL connector */ - H5VL_conn_inc_rc(vol_connector); + H5VL_conn_inc_rc(connector); conn_rc_incr = true; /* If this is a datatype, we have to hide the VOL object under the H5T_t pointer */ @@ -576,7 +555,7 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, bool wra done: /* Cleanup on error */ if (NULL == ret_value) { - if (conn_rc_incr && H5VL_conn_dec_rc(vol_connector) < 0) + if (conn_rc_incr && H5VL_conn_dec_rc(connector) < 0) HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector"); if (new_vol_obj) { @@ -587,12 +566,12 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, bool wra } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__new_vol_obj() */ +} /* end H5VL_new_vol_obj() */ /*------------------------------------------------------------------------- - * Function: H5VL_conn_copy + * Function: H5VL_conn_prop_copy * - * Purpose: Copy VOL connector ID & info. + * Purpose: Copy VOL connector property. * * Note: This is an "in-place" copy. * @@ -602,7 +581,7 @@ H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, bool wra *------------------------------------------------------------------------- */ herr_t -H5VL_conn_copy(H5VL_connector_prop_t *connector_prop) +H5VL_conn_prop_copy(H5VL_connector_prop_t *connector_prop) { herr_t ret_value = SUCCEED; /* Return value */ @@ -610,24 +589,17 @@ H5VL_conn_copy(H5VL_connector_prop_t *connector_prop) if (connector_prop) { /* Copy the connector ID & info, if there is one */ - if (connector_prop->connector_id > 0) { - /* Increment the reference count on connector ID and copy connector info */ - if (H5I_inc_ref(connector_prop->connector_id, false) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, - "unable to increment ref count on VOL connector ID"); + if (connector_prop->connector) { + /* Increment the reference count on connector */ + H5VL_conn_inc_rc(connector_prop->connector); /* Copy connector info, if it exists */ if (connector_prop->connector_info) { - H5VL_class_t *connector; /* Pointer to connector */ - void *new_connector_info = NULL; /* Copy of connector info */ - - /* Retrieve the connector for the ID */ - if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + void *new_connector_info = NULL; /* Copy of connector info */ /* Allocate and copy connector info */ - if (H5VL_copy_connector_info(connector, &new_connector_info, connector_prop->connector_info) < - 0) + if (H5VL_copy_connector_info(connector_prop->connector, &new_connector_info, + connector_prop->connector_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed"); /* Set the connector info to the copy */ @@ -638,12 +610,73 @@ H5VL_conn_copy(H5VL_connector_prop_t *connector_prop) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_conn_copy() */ +} /* end H5VL_conn_prop_copy() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_conn_prop_cmp + * + * Purpose: Compare two VOL connector properties. + * + * Return: positive if PROP1 is greater than PROP2, negative if PROP2 + * is greater than PROP1 and zero if PROP1 and PROP2 are equal. + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_conn_prop_cmp(int *cmp_value, const H5VL_connector_prop_t *prop1, const H5VL_connector_prop_t *prop2) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + assert(cmp_value); + assert(prop1); + assert(prop2); + + /* Fast check */ + if (prop1 == prop2) + /* Set output comparison value */ + *cmp_value = 0; + else { + H5VL_connector_t *conn1, *conn2; /* Connector for each property */ + int tmp_cmp_value = 0; /* Value from comparison */ + + /* Compare connectors' classes */ + conn1 = prop1->connector; + conn2 = prop2->connector; + if (H5VL_cmp_connector_cls(&tmp_cmp_value, conn1->cls, conn2->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + if (tmp_cmp_value != 0) + /* Set output comparison value */ + *cmp_value = tmp_cmp_value; + else { + /* At this point, we should be able to assume that we are dealing with + * the same connector class struct (or a copies of the same class struct) + */ + + /* Use one of the classes (cls1) info comparison routines to compare the + * info objects + */ + assert(conn1->cls->info_cls.cmp == conn2->cls->info_cls.cmp); + tmp_cmp_value = 0; + if (H5VL_cmp_connector_info(conn1, &tmp_cmp_value, prop1->connector_info, prop2->connector_info) < + 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector class info"); + + /* Set output comparison value */ + *cmp_value = tmp_cmp_value; + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_conn_prop_same() */ /*------------------------------------------------------------------------- - * Function: H5VL_conn_free + * Function: H5VL_conn_prop_free * - * Purpose: Free VOL connector ID & info. + * Purpose: Free VOL connector property * * Return: Success: Non-negative * Failure: Negative @@ -651,7 +684,7 @@ H5VL_conn_copy(H5VL_connector_prop_t *connector_prop) *------------------------------------------------------------------------- */ herr_t -H5VL_conn_free(const H5VL_connector_prop_t *connector_prop) +H5VL_conn_prop_free(const H5VL_connector_prop_t *connector_prop) { herr_t ret_value = SUCCEED; /* Return value */ @@ -659,23 +692,22 @@ H5VL_conn_free(const H5VL_connector_prop_t *connector_prop) if (connector_prop) { /* Free the connector info (if it exists) and decrement the ID */ - if (connector_prop->connector_id > 0) { + if (connector_prop->connector) { if (connector_prop->connector_info) /* Free the connector info */ - if (H5VL_free_connector_info(connector_prop->connector_id, connector_prop->connector_info) < - 0) + if (H5VL_free_connector_info(connector_prop->connector, connector_prop->connector_info) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object"); /* Decrement reference count for connector ID */ - if (H5I_dec_ref(connector_prop->connector_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for connector ID"); + if (H5VL_conn_dec_rc(connector_prop->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for connector"); } } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_conn_free() */ +} /* end H5VL_conn_prop_free() */ /*------------------------------------------------------------------------- * Function: H5VL_register @@ -690,7 +722,7 @@ H5VL_conn_free(const H5VL_connector_prop_t *connector_prop) *------------------------------------------------------------------------- */ hid_t -H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, bool app_ref) +H5VL_register(H5I_type_t type, void *object, H5VL_connector_t *vol_connector, bool app_ref) { H5VL_object_t *vol_obj = NULL; /* VOL object wrapper for library object */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -703,7 +735,7 @@ H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, bool app_ref /* Set up VOL object for the passed-in data */ /* (Does not wrap object, since it's from a VOL callback) */ - if (NULL == (vol_obj = H5VL__new_vol_obj(type, object, vol_connector, false))) + if (NULL == (vol_obj = H5VL_new_vol_obj(type, object, vol_connector, false))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't create VOL object"); /* Register VOL object as _object_ type, for future object API calls */ @@ -733,7 +765,7 @@ H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, bool app_ref *------------------------------------------------------------------------- */ herr_t -H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, bool app_ref, +H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_connector_t *vol_connector, bool app_ref, hid_t existing_id) { H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ @@ -747,7 +779,7 @@ H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_conne /* Set up VOL object for the passed-in data */ /* (Wraps object, since it's a library object) */ - if (NULL == (new_vol_obj = H5VL__new_vol_obj(type, object, vol_connector, true))) + if (NULL == (new_vol_obj = H5VL_new_vol_obj(type, object, vol_connector, true))) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object"); /* Call the underlying H5I function to complete the registration */ @@ -759,189 +791,159 @@ H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_conne } /* end H5VL_register_using_existing_id() */ /*------------------------------------------------------------------------- - * Function: H5VL_new_connector + * Function: H5VL_create_object * - * Purpose: Utility function to create a connector for a connector ID. + * Purpose: Similar to H5VL_register but does not create an ID. + * Creates a new VOL object for the provided generic object + * using the provided vol connector. Should only be used for + * internal objects returned from the connector such as + * requests. * - * Return: Success: Pointer to a new connector object + * Return: Success: A valid VOL object * Failure: NULL * *------------------------------------------------------------------------- */ -H5VL_t * -H5VL_new_connector(hid_t connector_id) +H5VL_object_t * +H5VL_create_object(void *object, H5VL_connector_t *vol_connector) { - H5VL_class_t *cls = NULL; /* VOL connector class */ - H5VL_t *connector = NULL; /* New VOL connector struct */ - bool conn_id_incr = false; /* Whether the VOL connector ID has been incremented */ - H5VL_t *ret_value = NULL; /* Return value */ + H5VL_object_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - /* Get the VOL class object from the connector's ID */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a VOL connector ID"); + /* Check arguments */ + assert(object); + assert(vol_connector); - /* Setup VOL info struct */ - if (NULL == (connector = H5FL_CALLOC(H5VL_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate VOL connector struct"); - connector->cls = cls; - connector->id = connector_id; - if (H5I_inc_ref(connector->id, false) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL connector"); - conn_id_incr = true; + /* Set up VOL object for the passed-in data */ + /* (Does not wrap object, since it's from a VOL callback) */ + if (NULL == (ret_value = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate memory for VOL object"); + ret_value->connector = vol_connector; + ret_value->data = object; + ret_value->rc = 1; - /* Set return value */ - ret_value = connector; + /* Bump the reference count on the VOL connector */ + H5VL_conn_inc_rc(vol_connector); done: - /* Clean up on error */ - if (NULL == ret_value) { - /* Decrement VOL connector ID ref count on error */ - if (conn_id_incr && H5I_dec_ref(connector_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector"); - - /* Free VOL connector struct */ - if (NULL != connector) - connector = H5FL_FREE(H5VL_t, connector); - } /* end if */ - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_new_connector() */ +} /* end H5VL_create_object() */ /*------------------------------------------------------------------------- - * Function: H5VL_register_using_vol_id + * Function: H5VL__conn_create * - * Purpose: Utility function to create a user ID for an object created - * or opened through the VOL. Uses the VOL connector's ID to - * get the connector information instead of it being passed in. + * Purpose: Utility function to create a connector around a class * - * Return: Success: A valid HDF5 ID - * Failure: H5I_INVALID_HID + * Return: Success: Pointer to a new connector object + * Failure: NULL * *------------------------------------------------------------------------- */ -hid_t -H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, bool app_ref) +static H5VL_connector_t * +H5VL__conn_create(H5VL_class_t *cls) { - H5VL_t *connector = NULL; /* VOL connector struct */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; /* New VOL connector struct */ + H5VL_connector_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE - /* Create new VOL connector object, using the connector ID */ - if (NULL == (connector = H5VL_new_connector(connector_id))) - HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't create VOL connector object"); + /* Sanity check */ + assert(cls); - /* Get an ID for the VOL object */ - if ((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); + /* Setup VOL info struct */ + if (NULL == (connector = H5FL_CALLOC(H5VL_connector_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate VOL connector struct"); + connector->cls = cls; -done: - /* Clean up on error */ - if (H5I_INVALID_HID == ret_value) - /* Release newly created connector */ - if (connector && H5VL_conn_dec_rc(connector) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, H5I_INVALID_HID, - "unable to decrement ref count on VOL connector") + /* Add connector to list of active VOL connectors */ + if (H5VL_conn_list_head_g) { + connector->next = H5VL_conn_list_head_g; + H5VL_conn_list_head_g->prev = connector; + } + H5VL_conn_list_head_g = connector; + /* Set return value */ + ret_value = connector; + +done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_register_using_vol_id() */ +} /* end H5VL__conn_create() */ /*------------------------------------------------------------------------- - * Function: H5VL_create_object + * Function: H5VL_conn_register * - * Purpose: Similar to H5VL_register but does not create an ID. - * Creates a new VOL object for the provided generic object - * using the provided vol connector. Should only be used for - * internal objects returned from the connector such as - * requests. + * Purpose: Registers an existing VOL connector with a new ID * - * Return: Success: A valid VOL object - * Failure: NULL + * Return: Success: VOL connector ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ -H5VL_object_t * -H5VL_create_object(void *object, H5VL_t *vol_connector) +hid_t +H5VL_conn_register(H5VL_connector_t *connector) { - H5VL_object_t *ret_value = NULL; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Check arguments */ - assert(object); - assert(vol_connector); + assert(connector); - /* Set up VOL object for the passed-in data */ - /* (Does not wrap object, since it's from a VOL callback) */ - if (NULL == (ret_value = H5FL_CALLOC(H5VL_object_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate memory for VOL object"); - ret_value->connector = vol_connector; - ret_value->data = object; - ret_value->rc = 1; + /* Create a ID for the connector */ + if ((ret_value = H5I_register(H5I_VOL, connector, true)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); - /* Bump the reference count on the VOL connector */ - H5VL_conn_inc_rc(vol_connector); + /* ID is holding a reference to the connector */ + H5VL_conn_inc_rc(connector); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_create_object() */ +} /* end H5VL_conn_register() */ /*------------------------------------------------------------------------- - * Function: H5VL_create_object_using_vol_id + * Function: H5VL__conn_find * - * Purpose: Similar to H5VL_register_using_vol_id but does not create - * an id. Intended for use by internal library routines, - * therefore it wraps the object. + * Purpose: Find a matching connector * - * Return: Success: VOL object pointer - * Failure: NULL + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ -H5VL_object_t * -H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id) +static herr_t +H5VL__conn_find(H5PL_vol_key_t *key, H5VL_connector_t **connector) { - H5VL_class_t *cls = NULL; /* VOL connector class */ - H5VL_t *connector = NULL; /* VOL connector struct */ - bool conn_id_incr = false; /* Whether the VOL connector ID has been incremented */ - H5VL_object_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Get the VOL class object from the connector's ID */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, NULL, "not a VOL connector ID"); + H5VL_connector_t *node; /* Current node in linked list */ - /* Setup VOL info struct */ - if (NULL == (connector = H5FL_CALLOC(H5VL_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate VOL info struct"); - connector->cls = cls; - connector->id = connector_id; - if (H5I_inc_ref(connector->id, false) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL connector"); - conn_id_incr = true; + FUNC_ENTER_PACKAGE_NOERR - /* Set up VOL object for the passed-in data */ - /* (Wraps object, since it's a library object) */ - if (NULL == (ret_value = H5VL__new_vol_obj(type, obj, connector, true))) - HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't create VOL object"); + /* Check arguments */ + assert(key); + assert(connector); -done: - /* Clean up on error */ - if (!ret_value) { - /* Decrement VOL connector ID ref count on error */ - if (conn_id_incr && H5I_dec_ref(connector_id) < 0) - HDONE_ERROR(H5E_VOL, H5E_CANTDEC, NULL, "unable to decrement ref count on VOL connector"); + /* Iterate over linked list of active connectors */ + node = H5VL_conn_list_head_g; + while (node) { + if (H5VL_GET_CONNECTOR_BY_NAME == key->kind) { + if (0 == strcmp(node->cls->name, key->u.name)) { + *connector = node; + break; + } /* end if */ + } /* end if */ + else { + assert(H5VL_GET_CONNECTOR_BY_VALUE == key->kind); + if (node->cls->value == key->u.value) { + *connector = node; + break; + } /* end if */ + } /* end else */ - /* Free VOL connector struct */ - if (NULL != connector) - connector = H5FL_FREE(H5VL_t, connector); - } /* end if */ + /* Advance to next node */ + node = node->next; + } - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_create_object_using_vol_id() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL__conn_find() */ /*------------------------------------------------------------------------- * Function: H5VL_conn_inc_rc @@ -953,7 +955,7 @@ H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id) *------------------------------------------------------------------------- */ int64_t -H5VL_conn_inc_rc(H5VL_t *connector) +H5VL_conn_inc_rc(H5VL_connector_t *connector) { int64_t ret_value = -1; @@ -965,6 +967,7 @@ H5VL_conn_inc_rc(H5VL_t *connector) /* Increment refcount for connector */ connector->nrefs++; + /* Set return value */ ret_value = connector->nrefs; FUNC_LEAVE_NOAPI(ret_value) @@ -980,7 +983,7 @@ H5VL_conn_inc_rc(H5VL_t *connector) *------------------------------------------------------------------------- */ int64_t -H5VL_conn_dec_rc(H5VL_t *connector) +H5VL_conn_dec_rc(H5VL_connector_t *connector) { int64_t ret_value = -1; /* Return value */ @@ -992,23 +995,123 @@ H5VL_conn_dec_rc(H5VL_t *connector) /* Decrement refcount for connector */ connector->nrefs--; - /* Check for last reference */ - if (0 == connector->nrefs) { - if (H5I_dec_ref(connector->id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector"); - H5FL_FREE(H5VL_t, connector); + /* Set return value */ + ret_value = connector->nrefs; - /* Set return value */ - ret_value = 0; - } /* end if */ - else - /* Set return value */ - ret_value = connector->nrefs; + /* Check for last reference */ + if (0 == connector->nrefs) + if (H5VL__conn_free(connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to free VOL connector"); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_conn_dec_rc() */ +/*------------------------------------------------------------------------- + * Function: H5VL_conn_same_class + * + * Purpose: Determine if two connectors point to the same VOL class + * + * Return: TRUE/FALSE/FAIL + * + *------------------------------------------------------------------------- + */ +htri_t +H5VL_conn_same_class(const H5VL_connector_t *conn1, const H5VL_connector_t *conn2) +{ + htri_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + assert(conn1); + assert(conn2); + + /* Fast check */ + if (conn1 == conn2) + HGOTO_DONE(TRUE); + else { + int cmp_value; /* Comparison result */ + + /* Compare connector classes */ + if (H5VL_cmp_connector_cls(&cmp_value, conn1->cls, conn2->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + ret_value = (0 == cmp_value); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_conn_same_class() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__conn_free + * + * Purpose: Free a connector object + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__conn_free(H5VL_connector_t *connector) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + assert(connector); + assert(0 == connector->nrefs); + + /* Remove connector from list of active VOL connectors */ + if (H5VL_conn_list_head_g == connector) { + H5VL_conn_list_head_g = H5VL_conn_list_head_g->next; + if (H5VL_conn_list_head_g) + H5VL_conn_list_head_g->prev = NULL; + } + else { + if (connector->prev) + connector->prev->next = connector->next; + if (connector->next) + connector->next->prev = connector->prev; + } + + if (H5VL__free_cls(connector->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "can't free VOL class"); + + H5FL_FREE(H5VL_connector_t, connector); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__conn_free() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__conn_free_id + * + * Purpose: Shim for freeing connector ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__conn_free_id(H5VL_connector_t *connector, void H5_ATTR_UNUSED **request) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + assert(connector); + + /* Decrement refcount on connector */ + if (H5VL_conn_dec_rc(connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__conn_free_id() */ + /*------------------------------------------------------------------------- * Function: H5VL_object_inc_rc * @@ -1076,7 +1179,7 @@ herr_t H5VL_object_is_native(const H5VL_object_t *obj, bool *is_native) { const H5VL_class_t *cls; /* VOL connector class structs for object */ - const H5VL_class_t *native_cls; /* Native VOL connector class structs */ + H5VL_connector_t *native; /* Native VOL connector */ int cmp_value; /* Comparison result */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1092,11 +1195,10 @@ H5VL_object_is_native(const H5VL_object_t *obj, bool *is_native) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector class"); /* Retrieve the native connector class */ - if (NULL == (native_cls = (H5VL_class_t *)H5I_object_verify(H5VL_NATIVE, H5I_VOL))) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve native VOL connector class"); + native = H5VL_NATIVE_conn_g; /* Compare connector classes */ - if (H5VL_cmp_connector_cls(&cmp_value, cls, native_cls) < 0) + if (H5VL_cmp_connector_cls(&cmp_value, cls, native->cls) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); /* If classes compare equal, then the object is / is in a native connector's file */ @@ -1173,19 +1275,18 @@ H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5VL_object_t *vol_obj2, * Purpose: Registers a new VOL connector as a member of the virtual object * layer class. * - * Return: Success: A VOL connector ID which is good until the - * library is closed or the connector is unregistered. - * - * Failure: H5I_INVALID_HID + * Return: Success: A pointer to a VOL connector + * Failure: NULL * *------------------------------------------------------------------------- */ -hid_t -H5VL__register_connector(const void *_cls, bool app_ref, hid_t vipl_id) +H5VL_connector_t * +H5VL__register_connector(const H5VL_class_t *cls, hid_t vipl_id) { - const H5VL_class_t *cls = (const H5VL_class_t *)_cls; - H5VL_class_t *saved = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5VL_connector_t *connector = NULL; + H5VL_class_t *saved = NULL; + bool init_done = false; + H5VL_connector_t *ret_value = NULL; FUNC_ENTER_PACKAGE @@ -1194,27 +1295,38 @@ H5VL__register_connector(const void *_cls, bool app_ref, hid_t vipl_id) /* Copy the class structure so the caller can reuse or free it */ if (NULL == (saved = H5FL_MALLOC(H5VL_class_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, - "memory allocation failed for VOL connector class struct"); + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "memory allocation failed for VOL connector class struct"); H5MM_memcpy(saved, cls, sizeof(H5VL_class_t)); if (NULL == (saved->name = H5MM_strdup(cls->name))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, - "memory allocation failed for VOL connector name"); + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "memory allocation failed for VOL connector name"); /* Initialize the VOL connector */ if (cls->initialize && cls->initialize(vipl_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to init VOL connector"); + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to init VOL connector"); + init_done = true; - /* Create the new class ID */ - if ((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); + /* Create new connector for the class */ + if (NULL == (connector = H5VL__conn_create(saved))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create VOL connector"); -done: - if (ret_value < 0 && saved) { - if (saved->name) - H5MM_xfree_const(saved->name); + /* Set return value */ + ret_value = connector; - H5FL_FREE(H5VL_class_t, saved); +done: + if (NULL == ret_value) { + if (connector) { + if (H5VL__conn_free(connector) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, NULL, "can't free VOL connector"); + } + else if (init_done) { + if (H5VL__free_cls(saved) < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRELEASE, NULL, "can't free VOL class"); + } + else if (saved) { + if (saved->name) + H5MM_xfree_const(saved->name); + H5FL_FREE(H5VL_class_t, saved); + } } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1226,64 +1338,56 @@ H5VL__register_connector(const void *_cls, bool app_ref, hid_t vipl_id) * Purpose: Registers a new VOL connector as a member of the virtual object * layer class. * - * Return: Success: A VOL connector ID which is good until the - * library is closed or the connector is - * unregistered. - * - * Failure: H5I_INVALID_HID + * Return: Success: A pointer to a VOL connector + * Failure: NULL * *------------------------------------------------------------------------- */ -hid_t -H5VL__register_connector_by_class(const H5VL_class_t *cls, bool app_ref, hid_t vipl_id) +H5VL_connector_t * +H5VL__register_connector_by_class(const H5VL_class_t *cls, hid_t vipl_id) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for class */ + H5PL_vol_key_t key; /* Info for connector search */ + H5VL_connector_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE /* Check arguments */ if (!cls) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, - "VOL connector class pointer cannot be NULL"); + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, NULL, "VOL connector class pointer cannot be NULL"); if (H5VL_VERSION != cls->version) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector has incompatible version"); + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "VOL connector has incompatible version"); if (!cls->name) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, - "VOL connector class name cannot be the NULL pointer"); + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "VOL connector class name cannot be the NULL pointer"); if (0 == strlen(cls->name)) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, - "VOL connector class name cannot be the empty string"); + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "VOL connector class name cannot be the empty string"); if (cls->info_cls.copy && !cls->info_cls.free) HGOTO_ERROR( - H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + H5E_VOL, H5E_CANTREGISTER, NULL, "VOL connector must provide free callback for VOL info objects when a copy callback is provided"); if (cls->wrap_cls.get_wrap_ctx && !cls->wrap_cls.free_wrap_ctx) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "VOL connector must provide free callback for object wrapping contexts when a get " "callback is provided"); - /* Set up op data for iteration */ - op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.key.u.name = cls->name; - op_data.found_id = H5I_INVALID_HID; + /* Set up data for find */ + key.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.u.name = cls->name; /* Check if connector is already registered */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, true) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL IDs"); - - /* Increment the ref count on the existing VOL connector ID, if it's already registered */ - if (op_data.found_id != H5I_INVALID_HID) { - if (H5I_inc_ref(op_data.found_id, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, - "unable to increment ref count on VOL connector"); - ret_value = op_data.found_id; - } /* end if */ - else { - /* Create a new class ID */ - if ((ret_value = H5VL__register_connector(cls, app_ref, vipl_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector"); - } /* end else */ + if (H5VL__conn_find(&key, &connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTFIND, NULL, "can't search VOL connectors"); + + /* If not found, create a new connector */ + if (NULL == connector) + if (NULL == (connector = H5VL__register_connector(cls, vipl_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "unable to register VOL connector"); + + /* Inc. refcount on connector object, so it can be uniformly released */ + H5VL_conn_inc_rc(connector); + + /* Set return value */ + ret_value = connector; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1295,52 +1399,49 @@ H5VL__register_connector_by_class(const H5VL_class_t *cls, bool app_ref, hid_t v * Purpose: Registers a new VOL connector as a member of the virtual object * layer class. * - * Return: Success: A VOL connector ID which is good until the - * library is closed or the connector is - * unregistered. - * - * Failure: H5I_INVALID_HID + * Return: Success: A pointer to a VOL connector + * Failure: NULL * *------------------------------------------------------------------------- */ -hid_t -H5VL__register_connector_by_name(const char *name, bool app_ref, hid_t vipl_id) +H5VL_connector_t * +H5VL__register_connector_by_name(const char *name, hid_t vipl_id) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for class */ + H5PL_vol_key_t key; /* Info for connector search */ + H5VL_connector_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* Set up op data for iteration */ - op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.key.u.name = name; - op_data.found_id = H5I_INVALID_HID; + /* Set up data for find */ + key.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.u.name = name; /* Check if connector is already registered */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids"); - - /* If connector already registered, increment ref count on ID and return ID */ - if (op_data.found_id != H5I_INVALID_HID) { - if (H5I_inc_ref(op_data.found_id, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, - "unable to increment ref count on VOL connector"); - ret_value = op_data.found_id; - } /* end if */ - else { - H5PL_key_t key; + if (H5VL__conn_find(&key, &connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTFIND, NULL, "can't search VOL connectors"); + + /* If not found, create a new connector */ + if (NULL == connector) { + H5PL_key_t plugin_key; const H5VL_class_t *cls; /* Try loading the connector */ - key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; - key.vol.u.name = name; - if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector"); - - /* Register the connector we loaded */ - if ((ret_value = H5VL__register_connector(cls, app_ref, vipl_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); - } /* end else */ + plugin_key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + plugin_key.vol.u.name = name; + if (NULL == (cls = H5PL_load(H5PL_TYPE_VOL, &plugin_key))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to load VOL connector"); + + /* Create a connector for the class we loaded */ + if (NULL == (connector = H5VL__register_connector(cls, vipl_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "unable to register VOL connector"); + } /* end if */ + + /* Inc. refcount on connector object, so it can be uniformly released */ + H5VL_conn_inc_rc(connector); + + /* Set return value */ + ret_value = connector; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1352,52 +1453,49 @@ H5VL__register_connector_by_name(const char *name, bool app_ref, hid_t vipl_id) * Purpose: Registers a new VOL connector as a member of the virtual object * layer class. * - * Return: Success: A VOL connector ID which is good until the - * library is closed or the connector is - * unregistered. - * - * Failure: H5I_INVALID_HID + * Return: Success: A pointer to a VOL connector + * Failure: NULL * *------------------------------------------------------------------------- */ -hid_t -H5VL__register_connector_by_value(H5VL_class_value_t value, bool app_ref, hid_t vipl_id) +H5VL_connector_t * +H5VL__register_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for class */ + H5PL_vol_key_t key; /* Info for connector search */ + H5VL_connector_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* Set up op data for iteration */ - op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.key.u.value = value; - op_data.found_id = H5I_INVALID_HID; + /* Set up data for find */ + key.kind = H5VL_GET_CONNECTOR_BY_VALUE; + key.u.value = value; /* Check if connector is already registered */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids"); - - /* If connector already registered, increment ref count on ID and return ID */ - if (op_data.found_id != H5I_INVALID_HID) { - if (H5I_inc_ref(op_data.found_id, app_ref) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, - "unable to increment ref count on VOL connector"); - ret_value = op_data.found_id; - } /* end if */ - else { - H5PL_key_t key; + if (H5VL__conn_find(&key, &connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTFIND, NULL, "can't search VOL connectors"); + + /* If not found, create a new connector */ + if (NULL == connector) { + H5PL_key_t plugin_key; const H5VL_class_t *cls; /* Try loading the connector */ - key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; - key.vol.u.value = value; - if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector"); - - /* Register the connector we loaded */ - if ((ret_value = H5VL__register_connector(cls, app_ref, vipl_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID"); - } /* end else */ + plugin_key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; + plugin_key.vol.u.value = value; + if (NULL == (cls = H5PL_load(H5PL_TYPE_VOL, &plugin_key))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to load VOL connector"); + + /* Create a connector for the class we loaded */ + if (NULL == (connector = H5VL__register_connector(cls, vipl_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, NULL, "unable to register VOL connector ID"); + } /* end if */ + + /* Inc. refcount on connector object, so it can be uniformly released */ + H5VL_conn_inc_rc(connector); + + /* Set return value */ + ret_value = connector; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1417,22 +1515,22 @@ H5VL__register_connector_by_value(H5VL_class_value_t value, bool app_ref, hid_t htri_t H5VL__is_connector_registered_by_name(const char *name) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - htri_t ret_value = false; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for class */ + H5PL_vol_key_t key; /* Info for connector search */ + htri_t ret_value = false; /* Return value */ FUNC_ENTER_PACKAGE - /* Set up op data for iteration */ - op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.key.u.name = name; - op_data.found_id = H5I_INVALID_HID; + /* Set up data for find */ + key.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.u.name = name; /* Find connector with name */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, true) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors"); + if (H5VL__conn_find(&key, &connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTFIND, FAIL, "can't search VOL connectors"); /* Found a connector with that name */ - if (op_data.found_id != H5I_INVALID_HID) + if (connector) ret_value = true; done: @@ -1454,22 +1552,22 @@ H5VL__is_connector_registered_by_name(const char *name) htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - htri_t ret_value = false; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for class */ + H5PL_vol_key_t key; /* Info for connector search */ + htri_t ret_value = false; /* Return value */ FUNC_ENTER_PACKAGE - /* Set up op data for iteration */ - op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.key.u.value = value; - op_data.found_id = H5I_INVALID_HID; + /* Set up data for find */ + key.kind = H5VL_GET_CONNECTOR_BY_VALUE; + key.u.value = value; /* Find connector with value */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, true) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL connectors"); + if (H5VL__conn_find(&key, &connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTFIND, FAIL, "can't search VOL connectors"); - /* Found a connector with that name */ - if (op_data.found_id != H5I_INVALID_HID) + /* Found a connector with that value */ + if (connector) ret_value = true; done: @@ -1477,245 +1575,109 @@ H5VL__is_connector_registered_by_value(H5VL_class_value_t value) } /* end H5VL__is_connector_registered_by_value() */ /*------------------------------------------------------------------------- - * Function: H5VL__get_connector_id + * Function: H5VL__get_connector_by_name * - * Purpose: Retrieves the VOL connector ID for a given object ID. + * Purpose: Looks up a connector by its class name. * - * Return: Positive if the VOL class has been registered - * Negative on error (if the class is not a valid class or not registered) + * Return: Pointer to the connector if the VOL class has been registered + * NULL on error (if the class is not a valid class or not registered) * *------------------------------------------------------------------------- */ -hid_t -H5VL__get_connector_id(hid_t obj_id, bool is_api) +H5VL_connector_t * +H5VL__get_connector_by_name(const char *name) { - H5VL_object_t *vol_obj = NULL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for class */ + H5PL_vol_key_t key; /* Info for connector search */ + H5VL_connector_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* Get the underlying VOL object for the object ID */ - if (NULL == (vol_obj = H5VL_vol_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier"); - - /* Return the VOL object's VOL class ID */ - ret_value = vol_obj->connector->id; - if (H5I_inc_ref(ret_value, is_api) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__get_connector_id() */ - -/*------------------------------------------------------------------------- - * Function: H5VL__get_connector_id_by_name - * - * Purpose: Retrieves the ID for a registered VOL connector. - * - * Return: Positive if the VOL class has been registered - * Negative on error (if the class is not a valid class or not registered) - * - *------------------------------------------------------------------------- - */ -hid_t -H5VL__get_connector_id_by_name(const char *name, bool is_api) -{ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_PACKAGE + /* Set up data for find */ + key.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.u.name = name; /* Find connector with name */ - if ((ret_value = H5VL__peek_connector_id_by_name(name)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector"); - - /* Found a connector with that name */ - if (H5I_inc_ref(ret_value, is_api) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__get_connector_id_by_name() */ - -/*------------------------------------------------------------------------- - * Function: H5VL__get_connector_id_by_value - * - * Purpose: Retrieves the ID for a registered VOL connector. - * - * Return: Positive if the VOL class has been registered - * Negative on error (if the class is not a valid class or - * not registered) - * - *------------------------------------------------------------------------- - */ -hid_t -H5VL__get_connector_id_by_value(H5VL_class_value_t value, bool is_api) -{ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + if (H5VL__conn_find(&key, &connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, NULL, "can't find VOL connector"); - FUNC_ENTER_PACKAGE + if (connector) + /* Inc. refcount on connector object, so it can be uniformly released */ + H5VL_conn_inc_rc(connector); - /* Find connector with value */ - if ((ret_value = H5VL__peek_connector_id_by_value(value)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't find VOL connector"); - - /* Found a connector with that value */ - if (H5I_inc_ref(ret_value, is_api) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector"); + /* Set return value */ + ret_value = connector; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__get_connector_id_by_value() */ +} /* end H5VL__get_connector_by_name() */ /*------------------------------------------------------------------------- - * Function: H5VL__peek_connector_id_by_name + * Function: H5VL__get_connector_by_value * - * Purpose: Retrieves the ID for a registered VOL connector. Does not - * increment the ref count + * Purpose: Looks up a connector by its class value. * - * Return: Positive if the VOL class has been registered - * Negative on error (if the class is not a valid class or - * not registered) + * Return: Pointer to the connector if the VOL class has been registered + * NULL on error (if the class is not a valid class or not registered) * *------------------------------------------------------------------------- */ -hid_t -H5VL__peek_connector_id_by_name(const char *name) +H5VL_connector_t * +H5VL__get_connector_by_value(H5VL_class_value_t value) { - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_connector_t *connector = NULL; /* Connector for class */ + H5PL_vol_key_t key; /* Info for connector search */ + H5VL_connector_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE - /* Set up op data for iteration */ - op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.key.u.name = name; - op_data.found_id = H5I_INVALID_HID; + /* Set up data for find */ + key.kind = H5VL_GET_CONNECTOR_BY_VALUE; + key.u.value = value; /* Find connector with name */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, true) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors"); + if (H5VL__conn_find(&key, &connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, NULL, "can't find VOL connector"); - /* Set return value */ - ret_value = op_data.found_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__peek_connector_id_by_name() */ - -/*------------------------------------------------------------------------- - * Function: H5VL__peek_connector_id_by_value - * - * Purpose: Retrieves the ID for a registered VOL connector. Does not - * increment the ref count - * - * Return: Positive if the VOL class has been registered - * Negative on error (if the class is not a valid class or - * not registered) - * - *------------------------------------------------------------------------- - */ -hid_t -H5VL__peek_connector_id_by_value(H5VL_class_value_t value) -{ - H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Set up op data for iteration */ - op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.key.u.value = value; - op_data.found_id = H5I_INVALID_HID; - - /* Find connector with value */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, true) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connectors"); + if (connector) + /* Inc. refcount on connector object, so it can be uniformly released */ + H5VL_conn_inc_rc(connector); /* Set return value */ - ret_value = op_data.found_id; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__peek_connector_id_by_value() */ - -/*------------------------------------------------------------------------- - * Function: H5VL__connector_str_to_info - * - * Purpose: Deserializes a string into a connector's info object - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Only deserialize string, if it's non-NULL */ - if (str) { - H5VL_class_t *cls; /* VOL connector's class struct */ - - /* Check args and get class pointer */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID"); - - /* Allow the connector to deserialize info */ - if (cls->info_cls.from_str) { - if ((cls->info_cls.from_str)(str, info) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize connector info"); - } /* end if */ - else - *info = NULL; - } /* end if */ - else - *info = NULL; + ret_value = connector; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__connector_str_to_info() */ +} /* end H5VL__get_connector_by_value() */ /*------------------------------------------------------------------------- * Function: H5VL__get_connector_name * - * Purpose: Private version of H5VLget_connector_name + * Purpose: Retrieve name of connector * * Return: Success: The length of the connector name - * Failure: Negative + * Failure: Can't fail * *------------------------------------------------------------------------- */ -ssize_t -H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size) +size_t +H5VL__get_connector_name(const H5VL_connector_t *connector, char *name /*out*/, size_t size) { - H5VL_object_t *vol_obj; - const H5VL_class_t *cls; - size_t len; - ssize_t ret_value = -1; - - FUNC_ENTER_PACKAGE + size_t len; - /* get the object pointer */ - if (NULL == (vol_obj = H5VL_vol_object(id))) - HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid VOL identifier"); + FUNC_ENTER_PACKAGE_NOERR - cls = vol_obj->connector->cls; + /* Sanity check */ + assert(connector); - len = strlen(cls->name); + len = strlen(connector->cls->name); if (name) { - strncpy(name, cls->name, size); + strncpy(name, connector->cls->name, size); if (len >= size) name[size - 1] = '\0'; } /* end if */ - /* Set the return value for the API call */ - ret_value = (ssize_t)len; - -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(len) } /* end H5VL__get_connector_name() */ /*------------------------------------------------------------------------- @@ -1734,28 +1696,13 @@ H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size) H5VL_object_t * H5VL_vol_object(hid_t id) { - void *obj = NULL; - H5I_type_t obj_type; H5VL_object_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - obj_type = H5I_get_type(id); - if (H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || H5I_DATASET == obj_type || - H5I_DATATYPE == obj_type || H5I_MAP == obj_type) { - /* Get the object */ - if (NULL == (obj = H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); - - /* If this is a datatype, get the VOL object attached to the H5T_t struct */ - if (H5I_DATATYPE == obj_type) - if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier type to function"); - - ret_value = (H5VL_object_t *)obj; + /* Get the underlying object */ + if (NULL == (ret_value = H5VL_vol_object_verify(id, H5I_get_type(id)))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't retrieve object for ID"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1782,13 +1729,19 @@ H5VL_vol_object_verify(hid_t id, H5I_type_t obj_type) FUNC_ENTER_NOAPI(NULL) - if (NULL == (obj = H5I_object_verify(id, obj_type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "identifier is not of specified type"); + if (H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || H5I_DATASET == obj_type || + H5I_DATATYPE == obj_type || H5I_MAP == obj_type) { + /* Get the object */ + if (NULL == (obj = H5I_object_verify(id, obj_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "identifier is not of specified type"); - /* If this is a datatype, get the VOL object attached to the H5T_t struct */ - if (H5I_DATATYPE == obj_type) - if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); + /* If this is a datatype, get the VOL object attached to the H5T_t struct */ + if (H5I_DATATYPE == obj_type) + if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier type to function"); ret_value = (H5VL_object_t *)obj; @@ -1875,7 +1828,7 @@ H5VL__object(hid_t id, H5I_type_t obj_type) case H5I_ATTR: case H5I_MAP: /* get the object */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) + if (NULL == (vol_obj = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); break; @@ -1883,7 +1836,7 @@ H5VL__object(hid_t id, H5I_type_t obj_type) H5T_t *dt = NULL; /* get the object */ - if (NULL == (dt = (H5T_t *)H5I_object(id))) + if (NULL == (dt = H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); /* Get the actual datatype object that should be the vol_obj */ @@ -2459,7 +2412,7 @@ H5VL_wrap_register(H5I_type_t type, void *obj, bool app_ref) * field will get clobbered later, so disallow this. */ if (type == H5I_DATATYPE) - if (vol_wrap_ctx->connector->id == H5VL_NATIVE) + if (vol_wrap_ctx->connector == H5VL_NATIVE_conn_g) if (true == H5T_already_vol_managed((const H5T_t *)obj)) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype"); @@ -2468,7 +2421,7 @@ H5VL_wrap_register(H5I_type_t type, void *obj, bool app_ref) HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't wrap library object"); /* Get an ID for the object */ - if ((ret_value = H5VL_register_using_vol_id(type, new_obj, vol_wrap_ctx->connector->id, app_ref)) < 0) + if ((ret_value = H5VL_register(type, new_obj, vol_wrap_ctx->connector, app_ref)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object"); done: @@ -2536,7 +2489,7 @@ H5VL_check_plugin_load(const H5VL_class_t *cls, const H5PL_key_t *key, bool *suc *------------------------------------------------------------------------- */ void -H5VL__is_default_conn(hid_t fapl_id, hid_t connector_id, bool *is_default) +H5VL__is_default_conn(hid_t fapl_id, const H5VL_connector_t *connector, bool *is_default) { FUNC_ENTER_PACKAGE_NOERR @@ -2547,8 +2500,8 @@ H5VL__is_default_conn(hid_t fapl_id, hid_t connector_id, bool *is_default) * values in the FAPL, connector ID, or the HDF5_VOL_CONNECTOR environment * variable being set. */ - *is_default = (H5VL_def_conn_s.connector_id == H5_DEFAULT_VOL) && - ((H5P_FILE_ACCESS_DEFAULT == fapl_id) || connector_id == H5_DEFAULT_VOL); + *is_default = (H5VL_def_conn_s.connector == H5_DEFAULT_VOL) && + (H5P_FILE_ACCESS_DEFAULT == fapl_id || connector == H5_DEFAULT_VOL); FUNC_LEAVE_NOAPI_VOID } /* end H5VL__is_default_conn() */ @@ -2573,7 +2526,7 @@ H5VL_setup_args(hid_t loc_id, H5I_type_t id_type, H5VL_object_t **vol_obj) assert(vol_obj); /* Get attribute pointer */ - if (NULL == (*vol_obj = (H5VL_object_t *)H5I_object_verify(loc_id, id_type))) + if (NULL == (*vol_obj = H5I_object_verify(loc_id, id_type))) HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not the correct type of ID"); /* Set up collective metadata (if appropriate) */ @@ -2823,7 +2776,7 @@ H5VL_setup_token_args(hid_t loc_id, H5O_token_t *obj_token, H5VL_object_t **vol_ } /* end H5VL_setup_token_args() */ /*------------------------------------------------------------------------- - * Function: H5VL_get_cap_flags + * Function: H5VL_conn_prop_get_cap_flags * * Purpose: Query capability flags for connector property. * @@ -2836,7 +2789,7 @@ H5VL_setup_token_args(hid_t loc_id, H5O_token_t *obj_token, H5VL_object_t **vol_ *------------------------------------------------------------------------- */ herr_t -H5VL_get_cap_flags(const H5VL_connector_prop_t *connector_prop, uint64_t *cap_flags) +H5VL_conn_prop_get_cap_flags(const H5VL_connector_prop_t *connector_prop, uint64_t *cap_flags) { herr_t ret_value = SUCCEED; /* Return value */ @@ -2846,15 +2799,10 @@ H5VL_get_cap_flags(const H5VL_connector_prop_t *connector_prop, uint64_t *cap_fl assert(connector_prop); /* Copy the connector ID & info, if there is one */ - if (connector_prop->connector_id > 0) { - H5VL_class_t *connector; /* Pointer to connector */ - - /* Retrieve the connector for the ID */ - if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID"); - + if (connector_prop->connector) { /* Query the connector's capability flags */ - if (H5VL_introspect_get_cap_flags(connector_prop->connector_info, connector, cap_flags) < 0) + if (H5VL_introspect_get_cap_flags(connector_prop->connector_info, connector_prop->connector->cls, + cap_flags) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't query connector's capability flags"); } /* end if */ else @@ -2862,4 +2810,4 @@ H5VL_get_cap_flags(const H5VL_connector_prop_t *connector_prop, uint64_t *cap_fl done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_get_cap_flags() */ +} /* end H5VL_conn_prop_get_cap_flags() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 6f6b2d0768d..3a360713ee6 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -39,11 +39,9 @@ #include "H5VLnative_private.h" /* Native VOL connector */ -/* The VOL connector identification number */ -static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; - -/* Prototypes */ -static herr_t H5VL__native_term(void); +/* The native VOL connector */ +hid_t H5VL_NATIVE_g = H5I_INVALID_HID; +H5VL_connector_t *H5VL_NATIVE_conn_g = NULL; #define H5VL_NATIVE_CAP_FLAGS \ (H5VL_CAP_FLAG_NATIVE_FILES | H5VL_CAP_FLAG_ATTR_BASIC | H5VL_CAP_FLAG_ATTR_MORE | \ @@ -66,7 +64,7 @@ static const H5VL_class_t H5VL_native_cls_g = { H5VL_NATIVE_VERSION, /* connector version */ H5VL_NATIVE_CAP_FLAGS, /* capability flags */ NULL, /* initialize */ - H5VL__native_term, /* terminate */ + NULL, /* terminate */ { /* info_cls */ (size_t)0, /* info size */ @@ -182,37 +180,42 @@ static const H5VL_class_t H5VL_native_cls_g = { }; /*------------------------------------------------------------------------- - * Function: H5VL_native_register + * Function: H5VL__native_register * - * Purpose: Register the native VOL connector and retrieve an ID for it. + * Purpose: Register the native VOL connector and set up an ID for it. * - * Return: Success: The ID for the native connector - * Failure: H5I_INVALID_HID + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ -hid_t -H5VL_native_register(void) +herr_t +H5VL__native_register(void) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_PACKAGE /* Register the native VOL connector, if it isn't already */ - if (H5I_INVALID_HID == H5VL_NATIVE_ID_g) - if ((H5VL_NATIVE_ID_g = - H5VL__register_connector(&H5VL_native_cls_g, true, H5P_VOL_INITIALIZE_DEFAULT)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL connector"); - - /* Set return value */ - ret_value = H5VL_NATIVE_ID_g; + if (NULL == H5VL_NATIVE_conn_g) + if (NULL == + (H5VL_NATIVE_conn_g = H5VL__register_connector(&H5VL_native_cls_g, H5P_VOL_INITIALIZE_DEFAULT))) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register native VOL connector"); + + /* Get ID for connector */ + if (H5I_VOL != H5I_get_type(H5VL_NATIVE_g)) { + if ((H5VL_NATIVE_g = H5I_register(H5I_VOL, H5VL_NATIVE_conn_g, false)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't create ID for native VOL connector"); + + /* ID is holding a reference to the connector */ + H5VL_conn_inc_rc(H5VL_NATIVE_conn_g); + } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_register() */ +} /* end H5VL__native_register() */ /*--------------------------------------------------------------------------- - * Function: H5VL__native_term + * Function: H5VL__native_unregister * * Purpose: Shut down the native VOL * @@ -220,16 +223,17 @@ H5VL_native_register(void) * *--------------------------------------------------------------------------- */ -static herr_t -H5VL__native_term(void) +herr_t +H5VL__native_unregister(void) { FUNC_ENTER_PACKAGE_NOERR - /* Reset VOL ID */ - H5VL_NATIVE_ID_g = H5I_INVALID_HID; + /* Reset VOL connector info */ + H5VL_NATIVE_g = H5I_INVALID_HID; + H5VL_NATIVE_conn_g = NULL; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5VL__native_term() */ +} /* end H5VL__native_unregister() */ /*--------------------------------------------------------------------------- * Function: H5VL__native_introspect_get_conn_cls diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 6ca484ae329..f0a185b22d6 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -25,8 +25,16 @@ /* Public Macros */ /*****************/ +/* When this header is included from a private header, don't make calls to H5open() */ +#undef H5OPEN +#ifndef H5private_H +#define H5OPEN H5open(), +#else /* H5private_H */ +#define H5OPEN +#endif /* H5private_H */ + /* Identifier for the native VOL connector */ -#define H5VL_NATIVE (H5VL_native_register()) +#define H5VL_NATIVE (H5OPEN H5VL_NATIVE_g) /* Characteristics of the native VOL connector */ #define H5VL_NATIVE_NAME "native" @@ -514,6 +522,9 @@ typedef union H5VL_native_object_optional_args_t { extern "C" { #endif +/* Global variable to hold the VOL connector ID */ +H5_DLLVAR hid_t H5VL_NATIVE_g; + /* Token <--> address converters */ /** @@ -551,12 +562,6 @@ H5_DLL herr_t H5VLnative_addr_to_token(hid_t loc_id, haddr_t addr, H5O_token_t * */ H5_DLL herr_t H5VLnative_token_to_addr(hid_t loc_id, H5O_token_t token, haddr_t *addr); -/** @private - * - * \brief Register the native VOL connector and retrieve an ID for it - */ -H5_DLL hid_t H5VL_native_register(void); - #ifdef __cplusplus } #endif diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h index c80c114a673..e3f5fb8f405 100644 --- a/src/H5VLnative_private.h +++ b/src/H5VLnative_private.h @@ -17,9 +17,12 @@ #ifndef H5VLnative_private_H #define H5VLnative_private_H +/* Include connector's public header */ +#include "H5VLnative.h" /* Native VOL connector */ + /* Private headers needed by this file */ -#include "H5Fprivate.h" /* Files */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5Fprivate.h" /* Files */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ /* Library Private Macros */ @@ -33,14 +36,13 @@ /* Library Private Variables */ /*****************************/ +/* The native VOL connector */ +H5_DLLVAR H5VL_connector_t *H5VL_NATIVE_conn_g; + /******************************/ /* Library Private Prototypes */ /******************************/ -#ifdef __cplusplus -extern "C" { -#endif - /* Attribute callbacks */ H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, @@ -162,8 +164,4 @@ H5_DLL herr_t H5VL_native_addr_to_token(void *obj, H5I_type_t obj_type, haddr_t H5_DLL herr_t H5VL_native_token_to_addr(void *obj, H5I_type_t obj_type, H5O_token_t token, haddr_t *addr); H5_DLL herr_t H5VL_native_get_file_struct(void *obj, H5I_type_t type, H5F_t **file); -#ifdef __cplusplus -} -#endif - #endif /* H5VLnative_private_H */ diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index df13afc2513..8c1de0e6d96 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -242,7 +242,7 @@ static herr_t H5VL_pass_through_optional(void *obj, H5VL_optional_args_t *args, /*******************/ /* Pass through VOL connector class struct */ -static const H5VL_class_t H5VL_pass_through_g = { +const H5VL_class_t H5VL_pass_through_g = { H5VL_VERSION, /* VOL class struct version */ (H5VL_class_value_t)H5VL_PASSTHRU_VALUE, /* value */ H5VL_PASSTHRU_NAME, /* name */ @@ -364,9 +364,6 @@ static const H5VL_class_t H5VL_pass_through_g = { H5VL_pass_through_optional /* optional */ }; -/* The connector identification number, initialized at runtime */ -static hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID; - /*------------------------------------------------------------------------- * Function: H5VL__pass_through_new_obj * @@ -420,27 +417,6 @@ H5VL_pass_through_free_obj(H5VL_pass_through_t *obj) return 0; } /* end H5VL__pass_through_free_obj() */ -/*------------------------------------------------------------------------- - * Function: H5VL_pass_through_register - * - * Purpose: Register the pass-through VOL connector and retrieve an ID - * for it. - * - * Return: Success: The ID for the pass-through VOL connector - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -hid_t -H5VL_pass_through_register(void) -{ - /* Singleton register the pass-through VOL connector ID */ - if (H5VL_PASSTHRU_g < 0) - H5VL_PASSTHRU_g = H5VLregister_connector(&H5VL_pass_through_g, H5P_DEFAULT); - - return H5VL_PASSTHRU_g; -} /* end H5VL_pass_through_register() */ - /*------------------------------------------------------------------------- * Function: H5VL_pass_through_init * @@ -486,9 +462,6 @@ H5VL_pass_through_term(void) printf("------- PASS THROUGH VOL TERM\n"); #endif - /* Reset VOL ID */ - H5VL_PASSTHRU_g = H5I_INVALID_HID; - return 0; } /* end H5VL_pass_through_term() */ diff --git a/src/H5VLpassthru.h b/src/H5VLpassthru.h index ec396cc8eb0..8480081cde6 100644 --- a/src/H5VLpassthru.h +++ b/src/H5VLpassthru.h @@ -20,8 +20,16 @@ /* Public headers needed by this file */ #include "H5VLpublic.h" /* Virtual Object Layer */ +/* When this header is included from a private header, don't make calls to H5open() */ +#undef H5OPEN +#ifndef H5private_H +#define H5OPEN H5open(), +#else /* H5private_H */ +#define H5OPEN +#endif /* H5private_H */ + /* Identifier for the pass-through VOL connector */ -#define H5VL_PASSTHRU (H5VL_pass_through_register()) +#define H5VL_PASSTHRU (H5OPEN H5VL_PASSTHRU_g) /* Characteristics of the pass-through VOL connector */ #define H5VL_PASSTHRU_NAME "pass_through" @@ -38,7 +46,8 @@ typedef struct H5VL_pass_through_info_t { extern "C" { #endif -H5_DLL hid_t H5VL_pass_through_register(void); +/* Global variable to hold the VOL connector ID */ +H5_DLLVAR hid_t H5VL_PASSTHRU_g; #ifdef __cplusplus } diff --git a/src/H5VLpassthru_int.c b/src/H5VLpassthru_int.c new file mode 100644 index 00000000000..b514101b8c4 --- /dev/null +++ b/src/H5VLpassthru_int.c @@ -0,0 +1,97 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Private routines for the internal passthru VOL connector. + * + * Necessary for using internal library routines, which are + * disallowed within the actual passthru VOL connector code. + * + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5VL_FRIEND /* Suppress error about including H5VLpkg */ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +#include "H5VLpassthru_private.h" /* Passthru VOL connector */ + +/* The native passthru VOL connector */ +hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID; +H5VL_connector_t *H5VL_PASSTHRU_conn_g = NULL; + +/*------------------------------------------------------------------------- + * Function: H5VL__passthru_register + * + * Purpose: Register the passthru VOL connector and set up an ID for it. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__passthru_register(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Register the passthru VOL connector, if it isn't already */ + if (NULL == H5VL_PASSTHRU_conn_g) + if (NULL == (H5VL_PASSTHRU_conn_g = + H5VL__register_connector(&H5VL_pass_through_g, H5P_VOL_INITIALIZE_DEFAULT))) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register passthru VOL connector"); + + /* Get ID for connector */ + if (H5I_VOL != H5I_get_type(H5VL_PASSTHRU_g)) { + if ((H5VL_PASSTHRU_g = H5I_register(H5I_VOL, H5VL_PASSTHRU_conn_g, false)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't create ID for passthru VOL connector"); + + /* ID is holding a reference to the connector */ + H5VL_conn_inc_rc(H5VL_PASSTHRU_conn_g); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__passthru_register() */ + +/*--------------------------------------------------------------------------- + * Function: H5VL__passthru_unregister + * + * Purpose: Shut down the passthru VOL + * + * Returns: SUCCEED (Can't fail) + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL__passthru_unregister(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Reset VOL connector info */ + H5VL_PASSTHRU_g = H5I_INVALID_HID; + H5VL_PASSTHRU_conn_g = NULL; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL__passthru_unregister() */ diff --git a/src/H5VLpassthru_private.h b/src/H5VLpassthru_private.h new file mode 100644 index 00000000000..8ac340937c2 --- /dev/null +++ b/src/H5VLpassthru_private.h @@ -0,0 +1,48 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The private header file for the passthru VOL connector. + */ + +#ifndef H5VLpassthru_private_H +#define H5VLpassthru_private_H + +/* Include connector's public header */ +#include "H5VLpassthru.h" /* Passthru VOL connector */ + +/* Private headers needed by this file */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/* Passthru VOL connector's class struct */ +H5_DLLVAR const H5VL_class_t H5VL_pass_through_g; + +/* The native VOL connector */ +H5_DLLVAR H5VL_connector_t *H5VL_PASSTHRU_conn_g; + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +#endif /* H5VLpassthru_private_H */ diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h index dae44eaf5d1..f33406e7602 100644 --- a/src/H5VLpkg.h +++ b/src/H5VLpkg.h @@ -36,6 +36,21 @@ /* Package Private Typedefs */ /****************************/ +/* Internal struct to track VOL connectors */ +struct H5VL_connector_t { + H5VL_class_t *cls; /* Pointer to connector class struct */ + int64_t nrefs; /* Number of references to this struct */ + struct H5VL_connector_t *next, *prev; /* Pointers to the next & previous */ + /* connectors in global list of active connectors */ +}; + +/* Internal vol object structure returned to the API */ +struct H5VL_object_t { + void *data; /* Pointer to connector-managed data for this object */ + H5VL_connector_t *connector; /* Pointer to VOL connector used by this object */ + size_t rc; /* Reference count */ +}; + /*****************************/ /* Package Private Variables */ /*****************************/ @@ -43,30 +58,35 @@ /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5VL__set_def_conn(void); -H5_DLL hid_t H5VL__register_connector(const void *cls, bool app_ref, hid_t vipl_id); -H5_DLL hid_t H5VL__register_connector_by_class(const H5VL_class_t *cls, bool app_ref, hid_t vipl_id); -H5_DLL hid_t H5VL__register_connector_by_name(const char *name, bool app_ref, hid_t vipl_id); -H5_DLL hid_t H5VL__register_connector_by_value(H5VL_class_value_t value, bool app_ref, hid_t vipl_id); -H5_DLL htri_t H5VL__is_connector_registered_by_name(const char *name); -H5_DLL htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value); -H5_DLL hid_t H5VL__get_connector_id(hid_t obj_id, bool is_api); -H5_DLL hid_t H5VL__get_connector_id_by_name(const char *name, bool is_api); -H5_DLL hid_t H5VL__get_connector_id_by_value(H5VL_class_value_t value, bool is_api); -H5_DLL hid_t H5VL__peek_connector_id_by_name(const char *name); -H5_DLL hid_t H5VL__peek_connector_id_by_value(H5VL_class_value_t value); -H5_DLL herr_t H5VL__connector_str_to_info(const char *str, hid_t connector_id, void **info); -H5_DLL ssize_t H5VL__get_connector_name(hid_t id, char *name /*out*/, size_t size); -H5_DLL void H5VL__is_default_conn(hid_t fapl_id, hid_t connector_id, bool *is_default); -H5_DLL herr_t H5VL__register_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); -H5_DLL size_t H5VL__num_opt_operation(void); -H5_DLL herr_t H5VL__find_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); -H5_DLL herr_t H5VL__unregister_opt_operation(H5VL_subclass_t subcls, const char *op_name); -H5_DLL herr_t H5VL__term_opt_operation(void); +H5_DLL herr_t H5VL__set_def_conn(void); +H5_DLL H5VL_connector_t *H5VL__register_connector(const H5VL_class_t *cls, hid_t vipl_id); +H5_DLL H5VL_connector_t *H5VL__register_connector_by_class(const H5VL_class_t *cls, hid_t vipl_id); +H5_DLL H5VL_connector_t *H5VL__register_connector_by_name(const char *name, hid_t vipl_id); +H5_DLL H5VL_connector_t *H5VL__register_connector_by_value(H5VL_class_value_t value, hid_t vipl_id); +H5_DLL htri_t H5VL__is_connector_registered_by_name(const char *name); +H5_DLL htri_t H5VL__is_connector_registered_by_value(H5VL_class_value_t value); +H5_DLL H5VL_connector_t *H5VL__get_connector_by_name(const char *name); +H5_DLL H5VL_connector_t *H5VL__get_connector_by_value(H5VL_class_value_t value); +H5_DLL herr_t H5VL__connector_str_to_info(const char *str, H5VL_connector_t *connector, void **info); +H5_DLL size_t H5VL__get_connector_name(const H5VL_connector_t *connector, char *name /*out*/, size_t size); +H5_DLL void H5VL__is_default_conn(hid_t fapl_id, const H5VL_connector_t *connector, bool *is_default); +H5_DLL herr_t H5VL__register_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); +H5_DLL size_t H5VL__num_opt_operation(void); +H5_DLL herr_t H5VL__find_opt_operation(H5VL_subclass_t subcls, const char *op_name, int *op_val); +H5_DLL herr_t H5VL__unregister_opt_operation(H5VL_subclass_t subcls, const char *op_name); +H5_DLL herr_t H5VL__term_opt_operation(void); + +/* Register the internal VOL connectors */ +H5_DLL herr_t H5VL__native_register(void); +H5_DLL herr_t H5VL__native_unregister(void); +H5_DLL herr_t H5VL__passthru_register(void); +H5_DLL herr_t H5VL__passthru_unregister(void); /* Testing functions */ #ifdef H5VL_TESTING H5_DLL herr_t H5VL__reparse_def_vol_conn_variable_test(void); +H5_DLL htri_t H5VL__is_native_connector_test(hid_t vol_id); +H5_DLL hid_t H5VL__register_using_vol_id_test(H5I_type_t type, void *object, hid_t vol_id); #endif /* H5VL_TESTING */ #endif /* H5VLpkg_H */ diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 2904a5b1c15..635642969bb 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -27,28 +27,33 @@ /* Library Private Macros */ /**************************/ +/* If the module using this macro is allowed access to the private variables, access them directly */ +#ifdef H5VL_MODULE +#define H5VL_OBJ_RC(VOL_OBJ) ((VOL_OBJ)->rc) +#define H5VL_OBJ_CONNECTOR(VOL_OBJ) ((VOL_OBJ)->connector) +#define H5VL_OBJ_DATA(VOL_OBJ) ((VOL_OBJ)->data) +#define H5VL_OBJ_DATA_RESET(VOL_OBJ) ((VOL_OBJ)->data = NULL) +#else /* H5VL_MODULE */ +#define H5VL_OBJ_RC(VOL_OBJ) (H5VL_obj_get_rc(VOL_OBJ)) +#define H5VL_OBJ_CONNECTOR(VOL_OBJ) (H5VL_obj_get_connector(VOL_OBJ)) +#define H5VL_OBJ_DATA(VOL_OBJ) (H5VL_obj_get_data(VOL_OBJ)) +#define H5VL_OBJ_DATA_RESET(VOL_OBJ) (H5VL_obj_reset_data(VOL_OBJ)) +#endif /* H5VL_MODULE */ + /****************************/ /* Library Private Typedefs */ /****************************/ -/* Internal struct to track VOL connector information for objects */ -typedef struct H5VL_t { - const H5VL_class_t *cls; /* Pointer to connector class struct */ - int64_t nrefs; /* Number of references by objects using this struct */ - hid_t id; /* Identifier for the VOL connector */ -} H5VL_t; - -/* Internal vol object structure returned to the API */ -typedef struct H5VL_object_t { - void *data; /* Pointer to connector-managed data for this object */ - H5VL_t *connector; /* Pointer to VOL connector struct */ - size_t rc; /* Reference count */ -} H5VL_object_t; - -/* Internal structure to hold the connector ID & info for FAPLs */ +/* Typedef for VOL connector (defined in H5VLpkg.h) */ +typedef struct H5VL_connector_t H5VL_connector_t; + +/* Typedef for VOL object (defined in H5VLpkg.h) */ +typedef struct H5VL_object_t H5VL_object_t; + +/* Property for the connector ID & info in FAPLs */ typedef struct H5VL_connector_prop_t { - hid_t connector_id; /* VOL connector's ID */ - const void *connector_info; /* VOL connector info, for open callbacks */ + H5VL_connector_t *connector; /* VOL connector */ + const void *connector_info; /* VOL connector info, for open callbacks */ } H5VL_connector_prop_t; /* Which kind of VOL connector field to use for searching */ @@ -66,15 +71,22 @@ typedef enum H5VL_get_connector_kind_t { /******************************/ /* Utility functions */ -H5_DLL herr_t H5VL_init_phase1(void); -H5_DLL herr_t H5VL_init_phase2(void); -H5_DLL H5VL_t *H5VL_new_connector(hid_t connector_id); -H5_DLL herr_t H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2); -H5_DLL herr_t H5VL_conn_copy(H5VL_connector_prop_t *value); -H5_DLL int64_t H5VL_conn_inc_rc(H5VL_t *connector); -H5_DLL int64_t H5VL_conn_dec_rc(H5VL_t *connector); -H5_DLL herr_t H5VL_conn_free(const H5VL_connector_prop_t *info); -H5_DLL herr_t H5VL_get_cap_flags(const H5VL_connector_prop_t *prop, uint64_t *cap_flags); +H5_DLL herr_t H5VL_init_phase1(void); +H5_DLL herr_t H5VL_init_phase2(void); +H5_DLL herr_t H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2); + +/* Connector routines */ +H5_DLL hid_t H5VL_conn_register(H5VL_connector_t *connector); +H5_DLL int64_t H5VL_conn_inc_rc(H5VL_connector_t *connector); +H5_DLL int64_t H5VL_conn_dec_rc(H5VL_connector_t *connector); +H5_DLL htri_t H5VL_conn_same_class(const H5VL_connector_t *connector1, const H5VL_connector_t *conn2); + +/* Connector property routines */ +H5_DLL herr_t H5VL_conn_prop_copy(H5VL_connector_prop_t *value); +H5_DLL herr_t H5VL_conn_prop_cmp(int *cmp_value, const H5VL_connector_prop_t *prop1, + const H5VL_connector_prop_t *prop2); +H5_DLL herr_t H5VL_conn_prop_free(const H5VL_connector_prop_t *info); +H5_DLL herr_t H5VL_conn_prop_get_cap_flags(const H5VL_connector_prop_t *prop, uint64_t *cap_flags); /* Functions that deal with VOL connectors */ union H5PL_key_t; @@ -97,8 +109,9 @@ H5_DLL void *H5VL_object_unwrap(const H5VL_object_t *vol_obj); H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type); H5_DLL H5VL_object_t *H5VL_vol_object(hid_t id); H5_DLL H5VL_object_t *H5VL_vol_object_verify(hid_t id, H5I_type_t obj_type); -H5_DLL H5VL_object_t *H5VL_create_object(void *object, H5VL_t *vol_connector); -H5_DLL H5VL_object_t *H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id); +H5_DLL H5VL_object_t *H5VL_create_object(void *object, H5VL_connector_t *vol_connector); +H5_DLL H5VL_object_t *H5VL_new_vol_obj(H5I_type_t type, void *object, H5VL_connector_t *vol_connector, + bool wrap_obj); H5_DLL hsize_t H5VL_object_inc_rc(H5VL_object_t *obj); H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); H5_DLL herr_t H5VL_object_is_native(const H5VL_object_t *obj, bool *is_native); @@ -106,15 +119,19 @@ H5_DLL herr_t H5VL_file_is_same(const H5VL_object_t *vol_obj1, const H5V bool *same_file); /* Functions that wrap / unwrap VOL objects */ -H5_DLL herr_t H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx); H5_DLL void *H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj, H5I_type_t obj_type); H5_DLL void *H5VL_unwrap_object(const H5VL_class_t *connector, void *obj); -H5_DLL herr_t H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx); H5_DLL herr_t H5VL_set_vol_wrapper(const H5VL_object_t *vol_obj); H5_DLL herr_t H5VL_inc_vol_wrapper(void *vol_wrap_ctx); H5_DLL herr_t H5VL_dec_vol_wrapper(void *vol_wrap_ctx); H5_DLL herr_t H5VL_reset_vol_wrapper(void); +/* Functions that retrieve values from VOL types */ +H5_DLL size_t H5VL_obj_get_rc(const H5VL_object_t *vol_obj); +H5_DLL H5VL_connector_t *H5VL_obj_get_connector(const H5VL_object_t *vol_obj); +H5_DLL void *H5VL_obj_get_data(const H5VL_object_t *vol_obj); +H5_DLL void H5VL_obj_reset_data(H5VL_object_t *vol_obj); + /* Library state functions */ H5_DLL herr_t H5VL_retrieve_lib_state(void **state); H5_DLL herr_t H5VL_start_lib_state(void); @@ -123,10 +140,9 @@ H5_DLL herr_t H5VL_finish_lib_state(void); H5_DLL herr_t H5VL_free_lib_state(void *state); /* ID registration functions */ -H5_DLL hid_t H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, bool app_ref); +H5_DLL hid_t H5VL_register(H5I_type_t type, void *object, H5VL_connector_t *vol_connector, bool app_ref); H5_DLL hid_t H5VL_wrap_register(H5I_type_t type, void *obj, bool app_ref); -H5_DLL hid_t H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, bool app_ref); -H5_DLL herr_t H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, +H5_DLL herr_t H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_connector_t *vol_connector, bool app_ref, hid_t existing_id); /* Object access functions */ @@ -149,10 +165,10 @@ H5_DLL herr_t H5VL_setup_token_args(hid_t loc_id, H5O_token_t *obj_token, H5VL_o *********************************/ /* Connector "management" functions */ -H5_DLL int H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, const void *src_info); -H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, const void *info1, +H5_DLL int H5VL_copy_connector_info(const H5VL_connector_t *connector, void **dst_info, const void *src_info); +H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_connector_t *connector, int *cmp_value, const void *info1, const void *info2); -H5_DLL herr_t H5VL_free_connector_info(hid_t connector_id, const void *info); +H5_DLL herr_t H5VL_free_connector_info(const H5VL_connector_t *connector, const void *info); /* Attribute functions */ H5_DLL void *H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, @@ -178,10 +194,10 @@ H5_DLL void *H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_p hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); H5_DLL void *H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_dataset_read(size_t count, void *obj[], H5VL_t *connector, hid_t mem_type_id[], +H5_DLL herr_t H5VL_dataset_read(size_t count, void *obj[], H5VL_connector_t *connector, hid_t mem_type_id[], hid_t mem_space_id[], hid_t file_space_id[], hid_t dxpl_id, void *buf[], void **req); -H5_DLL herr_t H5VL_dataset_write(size_t count, void *obj[], H5VL_t *connector, hid_t mem_type_id[], +H5_DLL herr_t H5VL_dataset_write(size_t count, void *obj[], H5VL_connector_t *connector, hid_t mem_type_id[], hid_t mem_space_id[], hid_t file_space_id[], hid_t dxpl_id, const void *buf[], void **req); H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_args_t *args, hid_t dxpl_id, @@ -209,10 +225,10 @@ H5_DLL herr_t H5VL_datatype_optional_op(H5VL_object_t *vol_obj, H5VL_optional_ar H5_DLL herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* File functions */ -H5_DLL void *H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, +H5_DLL void *H5VL_file_create(const H5VL_connector_t *connector, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_file_open(H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, - hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_file_open(H5VL_connector_t *connector, const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_args_t *args, hid_t dxpl_id, void **req); H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_args_t *args, hid_t dxpl_id, diff --git a/src/H5VLquery.c b/src/H5VLquery.c new file mode 100644 index 00000000000..47fd0d21a2c --- /dev/null +++ b/src/H5VLquery.c @@ -0,0 +1,149 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The purpose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: Retrieve the refcount for a VOL object + * + * Purpose: Quick and dirty routine to retrieve the VOL object's refcount. + * (Mainly added to stop non-file routines from poking about in the + * H5VL_object_t data structure) + * + * Return: Refcount on success/abort on failure (shouldn't fail) + * + *------------------------------------------------------------------------- + */ +size_t +H5VL_obj_get_rc(const H5VL_object_t *vol_obj) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + assert(vol_obj); + + FUNC_LEAVE_NOAPI(vol_obj->rc) +} /* end H5VL_obj_get_rc() */ + +/*------------------------------------------------------------------------- + * Function: Retrieve the connector for a VOL object + * + * Purpose: Quick and dirty routine to retrieve the VOL object's connector. + * (Mainly added to stop non-file routines from poking about in the + * H5VL_object_t data structure) + * + * Return: Pointer to connector on success/abort on failure (shouldn't fail) + * + *------------------------------------------------------------------------- + */ +H5VL_connector_t * +H5VL_obj_get_connector(const H5VL_object_t *vol_obj) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + assert(vol_obj); + + FUNC_LEAVE_NOAPI(vol_obj->connector) +} /* end H5VL_obj_get_connector() */ + +/*------------------------------------------------------------------------- + * Function: Retrieve the data for a VOL object + * + * Purpose: Quick and dirty routine to retrieve the VOL object's data. + * (Mainly added to stop non-file routines from poking about in the + * H5VL_object_t data structure) + * + * Return: Pointer to data on success/abort on failure (shouldn't fail) + * + *------------------------------------------------------------------------- + */ +void * +H5VL_obj_get_data(const H5VL_object_t *vol_obj) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + assert(vol_obj); + + FUNC_LEAVE_NOAPI(vol_obj->data) +} /* end H5VL_obj_get_data() */ + +/*------------------------------------------------------------------------- + * Function: Resetthe data for a VOL object + * + * Purpose: Quick and dirty routine to reset the VOL object's data. + * (Mainly added to stop non-file routines from poking about in the + * H5VL_object_t data structure) + * + * Return: none + * + *------------------------------------------------------------------------- + */ +void +H5VL_obj_reset_data(H5VL_object_t *vol_obj) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + assert(vol_obj); + + vol_obj->data = NULL; + + FUNC_LEAVE_NOAPI_VOID +} /* end H5VL_obj_reset_data() */ diff --git a/src/H5VLtest.c b/src/H5VLtest.c index 17368b77e8c..2c50a579e3e 100644 --- a/src/H5VLtest.c +++ b/src/H5VLtest.c @@ -31,8 +31,12 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ #include "H5VLpkg.h" /* Virtual Object Layer */ +/* VOL connectors */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ /****************/ @@ -89,3 +93,65 @@ H5VL__reparse_def_vol_conn_variable_test(void) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL__reparse_def_vol_conn_variable_test() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__is_native_connector_test + * + * Purpose: Check if connector is the native connector + * + * Return: TRUE/FALSE/FAIL + * + *------------------------------------------------------------------------- + */ +htri_t +H5VL__is_native_connector_test(hid_t vol_id) +{ + H5VL_connector_t *native, *connector; + int cmp_value; /* Comparison result */ + htri_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if (NULL == (connector = H5I_object_verify(vol_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID"); + + /* For the time being, we disallow unregistering the native VOL connector */ + native = H5VL_NATIVE_conn_g; + if (H5VL_cmp_connector_cls(&cmp_value, connector->cls, native->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes"); + ret_value = (0 == cmp_value); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__is_native_connector_test() */ + +/*------------------------------------------------------------------------- + * Function: H5VL__register_using_vol_id_test + * + * Purpose: Test infra wrapper around H5VL_register + * + * Return: Success: A valid HDF5 ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL__register_using_vol_id_test(H5I_type_t type, void *object, hid_t vol_id) +{ + H5VL_connector_t *connector; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if (NULL == (connector = H5I_object_verify(vol_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL connector ID"); + + /* Get an ID for the object */ + if ((ret_value = H5VL_register(type, object, connector, true)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__register_using_vol_id_test() */ diff --git a/src/H5private.h b/src/H5private.h index 9950d0ccadc..a506cb36075 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -126,8 +126,8 @@ #define H5_DEFAULT_VFD H5FD_SEC2 #define H5_DEFAULT_VFD_NAME "sec2" -/* Define the default VOL driver */ -#define H5_DEFAULT_VOL H5VL_NATIVE +/* Define the default VOL connector */ +#define H5_DEFAULT_VOL H5VL_NATIVE_conn_g #ifdef H5_HAVE_WIN32_API diff --git a/src/Makefile.am b/src/Makefile.am index 87b12d08b06..1ae1119c758 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,7 +104,8 @@ libhdf5_la_SOURCES= H5.c H5build_settings.c H5checksum.c H5dbg.c H5system.c \ H5VLnative_attr.c H5VLnative_blob.c H5VLnative_dataset.c \ H5VLnative_datatype.c H5VLnative_file.c H5VLnative_group.c \ H5VLnative_link.c H5VLnative_introspect.c H5VLnative_object.c \ - H5VLnative_token.c H5VLpassthru.c H5VLtest.c \ + H5VLnative_token.c H5VLpassthru.c H5VLpassthru_int.c H5VLquery.c \ + H5VLtest.c \ H5VM.c H5WB.c H5Z.c \ H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c H5Zscaleoffset.c \ H5Zszip.c H5Ztrans.c diff --git a/test/event_set.c b/test/event_set.c index 0880157f430..65ecc12887a 100644 --- a/test/event_set.c +++ b/test/event_set.c @@ -316,6 +316,7 @@ test_es_get_requests(void) void *requests[2]; /* Requests */ int req_targets[2]; /* Dummy targets for void * requests */ size_t count; /* # of events in set */ + int cmp_value; /* Comparison value */ bool op_failed; /* Whether an operation failed (unused) */ TESTING("event set get requests"); @@ -395,7 +396,12 @@ test_es_get_requests(void) TEST_ERROR; if (count != 1) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[0]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[0]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; if (connector_ids[1] != H5I_INVALID_HID) TEST_ERROR; @@ -423,7 +429,12 @@ test_es_get_requests(void) TEST_ERROR; if (count != 1) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[0]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[0]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; if (connector_ids[1] != H5I_INVALID_HID) TEST_ERROR; @@ -451,9 +462,19 @@ test_es_get_requests(void) TEST_ERROR; if (count != 2) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[0]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[0]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) + TEST_ERROR; + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[1], connector_ids_g[1]) < 0) TEST_ERROR; - if (connector_ids[1] != connector_ids_g[1]) + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[1]) < 0) TEST_ERROR; /* Try with H5_ITER_DEC */ @@ -464,9 +485,19 @@ test_es_get_requests(void) TEST_ERROR; if (count != 2) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[1]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[1]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) + TEST_ERROR; + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[1], connector_ids_g[0]) < 0) TEST_ERROR; - if (connector_ids[1] != connector_ids_g[0]) + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[1]) < 0) TEST_ERROR; /* Get only requests */ @@ -505,9 +536,19 @@ test_es_get_requests(void) TEST_ERROR; if (count != 2) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[0]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[0]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; - if (connector_ids[1] != connector_ids_g[1]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[1], connector_ids_g[1]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[1]) < 0) TEST_ERROR; if (requests[0] != &req_targets[0]) TEST_ERROR; @@ -524,9 +565,19 @@ test_es_get_requests(void) TEST_ERROR; if (count != 2) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[1]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[1]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; - if (connector_ids[1] != connector_ids_g[0]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[1], connector_ids_g[0]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[1]) < 0) TEST_ERROR; if (requests[0] != &req_targets[1]) TEST_ERROR; @@ -541,7 +592,12 @@ test_es_get_requests(void) TEST_ERROR; if (count != 2) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[0]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[0]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; if (connector_ids[1] != H5I_INVALID_HID) TEST_ERROR; @@ -554,7 +610,12 @@ test_es_get_requests(void) TEST_ERROR; if (count != 2) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[1]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[1]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; if (connector_ids[1] != H5I_INVALID_HID) TEST_ERROR; @@ -593,7 +654,12 @@ test_es_get_requests(void) requests[1] = NULL; if (H5ESget_requests(es_id, H5_ITER_INC, connector_ids, requests, 1, &count) < 0) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[0]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[0]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; if (connector_ids[1] != H5I_INVALID_HID) TEST_ERROR; @@ -610,7 +676,12 @@ test_es_get_requests(void) requests[1] = NULL; if (H5ESget_requests(es_id, H5_ITER_DEC, connector_ids, requests, 1, &count) < 0) TEST_ERROR; - if (connector_ids[0] != connector_ids_g[1]) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, connector_ids[0], connector_ids_g[1]) < 0) + TEST_ERROR; + if (cmp_value) + TEST_ERROR; + if (H5Idec_ref(connector_ids[0]) < 0) TEST_ERROR; if (connector_ids[1] != H5I_INVALID_HID) TEST_ERROR; diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index fa02bcd1039..3ed81d1f051 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -22,52 +22,64 @@ HDF5-DIAG: Error detected in HDF5 (version (number)): #002: (file name) line (number) in H5VL_setup_acc_args(): invalid location identifier major: Invalid arguments to routine minor: Inappropriate type - #003: (file name) line (number) in H5VL_vol_object(): invalid identifier type to function + #003: (file name) line (number) in H5VL_vol_object(): can't retrieve object for ID + major: Virtual Object Layer + minor: Can't get value + #004: (file name) line (number) in H5VL_vol_object_verify(): invalid identifier type to function major: Invalid arguments to routine minor: Inappropriate type ********* Print error stack in customized way ********* - error #000: (file name) in H5VL_vol_object(): line (number) + error #000: (file name) in H5VL_vol_object_verify(): line (number) major: Invalid arguments to routine minor: Inappropriate type - error #001: (file name) in H5VL_setup_acc_args(): line (number) + error #001: (file name) in H5VL_vol_object(): line (number) + major: Virtual Object Layer + minor: Can't get value + error #002: (file name) in H5VL_setup_acc_args(): line (number) major: Invalid arguments to routine minor: Inappropriate type - error #002: (file name) in H5D__create_api_common(): line (number) + error #003: (file name) in H5D__create_api_common(): line (number) major: Dataset minor: Can't set value - error #003: (file name) in H5Dcreate2(): line (number) + error #004: (file name) in H5Dcreate2(): line (number) major: Dataset minor: Unable to create file ********* Print error stack in customized way ********* - error #000: (file name) in H5VL_vol_object(): line (number) + error #000: (file name) in H5VL_vol_object_verify(): line (number) major: Invalid arguments to routine minor: Inappropriate type - error #001: (file name) in H5VL_setup_acc_args(): line (number) + error #001: (file name) in H5VL_vol_object(): line (number) + major: Virtual Object Layer + minor: Can't get value + error #002: (file name) in H5VL_setup_acc_args(): line (number) major: Invalid arguments to routine minor: Inappropriate type - error #002: (file name) in H5D__create_api_common(): line (number) + error #003: (file name) in H5D__create_api_common(): line (number) major: Dataset minor: Can't set value - error #003: (file name) in H5Dcreate2(): line (number) + error #004: (file name) in H5Dcreate2(): line (number) major: Dataset minor: Unable to create file - error #004: (file name) in H5Eget_auto(1 or 2)(): line (number) + error #005: (file name) in H5Eget_auto(1 or 2)(): line (number) major: Error API minor: Can't get value ********* Print error stack in customized way ********* - error #000: (file name) in H5VL_vol_object(): line (number) + error #000: (file name) in H5VL_vol_object_verify(): line (number) major: Invalid arguments to routine minor: Inappropriate type - error #001: (file name) in H5VL_setup_acc_args(): line (number) + error #001: (file name) in H5VL_vol_object(): line (number) + major: Virtual Object Layer + minor: Can't get value + error #002: (file name) in H5VL_setup_acc_args(): line (number) major: Invalid arguments to routine minor: Inappropriate type - error #002: (file name) in H5D__create_api_common(): line (number) + error #003: (file name) in H5D__create_api_common(): line (number) major: Dataset minor: Can't set value - error #003: (file name) in H5Dcreate2(): line (number) + error #004: (file name) in H5Dcreate2(): line (number) major: Dataset minor: Unable to create file HDF5-DIAG: Error detected in HDF5 (version (number)): @@ -80,7 +92,10 @@ HDF5-DIAG: Error detected in HDF5 (version (number)): #002: (file name) line (number) in H5VL_setup_acc_args(): invalid location identifier major: Invalid arguments to routine minor: Inappropriate type - #003: (file name) line (number) in H5VL_vol_object(): invalid identifier type to function + #003: (file name) line (number) in H5VL_vol_object(): can't retrieve object for ID + major: Virtual Object Layer + minor: Can't get value + #004: (file name) line (number) in H5VL_vol_object_verify(): invalid identifier type to function major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (version (number)): diff --git a/test/tmisc.c b/test/tmisc.c index 9c4c3764dc9..8c73aa61949 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -6589,7 +6589,7 @@ test_misc39(void) * the object should have a reference count of 1 since the file * was just created. */ - VERIFY(file_vol_obj->rc, 1, "checking reference count"); + VERIFY(H5VL_OBJ_RC(file_vol_obj), 1, "checking reference count"); /* Create a variable-length string type */ str_type = H5Tcopy(H5T_C_S1); @@ -6650,7 +6650,7 @@ test_misc39(void) * associate each attribute's datatype with the file's VOL object * and will have incremented the reference count by 5. */ - VERIFY(file_vol_obj->rc, 6, "checking reference count"); + VERIFY(H5VL_OBJ_RC(file_vol_obj), 6, "checking reference count"); /* Increments file's VOL object reference count by 1 */ ret = H5Awrite(attr_id1, str_type, buf); @@ -6682,7 +6682,7 @@ test_misc39(void) * incrementing the reference count of the associated file's VOL * object. */ - VERIFY(file_vol_obj->rc, 12, "checking reference count"); + VERIFY(H5VL_OBJ_RC(file_vol_obj), 12, "checking reference count"); ret = H5Aclose(attr_id1); CHECK(ret, FAIL, "H5Aclose"); @@ -6716,7 +6716,7 @@ test_misc39(void) * the object should have a reference count of 1 since the file * was just opened. */ - VERIFY(file_vol_obj->rc, 1, "checking reference count"); + VERIFY(H5VL_OBJ_RC(file_vol_obj), 1, "checking reference count"); /* Increments file's VOL object reference count by 1 */ attr_id1 = H5Aopen(file_id, "varstr_attribute", H5P_DEFAULT); @@ -6737,7 +6737,7 @@ test_misc39(void) * the attributes will also have associated their datatypes with * the file's VOL object. */ - VERIFY(file_vol_obj->rc, 6, "checking reference count"); + VERIFY(H5VL_OBJ_RC(file_vol_obj), 6, "checking reference count"); /* Increments file's VOL object reference count by 1 */ ret = H5Aread(attr_id1, str_type, rbuf); @@ -6769,7 +6769,7 @@ test_misc39(void) * incrementing the reference count of the associated file's VOL * object. */ - VERIFY(file_vol_obj->rc, 12, "checking reference count"); + VERIFY(H5VL_OBJ_RC(file_vol_obj), 12, "checking reference count"); ret = H5Treclaim(str_type, space_id, H5P_DEFAULT, rbuf); ret = H5Treclaim(array_type, space_id, H5P_DEFAULT, arr_rbuf); diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index 806ff4bb511..efa3b7c81b9 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -26,6 +26,9 @@ * ********************************************************************/ #include "ttsafe.h" +#define H5VL_FRIEND /* Suppress error about including H5VLpkg */ +#define H5VL_TESTING +#include "H5VLpkg.h" /* Virtual Object Layer */ #ifdef H5_HAVE_THREADSAFE @@ -63,6 +66,7 @@ tts_error(const void H5_ATTR_UNUSED *params) hid_t dataset = H5I_INVALID_HID; H5TS_thread_t threads[NUM_THREAD]; int value, i; + int is_native; herr_t status; /* Must initialize these at runtime */ @@ -108,7 +112,10 @@ tts_error(const void H5_ATTR_UNUSED *params) status = H5Pget_vol_id(def_fapl, &vol_id); CHECK(status, FAIL, "H5Pget_vol_id"); - if (vol_id == H5VL_NATIVE) { + is_native = H5VL__is_native_connector_test(vol_id); + CHECK(is_native, FAIL, "H5VL__is_native_connector_test"); + + if (is_native) { /* Create a hdf5 file using H5F_ACC_TRUNC access, default file * creation plist and default file access plist */ diff --git a/test/vol.c b/test/vol.c index 9fa4f06c1ca..92b64c2532d 100644 --- a/test/vol.c +++ b/test/vol.c @@ -1727,7 +1727,7 @@ exercise_reg_opt_oper(hid_t fake_vol_id, hid_t reg_opt_vol_id, H5VL_subclass_t s H5CX_push(); /* Create fake object on fake VOL connector */ - if (H5I_INVALID_HID == (obj_id = H5VL_register_using_vol_id(id_type, &fake_obj, fake_vol_id, true))) + if (H5I_INVALID_HID == (obj_id = H5VL__register_using_vol_id_test(id_type, &fake_obj, fake_vol_id))) TEST_ERROR; /* Pop the API context off the stack */ @@ -1783,7 +1783,7 @@ exercise_reg_opt_oper(hid_t fake_vol_id, hid_t reg_opt_vol_id, H5VL_subclass_t s H5CX_push(); /* Create fake object on reg_opt VOL connector */ - if (H5I_INVALID_HID == (obj_id = H5VL_register_using_vol_id(id_type, &fake_obj, reg_opt_vol_id, true))) + if (H5I_INVALID_HID == (obj_id = H5VL__register_using_vol_id_test(id_type, &fake_obj, reg_opt_vol_id))) TEST_ERROR; /* Pop the API context off the stack */ @@ -2209,12 +2209,12 @@ test_vol_cap_flags(void) /* If using the native VOL by default, check flags again with H5P_DEFAULT */ vol_env = getenv(HDF5_VOL_CONNECTOR); if (!vol_env || (0 == strcmp(vol_env, "native"))) { - H5VL_class_t *cls; - hid_t connector_id; + H5VL_connector_t *connector; + hid_t connector_id; if (H5Pget_vol_id(H5P_DEFAULT, &connector_id) < 0) TEST_ERROR; - if (NULL == (cls = H5I_object(connector_id))) + if (NULL == (connector = H5I_object(connector_id))) TEST_ERROR; vol_cap_flags_g = H5VL_CAP_FLAG_NONE; @@ -2222,7 +2222,7 @@ test_vol_cap_flags(void) if (H5Pget_vol_cap_flags(H5P_DEFAULT, &vol_cap_flags_g) < 0) TEST_ERROR; - if (vol_cap_flags_g != cls->cap_flags) + if (vol_cap_flags_g != connector->cls->cap_flags) TEST_ERROR; if (H5VLclose(connector_id) < 0) diff --git a/test/vol_plugin.c b/test/vol_plugin.c index 8ebc050c3b9..414f18c6677 100644 --- a/test/vol_plugin.c +++ b/test/vol_plugin.c @@ -257,6 +257,7 @@ test_getters(void) htri_t is_registered = FAIL; hid_t vol_id = H5I_INVALID_HID; hid_t vol_id_out = H5I_INVALID_HID; + int cmp_value; /* Comparison value */ TESTING("VOL getters"); @@ -273,7 +274,10 @@ test_getters(void) /* Get the connector's ID by name */ if ((vol_id_out = H5VLget_connector_id_by_name(NULL_VOL_CONNECTOR_NAME)) < 0) TEST_ERROR; - if (vol_id != vol_id_out) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, vol_id, vol_id_out) < 0) + TEST_ERROR; + if (cmp_value) FAIL_PUTS_ERROR("VOL connector IDs don't match"); if (H5VLclose(vol_id_out) < 0) TEST_ERROR; @@ -295,7 +299,10 @@ test_getters(void) /* Get the connector's ID by value */ if ((vol_id_out = H5VLget_connector_id_by_value(NULL_VOL_CONNECTOR_VALUE)) < 0) TEST_ERROR; - if (vol_id != vol_id_out) + cmp_value = 0; + if (H5VLcmp_connector_cls(&cmp_value, vol_id, vol_id_out) < 0) + TEST_ERROR; + if (cmp_value) FAIL_PUTS_ERROR("VOL connector IDs don't match"); if (H5VLclose(vol_id_out) < 0) TEST_ERROR; diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 29419e297af..83037f1de62 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -671,12 +671,8 @@ h5tools_set_fapl_vol(hid_t fapl_id, h5tools_vol_info_t *vol_info) /* Check for VOL connectors that ship with the library, then try * registering by name if that fails. */ - if (!strcmp(vol_info->u.name, H5VL_NATIVE_NAME)) { - connector_id = H5VL_NATIVE; - } - else if (!strcmp(vol_info->u.name, H5VL_PASSTHRU_NAME)) { + if (!strcmp(vol_info->u.name, H5VL_PASSTHRU_NAME)) connector_id = H5VL_PASSTHRU; - } else { /* NOTE: Not being able to pass in a VIPL may be a limitation for some * connectors. @@ -698,12 +694,8 @@ h5tools_set_fapl_vol(hid_t fapl_id, h5tools_vol_info_t *vol_info) } else { /* Check for VOL connectors that ship with the library */ - if (vol_info->u.value == H5VL_NATIVE_VALUE) { - connector_id = H5VL_NATIVE; - } - else if (vol_info->u.value == H5VL_PASSTHRU_VALUE) { + if (vol_info->u.value == H5VL_PASSTHRU_VALUE) connector_id = H5VL_PASSTHRU; - } else { /* NOTE: Not being able to pass in a VIPL may be a limitation for some * connectors.