Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-18 09:16:02

0001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
0002  * Copyright by The HDF Group.                                               *
0003  * All rights reserved.                                                      *
0004  *                                                                           *
0005  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
0006  * terms governing use, modification, and redistribution, is contained in    *
0007  * the COPYING file, which can be found at the root of the source code       *
0008  * distribution tree, or in https://www.hdfgroup.org/licenses.               *
0009  * If you do not have access to either file, you may request a copy from     *
0010  * help@hdfgroup.org.                                                        *
0011  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0012 
0013 #ifndef H5FDpublic_H
0014 #define H5FDpublic_H
0015 
0016 #include "H5public.h"  /* Generic Functions                        */
0017 #include "H5Fpublic.h" /* Files                                    */
0018 #include "H5Ipublic.h" /* Identifiers                              */
0019 
0020 /*****************/
0021 /* Public Macros */
0022 /*****************/
0023 
0024 #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */
0025 
0026 /* VFD identifier values
0027  * These are H5FD_class_value_t values, NOT hid_t values!
0028  */
0029 #define H5_VFD_INVALID   ((H5FD_class_value_t)(-1))
0030 #define H5_VFD_SEC2      ((H5FD_class_value_t)(0))
0031 #define H5_VFD_CORE      ((H5FD_class_value_t)(1))
0032 #define H5_VFD_LOG       ((H5FD_class_value_t)(2))
0033 #define H5_VFD_FAMILY    ((H5FD_class_value_t)(3))
0034 #define H5_VFD_MULTI     ((H5FD_class_value_t)(4))
0035 #define H5_VFD_STDIO     ((H5FD_class_value_t)(5))
0036 #define H5_VFD_SPLITTER  ((H5FD_class_value_t)(6))
0037 #define H5_VFD_MPIO      ((H5FD_class_value_t)(7))
0038 #define H5_VFD_DIRECT    ((H5FD_class_value_t)(8))
0039 #define H5_VFD_MIRROR    ((H5FD_class_value_t)(9))
0040 #define H5_VFD_HDFS      ((H5FD_class_value_t)(10))
0041 #define H5_VFD_ROS3      ((H5FD_class_value_t)(11))
0042 #define H5_VFD_SUBFILING ((H5FD_class_value_t)(12))
0043 #define H5_VFD_IOC       ((H5FD_class_value_t)(13))
0044 #define H5_VFD_ONION     ((H5FD_class_value_t)(14))
0045 
0046 /* VFD IDs below this value are reserved for library use. */
0047 #define H5_VFD_RESERVED 256
0048 
0049 /* Maximum VFD ID */
0050 #define H5_VFD_MAX 65535
0051 
0052 /* Define VFL driver features that can be enabled on a per-driver basis */
0053 /* These are returned with the 'query' function pointer in H5FD_class_t */
0054 /*
0055  * Defining H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that
0056  * the library will attempt to allocate a larger block for metadata and
0057  * then sub-allocate each metadata request from that larger block.
0058  */
0059 #define H5FD_FEAT_AGGREGATE_METADATA 0x00000001
0060 /*
0061  * Defining H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that
0062  * the library will attempt to cache metadata as it is written to the file
0063  * and build up a larger block of metadata to eventually pass to the VFL
0064  * 'write' routine.
0065  *
0066  * Distinguish between updating the metadata accumulator on writes and
0067  * reads.  This is particularly (perhaps only, even) important for MPI-I/O
0068  * where we guarantee that writes are collective, but reads may not be.
0069  * If we were to allow the metadata accumulator to be written during a
0070  * read operation, the application would hang.
0071  */
0072 #define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002
0073 #define H5FD_FEAT_ACCUMULATE_METADATA_READ  0x00000004
0074 #define H5FD_FEAT_ACCUMULATE_METADATA                                                                        \
0075     (H5FD_FEAT_ACCUMULATE_METADATA_WRITE | H5FD_FEAT_ACCUMULATE_METADATA_READ)
0076 /*
0077  * Defining H5FD_FEAT_DATA_SIEVE for a VFL driver means that
0078  * the library will attempt to cache raw data as it is read from/written to
0079  * a file in a "data sieve" buffer.  See Rajeev Thakur's papers:
0080  *  http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz
0081  *  http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz
0082  */
0083 #define H5FD_FEAT_DATA_SIEVE 0x00000008
0084 /*
0085  * Defining H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that
0086  * the library will attempt to allocate a larger block for "small" raw data
0087  * and then sub-allocate "small" raw data requests from that larger block.
0088  */
0089 #define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010
0090 /*
0091  * Defining H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that
0092  * the library will ignore the driver info that is encoded in the file
0093  * for the VFL driver.  (This will cause the driver info to be eliminated
0094  * from the file when it is flushed/closed, if the file is opened R/W).
0095  */
0096 #define H5FD_FEAT_IGNORE_DRVRINFO 0x00000020
0097 /*
0098  * Defining the H5FD_FEAT_DIRTY_DRVRINFO_LOAD for a VFL driver means that
0099  * the library will mark the driver info dirty when the file is opened
0100  * R/W.  This will cause the driver info to be re-encoded when the file
0101  * is flushed/closed.
0102  */
0103 #define H5FD_FEAT_DIRTY_DRVRINFO_LOAD 0x00000040
0104 /*
0105  * Defining H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that
0106  * the handle for the VFD (returned with the 'get_handle' callback) is
0107  * of type 'int' and is compatible with POSIX I/O calls.
0108  */
0109 #define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080
0110 /*
0111  * Defining H5FD_FEAT_HAS_MPI for a VFL driver means that
0112  * the driver makes use of MPI communication and code may retrieve
0113  * communicator/rank information from it
0114  */
0115 #define H5FD_FEAT_HAS_MPI 0x00000100
0116 /*
0117  * Defining the H5FD_FEAT_ALLOCATE_EARLY for a VFL driver will force
0118  * the library to use the H5D_ALLOC_TIME_EARLY on dataset create
0119  * instead of the default H5D_ALLOC_TIME_LATE
0120  */
0121 #define H5FD_FEAT_ALLOCATE_EARLY 0x00000200
0122 /*
0123  * Defining H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that
0124  * the driver is able to use a file image in the fapl as the initial
0125  * contents of a file.
0126  */
0127 #define H5FD_FEAT_ALLOW_FILE_IMAGE 0x00000400
0128 /*
0129  * Defining H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver
0130  * means that the driver is able to use callbacks to make a copy of the
0131  * image to store in memory.
0132  */
0133 #define H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS 0x00000800
0134 /*
0135  * Defining H5FD_FEAT_SUPPORTS_SWMR_IO for a VFL driver means that the
0136  * driver supports the single-writer/multiple-readers I/O pattern.
0137  */
0138 #define H5FD_FEAT_SUPPORTS_SWMR_IO 0x00001000
0139 /*
0140  * Defining H5FD_FEAT_USE_ALLOC_SIZE for a VFL driver
0141  * means that the library will just pass the allocation size to the
0142  * the driver's allocation callback which will eventually handle alignment.
0143  * This is specifically used for the multi/split driver.
0144  */
0145 #define H5FD_FEAT_USE_ALLOC_SIZE 0x00002000
0146 /*
0147  * Defining H5FD_FEAT_PAGED_AGGR for a VFL driver
0148  * means that the driver needs special file space mapping for paged aggregation.
0149  * This is specifically used for the multi/split driver.
0150  */
0151 #define H5FD_FEAT_PAGED_AGGR 0x00004000
0152 /*
0153  * Defining H5FD_FEAT_DEFAULT_VFD_COMPATIBLE for a VFL driver
0154  * that creates a file which is compatible with the default VFD.
0155  * Generally, this means that the VFD creates a single file that follows
0156  * the canonical HDF5 file format.
0157  * Regarding the Splitter VFD specifically, only drivers with this flag
0158  * enabled may be used as the Write-Only (W/O) channel driver.
0159  */
0160 #define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000
0161 /*
0162  * Defining H5FD_FEAT_MEMMANAGE for a VFL driver means that
0163  * the driver uses special memory management routines or wishes
0164  * to do memory management in a specific manner. Therefore, HDF5
0165  * should request that the driver handle any memory management
0166  * operations when appropriate.
0167  */
0168 #define H5FD_FEAT_MEMMANAGE 0x00010000
0169 
0170 /* ctl function definitions: */
0171 #define H5FD_CTL_OPC_RESERVED 512 /* Opcodes below this value are reserved for library use */
0172 #define H5FD_CTL_OPC_EXPER_MIN                                                                               \
0173     H5FD_CTL_OPC_RESERVED /* Minimum opcode value available for experimental use                             \
0174                            */
0175 #define H5FD_CTL_OPC_EXPER_MAX                                                                               \
0176     (H5FD_CTL_OPC_RESERVED + 511) /* Maximum opcode value available for experimental use */
0177 
0178 /* ctl function op codes: */
0179 #define H5FD_CTL_INVALID_OPCODE              0
0180 #define H5FD_CTL_TEST_OPCODE                 1
0181 #define H5FD_CTL_GET_MPI_COMMUNICATOR_OPCODE 2
0182 #define H5FD_CTL_GET_MPI_INFO_OPCODE         9
0183 #define H5FD_CTL_GET_MPI_RANK_OPCODE         3
0184 #define H5FD_CTL_GET_MPI_SIZE_OPCODE         4
0185 #define H5FD_CTL_MEM_ALLOC                   5
0186 #define H5FD_CTL_MEM_FREE                    6
0187 #define H5FD_CTL_MEM_COPY                    7
0188 #define H5FD_CTL_GET_MPI_FILE_SYNC_OPCODE    8
0189 
0190 /* ctl function flags: */
0191 
0192 /* Definitions:
0193  *
0194  * WARNING: While the following definitions of Terminal
0195  * and Passthrough VFDs should be workable for now, they
0196  * have to be adjusted as our use cases for VFDs expand.
0197  *
0198  *                                   JRM -- 8/4/21
0199  *
0200  *
0201  * Terminal VFD: Lowest VFD in the VFD stack through
0202  * which all VFD calls pass.  Note that this definition
0203  * is situational.  For example, the sec2 VFD is typically
0204  * terminal.  However, in the context of the family file
0205  * driver, it is not -- the family file driver is the
0206  * bottom VFD through which all VFD calls pass, and thus
0207  * it is terminal.
0208  *
0209  * Similarly, on the splitter VFD, a sec2 VFD on the
0210  * R/W channel is terminal, but a sec2 VFD on the W/O
0211  * channel is not.
0212  *
0213  *
0214  * Pass through VFD:  Any VFD that relays all VFD calls
0215  * (with the possible exception of some non-I/O related
0216  * calls) to underlying VFD(s).
0217  */
0218 
0219 /* Unknown op codes should be ignored silently unless the
0220  * H5FD_CTL_FAIL_IF_UNKNOWN_FLAG is set.
0221  *
0222  * On terminal VFDs, unknown op codes should generate an
0223  * error unconditionally if this flag is set.
0224  *
0225  * On pass through VFDs, unknown op codes should be routed
0226  * to the underlying VFD(s) as indicated by any routing
0227  * flags.  In the absence of such flags, the VFD should
0228  * generate an error.
0229  */
0230 #define H5FD_CTL_FAIL_IF_UNKNOWN_FLAG 0x0001
0231 
0232 /* The H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG is used only
0233  * by non-ternminal VFDs, and only applies to unknown
0234  * opcodes. (known op codes should be handled as
0235  * appropriate.)
0236  *
0237  * If this flag is set for an unknown op code, that
0238  * op code should be passed to the next VFD down
0239  * the VFD stack en-route to the terminal VFD.
0240  * If that VFD does not support the ctl call, the
0241  * pass through VFD should fail or succeed as directed
0242  * by the  H5FD_CTL_FAIL_IF_UNKNOWN_FLAG.
0243  */
0244 #define H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG 0x0002
0245 
0246 /*******************/
0247 /* Public Typedefs */
0248 /*******************/
0249 
0250 /*
0251  * File driver identifiers.
0252  *
0253  * Values 0 through 255 are for drivers defined by the HDF5 library.
0254  * Values 256 through 511 are available for testing new drivers.
0255  * Subsequent values should be obtained from the HDF5 development
0256  * team at mailto:help@hdfgroup.org.
0257  */
0258 typedef int H5FD_class_value_t;
0259 
0260 /* Types of allocation requests: see H5Fpublic.h  */
0261 typedef enum H5F_mem_t H5FD_mem_t;
0262 
0263 /**
0264  * Define enum for the source of file image callbacks
0265  */
0266 //! <!-- [H5FD_file_image_op_t_snip] -->
0267 typedef enum {
0268     H5FD_FILE_IMAGE_OP_NO_OP,
0269     H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET,
0270     /**< Passed to the \p image_malloc and \p image_memcpy callbacks when a
0271      * file image buffer is to be copied while being set in a file access
0272      * property list (FAPL)*/
0273     H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY,
0274     /**< Passed to the \p image_malloc and \p image_memcpy callbacks
0275      * when a file image buffer is to be copied when a FAPL is copied*/
0276     H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET,
0277     /**<Passed to the \p image_malloc and \p image_memcpy callbacks when
0278      * a file image buffer is to be copied while being retrieved from a FAPL*/
0279     H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE,
0280     /**<Passed to the \p image_free callback when a file image
0281      * buffer is to be released during a FAPL close operation*/
0282     H5FD_FILE_IMAGE_OP_FILE_OPEN,
0283     /**<Passed to the \p image_malloc and
0284      * \p image_memcpy callbackswhen a
0285      * file image buffer is to be copied during a file open operation \n
0286      * While the file image being opened will typically be copied from a
0287      * FAPL, this need not always be the case. For example, the core file
0288      * driver, also known as the memory file driver, takes its initial
0289      * image from a file.*/
0290     H5FD_FILE_IMAGE_OP_FILE_RESIZE,
0291     /**<Passed to the \p image_realloc callback when a file driver needs
0292      * to resize an image buffer*/
0293     H5FD_FILE_IMAGE_OP_FILE_CLOSE
0294     /**<Passed to the \p image_free callback when an image buffer is to
0295      * be released during a file close operation*/
0296 } H5FD_file_image_op_t;
0297 //! <!-- [H5FD_file_image_op_t_snip] -->
0298 
0299 /**
0300  * Define structure to hold file image callbacks
0301  */
0302 //! <!-- [H5FD_file_image_callbacks_t_snip] -->
0303 typedef struct {
0304     /**
0305      * \param[in] size Size in bytes of the file image buffer to allocate
0306      * \param[in] file_image_op A value from H5FD_file_image_op_t indicating
0307      *                          the operation being performed on the file image
0308      *                          when this callback is invoked
0309      * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
0310      *            parameter \p udata
0311      */
0312     //! <!-- [image_malloc_snip] -->
0313     void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op, void *udata);
0314     //! <!-- [image_malloc_snip] -->
0315     /**
0316      * \param[in] dest Address of the destination buffer
0317      * \param[in] src Address of the source buffer
0318      * \param[in] size Size in bytes of the file image buffer to allocate
0319      * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating
0320      *                          the operation being performed on the file image
0321      *                          when this callback is invoked
0322      * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
0323      *            parameter \p udata
0324      */
0325     //! <!-- [image_memcpy_snip] -->
0326     void *(*image_memcpy)(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op,
0327                           void *udata);
0328     //! <!-- [image_memcpy_snip] -->
0329     /**
0330      * \param[in] ptr Pointer to the buffer being reallocated
0331      * \param[in] size Size in bytes of the file image buffer to allocate
0332      * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating
0333      *                          the operation being performed on the file image
0334      *                          when this callback is invoked
0335      * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
0336      *            parameter \p udata
0337      */
0338     //! <!-- [image_realloc_snip] -->
0339     void *(*image_realloc)(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata);
0340     //! <!-- [image_realloc_snip] -->
0341     /**
0342      * \param[in] ptr Pointer to the buffer being reallocated
0343      * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating
0344      *                          the operation being performed on the file image
0345      *                          when this callback is invoked
0346      * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
0347      *            parameter \p udata
0348      */
0349     //! <!-- [image_free_snip] -->
0350     herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op, void *udata);
0351     //! <!-- [image_free_snip] -->
0352     /**
0353      * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
0354      *            parameter \p udata
0355      */
0356     //! <!-- [udata_copy_snip] -->
0357     void *(*udata_copy)(void *udata);
0358     //! <!-- [udata_copy_snip] -->
0359     /**
0360      * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
0361      *            parameter \p udata
0362      */
0363     //! <!-- [udata_free_snip] -->
0364     herr_t (*udata_free)(void *udata);
0365     //! <!-- [udata_free_snip] -->
0366     /**
0367      * \brief The final field in the #H5FD_file_image_callbacks_t struct,
0368      *        provides a pointer to user-defined data. This pointer will be
0369      *        passed to the image_malloc, image_memcpy, image_realloc, and
0370      *        image_free callbacks. Define udata as NULL if no user-defined
0371      *        data is provided.
0372      */
0373     void *udata;
0374 } H5FD_file_image_callbacks_t;
0375 //! <!-- [H5FD_file_image_callbacks_t_snip] -->
0376 
0377 /**
0378  * Define structure to hold "ctl memory copy" parameters
0379  */
0380 //! <!-- [H5FD_ctl_memcpy_args_t_snip] -->
0381 typedef struct H5FD_ctl_memcpy_args_t {
0382     void       *dstbuf;  /**< Destination buffer */
0383     hsize_t     dst_off; /**< Offset within destination buffer */
0384     const void *srcbuf;  /**< Source buffer */
0385     hsize_t     src_off; /**< Offset within source buffer */
0386     size_t      len;     /**< Length of data to copy from source buffer */
0387 } H5FD_ctl_memcpy_args_t;
0388 //! <!-- [H5FD_ctl_memcpy_args_t_snip] -->
0389 
0390 /********************/
0391 /* Public Variables */
0392 /********************/
0393 
0394 /*********************/
0395 /* Public Prototypes */
0396 /*********************/
0397 
0398 #ifdef __cplusplus
0399 extern "C" {
0400 #endif
0401 
0402 /* Function prototypes */
0403 
0404 /**
0405  * \ingroup H5FD
0406  *
0407  * \brief Allows querying a VFD ID for features before the file is opened
0408  *
0409  * \param[in] driver_id Virtual File Driver (VFD) ID
0410  * \param[out] flags VFD flags supported
0411  *
0412  * \return \herr_t
0413  *
0414  * \details Queries a virtual file driver (VFD) for feature flags. Takes a
0415  *          VFD hid_t so it can be used before the file is opened. For example,
0416  *          this could be used to check if a VFD supports SWMR.
0417  *
0418  * \note The flags obtained here are just those of the base driver and
0419  *       do not take any configuration options (e.g., set via a fapl
0420  *       call) into consideration.
0421  *
0422  * \since 1.10.2
0423  */
0424 H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/);
0425 
0426 #ifdef __cplusplus
0427 }
0428 #endif
0429 #endif