Skip to content

Commit

Permalink
Implement support for loading of Virtual File Drivers as plugins
Browse files Browse the repository at this point in the history
Fix plugin caching for VOL connector and VFD plugins

Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack
  • Loading branch information
jhendersonHDF committed Apr 28, 2021
1 parent 00dc456 commit dbbaedd
Show file tree
Hide file tree
Showing 87 changed files with 2,573 additions and 419 deletions.
3 changes: 3 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,8 @@
./test/ntypes.c
./test/null_vol_connector.c
./test/null_vol_connector.h
./test/null_vfd_plugin.c
./test/null_vfd_plugin.h
./test/objcopy.c
./test/objcopy_ref.c
./test/ohdr.c
Expand Down Expand Up @@ -1371,6 +1373,7 @@
./test/vds_swmr_reader.c
./test/vds_swmr_writer.c
./test/vfd.c
./test/vfd_plugin.c
./test/vol.c
./test/vol_plugin.c

Expand Down
1 change: 1 addition & 0 deletions bin/trace
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $Source = "";
"H5D_scatter_func_t" => "DS",
"H5FD_mpio_xfer_t" => "Dt",
"H5D_vds_view_t" => "Dv",
"H5FD_class_value_t" => "DV",
"herr_t" => "e",
"H5E_auto1_t" => "Ea",
"H5E_auto2_t" => "EA",
Expand Down
33 changes: 25 additions & 8 deletions src/H5E.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,16 +1532,22 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func /*out*/, void **client_data /*ou
H5E_auto_op_t op; /* Error stack function */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
/* Don't clear the error stack! :-) */
FUNC_ENTER_API_NOCLEAR(FAIL)
H5TRACE3("e", "ixx", estack_id, func, client_data);

if (estack_id == H5E_DEFAULT) {
if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in
non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
} /* end if */
else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
else {
/* Only clear the error stack if it's not the default stack */
H5E_clear_stack(NULL);

if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
} /* end else */

/* Get the automatic error reporting information */
if (H5E__get_auto(estack, &op, client_data) < 0)
Expand Down Expand Up @@ -1598,8 +1604,13 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data)
non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
} /* end if */
else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
else {
/* Only clear the error stack if it's not the default stack */
H5E_clear_stack(NULL);

if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
} /* end else */

#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Get the automatic error reporting information */
Expand Down Expand Up @@ -1646,16 +1657,22 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack)
H5E_t *estack; /* Error stack to operate on */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
/* Don't clear the error stack! :-) */
FUNC_ENTER_API_NOCLEAR(FAIL)
H5TRACE2("e", "i*Iu", estack_id, is_stack);

if (estack_id == H5E_DEFAULT) {
if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in
non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
} /* end if */
else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
else {
/* Only clear the error stack if it's not the default stack */
H5E_clear_stack(NULL);

if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
} /* end else */

/* Check if the error stack reporting function is the "newer" stack type */
if (is_stack)
Expand Down
56 changes: 56 additions & 0 deletions src/H5FD.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,62 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_register() */

/*-------------------------------------------------------------------------
* Function: H5FDis_driver_registered_by_name
*
* Purpose: Tests whether a VFD class has been registered or not
* according to a supplied driver name.
*
* Return: >0 if a VFD with that name has been registered
* 0 if a VFD with that name has NOT been registered
* <0 on errors
*
*-------------------------------------------------------------------------
*/
htri_t
H5FDis_driver_registered_by_name(const char *driver_name)
{
htri_t ret_value = FALSE; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE1("t", "*s", driver_name);

/* Check if driver with this name is registered */
if ((ret_value = H5FD_is_driver_registered_by_name(driver_name)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check if VFD is registered")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDis_driver_registered_by_name() */

/*-------------------------------------------------------------------------
* Function: H5FDis_driver_registered_by_value
*
* Purpose: Tests whether a VFD class has been registered or not
* according to a supplied driver value (ID).
*
* Return: >0 if a VFD with that value has been registered
* 0 if a VFD with that value hasn't been registered
* <0 on errors
*
*-------------------------------------------------------------------------
*/
htri_t
H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value)
{
htri_t ret_value = FALSE;

FUNC_ENTER_API(FAIL)
H5TRACE1("t", "DV", driver_value);

/* Check if driver with this value is registered */
if ((ret_value = H5FD_is_driver_registered_by_value(driver_value)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check if VFD is registered")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDis_driver_registered_by_value() */

/*-------------------------------------------------------------------------
* Function: H5FDunregister
*
Expand Down
20 changes: 20 additions & 0 deletions src/H5FDcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "H5Pprivate.h" /* Property lists */
#include "H5SLprivate.h" /* Skip lists */

/* For HDF5 plugin functionality */
#include "H5PLextern.h"

/* The driver identification number, initialized at runtime */
static hid_t H5FD_CORE_g = 0;

Expand Down Expand Up @@ -151,6 +154,7 @@ static herr_t H5FD__core_unlock(H5FD_t *_file);
static herr_t H5FD__core_delete(const char *filename, hid_t fapl_id);

static const H5FD_class_t H5FD_core_g = {
H5FD_CORE_VALUE, /* value */
"core", /* name */
MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
Expand Down Expand Up @@ -1743,3 +1747,19 @@ H5FD__core_delete(const char *filename, hid_t fapl_id)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__core_delete() */

/* These two functions are necessary to allow loading of
* this VFD as a plugin.
*/

H5PL_type_t
H5PLget_plugin_type(void)
{
return H5PL_TYPE_VFD;
}

const void *
H5PLget_plugin_info(void)
{
return &H5FD_core_g;
}
1 change: 1 addition & 0 deletions src/H5FDcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define H5FDcore_H

#define H5FD_CORE (H5FD_core_init())
#define H5FD_CORE_VALUE H5_VFD_CORE

#ifdef __cplusplus
extern "C" {
Expand Down
20 changes: 20 additions & 0 deletions src/H5FDdirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */

/* For HDF5 plugin functionality */
#include "H5PLextern.h"

#ifdef H5_HAVE_DIRECT

/* The driver identification number, initialized at runtime */
Expand Down Expand Up @@ -140,6 +143,7 @@ static herr_t H5FD__direct_unlock(H5FD_t *_file);
static herr_t H5FD__direct_delete(const char *filename, hid_t fapl_id);

static const H5FD_class_t H5FD_direct_g = {
H5FD_DIRECT_VALUE, /* value */
"direct", /* name */
MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
Expand Down Expand Up @@ -1407,4 +1411,20 @@ H5FD__direct_delete(const char *filename, hid_t H5_ATTR_UNUSED fapl_id)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__direct_delete() */

/* These two functions are necessary to allow loading of
* this VFD as a plugin.
*/

H5PL_type_t
H5PLget_plugin_type(void)
{
return H5PL_TYPE_VFD;
}

const void *
H5PLget_plugin_info(void)
{
return &H5FD_direct_g;
}

#endif /* H5_HAVE_DIRECT */
2 changes: 2 additions & 0 deletions src/H5FDdirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@

#ifdef H5_HAVE_DIRECT
#define H5FD_DIRECT (H5FD_direct_init())
#define H5FD_DIRECT_VALUE H5_VFD_DIRECT
#else
#define H5FD_DIRECT (H5I_INVALID_HID)
#define H5FD_DIRECT_VALUE H5_VFD_INVALID
#endif /* H5_HAVE_DIRECT */

#ifdef H5_HAVE_DIRECT
Expand Down
20 changes: 20 additions & 0 deletions src/H5FDfamily.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */

/* For HDF5 plugin functionality */
#include "H5PLextern.h"

/* The size of the member name buffers */
#define H5FD_FAM_MEMB_NAME_BUF_SIZE 4096

Expand Down Expand Up @@ -105,6 +108,7 @@ static herr_t H5FD__family_delete(const char *filename, hid_t fapl_id);

/* The class struct */
static const H5FD_class_t H5FD_family_g = {
H5FD_FAMILY_VALUE, /* value */
"family", /* name */
HADDR_MAX, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
Expand Down Expand Up @@ -1436,3 +1440,19 @@ H5FD__family_delete(const char *filename, hid_t fapl_id)

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__family_delete() */

/* These two functions are necessary to allow loading of
* this VFD as a plugin.
*/

H5PL_type_t
H5PLget_plugin_type(void)
{
return H5PL_TYPE_VFD;
}

const void *
H5PLget_plugin_info(void)
{
return &H5FD_family_g;
}
1 change: 1 addition & 0 deletions src/H5FDfamily.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define H5FDfamily_H

#define H5FD_FAMILY (H5FD_family_init())
#define H5FD_FAMILY_VALUE H5_VFD_FAMILY

#ifdef __cplusplus
extern "C" {
Expand Down
20 changes: 20 additions & 0 deletions src/H5FDhdfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */

/* For HDF5 plugin functionality */
#include "H5PLextern.h"

#ifdef H5_HAVE_LIBHDFS

/* HDFS routines */
Expand Down Expand Up @@ -278,6 +281,7 @@ static herr_t H5FD__hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing
static herr_t H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t *fa);

static const H5FD_class_t H5FD_hdfs_g = {
H5FD_HDFS_VALUE, /* value */
"hdfs", /* name */
MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
Expand Down Expand Up @@ -1644,4 +1648,20 @@ H5FD__hdfs_truncate(H5FD_t H5_ATTR_UNUSED *_file, hid_t H5_ATTR_UNUSED dxpl_id,
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__hdfs_truncate() */

/* These two functions are necessary to allow loading of
* this VFD as a plugin.
*/

H5PL_type_t
H5PLget_plugin_type(void)
{
return H5PL_TYPE_VFD;
}

const void *
H5PLget_plugin_info(void)
{
return &H5FD_hdfs_g;
}

#endif /* H5_HAVE_LIBHDFS */
2 changes: 2 additions & 0 deletions src/H5FDhdfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

#ifdef H5_HAVE_LIBHDFS
#define H5FD_HDFS (H5FD_hdfs_init())
#define H5FD_HDFS_VALUE H5_VFD_HDFS
#else /* H5_HAVE_LIBHDFS */
#define H5FD_HDFS (H5I_INVALID_HID)
#define H5FD_HDFS_VALUE H5_VFD_INVALID
#endif /* H5_HAVE_LIBHDFS */

#ifdef H5_HAVE_LIBHDFS
Expand Down
Loading

0 comments on commit dbbaedd

Please sign in to comment.