1 /** 2 * @copyright 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 * @endcopyright 22 * 23 * @file svn_fs_fs_private.h 24 * @brief Private API for tools that access FSFS internals and can't use 25 * the svn_fs_t API for that. 26 */ 27 28 29 #ifndef SVN_FS_FS_PRIVATE_H 30 #define SVN_FS_FS_PRIVATE_H 31 32 #include <apr_pools.h> 33 #include <apr_hash.h> 34 35 #include "svn_types.h" 36 #include "svn_error.h" 37 #include "svn_fs.h" 38 #include "svn_iter.h" 39 #include "svn_config.h" 40 #include "svn_string.h" 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif /* __cplusplus */ 45 46 47 48 /* Description of one large representation. It's content will be reused / 49 * overwritten when it gets replaced by an even larger representation. 50 */ 51 typedef struct svn_fs_fs__large_change_info_t 52 { 53 /* size of the (deltified) representation */ 54 apr_uint64_t size; 55 56 /* Revision of the representation. SVN_INVALID_REVNUM for unused entries. 57 */ 58 svn_revnum_t revision; 59 60 /* node path. "" for unused instances */ 61 svn_stringbuf_t *path; 62 } svn_fs_fs__large_change_info_t; 63 64 /* Container for the largest representations found so far. The capacity 65 * is fixed and entries will be inserted by reusing the last one and 66 * reshuffling the entry pointers. 67 */ 68 typedef struct svn_fs_fs__largest_changes_t 69 { 70 /* number of entries allocated in CHANGES */ 71 apr_size_t count; 72 73 /* size of the smallest change */ 74 apr_uint64_t min_size; 75 76 /* changes kept in this struct */ 77 svn_fs_fs__large_change_info_t **changes; 78 } svn_fs_fs__largest_changes_t; 79 80 /* Information we gather per size bracket. 81 */ 82 typedef struct svn_fs_fs__histogram_line_t 83 { 84 /* number of item that fall into this bracket */ 85 apr_uint64_t count; 86 87 /* sum of values in this bracket */ 88 apr_uint64_t sum; 89 } svn_fs_fs__histogram_line_t; 90 91 /* A histogram of 64 bit integer values. 92 */ 93 typedef struct svn_fs_fs__histogram_t 94 { 95 /* total sum over all brackets */ 96 svn_fs_fs__histogram_line_t total; 97 98 /* one bracket per binary step. 99 * line[i] is the 2^(i-1) <= x < 2^i bracket */ 100 svn_fs_fs__histogram_line_t lines[64]; 101 } svn_fs_fs__histogram_t; 102 103 /* Information we collect per file ending. 104 */ 105 typedef struct svn_fs_fs__extension_info_t 106 { 107 /* file extension, including leading "." 108 * "(none)" in the container for files w/o extension. */ 109 const char *extension; 110 111 /* histogram of representation sizes */ 112 svn_fs_fs__histogram_t rep_histogram; 113 114 /* histogram of sizes of changed files */ 115 svn_fs_fs__histogram_t node_histogram; 116 } svn_fs_fs__extension_info_t; 117 118 /* Compression statistics we collect over a given set of representations. 119 */ 120 typedef struct svn_fs_fs__rep_pack_stats_t 121 { 122 /* number of representations */ 123 apr_uint64_t count; 124 125 /* total size after deltification (i.e. on disk size) */ 126 apr_uint64_t packed_size; 127 128 /* total size after de-deltification (i.e. plain text size) */ 129 apr_uint64_t expanded_size; 130 131 /* total on-disk header size */ 132 apr_uint64_t overhead_size; 133 } svn_fs_fs__rep_pack_stats_t; 134 135 /* Statistics we collect over a given set of representations. 136 * We group them into shared and non-shared ("unique") reps. 137 */ 138 typedef struct svn_fs_fs__representation_stats_t 139 { 140 /* stats over all representations */ 141 svn_fs_fs__rep_pack_stats_t total; 142 143 /* stats over those representations with ref_count == 1 */ 144 svn_fs_fs__rep_pack_stats_t uniques; 145 146 /* stats over those representations with ref_count > 1 */ 147 svn_fs_fs__rep_pack_stats_t shared; 148 149 /* sum of all ref_counts */ 150 apr_uint64_t references; 151 152 /* sum of ref_count * expanded_size, 153 * i.e. total plaintext content if there was no rep sharing */ 154 apr_uint64_t expanded_size; 155 156 /* sum of all representation delta chain lengths */ 157 apr_uint64_t chain_len; 158 } svn_fs_fs__representation_stats_t; 159 160 /* Basic statistics we collect over a given set of noderevs. 161 */ 162 typedef struct svn_fs_fs__node_stats_t 163 { 164 /* number of noderev structs */ 165 apr_uint64_t count; 166 167 /* their total size on disk (structs only) */ 168 apr_uint64_t size; 169 } svn_fs_fs__node_stats_t; 170 171 /* Comprises all the information needed to create the output of the 172 * 'svnfsfs stats' command. 173 */ 174 typedef struct svn_fs_fs__stats_t 175 { 176 /* sum total of all rev / pack file sizes in bytes */ 177 apr_uint64_t total_size; 178 179 /* number of revisions in the repository */ 180 apr_uint64_t revision_count; 181 182 /* total number of changed paths */ 183 apr_uint64_t change_count; 184 185 /* sum of all changed path list sizes on disk in bytes */ 186 apr_uint64_t change_len; 187 188 /* stats on all representations */ 189 svn_fs_fs__representation_stats_t total_rep_stats; 190 191 /* stats on all file text representations */ 192 svn_fs_fs__representation_stats_t file_rep_stats; 193 194 /* stats on all directory text representations */ 195 svn_fs_fs__representation_stats_t dir_rep_stats; 196 197 /* stats on all file prop representations */ 198 svn_fs_fs__representation_stats_t file_prop_rep_stats; 199 200 /* stats on all directory prop representations */ 201 svn_fs_fs__representation_stats_t dir_prop_rep_stats; 202 203 /* size and count summary over all noderevs */ 204 svn_fs_fs__node_stats_t total_node_stats; 205 206 /* size and count summary over all file noderevs */ 207 svn_fs_fs__node_stats_t file_node_stats; 208 209 /* size and count summary over all directory noderevs */ 210 svn_fs_fs__node_stats_t dir_node_stats; 211 212 /* the biggest single contributors to repo size */ 213 svn_fs_fs__largest_changes_t *largest_changes; 214 215 /* histogram of representation sizes */ 216 svn_fs_fs__histogram_t rep_size_histogram; 217 218 /* histogram of sizes of changed nodes */ 219 svn_fs_fs__histogram_t node_size_histogram; 220 221 /* histogram of representation sizes */ 222 svn_fs_fs__histogram_t added_rep_size_histogram; 223 224 /* histogram of sizes of changed nodes */ 225 svn_fs_fs__histogram_t added_node_size_histogram; 226 227 /* histogram of unused representations */ 228 svn_fs_fs__histogram_t unused_rep_histogram; 229 230 /* histogram of sizes of changed files */ 231 svn_fs_fs__histogram_t file_histogram; 232 233 /* histogram of sizes of file representations */ 234 svn_fs_fs__histogram_t file_rep_histogram; 235 236 /* histogram of sizes of changed file property sets */ 237 svn_fs_fs__histogram_t file_prop_histogram; 238 239 /* histogram of sizes of file property representations */ 240 svn_fs_fs__histogram_t file_prop_rep_histogram; 241 242 /* histogram of sizes of changed directories (in bytes) */ 243 svn_fs_fs__histogram_t dir_histogram; 244 245 /* histogram of sizes of directories representations */ 246 svn_fs_fs__histogram_t dir_rep_histogram; 247 248 /* histogram of sizes of changed directories property sets */ 249 svn_fs_fs__histogram_t dir_prop_histogram; 250 251 /* histogram of sizes of directories property representations */ 252 svn_fs_fs__histogram_t dir_prop_rep_histogram; 253 254 /* extension -> svn_fs_fs__extension_info_t* map */ 255 apr_hash_t *by_extension; 256 } svn_fs_fs__stats_t; 257 258 259 /* Scan all contents of the repository FS and return statistics in *STATS, 260 * allocated in RESULT_POOL. Report progress through PROGRESS_FUNC with 261 * PROGRESS_BATON, if PROGRESS_FUNC is not NULL. 262 * Use SCRATCH_POOL for temporary allocations. 263 */ 264 svn_error_t * 265 svn_fs_fs__get_stats(svn_fs_fs__stats_t **stats, 266 svn_fs_t *fs, 267 svn_fs_progress_notify_func_t progress_func, 268 void *progress_baton, 269 svn_cancel_func_t cancel_func, 270 void *cancel_baton, 271 apr_pool_t *result_pool, 272 apr_pool_t *scratch_pool); 273 274 /* A node-revision ID in FSFS consists of 3 sub-IDs ("parts") that consist 275 * of a creation REVISION number and some revision- / transaction-local 276 * counter value (NUMBER). Old-style ID parts use global counter values. 277 * 278 * The parts are: node_id, copy_id and txn_id for in-txn IDs as well as 279 * node_id, copy_id and rev_item for in-revision IDs. This struct is the 280 * data structure used for each of those parts. 281 */ 282 typedef struct svn_fs_fs__id_part_t 283 { 284 /* SVN_INVALID_REVNUM for txn_id part -> not a txn, NUMBER must be 0. 285 SVN_INVALID_REVNUM for other parts -> not assigned to a revision, yet. 286 0 for other parts -> old-style ID or the root in rev 0. 287 */ 288 svn_revnum_t revision; 289 290 /* sub-id value relative to REVISION. Its interpretation depends on 291 the part itself. In rev_item, it is the index_index value, in others 292 it represents a unique counter value. */ 293 apr_uint64_t number; 294 } svn_fs_fs__id_part_t; 295 296 /* (user visible) entry in the phys-to-log index. It describes a section 297 * of some packed / non-packed rev file as containing a specific item. 298 * There must be no overlapping / conflicting entries. 299 */ 300 typedef struct svn_fs_fs__p2l_entry_t 301 { 302 /* offset of the first byte that belongs to the item */ 303 apr_off_t offset; 304 305 /* length of the item in bytes */ 306 apr_off_t size; 307 308 /* type of the item (see SVN_FS_FS__ITEM_TYPE_*) defines */ 309 apr_uint32_t type; 310 311 /* modified FNV-1a checksum. 0 if unknown checksum */ 312 apr_uint32_t fnv1_checksum; 313 314 /* item in that block */ 315 svn_fs_fs__id_part_t item; 316 } svn_fs_fs__p2l_entry_t; 317 318 319 /* Callback function type receiving a single P2L index ENTRY, a user 320 * provided BATON and a SCRATCH_POOL for temporary allocations. 321 * ENTRY's lifetime may end when the callback returns. 322 */ 323 typedef svn_error_t * 324 (*svn_fs_fs__dump_index_func_t)(const svn_fs_fs__p2l_entry_t *entry, 325 void *baton, 326 apr_pool_t *scratch_pool); 327 328 /* Read the P2L index for the rev / pack file containing REVISION in FS. 329 * For each index entry, invoke CALLBACK_FUNC with CALLBACK_BATON. 330 * If not NULL, call CANCEL_FUNC with CANCEL_BATON from time to time. 331 * Use SCRATCH_POOL for temporary allocations. 332 */ 333 svn_error_t * 334 svn_fs_fs__dump_index(svn_fs_t *fs, 335 svn_revnum_t revision, 336 svn_fs_fs__dump_index_func_t callback_func, 337 void *callback_baton, 338 svn_cancel_func_t cancel_func, 339 void *cancel_baton, 340 apr_pool_t *scratch_pool); 341 342 343 /* Rewrite the respective index information of the rev / pack file in FS 344 * containing REVISION and use the svn_fs_fs__p2l_entry_t * array ENTRIES 345 * as the new index contents. Allocate temporaries from SCRATCH_POOL. 346 * 347 * Note that this becomes a no-op if ENTRIES is empty. You may use a zero- 348 * sized empty entry instead. 349 */ 350 svn_error_t * 351 svn_fs_fs__load_index(svn_fs_t *fs, 352 svn_revnum_t revision, 353 apr_array_header_t *entries, 354 apr_pool_t *scratch_pool); 355 356 #ifdef __cplusplus 357 } 358 #endif /* __cplusplus */ 359 360 #endif /* SVN_FS_FS_PRIVATE_H */ 361