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