/src/hdf5/src/H5Ofsinfo.c
Line | Count | Source |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the LICENSE file, which can be found at the root of the source code * |
8 | | * distribution tree, or in https://www.hdfgroup.org/licenses. * |
9 | | * If you do not have access to either file, you may request a copy from * |
10 | | * help@hdfgroup.org. * |
11 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | | |
13 | | /*------------------------------------------------------------------------- |
14 | | * |
15 | | * Created: H5Ofsinfo.c |
16 | | * |
17 | | * Purpose: File space info message |
18 | | * |
19 | | *------------------------------------------------------------------------- |
20 | | */ |
21 | | #define H5F_FRIEND /*suppress error about including H5Fpkg */ |
22 | | #include "H5Omodule.h" /* This source code file is part of the H5O module */ |
23 | | |
24 | | #include "H5private.h" /* Generic Functions */ |
25 | | #include "H5Eprivate.h" /* Error handling */ |
26 | | #include "H5Fpkg.h" /* File access */ |
27 | | #include "H5FLprivate.h" /* Free lists */ |
28 | | #include "H5Opkg.h" /* Object headers */ |
29 | | |
30 | | /* PRIVATE PROTOTYPES */ |
31 | | static void *H5O__fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, |
32 | | size_t p_size, const uint8_t *p); |
33 | | static herr_t H5O__fsinfo_encode(H5F_t *f, bool disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p, |
34 | | const void *_mesg); |
35 | | static void *H5O__fsinfo_copy(const void *_mesg, void *_dest); |
36 | | static size_t H5O__fsinfo_size(const H5F_t *f, bool disable_shared, const void *_mesg); |
37 | | static herr_t H5O__fsinfo_free(void *mesg); |
38 | | static herr_t H5O__fsinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); |
39 | | |
40 | | /* This message derives from H5O message class */ |
41 | | const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{ |
42 | | H5O_FSINFO_ID, /* message id number */ |
43 | | "fsinfo", /* message name for debugging */ |
44 | | sizeof(H5O_fsinfo_t), /* native message size */ |
45 | | 0, /* messages are shareable? */ |
46 | | H5O__fsinfo_decode, /* decode message */ |
47 | | H5O__fsinfo_encode, /* encode message */ |
48 | | H5O__fsinfo_copy, /* copy the native value */ |
49 | | H5O__fsinfo_size, /* size of free-space manager info message */ |
50 | | NULL, /* default reset method */ |
51 | | H5O__fsinfo_free, /* free method */ |
52 | | NULL, /* file delete method */ |
53 | | NULL, /* link method */ |
54 | | NULL, /* set share method */ |
55 | | NULL, /* can share method */ |
56 | | NULL, /* pre copy native value to file */ |
57 | | NULL, /* copy native value to file */ |
58 | | NULL, /* post copy native value to file */ |
59 | | NULL, /* get creation index */ |
60 | | NULL, /* set creation index */ |
61 | | H5O__fsinfo_debug /* debug the message */ |
62 | | }}; |
63 | | |
64 | | /* Format version bounds for fsinfo message */ |
65 | | /* This message exists starting library release v1.10 */ |
66 | | static const unsigned H5O_fsinfo_ver_bounds[] = { |
67 | | H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */ |
68 | | H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */ |
69 | | H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */ |
70 | | H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V112 */ |
71 | | H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V114 */ |
72 | | H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V200 */ |
73 | | H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */ |
74 | | }; |
75 | | #define N_FSINFO_VERSION_BOUNDS H5F_LIBVER_NBOUNDS |
76 | | |
77 | | /* Declare a free list to manage the H5O_fsinfo_t struct */ |
78 | | H5FL_DEFINE_STATIC(H5O_fsinfo_t); |
79 | | |
80 | | /*------------------------------------------------------------------------- |
81 | | * Function: H5O__fsinfo_decode |
82 | | * |
83 | | * Purpose: Decode a message and return a pointer to a newly allocated one. |
84 | | * |
85 | | * Return: Success: Pointer to new message in native form |
86 | | * Failure: NULL |
87 | | *------------------------------------------------------------------------- |
88 | | */ |
89 | | static void * |
90 | | H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, |
91 | | unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) |
92 | 1 | { |
93 | 1 | H5O_fsinfo_t *fsinfo = NULL; /* File space info message */ |
94 | 1 | H5F_mem_page_t ptype; /* Memory type for iteration */ |
95 | 1 | unsigned vers; /* Message version */ |
96 | 1 | const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ |
97 | 1 | void *ret_value = NULL; |
98 | | |
99 | 1 | FUNC_ENTER_PACKAGE |
100 | | |
101 | 1 | assert(f); |
102 | 1 | assert(p); |
103 | | |
104 | | /* Allocate space for message */ |
105 | 1 | if (NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) |
106 | 0 | HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); |
107 | | |
108 | 13 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) |
109 | 12 | fsinfo->fs_addr[ptype - 1] = HADDR_UNDEF; |
110 | | |
111 | | /* Version of message */ |
112 | 1 | if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) |
113 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
114 | 1 | vers = *p++; |
115 | | |
116 | 1 | if (vers == H5O_FSINFO_VERSION_0) { |
117 | 1 | H5F_file_space_type_t strategy; /* Strategy */ |
118 | 1 | hsize_t threshold = 0; /* Threshold */ |
119 | 1 | H5FD_mem_t type; /* Memory type for iteration */ |
120 | | |
121 | 1 | fsinfo->persist = H5F_FREE_SPACE_PERSIST_DEF; |
122 | 1 | fsinfo->threshold = H5F_FREE_SPACE_THRESHOLD_DEF; |
123 | 1 | fsinfo->page_size = H5F_FILE_SPACE_PAGE_SIZE_DEF; |
124 | 1 | fsinfo->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; |
125 | 1 | fsinfo->eoa_pre_fsm_fsalloc = HADDR_UNDEF; |
126 | | |
127 | 1 | if (H5_IS_BUFFER_OVERFLOW(p, 1 + H5F_sizeof_size(f), p_end)) |
128 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
129 | 1 | strategy = (H5F_file_space_type_t)*p++; /* File space strategy */ |
130 | 1 | H5F_DECODE_LENGTH(f, p, threshold); /* Free-space section threshold */ |
131 | | |
132 | | /* Map version 0 (deprecated) to version 1 message */ |
133 | 1 | switch (strategy) { |
134 | 1 | case H5F_FILE_SPACE_ALL_PERSIST: |
135 | 1 | fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; |
136 | 1 | fsinfo->persist = true; |
137 | 1 | fsinfo->threshold = threshold; |
138 | 1 | if (HADDR_UNDEF == (fsinfo->eoa_pre_fsm_fsalloc = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) |
139 | 0 | HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file size"); |
140 | 7 | for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { |
141 | 6 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) |
142 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, |
143 | 6 | "ran off end of input buffer while decoding"); |
144 | 6 | H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type - 1])); |
145 | 6 | } |
146 | 1 | break; |
147 | | |
148 | 1 | case H5F_FILE_SPACE_ALL: |
149 | 0 | fsinfo->strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; |
150 | 0 | fsinfo->threshold = threshold; |
151 | 0 | break; |
152 | | |
153 | 0 | case H5F_FILE_SPACE_AGGR_VFD: |
154 | 0 | fsinfo->strategy = H5F_FSPACE_STRATEGY_AGGR; |
155 | 0 | break; |
156 | | |
157 | 0 | case H5F_FILE_SPACE_VFD: |
158 | 0 | fsinfo->strategy = H5F_FSPACE_STRATEGY_NONE; |
159 | 0 | break; |
160 | | |
161 | 0 | case H5F_FILE_SPACE_NTYPES: |
162 | 0 | case H5F_FILE_SPACE_DEFAULT: |
163 | 0 | default: |
164 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file space strategy"); |
165 | 1 | } |
166 | | |
167 | 1 | fsinfo->version = H5O_FSINFO_VERSION_1; |
168 | 1 | fsinfo->mapped = true; |
169 | 1 | } |
170 | 0 | else { |
171 | 0 | if (vers < H5O_FSINFO_VERSION_1) |
172 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "bad version number"); |
173 | | |
174 | 0 | fsinfo->version = vers; |
175 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, 1 + 1, p_end)) |
176 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
177 | 0 | fsinfo->strategy = (H5F_fspace_strategy_t)*p++; /* File space strategy */ |
178 | 0 | fsinfo->persist = *p++; /* Free-space persist or not */ |
179 | |
|
180 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) |
181 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
182 | 0 | H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section threshold */ |
183 | | |
184 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_size(f), p_end)) |
185 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
186 | 0 | H5F_DECODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ |
187 | | /* Basic sanity check */ |
188 | 0 | if (fsinfo->page_size == 0 || fsinfo->page_size > H5F_FILE_SPACE_PAGE_SIZE_MAX) |
189 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid page size in file space info"); |
190 | | |
191 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, 2, p_end)) |
192 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
193 | 0 | UINT16DECODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ |
194 | |
|
195 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) |
196 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
197 | 0 | H5F_addr_decode(f, &p, |
198 | 0 | &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ |
199 | | |
200 | | /* Decode addresses of free space managers, if persisting */ |
201 | 0 | if (fsinfo->persist) |
202 | 0 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) { |
203 | 0 | if (H5_IS_BUFFER_OVERFLOW(p, H5F_sizeof_addr(f), p_end)) |
204 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); |
205 | 0 | H5F_addr_decode(f, &p, &(fsinfo->fs_addr[ptype - 1])); |
206 | 0 | } |
207 | 0 | fsinfo->mapped = false; |
208 | 0 | } |
209 | | |
210 | | /* Set return value */ |
211 | 1 | ret_value = fsinfo; |
212 | | |
213 | 1 | done: |
214 | 1 | if (!ret_value && fsinfo) |
215 | 0 | H5FL_FREE(H5O_fsinfo_t, fsinfo); |
216 | | |
217 | 1 | FUNC_LEAVE_NOAPI(ret_value) |
218 | 1 | } /* end H5O__fsinfo_decode() */ |
219 | | |
220 | | /*------------------------------------------------------------------------- |
221 | | * Function: H5O__fsinfo_encode |
222 | | * |
223 | | * Purpose: Encodes a message. |
224 | | * |
225 | | * Return: Non-negative on success/Negative on failure |
226 | | * |
227 | | *------------------------------------------------------------------------- |
228 | | */ |
229 | | static herr_t |
230 | | H5O__fsinfo_encode(H5F_t *f, bool H5_ATTR_UNUSED disable_shared, size_t H5_ATTR_UNUSED p_size, uint8_t *p, |
231 | | const void *_mesg) |
232 | 0 | { |
233 | 0 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
234 | 0 | H5F_mem_page_t ptype; /* Memory type for iteration */ |
235 | |
|
236 | 0 | FUNC_ENTER_PACKAGE_NOERR |
237 | | |
238 | | /* check args */ |
239 | 0 | assert(f); |
240 | 0 | assert(p); |
241 | 0 | assert(fsinfo); |
242 | |
|
243 | 0 | *p++ = (uint8_t)fsinfo->version; /* message version */ |
244 | 0 | *p++ = (uint8_t)fsinfo->strategy; /* File space strategy */ |
245 | 0 | *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ |
246 | 0 | H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section size threshold */ |
247 | | |
248 | 0 | H5F_ENCODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ |
249 | 0 | UINT16ENCODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ |
250 | 0 | H5F_addr_encode(f, &p, fsinfo->eoa_pre_fsm_fsalloc); /* EOA before free-space header and section info */ |
251 | | |
252 | | /* Store addresses of free-space managers, if persisting */ |
253 | 0 | if (fsinfo->persist) |
254 | | /* Addresses of free-space managers */ |
255 | 0 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) |
256 | 0 | H5F_addr_encode(f, &p, fsinfo->fs_addr[ptype - 1]); |
257 | |
|
258 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
259 | 0 | } /* end H5O__fsinfo_encode() */ |
260 | | |
261 | | /*------------------------------------------------------------------------- |
262 | | * Function: H5O__fsinfo_copy |
263 | | * |
264 | | * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if |
265 | | * necessary. |
266 | | * |
267 | | * Return: Success: Ptr to _DEST |
268 | | * Failure: NULL |
269 | | * |
270 | | *------------------------------------------------------------------------- |
271 | | */ |
272 | | static void * |
273 | | H5O__fsinfo_copy(const void *_mesg, void *_dest) |
274 | 1 | { |
275 | 1 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
276 | 1 | H5O_fsinfo_t *dest = (H5O_fsinfo_t *)_dest; |
277 | 1 | void *ret_value = NULL; /* Return value */ |
278 | | |
279 | 1 | FUNC_ENTER_PACKAGE |
280 | | |
281 | | /* check args */ |
282 | 1 | assert(fsinfo); |
283 | 1 | if (!dest && NULL == (dest = H5FL_CALLOC(H5O_fsinfo_t))) |
284 | 0 | HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); |
285 | | |
286 | | /* copy */ |
287 | 1 | *dest = *fsinfo; |
288 | | |
289 | | /* Set return value */ |
290 | 1 | ret_value = dest; |
291 | | |
292 | 1 | done: |
293 | 1 | FUNC_LEAVE_NOAPI(ret_value) |
294 | 1 | } /* end H5O__fsinfo_copy() */ |
295 | | |
296 | | /*------------------------------------------------------------------------- |
297 | | * Function: H5O__fsinfo_size |
298 | | * |
299 | | * Purpose: Returns the size of the raw message in bytes not counting |
300 | | * the message type or size fields, but only the data fields. |
301 | | * This function doesn't take into account alignment. |
302 | | * |
303 | | * Return: Success: Message data size in bytes without alignment. |
304 | | * Failure: zero |
305 | | * |
306 | | *------------------------------------------------------------------------- |
307 | | */ |
308 | | static size_t |
309 | | H5O__fsinfo_size(const H5F_t *f, bool H5_ATTR_UNUSED disable_shared, const void *_mesg) |
310 | 0 | { |
311 | 0 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
312 | 0 | size_t ret_value = 0; /* Return value */ |
313 | |
|
314 | 0 | FUNC_ENTER_PACKAGE_NOERR |
315 | |
|
316 | 0 | ret_value = 3 /* Version, strategy & persist */ |
317 | 0 | + (size_t)H5F_SIZEOF_SIZE(f) /* Free-space section threshold */ |
318 | 0 | + (size_t)H5F_SIZEOF_SIZE(f) /* File space page size */ |
319 | 0 | + 2 /* Page end meta threshold */ |
320 | 0 | + (size_t)H5F_SIZEOF_ADDR(f); |
321 | | |
322 | | /* Free-space manager addresses */ |
323 | 0 | if (fsinfo->persist) |
324 | 0 | ret_value += (H5F_MEM_PAGE_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); |
325 | |
|
326 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
327 | 0 | } /* end H5O__fsinfo_size() */ |
328 | | |
329 | | /*------------------------------------------------------------------------- |
330 | | * Function: H5O__fsinfo_free |
331 | | * |
332 | | * Purpose: Frees the message |
333 | | * |
334 | | * Return: Non-negative on success/Negative on failure |
335 | | * |
336 | | *------------------------------------------------------------------------- |
337 | | */ |
338 | | static herr_t |
339 | | H5O__fsinfo_free(void *mesg) |
340 | 1 | { |
341 | 1 | FUNC_ENTER_PACKAGE_NOERR |
342 | | |
343 | 1 | assert(mesg); |
344 | | |
345 | 1 | mesg = H5FL_FREE(H5O_fsinfo_t, mesg); |
346 | | |
347 | 1 | FUNC_LEAVE_NOAPI(SUCCEED) |
348 | 1 | } /* end H5O__fsinfo_free() */ |
349 | | |
350 | | /*------------------------------------------------------------------------- |
351 | | * Function: H5O__fsinfo_debug |
352 | | * |
353 | | * Purpose: Prints debugging info for a message. |
354 | | * |
355 | | * Return: Non-negative on success/Negative on failure |
356 | | * |
357 | | *------------------------------------------------------------------------- |
358 | | */ |
359 | | static herr_t |
360 | | H5O__fsinfo_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) |
361 | 0 | { |
362 | 0 | const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; |
363 | 0 | H5F_mem_page_t ptype; /* Free-space types for iteration */ |
364 | |
|
365 | 0 | FUNC_ENTER_PACKAGE_NOERR |
366 | | |
367 | | /* check args */ |
368 | 0 | assert(f); |
369 | 0 | assert(fsinfo); |
370 | 0 | assert(stream); |
371 | 0 | assert(indent >= 0); |
372 | 0 | assert(fwidth >= 0); |
373 | |
|
374 | 0 | fprintf(stream, "%*s%-*s ", indent, "", fwidth, "File space strategy:"); |
375 | 0 | switch (fsinfo->strategy) { |
376 | 0 | case H5F_FSPACE_STRATEGY_FSM_AGGR: |
377 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_FSM_AGGR"); |
378 | 0 | break; |
379 | | |
380 | 0 | case H5F_FSPACE_STRATEGY_PAGE: |
381 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_PAGE"); |
382 | 0 | break; |
383 | | |
384 | 0 | case H5F_FSPACE_STRATEGY_AGGR: |
385 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_AGGR"); |
386 | 0 | break; |
387 | | |
388 | 0 | case H5F_FSPACE_STRATEGY_NONE: |
389 | 0 | fprintf(stream, "%s\n", "H5F_FSPACE_STRATEGY_NONE"); |
390 | 0 | break; |
391 | | |
392 | 0 | case H5F_FSPACE_STRATEGY_NTYPES: |
393 | 0 | default: |
394 | 0 | fprintf(stream, "%s\n", "unknown"); |
395 | 0 | } /* end switch */ |
396 | | |
397 | 0 | fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, |
398 | 0 | "Free-space persist:", fsinfo->persist ? "TRUE" : "FALSE"); |
399 | |
|
400 | 0 | fprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, |
401 | 0 | "Free-space section threshold:", fsinfo->threshold); |
402 | |
|
403 | 0 | fprintf(stream, "%*s%-*s %" PRIuHSIZE "\n", indent, "", fwidth, |
404 | 0 | "File space page size:", fsinfo->page_size); |
405 | |
|
406 | 0 | fprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, |
407 | 0 | "Page end metadata threshold:", fsinfo->pgend_meta_thres); |
408 | |
|
409 | 0 | fprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, |
410 | 0 | "eoa_pre_fsm_fsalloc:", fsinfo->eoa_pre_fsm_fsalloc); |
411 | |
|
412 | 0 | if (fsinfo->persist) { |
413 | 0 | for (ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; ptype++) |
414 | 0 | fprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, |
415 | 0 | "Free space manager address:", fsinfo->fs_addr[ptype - 1]); |
416 | 0 | } /* end if */ |
417 | |
|
418 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
419 | 0 | } /* end H5O__fsinfo_debug() */ |
420 | | |
421 | | /*------------------------------------------------------------------------- |
422 | | * Function: H5O_fsinfo_set_version |
423 | | * |
424 | | * Purpose: Set the version to encode the fsinfo message with. |
425 | | * |
426 | | * Return: SUCCEED/FAIL |
427 | | * |
428 | | *------------------------------------------------------------------------- |
429 | | */ |
430 | | herr_t |
431 | | H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo) |
432 | 0 | { |
433 | 0 | unsigned version; /* Message version */ |
434 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
435 | |
|
436 | 0 | FUNC_ENTER_NOAPI(FAIL) |
437 | | |
438 | | /* Sanity check */ |
439 | 0 | HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); |
440 | 0 | assert(fsinfo); |
441 | |
|
442 | 0 | version = H5O_FSINFO_VERSION_1; |
443 | | |
444 | | /* Upgrade to the version indicated by the file's low bound if higher */ |
445 | 0 | if (H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION) |
446 | 0 | version = MAX(version, H5O_fsinfo_ver_bounds[low]); |
447 | | |
448 | | /* Version bounds check */ |
449 | 0 | if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || version > H5O_fsinfo_ver_bounds[high]) |
450 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds"); |
451 | | |
452 | | /* Set the message version */ |
453 | 0 | fsinfo->version = version; |
454 | |
|
455 | 0 | done: |
456 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
457 | 0 | } /* end H5O_fsinfo_set_version() */ |
458 | | |
459 | | /*------------------------------------------------------------------------- |
460 | | * Function: H5O_fsinfo_check_version |
461 | | * |
462 | | * Purpose: Validate the fsinfo message version |
463 | | * |
464 | | * Return: SUCCEED/FAIL |
465 | | * |
466 | | *------------------------------------------------------------------------- |
467 | | */ |
468 | | herr_t |
469 | | H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo) |
470 | 1 | { |
471 | 1 | herr_t ret_value = SUCCEED; /* Return value */ |
472 | | |
473 | 1 | FUNC_ENTER_NOAPI(FAIL) |
474 | | |
475 | | /* Sanity check */ |
476 | 1 | HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS); |
477 | 1 | assert(fsinfo); |
478 | | |
479 | | /* Check the version */ |
480 | 1 | if (H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high]) |
481 | 0 | HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds"); |
482 | | |
483 | 1 | done: |
484 | 1 | FUNC_LEAVE_NOAPI(ret_value) |
485 | 1 | } /* end H5O_fsinfo_check_version() */ |