HDF5  1.12.0
H5FSprivate.h
Go to the documentation of this file.
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: H5FSprivate.h
17  * May 2 2006
18  * Quincey Koziol <koziol@hdfgroup.org>
19  *
20  * Purpose: Private header for library accessible file free space routines.
21  *
22  *-------------------------------------------------------------------------
23  */
24 
25 #ifndef _H5FSprivate_H
26 #define _H5FSprivate_H
27 
28 /* Private headers needed by this file */
29 #include "H5Fprivate.h" /* File access */
30 #include "H5FLprivate.h" /* Free Lists */
31 
32 /**************************/
33 /* Library Private Macros */
34 /**************************/
35 
36 /* Flags for H5FS_section_class_t 'flags' field */
37 #define H5FS_CLS_GHOST_OBJ 0x01 /* Objects in this class shouldn't be
38  * serialized to the file.
39  */
40 #define H5FS_CLS_SEPAR_OBJ 0x02 /* Objects in this class shouldn't
41  * participate in merge operations.
42  */
43 #define H5FS_CLS_MERGE_SYM 0x04 /* Objects in this class only merge
44  * with other objects in this class.
45  */
46 #define H5FS_CLS_ADJUST_OK 0x08 /* Objects in this class can be merged
47  * without requiring a can_adjust/adjust
48  * callback pair.
49  */
50 
51 /* Flags for H5FS_add() */
52 #define H5FS_ADD_DESERIALIZING 0x01 /* Free space is being deserialized
53  */
54 #define H5FS_ADD_RETURNED_SPACE 0x02 /* Section was previously allocated
55  * and is being returned to the
56  * free space manager (usually
57  * as a result of freeing an
58  * object)
59  */
60 #define H5FS_ADD_SKIP_VALID 0x04 /* Don't check validity after adding
61  * this section. (state of the
62  * managed sections is in flux)
63  */
64 
65 #define H5FS_PAGE_END_NO_ADD 0x08 /* For "small" page fs:
66  * Don't add section to free space:
67  * when the section is at page end and
68  * when the section size is <= "small"
69  */
70 
71 /* Flags for deserialize callback */
72 #define H5FS_DESERIALIZE_NO_ADD 0x01 /* Don't add section to free space
73  * manager after it's deserialized
74  * (its only here for it's side-
75  * effects).
76  */
77 
78 
79 /****************************/
80 /* Library Private Typedefs */
81 /****************************/
82 
83 /* Free space info (forward decl - defined in H5FSpkg.h) */
84 typedef struct H5FS_t H5FS_t;
85 
86 /* Forward declaration free space section info */
88 
89 /* Free space section class info */
90 typedef struct H5FS_section_class_t {
91  /* Class variables */
92  const unsigned type; /* Type of free space section */
93  size_t serial_size; /* Size of serialized form of section */
94  unsigned flags; /* Class flags */
95  void *cls_private; /* Class private information */
96 
97  /* Class methods */
98  herr_t (*init_cls)(struct H5FS_section_class_t *, void *); /* Routine to initialize class-specific settings */
99  herr_t (*term_cls)(struct H5FS_section_class_t *); /* Routine to terminate class-specific settings */
100 
101  /* Object methods */
102  herr_t (*add)(H5FS_section_info_t **, unsigned *, void *); /* Routine called when section is about to be added to manager */
103  herr_t (*serialize)(const struct H5FS_section_class_t *, const H5FS_section_info_t *, uint8_t *); /* Routine to serialize a "live" section into a buffer */
104  H5FS_section_info_t *(*deserialize)(const struct H5FS_section_class_t *, const uint8_t *, haddr_t, hsize_t, unsigned *); /* Routine to deserialize a buffer into a "live" section */
105  htri_t (*can_merge)(const H5FS_section_info_t *, const H5FS_section_info_t *, void *); /* Routine to determine if two nodes are mergable */
106  herr_t (*merge)(H5FS_section_info_t **, H5FS_section_info_t *, void *); /* Routine to merge two nodes */
107  htri_t (*can_shrink)(const H5FS_section_info_t *, void *); /* Routine to determine if node can shrink container */
108  herr_t (*shrink)(H5FS_section_info_t **, void *); /* Routine to shrink container */
109  herr_t (*free)(H5FS_section_info_t *); /* Routine to free node */
110  herr_t (*valid)(const struct H5FS_section_class_t *, const H5FS_section_info_t *); /* Routine to check if a section is valid */
111  H5FS_section_info_t *(*split)(H5FS_section_info_t *, hsize_t); /* Routine to create the split section */
112  herr_t (*debug)(const H5FS_section_info_t *, FILE *, int , int ); /* Routine to dump debugging information about a section */
114 
115 /* State of section ("live" or "serialized") */
116 typedef enum H5FS_section_state_t {
117  H5FS_SECT_LIVE, /* Section has "live" memory references */
118  H5FS_SECT_SERIALIZED /* Section is in "serialized" form */
120 
121 /* Free space section info */
123  haddr_t addr; /* Offset of free space section in the address space */
124  hsize_t size; /* Size of free space section */
125  unsigned type; /* Type of free space section (i.e. class) */
126  H5FS_section_state_t state; /* Whether the section is in "serialized" or "live" form */
127 };
128 
129 /* Free space client IDs for identifying user of free space */
130 typedef enum H5FS_client_t {
131  H5FS_CLIENT_FHEAP_ID = 0, /* Free space is used by fractal heap */
132  H5FS_CLIENT_FILE_ID, /* Free space is used by file */
133  H5FS_NUM_CLIENT_ID /* Number of free space client IDs (must be last) */
134 } H5FS_client_t;
135 
136 /* Free space creation parameters */
137 typedef struct H5FS_create_t {
138  H5FS_client_t client; /* Client's ID */
139  unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */
140  unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */
141  unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */
142  hsize_t max_sect_size; /* Maximum size of section to track */
143 } H5FS_create_t;
144 
145 /* Free space statistics info */
146 typedef struct H5FS_stat_t {
147  hsize_t tot_space; /* Total amount of space tracked */
148  hsize_t tot_sect_count; /* Total # of sections tracked */
149  hsize_t serial_sect_count; /* # of serializable sections tracked */
150  hsize_t ghost_sect_count; /* # of un-serializable sections tracked */
151  haddr_t addr; /* Address of free space header on disk */
152  hsize_t hdr_size; /* Size of the free-space header on disk */
153  haddr_t sect_addr; /* Address of the section info in the file */
154  hsize_t alloc_sect_size; /* Allocated size of the section info in the file */
155  hsize_t sect_size; /* Size of the section info in the file */
156 } H5FS_stat_t;
157 
158 /* Typedef for iteration operations */
160  void *operator_data/*in,out*/);
161 
162 
163 /*****************************/
164 /* Library-private Variables */
165 /*****************************/
166 
167 /* Declare a free list to manage the H5FS_section_class_t sequence information */
169 
170 
171 /***************************************/
172 /* Library-private Function Prototypes */
173 /***************************************/
174 
175 /* Package initialization routine */
176 H5_DLL herr_t H5FS_init(void);
177 
178 /* Free space manager routines */
179 H5_DLL H5FS_t *H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create,
180  uint16_t nclasses, const H5FS_section_class_t *classes[],
181  void *cls_init_udata, hsize_t alignment, hsize_t threshold);
182 H5_DLL H5FS_t *H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses,
183  const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment,
184  hsize_t threshold);
185 H5_DLL herr_t H5FS_size(const H5FS_t *fspace, hsize_t *meta_size);
187 H5_DLL herr_t H5FS_close(H5F_t *f, H5FS_t *fspace);
188 H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr);
190 H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space);
191 
192 /* Free space section routines */
194  unsigned flags, void *op_data);
196  H5FS_section_info_t *sect, unsigned flags, void *op_data);
198  hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data);
200 H5_DLL htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request,
201  H5FS_section_info_t **node);
202 H5_DLL herr_t H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data);
203 H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space,
204  hsize_t *nsects);
206  H5FS_section_info_t *sect, uint16_t new_class);
208  void *op_data);
209 
210 /* Statistics routine */
211 H5_DLL herr_t H5FS_stat_info(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *stats);
212 H5_DLL herr_t H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count);
213 
214 /* free space manager settling routines */
216  haddr_t *fs_addr_ptr);
217 
218 /* Debugging routines for dumping file structures */
219 H5_DLL herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent,
220  int fwidth);
221 H5_DLL herr_t H5FS_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent,
222  int fwidth, haddr_t fs_addr, haddr_t client_addr);
223 H5_DLL herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect,
224  FILE *stream, int indent, int fwidth);
225 
226 #endif /* _H5FSprivate_H */
227 
H5FS_create_t::max_sect_size
hsize_t max_sect_size
Definition: H5FSprivate.h:116
H5FS_sect_iterate
H5_DLL herr_t H5FS_sect_iterate(H5F_t *f, H5FS_t *fspace, H5FS_operator_t op, void *op_data)
Definition: H5FSsection.c:1978
H5FS_section_class_t::free
herr_t(* free)(H5FS_section_info_t *)
Definition: H5FSprivate.h:83
H5FS_section_info_t::addr
haddr_t addr
Definition: H5FSprivate.h:97
H5FS_stat_t
struct H5FS_stat_t H5FS_stat_t
size
iblock size
Definition: H5EAcache.c:787
f
hdr f
Definition: H5EA.c:755
H5FS_sect_debug
H5_DLL herr_t H5FS_sect_debug(const H5FS_t *fspace, const H5FS_section_info_t *sect, FILE *stream, int indent, int fwidth)
Definition: H5FSdbg.c:190
H5FS_alloc_sect
H5_DLL herr_t H5FS_alloc_sect(H5F_t *f, H5FS_t *fspace)
Definition: H5FS.c:862
H5FS_sects_debug
H5_DLL herr_t H5FS_sects_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t fs_addr, haddr_t client_addr)
H5FS_t
Definition: H5FSpkg.h:150
H5FS_create_t::expand_percent
unsigned expand_percent
Definition: H5FSprivate.h:114
H5FS_get_sect_count
H5_DLL herr_t H5FS_get_sect_count(const H5FS_t *frsp, hsize_t *tot_sect_count)
Definition: H5FS.c:1175
H5FS_NUM_CLIENT_ID
@ H5FS_NUM_CLIENT_ID
Definition: H5FSprivate.h:107
H5FS_stat_t::sect_addr
haddr_t sect_addr
Definition: H5FSprivate.h:127
H5FS_close
H5_DLL herr_t H5FS_close(H5F_t *f, H5FS_t *fspace)
Definition: H5FS.c:406
H5FL_SEQ_EXTERN
H5FL_SEQ_EXTERN(H5FS_section_class_t)
haddr_t
CATCH haddr_t
Definition: H5EAdblock.c:162
H5FS_stat_t::tot_sect_count
hsize_t tot_sect_count
Definition: H5FSprivate.h:122
indent
*s *s indent
Definition: H5HLdbg.c:111
H5FS_section_class_t::cls_private
void * cls_private
Definition: H5FSprivate.h:69
H5FS_sect_find
H5_DLL htri_t H5FS_sect_find(H5F_t *f, H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node)
Definition: H5FSsection.c:1836
H5FS_SECT_SERIALIZED
@ H5FS_SECT_SERIALIZED
Definition: H5FSprivate.h:92
H5FS_section_info_t
Definition: H5FSprivate.h:96
H5FS_section_class_t
Definition: H5FSprivate.h:64
H5FS_sect_stats
H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects)
Definition: H5FSsection.c:2044
H5FS_section_class_t::valid
herr_t(* valid)(const struct H5FS_section_class_t *, const H5FS_section_info_t *)
Definition: H5FSprivate.h:84
H5FS_sect_try_shrink_eoa
H5_DLL htri_t H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data)
Definition: H5FSsection.c:2394
H5FS_create
H5_DLL H5FS_t * H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold)
Definition: H5FS.c:105
H5FS_section_class_t
struct H5FS_section_class_t H5FS_section_class_t
H5FS_CLIENT_FHEAP_ID
@ H5FS_CLIENT_FHEAP_ID
Definition: H5FSprivate.h:105
H5FS_section_class_t::merge
herr_t(* merge)(H5FS_section_info_t **, H5FS_section_info_t *, void *)
Definition: H5FSprivate.h:80
uint8_t
unsigned char uint8_t
Definition: H5private.h:429
H5FS_section_state_t
H5FS_section_state_t
Definition: H5FSprivate.h:90
H5FS_sect_change_class
H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint16_t new_class)
Definition: H5FSsection.c:2075
H5FS_stat_t::serial_sect_count
hsize_t serial_sect_count
Definition: H5FSprivate.h:123
htri_t
int htri_t
Definition: H5public.h:160
H5FS_stat_t::alloc_sect_size
hsize_t alloc_sect_size
Definition: H5FSprivate.h:128
H5FS_section_class_t::type
const unsigned type
Definition: H5FSprivate.h:66
H5FS_section_class_t::can_shrink
htri_t(* can_shrink)(const H5FS_section_info_t *, void *)
Definition: H5FSprivate.h:81
H5FS_sect_add
H5_DLL herr_t H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node, unsigned flags, void *op_data)
Definition: H5FSsection.c:1397
H5FS_create_t
struct H5FS_create_t H5FS_create_t
H5FS_SECT_LIVE
@ H5FS_SECT_LIVE
Definition: H5FSprivate.h:91
H5FS_stat_t
Definition: H5FSprivate.h:120
H5FS_section_info_t::size
hsize_t size
Definition: H5FSprivate.h:98
uint16_t
uint16_t
Definition: H5overflow.txt:37
FILE
Invalid arguments to routine Resource unavailable Internal File accessibility Low level I O Function entry exit Object atom Object cache Links B Tree node Symbol table Heap Object header Datatype Dataspace Dataset Data storage Property lists Attribute Data filters External file list References Virtual File Layer Virtual Object Layer Ternary Search Trees Reference Counted Strings Error API Skip Lists Free Space Manager Shared Object Header Messages Extensible Array Fixed Array Plugin for dynamically loaded library Page Buffering API Context Map No error Argument errors Resource errors File accessibility errors FILE
Definition: H5err.txt:88
H5FS_create_t::shrink_percent
unsigned shrink_percent
Definition: H5FSprivate.h:113
H5FS_CLIENT_FILE_ID
@ H5FS_CLIENT_FILE_ID
Definition: H5FSprivate.h:106
H5FS_section_class_t::add
herr_t(* add)(H5FS_section_info_t **, unsigned *, void *)
Definition: H5FSprivate.h:76
int
CATCH int
Definition: H5EA.c:1002
H5Fprivate.h
H5FS_section_class_t::flags
unsigned flags
Definition: H5FSprivate.h:68
H5FS_operator_t
herr_t(* H5FS_operator_t)(H5FS_section_info_t *sect, void *operator_data)
Definition: H5FSprivate.h:133
H5FS_section_class_t::debug
herr_t(* debug)(const H5FS_section_info_t *, FILE *, int, int)
Definition: H5FSprivate.h:86
H5FS_section_class_t::can_merge
htri_t(* can_merge)(const H5FS_section_info_t *, const H5FS_section_info_t *, void *)
Definition: H5FSprivate.h:79
fwidth
*s *s fwidth
Definition: H5HLdbg.c:111
H5FS_stat_t::addr
haddr_t addr
Definition: H5FSprivate.h:125
H5FS_sect_remove
H5_DLL herr_t H5FS_sect_remove(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *node)
Definition: H5FSsection.c:933
H5FS_free
H5_DLL herr_t H5FS_free(H5F_t *f, H5FS_t *fspace, hbool_t free_file_space)
Definition: H5FS.c:910
H5FS_section_class_t::serialize
herr_t(* serialize)(const struct H5FS_section_class_t *, const H5FS_section_info_t *, uint8_t *)
Definition: H5FSprivate.h:77
H5FS_section_class_t::term_cls
herr_t(* term_cls)(struct H5FS_section_class_t *)
Definition: H5FSprivate.h:73
H5FS_section_info_t::type
unsigned type
Definition: H5FSprivate.h:99
H5FS_open
H5_DLL H5FS_t * H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold)
Definition: H5FS.c:188
H5FS_sect_try_merge
H5_DLL htri_t H5FS_sect_try_merge(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flags, void *op_data)
Definition: H5FSsection.c:1622
H5FS_create_t
Definition: H5FSprivate.h:111
H5_DLL
#define H5_DLL
Definition: H5api_adpt.h:234
H5FS_section_class_t::shrink
herr_t(* shrink)(H5FS_section_info_t **, void *)
Definition: H5FSprivate.h:82
H5FS_delete
H5_DLL herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr)
Definition: H5FS.c:256
H5FS_section_info_t::state
H5FS_section_state_t state
Definition: H5FSprivate.h:100
H5FS_stat_t::sect_size
hsize_t sect_size
Definition: H5FSprivate.h:129
H5FS_size
H5_DLL herr_t H5FS_size(const H5FS_t *fspace, hsize_t *meta_size)
Definition: H5FS.c:668
H5FS_section_class_t::init_cls
herr_t(* init_cls)(struct H5FS_section_class_t *, void *)
Definition: H5FSprivate.h:72
H5FS_stat_t::tot_space
hsize_t tot_space
Definition: H5FSprivate.h:121
H5FS_client_t
H5FS_client_t
Definition: H5FSprivate.h:104
H5FS_debug
H5_DLL herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)
Definition: H5FSdbg.c:92
H5FS_alloc_hdr
H5_DLL herr_t H5FS_alloc_hdr(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr)
Definition: H5FS.c:821
H5F_t
Definition: H5Fpkg.h:374
H5FS_sect_try_extend
H5_DLL htri_t H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, hsize_t extra_requested, unsigned flags, void *op_data)
Definition: H5FSsection.c:1484
H5FLprivate.h
herr_t
int herr_t
Definition: H5public.h:128
H5FS_stat_info
H5_DLL herr_t H5FS_stat_info(const H5F_t *f, const H5FS_t *frsp, H5FS_stat_t *stats)
Definition: H5FSstat.c:83
hbool_t
bool hbool_t
Definition: H5public.h:159
H5FS_create_t::client
H5FS_client_t client
Definition: H5FSprivate.h:112
hsize_t
hsize_t
Definition: H5overflow.txt:44
H5FS_vfd_alloc_hdr_and_section_info_if_needed
H5_DLL herr_t H5FS_vfd_alloc_hdr_and_section_info_if_needed(H5F_t *f, H5FS_t *fspace, haddr_t *fs_addr_ptr)
Definition: H5FSsection.c:2488
H5FS_section_class_t::serial_size
size_t serial_size
Definition: H5FSprivate.h:67
H5FS_create_t::max_sect_addr
unsigned max_sect_addr
Definition: H5FSprivate.h:115
H5FS_stat_t::hdr_size
hsize_t hdr_size
Definition: H5FSprivate.h:126
H5FS_init
H5_DLL herr_t H5FS_init(void)
Definition: H5FSint.c:95
H5FS_stat_t::ghost_sect_count
hsize_t ghost_sect_count
Definition: H5FSprivate.h:124