H5FDpublic.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * Copyright by the Board of Trustees of the University of Illinois. *
  4. * All rights reserved. *
  5. * *
  6. * This file is part of HDF5. The full HDF5 copyright notice, including *
  7. * terms governing use, modification, and redistribution, is contained in *
  8. * the COPYING file, which can be found at the root of the source code *
  9. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  10. * If you do not have access to either file, you may request a copy from *
  11. * help@hdfgroup.org. *
  12. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  13. /*
  14. * Programmer: Robb Matzke
  15. * Monday, July 26, 1999
  16. */
  17. #ifndef H5FDpublic_H
  18. #define H5FDpublic_H
  19. /* Public headers needed by this file */
  20. #include "H5public.h" /* Generic Functions */
  21. #include "H5Fpublic.h" /* Files */
  22. /*****************/
  23. /* Public Macros */
  24. /*****************/
  25. #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */
  26. /* VFD identifier values
  27. * These are H5FD_class_value_t values, NOT hid_t values!
  28. */
  29. #define H5_VFD_INVALID ((H5FD_class_value_t)(-1))
  30. #define H5_VFD_SEC2 ((H5FD_class_value_t)(0))
  31. #define H5_VFD_CORE ((H5FD_class_value_t)(1))
  32. #define H5_VFD_LOG ((H5FD_class_value_t)(2))
  33. #define H5_VFD_FAMILY ((H5FD_class_value_t)(3))
  34. #define H5_VFD_MULTI ((H5FD_class_value_t)(4))
  35. #define H5_VFD_STDIO ((H5FD_class_value_t)(5))
  36. #define H5_VFD_SPLITTER ((H5FD_class_value_t)(6))
  37. #ifdef H5_HAVE_PARALLEL
  38. #define H5_VFD_MPIO ((H5FD_class_value_t)(7))
  39. #endif
  40. #ifdef H5_HAVE_DIRECT
  41. #define H5_VFD_DIRECT ((H5FD_class_value_t)(8))
  42. #endif
  43. #ifdef H5_HAVE_MIRROR_VFD
  44. #define H5_VFD_MIRROR ((H5FD_class_value_t)(9))
  45. #endif
  46. #ifdef H5_HAVE_LIBHDFS
  47. #define H5_VFD_HDFS ((H5FD_class_value_t)(10))
  48. #endif
  49. #ifdef H5_HAVE_ROS3_VFD
  50. #define H5_VFD_ROS3 ((H5FD_class_value_t)(11))
  51. #endif
  52. /* VFD IDs below this value are reserved for library use. */
  53. #define H5_VFD_RESERVED 256
  54. /* Maximum VFD ID */
  55. #define H5_VFD_MAX 65535
  56. /* Define VFL driver features that can be enabled on a per-driver basis */
  57. /* These are returned with the 'query' function pointer in H5FD_class_t */
  58. /*
  59. * Defining H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that
  60. * the library will attempt to allocate a larger block for metadata and
  61. * then sub-allocate each metadata request from that larger block.
  62. */
  63. #define H5FD_FEAT_AGGREGATE_METADATA 0x00000001
  64. /*
  65. * Defining H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that
  66. * the library will attempt to cache metadata as it is written to the file
  67. * and build up a larger block of metadata to eventually pass to the VFL
  68. * 'write' routine.
  69. *
  70. * Distinguish between updating the metadata accumulator on writes and
  71. * reads. This is particularly (perhaps only, even) important for MPI-I/O
  72. * where we guarantee that writes are collective, but reads may not be.
  73. * If we were to allow the metadata accumulator to be written during a
  74. * read operation, the application would hang.
  75. */
  76. #define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002
  77. #define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004
  78. #define H5FD_FEAT_ACCUMULATE_METADATA \
  79. (H5FD_FEAT_ACCUMULATE_METADATA_WRITE | H5FD_FEAT_ACCUMULATE_METADATA_READ)
  80. /*
  81. * Defining H5FD_FEAT_DATA_SIEVE for a VFL driver means that
  82. * the library will attempt to cache raw data as it is read from/written to
  83. * a file in a "data seive" buffer. See Rajeev Thakur's papers:
  84. * http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz
  85. * http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz
  86. */
  87. #define H5FD_FEAT_DATA_SIEVE 0x00000008
  88. /*
  89. * Defining H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that
  90. * the library will attempt to allocate a larger block for "small" raw data
  91. * and then sub-allocate "small" raw data requests from that larger block.
  92. */
  93. #define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010
  94. /*
  95. * Defining H5FD_FEAT_IGNORE_DRVRINFO for a VFL driver means that
  96. * the library will ignore the driver info that is encoded in the file
  97. * for the VFL driver. (This will cause the driver info to be eliminated
  98. * from the file when it is flushed/closed, if the file is opened R/W).
  99. */
  100. #define H5FD_FEAT_IGNORE_DRVRINFO 0x00000020
  101. /*
  102. * Defining the H5FD_FEAT_DIRTY_DRVRINFO_LOAD for a VFL driver means that
  103. * the library will mark the driver info dirty when the file is opened
  104. * R/W. This will cause the driver info to be re-encoded when the file
  105. * is flushed/closed.
  106. */
  107. #define H5FD_FEAT_DIRTY_DRVRINFO_LOAD 0x00000040
  108. /*
  109. * Defining H5FD_FEAT_POSIX_COMPAT_HANDLE for a VFL driver means that
  110. * the handle for the VFD (returned with the 'get_handle' callback) is
  111. * of type 'int' and is compatible with POSIX I/O calls.
  112. */
  113. #define H5FD_FEAT_POSIX_COMPAT_HANDLE 0x00000080
  114. /*
  115. * Defining H5FD_FEAT_HAS_MPI for a VFL driver means that
  116. * the driver makes use of MPI communication and code may retrieve
  117. * communicator/rank information from it
  118. */
  119. #define H5FD_FEAT_HAS_MPI 0x00000100
  120. /*
  121. * Defining the H5FD_FEAT_ALLOCATE_EARLY for a VFL driver will force
  122. * the library to use the H5D_ALLOC_TIME_EARLY on dataset create
  123. * instead of the default H5D_ALLOC_TIME_LATE
  124. */
  125. #define H5FD_FEAT_ALLOCATE_EARLY 0x00000200
  126. /*
  127. * Defining H5FD_FEAT_ALLOW_FILE_IMAGE for a VFL driver means that
  128. * the driver is able to use a file image in the fapl as the initial
  129. * contents of a file.
  130. */
  131. #define H5FD_FEAT_ALLOW_FILE_IMAGE 0x00000400
  132. /*
  133. * Defining H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS for a VFL driver
  134. * means that the driver is able to use callbacks to make a copy of the
  135. * image to store in memory.
  136. */
  137. #define H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS 0x00000800
  138. /*
  139. * Defining H5FD_FEAT_SUPPORTS_SWMR_IO for a VFL driver means that the
  140. * driver supports the single-writer/multiple-readers I/O pattern.
  141. */
  142. #define H5FD_FEAT_SUPPORTS_SWMR_IO 0x00001000
  143. /*
  144. * Defining H5FD_FEAT_USE_ALLOC_SIZE for a VFL driver
  145. * means that the library will just pass the allocation size to the
  146. * the driver's allocation callback which will eventually handle alignment.
  147. * This is specifically used for the multi/split driver.
  148. */
  149. #define H5FD_FEAT_USE_ALLOC_SIZE 0x00002000
  150. /*
  151. * Defining H5FD_FEAT_PAGED_AGGR for a VFL driver
  152. * means that the driver needs special file space mapping for paged aggregation.
  153. * This is specifically used for the multi/split driver.
  154. */
  155. #define H5FD_FEAT_PAGED_AGGR 0x00004000
  156. /*
  157. * Defining H5FD_FEAT_DEFAULT_VFD_COMPATIBLE for a VFL driver
  158. * that creates a file which is compatible with the default VFD.
  159. * Generally, this means that the VFD creates a single file that follows
  160. * the canonical HDF5 file format.
  161. * Regarding the Splitter VFD specifically, only drivers with this flag
  162. * enabled may be used as the Write-Only (W/O) channel driver.
  163. */
  164. #define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000
  165. /*
  166. * Defining H5FD_FEAT_MEMMANAGE for a VFL driver means that
  167. * the driver uses special memory management routines or wishes
  168. * to do memory management in a specific manner. Therefore, HDF5
  169. * should request that the driver handle any memory management
  170. * operations when appropriate.
  171. */
  172. #define H5FD_FEAT_MEMMANAGE 0x00010000
  173. /* ctl function definitions: */
  174. #define H5FD_CTL_OPC_RESERVED 512 /* Opcodes below this value are reserved for library use */
  175. #define H5FD_CTL_OPC_EXPER_MIN \
  176. H5FD_CTL_OPC_RESERVED /* Minimum opcode value available for experimental use \
  177. */
  178. #define H5FD_CTL_OPC_EXPER_MAX \
  179. (H5FD_CTL_OPC_RESERVED + 511) /* Maximum opcode value available for experimental use */
  180. /* ctl function op codes: */
  181. #define H5FD_CTL__INVALID_OPCODE 0
  182. #define H5FD_CTL__TEST_OPCODE 1
  183. #define H5FD_CTL__GET_MPI_COMMUNICATOR_OPCODE 2
  184. #define H5FD_CTL__GET_MPI_RANK_OPCODE 3
  185. #define H5FD_CTL__GET_MPI_SIZE_OPCODE 4
  186. #define H5FD_CTL__MEM_ALLOC 5
  187. #define H5FD_CTL__MEM_FREE 6
  188. #define H5FD_CTL__MEM_COPY 7
  189. /* ctl function flags: */
  190. /* Definitions:
  191. *
  192. * WARNING: While the following definitions of Terminal
  193. * and Passthrough VFDs should be workable for now, they
  194. * have to be adjusted as our use cases for VFDs expand.
  195. *
  196. * JRM -- 8/4/21
  197. *
  198. *
  199. * Terminal VFD: Lowest VFD in the VFD stack through
  200. * which all VFD calls pass. Note that this definition
  201. * is situational. For example, the sec2 VFD is typically
  202. * terminal. However, in the context of the family file
  203. * driver, it is not -- the family file driver is the
  204. * bottom VFD through which all VFD calls pass, and thus
  205. * it is terminal.
  206. *
  207. * Similarly, on the splitter VFD, a sec2 VFD on the
  208. * R/W channel is terminal, but a sec2 VFD on the W/O
  209. * channel is not.
  210. *
  211. *
  212. * Pass through VFD: Any VFD that relays all VFD calls
  213. * (with the possible exception of some non-I/O related
  214. * calls) to underlying VFD(s).
  215. */
  216. /* Unknown op codes should be ignored silently unless the
  217. * H5FD_CTL__FAIL_IF_UNKNOWN_FLAG is set.
  218. *
  219. * On terminal VFDs, unknown op codes should generate an
  220. * error unconditionally if this flag is set.
  221. *
  222. * On pass through VFDs, unknown op codes should be routed
  223. * to the underlying VFD(s) as indicated by any routing
  224. * flags. In the absence of such flags, the VFD should
  225. * generate an error.
  226. */
  227. #define H5FD_CTL__FAIL_IF_UNKNOWN_FLAG 0x0001
  228. /* The H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG is used only
  229. * by non-ternminal VFDs, and only applies to unknown
  230. * opcodes. (known op codes should be handled as
  231. * appropriate.)
  232. *
  233. * If this flag is set for an unknown op code, that
  234. * op code should be passed to the next VFD down
  235. * the VFD stack en-route to the terminal VFD.
  236. * If that VFD does not support the ctl call, the
  237. * pass through VFD should fail or succeed as directed
  238. * by the H5FD_CTL__FAIL_IF_UNKNOWN_FLAG.
  239. */
  240. #define H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG 0x0002
  241. /*******************/
  242. /* Public Typedefs */
  243. /*******************/
  244. /*
  245. * File driver identifiers.
  246. *
  247. * Values 0 through 255 are for drivers defined by the HDF5 library.
  248. * Values 256 through 511 are available for testing new drivers.
  249. * Subsequent values should be obtained from the HDF5 development
  250. * team at mailto:help@hdfgroup.org.
  251. */
  252. typedef int H5FD_class_value_t;
  253. /* Types of allocation requests: see H5Fpublic.h */
  254. typedef enum H5F_mem_t H5FD_mem_t;
  255. /**
  256. * Define enum for the source of file image callbacks
  257. */
  258. //! <!-- [H5FD_file_image_op_t_snip] -->
  259. typedef enum {
  260. H5FD_FILE_IMAGE_OP_NO_OP,
  261. H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET,
  262. /**< Passed to the \p image_malloc and \p image_memcpy callbacks when a
  263. * file image buffer is to be copied while being set in a file access
  264. * property list (FAPL)*/
  265. H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY,
  266. /**< Passed to the \p image_malloc and \p image_memcpy callbacks
  267. * when a file image buffer is to be copied when a FAPL is copied*/
  268. H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET,
  269. /**<Passed to the \p image_malloc and \p image_memcpy callbacks when
  270. * a file image buffer is to be copied while being retrieved from a FAPL*/
  271. H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE,
  272. /**<Passed to the \p image_free callback when a file image
  273. * buffer is to be released during a FAPL close operation*/
  274. H5FD_FILE_IMAGE_OP_FILE_OPEN,
  275. /**<Passed to the \p image_malloc and
  276. * \p image_memcpy callbackswhen a
  277. * file image buffer is to be copied during a file open operation \n
  278. * While the file image being opened will typically be copied from a
  279. * FAPL, this need not always be the case. For example, the core file
  280. * driver, also known as the memory file driver, takes its initial
  281. * image from a file.*/
  282. H5FD_FILE_IMAGE_OP_FILE_RESIZE,
  283. /**<Passed to the \p image_realloc callback when a file driver needs
  284. * to resize an image buffer*/
  285. H5FD_FILE_IMAGE_OP_FILE_CLOSE
  286. /**<Passed to the \p image_free callback when an image buffer is to
  287. * be released during a file close operation*/
  288. } H5FD_file_image_op_t;
  289. //! <!-- [H5FD_file_image_op_t_snip] -->
  290. /**
  291. * Define structure to hold file image callbacks
  292. */
  293. //! <!-- [H5FD_file_image_callbacks_t_snip] -->
  294. typedef struct {
  295. /**
  296. * \param[in] size Size in bytes of the file image buffer to allocate
  297. * \param[in] file_image_op A value from H5FD_file_image_op_t indicating
  298. * the operation being performed on the file image
  299. * when this callback is invoked
  300. * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
  301. * parameter \p udata
  302. */
  303. //! <!-- [image_malloc_snip] -->
  304. void *(*image_malloc)(size_t size, H5FD_file_image_op_t file_image_op, void *udata);
  305. //! <!-- [image_malloc_snip] -->
  306. /**
  307. * \param[in] dest Address of the destination buffer
  308. * \param[in] src Address of the source buffer
  309. * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating
  310. * the operation being performed on the file image
  311. * when this callback is invoked
  312. * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
  313. * parameter \p udata
  314. */
  315. //! <!-- [image_memcpy_snip] -->
  316. void *(*image_memcpy)(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op,
  317. void *udata);
  318. //! <!-- [image_memcpy_snip] -->
  319. /**
  320. * \param[in] ptr Pointer to the buffer being reallocated
  321. * \param[in] file_image_op A value from #H5FD_file_image_op_t indicating
  322. * the operation being performed on the file image
  323. * when this callback is invoked
  324. * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
  325. * parameter \p udata
  326. */
  327. //! <!-- [image_realloc_snip] -->
  328. void *(*image_realloc)(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata);
  329. //! <!-- [image_realloc_snip] -->
  330. /**
  331. * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
  332. * parameter \p udata
  333. */
  334. //! <!-- [image_free_snip] -->
  335. herr_t (*image_free)(void *ptr, H5FD_file_image_op_t file_image_op, void *udata);
  336. //! <!-- [image_free_snip] -->
  337. /**
  338. * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
  339. * parameter \p udata
  340. */
  341. //! <!-- [udata_copy_snip] -->
  342. void *(*udata_copy)(void *udata);
  343. //! <!-- [udata_copy_snip] -->
  344. /**
  345. * \param[in] udata Value passed in in the H5Pset_file_image_callbacks
  346. * parameter \p udata
  347. */
  348. //! <!-- [udata_free_snip] -->
  349. herr_t (*udata_free)(void *udata);
  350. //! <!-- [udata_free_snip] -->
  351. /**
  352. * \brief The final field in the #H5FD_file_image_callbacks_t struct,
  353. * provides a pointer to user-defined data. This pointer will be
  354. * passed to the image_malloc, image_memcpy, image_realloc, and
  355. * image_free callbacks. Define udata as NULL if no user-defined
  356. * data is provided.
  357. */
  358. void *udata;
  359. } H5FD_file_image_callbacks_t;
  360. //! <!-- [H5FD_file_image_callbacks_t_snip] -->
  361. /**
  362. * Define structure to hold "ctl memory copy" parameters
  363. */
  364. //! <!-- [H5FD_ctl_memcpy_args_t_snip] -->
  365. typedef struct H5FD_ctl_memcpy_args_t {
  366. void * dstbuf; /**< Destination buffer */
  367. hsize_t dst_off; /**< Offset within destination buffer */
  368. const void *srcbuf; /**< Source buffer */
  369. hsize_t src_off; /**< Offset within source buffer */
  370. size_t len; /**< Length of data to copy from source buffer */
  371. } H5FD_ctl_memcpy_args_t;
  372. //! <!-- [H5FD_ctl_memcpy_args_t_snip] -->
  373. /********************/
  374. /* Public Variables */
  375. /********************/
  376. /*********************/
  377. /* Public Prototypes */
  378. /*********************/
  379. #ifdef __cplusplus
  380. extern "C" {
  381. #endif
  382. /* Function prototypes */
  383. /* Allows querying a VFD ID for features before the file is opened */
  384. H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/);
  385. #ifdef __cplusplus
  386. }
  387. #endif
  388. #endif