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@ncsa.uiuc.edu> 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 #ifndef H5FS_PACKAGE 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 + H5F_SIZEOF_SIZE(f) /* Total free space tracked */ \ 67 + H5F_SIZEOF_SIZE(f) /* Total # of sections tracked */ \ 68 + H5F_SIZEOF_SIZE(f) /* # of serializable sections tracked */ \ 69 + 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 + H5F_SIZEOF_SIZE(f) /* Max. size of section to track */ \ 75 + H5F_SIZEOF_ADDR(f) /* Address of serialized free space sections */ \ 76 + H5F_SIZEOF_SIZE(f) /* Size of serialized free space sections used */ \ 77 + 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 + 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 size_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 */ 101 } H5FS_hdr_cache_ud_t; 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 */ 107 hid_t dxpl_id; 108 } H5FS_sinfo_cache_ud_t; 109 110 /* Free space section bin info */ 111 typedef struct H5FS_bin_t { 112 size_t tot_sect_count; /* Total # of sections in this bin */ 113 size_t serial_sect_count; /* # of serializable sections in this bin */ 114 size_t ghost_sect_count; /* # of un-serializable sections in this bin */ 115 H5SL_t *bin_list; /* Skip list of differently sized sections */ 116 } H5FS_bin_t; 117 118 /* Free space node for free space sections of the same size */ 119 typedef struct H5FS_node_t { 120 hsize_t sect_size; /* Size of all sections on list */ 121 size_t serial_count; /* # of serializable sections on list */ 122 size_t ghost_count; /* # of un-serializable sections on list */ 123 H5SL_t *sect_list; /* Skip list to hold pointers to actual free list section node */ 124 } H5FS_node_t; 125 126 /* Free space section info */ 127 typedef struct H5FS_sinfo_t { 128 /* Information for H5AC cache functions, _must_ be first field in structure */ 129 H5AC_info_t cache_info; 130 131 /* Stored information */ 132 H5FS_bin_t *bins; /* Array of lists of lists of free sections */ 133 134 /* Computed/cached values */ 135 hbool_t dirty; /* Whether this info in memory is out of sync w/info in file */ 136 unsigned nbins; /* Number of bins */ 137 size_t serial_size; /* Total size of all serializable sections */ 138 size_t tot_size_count; /* Total number of differently sized sections */ 139 size_t serial_size_count; /* Total number of differently sized serializable sections */ 140 size_t ghost_size_count; /* Total number of differently sized un-serializable sections */ 141 unsigned sect_prefix_size; /* Size of the section serialization prefix (in bytes) */ 142 unsigned sect_off_size; /* Size of a section offset (in bytes) */ 143 unsigned sect_len_size; /* Size of a section length (in bytes) */ 144 H5FS_t *fspace; /* Pointer to free space manager that owns sections */ 145 146 /* Memory data structures (not stored directly) */ 147 H5SL_t *merge_list; /* Skip list to hold sections for detecting merges */ 148 } H5FS_sinfo_t; 149 150 /* Free space header info */ 151 struct H5FS_t { 152 /* Information for H5AC cache functions, _must_ be first field in structure */ 153 H5AC_info_t cache_info; 154 155 /* Stored information */ 156 /* Statistics about sections managed */ 157 hsize_t tot_space; /* Total amount of space tracked */ 158 hsize_t tot_sect_count; /* Total # of sections tracked */ 159 hsize_t serial_sect_count; /* # of serializable sections tracked */ 160 hsize_t ghost_sect_count; /* # of un-serializable sections tracked */ 161 162 /* Creation parameters */ 163 H5FS_client_t client; /* Type of user of this free space manager */ 164 unsigned nclasses; /* Number of section classes handled */ 165 unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ 166 unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ 167 unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ 168 hsize_t max_sect_size; /* Maximum size of section to track */ 169 170 /* Serialized section information */ 171 haddr_t sect_addr; /* Address of the section info in the file */ 172 hsize_t sect_size; /* Size of the section info in the file */ 173 hsize_t alloc_sect_size; /* Allocated size of the section info in the file */ 174 175 /* Computed/cached values */ 176 unsigned rc; /* Count of outstanding references to struct */ 177 haddr_t addr; /* Address of free space header on disk */ 178 size_t hdr_size; /* Size of free space header on disk */ 179 H5FS_sinfo_t *sinfo; /* Section information */ 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 H5AC_protect_t sinfo_accmode; /* Access mode for protecting the section info */ 184 size_t max_cls_serial_size; /* Max. additional size of serialized form of section */ 185 hsize_t threshold; /* Threshold for alignment */ 186 hsize_t alignment; /* Alignment */ 187 188 189 /* Memory data structures (not stored directly) */ 190 H5FS_section_class_t *sect_cls; /* Array of section classes for this free list */ 191 }; 192 193 194 /*****************************/ 195 /* Package Private Variables */ 196 /*****************************/ 197 198 /* H5FS header inherits cache-like properties from H5AC */ 199 H5_DLLVAR const H5AC_class_t H5AC_FSPACE_HDR[1]; 200 201 /* H5FS section info inherits cache-like properties from H5AC */ 202 H5_DLLVAR const H5AC_class_t H5AC_FSPACE_SINFO[1]; 203 204 /* Declare a free list to manage the H5FS_node_t struct */ 205 H5FL_EXTERN(H5FS_node_t); 206 207 /* Declare a free list to manage the H5FS_bin_t sequence information */ 208 H5FL_SEQ_EXTERN(H5FS_bin_t); 209 210 /* Declare a free list to manage the H5FS_sinfo_t struct */ 211 H5FL_EXTERN(H5FS_sinfo_t); 212 213 /* Declare a free list to manage the H5FS_t struct */ 214 H5FL_EXTERN(H5FS_t); 215 216 217 /******************************/ 218 /* Package Private Prototypes */ 219 /******************************/ 220 221 /* Free space manager header routines */ 222 H5_DLL H5FS_t *H5FS_new(const H5F_t *f, size_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); 226 H5_DLL herr_t H5FS_dirty(H5FS_t *fspace); 227 228 /* Free space section routines */ 229 H5_DLL H5FS_sinfo_t *H5FS_sinfo_new(H5F_t *f, H5FS_t *fspace); 230 231 /* Routines for destroying structures */ 232 H5_DLL herr_t H5FS_hdr_dest(H5FS_t *hdr); 233 H5_DLL herr_t H5FS_sinfo_dest(H5FS_sinfo_t *sinfo); 234 235 /* Sanity check routines */ 236 #ifdef H5FS_DEBUG 237 H5_DLL herr_t H5FS_assert(const H5FS_t *fspace); 238 H5_DLL herr_t H5FS_sect_assert(const H5FS_t *fspace); 239 #endif /* H5FS_DEBUG */ 240 241 /* Testing routines */ 242 #ifdef H5FS_TESTING 243 H5_DLL herr_t H5FS_get_cparam_test(const H5FS_t *fh, H5FS_create_t *cparam); 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 249