HDF5  1.12.0
H5FSpkg.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  * Programmer: Quincey Koziol <koziol@hdfgroup.org>
16  * Tuesday, May 2, 2006
17  *
18  * Purpose: This file contains declarations which are visible only within
19  * the H5FS package. Source files outside the H5FS package should
20  * include H5FSprivate.h instead.
21  */
22 #if !(defined H5FS_FRIEND || defined H5FS_MODULE)
23 #error "Do not include this file outside the H5FS package!"
24 #endif
25 
26 #ifndef _H5FSpkg_H
27 #define _H5FSpkg_H
28 
29 /* Uncomment this macro to enable debugging output for free space manager */
30 /* #define H5FS_DEBUG */
31 
32 /* Uncomment this macro to enable debugging output for free space sections */
33 /* #define H5FS_SINFO_DEBUG */
34 
35 /* Uncomment this macro to enable extra sanity checking */
36 /* #define H5FS_DEBUG_ASSERT */
37 
38 /* Get package's private header */
39 #include "H5FSprivate.h" /* File free space */
40 
41 /* Other private headers needed by this file */
42 #include "H5ACprivate.h" /* Metadata cache */
43 #include "H5SLprivate.h" /* Skip lists */
44 
45 /**************************/
46 /* Package Private Macros */
47 /**************************/
48 
49 /* Size of checksum information (on disk) */
50 #define H5FS_SIZEOF_CHKSUM 4
51 
52 /* "Standard" size of prefix information for free space metadata */
53 #define H5FS_METADATA_PREFIX_SIZE ( \
54  H5_SIZEOF_MAGIC /* Signature */ \
55  + 1 /* Version */ \
56  + H5FS_SIZEOF_CHKSUM /* Metadata checksum */ \
57  )
58 
59 /* Size of the fractal heap header on disk */
60 #define H5FS_HEADER_SIZE(f) ( \
61  /* General metadata fields */ \
62  H5FS_METADATA_PREFIX_SIZE \
63  \
64  /* Free space header specific fields */ \
65  + 1 /* Client ID */ \
66  + (unsigned)H5F_SIZEOF_SIZE(f) /* Total free space tracked */ \
67  + (unsigned)H5F_SIZEOF_SIZE(f) /* Total # of sections tracked */ \
68  + (unsigned)H5F_SIZEOF_SIZE(f) /* # of serializable sections tracked */ \
69  + (unsigned)H5F_SIZEOF_SIZE(f) /* # of ghost sections tracked */ \
70  + 2 /* Number of section classes */ \
71  + 2 /* Shrink percent */ \
72  + 2 /* Expand percent */ \
73  + 2 /* Size of address space for sections (log2 of value) */ \
74  + (unsigned)H5F_SIZEOF_SIZE(f) /* Max. size of section to track */ \
75  + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of serialized free space sections */ \
76  + (unsigned)H5F_SIZEOF_SIZE(f) /* Size of serialized free space sections used */ \
77  + (unsigned)H5F_SIZEOF_SIZE(f) /* Allocated size of serialized free space sections */ \
78  )
79 
80 /* Size of the free space serialized sections on disk */
81 #define H5FS_SINFO_PREFIX_SIZE(f) ( \
82  /* General metadata fields */ \
83  H5FS_METADATA_PREFIX_SIZE \
84  \
85  /* Free space serialized sections specific fields */ \
86  + (unsigned)H5F_SIZEOF_ADDR(f) /* Address of free space header for these sections */ \
87  )
88 
89 
90 /****************************/
91 /* Package Private Typedefs */
92 /****************************/
93 
94 /* Callback info for loading a free space header into the cache */
95 typedef struct H5FS_hdr_cache_ud_t {
96  H5F_t *f; /* File that free space header is within */
97  uint16_t nclasses; /* Number of section classes */
98  const H5FS_section_class_t **classes; /* Array of section class info */
99  void *cls_init_udata; /* Pointer to class init user data */
100  haddr_t addr; /* Address of header */
102 
103 /* Callback info for loading free space section info into the cache */
104 typedef struct H5FS_sinfo_cache_ud_t {
105  H5F_t *f; /* File that free space section info is within */
106  H5FS_t *fspace; /* free space manager */
108 
109 /* Free space section bin info */
110 typedef struct H5FS_bin_t {
111  size_t tot_sect_count; /* Total # of sections in this bin */
112  size_t serial_sect_count; /* # of serializable sections in this bin */
113  size_t ghost_sect_count; /* # of un-serializable sections in this bin */
114  H5SL_t *bin_list; /* Skip list of differently sized sections */
116 
117 /* Free space node for free space sections of the same size */
118 typedef struct H5FS_node_t {
119  hsize_t sect_size; /* Size of all sections on list */
120  size_t serial_count; /* # of serializable sections on list */
121  size_t ghost_count; /* # of un-serializable sections on list */
122  H5SL_t *sect_list; /* Skip list to hold pointers to actual free list section node */
124 
125 /* Free space section info */
126 typedef struct H5FS_sinfo_t {
127  /* Information for H5AC cache functions, _must_ be first field in structure */
129 
130 /* Stored information */
131  H5FS_bin_t *bins; /* Array of lists of lists of free sections */
132 
133 /* Computed/cached values */
134  hbool_t dirty; /* Whether this info in memory is out of sync w/info in file */
135  unsigned nbins; /* Number of bins */
136  size_t serial_size; /* Total size of all serializable sections */
137  size_t tot_size_count; /* Total number of differently sized sections */
138  size_t serial_size_count; /* Total number of differently sized serializable sections */
139  size_t ghost_size_count; /* Total number of differently sized un-serializable sections */
140  unsigned sect_prefix_size; /* Size of the section serialization prefix (in bytes) */
141  unsigned sect_off_size; /* Size of a section offset (in bytes) */
142  unsigned sect_len_size; /* Size of a section length (in bytes) */
143  H5FS_t *fspace; /* Pointer to free space manager that owns sections */
144 
145 /* Memory data structures (not stored directly) */
146  H5SL_t *merge_list; /* Skip list to hold sections for detecting merges */
148 
149 /* Free space header info */
150 struct H5FS_t {
151  /* Information for H5AC cache functions, _must_ be first field in structure */
153 
154 /* Stored information */
155  /* Statistics about sections managed */
156  hsize_t tot_space; /* Total amount of space tracked */
157  hsize_t tot_sect_count; /* Total # of sections tracked */
158  hsize_t serial_sect_count; /* # of serializable sections tracked */
159  hsize_t ghost_sect_count; /* # of un-serializable sections tracked */
160 
161  /* Creation parameters */
162  H5FS_client_t client; /* Type of user of this free space manager */
163  uint16_t nclasses; /* Number of section classes handled */
164  unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */
165  unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */
166  unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */
167  hsize_t max_sect_size; /* Maximum size of section to track */
168 
169  /* Serialized section information */
170  haddr_t sect_addr; /* Address of the section info in the file */
171  hsize_t sect_size; /* Size of the section info in the file */
172  hsize_t alloc_sect_size; /* Allocated size of the section info in the file */
173 
174 /* Computed/cached values */
175  unsigned rc; /* Count of outstanding references to struct */
176  haddr_t addr; /* Address of free space header on disk */
177  size_t hdr_size; /* Size of free space header on disk */
178  H5FS_sinfo_t *sinfo; /* Section information */
179  hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */
180  unsigned sinfo_lock_count; /* # of times the section info has been locked */
181  hbool_t sinfo_protected; /* Whether the section info was protected when locked */
182  hbool_t sinfo_modified; /* Whether the section info has been modified while locked */
183  unsigned sinfo_accmode; /* Access mode for protecting the section info */
184  /* must be either H5C__NO_FLAGS_SET (i.e r/w) */
185  /* or H5AC__READ_ONLY_FLAG (i.e. r/o). */
186  size_t max_cls_serial_size; /* Max. additional size of serialized form of section */
187  hsize_t alignment; /* Alignment */
188  hsize_t align_thres; /* Threshold for alignment */
189 
190 
191 /* Memory data structures (not stored directly) */
192  H5FS_section_class_t *sect_cls; /* Array of section classes for this free list */
193 };
194 
195 
196 /*****************************/
197 /* Package Private Variables */
198 /*****************************/
199 
200 /* Declare a free list to manage the H5FS_node_t struct */
202 
203 /* Declare a free list to manage the H5FS_bin_t sequence information */
205 
206 /* Declare a free list to manage the H5FS_sinfo_t struct */
208 
209 /* Declare a free list to manage the H5FS_t struct */
211 
212 
213 /******************************/
214 /* Package Private Prototypes */
215 /******************************/
216 
217 /* Generic routines */
218 H5_DLL herr_t H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry);
219 H5_DLL herr_t H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry);
220 
221 /* Free space manager header routines */
222 H5_DLL H5FS_t *H5FS__new(const H5F_t *f, uint16_t nclasses,
223  const H5FS_section_class_t *classes[], void *cls_init_udata);
224 H5_DLL herr_t H5FS__incr(H5FS_t *fspace);
225 H5_DLL herr_t H5FS__decr(H5FS_t *fspace);
227 
228 /* Free space section routines */
230 
231 /* Routines for destroying structures */
234 
235 /* Sanity check routines */
236 #ifdef H5FS_DEBUG_ASSERT
237 H5_DLL void H5FS__assert(const H5FS_t *fspace);
238 H5_DLL void H5FS__sect_assert(const H5FS_t *fspace);
239 #endif /* H5FS_DEBUG_ASSERT */
240 
241 /* Testing routines */
242 #ifdef H5FS_TESTING
244 H5_DLL int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2);
245 #endif /* H5FS_TESTING */
246 
247 #endif /* _H5FSpkg_H */
248 
H5FS_t::shrink_percent
unsigned shrink_percent
Definition: H5FSpkg.h:164
H5FS_sinfo_cache_ud_t::f
H5F_t * f
Definition: H5FSpkg.h:105
H5SL_t
Definition: H5SL.c:557
H5FS_hdr_cache_ud_t::cls_init_udata
void * cls_init_udata
Definition: H5FSpkg.h:99
H5FS_t::sect_addr
haddr_t sect_addr
Definition: H5FSpkg.h:170
H5FS_sinfo_t::serial_size
size_t serial_size
Definition: H5FSpkg.h:136
H5FS_t::sect_cls
H5FS_section_class_t * sect_cls
Definition: H5FSpkg.h:192
H5FS_sinfo_t::tot_size_count
size_t tot_size_count
Definition: H5FSpkg.h:137
H5FS_sinfo_t
struct H5FS_sinfo_t H5FS_sinfo_t
f
hdr f
Definition: H5EA.c:755
H5FS_hdr_cache_ud_t::classes
const H5FS_section_class_t ** classes
Definition: H5FSpkg.h:98
H5FS_t
Definition: H5FSpkg.h:150
H5FS_t::sinfo_accmode
unsigned sinfo_accmode
Definition: H5FSpkg.h:183
H5FS_t::align_thres
hsize_t align_thres
Definition: H5FSpkg.h:188
H5FS_hdr_cache_ud_t::f
H5F_t * f
Definition: H5FSpkg.h:96
H5FS_node_t::sect_size
hsize_t sect_size
Definition: H5FSpkg.h:119
H5FS_sinfo_t::sect_off_size
unsigned sect_off_size
Definition: H5FSpkg.h:141
H5FS_bin_t::tot_sect_count
size_t tot_sect_count
Definition: H5FSpkg.h:111
H5FS_sinfo_t
Definition: H5FSpkg.h:126
haddr_t
CATCH haddr_t
Definition: H5EAdblock.c:162
H5FS_sinfo_cache_ud_t::fspace
H5FS_t * fspace
Definition: H5FSpkg.h:106
H5FS_bin_t::serial_sect_count
size_t serial_sect_count
Definition: H5FSpkg.h:112
H5FS_t::serial_sect_count
hsize_t serial_sect_count
Definition: H5FSpkg.h:158
H5FS_t::max_sect_size
hsize_t max_sect_size
Definition: H5FSpkg.h:167
H5FS_section_class_t
Definition: H5FSprivate.h:64
H5FS_t::sinfo_protected
hbool_t sinfo_protected
Definition: H5FSpkg.h:181
H5FS_sinfo_t::dirty
hbool_t dirty
Definition: H5FSpkg.h:134
H5FS__new
H5_DLL H5FS_t * H5FS__new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata)
Definition: H5FS.c:589
H5FS_t::cache_info
H5AC_info_t cache_info
Definition: H5FSpkg.h:152
H5FS_sinfo_t::sect_prefix_size
unsigned sect_prefix_size
Definition: H5FSpkg.h:140
H5FS__create_flush_depend
H5_DLL herr_t H5FS__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)
Definition: H5FSint.c:119
H5FS_sinfo_t::fspace
H5FS_t * fspace
Definition: H5FSpkg.h:143
H5FS_bin_t
Definition: H5FSpkg.h:110
hdr
hdr
Definition: H5EAhdr.c:821
H5FS__destroy_flush_depend
H5_DLL herr_t H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)
Definition: H5FSint.c:151
H5FS_t::sect_size
hsize_t sect_size
Definition: H5FSpkg.h:171
H5FS_t::max_cls_serial_size
size_t max_cls_serial_size
Definition: H5FSpkg.h:186
H5FL_SEQ_EXTERN
H5FL_SEQ_EXTERN(H5FS_bin_t)
H5FS__hdr_dest
H5_DLL herr_t H5FS__hdr_dest(H5FS_t *hdr)
Definition: H5FS.c:1022
H5SLprivate.h
H5FS_t::alignment
hsize_t alignment
Definition: H5FSpkg.h:187
H5FS_t::alloc_sect_size
hsize_t alloc_sect_size
Definition: H5FSpkg.h:172
H5FS_t::sinfo_modified
hbool_t sinfo_modified
Definition: H5FSpkg.h:182
H5FS__sinfo_dest
H5_DLL herr_t H5FS__sinfo_dest(H5FS_sinfo_t *sinfo)
Definition: H5FS.c:1129
uint16_t
uint16_t
Definition: H5overflow.txt:37
H5FS__get_cparam_test
herr_t H5FS__get_cparam_test(const H5FS_t *frsp, H5FS_create_t *cparam)
Definition: H5FStest.c:85
H5ACprivate.h
H5FS_hdr_cache_ud_t
Definition: H5FSpkg.h:95
H5FS_t::hdr_size
size_t hdr_size
Definition: H5FSpkg.h:177
H5FS_node_t
Definition: H5FSpkg.h:118
H5FS_t::ghost_sect_count
hsize_t ghost_sect_count
Definition: H5FSpkg.h:159
H5FSprivate.h
H5FS_t::swmr_write
hbool_t swmr_write
Definition: H5FSpkg.h:179
H5FS__sinfo_new
H5_DLL H5FS_sinfo_t * H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace)
Definition: H5FSsection.c:128
H5FS_t::client
H5FS_client_t client
Definition: H5FSpkg.h:162
H5FS_sinfo_t::ghost_size_count
size_t ghost_size_count
Definition: H5FSpkg.h:139
H5FS_sinfo_t::sect_len_size
unsigned sect_len_size
Definition: H5FSpkg.h:142
H5FS_sinfo_t::bins
H5FS_bin_t * bins
Definition: H5FSpkg.h:131
H5FS_bin_t::ghost_sect_count
size_t ghost_sect_count
Definition: H5FSpkg.h:113
H5FS_create_t
Definition: H5FSprivate.h:111
H5FS__cmp_cparam_test
int H5FS__cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2)
Definition: H5FStest.c:117
H5_DLL
#define H5_DLL
Definition: H5api_adpt.h:234
H5FS_hdr_cache_ud_t::addr
haddr_t addr
Definition: H5FSpkg.h:100
H5FS_sinfo_t::serial_size_count
size_t serial_size_count
Definition: H5FSpkg.h:138
H5FS__dirty
H5_DLL herr_t H5FS__dirty(H5FS_t *fspace)
Definition: H5FS.c:785
H5FS_sinfo_cache_ud_t
struct H5FS_sinfo_cache_ud_t H5FS_sinfo_cache_ud_t
H5FS_client_t
H5FS_client_t
Definition: H5FSprivate.h:104
H5FS_sinfo_t::merge_list
H5SL_t * merge_list
Definition: H5FSpkg.h:146
H5FL_EXTERN
H5FL_EXTERN(H5FS_node_t)
H5FS_t::addr
haddr_t addr
Definition: H5FSpkg.h:176
H5FS_sinfo_t::nbins
unsigned nbins
Definition: H5FSpkg.h:135
H5FS_node_t::sect_list
H5SL_t * sect_list
Definition: H5FSpkg.h:122
H5F_t
Definition: H5Fpkg.h:374
H5FS_sinfo_cache_ud_t
Definition: H5FSpkg.h:104
H5FS_sinfo_t::cache_info
H5AC_info_t cache_info
Definition: H5FSpkg.h:128
H5FS_node_t::ghost_count
size_t ghost_count
Definition: H5FSpkg.h:121
H5FS_t::tot_space
hsize_t tot_space
Definition: H5FSpkg.h:156
H5FS_bin_t::bin_list
H5SL_t * bin_list
Definition: H5FSpkg.h:114
herr_t
int herr_t
Definition: H5public.h:128
H5FS_hdr_cache_ud_t
struct H5FS_hdr_cache_ud_t H5FS_hdr_cache_ud_t
hbool_t
bool hbool_t
Definition: H5public.h:159
H5FS__incr
H5_DLL herr_t H5FS__incr(H5FS_t *fspace)
Definition: H5FS.c:698
H5FS_t::expand_percent
unsigned expand_percent
Definition: H5FSpkg.h:165
H5FS_t::rc
unsigned rc
Definition: H5FSpkg.h:175
H5FS_t::tot_sect_count
hsize_t tot_sect_count
Definition: H5FSpkg.h:157
H5C_cache_entry_t
Definition: H5Cprivate.h:1597
H5FS_hdr_cache_ud_t::nclasses
uint16_t nclasses
Definition: H5FSpkg.h:97
H5FS_node_t::serial_count
size_t serial_count
Definition: H5FSpkg.h:120
H5FS_bin_t
struct H5FS_bin_t H5FS_bin_t
hsize_t
hsize_t
Definition: H5overflow.txt:44
H5FS__decr
H5_DLL herr_t H5FS__decr(H5FS_t *fspace)
Definition: H5FS.c:738
H5FS_t::sinfo
H5FS_sinfo_t * sinfo
Definition: H5FSpkg.h:178
H5FS_t::sinfo_lock_count
unsigned sinfo_lock_count
Definition: H5FSpkg.h:180
H5FS_t::max_sect_addr
unsigned max_sect_addr
Definition: H5FSpkg.h:166
H5FS_t::nclasses
uint16_t nclasses
Definition: H5FSpkg.h:163
H5FS_node_t
struct H5FS_node_t H5FS_node_t