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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
20 * ====================================================================
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.
29 #ifndef SVN_FS_FS_PRIVATE_H
30 #define SVN_FS_FS_PRIVATE_H
32 #include <apr_pools.h>
35 #include "svn_types.h"
36 #include "svn_error.h"
39 #include "svn_config.h"
40 #include "svn_string.h"
44 #endif /* __cplusplus */
48 /* Description of one large representation. It's content will be reused /
49 * overwritten when it gets replaced by an even larger representation.
51 typedef struct svn_fs_fs__large_change_info_t
53 /* size of the (deltified) representation */
56 /* Revision of the representation. SVN_INVALID_REVNUM for unused entries.
58 svn_revnum_t revision;
60 /* node path. "" for unused instances */
61 svn_stringbuf_t *path;
62 } svn_fs_fs__large_change_info_t;
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.
68 typedef struct svn_fs_fs__largest_changes_t
70 /* number of entries allocated in CHANGES */
73 /* size of the smallest change */
74 apr_uint64_t min_size;
76 /* changes kept in this struct */
77 svn_fs_fs__large_change_info_t **changes;
78 } svn_fs_fs__largest_changes_t;
80 /* Information we gather per size bracket.
82 typedef struct svn_fs_fs__histogram_line_t
84 /* number of item that fall into this bracket */
87 /* sum of values in this bracket */
89 } svn_fs_fs__histogram_line_t;
91 /* A histogram of 64 bit integer values.
93 typedef struct svn_fs_fs__histogram_t
95 /* total sum over all brackets */
96 svn_fs_fs__histogram_line_t total;
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;
103 /* Information we collect per file ending.
105 typedef struct svn_fs_fs__extension_info_t
107 /* file extension, including leading "."
108 * "(none)" in the container for files w/o extension. */
109 const char *extension;
111 /* histogram of representation sizes */
112 svn_fs_fs__histogram_t rep_histogram;
114 /* histogram of sizes of changed files */
115 svn_fs_fs__histogram_t node_histogram;
116 } svn_fs_fs__extension_info_t;
118 /* Compression statistics we collect over a given set of representations.
120 typedef struct svn_fs_fs__rep_pack_stats_t
122 /* number of representations */
125 /* total size after deltification (i.e. on disk size) */
126 apr_uint64_t packed_size;
128 /* total size after de-deltification (i.e. plain text size) */
129 apr_uint64_t expanded_size;
131 /* total on-disk header size */
132 apr_uint64_t overhead_size;
133 } svn_fs_fs__rep_pack_stats_t;
135 /* Statistics we collect over a given set of representations.
136 * We group them into shared and non-shared ("unique") reps.
138 typedef struct svn_fs_fs__representation_stats_t
140 /* stats over all representations */
141 svn_fs_fs__rep_pack_stats_t total;
143 /* stats over those representations with ref_count == 1 */
144 svn_fs_fs__rep_pack_stats_t uniques;
146 /* stats over those representations with ref_count > 1 */
147 svn_fs_fs__rep_pack_stats_t shared;
149 /* sum of all ref_counts */
150 apr_uint64_t references;
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;
156 /* sum of all representation delta chain lengths */
157 apr_uint64_t chain_len;
158 } svn_fs_fs__representation_stats_t;
160 /* Basic statistics we collect over a given set of noderevs.
162 typedef struct svn_fs_fs__node_stats_t
164 /* number of noderev structs */
167 /* their total size on disk (structs only) */
169 } svn_fs_fs__node_stats_t;
171 /* Comprises all the information needed to create the output of the
172 * 'svnfsfs stats' command.
174 typedef struct svn_fs_fs__stats_t
176 /* sum total of all rev / pack file sizes in bytes */
177 apr_uint64_t total_size;
179 /* number of revisions in the repository */
180 apr_uint64_t revision_count;
182 /* total number of changed paths */
183 apr_uint64_t change_count;
185 /* sum of all changed path list sizes on disk in bytes */
186 apr_uint64_t change_len;
188 /* stats on all representations */
189 svn_fs_fs__representation_stats_t total_rep_stats;
191 /* stats on all file text representations */
192 svn_fs_fs__representation_stats_t file_rep_stats;
194 /* stats on all directory text representations */
195 svn_fs_fs__representation_stats_t dir_rep_stats;
197 /* stats on all file prop representations */
198 svn_fs_fs__representation_stats_t file_prop_rep_stats;
200 /* stats on all directory prop representations */
201 svn_fs_fs__representation_stats_t dir_prop_rep_stats;
203 /* size and count summary over all noderevs */
204 svn_fs_fs__node_stats_t total_node_stats;
206 /* size and count summary over all file noderevs */
207 svn_fs_fs__node_stats_t file_node_stats;
209 /* size and count summary over all directory noderevs */
210 svn_fs_fs__node_stats_t dir_node_stats;
212 /* the biggest single contributors to repo size */
213 svn_fs_fs__largest_changes_t *largest_changes;
215 /* histogram of representation sizes */
216 svn_fs_fs__histogram_t rep_size_histogram;
218 /* histogram of sizes of changed nodes */
219 svn_fs_fs__histogram_t node_size_histogram;
221 /* histogram of representation sizes */
222 svn_fs_fs__histogram_t added_rep_size_histogram;
224 /* histogram of sizes of changed nodes */
225 svn_fs_fs__histogram_t added_node_size_histogram;
227 /* histogram of unused representations */
228 svn_fs_fs__histogram_t unused_rep_histogram;
230 /* histogram of sizes of changed files */
231 svn_fs_fs__histogram_t file_histogram;
233 /* histogram of sizes of file representations */
234 svn_fs_fs__histogram_t file_rep_histogram;
236 /* histogram of sizes of changed file property sets */
237 svn_fs_fs__histogram_t file_prop_histogram;
239 /* histogram of sizes of file property representations */
240 svn_fs_fs__histogram_t file_prop_rep_histogram;
242 /* histogram of sizes of changed directories (in bytes) */
243 svn_fs_fs__histogram_t dir_histogram;
245 /* histogram of sizes of directories representations */
246 svn_fs_fs__histogram_t dir_rep_histogram;
248 /* histogram of sizes of changed directories property sets */
249 svn_fs_fs__histogram_t dir_prop_histogram;
251 /* histogram of sizes of directories property representations */
252 svn_fs_fs__histogram_t dir_prop_rep_histogram;
254 /* extension -> svn_fs_fs__extension_info_t* map */
255 apr_hash_t *by_extension;
256 } svn_fs_fs__stats_t;
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.
265 svn_fs_fs__get_stats(svn_fs_fs__stats_t **stats,
267 svn_fs_progress_notify_func_t progress_func,
268 void *progress_baton,
269 svn_cancel_func_t cancel_func,
271 apr_pool_t *result_pool,
272 apr_pool_t *scratch_pool);
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.
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.
282 typedef struct svn_fs_fs__id_part_t
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.
288 svn_revnum_t revision;
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. */
294 } svn_fs_fs__id_part_t;
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.
300 typedef struct svn_fs_fs__p2l_entry_t
302 /* offset of the first byte that belongs to the item */
305 /* length of the item in bytes */
308 /* type of the item (see SVN_FS_FS__ITEM_TYPE_*) defines */
311 /* modified FNV-1a checksum. 0 if unknown checksum */
312 apr_uint32_t fnv1_checksum;
314 /* item in that block */
315 svn_fs_fs__id_part_t item;
316 } svn_fs_fs__p2l_entry_t;
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.
323 typedef svn_error_t *
324 (*svn_fs_fs__dump_index_func_t)(const svn_fs_fs__p2l_entry_t *entry,
326 apr_pool_t *scratch_pool);
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.
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,
340 apr_pool_t *scratch_pool);
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.
347 * Note that this becomes a no-op if ENTRIES is empty. You may use a zero-
348 * sized empty entry instead.
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);
358 #endif /* __cplusplus */
360 #endif /* SVN_FS_FS_PRIVATE_H */