fs.h revision 362181
1/* fs.h : interface to Subversion filesystem, private to libsvn_fs
2 *
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 */
22
23#ifndef SVN_LIBSVN_FS_FS_H
24#define SVN_LIBSVN_FS_FS_H
25
26#include <apr_pools.h>
27#include <apr_hash.h>
28#include <apr_network_io.h>
29#include <apr_md5.h>
30#include <apr_sha1.h>
31
32#include "svn_fs.h"
33#include "svn_config.h"
34#include "private/svn_atomic.h"
35#include "private/svn_cache.h"
36#include "private/svn_fs_private.h"
37#include "private/svn_sqlite.h"
38#include "private/svn_mutex.h"
39
40#include "rev_file.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif /* __cplusplus */
45
46
47/*** The filesystem structure.  ***/
48
49/* Following are defines that specify the textual elements of the
50   native filesystem directories and revision files. */
51
52/* Names of special files in the fs_fs filesystem. */
53#define PATH_FORMAT           "format"           /* Contains format number */
54#define PATH_UUID             "uuid"             /* Contains UUID */
55#define PATH_CURRENT          "current"          /* Youngest revision */
56#define PATH_LOCK_FILE        "write-lock"       /* Revision lock file */
57#define PATH_PACK_LOCK_FILE   "pack-lock"        /* Pack lock file */
58#define PATH_REVS_DIR         "revs"             /* Directory of revisions */
59#define PATH_REVPROPS_DIR     "revprops"         /* Directory of revprops */
60#define PATH_TXNS_DIR         "transactions"     /* Directory of transactions in
61                                                    repos w/o log addressing */
62#define PATH_NODE_ORIGINS_DIR "node-origins"     /* Lazy node-origin cache */
63#define PATH_TXN_PROTOS_DIR   "txn-protorevs"    /* Directory of proto-revs */
64#define PATH_TXN_CURRENT      "txn-current"      /* File with next txn key */
65#define PATH_TXN_CURRENT_LOCK "txn-current-lock" /* Lock for txn-current */
66#define PATH_LOCKS_DIR        "locks"            /* Directory of locks */
67#define PATH_MIN_UNPACKED_REV "min-unpacked-rev" /* Oldest revision which
68                                                    has not been packed. */
69#define PATH_REVPROP_GENERATION "revprop-generation"
70                                                 /* Current revprop generation*/
71#define PATH_MANIFEST         "manifest"         /* Manifest file name */
72#define PATH_PACKED           "pack"             /* Packed revision data file */
73#define PATH_EXT_PACKED_SHARD ".pack"            /* Extension for packed
74                                                    shards */
75#define PATH_EXT_L2P_INDEX    ".l2p"             /* extension of the log-
76                                                    to-phys index */
77#define PATH_EXT_P2L_INDEX    ".p2l"             /* extension of the phys-
78                                                    to-log index */
79/* If you change this, look at tests/svn_test_fs.c(maybe_install_fsfs_conf) */
80#define PATH_CONFIG           "fsfs.conf"        /* Configuration */
81
82/* Names of special files and file extensions for transactions */
83#define PATH_CHANGES       "changes"       /* Records changes made so far */
84#define PATH_TXN_PROPS     "props"         /* Transaction properties */
85#define PATH_NEXT_IDS      "next-ids"      /* Next temporary ID assignments */
86#define PATH_PREFIX_NODE   "node."         /* Prefix for node filename */
87#define PATH_EXT_TXN       ".txn"          /* Extension of txn dir */
88#define PATH_EXT_CHILDREN  ".children"     /* Extension for dir contents */
89#define PATH_EXT_PROPS     ".props"        /* Extension for node props */
90#define PATH_EXT_REV       ".rev"          /* Extension of protorev file */
91#define PATH_EXT_REV_LOCK  ".rev-lock"     /* Extension of protorev lock file */
92#define PATH_TXN_ITEM_INDEX "itemidx"      /* File containing the current item
93                                              index number */
94#define PATH_INDEX          "index"        /* name of index files w/o ext */
95
96/* Names of files in legacy FS formats */
97#define PATH_REV           "rev"           /* Proto rev file */
98#define PATH_REV_LOCK      "rev-lock"      /* Proto rev (write) lock file */
99
100/* Names of sections and options in fsfs.conf. */
101#define CONFIG_SECTION_CACHES            "caches"
102#define CONFIG_OPTION_FAIL_STOP          "fail-stop"
103#define CONFIG_SECTION_REP_SHARING       "rep-sharing"
104#define CONFIG_OPTION_ENABLE_REP_SHARING "enable-rep-sharing"
105#define CONFIG_SECTION_DELTIFICATION     "deltification"
106#define CONFIG_OPTION_ENABLE_DIR_DELTIFICATION   "enable-dir-deltification"
107#define CONFIG_OPTION_ENABLE_PROPS_DELTIFICATION "enable-props-deltification"
108#define CONFIG_OPTION_MAX_DELTIFICATION_WALK     "max-deltification-walk"
109#define CONFIG_OPTION_MAX_LINEAR_DELTIFICATION   "max-linear-deltification"
110#define CONFIG_OPTION_COMPRESSION_LEVEL  "compression-level"
111#define CONFIG_SECTION_PACKED_REVPROPS   "packed-revprops"
112#define CONFIG_OPTION_REVPROP_PACK_SIZE  "revprop-pack-size"
113#define CONFIG_OPTION_COMPRESS_PACKED_REVPROPS  "compress-packed-revprops"
114#define CONFIG_SECTION_IO                "io"
115#define CONFIG_OPTION_BLOCK_SIZE         "block-size"
116#define CONFIG_OPTION_L2P_PAGE_SIZE      "l2p-page-size"
117#define CONFIG_OPTION_P2L_PAGE_SIZE      "p2l-page-size"
118#define CONFIG_SECTION_DEBUG             "debug"
119#define CONFIG_OPTION_PACK_AFTER_COMMIT  "pack-after-commit"
120#define CONFIG_OPTION_VERIFY_BEFORE_COMMIT "verify-before-commit"
121#define CONFIG_OPTION_COMPRESSION        "compression"
122
123/* The format number of this filesystem.
124   This is independent of the repository format number, and
125   independent of any other FS back ends.
126
127   Note: If you bump this, please update the switch statement in
128         svn_fs_fs__create() as well.
129 */
130#define SVN_FS_FS__FORMAT_NUMBER   8
131
132/* The minimum format number that supports svndiff version 1.  */
133#define SVN_FS_FS__MIN_SVNDIFF1_FORMAT 2
134
135/* The minimum format number that supports transaction ID generation
136   using a transaction sequence in the txn-current file. */
137#define SVN_FS_FS__MIN_TXN_CURRENT_FORMAT 3
138
139/* The minimum format number that supports the "layout" filesystem
140   format option. */
141#define SVN_FS_FS__MIN_LAYOUT_FORMAT_OPTION_FORMAT 3
142
143/* The minimum format number that stores protorevs in a separate directory. */
144#define SVN_FS_FS__MIN_PROTOREVS_DIR_FORMAT 3
145
146/* The minimum format number that doesn't keep node and copy ID counters. */
147#define SVN_FS_FS__MIN_NO_GLOBAL_IDS_FORMAT 3
148
149/* The minimum format number that maintains minfo-here and minfo-count
150   noderev fields. */
151#define SVN_FS_FS__MIN_MERGEINFO_FORMAT 3
152
153/* The minimum format number that allows rep sharing. */
154#define SVN_FS_FS__MIN_REP_SHARING_FORMAT 4
155
156/* The minimum format number that supports packed shards. */
157#define SVN_FS_FS__MIN_PACKED_FORMAT 4
158
159/* The minimum format number that stores node kinds in changed-paths lists. */
160#define SVN_FS_FS__MIN_KIND_IN_CHANGED_FORMAT 4
161
162/* 1.8 deltification options should work with any FSFS repo but to avoid
163 * issues with very old servers, restrict those options to the 1.6+ format*/
164#define SVN_FS_FS__MIN_DELTIFICATION_FORMAT 4
165
166/* The minimum format number that supports a configuration file (fsfs.conf) */
167#define SVN_FS_FS__MIN_CONFIG_FILE 4
168
169/* The 1.7-dev format, never released, that packed revprops into SQLite
170   revprops.db . */
171#define SVN_FS_FS__PACKED_REVPROP_SQLITE_DEV_FORMAT 5
172
173/* The minimum format number that supports packed revprops. */
174#define SVN_FS_FS__MIN_PACKED_REVPROP_FORMAT 6
175
176/* The minimum format number that supports packed revprops. */
177#define SVN_FS_FS__MIN_LOG_ADDRESSING_FORMAT 7
178
179/* Minimum format number that providing a separate lock file for pack ops */
180#define SVN_FS_FS__MIN_PACK_LOCK_FORMAT 7
181
182/* Minimum format number that stores mergeinfo-mode flag in changed paths */
183#define SVN_FS_FS__MIN_MERGEINFO_IN_CHANGED_FORMAT 7
184
185/* Minimum format number that supports per-instance filesystem IDs. */
186#define SVN_FS_FS__MIN_INSTANCE_ID_FORMAT 7
187
188/* The minimum format number that supports svndiff version 2. */
189#define SVN_FS_FS__MIN_SVNDIFF2_FORMAT 8
190
191/* The minimum format number that supports the special notation ("-")
192   for optional values that are not present in the representation strings,
193   such as SHA1 or the uniquifier.  For example:
194
195     15 0 563 7809 28ef320a82e7bd11eebdf3502d69e608 - 14-g/_5
196 */
197#define SVN_FS_FS__MIN_REP_STRING_OPTIONAL_VALUES_FORMAT 8
198
199 /* The minimum format number that supports V2 schema of the rep-cache.db
200    database. */
201#define SVN_FS_FS__MIN_REP_CACHE_SCHEMA_V2_FORMAT 8
202
203/* On most operating systems apr implements file locks per process, not
204   per file.  On Windows apr implements the locking as per file handle
205   locks, so we don't have to add our own mutex for just in-process
206   synchronization. */
207#if APR_HAS_THREADS && !defined(WIN32)
208#define SVN_FS_FS__USE_LOCK_MUTEX 1
209#else
210#define SVN_FS_FS__USE_LOCK_MUTEX 0
211#endif
212
213/* Maximum number of changes we deliver per request when listing the
214   changed paths for a given revision.   Anything > 0 will do.
215   At 100..300 bytes per entry, this limits the allocation to ~30kB. */
216#define SVN_FS_FS__CHANGES_BLOCK_SIZE 100
217
218/* Private FSFS-specific data shared between all svn_txn_t objects that
219   relate to a particular transaction in a filesystem (as identified
220   by transaction id and filesystem UUID).  Objects of this type are
221   allocated in their own subpool of the common pool. */
222typedef struct fs_fs_shared_txn_data_t
223{
224  /* The next transaction in the list, or NULL if there is no following
225     transaction. */
226  struct fs_fs_shared_txn_data_t *next;
227
228  /* ID of this transaction. */
229  svn_fs_fs__id_part_t txn_id;
230
231  /* Whether the transaction's prototype revision file is locked for
232     writing by any thread in this process (including the current
233     thread; recursive locks are not permitted).  This is effectively
234     a non-recursive mutex. */
235  svn_boolean_t being_written;
236
237  /* The pool in which this object has been allocated; a subpool of the
238     common pool. */
239  apr_pool_t *pool;
240} fs_fs_shared_txn_data_t;
241
242/* Private FSFS-specific data shared between all svn_fs_t objects that
243   relate to a particular filesystem, as identified by filesystem UUID.
244   Objects of this type are allocated in the common pool. */
245typedef struct fs_fs_shared_data_t
246{
247  /* A list of shared transaction objects for each transaction that is
248     currently active, or NULL if none are.  All access to this list,
249     including the contents of the objects stored in it, is synchronised
250     under TXN_LIST_LOCK. */
251  fs_fs_shared_txn_data_t *txns;
252
253  /* A free transaction object, or NULL if there is no free object.
254     Access to this object is synchronised under TXN_LIST_LOCK. */
255  fs_fs_shared_txn_data_t *free_txn;
256
257  /* The following lock must be taken out in reverse order of their
258     declaration here.  Any subset may be acquired and held at any given
259     time but their relative acquisition order must not change.
260
261     (lock 'txn-current' before 'pack' before 'write' before 'txn-list') */
262
263  /* A lock for intra-process synchronization when accessing the TXNS list. */
264  svn_mutex__t *txn_list_lock;
265
266  /* A lock for intra-process synchronization when grabbing the
267     repository write lock. */
268  svn_mutex__t *fs_write_lock;
269
270  /* A lock for intra-process synchronization when grabbing the
271     repository pack operation lock. */
272  svn_mutex__t *fs_pack_lock;
273
274  /* A lock for intra-process synchronization when locking the
275     txn-current file. */
276  svn_mutex__t *txn_current_lock;
277
278  /* The common pool, under which this object is allocated, subpools
279     of which are used to allocate the transaction objects. */
280  apr_pool_t *common_pool;
281} fs_fs_shared_data_t;
282
283/* Data structure for the 1st level DAG node cache. */
284typedef struct fs_fs_dag_cache_t fs_fs_dag_cache_t;
285
286/* Key type for all caches that use revision + offset / counter as key.
287
288   Note: Cache keys should be 16 bytes for best performance and there
289         should be no padding. */
290typedef struct pair_cache_key_t
291{
292  /* The object's revision.  Use the 64 data type to prevent padding. */
293  apr_int64_t revision;
294
295  /* Sub-address: item index, revprop generation, packed flag, etc. */
296  apr_int64_t second;
297} pair_cache_key_t;
298
299/* Key type that identifies a txdelta window.
300
301   Note: Cache keys should require no padding. */
302typedef struct window_cache_key_t
303{
304  /* The object's revision.  Use the 64 data type to prevent padding. */
305  apr_int64_t revision;
306
307  /* Window number within that representation. */
308  apr_int64_t chunk_index;
309
310  /* Item index of the representation */
311  apr_uint64_t item_index;
312} window_cache_key_t;
313
314typedef enum compression_type_t
315{
316  compression_type_none,
317  compression_type_zlib,
318  compression_type_lz4
319} compression_type_t;
320
321/* Private (non-shared) FSFS-specific data for each svn_fs_t object.
322   Any caches in here may be NULL. */
323typedef struct fs_fs_data_t
324{
325  /* The format number of this FS. */
326  int format;
327
328  /* The maximum number of files to store per directory (for sharded
329     layouts) or zero (for linear layouts). */
330  int max_files_per_dir;
331
332  /* If set, this FS is using logical addressing. Otherwise, it is using
333     physical addressing. */
334  svn_boolean_t use_log_addressing;
335
336  /* Rev / pack file read granularity in bytes. */
337  apr_int64_t block_size;
338
339  /* Capacity in entries of log-to-phys index pages */
340  apr_int64_t l2p_page_size;
341
342  /* Rev / pack file granularity (in bytes) covered by a single phys-to-log
343   * index page. */
344  apr_int64_t p2l_page_size;
345
346  /* If set, parse and cache *all* data of each block that we read
347   * (not just the one bit that we need, atm). */
348  svn_boolean_t use_block_read;
349
350  /* The revision that was youngest, last time we checked. */
351  svn_revnum_t youngest_rev_cache;
352
353  /* Caches of immutable data.  (Note that these may be shared between
354     multiple svn_fs_t's for the same filesystem.) */
355
356  /* Access to the configured memcached instances.  May be NULL. */
357  svn_memcache_t *memcache;
358
359  /* If TRUE, don't ignore any cache-related errors.  If FALSE, errors from
360     e.g. memcached may be ignored as caching is an optional feature. */
361  svn_boolean_t fail_stop;
362
363  /* A cache of revision root IDs, mapping from (svn_revnum_t *) to
364     (svn_fs_id_t *).  (Not threadsafe.) */
365  svn_cache__t *rev_root_id_cache;
366
367  /* Caches native dag_node_t* instances and acts as a 1st level cache */
368  fs_fs_dag_cache_t *dag_node_cache;
369
370  /* DAG node cache for immutable nodes.  Maps (revision, fspath)
371     to (dag_node_t *). This is the 2nd level cache for DAG nodes. */
372  svn_cache__t *rev_node_cache;
373
374  /* A cache of the contents of immutable directories; maps from
375     unparsed FS ID to a apr_hash_t * mapping (const char *) dirent
376     names to (svn_fs_dirent_t *). */
377  svn_cache__t *dir_cache;
378
379  /* Fulltext cache; currently only used with memcached.  Maps from
380     rep key (revision/offset) to svn_stringbuf_t. */
381  svn_cache__t *fulltext_cache;
382
383  /* The current prefix to be used for revprop cache entries.
384     If this is 0, a new unique prefix must be chosen. */
385  apr_uint64_t revprop_prefix;
386
387  /* Revision property cache.  Maps from (rev,prefix) to apr_hash_t.
388     Unparsed svn_string_t representations of the serialized hash
389     will be written to the cache but the getter returns apr_hash_t. */
390  svn_cache__t *revprop_cache;
391
392  /* Node properties cache.  Maps from rep key to apr_hash_t. */
393  svn_cache__t *properties_cache;
394
395  /* Pack manifest cache; a cache mapping (svn_revnum_t) shard number to
396     a manifest; and a manifest is a mapping from (svn_revnum_t) revision
397     number offset within a shard to (apr_off_t) byte-offset in the
398     respective pack file. */
399  svn_cache__t *packed_offset_cache;
400
401  /* Cache for svn_fs_fs__raw_cached_window_t objects; the key is
402     window_cache_key_t. */
403  svn_cache__t *raw_window_cache;
404
405  /* Cache for txdelta_window_t objects; the key is window_cache_key_t */
406  svn_cache__t *txdelta_window_cache;
407
408  /* Cache for combined windows as svn_stringbuf_t objects;
409     the key is window_cache_key_t */
410  svn_cache__t *combined_window_cache;
411
412  /* Cache for node_revision_t objects; the key is (revision, item_index) */
413  svn_cache__t *node_revision_cache;
414
415  /* Cache for change lists n blocks as svn_fs_fs__changes_list_t * objects;
416     the key is the (revision, first-element-in-block) pair. */
417  svn_cache__t *changes_cache;
418
419  /* Cache for svn_fs_fs__rep_header_t objects; the key is a
420     (revision, item index) pair */
421  svn_cache__t *rep_header_cache;
422
423  /* Cache for svn_mergeinfo_t objects; the key is a combination of
424     revision, inheritance flags and path. */
425  svn_cache__t *mergeinfo_cache;
426
427  /* Cache for presence of svn_mergeinfo_t on a noderev; the key is a
428     combination of revision, inheritance flags and path; value is "1"
429     if the node has mergeinfo, "0" if it doesn't. */
430  svn_cache__t *mergeinfo_existence_cache;
431
432  /* Cache for l2p_header_t objects; the key is (revision, is-packed).
433     Will be NULL for pre-format7 repos */
434  svn_cache__t *l2p_header_cache;
435
436  /* Cache for l2p_page_t objects; the key is svn_fs_fs__page_cache_key_t.
437     Will be NULL for pre-format7 repos */
438  svn_cache__t *l2p_page_cache;
439
440  /* Cache for p2l_header_t objects; the key is (revision, is-packed).
441     Will be NULL for pre-format7 repos */
442  svn_cache__t *p2l_header_cache;
443
444  /* Cache for apr_array_header_t objects containing svn_fs_fs__p2l_entry_t
445     elements; the key is svn_fs_fs__page_cache_key_t.
446     Will be NULL for pre-format7 repos */
447  svn_cache__t *p2l_page_cache;
448
449  /* TRUE while the we hold a lock on the write lock file. */
450  svn_boolean_t has_write_lock;
451
452  /* If set, there are or have been more than one concurrent transaction */
453  svn_boolean_t concurrent_transactions;
454
455  /* Temporary cache for changed directories yet to be committed; maps from
456     unparsed FS ID to ###x.  NULL outside transactions. */
457  svn_cache__t *txn_dir_cache;
458
459  /* Data shared between all svn_fs_t objects for a given filesystem. */
460  fs_fs_shared_data_t *shared;
461
462  /* The sqlite database used for rep caching. */
463  svn_sqlite__db_t *rep_cache_db;
464
465  /* Thread-safe boolean */
466  svn_atomic_t rep_cache_db_opened;
467
468  /* The oldest revision not in a pack file.  It also applies to revprops
469   * if revprop packing has been enabled by the FSFS format version. */
470  svn_revnum_t min_unpacked_rev;
471
472  /* Whether rep-sharing is supported by the filesystem
473   * and allowed by the configuration. */
474  svn_boolean_t rep_sharing_allowed;
475
476  /* File size limit in bytes up to which multiple revprops shall be packed
477   * into a single file. */
478  apr_int64_t revprop_pack_size;
479
480  /* Whether packed revprop files shall be compressed. */
481  svn_boolean_t compress_packed_revprops;
482
483  /* Whether directory nodes shall be deltified just like file nodes. */
484  svn_boolean_t deltify_directories;
485
486  /* Whether nodes properties shall be deltified. */
487  svn_boolean_t deltify_properties;
488
489  /* Restart deltification histories after each multiple of this value */
490  apr_int64_t max_deltification_walk;
491
492  /* Maximum number of length of the linear part at the top of the
493   * deltification history after which skip deltas will be used. */
494  apr_int64_t max_linear_deltification;
495
496  /* Compression type to use with txdelta storage format in new revs. */
497  compression_type_t delta_compression_type;
498
499  /* Compression level (currently, only used with compression_type_zlib). */
500  int delta_compression_level;
501
502  /* Pack after every commit. */
503  svn_boolean_t pack_after_commit;
504
505  /* Verify each new revision before commit. */
506  svn_boolean_t verify_before_commit;
507
508  /* Per-instance filesystem ID, which provides an additional level of
509     uniqueness for filesystems that share the same UUID, but should
510     still be distinguishable (e.g. backups produced by svn_fs_hotcopy()
511     or dump / load cycles). */
512  const char *instance_id;
513
514  /* Ensure that all filesystem changes are written to disk. */
515  svn_boolean_t flush_to_disk;
516
517  /* Pointer to svn_fs_open. */
518  svn_error_t *(*svn_fs_open_)(svn_fs_t **, const char *, apr_hash_t *,
519                               apr_pool_t *, apr_pool_t *);
520} fs_fs_data_t;
521
522
523/*** Filesystem Transaction ***/
524typedef struct transaction_t
525{
526  /* node revision id of the root node.  */
527  const svn_fs_id_t *root_id;
528
529  /* node revision id of the node which is the root of the revision
530     upon which this txn is base.  (unfinished only) */
531  const svn_fs_id_t *base_id;
532
533  /* copies list (const char * copy_ids), or NULL if there have been
534     no copies in this transaction.  */
535  apr_array_header_t *copies;
536
537} transaction_t;
538
539
540/*** Representation ***/
541/* If you add fields to this, check to see if you need to change
542 * svn_fs_fs__rep_copy. */
543typedef struct representation_t
544{
545  /* Checksums digests for the contents produced by this representation.
546     This checksum is for the contents the rep shows to consumers,
547     regardless of how the rep stores the data under the hood.  It is
548     independent of the storage (fulltext, delta, whatever).
549
550     If has_sha1 is FALSE, then for compatibility behave as though this
551     checksum matches the expected checksum.
552
553     The md5 checksum is always filled, unless this is rep which was
554     retrieved from the rep-cache.  The sha1 checksum is only computed on
555     a write, for use with rep-sharing. */
556  svn_boolean_t has_sha1;
557  unsigned char sha1_digest[APR_SHA1_DIGESTSIZE];
558  unsigned char md5_digest[APR_MD5_DIGESTSIZE];
559
560  /* Revision where this representation is located. */
561  svn_revnum_t revision;
562
563  /* Item index with the revision. */
564  apr_uint64_t item_index;
565
566  /* The size of the representation in bytes as seen in the revision
567     file. */
568  svn_filesize_t size;
569
570  /* The size of the fulltext of the representation. If this is 0,
571   * for a plain rep, the real fulltext size is equal to the SIZE field.
572   * For a delta rep, this field is always the real fulltext size.
573   *
574   * Note that svn_fs_fs__fixup_expanded_size() checks for these special
575   * cases and ensures that this field contains the actual value.  We call
576   * it early after reading a representation struct, so most code does not
577   * have to worry about it.
578   */
579  svn_filesize_t expanded_size;
580
581  /* Is this a representation (still) within a transaction? */
582  svn_fs_fs__id_part_t txn_id;
583
584  /* For rep-sharing, we need a way of uniquifying node-revs which share the
585     same representation (see svn_fs_fs__noderev_same_rep_key() ).  So, we
586     store the original txn of the node rev (not the rep!), along with some
587     intra-node uniqification content. */
588  struct
589    {
590      /* unique context, i.e. txn ID, in which the noderev (!) got created */
591      svn_fs_fs__id_part_t noderev_txn_id;
592
593      /* unique value within that txn */
594      apr_uint64_t number;
595    } uniquifier;
596} representation_t;
597
598
599/*** Node-Revision ***/
600/* If you add fields to this, check to see if you need to change
601 * copy_node_revision in dag.c. */
602typedef struct node_revision_t
603{
604  /* node kind */
605  svn_node_kind_t kind;
606
607  /* The node-id for this node-rev. */
608  const svn_fs_id_t *id;
609
610  /* predecessor node revision id, or NULL if there is no predecessor
611     for this node revision */
612  const svn_fs_id_t *predecessor_id;
613
614  /* If this node-rev is a copy, where was it copied from? */
615  const char *copyfrom_path;
616  svn_revnum_t copyfrom_rev;
617
618  /* Helper for history tracing, root of the parent tree from whence
619     this node-rev was copied. */
620  svn_revnum_t copyroot_rev;
621  const char *copyroot_path;
622
623  /* Number of predecessors this node revision has (recursively).
624     A difference from the BDB backend is that it cannot be -1. */
625  int predecessor_count;
626
627  /* representation key for this node's properties.  may be NULL if
628     there are no properties.  */
629  representation_t *prop_rep;
630
631  /* representation for this node's data.  may be NULL if there is
632     no data. */
633  representation_t *data_rep;
634
635  /* path at which this node first came into existence.  */
636  const char *created_path;
637
638  /* is this the unmodified root of a transaction? */
639  svn_boolean_t is_fresh_txn_root;
640
641  /* Number of nodes with svn:mergeinfo properties that are
642     descendants of this node (including it itself) */
643  apr_int64_t mergeinfo_count;
644
645  /* Does this node itself have svn:mergeinfo? */
646  svn_boolean_t has_mergeinfo;
647
648} node_revision_t;
649
650
651/*** Change ***/
652typedef struct change_t
653{
654  /* Path of the change. */
655  svn_string_t path;
656
657  /* API compatible change description */
658  svn_fs_path_change2_t info;
659} change_t;
660
661
662/*** Context for reading changed paths lists iteratively. */
663typedef struct svn_fs_fs__changes_context_t
664{
665  /* Repository to fetch from. */
666  svn_fs_t *fs;
667
668  /* Revision that we read from. */
669  svn_revnum_t revision;
670
671  /* Revision file object to use when needed.  NULL until the first access. */
672  svn_fs_fs__revision_file_t *revision_file;
673
674  /* Pool to create REVISION_FILE in. */
675  apr_pool_t *rev_file_pool;
676
677  /* Index of the next change to fetch. */
678  apr_size_t next;
679
680  /* Offset, within the changed paths list on disk, of the next change to
681     fetch. */
682  apr_off_t next_offset;
683
684  /* Has the end of the list been reached? */
685  svn_boolean_t eol;
686
687} svn_fs_fs__changes_context_t;
688
689/*** Directory (only used at the cache interface) ***/
690typedef struct svn_fs_fs__dir_data_t
691{
692  /* Contents, i.e. all directory entries, sorted by name. */
693  apr_array_header_t *entries;
694
695  /* SVN_INVALID_FILESIZE for committed data, otherwise the length of the
696   * in-txn on-disk representation of that directory. */
697  svn_filesize_t txn_filesize;
698} svn_fs_fs__dir_data_t;
699
700
701#ifdef __cplusplus
702}
703#endif /* __cplusplus */
704
705#endif /* SVN_LIBSVN_FS_FS_H */
706