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. */
57
svn_revnum_t revision;
59
/* node path. "" for unused instances */
60
svn_stringbuf_t *path;
61
} svn_fs_fs__large_change_info_t;
63
/* Container for the largest representations found so far. The capacity
64
* is fixed and entries will be inserted by reusing the last one and
65
* reshuffling the entry pointers.
67
typedef struct svn_fs_fs__largest_changes_t
69
/* number of entries allocated in CHANGES */
72
/* size of the smallest change */
73
apr_uint64_t min_size;
75
/* changes kept in this struct */
76
svn_fs_fs__large_change_info_t **changes;
77
} svn_fs_fs__largest_changes_t;
79
/* Information we gather per size bracket.
81
typedef struct svn_fs_fs__histogram_line_t
83
/* number of item that fall into this bracket */
86
/* sum of values in this bracket */
88
} svn_fs_fs__histogram_line_t;
90
/* A histogram of 64 bit integer values.
92
typedef struct svn_fs_fs__histogram_t
94
/* total sum over all brackets */
95
svn_fs_fs__histogram_line_t total;
97
/* one bracket per binary step.
98
* line[i] is the 2^(i-1) <= x < 2^i bracket */
99
svn_fs_fs__histogram_line_t lines[64];
100
} svn_fs_fs__histogram_t;
102
/* Information we collect per file ending.
104
typedef struct svn_fs_fs__extension_info_t
106
/* file extension, including leading "."
107
* "(none)" in the container for files w/o extension. */
108
const char *extension;
110
/* histogram of representation sizes */
111
svn_fs_fs__histogram_t rep_histogram;
113
/* histogram of sizes of changed files */
114
svn_fs_fs__histogram_t node_histogram;
115
} svn_fs_fs__extension_info_t;
117
/* Compression statistics we collect over a given set of representations.
119
typedef struct svn_fs_fs__rep_pack_stats_t
121
/* number of representations */
124
/* total size after deltification (i.e. on disk size) */
125
apr_uint64_t packed_size;
127
/* total size after de-deltification (i.e. plain text size) */
128
apr_uint64_t expanded_size;
130
/* total on-disk header size */
131
apr_uint64_t overhead_size;
132
} svn_fs_fs__rep_pack_stats_t;
134
/* Statistics we collect over a given set of representations.
135
* We group them into shared and non-shared ("unique") reps.
137
typedef struct svn_fs_fs__representation_stats_t
139
/* stats over all representations */
140
svn_fs_fs__rep_pack_stats_t total;
142
/* stats over those representations with ref_count == 1 */
143
svn_fs_fs__rep_pack_stats_t uniques;
145
/* stats over those representations with ref_count > 1 */
146
svn_fs_fs__rep_pack_stats_t shared;
148
/* sum of all ref_counts */
149
apr_uint64_t references;
151
/* sum of ref_count * expanded_size,
152
* i.e. total plaintext content if there was no rep sharing */
153
apr_uint64_t expanded_size;
154
} svn_fs_fs__representation_stats_t;
156
/* Basic statistics we collect over a given set of noderevs.
158
typedef struct svn_fs_fs__node_stats_t
160
/* number of noderev structs */
163
/* their total size on disk (structs only) */
165
} svn_fs_fs__node_stats_t;
167
/* Comprises all the information needed to create the output of the
168
* 'svnfsfs stats' command.
170
typedef struct svn_fs_fs__stats_t
172
/* sum total of all rev / pack file sizes in bytes */
173
apr_uint64_t total_size;
175
/* number of revisions in the repository */
176
apr_uint64_t revision_count;
178
/* total number of changed paths */
179
apr_uint64_t change_count;
181
/* sum of all changed path list sizes on disk in bytes */
182
apr_uint64_t change_len;
184
/* stats on all representations */
185
svn_fs_fs__representation_stats_t total_rep_stats;
187
/* stats on all file text representations */
188
svn_fs_fs__representation_stats_t file_rep_stats;
190
/* stats on all directory text representations */
191
svn_fs_fs__representation_stats_t dir_rep_stats;
193
/* stats on all file prop representations */
194
svn_fs_fs__representation_stats_t file_prop_rep_stats;
196
/* stats on all directory prop representations */
197
svn_fs_fs__representation_stats_t dir_prop_rep_stats;
199
/* size and count summary over all noderevs */
200
svn_fs_fs__node_stats_t total_node_stats;
202
/* size and count summary over all file noderevs */
203
svn_fs_fs__node_stats_t file_node_stats;
205
/* size and count summary over all directory noderevs */
206
svn_fs_fs__node_stats_t dir_node_stats;
208
/* the biggest single contributors to repo size */
209
svn_fs_fs__largest_changes_t *largest_changes;
211
/* histogram of representation sizes */
212
svn_fs_fs__histogram_t rep_size_histogram;
214
/* histogram of sizes of changed nodes */
215
svn_fs_fs__histogram_t node_size_histogram;
217
/* histogram of representation sizes */
218
svn_fs_fs__histogram_t added_rep_size_histogram;
220
/* histogram of sizes of changed nodes */
221
svn_fs_fs__histogram_t added_node_size_histogram;
223
/* histogram of unused representations */
224
svn_fs_fs__histogram_t unused_rep_histogram;
226
/* histogram of sizes of changed files */
227
svn_fs_fs__histogram_t file_histogram;
229
/* histogram of sizes of file representations */
230
svn_fs_fs__histogram_t file_rep_histogram;
232
/* histogram of sizes of changed file property sets */
233
svn_fs_fs__histogram_t file_prop_histogram;
235
/* histogram of sizes of file property representations */
236
svn_fs_fs__histogram_t file_prop_rep_histogram;
238
/* histogram of sizes of changed directories (in bytes) */
239
svn_fs_fs__histogram_t dir_histogram;
241
/* histogram of sizes of directories representations */
242
svn_fs_fs__histogram_t dir_rep_histogram;
244
/* histogram of sizes of changed directories property sets */
245
svn_fs_fs__histogram_t dir_prop_histogram;
247
/* histogram of sizes of directories property representations */
248
svn_fs_fs__histogram_t dir_prop_rep_histogram;
250
/* extension -> svn_fs_fs__extension_info_t* map */
251
apr_hash_t *by_extension;
252
} svn_fs_fs__stats_t;
255
/* Scan all contents of the repository FS and return statistics in *STATS,
256
* allocated in RESULT_POOL. Report progress through PROGRESS_FUNC with
257
* PROGRESS_BATON, if PROGRESS_FUNC is not NULL.
258
* Use SCRATCH_POOL for temporary allocations.
261
svn_fs_fs__get_stats(svn_fs_fs__stats_t **stats,
263
svn_fs_progress_notify_func_t progress_func,
264
void *progress_baton,
265
svn_cancel_func_t cancel_func,
267
apr_pool_t *result_pool,
268
apr_pool_t *scratch_pool);
270
/* Node-revision IDs in FSFS consist of 3 of sub-IDs ("parts") that consist
271
* of a creation REVISION number and some revision- / transaction-local
272
* counter value (NUMBER). Old-style ID parts use global counter values.
274
* The parts are: node_id, copy_id and txn_id for in-txn IDs as well as
275
* node_id, copy_id and rev_offset for in-revision IDs. This struct the
276
* data structure used for each of those parts.
278
typedef struct svn_fs_fs__id_part_t
280
/* SVN_INVALID_REVNUM for txns -> not a txn, COUNTER must be 0.
281
SVN_INVALID_REVNUM for others -> not assigned to a revision, yet.
282
0 for others -> old-style ID or the root in rev 0. */
283
svn_revnum_t revision;
285
/* sub-id value relative to REVISION. Its interpretation depends on
286
the part itself. In rev_item, it is the index_index value, in others
287
it represents a unique counter value. */
289
} svn_fs_fs__id_part_t;
291
/* (user visible) entry in the phys-to-log index. It describes a section
292
* of some packed / non-packed rev file as containing a specific item.
293
* There must be no overlapping / conflicting entries.
295
typedef struct svn_fs_fs__p2l_entry_t
297
/* offset of the first byte that belongs to the item */
300
/* length of the item in bytes */
303
/* type of the item (see SVN_FS_FS__ITEM_TYPE_*) defines */
306
/* modified FNV-1a checksum. 0 if unknown checksum */
307
apr_uint32_t fnv1_checksum;
309
/* item in that block */
310
svn_fs_fs__id_part_t item;
311
} svn_fs_fs__p2l_entry_t;
314
/* Callback function type receiving a single P2L index ENTRY, a user
315
* provided BATON and a SCRATCH_POOL for temporary allocations.
316
* ENTRY's lifetime may end when the callback returns.
318
typedef svn_error_t *
319
(*svn_fs_fs__dump_index_func_t)(const svn_fs_fs__p2l_entry_t *entry,
321
apr_pool_t *scratch_pool);
323
/* Read the P2L index for the rev / pack file containing REVISION in FS.
324
* For each index entry, invoke CALLBACK_FUNC with CALLBACK_BATON.
325
* If not NULL, call CANCEL_FUNC with CANCEL_BATON from time to time.
326
* Use SCRATCH_POOL for temporary allocations.
329
svn_fs_fs__dump_index(svn_fs_t *fs,
330
svn_revnum_t revision,
331
svn_fs_fs__dump_index_func_t callback_func,
332
void *callback_baton,
333
svn_cancel_func_t cancel_func,
335
apr_pool_t *scratch_pool);
338
/* Rewrite the respective index information of the rev / pack file in FS
339
* containing REVISION and use the svn_fs_fs__p2l_entry_t * array ENTRIES
340
* as the new index contents. Allocate temporaries from SCRATCH_POOL.
342
* Note that this becomes a no-op if ENTRIES is empty. You may use a zero-
343
* sized empty entry instead.
346
svn_fs_fs__load_index(svn_fs_t *fs,
347
svn_revnum_t revision,
348
apr_array_header_t *entries,
349
apr_pool_t *scratch_pool);
353
#endif /* __cplusplus */
355
#endif /* SVN_FS_FS_PRIVATE_H */