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 /*-------------------------------------------------------------------------
15 *
16 * Created: H5Pfapl.c
17 *
18 * Purpose: File access property list class routines
19 *
20 *-------------------------------------------------------------------------
21 */
22
23 /****************/
24 /* Module Setup */
25 /****************/
26
27 #include "H5Pmodule.h" /* This source code file is part of the H5P module */
28
29 /***********/
30 /* Headers */
31 /***********/
32 #include "H5private.h" /* Generic Functions */
33 #include "H5ACprivate.h" /* Metadata cache */
34 #include "H5Eprivate.h" /* Error handling */
35 #include "H5Fprivate.h" /* Files */
36 #include "H5FDprivate.h" /* File drivers */
37 #include "H5Iprivate.h" /* IDs */
38 #include "H5MMprivate.h" /* Memory Management */
39 #include "H5Ppkg.h" /* Property lists */
40 #include "H5VLprivate.h" /* Virtual Object Layer */
41 #include "H5VMprivate.h" /* Vector Functions */
42
43 /* Includes needed to set default file driver */
44 #include "H5FDsec2.h" /* POSIX unbuffered I/O */
45 #include "H5FDstdio.h" /* Standard C buffered I/O */
46 #ifdef H5_HAVE_WINDOWS
47 #include "H5FDwindows.h" /* Win32 I/O */
48 #endif
49
50 /* Includes needed to set default VOL connector */
51 #include "H5VLnative_private.h" /* Native VOL connector */
52
53 /****************/
54 /* Local Macros */
55 /****************/
56
57 /* ========= File Access properties ============ */
58 /* Definitions for the initial metadata cache resize configuration */
59 #define H5F_ACS_META_CACHE_INIT_CONFIG_SIZE sizeof(H5AC_cache_config_t)
60 #define H5F_ACS_META_CACHE_INIT_CONFIG_DEF H5AC__DEFAULT_CACHE_CONFIG
61 #define H5F_ACS_META_CACHE_INIT_CONFIG_ENC H5P__facc_cache_config_enc
62 #define H5F_ACS_META_CACHE_INIT_CONFIG_DEC H5P__facc_cache_config_dec
63 #define H5F_ACS_META_CACHE_INIT_CONFIG_CMP H5P__facc_cache_config_cmp
64 /* Definitions for size of raw data chunk cache(slots) */
65 #define H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t)
66 #define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF 521
67 #define H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC H5P__encode_size_t
68 #define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC H5P__decode_size_t
69 /* Definition for size of raw data chunk cache(bytes) */
70 #define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t)
71 #define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024 * 1024)
72 #define H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC H5P__encode_size_t
73 #define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC H5P__decode_size_t
74 /* Definition for preemption read chunks first */
75 #define H5F_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double)
76 #define H5F_ACS_PREEMPT_READ_CHUNKS_DEF 0.75f
77 #define H5F_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double
78 #define H5F_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double
79 /* Definition for threshold for alignment */
80 #define H5F_ACS_ALIGN_THRHD_SIZE sizeof(hsize_t)
81 #define H5F_ACS_ALIGN_THRHD_DEF H5F_ALIGN_THRHD_DEF
82 #define H5F_ACS_ALIGN_THRHD_ENC H5P__encode_hsize_t
83 #define H5F_ACS_ALIGN_THRHD_DEC H5P__decode_hsize_t
84 /* Definition for alignment */
85 #define H5F_ACS_ALIGN_SIZE sizeof(hsize_t)
86 #define H5F_ACS_ALIGN_DEF H5F_ALIGN_DEF
87 #define H5F_ACS_ALIGN_ENC H5P__encode_hsize_t
88 #define H5F_ACS_ALIGN_DEC H5P__decode_hsize_t
89 /* Definition for minimum metadata allocation block size (when
90 aggregating metadata allocations. */
91 #define H5F_ACS_META_BLOCK_SIZE_SIZE sizeof(hsize_t)
92 #define H5F_ACS_META_BLOCK_SIZE_DEF H5F_META_BLOCK_SIZE_DEF
93 #define H5F_ACS_META_BLOCK_SIZE_ENC H5P__encode_hsize_t
94 #define H5F_ACS_META_BLOCK_SIZE_DEC H5P__decode_hsize_t
95 /* Definition for maximum sieve buffer size (when data sieving
96 is allowed by file driver */
97 #define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t)
98 #define H5F_ACS_SIEVE_BUF_SIZE_DEF (64 * 1024)
99 #define H5F_ACS_SIEVE_BUF_SIZE_ENC H5P__encode_size_t
100 #define H5F_ACS_SIEVE_BUF_SIZE_DEC H5P__decode_size_t
101 /* Definition for minimum "small data" allocation block size (when
102 aggregating "small" raw data allocations. */
103 #define H5F_ACS_SDATA_BLOCK_SIZE_SIZE sizeof(hsize_t)
104 #define H5F_ACS_SDATA_BLOCK_SIZE_DEF H5F_SDATA_BLOCK_SIZE_DEF
105 #define H5F_ACS_SDATA_BLOCK_SIZE_ENC H5P__encode_hsize_t
106 #define H5F_ACS_SDATA_BLOCK_SIZE_DEC H5P__decode_hsize_t
107 /* Definition for garbage-collect references */
108 #define H5F_ACS_GARBG_COLCT_REF_SIZE sizeof(unsigned)
109 #define H5F_ACS_GARBG_COLCT_REF_DEF 0
110 #define H5F_ACS_GARBG_COLCT_REF_ENC H5P__encode_unsigned
111 #define H5F_ACS_GARBG_COLCT_REF_DEC H5P__decode_unsigned
112 /* Definition for file driver ID & info */
113 #define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t)
114 #define H5F_ACS_FILE_DRV_DEF \
115 { \
116 H5_DEFAULT_VFD, NULL \
117 }
118 #define H5F_ACS_FILE_DRV_CRT H5P__facc_file_driver_create
119 #define H5F_ACS_FILE_DRV_SET H5P__facc_file_driver_set
120 #define H5F_ACS_FILE_DRV_GET H5P__facc_file_driver_get
121 #define H5F_ACS_FILE_DRV_DEL H5P__facc_file_driver_del
122 #define H5F_ACS_FILE_DRV_COPY H5P__facc_file_driver_copy
123 #define H5F_ACS_FILE_DRV_CMP H5P__facc_file_driver_cmp
124 #define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close
125 /* Definition for file close degree */
126 #define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t)
127 #define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT
128 #define H5F_CLOSE_DEGREE_ENC H5P__facc_fclose_degree_enc
129 #define H5F_CLOSE_DEGREE_DEC H5P__facc_fclose_degree_dec
130 /* Definition for offset position in file for family file driver */
131 #define H5F_ACS_FAMILY_OFFSET_SIZE sizeof(hsize_t)
132 #define H5F_ACS_FAMILY_OFFSET_DEF 0
133 #define H5F_ACS_FAMILY_OFFSET_ENC H5P__encode_hsize_t
134 #define H5F_ACS_FAMILY_OFFSET_DEC H5P__decode_hsize_t
135 /* Definition for new member size of family driver. It's private
136 * property only used by h5repart */
137 #define H5F_ACS_FAMILY_NEWSIZE_SIZE sizeof(hsize_t)
138 #define H5F_ACS_FAMILY_NEWSIZE_DEF 0
139 /* Definition for whether to convert family to a single-file driver.
140 * It's a private property only used by h5repart.
141 */
142 #define H5F_ACS_FAMILY_TO_SINGLE_SIZE sizeof(hbool_t)
143 #define H5F_ACS_FAMILY_TO_SINGLE_DEF FALSE
144 /* Definition for data type in multi file driver */
145 #define H5F_ACS_MULTI_TYPE_SIZE sizeof(H5FD_mem_t)
146 #define H5F_ACS_MULTI_TYPE_DEF H5FD_MEM_DEFAULT
147 #define H5F_ACS_MULTI_TYPE_ENC H5P__facc_multi_type_enc
148 #define H5F_ACS_MULTI_TYPE_DEC H5P__facc_multi_type_dec
149
150 /* Definition for "low" bound of library format versions */
151 #define H5F_ACS_LIBVER_LOW_BOUND_SIZE sizeof(H5F_libver_t)
152 #define H5F_ACS_LIBVER_LOW_BOUND_DEF H5F_LIBVER_EARLIEST
153 #define H5F_ACS_LIBVER_LOW_BOUND_ENC H5P__facc_libver_type_enc
154 #define H5F_ACS_LIBVER_LOW_BOUND_DEC H5P__facc_libver_type_dec
155
156 /* Definition for "high" bound of library format versions */
157 #define H5F_ACS_LIBVER_HIGH_BOUND_SIZE sizeof(H5F_libver_t)
158 #define H5F_ACS_LIBVER_HIGH_BOUND_DEF H5F_LIBVER_LATEST
159 #define H5F_ACS_LIBVER_HIGH_BOUND_ENC H5P__facc_libver_type_enc
160 #define H5F_ACS_LIBVER_HIGH_BOUND_DEC H5P__facc_libver_type_dec
161
162 /* Definition for whether to query the file descriptor from the core VFD
163 * instead of the memory address. (Private to library)
164 */
165 #define H5F_ACS_WANT_POSIX_FD_SIZE sizeof(hbool_t)
166 #define H5F_ACS_WANT_POSIX_FD_DEF FALSE
167 /* Definition for external file cache size */
168 #define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned)
169 #define H5F_ACS_EFC_SIZE_DEF 0
170 #define H5F_ACS_EFC_SIZE_ENC H5P__encode_unsigned
171 #define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned
172 /* Definition of pointer to initial file image info */
173 #define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t)
174 #define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO
175 #define H5F_ACS_FILE_IMAGE_INFO_SET H5P__facc_file_image_info_set
176 #define H5F_ACS_FILE_IMAGE_INFO_GET H5P__facc_file_image_info_get
177 #define H5F_ACS_FILE_IMAGE_INFO_DEL H5P__facc_file_image_info_del
178 #define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy
179 #define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp
180 #define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close
181 /* Definition for # of metadata read attempts */
182 #define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned)
183 #define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0
184 #define H5F_ACS_METADATA_READ_ATTEMPTS_ENC H5P__encode_unsigned
185 #define H5F_ACS_METADATA_READ_ATTEMPTS_DEC H5P__decode_unsigned
186 /* Definition for object flush callback */
187 #define H5F_ACS_OBJECT_FLUSH_CB_SIZE sizeof(H5F_object_flush_t)
188 #define H5F_ACS_OBJECT_FLUSH_CB_DEF \
189 { \
190 NULL, NULL \
191 }
192 /* Definition for status_flags in the superblock */
193 #define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(hbool_t)
194 #define H5F_ACS_CLEAR_STATUS_FLAGS_DEF FALSE
195
196 /* Definition for dropping free-space to the floor when reading in the superblock */
197 #define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(hbool_t)
198 #define H5F_ACS_NULL_FSM_ADDR_DEF FALSE
199 /* Definition for skipping EOF check when reading in the superblock */
200 #define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(hbool_t)
201 #define H5F_ACS_SKIP_EOF_CHECK_DEF FALSE
202
203 /* Definition for 'use metadata cache logging' flag */
204 #define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(hbool_t)
205 #define H5F_ACS_USE_MDC_LOGGING_DEF FALSE
206 #define H5F_ACS_USE_MDC_LOGGING_ENC H5P__encode_hbool_t
207 #define H5F_ACS_USE_MDC_LOGGING_DEC H5P__decode_hbool_t
208 /* Definition for 'mdc log location' flag */
209 #define H5F_ACS_MDC_LOG_LOCATION_SIZE sizeof(char *)
210 #define H5F_ACS_MDC_LOG_LOCATION_DEF NULL /* default is no log location */
211 #define H5F_ACS_MDC_LOG_LOCATION_ENC H5P__facc_mdc_log_location_enc
212 #define H5F_ACS_MDC_LOG_LOCATION_DEC H5P__facc_mdc_log_location_dec
213 #define H5F_ACS_MDC_LOG_LOCATION_DEL H5P__facc_mdc_log_location_del
214 #define H5F_ACS_MDC_LOG_LOCATION_COPY H5P__facc_mdc_log_location_copy
215 #define H5F_ACS_MDC_LOG_LOCATION_CMP H5P__facc_mdc_log_location_cmp
216 #define H5F_ACS_MDC_LOG_LOCATION_CLOSE H5P__facc_mdc_log_location_close
217 /* Definition for 'start metadata cache logging on access' flag */
218 #define H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE sizeof(hbool_t)
219 #define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF FALSE
220 #define H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC H5P__encode_hbool_t
221 #define H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC H5P__decode_hbool_t
222 /* Definition for evict on close property */
223 #define H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE sizeof(hbool_t)
224 #define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF FALSE
225 #define H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC H5P__encode_hbool_t
226 #define H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC H5P__decode_hbool_t
227 #ifdef H5_HAVE_PARALLEL
228 /* Definition of collective metadata read mode flag */
229 #define H5F_ACS_COLL_MD_READ_FLAG_SIZE sizeof(H5P_coll_md_read_flag_t)
230 #define H5F_ACS_COLL_MD_READ_FLAG_DEF H5P_USER_FALSE
231 #define H5F_ACS_COLL_MD_READ_FLAG_ENC H5P__encode_coll_md_read_flag_t
232 #define H5F_ACS_COLL_MD_READ_FLAG_DEC H5P__decode_coll_md_read_flag_t
233 /* Definition of collective metadata write mode flag */
234 #define H5F_ACS_COLL_MD_WRITE_FLAG_SIZE sizeof(hbool_t)
235 #define H5F_ACS_COLL_MD_WRITE_FLAG_DEF FALSE
236 #define H5F_ACS_COLL_MD_WRITE_FLAG_ENC H5P__encode_hbool_t
237 #define H5F_ACS_COLL_MD_WRITE_FLAG_DEC H5P__decode_hbool_t
238 /* Definition for the file's MPI communicator */
239 #define H5F_ACS_MPI_PARAMS_COMM_SIZE sizeof(MPI_Comm)
240 #define H5F_ACS_MPI_PARAMS_COMM_DEF MPI_COMM_NULL
241 #define H5F_ACS_MPI_PARAMS_COMM_SET H5P__facc_mpi_comm_set
242 #define H5F_ACS_MPI_PARAMS_COMM_GET H5P__facc_mpi_comm_get
243 #define H5F_ACS_MPI_PARAMS_COMM_DEL H5P__facc_mpi_comm_del
244 #define H5F_ACS_MPI_PARAMS_COMM_COPY H5P__facc_mpi_comm_copy
245 #define H5F_ACS_MPI_PARAMS_COMM_CMP H5P__facc_mpi_comm_cmp
246 #define H5F_ACS_MPI_PARAMS_COMM_CLOSE H5P__facc_mpi_comm_close
247 /* Definition for the file's MPI info */
248 #define H5F_ACS_MPI_PARAMS_INFO_SIZE sizeof(MPI_Info)
249 #define H5F_ACS_MPI_PARAMS_INFO_DEF MPI_INFO_NULL
250 #define H5F_ACS_MPI_PARAMS_INFO_SET H5P__facc_mpi_info_set
251 #define H5F_ACS_MPI_PARAMS_INFO_GET H5P__facc_mpi_info_get
252 #define H5F_ACS_MPI_PARAMS_INFO_DEL H5P__facc_mpi_info_del
253 #define H5F_ACS_MPI_PARAMS_INFO_COPY H5P__facc_mpi_info_copy
254 #define H5F_ACS_MPI_PARAMS_INFO_CMP H5P__facc_mpi_info_cmp
255 #define H5F_ACS_MPI_PARAMS_INFO_CLOSE H5P__facc_mpi_info_close
256 #endif /* H5_HAVE_PARALLEL */
257 /* Definitions for the initial metadata cache image configuration */
258 #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE sizeof(H5AC_cache_image_config_t)
259 #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF H5AC__DEFAULT_CACHE_IMAGE_CONFIG
260 #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC H5P__facc_cache_image_config_enc
261 #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC H5P__facc_cache_image_config_dec
262 #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP H5P__facc_cache_image_config_cmp
263 /* Definition for total size of page buffer(bytes) */
264 #define H5F_ACS_PAGE_BUFFER_SIZE_SIZE sizeof(size_t)
265 #define H5F_ACS_PAGE_BUFFER_SIZE_DEF 0
266 #define H5F_ACS_PAGE_BUFFER_SIZE_ENC H5P__encode_size_t
267 #define H5F_ACS_PAGE_BUFFER_SIZE_DEC H5P__decode_size_t
268 /* Definition for minimum metadata size of page buffer(bytes) */
269 #define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE sizeof(unsigned)
270 #define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF 0
271 #define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC H5P__encode_unsigned
272 #define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC H5P__decode_unsigned
273 /* Definition for minimum raw data size of page buffer(bytes) */
274 #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE sizeof(unsigned)
275 #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0
276 #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned
277 #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned
278 /* Definition for file VOL connector properties (ID, etc.) */
279 #define H5F_ACS_VOL_CONN_SIZE sizeof(H5VL_connector_prop_t)
280 #define H5F_ACS_VOL_CONN_DEF \
281 { \
282 H5_DEFAULT_VOL, NULL \
283 }
284 #define H5F_ACS_VOL_CONN_CRT H5P__facc_vol_create
285 #define H5F_ACS_VOL_CONN_SET H5P__facc_vol_set
286 #define H5F_ACS_VOL_CONN_GET H5P__facc_vol_get
287 #define H5F_ACS_VOL_CONN_DEL H5P__facc_vol_del
288 #define H5F_ACS_VOL_CONN_COPY H5P__facc_vol_copy
289 #define H5F_ACS_VOL_CONN_CMP H5P__facc_vol_cmp
290 #define H5F_ACS_VOL_CONN_CLOSE H5P__facc_vol_close
291 /* Definition for using file locking or not. The default is set
292 * via the configure step.
293 */
294 #define H5F_ACS_USE_FILE_LOCKING_SIZE sizeof(hbool_t)
295 #if defined H5_USE_FILE_LOCKING && H5_USE_FILE_LOCKING
296 #define H5F_ACS_USE_FILE_LOCKING_DEF TRUE
297 #else
298 #define H5F_ACS_USE_FILE_LOCKING_DEF FALSE
299 #endif
300 #define H5F_ACS_USE_FILE_LOCKING_ENC H5P__encode_hbool_t
301 #define H5F_ACS_USE_FILE_LOCKING_DEC H5P__decode_hbool_t
302 /* Definition for whether we ignore file locking errors when we can
303 * tell that file locking has been disabled on the file system.
304 * The default is set via the configure step.
305 */
306 #define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE sizeof(hbool_t)
307 #if defined H5_IGNORE_DISABLED_FILE_LOCKS && H5_IGNORE_DISABLED_FILE_LOCKS
308 #define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF TRUE
309 #else
310 #define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF FALSE
311 #endif
312 #define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC H5P__encode_hbool_t
313 #define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC H5P__decode_hbool_t
314
315 /******************/
316 /* Local Typedefs */
317 /******************/
318
319 /********************/
320 /* Package Typedefs */
321 /********************/
322
323 /********************/
324 /* Local Prototypes */
325 /********************/
326
327 /* Property class callbacks */
328 static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass);
329
330 /* File driver ID & info property callbacks */
331 static herr_t H5P__facc_file_driver_create(const char *name, size_t size, void *value);
332 static herr_t H5P__facc_file_driver_set(hid_t prop_id, const char *name, size_t size, void *value);
333 static herr_t H5P__facc_file_driver_get(hid_t prop_id, const char *name, size_t size, void *value);
334 static herr_t H5P__facc_file_driver_del(hid_t prop_id, const char *name, size_t size, void *value);
335 static herr_t H5P__facc_file_driver_copy(const char *name, size_t size, void *value);
336 static int H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size);
337 static herr_t H5P__facc_file_driver_close(const char *name, size_t size, void *value);
338
339 /* File image info property callbacks */
340 static herr_t H5P__file_image_info_copy(void *value);
341 static herr_t H5P__file_image_info_free(void *value);
342 static herr_t H5P__facc_file_image_info_set(hid_t prop_id, const char *name, size_t size, void *value);
343 static herr_t H5P__facc_file_image_info_get(hid_t prop_id, const char *name, size_t size, void *value);
344 static herr_t H5P__facc_file_image_info_del(hid_t prop_id, const char *name, size_t size, void *value);
345 static herr_t H5P__facc_file_image_info_copy(const char *name, size_t size, void *value);
346 static int H5P__facc_file_image_info_cmp(const void *value1, const void *value2, size_t size);
347 static herr_t H5P__facc_file_image_info_close(const char *name, size_t size, void *value);
348
349 /* encode & decode callbacks */
350 static herr_t H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size);
351 static herr_t H5P__facc_cache_config_dec(const void **_pp, void *value);
352 static int H5P__facc_cache_config_cmp(const void *value1, const void *value2, size_t size);
353 static herr_t H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size);
354 static herr_t H5P__facc_fclose_degree_dec(const void **pp, void *value);
355 static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size);
356 static herr_t H5P__facc_multi_type_dec(const void **_pp, void *value);
357 static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size, void*);
358 static herr_t H5P__facc_libver_type_dec(const void **_pp, void *value);
359
360 /* Metadata cache log location property callbacks */
361 static herr_t H5P__facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size);
362 static herr_t H5P__facc_mdc_log_location_dec(const void **_pp, void *value);
363 static herr_t H5P__facc_mdc_log_location_del(hid_t prop_id, const char *name, size_t size, void *value);
364 static herr_t H5P__facc_mdc_log_location_copy(const char *name, size_t size, void *value);
365 static int H5P__facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t size);
366 static herr_t H5P__facc_mdc_log_location_close(const char *name, size_t size, void *value);
367
368 /* Metadata cache image property callbacks */
369 static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2,
370 size_t H5_ATTR_UNUSED size);
371 static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size);
372 static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value);
373
374 /* VOL connector callbacks */
375 static herr_t H5P__facc_vol_create(const char *name, size_t size, void *value);
376 static herr_t H5P__facc_vol_set(hid_t prop_id, const char *name, size_t size, void *value);
377 static herr_t H5P__facc_vol_get(hid_t prop_id, const char *name, size_t size, void *value);
378 static herr_t H5P__facc_vol_del(hid_t prop_id, const char *name, size_t size, void *value);
379 static herr_t H5P__facc_vol_copy(const char *name, size_t size, void *value);
380 static int H5P__facc_vol_cmp(const void *value1, const void *value2, size_t size);
381 static herr_t H5P__facc_vol_close(const char *name, size_t size, void *value);
382
383 #ifdef H5_HAVE_PARALLEL
384 /* MPI communicator callbacks */
385 static herr_t H5P__facc_mpi_comm_set(hid_t prop_id, const char *name, size_t size, void *value);
386 static herr_t H5P__facc_mpi_comm_get(hid_t prop_id, const char *name, size_t size, void *value);
387 static herr_t H5P__facc_mpi_comm_del(hid_t prop_id, const char *name, size_t size, void *value);
388 static herr_t H5P__facc_mpi_comm_copy(const char *name, size_t size, void *value);
389 static int H5P__facc_mpi_comm_cmp(const void *value1, const void *value2, size_t size);
390 static herr_t H5P__facc_mpi_comm_close(const char *name, size_t size, void *value);
391
392 /* MPI info callbacks */
393 static herr_t H5P__facc_mpi_info_set(hid_t prop_id, const char *name, size_t size, void *value);
394 static herr_t H5P__facc_mpi_info_get(hid_t prop_id, const char *name, size_t size, void *value);
395 static herr_t H5P__facc_mpi_info_del(hid_t prop_id, const char *name, size_t size, void *value);
396 static herr_t H5P__facc_mpi_info_copy(const char *name, size_t size, void *value);
397 static int H5P__facc_mpi_info_cmp(const void *value1, const void *value2, size_t size);
398 static herr_t H5P__facc_mpi_info_close(const char *name, size_t size, void *value);
399 #endif /* H5_HAVE_PARALLEL */
400
401 /*********************/
402 /* Package Variables */
403 /*********************/
404
405 /* File access property list class library initialization object */
406 const H5P_libclass_t H5P_CLS_FACC[1] = {{
407 "file access", /* Class name for debugging */
408 H5P_TYPE_FILE_ACCESS, /* Class type */
409
410 &H5P_CLS_ROOT_g, /* Parent class */
411 &H5P_CLS_FILE_ACCESS_g, /* Pointer to class */
412 &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID */
413 &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */
414 H5P__facc_reg_prop, /* Default property registration routine */
415
416 NULL, /* Class creation callback */
417 NULL, /* Class creation callback info */
418 NULL, /* Class copy callback */
419 NULL, /* Class copy callback info */
420 NULL, /* Class close callback */
421 NULL /* Class close callback info */
422 }};
423
424 /*****************************/
425 /* Library Private Variables */
426 /*****************************/
427
428 /*******************/
429 /* Local Variables */
430 /*******************/
431
432 /* Property value defaults */
433 static const H5AC_cache_config_t H5F_def_mdc_initCacheCfg_g =
434 H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */
435 static const size_t H5F_def_rdcc_nslots_g =
436 H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */
437 static const size_t H5F_def_rdcc_nbytes_g =
438 H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */
439 static const double H5F_def_rdcc_w0_g =
440 H5F_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */
441 static const hsize_t H5F_def_threshold_g =
442 H5F_ACS_ALIGN_THRHD_DEF; /* Default allocation alignment threshold */
443 static const hsize_t H5F_def_alignment_g = H5F_ACS_ALIGN_DEF; /* Default allocation alignment value */
444 static const hsize_t H5F_def_meta_block_size_g =
445 H5F_ACS_META_BLOCK_SIZE_DEF; /* Default metadata allocation block size */
446 static const size_t H5F_def_sieve_buf_size_g =
447 H5F_ACS_SIEVE_BUF_SIZE_DEF; /* Default raw data I/O sieve buffer size */
448 static const hsize_t H5F_def_sdata_block_size_g =
449 H5F_ACS_SDATA_BLOCK_SIZE_DEF; /* Default small data allocation block size */
450 static const unsigned H5F_def_gc_ref_g =
451 H5F_ACS_GARBG_COLCT_REF_DEF; /* Default garbage collection for references setting */
452 static const H5F_close_degree_t H5F_def_close_degree_g = H5F_CLOSE_DEGREE_DEF; /* Default file close degree */
453 static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; /* Default offset for family VFD */
454 static const hsize_t H5F_def_family_newsize_g =
455 H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */
456 static const hbool_t H5F_def_family_to_single_g =
457 H5F_ACS_FAMILY_TO_SINGLE_DEF; /* Default ?? for family VFD */
458 static const H5FD_mem_t H5F_def_mem_type_g =
459 H5F_ACS_MULTI_TYPE_DEF; /* Default file space type for multi VFD */
460
461 static const H5F_libver_t H5F_def_libver_low_bound_g =
462 H5F_ACS_LIBVER_LOW_BOUND_DEF; /* Default setting for "low" bound of format version */
463 static const H5F_libver_t H5F_def_libver_high_bound_g =
464 H5F_ACS_LIBVER_HIGH_BOUND_DEF; /* Default setting for "high" bound of format version */
465
466 static const hbool_t H5F_def_want_posix_fd_g =
467 H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */
468 static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */
469 static const H5FD_file_image_info_t H5F_def_file_image_info_g =
470 H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */
471 static const unsigned H5F_def_metadata_read_attempts_g =
472 H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */
473 static const H5F_object_flush_t H5F_def_object_flush_cb_g =
474 H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */
475 static const hbool_t H5F_def_clear_status_flags_g =
476 H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */
477 static const hbool_t H5F_def_skip_eof_check_g =
478 H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */
479 static const hbool_t H5F_def_null_fsm_addr_g =
480 H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */
481
482 static const hbool_t H5F_def_use_mdc_logging_g =
483 H5F_ACS_USE_MDC_LOGGING_DEF; /* Default metadata cache logging flag */
484 static const char * H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */
485 static const hbool_t H5F_def_start_mdc_log_on_access_g =
486 H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */
487 static const hbool_t H5F_def_evict_on_close_flag_g =
488 H5F_ACS_EVICT_ON_CLOSE_FLAG_DEF; /* Default setting for evict on close property */
489 #ifdef H5_HAVE_PARALLEL
490 static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g =
491 H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */
492 static const hbool_t H5F_def_coll_md_write_flag_g =
493 H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */
494 static const MPI_Comm H5F_def_mpi_params_comm_g = H5F_ACS_MPI_PARAMS_COMM_DEF; /* Default MPI communicator */
495 static const MPI_Info H5F_def_mpi_params_info_g = H5F_ACS_MPI_PARAMS_INFO_DEF; /* Default MPI info struct */
496 #endif /* H5_HAVE_PARALLEL */
497 static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g =
498 H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */
499 static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* Default page buffer size */
500 static const unsigned H5F_def_page_buf_min_meta_perc_g =
501 H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */
502 static const unsigned H5F_def_page_buf_min_raw_perc_g =
503 H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer mininum raw data size */
504 static const hbool_t H5F_def_use_file_locking_g =
505 H5F_ACS_USE_FILE_LOCKING_DEF; /* Default use file locking flag */
506 static const hbool_t H5F_def_ignore_disabled_file_locks_g =
507 H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEF; /* Default ignore disabled file locks flag */
508
509 /*-------------------------------------------------------------------------
510 * Function: H5P__facc_reg_prop
511 *
512 * Purpose: Register the file access property list class's properties
513 *
514 * Return: Non-negative on success/Negative on failure
515 *
516 * Programmer: Quincey Koziol
517 * October 31, 2006
518 *-------------------------------------------------------------------------
519 */
520 static herr_t
H5P__facc_reg_prop(H5P_genclass_t * pclass)521 H5P__facc_reg_prop(H5P_genclass_t *pclass)
522 {
523 const H5FD_driver_prop_t def_driver_prop =
524 H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */
525 const H5VL_connector_prop_t def_vol_prop =
526 H5F_ACS_VOL_CONN_DEF; /* Default VOL connector ID & info (initialized from a variable) */
527 herr_t ret_value = SUCCEED; /* Return value */
528
529 FUNC_ENTER_STATIC
530
531 /* Register the initial metadata cache resize configuration */
532 if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_CONFIG_SIZE,
533 &H5F_def_mdc_initCacheCfg_g, NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_ENC,
534 H5F_ACS_META_CACHE_INIT_CONFIG_DEC, NULL, NULL, H5F_ACS_META_CACHE_INIT_CONFIG_CMP,
535 NULL) < 0)
536 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
537
538 /* Register the size of raw data chunk cache (elements) */
539 if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE,
540 &H5F_def_rdcc_nslots_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_NUM_SLOTS_ENC,
541 H5F_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0)
542 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
543
544 /* Register the size of raw data chunk cache(bytes) */
545 if (H5P__register_real(pclass, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE,
546 &H5F_def_rdcc_nbytes_g, NULL, NULL, NULL, H5F_ACS_DATA_CACHE_BYTE_SIZE_ENC,
547 H5F_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
548 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
549
550 /* Register the preemption for reading chunks */
551 if (H5P__register_real(pclass, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, H5F_ACS_PREEMPT_READ_CHUNKS_SIZE,
552 &H5F_def_rdcc_w0_g, NULL, NULL, NULL, H5F_ACS_PREEMPT_READ_CHUNKS_ENC,
553 H5F_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0)
554 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
555
556 /* Register the threshold for alignment */
557 if (H5P__register_real(pclass, H5F_ACS_ALIGN_THRHD_NAME, H5F_ACS_ALIGN_THRHD_SIZE, &H5F_def_threshold_g,
558 NULL, NULL, NULL, H5F_ACS_ALIGN_THRHD_ENC, H5F_ACS_ALIGN_THRHD_DEC, NULL, NULL,
559 NULL, NULL) < 0)
560 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
561
562 /* Register the alignment */
563 if (H5P__register_real(pclass, H5F_ACS_ALIGN_NAME, H5F_ACS_ALIGN_SIZE, &H5F_def_alignment_g, NULL, NULL,
564 NULL, H5F_ACS_ALIGN_ENC, H5F_ACS_ALIGN_DEC, NULL, NULL, NULL, NULL) < 0)
565 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
566
567 /* Register the minimum metadata allocation block size */
568 if (H5P__register_real(pclass, H5F_ACS_META_BLOCK_SIZE_NAME, H5F_ACS_META_BLOCK_SIZE_SIZE,
569 &H5F_def_meta_block_size_g, NULL, NULL, NULL, H5F_ACS_META_BLOCK_SIZE_ENC,
570 H5F_ACS_META_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
571 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
572
573 /* Register the maximum sieve buffer size */
574 if (H5P__register_real(pclass, H5F_ACS_SIEVE_BUF_SIZE_NAME, H5F_ACS_SIEVE_BUF_SIZE_SIZE,
575 &H5F_def_sieve_buf_size_g, NULL, NULL, NULL, H5F_ACS_SIEVE_BUF_SIZE_ENC,
576 H5F_ACS_SIEVE_BUF_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
577 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
578
579 /* Register the minimum "small data" allocation block size */
580 if (H5P__register_real(pclass, H5F_ACS_SDATA_BLOCK_SIZE_NAME, H5F_ACS_SDATA_BLOCK_SIZE_SIZE,
581 &H5F_def_sdata_block_size_g, NULL, NULL, NULL, H5F_ACS_SDATA_BLOCK_SIZE_ENC,
582 H5F_ACS_SDATA_BLOCK_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
583 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
584
585 /* Register the garbage collection reference */
586 if (H5P__register_real(pclass, H5F_ACS_GARBG_COLCT_REF_NAME, H5F_ACS_GARBG_COLCT_REF_SIZE,
587 &H5F_def_gc_ref_g, NULL, NULL, NULL, H5F_ACS_GARBG_COLCT_REF_ENC,
588 H5F_ACS_GARBG_COLCT_REF_DEC, NULL, NULL, NULL, NULL) < 0)
589 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
590
591 /* Register the file driver ID & info */
592 /* (Note: this property should not have an encode/decode callback -QAK) */
593 if (H5P__register_real(pclass, H5F_ACS_FILE_DRV_NAME, H5F_ACS_FILE_DRV_SIZE, &def_driver_prop,
594 H5F_ACS_FILE_DRV_CRT, H5F_ACS_FILE_DRV_SET, H5F_ACS_FILE_DRV_GET, NULL, NULL,
595 H5F_ACS_FILE_DRV_DEL, H5F_ACS_FILE_DRV_COPY, H5F_ACS_FILE_DRV_CMP,
596 H5F_ACS_FILE_DRV_CLOSE) < 0)
597 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
598
599 /* Register the file close degree */
600 if (H5P__register_real(pclass, H5F_ACS_CLOSE_DEGREE_NAME, H5F_CLOSE_DEGREE_SIZE, &H5F_def_close_degree_g,
601 NULL, NULL, NULL, H5F_CLOSE_DEGREE_ENC, H5F_CLOSE_DEGREE_DEC, NULL, NULL, NULL,
602 NULL) < 0)
603 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
604
605 /* Register the offset of family driver info */
606 if (H5P__register_real(pclass, H5F_ACS_FAMILY_OFFSET_NAME, H5F_ACS_FAMILY_OFFSET_SIZE,
607 &H5F_def_family_offset_g, NULL, NULL, NULL, H5F_ACS_FAMILY_OFFSET_ENC,
608 H5F_ACS_FAMILY_OFFSET_DEC, NULL, NULL, NULL, NULL) < 0)
609 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
610
611 /* Register the private property of new family file size. It's used by h5repart only. */
612 /* (Note: this property should not have an encode/decode callback -QAK) */
613 if (H5P__register_real(pclass, H5F_ACS_FAMILY_NEWSIZE_NAME, H5F_ACS_FAMILY_NEWSIZE_SIZE,
614 &H5F_def_family_newsize_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
615 NULL) < 0)
616 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
617
618 /* Register the private property of whether convert family to a single-file driver. It's used by h5repart
619 * only. */
620 /* (Note: this property should not have an encode/decode callback -QAK) */
621 if (H5P__register_real(pclass, H5F_ACS_FAMILY_TO_SINGLE_NAME, H5F_ACS_FAMILY_TO_SINGLE_SIZE,
622 &H5F_def_family_to_single_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
623 NULL) < 0)
624 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
625
626 /* Register the data type of multi driver info */
627 if (H5P__register_real(pclass, H5F_ACS_MULTI_TYPE_NAME, H5F_ACS_MULTI_TYPE_SIZE, &H5F_def_mem_type_g,
628 NULL, NULL, NULL, H5F_ACS_MULTI_TYPE_ENC, H5F_ACS_MULTI_TYPE_DEC, NULL, NULL, NULL,
629 NULL) < 0)
630 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
631
632 /* Register the 'low' bound of library format versions */
633 if (H5P__register_real(pclass, H5F_ACS_LIBVER_LOW_BOUND_NAME, H5F_ACS_LIBVER_LOW_BOUND_SIZE,
634 &H5F_def_libver_low_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_LOW_BOUND_ENC,
635 H5F_ACS_LIBVER_LOW_BOUND_DEC, NULL, NULL, NULL, NULL) < 0)
636 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
637
638 /* Register the 'high' bound of library format versions */
639 if (H5P__register_real(pclass, H5F_ACS_LIBVER_HIGH_BOUND_NAME, H5F_ACS_LIBVER_HIGH_BOUND_SIZE,
640 &H5F_def_libver_high_bound_g, NULL, NULL, NULL, H5F_ACS_LIBVER_HIGH_BOUND_ENC,
641 H5F_ACS_LIBVER_HIGH_BOUND_DEC, NULL, NULL, NULL, NULL) < 0)
642 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
643
644 /* Register the private property of whether to retrieve the file descriptor from the core VFD */
645 /* (used internally to the library only) */
646 /* (Note: this property should not have an encode/decode callback -QAK) */
647 if (H5P__register_real(pclass, H5F_ACS_WANT_POSIX_FD_NAME, H5F_ACS_WANT_POSIX_FD_SIZE,
648 &H5F_def_want_posix_fd_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
649 NULL) < 0)
650 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
651
652 /* Register the external file cache size */
653 if (H5P__register_real(pclass, H5F_ACS_EFC_SIZE_NAME, H5F_ACS_EFC_SIZE_SIZE, &H5F_def_efc_size_g, NULL,
654 NULL, NULL, H5F_ACS_EFC_SIZE_ENC, H5F_ACS_EFC_SIZE_DEC, NULL, NULL, NULL,
655 NULL) < 0)
656 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
657
658 /* Register the initial file image info */
659 /* (Note: this property should not have an encode/decode callback -QAK) */
660 if (H5P__register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE,
661 &H5F_def_file_image_info_g, NULL, H5F_ACS_FILE_IMAGE_INFO_SET,
662 H5F_ACS_FILE_IMAGE_INFO_GET, NULL, NULL, H5F_ACS_FILE_IMAGE_INFO_DEL,
663 H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP,
664 H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0)
665 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
666
667 /* Register the # of read attempts */
668 if (H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE,
669 &H5F_def_metadata_read_attempts_g, NULL, NULL, NULL,
670 H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, NULL, NULL,
671 NULL, NULL) < 0)
672 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
673
674 /* Register object flush callback */
675 /* (Note: this property should not have an encode/decode callback -QAK) */
676 if (H5P__register_real(pclass, H5F_ACS_OBJECT_FLUSH_CB_NAME, H5F_ACS_OBJECT_FLUSH_CB_SIZE,
677 &H5F_def_object_flush_cb_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
678 NULL) < 0)
679 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
680
681 /* Register the private property of whether to clear the superblock status_flags. It's used by h5clear
682 * only. */
683 if (H5P__register_real(pclass, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, H5F_ACS_CLEAR_STATUS_FLAGS_SIZE,
684 &H5F_def_clear_status_flags_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
685 NULL) < 0)
686 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
687
688 /* Register the private property of whether to skip EOF check. It's used by h5clear only. */
689 if (H5P__register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE,
690 &H5F_def_skip_eof_check_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
691 NULL) < 0)
692 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
693
694 /* Register the private property of whether to drop free-space to the floor. It's used by h5clear only. */
695 if (H5P__register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE,
696 &H5F_def_null_fsm_addr_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
697 NULL) < 0)
698 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
699
700 /* Register the metadata cache logging flag. */
701 if (H5P__register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE,
702 &H5F_def_use_mdc_logging_g, NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC,
703 H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0)
704 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
705
706 /* Register the metadata cache log location. */
707 if (H5P__register_real(pclass, H5F_ACS_MDC_LOG_LOCATION_NAME, H5F_ACS_MDC_LOG_LOCATION_SIZE,
708 &H5F_def_mdc_log_location_g, NULL, NULL, NULL, H5F_ACS_MDC_LOG_LOCATION_ENC,
709 H5F_ACS_MDC_LOG_LOCATION_DEC, H5F_ACS_MDC_LOG_LOCATION_DEL,
710 H5F_ACS_MDC_LOG_LOCATION_COPY, H5F_ACS_MDC_LOG_LOCATION_CMP,
711 H5F_ACS_MDC_LOG_LOCATION_CLOSE) < 0)
712 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
713
714 /* Register the flag that indicates whether mdc logging starts on file access. */
715 if (H5P__register_real(pclass, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, H5F_ACS_START_MDC_LOG_ON_ACCESS_SIZE,
716 &H5F_def_start_mdc_log_on_access_g, NULL, NULL, NULL,
717 H5F_ACS_START_MDC_LOG_ON_ACCESS_ENC, H5F_ACS_START_MDC_LOG_ON_ACCESS_DEC, NULL,
718 NULL, NULL, NULL) < 0)
719 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
720
721 /* Register the evict on close flag */
722 if (H5P__register_real(pclass, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, H5F_ACS_EVICT_ON_CLOSE_FLAG_SIZE,
723 &H5F_def_evict_on_close_flag_g, NULL, NULL, NULL, H5F_ACS_EVICT_ON_CLOSE_FLAG_ENC,
724 H5F_ACS_EVICT_ON_CLOSE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0)
725 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
726
727 #ifdef H5_HAVE_PARALLEL
728 /* Register the metadata collective read flag */
729 if (H5P__register_real(pclass, H5_COLL_MD_READ_FLAG_NAME, H5F_ACS_COLL_MD_READ_FLAG_SIZE,
730 &H5F_def_coll_md_read_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_READ_FLAG_ENC,
731 H5F_ACS_COLL_MD_READ_FLAG_DEC, NULL, NULL, NULL, NULL) < 0)
732 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
733
734 /* Register the metadata collective write flag */
735 if (H5P__register_real(pclass, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, H5F_ACS_COLL_MD_WRITE_FLAG_SIZE,
736 &H5F_def_coll_md_write_flag_g, NULL, NULL, NULL, H5F_ACS_COLL_MD_WRITE_FLAG_ENC,
737 H5F_ACS_COLL_MD_WRITE_FLAG_DEC, NULL, NULL, NULL, NULL) < 0)
738 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
739
740 /* Register the MPI communicator */
741 if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_COMM_NAME, H5F_ACS_MPI_PARAMS_COMM_SIZE,
742 &H5F_def_mpi_params_comm_g, NULL, H5F_ACS_MPI_PARAMS_COMM_SET,
743 H5F_ACS_MPI_PARAMS_COMM_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_COMM_DEL,
744 H5F_ACS_MPI_PARAMS_COMM_COPY, H5F_ACS_MPI_PARAMS_COMM_CMP,
745 H5F_ACS_MPI_PARAMS_COMM_CLOSE) < 0)
746 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
747
748 /* Register the MPI info struct */
749 if (H5P__register_real(pclass, H5F_ACS_MPI_PARAMS_INFO_NAME, H5F_ACS_MPI_PARAMS_INFO_SIZE,
750 &H5F_def_mpi_params_info_g, NULL, H5F_ACS_MPI_PARAMS_INFO_SET,
751 H5F_ACS_MPI_PARAMS_INFO_GET, NULL, NULL, H5F_ACS_MPI_PARAMS_INFO_DEL,
752 H5F_ACS_MPI_PARAMS_INFO_COPY, H5F_ACS_MPI_PARAMS_INFO_CMP,
753 H5F_ACS_MPI_PARAMS_INFO_CLOSE) < 0)
754 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
755
756 #endif /* H5_HAVE_PARALLEL */
757
758 /* Register the initial metadata cache image configuration */
759 if (H5P__register_real(pclass, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME,
760 H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE, &H5F_def_mdc_initCacheImageCfg_g, NULL,
761 NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC,
762 H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC, NULL, NULL,
763 H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0)
764 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
765
766 /* Register the size of the page buffer size */
767 if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_SIZE_NAME, H5F_ACS_PAGE_BUFFER_SIZE_SIZE,
768 &H5F_def_page_buf_size_g, NULL, NULL, NULL, H5F_ACS_PAGE_BUFFER_SIZE_ENC,
769 H5F_ACS_PAGE_BUFFER_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
770 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
771
772 /* Register the size of the page buffer minimum metadata size */
773 if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME,
774 H5F_ACS_PAGE_BUFFER_MIN_META_PERC_SIZE, &H5F_def_page_buf_min_meta_perc_g, NULL,
775 NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_ENC,
776 H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEC, NULL, NULL, NULL, NULL) < 0)
777 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
778
779 /* Register the size of the page buffer minimum raw data size */
780 if (H5P__register_real(pclass, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME,
781 H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_SIZE, &H5F_def_page_buf_min_raw_perc_g, NULL,
782 NULL, NULL, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC,
783 H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC, NULL, NULL, NULL, NULL) < 0)
784 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
785
786 /* Register the file VOL connector ID & info */
787 /* (Note: this property should not have an encode/decode callback -QAK) */
788 if (H5P__register_real(pclass, H5F_ACS_VOL_CONN_NAME, H5F_ACS_VOL_CONN_SIZE, &def_vol_prop,
789 H5F_ACS_VOL_CONN_CRT, H5F_ACS_VOL_CONN_SET, H5F_ACS_VOL_CONN_GET, NULL, NULL,
790 H5F_ACS_VOL_CONN_DEL, H5F_ACS_VOL_CONN_COPY, H5F_ACS_VOL_CONN_CMP,
791 H5F_ACS_VOL_CONN_CLOSE) < 0)
792 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
793
794 /* Register the use file locking flag */
795 if (H5P__register_real(pclass, H5F_ACS_USE_FILE_LOCKING_NAME, H5F_ACS_USE_FILE_LOCKING_SIZE,
796 &H5F_def_use_file_locking_g, NULL, NULL, NULL, H5F_ACS_USE_FILE_LOCKING_ENC,
797 H5F_ACS_USE_FILE_LOCKING_DEC, NULL, NULL, NULL, NULL) < 0)
798 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
799
800 /* Register the ignore disabled file locks flag */
801 if (H5P__register_real(pclass, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME,
802 H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_SIZE, &H5F_def_ignore_disabled_file_locks_g,
803 NULL, NULL, NULL, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_ENC,
804 H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC, NULL, NULL, NULL, NULL) < 0)
805 HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
806
807 done:
808 FUNC_LEAVE_NOAPI(ret_value)
809 } /* end H5P__facc_reg_prop() */
810
811 /*-------------------------------------------------------------------------
812 * Function: H5Pset_alignment
813 *
814 * Purpose: Sets the alignment properties of a file access property list
815 * so that any file object >= THRESHOLD bytes will be aligned on
816 * an address which is a multiple of ALIGNMENT. The addresses
817 * are relative to the end of the user block; the alignment is
818 * calculated by subtracting the user block size from the
819 * absolute file address and then adjusting the address to be a
820 * multiple of ALIGNMENT.
821 *
822 * Default values for THRESHOLD and ALIGNMENT are one, implying
823 * no alignment. Generally the default values will result in
824 * the best performance for single-process access to the file.
825 * For MPI-IO and other parallel systems, choose an alignment
826 * which is a multiple of the disk block size.
827 *
828 * Return: Non-negative on success/Negative on failure
829 *
830 * Programmer: Robb Matzke
831 * Tuesday, June 9, 1998
832 *
833 *-------------------------------------------------------------------------
834 */
835 herr_t
H5Pset_alignment(hid_t fapl_id,hsize_t threshold,hsize_t alignment)836 H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignment)
837 {
838 H5P_genplist_t *plist; /* Property list pointer */
839 herr_t ret_value = SUCCEED; /* return value */
840
841 FUNC_ENTER_API(FAIL)
842 H5TRACE3("e", "ihh", fapl_id, threshold, alignment);
843
844 /* Check args */
845 if (alignment < 1)
846 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "alignment must be positive")
847
848 /* Get the plist structure */
849 if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
850 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
851
852 /* Set values */
853 if (H5P_set(plist, H5F_ACS_ALIGN_THRHD_NAME, &threshold) < 0)
854 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set threshold")
855 if (H5P_set(plist, H5F_ACS_ALIGN_NAME, &alignment) < 0)
856 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment")
857
858 done:
859 FUNC_LEAVE_API(ret_value)
860 }
861
862 /*-------------------------------------------------------------------------
863 * Function: H5Pget_alignment
864 *
865 * Purpose: Returns the current settings for alignment properties from a
866 * file access property list. The THRESHOLD and/or ALIGNMENT
867 * pointers may be null pointers.
868 *
869 * Return: Non-negative on success/Negative on failure
870 *
871 * Programmer: Robb Matzke
872 * Tuesday, June 9, 1998
873 *
874 *-------------------------------------------------------------------------
875 */
876 herr_t
H5Pget_alignment(hid_t fapl_id,hsize_t * threshold,hsize_t * alignment)877 H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment /*out*/)
878 {
879 H5P_genplist_t *plist; /* Property list pointer */
880 herr_t ret_value = SUCCEED; /* Return value */
881
882 FUNC_ENTER_API(FAIL)
883 H5TRACE3("e", "ixx", fapl_id, threshold, alignment);
884
885 /* Get the plist structure */
886 if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
887 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
888
889 /* Get values */
890 if (threshold)
891 if (H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, threshold) < 0)
892 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get threshold")
893 if (alignment)
894 if (H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0)
895 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment")
896
897 done:
898 FUNC_LEAVE_API(ret_value)
899 } /* end H5Pget_alignment() */
900
901 /*-------------------------------------------------------------------------
902 * Function: H5P_set_driver
903 *
904 * Purpose: Set the file driver (DRIVER_ID) for a file access
905 * property list (PLIST_ID) and supply an optional
906 * struct containing the driver-specific properites
907 * (DRIVER_INFO). The driver properties will be copied into the
908 * property list and the reference count on the driver will be
909 * incremented, allowing the caller to close the driver ID but
910 * still use the property list.
911 *
912 * Return: Success: Non-negative
913 * Failure: Negative
914 *
915 * Programmer: Robb Matzke
916 * Tuesday, August 3, 1999
917 *
918 *-------------------------------------------------------------------------
919 */
920 herr_t
H5P_set_driver(H5P_genplist_t * plist,hid_t new_driver_id,const void * new_driver_info)921 H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info)
922 {
923 herr_t ret_value = SUCCEED; /* Return value */
924
925 FUNC_ENTER_NOAPI(FAIL)
926
927 if (NULL == H5I_object_verify(new_driver_id, H5I_VFL))
928 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID")
929
930 if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
931 H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
932
933 /* Prepare the driver property */
934 driver_prop.driver_id = new_driver_id;
935 driver_prop.driver_info = new_driver_info;
936
937 /* Set the driver ID & info property */
938 if (H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
939 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID & info")
940 } /* end if */
941 else
942 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
943
944 done:
945 FUNC_LEAVE_NOAPI(ret_value)
946 } /* end H5P_set_driver() */
947
948 /*-------------------------------------------------------------------------
949 * Function: H5Pset_driver
950 *
951 * Purpose: Set the file driver (DRIVER_ID) for a file access
952 * property list (PLIST_ID) and supply an optional
953 * struct containing the driver-specific properites
954 * (DRIVER_INFO). The driver properties will be copied into the
955 * property list and the reference count on the driver will be
956 * incremented, allowing the caller to close the driver ID but
957 * still use the property list.
958 *
959 * Return: Success: Non-negative
960 * Failure: Negative
961 *
962 * Programmer: Robb Matzke
963 * Tuesday, August 3, 1999
964 *
965 *-------------------------------------------------------------------------
966 */
967 herr_t
H5Pset_driver(hid_t plist_id,hid_t new_driver_id,const void * new_driver_info)968 H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info)
969 {
970 H5P_genplist_t *plist; /* Property list pointer */
971 herr_t ret_value = SUCCEED; /* Return value */
972
973 FUNC_ENTER_API(FAIL)
974 H5TRACE3("e", "ii*x", plist_id, new_driver_id, new_driver_info);
975
976 /* Check arguments */
977 if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
978 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
979 if (NULL == H5I_object_verify(new_driver_id, H5I_VFL))
980 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID")
981
982 /* Set the driver */
983 if (H5P_set_driver(plist, new_driver_id, new_driver_info) < 0)
984 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info")
985
986 done:
987 FUNC_LEAVE_API(ret_value)
988 } /* end H5Pset_driver() */
989
990 /*-------------------------------------------------------------------------
991 * Function: H5P_peek_driver
992 *
993 * Purpose: Return the ID of the low-level file driver. PLIST_ID should
994 * be a file access property list.
995 *
996 * Return: Success: A low-level driver ID which is the same ID
997 * used when the driver was set for the property
998 * list. The driver ID is only valid as long as
999 * the file driver remains registered.
1000 *
1001 * Failure: Negative
1002 *
1003 * Programmer: Robb Matzke
1004 * Thursday, February 26, 1998
1005 *
1006 *-------------------------------------------------------------------------
1007 */
1008 hid_t
H5P_peek_driver(H5P_genplist_t * plist)1009 H5P_peek_driver(H5P_genplist_t *plist)
1010 {
1011 hid_t ret_value = FAIL; /* Return value */
1012
1013 FUNC_ENTER_NOAPI(FAIL)
1014
1015 /* Get the current driver ID */
1016 if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
1017 H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
1018
1019 if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
1020 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID")
1021 ret_value = driver_prop.driver_id;
1022 } /* end if */
1023 else
1024 HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list")
1025
1026 if (H5FD_VFD_DEFAULT == ret_value)
1027 ret_value = H5_DEFAULT_VFD;
1028
1029 done:
1030 FUNC_LEAVE_NOAPI(ret_value)
1031 } /* end H5P_peek_driver() */
1032
1033 /*-------------------------------------------------------------------------
1034 * Function: H5Pget_driver
1035 *
1036 * Purpose: Return the ID of the low-level file driver. PLIST_ID should
1037 * be a file access property list.
1038 *
1039 * Note: The ID returned should not be closed.
1040 *
1041 * Return: Success: A low-level driver ID which is the same ID
1042 * used when the driver was set for the property
1043 * list. The driver ID is only valid as long as
1044 * the file driver remains registered.
1045 *
1046 * Failure: Negative
1047 *
1048 * Programmer: Robb Matzke
1049 * Thursday, February 26, 1998
1050 *
1051 *-------------------------------------------------------------------------
1052 */
1053 hid_t
H5Pget_driver(hid_t plist_id)1054 H5Pget_driver(hid_t plist_id)
1055 {
1056 H5P_genplist_t *plist; /* Property list pointer */
1057 hid_t ret_value; /* Return value */
1058
1059 FUNC_ENTER_API(FAIL)
1060 H5TRACE1("i", "i", plist_id);
1061
1062 if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1063 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
1064
1065 /* Get the driver */
1066 if ((ret_value = H5P_peek_driver(plist)) < 0)
1067 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver")
1068
1069 done:
1070 FUNC_LEAVE_API(ret_value)
1071 } /* end H5Pget_driver() */
1072
1073 /*-------------------------------------------------------------------------
1074 * Function: H5P_peek_driver_info
1075 *
1076 * Purpose: Returns a pointer directly to the file driver-specific
1077 * information of a file access.
1078 *
1079 * Return: Success: Ptr to *uncopied* driver specific data
1080 * structure if any.
1081 *
1082 * Failure: NULL. Null is also returned if the driver has
1083 * not registered any driver-specific properties
1084 * although no error is pushed on the stack in
1085 * this case.
1086 *
1087 * Programmer: Robb Matzke
1088 * Wednesday, August 4, 1999
1089 *
1090 *-------------------------------------------------------------------------
1091 */
1092 const void *
H5P_peek_driver_info(H5P_genplist_t * plist)1093 H5P_peek_driver_info(H5P_genplist_t *plist)
1094 {
1095 const void *ret_value = NULL; /* Return value */
1096
1097 FUNC_ENTER_NOAPI(NULL)
1098
1099 /* Get the current driver info */
1100 if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
1101 H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
1102
1103 if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
1104 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info")
1105 ret_value = driver_prop.driver_info;
1106 } /* end if */
1107 else
1108 HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a file access property list")
1109
1110 done:
1111 FUNC_LEAVE_NOAPI(ret_value)
1112 } /* end H5P_peek_driver_info() */
1113
1114 /*-------------------------------------------------------------------------
1115 * Function: H5Pget_driver_info
1116 *
1117 * Purpose: Returns a pointer directly to the file driver-specific
1118 * information of a file access.
1119 *
1120 * Return: Success: Ptr to *uncopied* driver specific data
1121 * structure if any.
1122 *
1123 * Failure: NULL. Null is also returned if the driver has
1124 * not registered any driver-specific properties
1125 * although no error is pushed on the stack in
1126 * this case.
1127 *
1128 * Programmer: Robb Matzke
1129 * Wednesday, August 4, 1999
1130 *
1131 *-------------------------------------------------------------------------
1132 */
1133 const void *
H5Pget_driver_info(hid_t plist_id)1134 H5Pget_driver_info(hid_t plist_id)
1135 {
1136 H5P_genplist_t *plist = NULL; /* Property list pointer */
1137 const void * ret_value = NULL; /* Return value */
1138
1139 FUNC_ENTER_API(NULL)
1140 H5TRACE1("*x", "i", plist_id);
1141
1142 if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1143 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list")
1144
1145 /* Get the driver info */
1146 if (NULL == (ret_value = (const void *)H5P_peek_driver_info(plist)))
1147 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info")
1148
1149 done:
1150 FUNC_LEAVE_API(ret_value)
1151 } /* end H5Pget_driver_info() */
1152
1153 /*-------------------------------------------------------------------------
1154 * Function: H5P__file_driver_copy
1155 *
1156 * Purpose: Copy file driver ID & info.
1157 *
1158 * Note: This is an "in-place" copy, since this routine gets called
1159 * after the top-level copy has been performed and this routine
1160 * finishes the "deep" part of the copy.
1161 *
1162 * Return: Success: Non-negative
1163 * Failure: Negative
1164 *
1165 * Programmer: Quincey Koziol
1166 * Monday, Sept 8, 2015
1167 *
1168 *-------------------------------------------------------------------------
1169 */
1170 static herr_t
H5P__file_driver_copy(void * value)1171 H5P__file_driver_copy(void *value)
1172 {
1173 herr_t ret_value = SUCCEED; /* Return value */
1174
1175 FUNC_ENTER_STATIC
1176
1177 if (value) {
1178 H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */
1179
1180 /* Copy the driver & info, if there is one */
1181 if (info->driver_id > 0) {
1182 /* Increment the reference count on driver and copy driver info */
1183 if (H5I_inc_ref(info->driver_id, FALSE) < 0)
1184 HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver")
1185
1186 /* Copy driver info, if it exists */
1187 if (info->driver_info) {
1188 H5FD_class_t *driver; /* Pointer to driver */
1189 void * new_pl; /* Copy of driver info */
1190
1191 /* Retrieve the driver for the ID */
1192 if (NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id)))
1193 HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID")
1194
1195 /* Allow the driver to copy or do it ourselves */
1196 if (driver->fapl_copy) {
1197 if (NULL == (new_pl = (driver->fapl_copy)(info->driver_info)))
1198 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver info copy failed")
1199 } /* end if */
1200 else if (driver->fapl_size > 0) {
1201 if (NULL == (new_pl = H5MM_malloc(driver->fapl_size)))
1202 HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed")
1203 H5MM_memcpy(new_pl, info->driver_info, driver->fapl_size);
1204 } /* end else-if */
1205 else
1206 HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "no way to copy driver info")
1207
1208 /* Set the driver info for the copy */
1209 info->driver_info = new_pl;
1210 } /* end if */
1211 } /* end if */
1212 } /* end if */
1213
1214 done:
1215 FUNC_LEAVE_NOAPI(ret_value)
1216 } /* end H5P__file_driver_copy() */
1217
1218 /*-------------------------------------------------------------------------
1219 * Function: H5P__file_driver_free
1220 *
1221 * Purpose: Free file driver ID & info.
1222 *
1223 * Return: Success: Non-negative
1224 * Failure: Negative
1225 *
1226 * Programmer: Quincey Koziol
1227 * Monday, Sept 8, 2015
1228 *
1229 *-------------------------------------------------------------------------
1230 */
1231 static herr_t
H5P__file_driver_free(void * value)1232 H5P__file_driver_free(void *value)
1233 {
1234 herr_t ret_value = SUCCEED; /* Return value */
1235
1236 FUNC_ENTER_STATIC
1237
1238 if (value) {
1239 H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */
1240
1241 /* Copy the driver & info, if there is one */
1242 if (info->driver_id > 0) {
1243
1244 /* Free the driver info, if it exists */
1245 if (info->driver_info)
1246 if (H5FD_free_driver_info(info->driver_id, info->driver_info) < 0)
1247 HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed")
1248
1249 /* Decrement reference count for driver */
1250 if (H5I_dec_ref(info->driver_id) < 0)
1251 HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID")
1252 }
1253 }
1254
1255 done:
1256 FUNC_LEAVE_NOAPI(ret_value)
1257 } /* end H5P__file_driver_free() */
1258
1259 /*-------------------------------------------------------------------------
1260 * Function: H5P__facc_file_driver_create
1261 *
1262 * Purpose: Create callback for the file driver ID & info property.
1263 *
1264 * Return: Success: Non-negative
1265 * Failure: Negative
1266 *
1267 * Programmer: Quincey Koziol
1268 * Monday, September 8, 2015
1269 *
1270 *-------------------------------------------------------------------------
1271 */
1272 static herr_t
H5P__facc_file_driver_create(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)1273 H5P__facc_file_driver_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
1274 {
1275 herr_t ret_value = SUCCEED; /* Return value */
1276
1277 FUNC_ENTER_STATIC
1278
1279 /* Make copy of file driver */
1280 if (H5P__file_driver_copy(value) < 0)
1281 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver")
1282
1283 done:
1284 FUNC_LEAVE_NOAPI(ret_value)
1285 } /* end H5P__facc_file_driver_create() */
1286
1287 /*-------------------------------------------------------------------------
1288 * Function: H5P__facc_file_driver_set
1289 *
1290 * Purpose: Copies a file driver property when it's set for a property list
1291 *
1292 * Return: Success: Non-negative
1293 * Failure: Negative
1294 *
1295 * Programmer: Quincey Koziol
1296 * Monday, Sept 7, 2015
1297 *
1298 *-------------------------------------------------------------------------
1299 */
1300 static herr_t
H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)1301 H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
1302 size_t H5_ATTR_UNUSED size, void *value)
1303 {
1304 herr_t ret_value = SUCCEED; /* Return value */
1305
1306 FUNC_ENTER_STATIC
1307
1308 /* Sanity check */
1309 HDassert(value);
1310
1311 /* Make copy of file driver ID & info */
1312 if (H5P__file_driver_copy(value) < 0)
1313 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver")
1314
1315 done:
1316 FUNC_LEAVE_NOAPI(ret_value)
1317 } /* end H5P__facc_file_driver_set() */
1318
1319 /*-------------------------------------------------------------------------
1320 * Function: H5P__facc_file_driver_get
1321 *
1322 * Purpose: Copies a file driver property when it's retrieved from a property list
1323 *
1324 * Return: Success: Non-negative
1325 * Failure: Negative
1326 *
1327 * Programmer: Quincey Koziol
1328 * Monday, Sept 7, 2015
1329 *
1330 *-------------------------------------------------------------------------
1331 */
1332 static herr_t
H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)1333 H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
1334 size_t H5_ATTR_UNUSED size, void *value)
1335 {
1336 herr_t ret_value = SUCCEED; /* Return value */
1337
1338 FUNC_ENTER_STATIC
1339
1340 /* Sanity check */
1341 HDassert(value);
1342
1343 /* Make copy of file driver */
1344 if (H5P__file_driver_copy(value) < 0)
1345 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver")
1346
1347 done:
1348 FUNC_LEAVE_NOAPI(ret_value)
1349 } /* end H5P__facc_file_driver_get() */
1350
1351 /*-------------------------------------------------------------------------
1352 * Function: H5P__facc_file_driver_del
1353 *
1354 * Purpose: Frees memory used to store the driver ID & info property
1355 *
1356 * Return: Success: Non-negative
1357 * Failure: Negative
1358 *
1359 * Programmer: Quincey Koziol
1360 * Monday, September 8, 2015
1361 *
1362 *-------------------------------------------------------------------------
1363 */
1364 static herr_t
H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)1365 H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
1366 size_t H5_ATTR_UNUSED size, void *value)
1367 {
1368 herr_t ret_value = SUCCEED; /* Return value */
1369
1370 FUNC_ENTER_STATIC
1371
1372 /* Free the file driver ID & info */
1373 if (H5P__file_driver_free(value) < 0)
1374 HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver")
1375
1376 done:
1377 FUNC_LEAVE_NOAPI(ret_value)
1378 } /* end H5P__facc_file_driver_del() */
1379
1380 /*-------------------------------------------------------------------------
1381 * Function: H5P__facc_file_driver_copy
1382 *
1383 * Purpose: Copy callback for the file driver ID & info property.
1384 *
1385 * Return: Success: Non-negative
1386 * Failure: Negative
1387 *
1388 * Programmer: Quincey Koziol
1389 * Monday, September 8, 2015
1390 *
1391 *-------------------------------------------------------------------------
1392 */
1393 static herr_t
H5P__facc_file_driver_copy(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)1394 H5P__facc_file_driver_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
1395 {
1396 herr_t ret_value = SUCCEED; /* Return value */
1397
1398 FUNC_ENTER_STATIC
1399
1400 /* Make copy of file driver */
1401 if (H5P__file_driver_copy(value) < 0)
1402 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver")
1403
1404 done:
1405 FUNC_LEAVE_NOAPI(ret_value)
1406 } /* end H5P__facc_file_driver_copy() */
1407
1408 /*-------------------------------------------------------------------------
1409 * Function: H5P__facc_file_driver_cmp
1410 *
1411 * Purpose: Callback routine which is called whenever the file driver ID & info
1412 * property in the file access property list is compared.
1413 *
1414 * Return: positive if VALUE1 is greater than VALUE2, negative if
1415 * VALUE2 is greater than VALUE1 and zero if VALUE1 and
1416 * VALUE2 are equal.
1417 *
1418 * Programmer: Quincey Koziol
1419 * Monday, September 8, 2015
1420 *
1421 *-------------------------------------------------------------------------
1422 */
1423 static int
H5P__facc_file_driver_cmp(const void * _info1,const void * _info2,size_t H5_ATTR_UNUSED size)1424 H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size)
1425 {
1426 const H5FD_driver_prop_t *info1 =
1427 (const H5FD_driver_prop_t *)_info1, /* Create local aliases for values */
1428 *info2 = (const H5FD_driver_prop_t *)_info2;
1429 H5FD_class_t *cls1, *cls2; /* Driver class for each property */
1430 int cmp_value; /* Value from comparison */
1431 herr_t ret_value = 0; /* Return value */
1432
1433 FUNC_ENTER_STATIC_NOERR
1434
1435 /* Sanity check */
1436 HDassert(info1);
1437 HDassert(info2);
1438 HDassert(size == sizeof(H5FD_driver_prop_t));
1439
1440 /* Compare drivers */
1441 if (NULL == (cls1 = H5FD_get_class(info1->driver_id)))
1442 HGOTO_DONE(-1)
1443 if (NULL == (cls2 = H5FD_get_class(info2->driver_id)))
1444 HGOTO_DONE(1)
1445 if (cls1->name == NULL && cls2->name != NULL)
1446 HGOTO_DONE(-1);
1447 if (cls1->name != NULL && cls2->name == NULL)
1448 HGOTO_DONE(1);
1449 if (0 != (cmp_value = HDstrcmp(cls1->name, cls2->name)))
1450 HGOTO_DONE(cmp_value);
1451
1452 /* Compare driver infos */
1453 if (cls1->fapl_size < cls2->fapl_size)
1454 HGOTO_DONE(-1)
1455 if (cls1->fapl_size > cls2->fapl_size)
1456 HGOTO_DONE(1)
1457 HDassert(cls1->fapl_size == cls2->fapl_size);
1458 if (info1->driver_info == NULL && info2->driver_info != NULL)
1459 HGOTO_DONE(-1);
1460 if (info1->driver_info != NULL && info2->driver_info == NULL)
1461 HGOTO_DONE(1);
1462 if (info1->driver_info) {
1463 HDassert(cls1->fapl_size > 0);
1464 if (0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size)))
1465 HGOTO_DONE(cmp_value);
1466 } /* end if */
1467
1468 done:
1469 FUNC_LEAVE_NOAPI(ret_value)
1470 } /* end H5P__facc_file_driver_cmp() */
1471
1472 /*-------------------------------------------------------------------------
1473 * Function: H5P__facc_file_driver_close
1474 *
1475 * Purpose: Close callback for the file driver ID & info property.
1476 *
1477 * Return: Success: Non-negative
1478 * Failure: Negative
1479 *
1480 * Programmer: Quincey Koziol
1481 * Monday, September 8, 2015
1482 *
1483 *-------------------------------------------------------------------------
1484 */
1485 static herr_t
H5P__facc_file_driver_close(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)1486 H5P__facc_file_driver_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
1487 {
1488 herr_t ret_value = SUCCEED; /* Return value */
1489
1490 FUNC_ENTER_STATIC
1491
1492 /* Free the file driver */
1493 if (H5P__file_driver_free(value) < 0)
1494 HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver")
1495
1496 done:
1497 FUNC_LEAVE_NOAPI(ret_value)
1498 } /* end H5P__facc_file_driver_close() */
1499
1500 /*-------------------------------------------------------------------------
1501 * Function: H5Pset_family_offset
1502 *
1503 * Purpose: Set offset for family driver. This file access property
1504 * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
1505 * to retrieve VFD file handle.
1506 *
1507 * Return: Success: Non-negative value.
1508 * Failure: Negative value.
1509 *
1510 * Programmer: Raymond Lu
1511 * Sep 17, 2002
1512 *
1513 *-------------------------------------------------------------------------
1514 */
1515 herr_t
H5Pset_family_offset(hid_t fapl_id,hsize_t offset)1516 H5Pset_family_offset(hid_t fapl_id, hsize_t offset)
1517 {
1518 H5P_genplist_t *plist; /* Property list pointer */
1519 herr_t ret_value = SUCCEED; /* Return value */
1520
1521 FUNC_ENTER_API(FAIL)
1522 H5TRACE2("e", "ih", fapl_id, offset);
1523
1524 /* Get the plist structure */
1525 if (H5P_DEFAULT == fapl_id)
1526 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list")
1527 if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
1528 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1529
1530 /* Set value */
1531 if (H5P_set(plist, H5F_ACS_FAMILY_OFFSET_NAME, &offset) < 0)
1532 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set offset for family file")
1533
1534 done:
1535 FUNC_LEAVE_API(ret_value)
1536 } /* end H5Pset_family_offset() */
1537
1538 /*-------------------------------------------------------------------------
1539 * Function: H5Pget_family_offset
1540 *
1541 * Purpose: Get offset for family driver. This file access property
1542 * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
1543 * to retrieve VFD file handle.
1544 *
1545 * Return: Success: Non-negative value.
1546 * Failure: Negative value.
1547 *
1548 * Programmer: Raymond Lu
1549 * Sep 17, 2002
1550 *
1551 *-------------------------------------------------------------------------
1552 */
1553 herr_t
H5Pget_family_offset(hid_t fapl_id,hsize_t * offset)1554 H5Pget_family_offset(hid_t fapl_id, hsize_t *offset)
1555 {
1556 H5P_genplist_t *plist; /* Property list pointer */
1557 herr_t ret_value = SUCCEED; /* Return value */
1558
1559 FUNC_ENTER_API(FAIL)
1560 H5TRACE2("e", "i*h", fapl_id, offset);
1561
1562 /* Get the plist structure */
1563 if (H5P_DEFAULT == fapl_id)
1564 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list")
1565 if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
1566 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1567
1568 /* Get value */
1569 if (offset) {
1570 if (H5P_get(plist, H5F_ACS_FAMILY_OFFSET_NAME, offset) < 0)
1571 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set offset for family file")
1572 } /* end if */
1573
1574 done:
1575 FUNC_LEAVE_API(ret_value)
1576 } /* end H5Pget_family_offset() */
1577
1578 /*-------------------------------------------------------------------------
1579 * Function: H5Pset_multi_type
1580 *
1581 * Purpose: Set data type for multi driver. This file access property
1582 * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
1583 * to retrieve VFD file handle.
1584 *
1585 * Return: Success: Non-negative value.
1586 * Failure: Negative value.
1587 *
1588 * Programmer: Raymond Lu
1589 * Sep 17, 2002
1590 *
1591 *-------------------------------------------------------------------------
1592 */
1593 herr_t
H5Pset_multi_type(hid_t fapl_id,H5FD_mem_t type)1594 H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type)
1595 {
1596 H5P_genplist_t *plist; /* Property list pointer */
1597 herr_t ret_value = SUCCEED; /* return value */
1598
1599 FUNC_ENTER_API(FAIL)
1600 H5TRACE2("e", "iMt", fapl_id, type);
1601
1602 /* Get the plist structure */
1603 if (H5P_DEFAULT == fapl_id)
1604 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list")
1605 if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
1606 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1607
1608 /* Set value */
1609 if (H5P_set(plist, H5F_ACS_MULTI_TYPE_NAME, &type) < 0)
1610 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type for multi driver")
1611
1612 done:
1613 FUNC_LEAVE_API(ret_value)
1614 } /* end H5Pset_multi_type() */
1615
1616 /*-------------------------------------------------------------------------
1617 * Function: H5Pget_multi_type
1618 *
1619 * Purpose: Get data type for multi driver. This file access property
1620 * list will be passed to H5Fget_vfd_handle or H5FDget_vfd_handle
1621 * to retrieve VFD file handle.
1622 *
1623 * Return: Success: Non-negative value.
1624 * Failure: Negative value.
1625 *
1626 * Programmer: Raymond Lu
1627 * Sep 17, 2002
1628 *
1629 *-------------------------------------------------------------------------
1630 */
1631 herr_t
H5Pget_multi_type(hid_t fapl_id,H5FD_mem_t * type)1632 H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type)
1633 {
1634 H5P_genplist_t *plist; /* Property list pointer */
1635 herr_t ret_value = SUCCEED; /* Return value */
1636
1637 FUNC_ENTER_API(FAIL)
1638 H5TRACE2("e", "i*Mt", fapl_id, type);
1639
1640 /* Get the plist structure */
1641 if (H5P_DEFAULT == fapl_id)
1642 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list")
1643 if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
1644 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1645
1646 /* Get value */
1647 if (type) {
1648 if (H5P_get(plist, H5F_ACS_MULTI_TYPE_NAME, type) < 0)
1649 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get type for multi driver")
1650 } /* end if */
1651
1652 done:
1653 FUNC_LEAVE_API(ret_value)
1654 } /* end H5Pget_multi_type() */
1655
1656 /*-------------------------------------------------------------------------
1657 * Function: H5Pset_cache
1658 *
1659 * Purpose: Set the number of objects in the meta data cache and the
1660 * maximum number of chunks and bytes in the raw data chunk
1661 * cache.
1662 *
1663 * The RDCC_W0 value should be between 0 and 1 inclusive and
1664 * indicates how much chunks that have been fully read or fully
1665 * written are favored for preemption. A value of zero means
1666 * fully read or written chunks are treated no differently than
1667 * other chunks (the preemption is strictly LRU) while a value
1668 * of one means fully read chunks are always preempted before
1669 * other chunks.
1670 *
1671 * Return: Non-negative on success/Negative on failure
1672 *
1673 * Programmer: Robb Matzke
1674 * Tuesday, May 19, 1998
1675 *
1676 *-------------------------------------------------------------------------
1677 */
1678 herr_t
H5Pset_cache(hid_t plist_id,int H5_ATTR_UNUSED mdc_nelmts,size_t rdcc_nslots,size_t rdcc_nbytes,double rdcc_w0)1679 H5Pset_cache(hid_t plist_id, int H5_ATTR_UNUSED mdc_nelmts, size_t rdcc_nslots, size_t rdcc_nbytes,
1680 double rdcc_w0)
1681 {
1682 H5P_genplist_t *plist; /* Property list pointer */
1683 herr_t ret_value = SUCCEED; /* return value */
1684
1685 FUNC_ENTER_API(FAIL)
1686 H5TRACE5("e", "iIszzd", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0);
1687
1688 /* Check arguments */
1689 if (rdcc_w0 < 0.0 || rdcc_w0 > 1.0)
1690 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
1691 "raw data cache w0 value must be between 0.0 and 1.0 inclusive")
1692
1693 /* Get the plist structure */
1694 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
1695 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1696
1697 /* Set sizes */
1698 if (H5P_set(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0)
1699 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots")
1700 if (H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0)
1701 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size")
1702 if (H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0)
1703 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks")
1704
1705 done:
1706 FUNC_LEAVE_API(ret_value)
1707 } /* end H5Pset_cache() */
1708
1709 /*-------------------------------------------------------------------------
1710 * Function: H5Pget_cache
1711 *
1712 * Purpose: Retrieves the maximum possible number of elements in the meta
1713 * data cache and the maximum possible number of elements and
1714 * bytes and the RDCC_W0 value in the raw data chunk cache. Any
1715 * (or all) arguments may be null pointers in which case the
1716 * corresponding datum is not returned.
1717 *
1718 * Return: Non-negative on success/Negative on failure
1719 *
1720 * Programmer: Robb Matzke
1721 * Tuesday, May 19, 1998
1722 *
1723 *-------------------------------------------------------------------------
1724 */
1725 herr_t
H5Pget_cache(hid_t plist_id,int * mdc_nelmts,size_t * rdcc_nslots,size_t * rdcc_nbytes,double * rdcc_w0)1726 H5Pget_cache(hid_t plist_id, int *mdc_nelmts, size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0)
1727 {
1728 H5P_genplist_t *plist; /* Property list pointer */
1729 herr_t ret_value = SUCCEED; /* return value */
1730
1731 FUNC_ENTER_API(FAIL)
1732 H5TRACE5("e", "i*Is*z*z*d", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0);
1733
1734 /* Get the plist structure */
1735 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
1736 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1737
1738 /* Get sizes */
1739
1740 /* the mdc_nelmts FAPL entry no longer exists, so just return a constant */
1741 if (mdc_nelmts)
1742 *mdc_nelmts = 0;
1743
1744 if (rdcc_nslots)
1745 if (H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0)
1746 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache number of slots")
1747 if (rdcc_nbytes)
1748 if (H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0)
1749 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get data cache byte size")
1750 if (rdcc_w0)
1751 if (H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0)
1752 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get preempt read chunks")
1753
1754 done:
1755 FUNC_LEAVE_API(ret_value)
1756 } /* end H5Pget_cache() */
1757
1758 /*-------------------------------------------------------------------------
1759 * Function: H5Pset_mdc_image_config
1760 *
1761 * Purpose: Set the initial metadata cache image configuration in the
1762 * target FAPL.
1763 *
1764 * Return: Non-negative on success/Negative on failure
1765 *
1766 * Programmer: J. Mainzer
1767 * Thursday, June 25, 2015
1768 *
1769 *-------------------------------------------------------------------------
1770 */
1771 herr_t
H5Pset_mdc_image_config(hid_t plist_id,H5AC_cache_image_config_t * config_ptr)1772 H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr)
1773 {
1774 H5P_genplist_t *plist; /* Property list pointer */
1775 herr_t ret_value = SUCCEED; /* return value */
1776
1777 FUNC_ENTER_API(FAIL)
1778 H5TRACE2("e", "i*x", plist_id, config_ptr);
1779
1780 /* Get the plist structure */
1781 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
1782 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1783
1784 /* validate the new configuration */
1785 if (H5AC_validate_cache_image_config(config_ptr) < 0)
1786 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache image configuration")
1787
1788 /* set the modified metadata cache image config */
1789
1790 /* If we ever support multiple versions of H5AC_cache_image_config_t, we
1791 * will have to test the version and do translation here.
1792 */
1793
1794 if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0)
1795 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache image initial config")
1796
1797 done:
1798 FUNC_LEAVE_API(ret_value)
1799 } /* H5Pset_mdc_image_config() */
1800
1801 /*-------------------------------------------------------------------------
1802 * Function: H5Pget_mdc_image_config
1803 *
1804 * Purpose: Retrieve the metadata cache initial image configuration
1805 * from the target FAPL.
1806 *
1807 * Observe that the function will fail if config_ptr is
1808 * NULL, or if config_ptr->version specifies an unknown
1809 * version of H5AC_cache_image_config_t.
1810 *
1811 * Return: Non-negative on success/Negative on failure
1812 *
1813 * Programmer: J. Mainzer
1814 * Friday, June 26, 2015
1815 *
1816 *-------------------------------------------------------------------------
1817 */
1818 herr_t
H5Pget_mdc_image_config(hid_t plist_id,H5AC_cache_image_config_t * config)1819 H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config)
1820 {
1821 H5P_genplist_t *plist; /* Property list pointer */
1822 herr_t ret_value = SUCCEED; /* return value */
1823
1824 FUNC_ENTER_API(FAIL)
1825 H5TRACE2("e", "i*x", plist_id, config);
1826
1827 /* Get the plist structure */
1828 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
1829 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1830
1831 /* validate the config ptr */
1832 if (config == NULL)
1833 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config ptr on entry.")
1834 if (config->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION)
1835 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown image config version.")
1836
1837 /* If we ever support multiple versions of H5AC_cache_config_t, we
1838 * will have to get the canonical version here, and then translate
1839 * to the version of the structure supplied.
1840 */
1841
1842 /* Get the current initial metadata cache resize configuration */
1843 if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config) < 0)
1844 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial image config")
1845
1846 done:
1847 FUNC_LEAVE_API(ret_value)
1848 } /* H5Pget_mdc_image_config() */
1849
1850 /*-------------------------------------------------------------------------
1851 * Function: H5Pset_mdc_config
1852 *
1853 * Purpose: Set the initial metadata cache resize configuration in the
1854 * target FAPL.
1855 *
1856 * Return: Non-negative on success/Negative on failure
1857 *
1858 * Programmer: J. Mainzer
1859 * Thursday, April 7, 2005
1860 *
1861 *-------------------------------------------------------------------------
1862 */
1863 herr_t
H5Pset_mdc_config(hid_t plist_id,H5AC_cache_config_t * config_ptr)1864 H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr)
1865 {
1866 H5P_genplist_t *plist; /* Property list pointer */
1867 herr_t ret_value = SUCCEED; /* return value */
1868
1869 FUNC_ENTER_API(FAIL)
1870 H5TRACE2("e", "i*x", plist_id, config_ptr);
1871
1872 /* Get the plist structure */
1873 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
1874 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1875
1876 /* validate the new configuration */
1877 if (H5AC_validate_config(config_ptr) < 0)
1878 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache configuration")
1879
1880 /* set the modified config */
1881
1882 /* If we ever support multiple versions of H5AC_cache_config_t, we
1883 * will have to test the version and do translation here.
1884 */
1885
1886 if (H5P_set(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config_ptr) < 0)
1887 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache initial config")
1888
1889 done:
1890 FUNC_LEAVE_API(ret_value)
1891 } /* H5Pset_mdc_config() */
1892
1893 /*-------------------------------------------------------------------------
1894 * Function: H5Pget_mdc_config
1895 *
1896 * Purpose: Retrieve the metadata cache initial resize configuration
1897 * from the target FAPL.
1898 *
1899 * Observe that the function will fail if config is
1900 * NULL, or if config_ptr->version specifies an unknown
1901 * version of H5AC_cache_config_t.
1902 *
1903 * Return: Non-negative on success/Negative on failure
1904 *
1905 * Programmer: J. Mainzer
1906 * Thursday, April 7, 2005
1907 *
1908 *-------------------------------------------------------------------------
1909 */
1910 herr_t
H5Pget_mdc_config(hid_t plist_id,H5AC_cache_config_t * config)1911 H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config)
1912 {
1913 H5P_genplist_t *plist; /* Property list pointer */
1914 herr_t ret_value = SUCCEED; /* return value */
1915
1916 FUNC_ENTER_API(FAIL)
1917 H5TRACE2("e", "i*x", plist_id, config);
1918
1919 /* Get the plist structure */
1920 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
1921 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1922
1923 /* validate the config ptr */
1924 if (config == NULL)
1925 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config ptr on entry.")
1926 if (config->version != H5AC__CURR_CACHE_CONFIG_VERSION)
1927 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown config version.")
1928
1929 /* If we ever support multiple versions of H5AC_cache_config_t, we
1930 * will have to get the canonical version here, and then translate
1931 * to the version of the structure supplied.
1932 */
1933
1934 /* Get the current initial metadata cache resize configuration */
1935 if (H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, config) < 0)
1936 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get metadata cache initial resize config")
1937
1938 done:
1939 FUNC_LEAVE_API(ret_value)
1940 } /* H5Pget_mdc_config() */
1941
1942 /*-------------------------------------------------------------------------
1943 * Function: H5Pset_gc_references
1944 *
1945 * Purpose: Sets the flag for garbage collecting references for the file.
1946 * Dataset region references (and other reference types
1947 * probably) use space in the file heap. If garbage collection
1948 * is on and the user passes in an uninitialized value in a
1949 * reference structure, the heap might get corrupted. When
1950 * garbage collection is off however and the user re-uses a
1951 * reference, the previous heap block will be orphaned and not
1952 * returned to the free heap space. When garbage collection is
1953 * on, the user must initialize the reference structures to 0 or
1954 * risk heap corruption.
1955 *
1956 * Default value for garbage collecting references is off, just
1957 * to be on the safe side.
1958 *
1959 * Return: Non-negative on success/Negative on failure
1960 *
1961 * Programmer: Quincey Koziol
1962 * June, 1999
1963 *
1964 *-------------------------------------------------------------------------
1965 */
1966 herr_t
H5Pset_gc_references(hid_t plist_id,unsigned gc_ref)1967 H5Pset_gc_references(hid_t plist_id, unsigned gc_ref)
1968 {
1969 H5P_genplist_t *plist; /* Property list pointer */
1970 herr_t ret_value = SUCCEED; /* return value */
1971
1972 FUNC_ENTER_API(FAIL)
1973 H5TRACE2("e", "iIu", plist_id, gc_ref);
1974
1975 /* Get the plist structure */
1976 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
1977 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
1978
1979 /* Set values */
1980 if (H5P_set(plist, H5F_ACS_GARBG_COLCT_REF_NAME, &gc_ref) < 0)
1981 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference")
1982
1983 done:
1984 FUNC_LEAVE_API(ret_value)
1985 }
1986
1987 /*-------------------------------------------------------------------------
1988 * Function: H5Pget_gc_references
1989 *
1990 * Purpose: Returns the current setting for the garbage collection
1991 * references property from a file access property list.
1992 *
1993 * Return: Non-negative on success/Negative on failure
1994 *
1995 * Programmer: Quincey Koziol
1996 * June, 1999
1997 *
1998 *-------------------------------------------------------------------------
1999 */
2000 herr_t
H5Pget_gc_references(hid_t plist_id,unsigned * gc_ref)2001 H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref /*out*/)
2002 {
2003 H5P_genplist_t *plist; /* Property list pointer */
2004 herr_t ret_value = SUCCEED; /* return value */
2005
2006 FUNC_ENTER_API(FAIL)
2007 H5TRACE2("e", "ix", plist_id, gc_ref);
2008
2009 /* Get the plist structure */
2010 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2011 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2012
2013 /* Get values */
2014 if (gc_ref)
2015 if (H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0)
2016 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get garbage collect reference")
2017
2018 done:
2019 FUNC_LEAVE_API(ret_value)
2020 }
2021
2022 /*-------------------------------------------------------------------------
2023 * Function: H5Pset_fclose_degree
2024 *
2025 * Purpose: Sets the degree for the file close behavior.
2026 *
2027 * Return: Non-negative on success/Negative on failure
2028 *
2029 * Programmer: Raymond Lu
2030 * November, 2001
2031 *
2032 *-------------------------------------------------------------------------
2033 */
2034 herr_t
H5Pset_fclose_degree(hid_t plist_id,H5F_close_degree_t degree)2035 H5Pset_fclose_degree(hid_t plist_id, H5F_close_degree_t degree)
2036 {
2037 H5P_genplist_t *plist; /* Property list pointer */
2038 herr_t ret_value = SUCCEED; /* return value */
2039
2040 FUNC_ENTER_API(FAIL)
2041 H5TRACE2("e", "iFd", plist_id, degree);
2042
2043 /* Get the plist structure */
2044 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2045 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2046
2047 /* Set values */
2048 if (H5P_set(plist, H5F_ACS_CLOSE_DEGREE_NAME, °ree) < 0)
2049 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree")
2050
2051 done:
2052 FUNC_LEAVE_API(ret_value)
2053 } /* end H5Pset_fclose_degree() */
2054
2055 /*-------------------------------------------------------------------------
2056 * Function: H5Pget_fclose_degree
2057 *
2058 * Purpose: Returns the degree for the file close behavior.
2059 *
2060 * Return: Non-negative on success/Negative on failure
2061 *
2062 * Programmer: Raymond Lu
2063 * November, 2001
2064 *
2065 *-------------------------------------------------------------------------
2066 */
2067 herr_t
H5Pget_fclose_degree(hid_t plist_id,H5F_close_degree_t * degree)2068 H5Pget_fclose_degree(hid_t plist_id, H5F_close_degree_t *degree)
2069 {
2070 H5P_genplist_t *plist; /* Property list pointer */
2071 herr_t ret_value = SUCCEED; /* return value */
2072
2073 FUNC_ENTER_API(FAIL)
2074 H5TRACE2("e", "i*Fd", plist_id, degree);
2075
2076 /* Get the plist structure */
2077 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2078 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2079
2080 if (degree && H5P_get(plist, H5F_ACS_CLOSE_DEGREE_NAME, degree) < 0)
2081 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file close degree")
2082
2083 done:
2084 FUNC_LEAVE_API(ret_value)
2085 } /* end H5Pget_fclose_degree() */
2086
2087 /*-------------------------------------------------------------------------
2088 * Function: H5Pset_meta_block_size
2089 *
2090 * Purpose: Sets the minimum size of metadata block allocations when
2091 * the H5FD_FEAT_AGGREGATE_METADATA is set by a VFL driver.
2092 * Each "raw" metadata block is allocated to be this size and then
2093 * specific pieces of metadata (object headers, local heaps, B-trees, etc)
2094 * are sub-allocated from this block.
2095 *
2096 * The default value is set to 2048 (bytes), indicating that metadata
2097 * will be attempted to be bunched together in (at least) 2K blocks in
2098 * the file. Setting the value to 0 with this API function will
2099 * turn off the metadata aggregation, even if the VFL driver attempts to
2100 * use that strategy.
2101 *
2102 * Return: Non-negative on success/Negative on failure
2103 *
2104 * Programmer: Quincey Koziol
2105 * Friday, August 25, 2000
2106 *
2107 *-------------------------------------------------------------------------
2108 */
2109 herr_t
H5Pset_meta_block_size(hid_t plist_id,hsize_t size)2110 H5Pset_meta_block_size(hid_t plist_id, hsize_t size)
2111 {
2112 H5P_genplist_t *plist; /* Property list pointer */
2113 herr_t ret_value = SUCCEED; /* return value */
2114
2115 FUNC_ENTER_API(FAIL)
2116 H5TRACE2("e", "ih", plist_id, size);
2117
2118 /* Get the plist structure */
2119 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2120 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2121
2122 /* Set values */
2123 if (H5P_set(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &size) < 0)
2124 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data block size")
2125
2126 done:
2127 FUNC_LEAVE_API(ret_value)
2128 }
2129
2130 /*-------------------------------------------------------------------------
2131 * Function: H5Pget_meta_block_size
2132 *
2133 * Purpose: Returns the current settings for the metadata block allocation
2134 * property from a file access property list.
2135 *
2136 * Return: Non-negative on success/Negative on failure
2137 *
2138 * Programmer: Quincey Koziol
2139 * Friday, August 29, 2000
2140 *
2141 *-------------------------------------------------------------------------
2142 */
2143 herr_t
H5Pget_meta_block_size(hid_t plist_id,hsize_t * size)2144 H5Pget_meta_block_size(hid_t plist_id, hsize_t *size /*out*/)
2145 {
2146 H5P_genplist_t *plist; /* Property list pointer */
2147 herr_t ret_value = SUCCEED; /* return value */
2148
2149 FUNC_ENTER_API(FAIL)
2150 H5TRACE2("e", "ix", plist_id, size);
2151
2152 /* Get the plist structure */
2153 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2154 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2155
2156 /* Get values */
2157 if (size) {
2158 if (H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, size) < 0)
2159 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get meta data block size")
2160 } /* end if */
2161
2162 done:
2163 FUNC_LEAVE_API(ret_value)
2164 }
2165
2166 /*-------------------------------------------------------------------------
2167 * Function: H5Pset_sieve_buf_size
2168 *
2169 * Purpose: Sets the maximum size of the data seive buffer used for file
2170 * drivers which are capable of using data sieving. The data sieve
2171 * buffer is used when performing I/O on datasets in the file. Using a
2172 * buffer which is large anough to hold several pieces of the dataset
2173 * being read in for hyperslab selections boosts performance by quite a
2174 * bit.
2175 *
2176 * The default value is set to 64KB, indicating that file I/O for raw data
2177 * reads and writes will occur in at least 64KB blocks.
2178 * Setting the value to 0 with this API function will turn off the
2179 * data sieving, even if the VFL driver attempts to use that strategy.
2180 *
2181 * Return: Non-negative on success/Negative on failure
2182 *
2183 * Programmer: Quincey Koziol
2184 * Thursday, September 21, 2000
2185 *
2186 *-------------------------------------------------------------------------
2187 */
2188 herr_t
H5Pset_sieve_buf_size(hid_t plist_id,size_t size)2189 H5Pset_sieve_buf_size(hid_t plist_id, size_t size)
2190 {
2191 H5P_genplist_t *plist; /* Property list pointer */
2192 herr_t ret_value = SUCCEED; /* return value */
2193
2194 FUNC_ENTER_API(FAIL)
2195 H5TRACE2("e", "iz", plist_id, size);
2196
2197 /* Get the plist structure */
2198 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2199 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2200
2201 /* Set values */
2202 if (H5P_set(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &size) < 0)
2203 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set sieve buffer size")
2204
2205 done:
2206 FUNC_LEAVE_API(ret_value)
2207 } /* end H5Pset_sieve_buf_size() */
2208
2209 /*-------------------------------------------------------------------------
2210 * Function: H5Pget_sieve_buf_size
2211 *
2212 * Purpose: Returns the current settings for the data sieve buffer size
2213 * property from a file access property list.
2214 *
2215 * Return: Non-negative on success/Negative on failure
2216 *
2217 * Programmer: Quincey Koziol
2218 * Thursday, September 21, 2000
2219 *
2220 *-------------------------------------------------------------------------
2221 */
2222 herr_t
H5Pget_sieve_buf_size(hid_t plist_id,size_t * size)2223 H5Pget_sieve_buf_size(hid_t plist_id, size_t *size /*out*/)
2224 {
2225 H5P_genplist_t *plist; /* Property list pointer */
2226 herr_t ret_value = SUCCEED; /* return value */
2227
2228 FUNC_ENTER_API(FAIL)
2229 H5TRACE2("e", "ix", plist_id, size);
2230
2231 /* Get the plist structure */
2232 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2233 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2234
2235 /* Get values */
2236 if (size)
2237 if (H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, size) < 0)
2238 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get sieve buffer size")
2239
2240 done:
2241 FUNC_LEAVE_API(ret_value)
2242 } /* end H5Pget_sieve_buf_size() */
2243
2244 /*-------------------------------------------------------------------------
2245 * Function: H5Pset_small_data_block_size
2246 *
2247 * Purpose: Sets the minimum size of "small" raw data block allocations
2248 * when the H5FD_FEAT_AGGREGATE_SMALLDATA is set by a VFL driver.
2249 * Each "small" raw data block is allocated to be this size and then
2250 * pieces of raw data which are small enough to fit are sub-allocated from
2251 * this block.
2252 *
2253 * The default value is set to 2048 (bytes), indicating that raw data
2254 * smaller than this value will be attempted to be bunched together in (at
2255 * least) 2K blocks in the file. Setting the value to 0 with this API
2256 * function will turn off the "small" raw data aggregation, even if the
2257 * VFL driver attempts to use that strategy.
2258 *
2259 * Return: Non-negative on success/Negative on failure
2260 *
2261 * Programmer: Quincey Koziol
2262 * Wednesday, June 5, 2002
2263 *
2264 *-------------------------------------------------------------------------
2265 */
2266 herr_t
H5Pset_small_data_block_size(hid_t plist_id,hsize_t size)2267 H5Pset_small_data_block_size(hid_t plist_id, hsize_t size)
2268 {
2269 H5P_genplist_t *plist; /* Property list pointer */
2270 herr_t ret_value = SUCCEED; /* return value */
2271
2272 FUNC_ENTER_API(FAIL)
2273 H5TRACE2("e", "ih", plist_id, size);
2274
2275 /* Get the plist structure */
2276 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2277 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2278
2279 /* Set values */
2280 if (H5P_set(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &size) < 0)
2281 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' block size")
2282
2283 done:
2284 FUNC_LEAVE_API(ret_value)
2285 } /* end H5Pset_small_data_block_size() */
2286
2287 /*-------------------------------------------------------------------------
2288 * Function: H5Pget_small_data_block_size
2289 *
2290 * Purpose: Returns the current settings for the "small" raw data block
2291 * allocation property from a file access property list.
2292 *
2293 * Return: Non-negative on success/Negative on failure
2294 *
2295 * Programmer: Quincey Koziol
2296 * Wednesday, June 5, 2002
2297 *
2298 *-------------------------------------------------------------------------
2299 */
2300 herr_t
H5Pget_small_data_block_size(hid_t plist_id,hsize_t * size)2301 H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size /*out*/)
2302 {
2303 H5P_genplist_t *plist; /* Property list pointer */
2304 herr_t ret_value = SUCCEED; /* return value */
2305
2306 FUNC_ENTER_API(FAIL)
2307 H5TRACE2("e", "ix", plist_id, size);
2308
2309 /* Get the plist structure */
2310 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2311 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2312
2313 /* Get values */
2314 if (size) {
2315 if (H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, size) < 0)
2316 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get 'small data' block size")
2317 } /* end if */
2318
2319 done:
2320 FUNC_LEAVE_API(ret_value)
2321 } /* end H5Pget_small_data_block_size() */
2322
2323 /*-------------------------------------------------------------------------
2324 * Function: H5Pset_libver_bounds
2325 *
2326 * Purpose: Indicates which versions of the file format the library should
2327 * use when creating objects. LOW is the earliest version of the HDF5
2328 * library that is guaranteed to be able to access the objects created
2329 * (the format of some objects in an HDF5 file may not have changed between
2330 * versions of the HDF5 library, possibly allowing earlier versions of the
2331 * HDF5 library to access those objects) and HIGH is the latest version
2332 * of the library required to access the objects created (later versions
2333 * of the HDF5 library will also be able to access those objects).
2334 *
2335 * LOW is used to require that objects use a more modern format and HIGH
2336 * is used to restrict objects from using a more modern format.
2337 *
2338 * The special values of H5F_FORMAT_EARLIEST and H5F_FORMAT_LATEST can be
2339 * used in the following manner: Setting LOW and HIGH to H5F_FORMAT_LATEST
2340 * will produce files whose objects use the latest version of the file
2341 * format available in the current HDF5 library for each object created.
2342 * Setting LOW and HIGH to H5F_FORMAT_EARLIEST will produce files that that
2343 * always require the use of the earliest version of the file format for
2344 * each object created. [NOTE! LOW=HIGH=H5F_FORMAT_EARLIEST is not
2345 * implemented as of version 1.8.0 and setting LOW and HIGH to
2346 * H5F_FORMAT_EARLIEST will produce an error currently].
2347 *
2348 * Currently, the only two valid combinations for this routine are:
2349 * LOW = H5F_FORMAT_EARLIEST and HIGH = H5F_FORMAT_LATEST (the default
2350 * setting, which creates objects with the ealiest version possible for
2351 * each object, but no upper limit on the version allowed to be created if
2352 * a newer version of an object's format is required to support a feature
2353 * requested with an HDF5 library API routine), and LOW = H5F_FORMAT_LATEST
2354 * and HIGH = H5F_FORMAT_LATEST (which is described above).
2355 *
2356 * The LOW and HIGH values set with this routine at imposed with each
2357 * HDF5 library API call that creates objects in the file. API calls that
2358 * would violate the LOW or HIGH format bound will fail.
2359 *
2360 * Setting the LOW and HIGH values will not affect reading/writing existing
2361 * objects, only the creation of new objects.
2362 *
2363 * Note: Eventually we want to add more values to the H5F_libver_t
2364 * enumerated type that indicate library release values where the file
2365 * format was changed (like "H5F_FORMAT_1_2_0" for the file format changes
2366 * in the 1.2.x release branch and possily even "H5F_FORMAT_1_4_2" for
2367 * a change mid-way through the 1.4.x release branch, etc).
2368 *
2369 * Adding more values will allow applications to make settings like the
2370 * following:
2371 * LOW = H5F_FORMAT_EARLIEST, HIGH = H5F_FORMAT_1_2_0 => Create objects
2372 * with the earliest possible format and don't allow any objects
2373 * to be created that require a library version greater than 1.2.x
2374 * (This is the "make certain that <application> linked with v1.2.x
2375 * of the library can read the file produced" use case)
2376 *
2377 * LOW = H5F_FORMAT_1_4_2, HIGH = H5F_FORMAT_LATEST => create objects
2378 * with at least the version of their format that the 1.4.2 library
2379 * uses and allow any later version of the object's format
2380 * necessary to represent features used.
2381 * (This is the "make certain to take advantage of <new feature>
2382 * in the file format" use case (maybe <new feature> is smaller
2383 * or scales better than an earlier version, which would otherwise
2384 * be used))
2385 *
2386 * LOW = H5F_FORMAT_1_2_0, HIGH = H5F_FORMAT_1_6_0 => creates objects
2387 * with at least the version of their format that the 1.2.x library
2388 * uses and don't allow any objects to be created that require a
2389 * library version greater than 1.6.x.
2390 * (Not certain of a particular use case for these settings,
2391 * although its probably just the logical combination of the
2392 * previous two; it just falls out as possible/logical (if it turns
2393 * out to be hard to implement in some way, we can always disallow
2394 * it))
2395 *
2396 * Note #2: We talked about whether to include enum values for only library
2397 * versions where the format changed and decided it would be less confusing
2398 * for application developers if we include enum values for _all_ library
2399 * releases and then map down to the previous actual library release which
2400 * had a format change.
2401 *
2402 * Note #3: The enumerated define for H5F_libver_t in 1.10 is:
2403 * typedef enum H5F_libver_t {
2404 * H5F_LIBVER_ERROR = -1,
2405 * H5F_LIBVER_EARLIEST = 0,
2406 * H5F_LIBVER_V18 = 1,
2407 * H5F_LIBVER_V110 = 2,
2408 * H5F_LIBVER_NBOUNDS
2409 * } H5F_libver_t;
2410 * #define H5F_LIBVER_LATEST H5F_LIBVER_V110
2411 *
2412 * The library supports five pairs of (low, high) combinations via H5Pset_libver_bounds():
2413 * 1) H5F_LIBVER_EARLIEST, H5F_LIBVER_V18
2414 * 2) H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST
2415 * 4) H5F_LIBVER_V18, H5F_LIBVER_V18
2416 * 4) H5F_LIBVER_V18, H5F_LIBVER_LATEST
2417 * 5) H5F_LIBVER_LATEST, H5F_LIBVER_LATEST
2418 * See detailed description in the RFC: Setting Bounds for Object Creation in HDF5 1.10.0.
2419 *
2420 * Return: Non-negative on success/Negative on failure
2421 *
2422 * Programmer: Quincey Koziol
2423 * Sunday, December 30, 2007
2424 *
2425 *-------------------------------------------------------------------------
2426 */
2427 herr_t
H5Pset_libver_bounds(hid_t plist_id,H5F_libver_t low,H5F_libver_t high)2428 H5Pset_libver_bounds(hid_t plist_id, H5F_libver_t low, H5F_libver_t high)
2429 {
2430 H5P_genplist_t *plist; /* Property list pointer */
2431 herr_t ret_value = SUCCEED; /* return value */
2432
2433 FUNC_ENTER_API(FAIL)
2434 H5TRACE3("e", "iFvFv", plist_id, low, high);
2435
2436 /* Check args */
2437 if (low < 0 || low > H5F_LIBVER_LATEST)
2438 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "low bound is not valid")
2439 if (high < 0 || high > H5F_LIBVER_LATEST)
2440 HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "high bound is not valid")
2441
2442 /* (earliest, earliest), (latest, earliest), (v18, earliest) are not valid combinations */
2443 if (high == H5F_LIBVER_EARLIEST)
2444 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound")
2445
2446 /* (latest, v18) is not valid combination */
2447 if (high < low)
2448 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Invalid (low,high) combination of library version bound")
2449
2450 /* Get the plist structure */
2451 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2452 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2453
2454 /* Set values */
2455 if (H5P_set(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low) < 0)
2456 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set low bound for library format versions")
2457 if (H5P_set(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high) < 0)
2458 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set high bound for library format versions")
2459 done:
2460 FUNC_LEAVE_API(ret_value)
2461 } /* end H5Pset_libver_bounds() */
2462
2463 /*-------------------------------------------------------------------------
2464 * Function: H5Pget_libver_bounds
2465 *
2466 * Purpose: Returns the current settings for the library version format bounds
2467 * from a file access property list.
2468 *
2469 * Return: Non-negative on success/Negative on failure
2470 *
2471 * Programmer: Quincey Koziol
2472 * Thursday, January 3, 2008
2473 *
2474 *-------------------------------------------------------------------------
2475 */
2476 herr_t
H5Pget_libver_bounds(hid_t plist_id,H5F_libver_t * low,H5F_libver_t * high)2477 H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low /*out*/, H5F_libver_t *high /*out*/)
2478 {
2479 H5P_genplist_t *plist; /* Property list pointer */
2480 herr_t ret_value = SUCCEED; /* return value */
2481
2482 FUNC_ENTER_API(FAIL)
2483 H5TRACE3("e", "ixx", plist_id, low, high);
2484
2485 /* Get the plist structure */
2486 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2487 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2488
2489 /* Get values */
2490 if (low)
2491 if (H5P_get(plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, low) < 0)
2492 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get low bound for library format versions")
2493
2494 if (high)
2495 if (H5P_get(plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, high) < 0)
2496 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get high bound for library format versions")
2497
2498 done:
2499 FUNC_LEAVE_API(ret_value)
2500 } /* end H5Pget_libver_bounds() */
2501
2502 /*-------------------------------------------------------------------------
2503 * Function: H5Pset_elink_file_cache_size
2504 *
2505 * Purpose: Sets the number of files opened through external links
2506 * from the file associated with this fapl to be held open
2507 * in that file's external file cache. When the maximum
2508 * number of files is reached, the least recently used file
2509 * is closed (unless it is opened from somewhere else).
2510 *
2511 * Return: Non-negative on success/Negative on failure
2512 *
2513 * Programmer: Neil Fortner
2514 * Friday, December 17, 2010
2515 *
2516 *-------------------------------------------------------------------------
2517 */
2518 herr_t
H5Pset_elink_file_cache_size(hid_t plist_id,unsigned efc_size)2519 H5Pset_elink_file_cache_size(hid_t plist_id, unsigned efc_size)
2520 {
2521 H5P_genplist_t *plist; /* Property list pointer */
2522 herr_t ret_value = SUCCEED; /* return value */
2523
2524 FUNC_ENTER_API(FAIL)
2525 H5TRACE2("e", "iIu", plist_id, efc_size);
2526
2527 /* Get the plist structure */
2528 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2529 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2530
2531 /* Set value */
2532 if (H5P_set(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0)
2533 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set elink file cache size")
2534
2535 done:
2536 FUNC_LEAVE_API(ret_value)
2537 } /* end H5Pset_elink_file_cache_size() */
2538
2539 /*-------------------------------------------------------------------------
2540 * Function: H5Pget_elink_file_cache_size
2541 *
2542 * Purpose: Gets the number of files opened through external links
2543 * from the file associated with this fapl to be held open
2544 * in that file's external file cache. When the maximum
2545 * number of files is reached, the least recently used file
2546 * is closed (unless it is opened from somewhere else).
2547 *
2548 * Return: Non-negative on success/Negative on failure
2549 *
2550 * Programmer: Neil Fortner
2551 * Friday, December 17, 2010
2552 *
2553 *-------------------------------------------------------------------------
2554 */
2555 herr_t
H5Pget_elink_file_cache_size(hid_t plist_id,unsigned * efc_size)2556 H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size)
2557 {
2558 H5P_genplist_t *plist; /* Property list pointer */
2559 herr_t ret_value = SUCCEED; /* return value */
2560
2561 FUNC_ENTER_API(FAIL)
2562 H5TRACE2("e", "i*Iu", plist_id, efc_size);
2563
2564 /* Get the plist structure */
2565 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
2566 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2567
2568 /* Get value */
2569 if (efc_size)
2570 if (H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, efc_size) < 0)
2571 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get elink file cache size")
2572
2573 done:
2574 FUNC_LEAVE_API(ret_value)
2575 } /* end H5Pget_elink_file_cache_size() */
2576
2577 /*-------------------------------------------------------------------------
2578 * Function: H5Pset_file_image
2579 *
2580 * Purpose: Sets the initial file image. Some file drivers can initialize
2581 * the starting data in a file from a buffer.
2582 *
2583 * Return: Non-negative on success/Negative on failure
2584 *
2585 * Programmer: Jacob Gruber
2586 * Thurday, August 11, 2011
2587 *
2588 *-------------------------------------------------------------------------
2589 */
2590 herr_t
H5Pset_file_image(hid_t fapl_id,void * buf_ptr,size_t buf_len)2591 H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len)
2592 {
2593 H5P_genplist_t * fapl; /* Property list pointer */
2594 H5FD_file_image_info_t image_info; /* File image info */
2595 herr_t ret_value = SUCCEED; /* Return value */
2596
2597 FUNC_ENTER_API(FAIL)
2598 H5TRACE3("e", "i*xz", fapl_id, buf_ptr, buf_len);
2599
2600 /* validate parameters */
2601 if (!(((buf_ptr == NULL) && (buf_len == 0)) || ((buf_ptr != NULL) && (buf_len > 0))))
2602 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "inconsistent buf_ptr and buf_len")
2603
2604 /* Get the plist structure */
2605 if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
2606 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2607
2608 /* Get old image info */
2609 if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0)
2610 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image pointer")
2611
2612 /* Release previous buffer, if it exists */
2613 if (image_info.buffer != NULL) {
2614 if (image_info.callbacks.image_free) {
2615 if (SUCCEED != image_info.callbacks.image_free(image_info.buffer,
2616 H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET,
2617 image_info.callbacks.udata))
2618 HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed")
2619 } /* end if */
2620 else
2621 H5MM_xfree(image_info.buffer);
2622 } /* end if */
2623
2624 /* Update struct */
2625 if (buf_ptr) {
2626 /* Allocate memory */
2627 if (image_info.callbacks.image_malloc) {
2628 if (NULL == (image_info.buffer = image_info.callbacks.image_malloc(
2629 buf_len, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET, image_info.callbacks.udata)))
2630 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "image malloc callback failed")
2631 } /* end if */
2632 else if (NULL == (image_info.buffer = H5MM_malloc(buf_len)))
2633 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block")
2634
2635 /* Copy data */
2636 if (image_info.callbacks.image_memcpy) {
2637 if (image_info.buffer != image_info.callbacks.image_memcpy(image_info.buffer, buf_ptr, buf_len,
2638 H5FD_FILE_IMAGE_OP_PROPERTY_LIST_SET,
2639 image_info.callbacks.udata))
2640 HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed")
2641 } /* end if */
2642 else
2643 H5MM_memcpy(image_info.buffer, buf_ptr, buf_len);
2644 } /* end if */
2645 else
2646 image_info.buffer = NULL;
2647
2648 image_info.size = buf_len;
2649
2650 /* Set values */
2651 if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0)
2652 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info")
2653
2654 done:
2655 FUNC_LEAVE_API(ret_value)
2656 } /* end H5Pset_file_image() */
2657
2658 /*-------------------------------------------------------------------------
2659 * Function: H5Pget_file_image
2660 *
2661 * Purpose: If the file image exists and buf is not NULL,
2662 * allocate a buffer of the correct size, copy the image into
2663 * the new buffer, and return the buffer to the caller in
2664 * *buf. Do this using the file image callbacks
2665 * if defined.
2666 *
2667 * NB: It is the responsibility of the caller to free the
2668 * buffer whose address is returned in *buf. Do
2669 * this using free if the file image callbacks are not
2670 * defined, or with whatever method is appropriate if
2671 * the callbacks are defined.
2672 *
2673 * If buf is not NULL, and no image exists, set
2674 * *buf to NULL.
2675 *
2676 * If buf_len is not NULL, set *buf_len equal
2677 * to the length of the file image if it exists, and
2678 * to 0 if it does not.
2679 *
2680 * Return: Non-negative on success/Negative on failure
2681 *
2682 * Programmer: Jacob Gruber
2683 * Thurday, August 11, 2011
2684 *
2685 *-------------------------------------------------------------------------
2686 */
2687 herr_t
H5Pget_file_image(hid_t fapl_id,void ** buf,size_t * buf_len)2688 H5Pget_file_image(hid_t fapl_id, void **buf, size_t *buf_len)
2689 {
2690 H5P_genplist_t * fapl; /* Property list pointer */
2691 H5FD_file_image_info_t image_info; /* File image info */
2692 herr_t ret_value = SUCCEED; /* Return value */
2693
2694 FUNC_ENTER_API(FAIL)
2695 H5TRACE3("e", "i**x*z", fapl_id, buf, buf_len);
2696
2697 /* Get the plist structure */
2698 if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
2699 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2700
2701 /* Get values */
2702 if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0)
2703 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info")
2704
2705 /* verify file image field consistency */
2706 HDassert(((image_info.buffer != NULL) && (image_info.size > 0)) ||
2707 ((image_info.buffer == NULL) && (image_info.size == 0)));
2708
2709 /* Set output size */
2710 if (buf_len != NULL)
2711 *buf_len = image_info.size;
2712
2713 /* Duplicate the image if desired, using callbacks if available */
2714 if (buf != NULL) {
2715 void *copy_ptr = NULL; /* Copy of memory image */
2716
2717 if (image_info.buffer != NULL) {
2718 /* Allocate memory */
2719 if (image_info.callbacks.image_malloc) {
2720 if (NULL ==
2721 (copy_ptr = image_info.callbacks.image_malloc(
2722 image_info.size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata)))
2723 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "image malloc callback failed")
2724 } /* end if */
2725 else if (NULL == (copy_ptr = H5MM_malloc(image_info.size)))
2726 HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate copy")
2727
2728 /* Copy data */
2729 if (image_info.callbacks.image_memcpy) {
2730 if (copy_ptr != image_info.callbacks.image_memcpy(
2731 copy_ptr, image_info.buffer, image_info.size,
2732 H5FD_FILE_IMAGE_OP_PROPERTY_LIST_GET, image_info.callbacks.udata))
2733 HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed")
2734 } /* end if */
2735 else
2736 H5MM_memcpy(copy_ptr, image_info.buffer, image_info.size);
2737 } /* end if */
2738
2739 *buf = copy_ptr;
2740 } /* end if */
2741
2742 done:
2743 FUNC_LEAVE_API(ret_value)
2744 } /* end H5Pget_file_image */
2745
2746 /*-------------------------------------------------------------------------
2747 * Function: H5Pset_file_image_callbacks
2748 *
2749 * Purpose: Sets the callbacks for file images. Some file drivers allow
2750 * the use of user-defined callbacks for allocating, freeing and
2751 * copying the drivers internal buffer, potentially allowing a
2752 * clever user to do optimizations such as avoiding large mallocs
2753 * and memcpys or to perform detailed logging.
2754 *
2755 * Return: Non-negative on success/Negative on failure
2756 *
2757 * Programmer: Jacob Gruber
2758 * Thurday, August 11, 2011
2759 *
2760 *-------------------------------------------------------------------------
2761 */
2762 herr_t
H5Pset_file_image_callbacks(hid_t fapl_id,H5FD_file_image_callbacks_t * callbacks_ptr)2763 H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr)
2764 {
2765 H5P_genplist_t * fapl; /* Property list pointer */
2766 H5FD_file_image_info_t info; /* File image info */
2767 herr_t ret_value = SUCCEED; /* Return value */
2768
2769 FUNC_ENTER_API(FAIL)
2770 H5TRACE2("e", "i*x", fapl_id, callbacks_ptr);
2771
2772 /* Get the plist structure */
2773 if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
2774 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2775
2776 /* Get old info */
2777 if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0)
2778 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image info")
2779
2780 /* verify file image field consistency */
2781 HDassert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0)));
2782
2783 /* Make sure a file image hasn't already been set */
2784 if (info.buffer != NULL || info.size > 0)
2785 HGOTO_ERROR(
2786 H5E_PLIST, H5E_SETDISALLOWED, FAIL,
2787 "setting callbacks when an image is already set is forbidden. It could cause memory leaks.")
2788
2789 /* verify that callbacks_ptr is not NULL */
2790 if (NULL == callbacks_ptr)
2791 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks_ptr")
2792
2793 /* Make sure udata callbacks are going to be set if udata is going to be set */
2794 if (callbacks_ptr->udata)
2795 if (callbacks_ptr->udata_copy == NULL || callbacks_ptr->udata_free == NULL)
2796 HGOTO_ERROR(H5E_PLIST, H5E_SETDISALLOWED, FAIL, "udata callbacks must be set if udata is set")
2797
2798 /* Release old udata if it exists */
2799 if (info.callbacks.udata != NULL) {
2800 HDassert(info.callbacks.udata_free);
2801 if (info.callbacks.udata_free(info.callbacks.udata) < 0)
2802 HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed")
2803 } /* end if */
2804
2805 /* Update struct */
2806 info.callbacks = *callbacks_ptr;
2807
2808 if (callbacks_ptr->udata) {
2809 HDassert(callbacks_ptr->udata_copy);
2810 HDassert(callbacks_ptr->udata_free);
2811 if ((info.callbacks.udata = callbacks_ptr->udata_copy(callbacks_ptr->udata)) == NULL)
2812 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy the suppplied udata")
2813 } /* end if */
2814
2815 /* Set values */
2816 if (H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0)
2817 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info")
2818
2819 done:
2820 FUNC_LEAVE_API(ret_value)
2821 } /* end H5Pset_file_image_callbacks() */
2822
2823 /*-------------------------------------------------------------------------
2824 * Function: H5Pget_file_image_callbacks
2825 *
2826 * Purpose: Sets the callbacks for file images. Some file drivers allow
2827 * the use of user-defined callbacks for allocating, freeing and
2828 * copying the drivers internal buffer, potentially allowing a
2829 * clever user to do optimizations such as avoiding large mallocs
2830 *
2831 * Return: Non-negative on success/Negative on failure
2832 *
2833 * Programmer: Jacob Gruber
2834 * Thurday, August 11, 2011
2835 *
2836 *-------------------------------------------------------------------------
2837 */
2838 herr_t
H5Pget_file_image_callbacks(hid_t fapl_id,H5FD_file_image_callbacks_t * callbacks)2839 H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks)
2840 {
2841 H5P_genplist_t * fapl; /* Property list pointer */
2842 H5FD_file_image_info_t info; /* File image info */
2843 herr_t ret_value = SUCCEED; /* Return value */
2844
2845 FUNC_ENTER_API(FAIL)
2846 H5TRACE2("e", "i*x", fapl_id, callbacks);
2847
2848 /* Get the plist structure */
2849 if (NULL == (fapl = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
2850 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
2851
2852 /* Get old info */
2853 if (H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0)
2854 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info")
2855
2856 /* verify file image field consistency */
2857 HDassert(((info.buffer != NULL) && (info.size > 0)) || ((info.buffer == NULL) && (info.size == 0)));
2858
2859 /* verify that callbacks is not NULL */
2860 if (NULL == callbacks)
2861 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL callbacks ptr")
2862
2863 /* Transfer values to parameters */
2864 *callbacks = info.callbacks;
2865
2866 /* Copy udata if it exists */
2867 if (info.callbacks.udata != NULL) {
2868 HDassert(info.callbacks.udata_copy);
2869 if ((callbacks->udata = info.callbacks.udata_copy(info.callbacks.udata)) == 0)
2870 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy udata")
2871 } /* end if */
2872
2873 done:
2874 FUNC_LEAVE_API(ret_value)
2875 } /* end H5Pget_file_image_callbacks() */
2876
2877 /*-------------------------------------------------------------------------
2878 * Function: H5P__file_image_info_copy
2879 *
2880 * Purpose: Copy file image info. The buffer
2881 * and udata may need to be copied, possibly using their
2882 * respective callbacks so the default copy won't work.
2883 *
2884 * Note: This is an "in-place" copy, since this routine gets called
2885 * after the top-level copy has been performed and this routine
2886 * finishes the "deep" part of the copy.
2887 *
2888 * Return: Success: Non-negative
2889 * Failure: Negative
2890 *
2891 * Programmer: Quincey Koziol
2892 * Tuesday, Sept 1, 2015
2893 *
2894 *-------------------------------------------------------------------------
2895 */
2896 static herr_t
H5P__file_image_info_copy(void * value)2897 H5P__file_image_info_copy(void *value)
2898 {
2899 herr_t ret_value = SUCCEED; /* Return value */
2900
2901 FUNC_ENTER_STATIC
2902
2903 if (value) {
2904 H5FD_file_image_info_t *info; /* Image info struct */
2905
2906 info = (H5FD_file_image_info_t *)value;
2907
2908 /* verify file image field consistency */
2909 HDassert(((info->buffer != NULL) && (info->size > 0)) ||
2910 ((info->buffer == NULL) && (info->size == 0)));
2911
2912 if (info->buffer && info->size > 0) {
2913 void *old_buffer; /* Pointer to old image buffer */
2914
2915 /* Store the old buffer */
2916 old_buffer = info->buffer;
2917
2918 /* Allocate new buffer */
2919 if (info->callbacks.image_malloc) {
2920 if (NULL == (info->buffer = info->callbacks.image_malloc(
2921 info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata)))
2922 HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "image malloc callback failed")
2923 } /* end if */
2924 else {
2925 if (NULL == (info->buffer = H5MM_malloc(info->size)))
2926 HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory block")
2927 } /* end else */
2928
2929 /* Copy data to new buffer */
2930 if (info->callbacks.image_memcpy) {
2931 if (info->buffer != info->callbacks.image_memcpy(info->buffer, old_buffer, info->size,
2932 H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY,
2933 info->callbacks.udata))
2934 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed")
2935 } /* end if */
2936 else
2937 H5MM_memcpy(info->buffer, old_buffer, info->size);
2938 } /* end if */
2939
2940 /* Copy udata if it exists */
2941 if (info->callbacks.udata) {
2942 void *old_udata = info->callbacks.udata;
2943
2944 if (NULL == info->callbacks.udata_copy)
2945 HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_copy not defined")
2946
2947 info->callbacks.udata = info->callbacks.udata_copy(old_udata);
2948 } /* end if */
2949 } /* end if */
2950
2951 done:
2952 FUNC_LEAVE_NOAPI(ret_value)
2953 } /* end H5P__file_image_info_copy() */
2954
2955 /*-------------------------------------------------------------------------
2956 * Function: H5P__file_image_info_free
2957 *
2958 * Purpose: Free file image info. The buffer and udata may need to be
2959 * freed, possibly using their respective callbacks, so the
2960 * default free won't work.
2961 *
2962 * Return: Success: Non-negative
2963 * Failure: Negative
2964 *
2965 * Programmer: Quincey Koziol
2966 * Wednesday, Sept 2, 2015
2967 *
2968 *-------------------------------------------------------------------------
2969 */
2970 static herr_t
H5P__file_image_info_free(void * value)2971 H5P__file_image_info_free(void *value)
2972 {
2973 herr_t ret_value = SUCCEED; /* Return value */
2974
2975 FUNC_ENTER_STATIC
2976
2977 if (value) {
2978 H5FD_file_image_info_t *info; /* Image info struct */
2979
2980 info = (H5FD_file_image_info_t *)value;
2981
2982 /* Verify file image field consistency */
2983 HDassert(((info->buffer != NULL) && (info->size > 0)) ||
2984 ((info->buffer == NULL) && (info->size == 0)));
2985
2986 /* Free buffer */
2987 if (info->buffer != NULL && info->size > 0) {
2988 if (info->callbacks.image_free) {
2989 if ((*info->callbacks.image_free)(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE,
2990 info->callbacks.udata) < 0)
2991 HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed")
2992 } /* end if */
2993 else
2994 H5MM_xfree(info->buffer);
2995 } /* end if */
2996
2997 /* Free udata if it exists */
2998 if (info->callbacks.udata) {
2999 if (NULL == info->callbacks.udata_free)
3000 HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_free not defined")
3001 if ((*info->callbacks.udata_free)(info->callbacks.udata) < 0)
3002 HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "udata_free callback failed")
3003 } /* end if */
3004 } /* end if */
3005
3006 done:
3007 FUNC_LEAVE_NOAPI(ret_value)
3008 } /* end H5P__file_image_info_free() */
3009
3010 /*-------------------------------------------------------------------------
3011 * Function: H5P__facc_cache_image_config_cmp
3012 *
3013 * Purpose: Compare two cache image configurations.
3014 *
3015 * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
3016 * greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
3017 *
3018 * Programmer: John Mainzer
3019 * June 26, 2015
3020 *
3021 *-------------------------------------------------------------------------
3022 */
3023 static int
H5P__facc_cache_image_config_cmp(const void * _config1,const void * _config2,size_t H5_ATTR_UNUSED size)3024 H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size)
3025 {
3026 const H5AC_cache_image_config_t *config1 =
3027 (const H5AC_cache_image_config_t *)_config1; /* Create local aliases for values */
3028 const H5AC_cache_image_config_t *config2 =
3029 (const H5AC_cache_image_config_t *)_config2; /* Create local aliases for values */
3030 int ret_value = 0; /* Return value */
3031
3032 FUNC_ENTER_STATIC_NOERR
3033
3034 /* Check for a property being set */
3035 if (config1 == NULL && config2 != NULL)
3036 HGOTO_DONE(-1);
3037 if (config1 != NULL && config2 == NULL)
3038 HGOTO_DONE(1);
3039
3040 if (config1->version < config2->version)
3041 HGOTO_DONE(-1);
3042 if (config1->version > config2->version)
3043 HGOTO_DONE(1);
3044
3045 if (config1->generate_image < config2->generate_image)
3046 HGOTO_DONE(-1);
3047 if (config1->generate_image > config2->generate_image)
3048 HGOTO_DONE(1);
3049
3050 if (config1->save_resize_status < config2->save_resize_status)
3051 HGOTO_DONE(-1);
3052 if (config1->save_resize_status > config2->save_resize_status)
3053 HGOTO_DONE(1);
3054
3055 if (config1->entry_ageout < config2->entry_ageout)
3056 HGOTO_DONE(-1);
3057 if (config1->entry_ageout > config2->entry_ageout)
3058 HGOTO_DONE(1);
3059
3060 done:
3061 FUNC_LEAVE_NOAPI(ret_value)
3062 } /* end H5P__facc_cache_image_config_cmp() */
3063
3064 /*-------------------------------------------------------------------------
3065 * Function: H5P__facc_cache_image_config_enc
3066 *
3067 * Purpose: Callback routine which is called whenever the default
3068 * cache image config property in the file creation
3069 * property list is encoded.
3070 *
3071 * Return: Success: Non-negative
3072 * Failure: Negative
3073 *
3074 * Programmer: John Mainzer
3075 * June 26, 2015
3076 *
3077 *-------------------------------------------------------------------------
3078 */
3079 static herr_t
H5P__facc_cache_image_config_enc(const void * value,void ** _pp,size_t * size)3080 H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size)
3081 {
3082 const H5AC_cache_image_config_t *config =
3083 (const H5AC_cache_image_config_t *)value; /* Create local aliases for value */
3084 uint8_t **pp = (uint8_t **)_pp;
3085
3086 FUNC_ENTER_STATIC_NOERR
3087
3088 /* Sanity check */
3089 HDassert(value);
3090
3091 if (NULL != *pp) {
3092 /* Encode type sizes (as a safety check) */
3093 *(*pp)++ = (uint8_t)sizeof(unsigned);
3094
3095 INT32ENCODE(*pp, (int32_t)config->version);
3096
3097 H5_ENCODE_UNSIGNED(*pp, config->generate_image);
3098
3099 H5_ENCODE_UNSIGNED(*pp, config->save_resize_status);
3100
3101 INT32ENCODE(*pp, (int32_t)config->entry_ageout);
3102 } /* end if */
3103
3104 /* Compute encoded size of fixed-size values */
3105 *size += (1 + (2 * sizeof(unsigned)) + (2 * sizeof(int32_t)));
3106
3107 FUNC_LEAVE_NOAPI(SUCCEED)
3108 } /* end H5P__facc_cache_image_config_enc() */
3109
3110 /*-------------------------------------------------------------------------
3111 * Function: H5P__facc_cache_image_config_dec
3112 *
3113 * Purpose: Callback routine which is called whenever the default
3114 * cache image config property in the file creation property
3115 * list is decoded.
3116 *
3117 * Return: Success: Non-negative
3118 * Failure: Negative
3119 *
3120 * Programmer: John Mainzer
3121 * June 26, 2015
3122 *
3123 *-------------------------------------------------------------------------
3124 */
3125 static herr_t
H5P__facc_cache_image_config_dec(const void ** _pp,void * _value)3126 H5P__facc_cache_image_config_dec(const void **_pp, void *_value)
3127 {
3128 H5AC_cache_image_config_t *config = (H5AC_cache_image_config_t *)_value;
3129 const uint8_t ** pp = (const uint8_t **)_pp;
3130 unsigned enc_size;
3131 herr_t ret_value = SUCCEED; /* Return value */
3132
3133 FUNC_ENTER_STATIC
3134
3135 /* Sanity checks */
3136 HDassert(pp);
3137 HDassert(*pp);
3138 HDassert(config);
3139 HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
3140
3141 /* Set property to default value */
3142 H5MM_memcpy(config, &H5F_def_mdc_initCacheImageCfg_g, sizeof(H5AC_cache_image_config_t));
3143
3144 /* Decode type sizes */
3145 enc_size = *(*pp)++;
3146 if (enc_size != sizeof(unsigned))
3147 HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded")
3148
3149 INT32DECODE(*pp, config->version);
3150
3151 H5_DECODE_UNSIGNED(*pp, config->generate_image);
3152
3153 H5_DECODE_UNSIGNED(*pp, config->save_resize_status);
3154
3155 INT32DECODE(*pp, config->entry_ageout);
3156
3157 done:
3158 FUNC_LEAVE_NOAPI(ret_value)
3159 } /* end H5P__facc_cache_image_config_dec() */
3160
3161 /*-------------------------------------------------------------------------
3162 * Function: H5P__facc_file_image_info_set
3163 *
3164 * Purpose: Copies a file image property when it's set for a property list
3165 *
3166 * Return: Success: Non-negative
3167 * Failure: Negative
3168 *
3169 * Programmer: Quincey Koziol
3170 * Tuesday, Sept 1, 2015
3171 *
3172 *-------------------------------------------------------------------------
3173 */
3174 static herr_t
H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)3175 H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
3176 size_t H5_ATTR_UNUSED size, void *value)
3177 {
3178 herr_t ret_value = SUCCEED; /* Return value */
3179
3180 FUNC_ENTER_STATIC
3181
3182 /* Sanity check */
3183 HDassert(value);
3184
3185 /* Make copy of file image info */
3186 if (H5P__file_image_info_copy(value) < 0)
3187 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info")
3188
3189 done:
3190 FUNC_LEAVE_NOAPI(ret_value)
3191 } /* end H5P__facc_file_image_info_set() */
3192
3193 /*-------------------------------------------------------------------------
3194 * Function: H5P__facc_file_image_info_get
3195 *
3196 * Purpose: Copies a file image property when it's retrieved from a property list
3197 *
3198 * Return: Success: Non-negative
3199 * Failure: Negative
3200 *
3201 * Programmer: Quincey Koziol
3202 * Tuesday, Sept 1, 2015
3203 *
3204 *-------------------------------------------------------------------------
3205 */
3206 static herr_t
H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)3207 H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
3208 size_t H5_ATTR_UNUSED size, void *value)
3209 {
3210 herr_t ret_value = SUCCEED; /* Return value */
3211
3212 FUNC_ENTER_STATIC
3213
3214 /* Sanity check */
3215 HDassert(value);
3216
3217 /* Make copy of file image info */
3218 if (H5P__file_image_info_copy(value) < 0)
3219 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info")
3220
3221 done:
3222 FUNC_LEAVE_NOAPI(ret_value)
3223 } /* end H5P__facc_file_image_info_get() */
3224
3225 /*-------------------------------------------------------------------------
3226 * Function: H5P__facc_file_image_info_del
3227 *
3228 * Purpose: Delete callback for the file image info property, called
3229 * when the property is deleted from the plist. The buffer
3230 * and udata may need to be freed, possibly using their
3231 * respective callbacks so the default free won't work.
3232 *
3233 * Return: Non-negative on success/Negative on failure
3234 *
3235 * Programmer: Jacob Gruber
3236 * Thurday, August 11, 2011
3237 *
3238 *-------------------------------------------------------------------------
3239 */
3240 static herr_t
H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)3241 H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
3242 size_t H5_ATTR_UNUSED size, void *value)
3243 {
3244 herr_t ret_value = SUCCEED; /* Return value */
3245
3246 FUNC_ENTER_STATIC
3247
3248 /* Free the file image info */
3249 if (H5P__file_image_info_free(value) < 0)
3250 HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info")
3251
3252 done:
3253 FUNC_LEAVE_NOAPI(ret_value)
3254 } /* end H5P__facc_file_image_info_del() */
3255
3256 /*-------------------------------------------------------------------------
3257 * Function: H5P__facc_file_image_info_copy
3258 *
3259 * Purpose: Copy callback for the file image info property. The buffer
3260 * and udata may need to be copied, possibly using their
3261 * respective callbacks so the default copy won't work.
3262 *
3263 * Return: Non-negative on success/Negative on failure
3264 *
3265 * Programmer: Jacob Gruber
3266 * Thurday, August 11, 2011
3267 *
3268 *-------------------------------------------------------------------------
3269 */
3270 static herr_t
H5P__facc_file_image_info_copy(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)3271 H5P__facc_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
3272 {
3273 herr_t ret_value = SUCCEED; /* Return value */
3274
3275 FUNC_ENTER_STATIC
3276
3277 /* Make copy of file image info */
3278 if (H5P__file_image_info_copy(value) < 0)
3279 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info")
3280
3281 done:
3282 FUNC_LEAVE_NOAPI(ret_value)
3283 } /* end H5P__facc_file_image_info_copy() */
3284
3285 /*-------------------------------------------------------------------------
3286 * Function: H5P__facc_file_image_info_cmp
3287 *
3288 * Purpose: Callback routine which is called whenever the file image info
3289 * property in the file access property list is compared.
3290 *
3291 * Return: positive if VALUE1 is greater than VALUE2, negative if
3292 * VALUE2 is greater than VALUE1 and zero if VALUE1 and
3293 * VALUE2 are equal.
3294 *
3295 * Programmer: Quincey Koziol
3296 * Thursday, September 3, 2015
3297 *
3298 *-------------------------------------------------------------------------
3299 */
3300 static int
H5P__facc_file_image_info_cmp(const void * _info1,const void * _info2,size_t H5_ATTR_UNUSED size)3301 H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size)
3302 {
3303 const H5FD_file_image_info_t *info1 = (const H5FD_file_image_info_t *)
3304 _info1, /* Create local aliases for values */
3305 *info2 = (const H5FD_file_image_info_t *)_info2;
3306 herr_t ret_value = 0; /* Return value */
3307
3308 FUNC_ENTER_STATIC_NOERR
3309
3310 /* Sanity check */
3311 HDassert(info1);
3312 HDassert(info2);
3313 HDassert(size == sizeof(H5FD_file_image_info_t));
3314
3315 /* Check for different buffer sizes */
3316 if (info1->size < info2->size)
3317 HGOTO_DONE(-1)
3318 if (info1->size > info2->size)
3319 HGOTO_DONE(1)
3320
3321 /* Check for different callbacks */
3322 /* (Order in memory is fairly meaningless, so just check for equality) */
3323 if (info1->callbacks.image_malloc != info2->callbacks.image_malloc)
3324 HGOTO_DONE(1)
3325 if (info1->callbacks.image_memcpy != info2->callbacks.image_memcpy)
3326 HGOTO_DONE(-1)
3327 if (info1->callbacks.image_realloc != info2->callbacks.image_realloc)
3328 HGOTO_DONE(1)
3329 if (info1->callbacks.image_free != info2->callbacks.image_free)
3330 HGOTO_DONE(-1)
3331 if (info1->callbacks.udata_copy != info2->callbacks.udata_copy)
3332 HGOTO_DONE(1)
3333 if (info1->callbacks.udata_free != info2->callbacks.udata_free)
3334 HGOTO_DONE(-1)
3335
3336 /* Check for different udata */
3337 /* (Don't know how big it is, so can't check contents) */
3338 if (info1->callbacks.udata < info2->callbacks.udata)
3339 HGOTO_DONE(-1)
3340 if (info1->callbacks.udata > info2->callbacks.udata)
3341 HGOTO_DONE(1)
3342
3343 /* Check buffer contents (instead of buffer pointers) */
3344 if (info1->buffer != NULL && info2->buffer == NULL)
3345 HGOTO_DONE(-1)
3346 if (info1->buffer == NULL && info2->buffer != NULL)
3347 HGOTO_DONE(1)
3348 if (info1->buffer != NULL && info2->buffer != NULL)
3349 ret_value = HDmemcmp(info1->buffer, info2->buffer, size);
3350
3351 done:
3352 FUNC_LEAVE_NOAPI(ret_value)
3353 } /* end H5P__facc_file_image_info_cmp() */
3354
3355 /*-------------------------------------------------------------------------
3356 * Function: H5P__facc_file_image_info_close
3357 *
3358 * Purpose: Close callback for the file image info property. The buffer
3359 * and udata may need to be freed, possibly using their
3360 * respective callbacks so the standard free won't work.
3361 *
3362 * Return: Non-negative on success/Negative on failure
3363 *
3364 * Programmer: Jacob Gruber
3365 * Thurday, August 11, 2011
3366 *
3367 *-------------------------------------------------------------------------
3368 */
3369 static herr_t
H5P__facc_file_image_info_close(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)3370 H5P__facc_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
3371 {
3372 herr_t ret_value = SUCCEED; /* Return value */
3373
3374 FUNC_ENTER_STATIC
3375
3376 /* Free the file image info */
3377 if (H5P__file_image_info_free(value) < 0)
3378 HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info")
3379
3380 done:
3381 FUNC_LEAVE_NOAPI(ret_value)
3382 } /* end H5P__facc_file_image_info_close() */
3383
3384 /*-------------------------------------------------------------------------
3385 * Function: H5P__facc_cache_config_cmp
3386 *
3387 * Purpose: Compare two cache configurations.
3388 *
3389 * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
3390 * greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
3391 *
3392 * Programmer: Mohamad Chaarawi
3393 * September 24, 2012
3394 *
3395 *-------------------------------------------------------------------------
3396 */
3397 static int
H5P__facc_cache_config_cmp(const void * _config1,const void * _config2,size_t H5_ATTR_UNUSED size)3398 H5P__facc_cache_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size)
3399 {
3400 const H5AC_cache_config_t *config1 =
3401 (const H5AC_cache_config_t *)_config1; /* Create local aliases for values */
3402 const H5AC_cache_config_t *config2 =
3403 (const H5AC_cache_config_t *)_config2; /* Create local aliases for values */
3404 int ret_value = 0; /* Return value */
3405
3406 FUNC_ENTER_STATIC_NOERR
3407
3408 /* Check for a property being set */
3409 if (config1 == NULL && config2 != NULL)
3410 HGOTO_DONE(-1);
3411 if (config1 != NULL && config2 == NULL)
3412 HGOTO_DONE(1);
3413
3414 if (config1->version < config2->version)
3415 HGOTO_DONE(-1);
3416 if (config1->version > config2->version)
3417 HGOTO_DONE(1);
3418
3419 if (config1->rpt_fcn_enabled < config2->rpt_fcn_enabled)
3420 HGOTO_DONE(-1);
3421 if (config1->rpt_fcn_enabled > config2->rpt_fcn_enabled)
3422 HGOTO_DONE(1);
3423
3424 if (config1->evictions_enabled < config2->evictions_enabled)
3425 HGOTO_DONE(-1);
3426 if (config1->evictions_enabled > config2->evictions_enabled)
3427 HGOTO_DONE(1);
3428
3429 if (config1->set_initial_size < config2->set_initial_size)
3430 HGOTO_DONE(-1);
3431 if (config1->set_initial_size > config2->set_initial_size)
3432 HGOTO_DONE(1);
3433
3434 if (config1->initial_size < config2->initial_size)
3435 HGOTO_DONE(-1);
3436 if (config1->initial_size > config2->initial_size)
3437 HGOTO_DONE(1);
3438
3439 if (config1->min_clean_fraction < config2->min_clean_fraction)
3440 HGOTO_DONE(-1);
3441 if (config1->min_clean_fraction > config2->min_clean_fraction)
3442 HGOTO_DONE(1);
3443
3444 if (config1->max_size < config2->max_size)
3445 HGOTO_DONE(-1);
3446 if (config1->max_size > config2->max_size)
3447 HGOTO_DONE(1);
3448
3449 if (config1->min_size < config2->min_size)
3450 HGOTO_DONE(-1);
3451 if (config1->min_size > config2->min_size)
3452 HGOTO_DONE(1);
3453
3454 if (config1->epoch_length < config2->epoch_length)
3455 HGOTO_DONE(-1);
3456 if (config1->epoch_length > config2->epoch_length)
3457 HGOTO_DONE(1);
3458
3459 if (config1->incr_mode < config2->incr_mode)
3460 HGOTO_DONE(-1);
3461 if (config1->incr_mode > config2->incr_mode)
3462 HGOTO_DONE(1);
3463
3464 if (config1->lower_hr_threshold < config2->lower_hr_threshold)
3465 HGOTO_DONE(-1);
3466 if (config1->lower_hr_threshold > config2->lower_hr_threshold)
3467 HGOTO_DONE(1);
3468
3469 if (config1->increment < config2->increment)
3470 HGOTO_DONE(-1);
3471 if (config1->increment > config2->increment)
3472 HGOTO_DONE(1);
3473
3474 if (config1->apply_max_increment < config2->apply_max_increment)
3475 HGOTO_DONE(-1);
3476 if (config1->apply_max_increment > config2->apply_max_increment)
3477 HGOTO_DONE(1);
3478
3479 if (config1->max_increment < config2->max_increment)
3480 HGOTO_DONE(-1);
3481 if (config1->max_increment > config2->max_increment)
3482 HGOTO_DONE(1);
3483
3484 if (config1->flash_incr_mode < config2->flash_incr_mode)
3485 HGOTO_DONE(-1);
3486 if (config1->flash_incr_mode > config2->flash_incr_mode)
3487 HGOTO_DONE(1);
3488
3489 if (config1->flash_multiple < config2->flash_multiple)
3490 HGOTO_DONE(-1);
3491 if (config1->flash_multiple > config2->flash_multiple)
3492 HGOTO_DONE(1);
3493
3494 if (config1->flash_threshold < config2->flash_threshold)
3495 HGOTO_DONE(-1);
3496 if (config1->flash_threshold > config2->flash_threshold)
3497 HGOTO_DONE(1);
3498
3499 if (config1->decr_mode < config2->decr_mode)
3500 HGOTO_DONE(-1);
3501 if (config1->decr_mode > config2->decr_mode)
3502 HGOTO_DONE(1);
3503
3504 if (config1->upper_hr_threshold < config2->upper_hr_threshold)
3505 HGOTO_DONE(-1);
3506 if (config1->upper_hr_threshold > config2->upper_hr_threshold)
3507 HGOTO_DONE(1);
3508
3509 if (config1->decrement < config2->decrement)
3510 HGOTO_DONE(-1);
3511 if (config1->decrement > config2->decrement)
3512 HGOTO_DONE(1);
3513
3514 if (config1->apply_max_decrement < config2->apply_max_decrement)
3515 HGOTO_DONE(-1);
3516 if (config1->apply_max_decrement > config2->apply_max_decrement)
3517 HGOTO_DONE(1);
3518
3519 if (config1->max_decrement < config2->max_decrement)
3520 HGOTO_DONE(-1);
3521 if (config1->max_decrement > config2->max_decrement)
3522 HGOTO_DONE(1);
3523
3524 if (config1->epochs_before_eviction < config2->epochs_before_eviction)
3525 HGOTO_DONE(-1);
3526 if (config1->epochs_before_eviction > config2->epochs_before_eviction)
3527 HGOTO_DONE(1);
3528
3529 if (config1->apply_empty_reserve < config2->apply_empty_reserve)
3530 HGOTO_DONE(-1);
3531 if (config1->apply_empty_reserve > config2->apply_empty_reserve)
3532 HGOTO_DONE(1);
3533
3534 if (config1->empty_reserve < config2->empty_reserve)
3535 HGOTO_DONE(-1);
3536 if (config1->empty_reserve > config2->empty_reserve)
3537 HGOTO_DONE(1);
3538
3539 if (config1->dirty_bytes_threshold < config2->dirty_bytes_threshold)
3540 HGOTO_DONE(-1);
3541 if (config1->dirty_bytes_threshold > config2->dirty_bytes_threshold)
3542 HGOTO_DONE(1);
3543
3544 if (config1->metadata_write_strategy < config2->metadata_write_strategy)
3545 HGOTO_DONE(-1);
3546 if (config1->metadata_write_strategy > config2->metadata_write_strategy)
3547 HGOTO_DONE(1);
3548
3549 done:
3550 FUNC_LEAVE_NOAPI(ret_value)
3551 } /* end H5P__facc_cache_config_cmp() */
3552
3553 /*-------------------------------------------------------------------------
3554 * Function: H5P__facc_cache_config_enc
3555 *
3556 * Purpose: Callback routine which is called whenever the default
3557 * cache config property in the file creation property list is
3558 * encoded.
3559 *
3560 * Return: Success: Non-negative
3561 * Failure: Negative
3562 *
3563 * Programmer: Mohamad Chaarawi
3564 * August 09, 2012
3565 *
3566 *-------------------------------------------------------------------------
3567 */
3568 static herr_t
H5P__facc_cache_config_enc(const void * value,void ** _pp,size_t * size)3569 H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size)
3570 {
3571 const H5AC_cache_config_t *config =
3572 (const H5AC_cache_config_t *)value; /* Create local aliases for values */
3573 uint8_t **pp = (uint8_t **)_pp;
3574 unsigned enc_size; /* Size of encoded property */
3575 uint64_t enc_value; /* Property to encode */
3576
3577 FUNC_ENTER_STATIC_NOERR
3578
3579 /* Sanity check */
3580 HDassert(value);
3581 HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
3582
3583 if (NULL != *pp) {
3584 /* Encode type sizes (as a safety check) */
3585 *(*pp)++ = (uint8_t)sizeof(unsigned);
3586 *(*pp)++ = (uint8_t)sizeof(double);
3587
3588 /* int */
3589 INT32ENCODE(*pp, (int32_t)config->version);
3590
3591 H5_ENCODE_UNSIGNED(*pp, config->rpt_fcn_enabled);
3592
3593 H5_ENCODE_UNSIGNED(*pp, config->open_trace_file);
3594
3595 H5_ENCODE_UNSIGNED(*pp, config->close_trace_file);
3596
3597 H5MM_memcpy(*pp, (const uint8_t *)(config->trace_file_name),
3598 (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1));
3599 *pp += H5AC__MAX_TRACE_FILE_NAME_LEN + 1;
3600
3601 H5_ENCODE_UNSIGNED(*pp, config->evictions_enabled);
3602
3603 H5_ENCODE_UNSIGNED(*pp, config->set_initial_size);
3604
3605 enc_value = (uint64_t)config->initial_size;
3606 enc_size = H5VM_limit_enc_size(enc_value);
3607 HDassert(enc_size < 256);
3608 *(*pp)++ = (uint8_t)enc_size;
3609 UINT64ENCODE_VAR(*pp, enc_value, enc_size);
3610
3611 H5_ENCODE_DOUBLE(*pp, config->min_clean_fraction);
3612
3613 enc_value = (uint64_t)config->max_size;
3614 enc_size = H5VM_limit_enc_size(enc_value);
3615 HDassert(enc_size < 256);
3616 *(*pp)++ = (uint8_t)enc_size;
3617 UINT64ENCODE_VAR(*pp, enc_value, enc_size);
3618
3619 enc_value = (uint64_t)config->min_size;
3620 enc_size = H5VM_limit_enc_size(enc_value);
3621 HDassert(enc_size < 256);
3622 *(*pp)++ = (uint8_t)enc_size;
3623 UINT64ENCODE_VAR(*pp, enc_value, enc_size);
3624
3625 /* long int */
3626 INT64ENCODE(*pp, (int64_t)config->epoch_length);
3627
3628 /* enum */
3629 *(*pp)++ = (uint8_t)config->incr_mode;
3630
3631 H5_ENCODE_DOUBLE(*pp, config->lower_hr_threshold);
3632
3633 H5_ENCODE_DOUBLE(*pp, config->increment);
3634
3635 H5_ENCODE_UNSIGNED(*pp, config->apply_max_increment);
3636
3637 enc_value = (uint64_t)config->max_increment;
3638 enc_size = H5VM_limit_enc_size(enc_value);
3639 HDassert(enc_size < 256);
3640 *(*pp)++ = (uint8_t)enc_size;
3641 UINT64ENCODE_VAR(*pp, enc_value, enc_size);
3642
3643 /* enum */
3644 *(*pp)++ = (uint8_t)config->flash_incr_mode;
3645
3646 H5_ENCODE_DOUBLE(*pp, config->flash_multiple);
3647
3648 H5_ENCODE_DOUBLE(*pp, config->flash_threshold);
3649
3650 /* enum */
3651 *(*pp)++ = (uint8_t)config->decr_mode;
3652
3653 H5_ENCODE_DOUBLE(*pp, config->upper_hr_threshold);
3654
3655 H5_ENCODE_DOUBLE(*pp, config->decrement);
3656
3657 H5_ENCODE_UNSIGNED(*pp, config->apply_max_decrement);
3658
3659 enc_value = (uint64_t)config->max_decrement;
3660 enc_size = H5VM_limit_enc_size(enc_value);
3661 HDassert(enc_size < 256);
3662 *(*pp)++ = (uint8_t)enc_size;
3663 UINT64ENCODE_VAR(*pp, enc_value, enc_size);
3664
3665 /* int */
3666 INT32ENCODE(*pp, (int32_t)config->epochs_before_eviction);
3667
3668 H5_ENCODE_UNSIGNED(*pp, config->apply_empty_reserve);
3669
3670 H5_ENCODE_DOUBLE(*pp, config->empty_reserve);
3671
3672 /* unsigned */
3673 UINT32ENCODE(*pp, (uint32_t)config->dirty_bytes_threshold);
3674
3675 /* int */
3676 INT32ENCODE(*pp, (int32_t)config->metadata_write_strategy);
3677 } /* end if */
3678
3679 /* Compute encoded size of variably-encoded values */
3680 enc_value = (uint64_t)config->initial_size;
3681 *size += 1 + H5VM_limit_enc_size(enc_value);
3682 enc_value = (uint64_t)config->max_size;
3683 *size += 1 + H5VM_limit_enc_size(enc_value);
3684 enc_value = (uint64_t)config->min_size;
3685 *size += 1 + H5VM_limit_enc_size(enc_value);
3686 enc_value = (uint64_t)config->max_increment;
3687 *size += 1 + H5VM_limit_enc_size(enc_value);
3688 enc_value = (uint64_t)config->max_decrement;
3689 *size += 1 + H5VM_limit_enc_size(enc_value);
3690
3691 /* Compute encoded size of fixed-size values */
3692 *size += (5 + (sizeof(unsigned) * 8) + (sizeof(double) * 8) + (sizeof(int32_t) * 4) + sizeof(int64_t) +
3693 H5AC__MAX_TRACE_FILE_NAME_LEN + 1);
3694
3695 FUNC_LEAVE_NOAPI(SUCCEED)
3696 } /* end H5P__facc_cache_config_enc() */
3697
3698 /*-------------------------------------------------------------------------
3699 * Function: H5P__facc_cache_config_dec
3700 *
3701 * Purpose: Callback routine which is called whenever the default
3702 * cache config property in the file creation property list is
3703 * decoded.
3704 *
3705 * Return: Success: Non-negative
3706 * Failure: Negative
3707 *
3708 * Programmer: Mohamad Chaarawi
3709 * August 09, 2012
3710 *
3711 *-------------------------------------------------------------------------
3712 */
3713 static herr_t
H5P__facc_cache_config_dec(const void ** _pp,void * _value)3714 H5P__facc_cache_config_dec(const void **_pp, void *_value)
3715 {
3716 H5AC_cache_config_t *config = (H5AC_cache_config_t *)_value;
3717 const uint8_t ** pp = (const uint8_t **)_pp;
3718 unsigned enc_size;
3719 uint64_t enc_value;
3720 herr_t ret_value = SUCCEED; /* Return value */
3721
3722 FUNC_ENTER_STATIC
3723
3724 /* Sanity checks */
3725 HDassert(pp);
3726 HDassert(*pp);
3727 HDassert(config);
3728 HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
3729
3730 /* Set property to default value */
3731 H5MM_memcpy(config, &H5F_def_mdc_initCacheCfg_g, sizeof(H5AC_cache_config_t));
3732
3733 /* Decode type sizes */
3734 enc_size = *(*pp)++;
3735 if (enc_size != sizeof(unsigned))
3736 HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded")
3737 enc_size = *(*pp)++;
3738 if (enc_size != sizeof(double))
3739 HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded")
3740
3741 /* int */
3742 INT32DECODE(*pp, config->version);
3743
3744 H5_DECODE_UNSIGNED(*pp, config->rpt_fcn_enabled);
3745
3746 H5_DECODE_UNSIGNED(*pp, config->open_trace_file);
3747
3748 H5_DECODE_UNSIGNED(*pp, config->close_trace_file);
3749
3750 HDstrcpy(config->trace_file_name, (const char *)(*pp));
3751 *pp += H5AC__MAX_TRACE_FILE_NAME_LEN + 1;
3752
3753 H5_DECODE_UNSIGNED(*pp, config->evictions_enabled);
3754
3755 H5_DECODE_UNSIGNED(*pp, config->set_initial_size);
3756
3757 enc_size = *(*pp)++;
3758 HDassert(enc_size < 256);
3759 UINT64DECODE_VAR(*pp, enc_value, enc_size);
3760 config->initial_size = (size_t)enc_value;
3761
3762 H5_DECODE_DOUBLE(*pp, config->min_clean_fraction);
3763
3764 enc_size = *(*pp)++;
3765 HDassert(enc_size < 256);
3766 UINT64DECODE_VAR(*pp, enc_value, enc_size);
3767 config->max_size = (size_t)enc_value;
3768
3769 enc_size = *(*pp)++;
3770 HDassert(enc_size < 256);
3771 UINT64DECODE_VAR(*pp, enc_value, enc_size);
3772 config->min_size = (size_t)enc_value;
3773
3774 /* long int */
3775 {
3776 int64_t temp;
3777 INT64DECODE(*pp, temp);
3778 config->epoch_length = (long int)temp;
3779 }
3780 /* enum */
3781 config->incr_mode = (enum H5C_cache_incr_mode) * (*pp)++;
3782
3783 H5_DECODE_DOUBLE(*pp, config->lower_hr_threshold);
3784
3785 H5_DECODE_DOUBLE(*pp, config->increment);
3786
3787 H5_DECODE_UNSIGNED(*pp, config->apply_max_increment);
3788
3789 enc_size = *(*pp)++;
3790 HDassert(enc_size < 256);
3791 UINT64DECODE_VAR(*pp, enc_value, enc_size);
3792 config->max_increment = (size_t)enc_value;
3793
3794 /* enum */
3795 config->flash_incr_mode = (enum H5C_cache_flash_incr_mode) * (*pp)++;
3796
3797 H5_DECODE_DOUBLE(*pp, config->flash_multiple);
3798
3799 H5_DECODE_DOUBLE(*pp, config->flash_threshold);
3800
3801 /* enum */
3802 config->decr_mode = (enum H5C_cache_decr_mode) * (*pp)++;
3803
3804 H5_DECODE_DOUBLE(*pp, config->upper_hr_threshold);
3805
3806 H5_DECODE_DOUBLE(*pp, config->decrement);
3807
3808 H5_DECODE_UNSIGNED(*pp, config->apply_max_decrement);
3809
3810 enc_size = *(*pp)++;
3811 HDassert(enc_size < 256);
3812 UINT64DECODE_VAR(*pp, enc_value, enc_size);
3813 config->max_decrement = (size_t)enc_value;
3814
3815 /* int */
3816 INT32DECODE(*pp, config->epochs_before_eviction);
3817
3818 H5_DECODE_UNSIGNED(*pp, config->apply_empty_reserve);
3819
3820 H5_DECODE_DOUBLE(*pp, config->empty_reserve);
3821
3822 /* unsigned */
3823 UINT32DECODE(*pp, config->dirty_bytes_threshold);
3824
3825 /* int */
3826 INT32DECODE(*pp, config->metadata_write_strategy);
3827
3828 done:
3829 FUNC_LEAVE_NOAPI(ret_value)
3830 } /* end H5P__facc_cache_config_dec() */
3831
3832 /*-------------------------------------------------------------------------
3833 * Function: H5P__facc_fclose_degree_enc
3834 *
3835 * Purpose: Callback routine which is called whenever the file close
3836 * degree property in the file access property list
3837 * is encoded.
3838 *
3839 * Return: Success: Non-negative
3840 * Failure: Negative
3841 *
3842 * Programmer: Quincey Koziol
3843 * Wednesday, August 15, 2012
3844 *
3845 *-------------------------------------------------------------------------
3846 */
3847 static herr_t
H5P__facc_fclose_degree_enc(const void * value,void ** _pp,size_t * size)3848 H5P__facc_fclose_degree_enc(const void *value, void **_pp, size_t *size)
3849 {
3850 const H5F_close_degree_t *fclose_degree =
3851 (const H5F_close_degree_t *)value; /* Create local alias for values */
3852 uint8_t **pp = (uint8_t **)_pp;
3853
3854 FUNC_ENTER_STATIC_NOERR
3855
3856 /* Sanity check */
3857 HDassert(fclose_degree);
3858 HDassert(size);
3859
3860 if (NULL != *pp)
3861 /* Encode file close degree */
3862 *(*pp)++ = (uint8_t)*fclose_degree;
3863
3864 /* Size of file close degree */
3865 (*size)++;
3866
3867 FUNC_LEAVE_NOAPI(SUCCEED)
3868 } /* end H5P__facc_fclose_degree_enc() */
3869
3870 /*-------------------------------------------------------------------------
3871 * Function: H5P__facc_fclose_degree_dec
3872 *
3873 * Purpose: Callback routine which is called whenever the file close
3874 * degree property in the file access property list
3875 * is decoded.
3876 *
3877 * Return: Success: Non-negative
3878 * Failure: Negative
3879 *
3880 * Programmer: Quincey Koziol
3881 * Wednesday, August 15, 2012
3882 *
3883 *-------------------------------------------------------------------------
3884 */
3885 static herr_t
H5P__facc_fclose_degree_dec(const void ** _pp,void * _value)3886 H5P__facc_fclose_degree_dec(const void **_pp, void *_value)
3887 {
3888 H5F_close_degree_t *fclose_degree = (H5F_close_degree_t *)_value; /* File close degree */
3889 const uint8_t ** pp = (const uint8_t **)_pp;
3890
3891 FUNC_ENTER_STATIC_NOERR
3892
3893 /* Sanity checks */
3894 HDassert(pp);
3895 HDassert(*pp);
3896 HDassert(fclose_degree);
3897
3898 /* Decode file close degree */
3899 *fclose_degree = (H5F_close_degree_t) * (*pp)++;
3900
3901 FUNC_LEAVE_NOAPI(SUCCEED)
3902 } /* end H5P__facc_fclose_degree_dec() */
3903
3904 /*-------------------------------------------------------------------------
3905 * Function: H5P__facc_multi_type_enc
3906 *
3907 * Purpose: Callback routine which is called whenever the multi VFD
3908 * memory type property in the file access property list
3909 * is encoded.
3910 *
3911 * Return: Success: Non-negative
3912 * Failure: Negative
3913 *
3914 * Programmer: Quincey Koziol
3915 * Wednesday, August 15, 2012
3916 *
3917 *-------------------------------------------------------------------------
3918 */
3919 static herr_t
H5P__facc_multi_type_enc(const void * value,void ** _pp,size_t * size)3920 H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size)
3921 {
3922 const H5FD_mem_t *type = (const H5FD_mem_t *)value; /* Create local alias for values */
3923 uint8_t ** pp = (uint8_t **)_pp;
3924
3925 FUNC_ENTER_STATIC_NOERR
3926
3927 /* Sanity check */
3928 HDassert(type);
3929 HDassert(size);
3930
3931 if (NULL != *pp)
3932 /* Encode file close degree */
3933 *(*pp)++ = (uint8_t)*type;
3934
3935 /* Size of multi VFD memory type */
3936 (*size)++;
3937
3938 FUNC_LEAVE_NOAPI(SUCCEED)
3939 } /* end H5P__facc_multi_type_enc() */
3940
3941 /*-------------------------------------------------------------------------
3942 * Function: H5P__facc_multi_type_dec
3943 *
3944 * Purpose: Callback routine which is called whenever the multi VFD
3945 * memory type property in the file access property list
3946 * is decoded.
3947 *
3948 * Return: Success: Non-negative
3949 * Failure: Negative
3950 *
3951 * Programmer: Quincey Koziol
3952 * Wednesday, August 15, 2012
3953 *
3954 *-------------------------------------------------------------------------
3955 */
3956 static herr_t
H5P__facc_multi_type_dec(const void ** _pp,void * _value)3957 H5P__facc_multi_type_dec(const void **_pp, void *_value)
3958 {
3959 H5FD_mem_t * type = (H5FD_mem_t *)_value; /* File close degree */
3960 const uint8_t **pp = (const uint8_t **)_pp;
3961
3962 FUNC_ENTER_STATIC_NOERR
3963
3964 /* Sanity checks */
3965 HDassert(pp);
3966 HDassert(*pp);
3967 HDassert(type);
3968
3969 /* Decode multi VFD memory type */
3970 *type = (H5FD_mem_t) * (*pp)++;
3971
3972 FUNC_LEAVE_NOAPI(SUCCEED)
3973 } /* end H5P__facc_multi_type_dec() */
3974
3975 /*-------------------------------------------------------------------------
3976 * Function: H5P__facc_libver_type_enc
3977 *
3978 * Purpose: Callback routine which is called whenever the 'low' or
3979 * 'high' bound of library format versions property in the
3980 * file access property list is encoded.
3981 *
3982 * Return: Success: Non-negative
3983 * Failure: Negative
3984 *
3985 * Programmer
3986 *
3987 *-------------------------------------------------------------------------
3988 */
3989 static herr_t
H5P__facc_libver_type_enc(const void * value,void ** _pp,size_t * size,void * udata)3990 H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size, void* udata)
3991 {
3992 const H5F_libver_t *type = (const H5F_libver_t *)value; /* Create local alias for values */
3993 uint8_t ** pp = (uint8_t **)_pp;
3994 (void)udata;
3995
3996 FUNC_ENTER_STATIC_NOERR
3997
3998 /* Sanity check */
3999 HDassert(type);
4000 HDassert(size);
4001
4002 /* Encode */
4003 if (NULL != *pp)
4004 *(*pp)++ = (uint8_t)*type;
4005
4006 /* Size */
4007 (*size)++;
4008
4009 FUNC_LEAVE_NOAPI(SUCCEED)
4010 } /* end H5P__facc_libver_type_enc() */
4011
4012 /*-------------------------------------------------------------------------
4013 * Function: H5P__facc_libver_type_dec
4014 *
4015 * Purpose: Callback routine which is called whenever the 'low' or
4016 * 'high' bound of library format versions property in the
4017 * file access property list is decoded.
4018 *
4019 * Return: Success: Non-negative
4020 * Failure: Negative
4021 *
4022 * Programmer:
4023 *
4024 *-------------------------------------------------------------------------
4025 */
4026 static herr_t
H5P__facc_libver_type_dec(const void ** _pp,void * _value)4027 H5P__facc_libver_type_dec(const void **_pp, void *_value)
4028 {
4029 H5F_libver_t * type = (H5F_libver_t *)_value;
4030 const uint8_t **pp = (const uint8_t **)_pp;
4031
4032 FUNC_ENTER_STATIC_NOERR
4033
4034 /* Sanity checks */
4035 HDassert(pp);
4036 HDassert(*pp);
4037 HDassert(type);
4038
4039 /* Decode */
4040 *type = (H5F_libver_t) * (*pp)++;
4041
4042 FUNC_LEAVE_NOAPI(SUCCEED)
4043 } /* end H5P__facc_libver_type_dec() */
4044
4045 /*-------------------------------------------------------------------------
4046 * Function: H5Pset_metadata_read_attempts
4047 *
4048 * Purpose: Sets the # of read attempts in the file access property list
4049 * when reading metadata with checksum.
4050 * The # of read attempts set via this routine will only apply
4051 * when opening a file with SWMR access.
4052 * The # of read attempts set via this routine does not have
4053 * any effect when opening a file with non-SWMR access; for this
4054 * case, the # of read attempts will be always be 1.
4055 *
4056 * Return: Non-negative on success/Negative on failure
4057 *
4058 * Programmer: Vailin Choi; Sept 2013
4059 *
4060 *-------------------------------------------------------------------------
4061 */
4062 herr_t
H5Pset_metadata_read_attempts(hid_t plist_id,unsigned attempts)4063 H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts)
4064 {
4065 H5P_genplist_t *plist; /* Property list pointer */
4066 herr_t ret_value = SUCCEED; /* return value */
4067
4068 FUNC_ENTER_API(FAIL)
4069 H5TRACE2("e", "iIu", plist_id, attempts);
4070
4071 /* Cannot set the # of attempts to 0 */
4072 if (attempts == 0)
4073 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
4074 "number of metadatata read attempts must be greater than 0");
4075
4076 /* Get the plist structure */
4077 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
4078 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4079
4080 /* Set values */
4081 if (H5P_set(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &attempts) < 0)
4082 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set # of metadata read attempts")
4083
4084 done:
4085 FUNC_LEAVE_API(ret_value)
4086 } /* H5Pset_metadata_read_attempts() */
4087
4088 /*-------------------------------------------------------------------------
4089 * Function: H5Pget_metadata_read_attempts
4090 *
4091 * Purpose: Returns the # of metadata read attempts set in the file access property list.
4092 *
4093 * Return: Non-negative on success/Negative on failure
4094 *
4095 * Programmer: Vailin Choi; Sept 2013
4096 *
4097 *-------------------------------------------------------------------------
4098 */
4099 herr_t
H5Pget_metadata_read_attempts(hid_t plist_id,unsigned * attempts)4100 H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts /*out*/)
4101 {
4102 herr_t ret_value = SUCCEED; /* Return value */
4103
4104 FUNC_ENTER_API(FAIL)
4105 H5TRACE2("e", "ix", plist_id, attempts);
4106
4107 /* Get values */
4108 if (attempts) {
4109 H5P_genplist_t *plist; /* Property list pointer */
4110
4111 /* Get the plist structure */
4112 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
4113 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4114
4115 /* Get the # of read attempts set */
4116 if (H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, attempts) < 0)
4117 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get the number of metadata read attempts")
4118
4119 /* If not set, return the default value */
4120 if (*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */
4121 *attempts = H5F_METADATA_READ_ATTEMPTS;
4122 } /* end if */
4123
4124 done:
4125 FUNC_LEAVE_API(ret_value)
4126 } /* end H5Pget_metadata_read_attempts() */
4127
4128 /*-------------------------------------------------------------------------
4129 * Function: H5Pset_obj_flush_cb
4130 *
4131 * Purpose: Sets the callback function to invoke and the user data when an
4132 * object flush occurs in the file.
4133 *
4134 * Return: Non-negative on success/Negative on failure
4135 *
4136 * Programmer: Vailin Choi; Dec 2013
4137 *
4138 *-------------------------------------------------------------------------
4139 */
4140 herr_t
H5Pset_object_flush_cb(hid_t plist_id,H5F_flush_cb_t func,void * udata)4141 H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata)
4142 {
4143 H5P_genplist_t * plist; /* Property list pointer */
4144 H5F_object_flush_t flush_info;
4145 herr_t ret_value = SUCCEED; /* return value */
4146
4147 FUNC_ENTER_API(FAIL)
4148 H5TRACE3("e", "ix*x", plist_id, func, udata);
4149
4150 /* Check if the callback function is NULL and the user data is non-NULL.
4151 * This is almost certainly an error as the user data will not be used. */
4152 if (!func && udata)
4153 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not")
4154
4155 /* Get the plist structure */
4156 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
4157 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4158
4159 /* Update property list */
4160 flush_info.func = func;
4161 flush_info.udata = udata;
4162
4163 /* Set values */
4164 if (H5P_set(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0)
4165 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback")
4166
4167 done:
4168 FUNC_LEAVE_API(ret_value)
4169 } /* H5Pset_obj_flush_cb() */
4170
4171 /*-------------------------------------------------------------------------
4172 * Function: H5Pget_obj_flush_cb
4173 *
4174 * Purpose: Retrieves the callback function and user data set in the
4175 * property list for an object flush.
4176 *
4177 * Return: Non-negative on success/Negative on failure
4178 *
4179 * Programmer: Vailin Choi; Dec 2013
4180 *
4181 *-------------------------------------------------------------------------
4182 */
4183 herr_t
H5Pget_object_flush_cb(hid_t plist_id,H5F_flush_cb_t * func,void ** udata)4184 H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata)
4185 {
4186 H5P_genplist_t * plist; /* Property list pointer */
4187 H5F_object_flush_t flush_info;
4188 herr_t ret_value = SUCCEED; /* return value */
4189
4190 FUNC_ENTER_API(FAIL)
4191 H5TRACE3("e", "i*x**x", plist_id, func, udata);
4192
4193 /* Get the plist structure */
4194 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
4195 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4196
4197 /* Retrieve the callback function and user data */
4198 if (H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &flush_info) < 0)
4199 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object flush callback")
4200
4201 /* Assign return value */
4202 if (func)
4203 *func = flush_info.func;
4204 if (udata)
4205 *udata = flush_info.udata;
4206
4207 done:
4208 FUNC_LEAVE_API(ret_value)
4209 } /* H5Pget_obj_flush_cb() */
4210
4211 /*-------------------------------------------------------------------------
4212 * Function: H5Pset_mdc_log_options
4213 *
4214 * Purpose: Set metadata cache log options.
4215 *
4216 * Return: Non-negative on success/Negative on failure
4217 *
4218 *-------------------------------------------------------------------------
4219 */
4220 herr_t
H5Pset_mdc_log_options(hid_t plist_id,hbool_t is_enabled,const char * location,hbool_t start_on_access)4221 H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access)
4222 {
4223 H5P_genplist_t *plist; /* Property list pointer */
4224 char * new_location; /* Working location pointer */
4225 herr_t ret_value = SUCCEED; /* Return value */
4226
4227 FUNC_ENTER_API(FAIL)
4228 H5TRACE4("e", "ib*sb", plist_id, is_enabled, location, start_on_access);
4229
4230 /* Check arguments */
4231 if (H5P_DEFAULT == plist_id)
4232 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't modify default property list")
4233 if (!location)
4234 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "location cannot be NULL")
4235
4236 /* Get the property list structure */
4237 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
4238 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list")
4239
4240 /* Make a copy of the passed-in location */
4241 if (NULL == (new_location = H5MM_xstrdup(location)))
4242 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy passed-in log location")
4243
4244 /* Set values */
4245 if (H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0)
4246 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set is_enabled flag")
4247 if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &new_location) < 0)
4248 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set log location")
4249 if (H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0)
4250 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set start_on_access flag")
4251
4252 done:
4253 FUNC_LEAVE_API(ret_value)
4254 } /* end H5Pset_mdc_log_options() */
4255
4256 /*-------------------------------------------------------------------------
4257 * Function: H5Pget_mdc_log_options
4258 *
4259 * Purpose: Get metadata cache log options.
4260 *
4261 * Return: Non-negative on success/Negative on failure
4262 *
4263 *-------------------------------------------------------------------------
4264 */
4265 herr_t
H5Pget_mdc_log_options(hid_t plist_id,hbool_t * is_enabled,char * location,size_t * location_size,hbool_t * start_on_access)4266 H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, size_t *location_size,
4267 hbool_t *start_on_access)
4268 {
4269 H5P_genplist_t *plist; /* Property list pointer */
4270 char * location_ptr = NULL; /* Pointer to location string */
4271 herr_t ret_value = SUCCEED; /* Return value */
4272
4273 FUNC_ENTER_API(FAIL)
4274 H5TRACE5("e", "i*b*s*z*b", plist_id, is_enabled, location, location_size, start_on_access);
4275
4276 /* Get the property list structure */
4277 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
4278 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list")
4279
4280 /* Get simple values */
4281 if (is_enabled)
4282 if (H5P_get(plist, H5F_ACS_USE_MDC_LOGGING_NAME, is_enabled) < 0)
4283 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location")
4284 if (start_on_access)
4285 if (H5P_get(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, start_on_access) < 0)
4286 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get start_on_access flag")
4287
4288 /* Get the location */
4289 if (location || location_size)
4290 if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &location_ptr) < 0)
4291 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get log location")
4292
4293 /* Copy log location to output buffer */
4294 if (location_ptr && location)
4295 H5MM_memcpy(location, location_ptr, *location_size);
4296
4297 /* Get location size, including terminating NULL */
4298 if (location_size) {
4299 if (location_ptr)
4300 *location_size = HDstrlen(location_ptr) + 1;
4301 else
4302 *location_size = 0;
4303 } /* end if */
4304
4305 done:
4306 FUNC_LEAVE_API(ret_value)
4307 } /* end H5Pget_mdc_log_options() */
4308
4309 /*-------------------------------------------------------------------------
4310 * Function: H5P__facc_mdc_log_location_enc
4311 *
4312 * Purpose: Callback routine which is called whenever the metadata
4313 * cache log location property in the file access property
4314 * list is encoded.
4315 *
4316 * Return: Success: Non-negative
4317 * Failure: Negative
4318 *
4319 *-------------------------------------------------------------------------
4320 */
4321 static herr_t
H5P__facc_mdc_log_location_enc(const void * value,void ** _pp,size_t * size)4322 H5P__facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size)
4323 {
4324 const char *log_location = *(const char *const *)value;
4325 uint8_t ** pp = (uint8_t **)_pp;
4326 size_t len = 0;
4327 uint64_t enc_value;
4328 unsigned enc_size;
4329
4330 FUNC_ENTER_STATIC_NOERR
4331
4332 HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
4333
4334 /* calculate prefix length */
4335 if (NULL != log_location)
4336 len = HDstrlen(log_location);
4337
4338 enc_value = (uint64_t)len;
4339 enc_size = H5VM_limit_enc_size(enc_value);
4340 HDassert(enc_size < 256);
4341
4342 if (NULL != *pp) {
4343 /* encode the length of the prefix */
4344 *(*pp)++ = (uint8_t)enc_size;
4345 UINT64ENCODE_VAR(*pp, enc_value, enc_size);
4346
4347 /* encode the prefix */
4348 if (NULL != log_location) {
4349 H5MM_memcpy(*(char **)pp, log_location, len);
4350 *pp += len;
4351 } /* end if */
4352 } /* end if */
4353
4354 *size += (1 + enc_size);
4355 if (NULL != log_location)
4356 *size += len;
4357
4358 FUNC_LEAVE_NOAPI(SUCCEED)
4359 } /* end H5P__facc_mdc_log_location_enc() */
4360
4361 /*-------------------------------------------------------------------------
4362 * Function: H5P__facc_mdc_log_location_dec
4363 *
4364 * Purpose: Callback routine which is called whenever the metadata
4365 * cache log location property in the file access property
4366 * list is decoded.
4367 *
4368 * Return: Success: Non-negative
4369 * Failure: Negative
4370 *
4371 *-------------------------------------------------------------------------
4372 */
4373 static herr_t
H5P__facc_mdc_log_location_dec(const void ** _pp,void * _value)4374 H5P__facc_mdc_log_location_dec(const void **_pp, void *_value)
4375 {
4376 char ** log_location = (char **)_value;
4377 const uint8_t **pp = (const uint8_t **)_pp;
4378 size_t len;
4379 uint64_t enc_value; /* Decoded property value */
4380 unsigned enc_size; /* Size of encoded property */
4381 herr_t ret_value = SUCCEED;
4382
4383 FUNC_ENTER_STATIC
4384
4385 HDassert(pp);
4386 HDassert(*pp);
4387 HDassert(log_location);
4388 HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
4389
4390 /* Decode the size */
4391 enc_size = *(*pp)++;
4392 HDassert(enc_size < 256);
4393
4394 /* Decode the value */
4395 UINT64DECODE_VAR(*pp, enc_value, enc_size);
4396 len = enc_value;
4397
4398 if (0 != len) {
4399 /* Make a copy of the user's prefix string */
4400 if (NULL == (*log_location = (char *)H5MM_malloc(len + 1)))
4401 HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for prefix")
4402 HDstrncpy(*log_location, *(const char **)pp, len);
4403 (*log_location)[len] = '\0';
4404
4405 *pp += len;
4406 } /* end if */
4407 else
4408 *log_location = NULL;
4409
4410 done:
4411 FUNC_LEAVE_NOAPI(ret_value)
4412 } /* end H5P__facc_mdc_log_location_dec() */
4413
4414 /*-------------------------------------------------------------------------
4415 * Function: H5P__facc_mdc_log_location_del
4416 *
4417 * Purpose: Frees memory used to store the metadata cache log location.
4418 *
4419 * Return: Non-negative on success/Negative on failure
4420 *
4421 *-------------------------------------------------------------------------
4422 */
4423 static herr_t
H5P__facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)4424 H5P__facc_mdc_log_location_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
4425 size_t H5_ATTR_UNUSED size, void *value)
4426 {
4427 FUNC_ENTER_STATIC_NOERR
4428
4429 HDassert(value);
4430
4431 H5MM_xfree(*(void **)value);
4432
4433 FUNC_LEAVE_NOAPI(SUCCEED)
4434 } /* end H5P__facc_mdc_log_location_del() */
4435
4436 /*-------------------------------------------------------------------------
4437 * Function: H5P__facc_mdc_log_location_copy
4438 *
4439 * Purpose: Creates a copy of the metadata cache log location string.
4440 *
4441 * Return: Non-negative on success/Negative on failure
4442 *
4443 *-------------------------------------------------------------------------
4444 */
4445 static herr_t
H5P__facc_mdc_log_location_copy(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)4446 H5P__facc_mdc_log_location_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
4447 {
4448 FUNC_ENTER_STATIC_NOERR
4449
4450 HDassert(value);
4451
4452 *(char **)value = H5MM_xstrdup(*(const char **)value);
4453
4454 FUNC_LEAVE_NOAPI(SUCCEED)
4455 } /* end H5P__facc_mdc_log_location_copy() */
4456
4457 /*-------------------------------------------------------------------------
4458 * Function: H5P__facc_mdc_log_location_cmp
4459 *
4460 * Purpose: Callback routine which is called whenever the metadata
4461 * cache log location property in the file creation property
4462 * list is compared.
4463 *
4464 * Return: zero if VALUE1 and VALUE2 are equal, non zero otherwise.
4465 *
4466 *-------------------------------------------------------------------------
4467 */
4468 static H5_ATTR_PURE int
H5P__facc_mdc_log_location_cmp(const void * value1,const void * value2,size_t H5_ATTR_UNUSED size)4469 H5P__facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size)
4470 {
4471 const char *pref1 = *(const char *const *)value1;
4472 const char *pref2 = *(const char *const *)value2;
4473 int ret_value = 0;
4474
4475 FUNC_ENTER_STATIC_NOERR
4476
4477 if (NULL == pref1 && NULL != pref2)
4478 HGOTO_DONE(1);
4479 if (NULL != pref1 && NULL == pref2)
4480 HGOTO_DONE(-1);
4481 if (NULL != pref1 && NULL != pref2)
4482 ret_value = HDstrcmp(pref1, pref2);
4483
4484 done:
4485 FUNC_LEAVE_NOAPI(ret_value)
4486 } /* end H5P__facc_mdc_log_location_cmp() */
4487
4488 /*-------------------------------------------------------------------------
4489 * Function: H5P__facc_mdc_log_location_close
4490 *
4491 * Purpose: Frees memory used to store the metadata cache log location
4492 * string
4493 *
4494 * Return: Non-negative on success/Negative on failure
4495 *
4496 *-------------------------------------------------------------------------
4497 */
4498 static herr_t
H5P__facc_mdc_log_location_close(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)4499 H5P__facc_mdc_log_location_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
4500 {
4501 FUNC_ENTER_STATIC_NOERR
4502
4503 HDassert(value);
4504
4505 H5MM_xfree(*(void **)value);
4506
4507 FUNC_LEAVE_NOAPI(SUCCEED)
4508 } /* end H5P__facc_mdc_log_location_close() */
4509
4510 /*-------------------------------------------------------------------------
4511 * Function: H5Pset_evict_on_close
4512 *
4513 * Purpose: Sets the evict_on_close property value.
4514 *
4515 * When this property is set, closing an HDF5 object will
4516 * cause the object's metadata cache entries to be flushed
4517 * and evicted from the cache.
4518 *
4519 * Currently only implemented for datasets.
4520 *
4521 * Return: SUCCEED/FAIL
4522 *
4523 * Programmer: Dana Robinson
4524 * Spring 2016
4525 *
4526 *-------------------------------------------------------------------------
4527 */
4528 herr_t
H5Pset_evict_on_close(hid_t fapl_id,hbool_t H5_ATTR_PARALLEL_UNUSED evict_on_close)4529 H5Pset_evict_on_close(hid_t fapl_id, hbool_t H5_ATTR_PARALLEL_UNUSED evict_on_close)
4530 {
4531 H5P_genplist_t *plist; /* property list pointer */
4532 herr_t ret_value = SUCCEED; /* return value */
4533
4534 FUNC_ENTER_API(FAIL)
4535 H5TRACE2("e", "ib", fapl_id, evict_on_close);
4536
4537 /* Compare the property list's class against the other class */
4538 if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
4539 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist")
4540
4541 /* Get the plist structure */
4542 if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
4543 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4544
4545 #ifndef H5_HAVE_PARALLEL
4546 /* Set value */
4547 if (H5P_set(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, &evict_on_close) < 0)
4548 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set evict on close property")
4549 #else
4550 HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL,
4551 "evict on close is currently not supported in parallel HDF5")
4552 #endif /* H5_HAVE_PARALLEL */
4553
4554 done:
4555 FUNC_LEAVE_API(ret_value)
4556 } /* end H5Pset_evict_on_close() */
4557
4558 /*-------------------------------------------------------------------------
4559 * Function: H5Pget_evict_on_close
4560 *
4561 * Purpose: Gets the evict_on_close property value.
4562 *
4563 * When this property is set, closing an HDF5 object will
4564 * cause the object's metadata cache entries to be flushed
4565 * and evicted from the cache.
4566 *
4567 * Currently only implemented for datasets.
4568 *
4569 * Return: SUCCEED/FAIL
4570 *
4571 * Programmer: Dana Robinson
4572 * Spring 2016
4573 *
4574 *-------------------------------------------------------------------------
4575 */
4576 herr_t
H5Pget_evict_on_close(hid_t fapl_id,hbool_t * evict_on_close)4577 H5Pget_evict_on_close(hid_t fapl_id, hbool_t *evict_on_close)
4578 {
4579 H5P_genplist_t *plist; /* property list pointer */
4580 herr_t ret_value = SUCCEED; /* return value */
4581
4582 FUNC_ENTER_API(FAIL)
4583 H5TRACE2("e", "i*b", fapl_id, evict_on_close);
4584
4585 /* Compare the property list's class against the other class */
4586 if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
4587 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist")
4588
4589 /* Get the plist structure */
4590 if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
4591 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4592
4593 if (H5P_get(plist, H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME, evict_on_close) < 0)
4594 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get evict on close property")
4595
4596 done:
4597 FUNC_LEAVE_API(ret_value)
4598 } /* end H5Pget_evict_on_close() */
4599
4600 /*-------------------------------------------------------------------------
4601 * Function: H5Pset_file_locking
4602 *
4603 * Purpose: Sets the file locking property values.
4604 *
4605 * Overrides the default file locking flag setting that was
4606 * set when the library was configured.
4607 *
4608 * Can be overridden by the HDF5_USE_FILE_LOCKING environment
4609 * variable.
4610 *
4611 * File locking is used when creating/opening a file to prevent
4612 * problematic file accesses.
4613 *
4614 * Return: SUCCEED/FAIL
4615 *
4616 * Programmer: Dana Robinson
4617 * Spring 2020
4618 *
4619 *-------------------------------------------------------------------------
4620 */
4621 herr_t
H5Pset_file_locking(hid_t fapl_id,hbool_t use_file_locking,hbool_t ignore_when_disabled)4622 H5Pset_file_locking(hid_t fapl_id, hbool_t use_file_locking, hbool_t ignore_when_disabled)
4623 {
4624 H5P_genplist_t *plist; /* property list pointer */
4625 herr_t ret_value = SUCCEED; /* return value */
4626
4627 FUNC_ENTER_API(FAIL)
4628 H5TRACE3("e", "ibb", fapl_id, use_file_locking, ignore_when_disabled);
4629
4630 /* Make sure this is a fapl */
4631 if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
4632 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist")
4633
4634 /* Get the plist structure */
4635 if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
4636 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4637
4638 /* Set values */
4639 if (H5P_set(plist, H5F_ACS_USE_FILE_LOCKING_NAME, &use_file_locking) < 0)
4640 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set use file locking property")
4641 if (H5P_set(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, &ignore_when_disabled) < 0)
4642 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set ignore disabled file locks property")
4643
4644 done:
4645 FUNC_LEAVE_API(ret_value)
4646 } /* end H5Pset_file_locking() */
4647
4648 /*-------------------------------------------------------------------------
4649 * Function: H5Pget_file_locking
4650 *
4651 * Purpose: Gets the file locking property values.
4652 *
4653 * File locking is used when creating/opening a file to prevent
4654 * problematic file accesses.
4655 *
4656 * Return: SUCCEED/FAIL
4657 *
4658 * Programmer: Dana Robinson
4659 * Spring 2020
4660 *
4661 *-------------------------------------------------------------------------
4662 */
4663 herr_t
H5Pget_file_locking(hid_t fapl_id,hbool_t * use_file_locking,hbool_t * ignore_when_disabled)4664 H5Pget_file_locking(hid_t fapl_id, hbool_t *use_file_locking, hbool_t *ignore_when_disabled)
4665 {
4666 H5P_genplist_t *plist; /* property list pointer */
4667 herr_t ret_value = SUCCEED; /* return value */
4668
4669 FUNC_ENTER_API(FAIL)
4670 H5TRACE3("e", "i*b*b", fapl_id, use_file_locking, ignore_when_disabled);
4671
4672 /* Make sure this is a fapl */
4673 if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
4674 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist")
4675
4676 /* Get the plist structure */
4677 if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
4678 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4679
4680 /* Get values */
4681 if (H5P_get(plist, H5F_ACS_USE_FILE_LOCKING_NAME, use_file_locking) < 0)
4682 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get use file locking property")
4683 if (H5P_get(plist, H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME, ignore_when_disabled) < 0)
4684 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get ignore disabled file locks property")
4685
4686 done:
4687 FUNC_LEAVE_API(ret_value)
4688 } /* end H5Pget_file_locking() */
4689
4690 #ifdef H5_HAVE_PARALLEL
4691
4692 /*-------------------------------------------------------------------------
4693 * Function: H5P__encode_coll_md_read_flag_t
4694 *
4695 * Purpose: Generic encoding callback routine for 'coll_md_read_flag' properties.
4696 *
4697 * Return: Success: Non-negative
4698 * Failure: Negative
4699 *
4700 * Programmer: Mohamad Chaarawi
4701 * Sunday, June 21, 2015
4702 *
4703 *-------------------------------------------------------------------------
4704 */
4705 herr_t
H5P__encode_coll_md_read_flag_t(const void * value,void ** _pp,size_t * size)4706 H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size)
4707 {
4708 const H5P_coll_md_read_flag_t *coll_md_read_flag = (const H5P_coll_md_read_flag_t *)value;
4709 uint8_t ** pp = (uint8_t **)_pp;
4710
4711 FUNC_ENTER_PACKAGE_NOERR
4712
4713 /* Sanity checks */
4714 HDassert(coll_md_read_flag);
4715 HDassert(size);
4716
4717 if (NULL != *pp) {
4718 /* Encode the value */
4719 H5MM_memcpy(*pp, coll_md_read_flag, sizeof(H5P_coll_md_read_flag_t));
4720 *pp += sizeof(H5P_coll_md_read_flag_t);
4721 } /* end if */
4722
4723 /* Set size needed for encoding */
4724 *size += sizeof(H5P_coll_md_read_flag_t);
4725
4726 FUNC_LEAVE_NOAPI(SUCCEED)
4727 } /* end H5P__encode_coll_md_read_flag_t() */
4728
4729 /*-------------------------------------------------------------------------
4730 * Function: H5P__decode_coll_md_read_flag_t
4731 *
4732 * Purpose: Generic decoding callback routine for 'coll_md_read_flag' properties.
4733 *
4734 * Return: Success: Non-negative
4735 * Failure: Negative
4736 *
4737 * Programmer: Mohamad Chaarawi
4738 * Sunday, June 21, 2015
4739 *
4740 *-------------------------------------------------------------------------
4741 */
4742 herr_t
H5P__decode_coll_md_read_flag_t(const void ** _pp,void * _value)4743 H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value)
4744 {
4745 H5P_coll_md_read_flag_t *coll_md_read_flag = (H5P_coll_md_read_flag_t *)_value; /* File close degree */
4746 const uint8_t ** pp = (const uint8_t **)_pp;
4747
4748 FUNC_ENTER_STATIC_NOERR
4749
4750 /* Sanity checks */
4751 HDassert(pp);
4752 HDassert(*pp);
4753 HDassert(coll_md_read_flag);
4754
4755 /* Decode file close degree */
4756 *coll_md_read_flag = (H5P_coll_md_read_flag_t) * (*pp);
4757 *pp += sizeof(H5P_coll_md_read_flag_t);
4758
4759 FUNC_LEAVE_NOAPI(SUCCEED)
4760 } /* end H5P__decode_coll_md_read_flag_t() */
4761
4762 /*-------------------------------------------------------------------------
4763 * Function: H5Pset_all_coll_metadata_ops
4764 *
4765 * Purpose: Tell the library whether the metadata read operations will
4766 * be done collectively (1) or not (0). Default is independent.
4767 * With collective mode, the library will optimize access to
4768 * metadata operations on the file.
4769 *
4770 * Note: This routine accepts file access property lists, link
4771 * access property lists, attribute access property lists,
4772 * dataset access property lists, group access property lists,
4773 * named datatype access property lists,
4774 * and dataset transfer property lists.
4775 *
4776 * Return: Non-negative on success/Negative on failure
4777 *
4778 * Programmer: Mohamad Chaarawi
4779 * Sunday, June 21, 2015
4780 *
4781 *-------------------------------------------------------------------------
4782 */
4783 herr_t
H5Pset_all_coll_metadata_ops(hid_t plist_id,hbool_t is_collective)4784 H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective)
4785 {
4786 H5P_genplist_t * plist; /* Property list pointer */
4787 H5P_coll_md_read_flag_t coll_meta_read; /* Property value */
4788 herr_t ret_value = SUCCEED; /* return value */
4789
4790 FUNC_ENTER_API(FAIL)
4791 H5TRACE2("e", "ib", plist_id, is_collective);
4792
4793 /* Compare the property list's class against the other class */
4794 /* (Dataset, group, attribute, and named datype access property lists
4795 * are sub-classes of link access property lists -QAK)
4796 */
4797 if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) &&
4798 TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER))
4799 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist")
4800
4801 /* set property to either TRUE if > 0, or FALSE otherwise */
4802 if (is_collective)
4803 coll_meta_read = H5P_USER_TRUE;
4804 else
4805 coll_meta_read = H5P_USER_FALSE;
4806
4807 /* Get the plist structure */
4808 if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
4809 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4810
4811 /* Set values */
4812 if (H5P_set(plist, H5_COLL_MD_READ_FLAG_NAME, &coll_meta_read) < 0)
4813 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata read flag")
4814
4815 done:
4816 FUNC_LEAVE_API(ret_value)
4817 } /* end H5Pset_all_coll_metadata_ops() */
4818
4819 /*-------------------------------------------------------------------------
4820 * Function: H5Pget_all_coll_metadata_ops
4821 *
4822 * Purpose: Gets information about collective metadata read mode.
4823 *
4824 * Note: This routine accepts file access property lists, link
4825 * access property lists, attribute access property lists,
4826 * dataset access property lists, group access property lists,
4827 * named datatype access property lists,
4828 * and dataset transfer property lists.
4829 *
4830 * Return: Non-negative on success/Negative on failure
4831 *
4832 * Programmer: Mohamad Chaarawi
4833 * Sunday, June 21, 2015
4834 *
4835 *-------------------------------------------------------------------------
4836 */
4837 herr_t
H5Pget_all_coll_metadata_ops(hid_t plist_id,hbool_t * is_collective)4838 H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective)
4839 {
4840 herr_t ret_value = SUCCEED; /* return value */
4841
4842 FUNC_ENTER_API(FAIL)
4843 H5TRACE2("e", "i*b", plist_id, is_collective);
4844
4845 /* Compare the property list's class against the other class */
4846 /* (Dataset, group, attribute, and named datype access property lists
4847 * are sub-classes of link access property lists -QAK)
4848 */
4849 if (TRUE != H5P_isa_class(plist_id, H5P_LINK_ACCESS) &&
4850 TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS) && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER))
4851 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist")
4852
4853 /* Get value */
4854 if (is_collective) {
4855 H5P_coll_md_read_flag_t
4856 internal_flag; /* property setting. we need to convert to either TRUE or FALSE */
4857 H5P_genplist_t *plist; /* Property list pointer */
4858
4859 /* Get the plist structure */
4860 if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
4861 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4862
4863 if (H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &internal_flag) < 0)
4864 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core collective metadata read flag")
4865
4866 if (internal_flag < 0)
4867 *is_collective = FALSE;
4868 else
4869 *is_collective = (hbool_t)internal_flag;
4870 } /* end if */
4871
4872 done:
4873 FUNC_LEAVE_API(ret_value)
4874 } /* H5Pget_all_coll_metadata_ops */
4875
4876 /*-------------------------------------------------------------------------
4877 * Function: H5Pset_coll_metadata_write
4878 *
4879 * Purpose: Tell the library whether the metadata write operations will
4880 * be done collectively (1) or not (0). Default is collective.
4881 *
4882 * Return: Non-negative on success/Negative on failure
4883 *
4884 * Programmer: Mohamad Chaarawi
4885 * Sunday, June 21, 2015
4886 *
4887 *-------------------------------------------------------------------------
4888 */
4889 herr_t
H5Pset_coll_metadata_write(hid_t plist_id,hbool_t is_collective)4890 H5Pset_coll_metadata_write(hid_t plist_id, hbool_t is_collective)
4891 {
4892 H5P_genplist_t *plist; /* Property list pointer */
4893 herr_t ret_value = SUCCEED; /* return value */
4894
4895 FUNC_ENTER_API(FAIL)
4896 H5TRACE2("e", "ib", plist_id, is_collective);
4897
4898 /* Compare the property list's class against the other class */
4899 if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
4900 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist")
4901
4902 /* Get the plist structure */
4903 if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
4904 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4905
4906 /* Set values */
4907 if (H5P_set(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &is_collective) < 0)
4908 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata write flag")
4909
4910 done:
4911 FUNC_LEAVE_API(ret_value)
4912 } /* end H5Pset_coll_metadata_write() */
4913
4914 /*-------------------------------------------------------------------------
4915 * Function: H5Pget_mpi_params
4916 *
4917 * Purpose: Gets the MPI communicator and info stored in the fapl.
4918 *
4919 * Return: Non-negative on success/Negative on failure
4920 *
4921 * Programmer: Dana Robinson
4922 * August 2019
4923 *
4924 *-------------------------------------------------------------------------
4925 */
4926 herr_t
H5Pget_mpi_params(hid_t plist_id,MPI_Comm * comm,MPI_Info * info)4927 H5Pget_mpi_params(hid_t plist_id, MPI_Comm *comm, MPI_Info *info)
4928 {
4929 H5P_genplist_t *plist; /* Property list pointer */
4930 herr_t ret_value = SUCCEED; /* return value */
4931
4932 FUNC_ENTER_API(FAIL)
4933 H5TRACE3("e", "i*Mc*Mi", plist_id, comm, info);
4934
4935 /* Make sure that the property list is a fapl */
4936 if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
4937 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist")
4938
4939 /* Get the plist structure */
4940 if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
4941 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4942
4943 /* Get the properties */
4944 if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, comm) < 0)
4945 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI communicator from plist")
4946 if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, info) < 0)
4947 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI info from plist")
4948
4949 done:
4950 FUNC_LEAVE_API(ret_value)
4951 } /* end H5Pget_mpi_params() */
4952
4953 /*-------------------------------------------------------------------------
4954 * Function: H5Pset_mpi_params
4955 *
4956 * Purpose: Set the MPI communicator and info
4957 *
4958 * Return: Non-negative on success/Negative on failure
4959 *
4960 * Programmer: Dana Robinson
4961 * August 2019
4962 *
4963 *-------------------------------------------------------------------------
4964 */
4965 herr_t
H5Pset_mpi_params(hid_t plist_id,MPI_Comm comm,MPI_Info info)4966 H5Pset_mpi_params(hid_t plist_id, MPI_Comm comm, MPI_Info info)
4967 {
4968 H5P_genplist_t *plist; /* Property list pointer */
4969 herr_t ret_value = SUCCEED; /* return value */
4970
4971 FUNC_ENTER_API(FAIL)
4972 H5TRACE3("e", "iMcMi", plist_id, comm, info);
4973
4974 /* Make sure the MPI communicator is valid */
4975 if (MPI_COMM_NULL == comm)
4976 HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "not a valid argument")
4977
4978 /* Make sure that the property list is a fapl */
4979 if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
4980 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not a file access plist")
4981
4982 /* Get the plist structure */
4983 if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
4984 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
4985
4986 /* Set values */
4987 if (H5P_set(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0)
4988 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI communicator")
4989 if (H5P_set(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0)
4990 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI info object")
4991
4992 done:
4993 FUNC_LEAVE_API(ret_value)
4994 } /* end H5Pset_mpi_params() */
4995
4996 /*-------------------------------------------------------------------------
4997 * Function: H5P__facc_mpi_comm_set
4998 *
4999 * Purpose: Copies an MPI comminicator property when it's set for a property list
5000 *
5001 * Return: Success: Non-negative
5002 * Failure: Negative
5003 *
5004 *-------------------------------------------------------------------------
5005 */
5006 static herr_t
H5P__facc_mpi_comm_set(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5007 H5P__facc_mpi_comm_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5008 size_t H5_ATTR_UNUSED size, void *value)
5009 {
5010 MPI_Comm *comm = (MPI_Comm *)value;
5011 MPI_Comm comm_tmp = MPI_COMM_NULL;
5012 herr_t ret_value = SUCCEED;
5013
5014 FUNC_ENTER_STATIC
5015
5016 /* Make a copy of the MPI communicator */
5017 if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0)
5018 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator")
5019
5020 done:
5021 /* Copy the communicator to the in/out parameter */
5022 if (ret_value != SUCCEED)
5023 *comm = MPI_COMM_NULL;
5024 else
5025 *comm = comm_tmp;
5026
5027 FUNC_LEAVE_NOAPI(ret_value)
5028 } /* end H5P__facc_mpi_comm_set() */
5029
5030 /*-------------------------------------------------------------------------
5031 * Function: H5P__facc_mpi_comm_get
5032 *
5033 * Purpose: Copies an MPI comminicator property when it's retrieved from a property list
5034 *
5035 * Return: Success: Non-negative
5036 * Failure: Negative
5037 *
5038 *-------------------------------------------------------------------------
5039 */
5040 static herr_t
H5P__facc_mpi_comm_get(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5041 H5P__facc_mpi_comm_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5042 size_t H5_ATTR_UNUSED size, void *value)
5043 {
5044 MPI_Comm *comm = (MPI_Comm *)value;
5045 MPI_Comm comm_tmp = MPI_COMM_NULL;
5046 herr_t ret_value = SUCCEED;
5047
5048 FUNC_ENTER_STATIC
5049
5050 /* Make a copy of the MPI communicator */
5051 if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0)
5052 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator")
5053
5054 done:
5055 /* Copy the communicator to the out parameter */
5056 if (ret_value != SUCCEED)
5057 *comm = MPI_COMM_NULL;
5058 else
5059 *comm = comm_tmp;
5060
5061 FUNC_LEAVE_NOAPI(ret_value)
5062 } /* end H5P__facc_mpi_comm_get() */
5063
5064 /*-------------------------------------------------------------------------
5065 * Function: H5P__facc_mpi_comm_del
5066 *
5067 * Purpose: Frees an MPI communicator property
5068 *
5069 * Return: Success: Non-negative
5070 * Failure: Negative
5071 *
5072 *-------------------------------------------------------------------------
5073 */
5074 static herr_t
H5P__facc_mpi_comm_del(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5075 H5P__facc_mpi_comm_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5076 size_t H5_ATTR_UNUSED size, void *value)
5077 {
5078 MPI_Comm *comm = (MPI_Comm *)value;
5079 herr_t ret_value = SUCCEED;
5080
5081 FUNC_ENTER_STATIC
5082
5083 /* Free the MPI communicator */
5084 if (H5_mpi_comm_free(comm) < 0)
5085 HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator")
5086
5087 done:
5088 FUNC_LEAVE_NOAPI(ret_value)
5089 } /* end H5P__facc_mpi_comm_del() */
5090
5091 /*-------------------------------------------------------------------------
5092 * Function: H5P__facc_mpi_comm_copy
5093 *
5094 * Purpose: Copy callback for the MPI communicator property.
5095 *
5096 * Return: Success: Non-negative
5097 * Failure: Negative
5098 *
5099 *-------------------------------------------------------------------------
5100 */
5101 static herr_t
H5P__facc_mpi_comm_copy(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5102 H5P__facc_mpi_comm_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5103 {
5104 MPI_Comm *comm = (MPI_Comm *)value;
5105 MPI_Comm comm_tmp = MPI_COMM_NULL;
5106 herr_t ret_value = SUCCEED;
5107
5108 FUNC_ENTER_STATIC
5109
5110 /* Make a copy of the MPI communicator */
5111 if (H5_mpi_comm_dup(*comm, &comm_tmp) < 0)
5112 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI communicator")
5113
5114 done:
5115 /* Copy the communicator to the in/out parameter */
5116 if (ret_value != SUCCEED)
5117 *comm = MPI_COMM_NULL;
5118 else
5119 *comm = comm_tmp;
5120
5121 FUNC_LEAVE_NOAPI(ret_value)
5122 } /* end H5P__facc_mpi_comm_copy() */
5123
5124 /*-------------------------------------------------------------------------
5125 * Function: H5P__facc_mpi_comm_cmp
5126 *
5127 * Purpose: Callback routine which is called whenever the MPI
5128 * communicator property in the file access property list
5129 * is compared.
5130 *
5131 * Return: positive if VALUE1 is greater than VALUE2, negative if
5132 * VALUE2 is greater than VALUE1 and zero if VALUE1 and
5133 * VALUE2 are equal.
5134 *
5135 *-------------------------------------------------------------------------
5136 */
5137 static int
H5P__facc_mpi_comm_cmp(const void * _comm1,const void * _comm2,size_t H5_ATTR_UNUSED size)5138 H5P__facc_mpi_comm_cmp(const void *_comm1, const void *_comm2, size_t H5_ATTR_UNUSED size)
5139 {
5140 const MPI_Comm *comm1 = (const MPI_Comm *)_comm1;
5141 const MPI_Comm *comm2 = (const MPI_Comm *)_comm2;
5142 int ret_value = 0;
5143
5144 FUNC_ENTER_STATIC
5145
5146 /* Compare the MPI communicators */
5147 if (H5_mpi_comm_cmp(*comm1, *comm2, &ret_value) < 0)
5148 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI communicator")
5149
5150 done:
5151 FUNC_LEAVE_NOAPI(ret_value)
5152 } /* end H5P__facc_mpi_comm_cmp() */
5153
5154 /*-------------------------------------------------------------------------
5155 * Function: H5P__facc_mpi_comm_close
5156 *
5157 * Purpose: Close callback for the MPI communicator property.
5158 *
5159 * Return: Success: Non-negative
5160 * Failure: Negative
5161 *
5162 *-------------------------------------------------------------------------
5163 */
5164 static herr_t
H5P__facc_mpi_comm_close(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5165 H5P__facc_mpi_comm_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5166 {
5167 MPI_Comm *comm = (MPI_Comm *)value;
5168 herr_t ret_value = SUCCEED;
5169
5170 FUNC_ENTER_STATIC
5171
5172 /* Free the MPI communicator */
5173 if (H5_mpi_comm_free(comm) < 0)
5174 HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI communicator")
5175
5176 done:
5177 FUNC_LEAVE_NOAPI(ret_value)
5178 } /* end H5P__facc_mpi_comm_close() */
5179
5180 /*-------------------------------------------------------------------------
5181 * Function: H5P__facc_mpi_info_set
5182 *
5183 * Purpose: Copies an MPI info object property when it's set for a property list
5184 *
5185 * Return: Success: Non-negative
5186 * Failure: Negative
5187 *
5188 *-------------------------------------------------------------------------
5189 */
5190 static herr_t
H5P__facc_mpi_info_set(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5191 H5P__facc_mpi_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5192 size_t H5_ATTR_UNUSED size, void *value)
5193 {
5194 MPI_Info *info = (MPI_Info *)value;
5195 MPI_Info info_tmp = MPI_INFO_NULL;
5196 herr_t ret_value = SUCCEED;
5197
5198 FUNC_ENTER_STATIC
5199
5200 /* Make a copy of the MPI info object */
5201 if (H5_mpi_info_dup(*info, &info_tmp) < 0)
5202 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object")
5203
5204 done:
5205 /* Copy the info object to the in/out parameter */
5206 if (ret_value != SUCCEED)
5207 *info = MPI_INFO_NULL;
5208 else
5209 *info = info_tmp;
5210
5211 FUNC_LEAVE_NOAPI(ret_value)
5212 } /* end H5P__facc_mpi_info_set() */
5213
5214 /*-------------------------------------------------------------------------
5215 * Function: H5P__facc_mpi_info_get
5216 *
5217 * Purpose: Copies an MPI comminicator property when it's retrieved from a property list
5218 *
5219 * Return: Success: Non-negative
5220 * Failure: Negative
5221 *
5222 *-------------------------------------------------------------------------
5223 */
5224 static herr_t
H5P__facc_mpi_info_get(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5225 H5P__facc_mpi_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5226 size_t H5_ATTR_UNUSED size, void *value)
5227 {
5228 MPI_Info *info = (MPI_Info *)value;
5229 MPI_Info info_tmp = MPI_INFO_NULL;
5230 herr_t ret_value = SUCCEED;
5231
5232 FUNC_ENTER_STATIC
5233
5234 /* Make a copy of the MPI communicator */
5235 if (H5_mpi_info_dup(*info, &info_tmp) < 0)
5236 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object")
5237
5238 done:
5239 /* Copy the info object to the out parameter */
5240 if (ret_value != SUCCEED)
5241 *info = MPI_INFO_NULL;
5242 else
5243 *info = info_tmp;
5244
5245 FUNC_LEAVE_NOAPI(ret_value)
5246 } /* end H5P__facc_mpi_info_get() */
5247
5248 /*-------------------------------------------------------------------------
5249 * Function: H5P__facc_mpi_info_del
5250 *
5251 * Purpose: Frees an MPI info object property
5252 *
5253 * Return: Success: Non-negative
5254 * Failure: Negative
5255 *
5256 *-------------------------------------------------------------------------
5257 */
5258 static herr_t
H5P__facc_mpi_info_del(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5259 H5P__facc_mpi_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
5260 size_t H5_ATTR_UNUSED size, void *value)
5261 {
5262 MPI_Info *info = (MPI_Info *)value;
5263 herr_t ret_value = SUCCEED;
5264
5265 FUNC_ENTER_STATIC
5266
5267 /* Free the MPI info object */
5268 if (H5_mpi_info_free(info) < 0)
5269 HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object")
5270
5271 done:
5272 FUNC_LEAVE_NOAPI(ret_value)
5273 } /* end H5P__facc_mpi_info_del() */
5274
5275 /*-------------------------------------------------------------------------
5276 * Function: H5P__facc_mpi_info_copy
5277 *
5278 * Purpose: Copy callback for the MPI info object property.
5279 *
5280 * Return: Success: Non-negative
5281 * Failure: Negative
5282 *
5283 *-------------------------------------------------------------------------
5284 */
5285 static herr_t
H5P__facc_mpi_info_copy(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5286 H5P__facc_mpi_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5287 {
5288 MPI_Info *info = (MPI_Info *)value;
5289 MPI_Info info_tmp = MPI_INFO_NULL;
5290 herr_t ret_value = SUCCEED;
5291
5292 FUNC_ENTER_STATIC
5293
5294 /* Make a copy of the MPI info object */
5295 if (H5_mpi_info_dup(*info, &info_tmp) < 0)
5296 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to duplicate MPI info object")
5297
5298 done:
5299 /* Copy the info object to the in/out parameter */
5300 if (ret_value != SUCCEED)
5301 *info = MPI_INFO_NULL;
5302 else
5303 *info = info_tmp;
5304
5305 FUNC_LEAVE_NOAPI(ret_value)
5306 } /* end H5P__facc_mpi_info_copy() */
5307
5308 /*-------------------------------------------------------------------------
5309 * Function: H5P__facc_mpi_info_cmp
5310 *
5311 * Purpose: Callback routine which is called whenever the MPI
5312 * info object property in the file access property list
5313 * is compared.
5314 *
5315 * Return: positive if VALUE1 is greater than VALUE2, negative if
5316 * VALUE2 is greater than VALUE1 and zero if VALUE1 and
5317 * VALUE2 are equal.
5318 *
5319 *-------------------------------------------------------------------------
5320 */
5321 static int
H5P__facc_mpi_info_cmp(const void * _info1,const void * _info2,size_t H5_ATTR_UNUSED size)5322 H5P__facc_mpi_info_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size)
5323 {
5324 const MPI_Info *info1 = (const MPI_Info *)_info1;
5325 const MPI_Info *info2 = (const MPI_Info *)_info2;
5326 int ret_value = 0;
5327
5328 FUNC_ENTER_STATIC
5329
5330 /* Compare the MPI info objects */
5331 if (H5_mpi_info_cmp(*info1, *info2, &ret_value) < 0)
5332 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, 0, "unable to compare MPI info objects")
5333
5334 done:
5335 FUNC_LEAVE_NOAPI(ret_value)
5336 } /* end H5P__facc_mpi_info_cmp() */
5337
5338 /*-------------------------------------------------------------------------
5339 * Function: H5P__facc_mpi_info_close
5340 *
5341 * Purpose: Close callback for the MPI info object property.
5342 *
5343 * Return: Success: Non-negative
5344 * Failure: Negative
5345 *
5346 *-------------------------------------------------------------------------
5347 */
5348 static herr_t
H5P__facc_mpi_info_close(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5349 H5P__facc_mpi_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5350 {
5351 MPI_Info *info = (MPI_Info *)value;
5352 herr_t ret_value = SUCCEED;
5353
5354 FUNC_ENTER_STATIC
5355
5356 /* Free the MPI info object */
5357 if (H5_mpi_info_free(info) < 0)
5358 HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to free MPI info object")
5359
5360 done:
5361 FUNC_LEAVE_NOAPI(ret_value)
5362 } /* end H5P__facc_mpi_info_close() */
5363
5364 /*-------------------------------------------------------------------------
5365 * Function: H5Pget_coll_metadata_write
5366 *
5367 * Purpose: Gets information about collective metadata write mode.
5368 *
5369 * Return: Non-negative on success/Negative on failure
5370 *
5371 * Programmer: Mohamad Chaarawi
5372 * Sunday, June 21, 2015
5373 *
5374 *-------------------------------------------------------------------------
5375 */
5376 herr_t
H5Pget_coll_metadata_write(hid_t plist_id,hbool_t * is_collective)5377 H5Pget_coll_metadata_write(hid_t plist_id, hbool_t *is_collective)
5378 {
5379 H5P_genplist_t *plist; /* Property list pointer */
5380 herr_t ret_value = SUCCEED; /* return value */
5381
5382 FUNC_ENTER_API(FAIL)
5383 H5TRACE2("e", "i*b", plist_id, is_collective);
5384
5385 /* Compare the property list's class against the other class */
5386 if (TRUE != H5P_isa_class(plist_id, H5P_FILE_ACCESS))
5387 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property list is not an access plist")
5388
5389 /* Get the plist structure */
5390 if (NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
5391 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
5392
5393 if (H5P_get(plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, is_collective) < 0)
5394 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get collective metadata write flag")
5395
5396 done:
5397 FUNC_LEAVE_API(ret_value)
5398 } /* end H5Pget_coll_metadata_write() */
5399 #endif /* H5_HAVE_PARALLEL */
5400
5401 /*-------------------------------------------------------------------------
5402 * Function: H5Pset_page_buffer_size
5403 *
5404 * Purpose: Set the maximum page buffering size. This has to be a
5405 * multiple of the page allocation size which must be enabled;
5406 * otherwise file create/open will fail.
5407 *
5408 * Return: Non-negative on success/Negative on failure
5409 *
5410 * Programmer: Mohamad Chaarawi
5411 * June 2015
5412 *
5413 *-------------------------------------------------------------------------
5414 */
5415 herr_t
H5Pset_page_buffer_size(hid_t plist_id,size_t buf_size,unsigned min_meta_perc,unsigned min_raw_perc)5416 H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_perc, unsigned min_raw_perc)
5417 {
5418 H5P_genplist_t *plist; /* Property list pointer */
5419 herr_t ret_value = SUCCEED; /* return value */
5420
5421 FUNC_ENTER_API(FAIL)
5422 H5TRACE4("e", "izIuIu", plist_id, buf_size, min_meta_perc, min_raw_perc);
5423
5424 /* Get the plist structure */
5425 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
5426 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
5427
5428 if (min_meta_perc > 100)
5429 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
5430 "Minimum metadata fractions must be between 0 and 100 inclusive")
5431 if (min_raw_perc > 100)
5432 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
5433 "Minimum rawdata fractions must be between 0 and 100 inclusive")
5434
5435 if (min_meta_perc + min_raw_perc > 100)
5436 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
5437 "Sum of minimum metadata and raw data fractions can't be bigger than 100");
5438
5439 /* Set size */
5440 if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &buf_size) < 0)
5441 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set page buffer size")
5442 if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &min_meta_perc) < 0)
5443 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min metadata entries")
5444 if (H5P_set(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &min_raw_perc) < 0)
5445 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set percentage of min rawdata entries")
5446
5447 done:
5448 FUNC_LEAVE_API(ret_value)
5449 } /* end H5Pset_page_buffer_size() */
5450
5451 /*-------------------------------------------------------------------------
5452 * Function: H5Pget_page_buffer_size
5453 *
5454 * Purpose: Retrieves the maximum page buffer size.
5455 *
5456 * Return: Non-negative on success/Negative on failure
5457 *
5458 * Programmer: Mohamad Chaarawi
5459 * June 2015
5460 *
5461 *-------------------------------------------------------------------------
5462 */
5463 herr_t
H5Pget_page_buffer_size(hid_t plist_id,size_t * buf_size,unsigned * min_meta_perc,unsigned * min_raw_perc)5464 H5Pget_page_buffer_size(hid_t plist_id, size_t *buf_size, unsigned *min_meta_perc, unsigned *min_raw_perc)
5465 {
5466 H5P_genplist_t *plist; /* Property list pointer */
5467 herr_t ret_value = SUCCEED; /* return value */
5468
5469 FUNC_ENTER_API(FAIL)
5470 H5TRACE4("e", "i*z*Iu*Iu", plist_id, buf_size, min_meta_perc, min_raw_perc);
5471
5472 /* Get the plist structure */
5473 if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
5474 HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
5475
5476 /* Get size */
5477
5478 if (buf_size)
5479 if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, buf_size) < 0)
5480 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer size")
5481 if (min_meta_perc)
5482 if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, min_meta_perc) < 0)
5483 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum metadata percent")
5484 if (min_raw_perc)
5485 if (H5P_get(plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, min_raw_perc) < 0)
5486 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get page buffer minimum raw data percent")
5487
5488 done:
5489 FUNC_LEAVE_API(ret_value)
5490 } /* end H5Pget_page_buffer_size() */
5491
5492 /*-------------------------------------------------------------------------
5493 * Function: H5P_set_vol
5494 *
5495 * Purpose: Set the VOL connector for a file access property list
5496 * (PLIST_ID). The VOL properties will
5497 * be copied into the property list and the reference count on
5498 * the VOL will be incremented.
5499 *
5500 * Return: SUCCEED/FAIL
5501 *
5502 *-------------------------------------------------------------------------
5503 */
5504 herr_t
H5P_set_vol(H5P_genplist_t * plist,hid_t vol_id,const void * vol_info)5505 H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info)
5506 {
5507 herr_t ret_value = SUCCEED; /* Return value */
5508
5509 FUNC_ENTER_NOAPI(FAIL)
5510
5511 if (NULL == H5I_object_verify(vol_id, H5I_VOL))
5512 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID")
5513
5514 if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
5515 H5VL_connector_prop_t vol_prop; /* Property for VOL ID & info */
5516
5517 /* Prepare the VOL connector property */
5518 vol_prop.connector_id = vol_id;
5519 vol_prop.connector_info = vol_info;
5520
5521 /* Set the connector ID & info property */
5522 if (H5P_set(plist, H5F_ACS_VOL_CONN_NAME, &vol_prop) < 0)
5523 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info")
5524 } /* end if */
5525 else
5526 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
5527
5528 done:
5529 FUNC_LEAVE_NOAPI(ret_value)
5530 } /* end H5P_set_vol() */
5531
5532 /*-------------------------------------------------------------------------
5533 * Function: H5P_reset_vol_class
5534 *
5535 * Purpose: Change the VOL connector for a file access property class.
5536 *
5537 * Note: The VOL property will be copied into the property list and
5538 * the reference count on the previous VOL will _NOT_ be decremented.
5539 * The reference count on the new VOL will _NOT_ be incremented.
5540 *
5541 * Return: SUCCEED/FAIL
5542 *
5543 * Programmer: Quincey Koziol
5544 * March 8, 2019
5545 *
5546 *-------------------------------------------------------------------------
5547 */
5548 herr_t
H5P_reset_vol_class(const H5P_genclass_t * pclass,const H5VL_connector_prop_t * vol_prop)5549 H5P_reset_vol_class(const H5P_genclass_t *pclass, const H5VL_connector_prop_t *vol_prop)
5550 {
5551 H5VL_connector_prop_t old_vol_prop; /* Previous VOL connector property */
5552 herr_t ret_value = SUCCEED; /* Return value */
5553
5554 FUNC_ENTER_NOAPI(FAIL)
5555
5556 /* Get the connector ID & info property */
5557 if (H5P__class_get(pclass, H5F_ACS_VOL_CONN_NAME, &old_vol_prop) < 0)
5558 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector ID & info")
5559
5560 /* Set the new connector ID & info property */
5561 if (H5P__class_set(pclass, H5F_ACS_VOL_CONN_NAME, vol_prop) < 0)
5562 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info")
5563
5564 done:
5565 FUNC_LEAVE_NOAPI(ret_value)
5566 } /* end H5P_set_vol_class() */
5567
5568 /*-------------------------------------------------------------------------
5569 * Function: H5Pset_vol
5570 *
5571 * Purpose: Set the file VOL connector (VOL_ID) for a file access
5572 * property list (PLIST_ID)
5573 *
5574 * Return: Success: Non-negative
5575 * Failure: Negative
5576 *
5577 *-------------------------------------------------------------------------
5578 */
5579 herr_t
H5Pset_vol(hid_t plist_id,hid_t new_vol_id,const void * new_vol_info)5580 H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info)
5581 {
5582 H5P_genplist_t *plist; /* Property list pointer */
5583 herr_t ret_value = SUCCEED; /* Return value */
5584
5585 FUNC_ENTER_API(FAIL)
5586 H5TRACE3("e", "ii*x", plist_id, new_vol_id, new_vol_info);
5587
5588 /* Check arguments */
5589 if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
5590 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
5591 if (NULL == H5I_object_verify(new_vol_id, H5I_VOL))
5592 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file VOL ID")
5593
5594 /* Set the VOL */
5595 if (H5P_set_vol(plist, new_vol_id, new_vol_info) < 0)
5596 HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL")
5597
5598 done:
5599 FUNC_LEAVE_API(ret_value)
5600 } /* end H5Pset_vol() */
5601
5602 /*-------------------------------------------------------------------------
5603 * Function: H5Pget_vol_id
5604 *
5605 * Purpose: Returns the ID of the current VOL connector.
5606 * This ID should be closed with H5VLclose().
5607 *
5608 * Return: Success: Non-negative
5609 * Failure: Negative
5610 *
5611 *-------------------------------------------------------------------------
5612 */
5613 herr_t
H5Pget_vol_id(hid_t plist_id,hid_t * vol_id)5614 H5Pget_vol_id(hid_t plist_id, hid_t *vol_id)
5615 {
5616 H5P_genplist_t *plist; /* Property list pointer */
5617 herr_t ret_value = SUCCEED; /* Return value */
5618
5619 FUNC_ENTER_API(FAIL)
5620 H5TRACE2("e", "i*i", plist_id, vol_id);
5621
5622 /* Get property list for ID */
5623 if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
5624 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
5625
5626 /* Get the current VOL ID */
5627 if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
5628 H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
5629
5630 /* Get the connector property */
5631 if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
5632 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector info")
5633
5634 /* Increment the VOL ID's ref count */
5635 if (H5I_inc_ref(connector_prop.connector_id, TRUE) < 0)
5636 HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID")
5637
5638 /* Set the connector ID to return */
5639 *vol_id = connector_prop.connector_id;
5640 } /* end if */
5641 else
5642 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
5643
5644 done:
5645 FUNC_LEAVE_API(ret_value)
5646 } /* end H5Pget_vol_id() */
5647
5648 /*-------------------------------------------------------------------------
5649 * Function: H5Pget_vol_info
5650 *
5651 * Purpose: Returns a copy of the VOL info for a connector.
5652 * This information should be freed with H5VLfree_connector_info.
5653 *
5654 * Return: Success: Non-negative
5655 * Failure: Negative
5656 *
5657 *-------------------------------------------------------------------------
5658 */
5659 herr_t
H5Pget_vol_info(hid_t plist_id,void ** vol_info)5660 H5Pget_vol_info(hid_t plist_id, void **vol_info)
5661 {
5662 H5P_genplist_t *plist; /* Property list pointer */
5663 herr_t ret_value = SUCCEED; /* Return value */
5664
5665 FUNC_ENTER_API(FAIL)
5666 H5TRACE2("e", "i**x", plist_id, vol_info);
5667
5668 /* Get property list for ID */
5669 if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
5670 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
5671
5672 /* Get the current VOL info */
5673 if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
5674 void * new_connector_info = NULL; /* Copy of connector info */
5675 H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */
5676
5677 /* Get the connector property */
5678 if (H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0)
5679 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property")
5680
5681 /* Copy connector info, if it exists */
5682 if (connector_prop.connector_info) {
5683 H5VL_class_t *connector; /* Pointer to connector */
5684
5685 /* Retrieve the connector for the ID */
5686 if (NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id)))
5687 HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID")
5688
5689 /* Allocate and copy connector info */
5690 if (H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0)
5691 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed")
5692 } /* end if */
5693
5694 /* Set the connector info */
5695 *vol_info = new_connector_info;
5696 } /* end if */
5697 else
5698 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
5699
5700 done:
5701 FUNC_LEAVE_API(ret_value)
5702 } /* end H5Pget_vol_info() */
5703
5704 /*-------------------------------------------------------------------------
5705 * Function: H5P__facc_vol_create
5706 *
5707 connectorose: Create callback for the VOL connector ID & info property.
5708 *
5709 * Return: Success: Non-negative
5710 * Failure: Negative
5711 *
5712 *-------------------------------------------------------------------------
5713 */
5714 static herr_t
H5P__facc_vol_create(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5715 H5P__facc_vol_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5716 {
5717 herr_t ret_value = SUCCEED; /* Return value */
5718
5719 FUNC_ENTER_STATIC
5720
5721 /* Make copy of the VOL connector */
5722 if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0)
5723 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector")
5724
5725 done:
5726 FUNC_LEAVE_NOAPI(ret_value)
5727 } /* end H5P__facc_vol_create() */
5728
5729 /*-------------------------------------------------------------------------
5730 * Function: H5P__facc_vol_set
5731 *
5732 * Purpose: Copies a VOL connector property when it's set for a property list
5733 *
5734 * Return: Success: Non-negative
5735 * Failure: Negative
5736 *
5737 *-------------------------------------------------------------------------
5738 */
5739 static herr_t
H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5740 H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
5741 void *value)
5742 {
5743 herr_t ret_value = SUCCEED; /* Return value */
5744
5745 FUNC_ENTER_STATIC
5746
5747 /* Sanity check */
5748 HDassert(value);
5749
5750 /* Make copy of VOL connector ID & info */
5751 if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0)
5752 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector")
5753
5754 done:
5755 FUNC_LEAVE_NOAPI(ret_value)
5756 } /* end H5P__facc_vol_set() */
5757
5758 /*-------------------------------------------------------------------------
5759 * Function: H5P__facc_vol_get
5760 *
5761 * Purpose: Copies a VOL connector property when it's retrieved from a property list
5762 *
5763 * Return: Success: Non-negative
5764 * Failure: Negative
5765 *
5766 *-------------------------------------------------------------------------
5767 */
5768 static herr_t
H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5769 H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
5770 void *value)
5771 {
5772 herr_t ret_value = SUCCEED; /* Return value */
5773
5774 FUNC_ENTER_STATIC
5775
5776 /* Sanity check */
5777 HDassert(value);
5778
5779 /* Make copy of VOL connector */
5780 if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0)
5781 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector")
5782
5783 done:
5784 FUNC_LEAVE_NOAPI(ret_value)
5785 } /* end H5P__facc_vol_get() */
5786
5787 /*-------------------------------------------------------------------------
5788 * Function: H5P__facc_vol_del
5789 *
5790 * Purpose: Frees memory used to store the VOL connector ID & info property
5791 *
5792 * Return: Success: Non-negative
5793 * Failure: Negative
5794 *
5795 *-------------------------------------------------------------------------
5796 */
5797 static herr_t
H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id,const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5798 H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
5799 void *value)
5800 {
5801 herr_t ret_value = SUCCEED; /* Return value */
5802
5803 FUNC_ENTER_STATIC
5804
5805 /* Free the VOL connector ID & info */
5806 if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0)
5807 HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector")
5808
5809 done:
5810 FUNC_LEAVE_NOAPI(ret_value)
5811 } /* end H5P__facc_vol_del() */
5812
5813 /*-------------------------------------------------------------------------
5814 * Function: H5P__facc_vol_copy
5815 *
5816 * Purpose: Copy callback for the VOL connector ID & info property.
5817 *
5818 * Return: Success: Non-negative
5819 * Failure: Negative
5820 *
5821 *-------------------------------------------------------------------------
5822 */
5823 static herr_t
H5P__facc_vol_copy(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5824 H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5825 {
5826 herr_t ret_value = SUCCEED; /* Return value */
5827
5828 FUNC_ENTER_STATIC
5829
5830 /* Make copy of VOL connector */
5831 if (H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0)
5832 HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector")
5833
5834 done:
5835 FUNC_LEAVE_NOAPI(ret_value)
5836 } /* end H5P__facc_vol_copy() */
5837
5838 /*-------------------------------------------------------------------------
5839 * Function: H5P__facc_vol_cmp
5840 *
5841 * Purpose: Callback routine which is called whenever the VOL connector
5842 * ID & info property in the file access property list
5843 * is compared.
5844 *
5845 * Return: positive if VALUE1 is greater than VALUE2, negative if
5846 * VALUE2 is greater than VALUE1 and zero if VALUE1 and
5847 * VALUE2 are equal.
5848 *
5849 *-------------------------------------------------------------------------
5850 */
5851 static int
H5P__facc_vol_cmp(const void * _info1,const void * _info2,size_t H5_ATTR_UNUSED size)5852 H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size)
5853 {
5854 const H5VL_connector_prop_t *info1 =
5855 (const H5VL_connector_prop_t *)_info1; /* Create local aliases for values */
5856 const H5VL_connector_prop_t *info2 = (const H5VL_connector_prop_t *)_info2;
5857 H5VL_class_t * cls1, *cls2; /* connector class for each property */
5858 int cmp_value = 0; /* Value from comparison */
5859 herr_t H5_ATTR_NDEBUG_UNUSED status; /* Status from info comparison */
5860 int ret_value = 0; /* Return value */
5861
5862 FUNC_ENTER_STATIC_NOERR
5863
5864 /* Sanity check */
5865 HDassert(info1);
5866 HDassert(info2);
5867 HDassert(size == sizeof(H5VL_connector_prop_t));
5868
5869 /* Compare connectors */
5870 if (NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->connector_id)))
5871 HGOTO_DONE(-1)
5872 if (NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->connector_id)))
5873 HGOTO_DONE(1)
5874 status = H5VL_cmp_connector_cls(&cmp_value, cls1, cls2);
5875 HDassert(status >= 0);
5876 if (cmp_value != 0)
5877 HGOTO_DONE(cmp_value);
5878
5879 /* At this point, we should be able to assume that we are dealing with
5880 * the same connector class struct (or a copies of the same class struct)
5881 */
5882
5883 /* Use one of the classes (cls1) info comparison routines to compare the
5884 * info objects
5885 */
5886 HDassert(cls1->info_cls.cmp == cls2->info_cls.cmp);
5887 status = H5VL_cmp_connector_info(cls1, &cmp_value, info1->connector_info, info2->connector_info);
5888 HDassert(status >= 0);
5889
5890 /* Set return value */
5891 ret_value = cmp_value;
5892
5893 done:
5894 FUNC_LEAVE_NOAPI(ret_value)
5895 } /* end H5P__facc_vol_cmp() */
5896
5897 /*-------------------------------------------------------------------------
5898 * Function: H5P__facc_vol_close
5899 *
5900 * Purpose: Close callback for the VOL connector ID & info property.
5901 *
5902 * Return: Success: Non-negative
5903 * Failure: Negative
5904 *
5905 *-------------------------------------------------------------------------
5906 */
5907 static herr_t
H5P__facc_vol_close(const char H5_ATTR_UNUSED * name,size_t H5_ATTR_UNUSED size,void * value)5908 H5P__facc_vol_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
5909 {
5910 herr_t ret_value = SUCCEED; /* Return value */
5911
5912 FUNC_ENTER_STATIC
5913
5914 /* Free the VOL connector */
5915 if (H5VL_conn_free((H5VL_connector_prop_t *)value) < 0)
5916 HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector")
5917
5918 done:
5919 FUNC_LEAVE_NOAPI(ret_value)
5920 } /* end H5P__facc_vol_close() */
5921