Remove no-longer-used svn_*_get_mergeinfo_for_tree APIs.
[svn.git] / subversion / libsvn_fs_fs / fs.h
blobf6fc63403f13a9bff0c2c465b9d77aa4b1cbf0b2
1 /* fs.h : interface to Subversion filesystem, private to libsvn_fs
3 * ====================================================================
4 * Copyright (c) 2000-2007 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #ifndef SVN_LIBSVN_FS_FS_H
19 #define SVN_LIBSVN_FS_FS_H
21 #include <apr_pools.h>
22 #include <apr_hash.h>
23 #include <apr_md5.h>
24 #include <apr_thread_mutex.h>
25 #include <apr_network_io.h>
27 #include "svn_fs.h"
28 #include "private/svn_fs_private.h"
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
35 /*** The filesystem structure. ***/
37 /* Following are defines that specify the textual elements of the
38 native filesystem directories and revision files. */
40 /* Names of special files in the fs_fs filesystem. */
41 #define PATH_FORMAT "format" /* Contains format number */
42 #define PATH_UUID "uuid" /* Contains UUID */
43 #define PATH_CURRENT "current" /* Youngest revision */
44 #define PATH_LOCK_FILE "write-lock" /* Revision lock file */
45 #define PATH_REVS_DIR "revs" /* Directory of revisions */
46 #define PATH_REVPROPS_DIR "revprops" /* Directory of revprops */
47 #define PATH_TXNS_DIR "transactions" /* Directory of transactions */
48 #define PATH_TXN_PROTOS_DIR "txn-protorevs" /* Directory of proto-revs */
49 #define PATH_TXN_CURRENT "transaction-current" /* File with next txn key */
50 #define PATH_TXN_CURRENT_LOCK "txn-current-lock" /* Lock for txn-current */
51 #define PATH_LOCKS_DIR "locks" /* Directory of locks */
53 /* Names of special files and file extensions for transactions */
54 #define PATH_CHANGES "changes" /* Records changes made so far */
55 #define PATH_TXN_PROPS "props" /* Transaction properties */
56 #define PATH_NEXT_IDS "next-ids" /* Next temporary ID assignments */
57 #define PATH_TXN_MERGEINFO "mergeinfo" /* Transaction mergeinfo props */
58 #define PATH_PREFIX_NODE "node." /* Prefix for node filename */
59 #define PATH_EXT_TXN ".txn" /* Extension of txn dir */
60 #define PATH_EXT_CHILDREN ".children" /* Extension for dir contents */
61 #define PATH_EXT_PROPS ".props" /* Extension for node props */
62 #define PATH_EXT_REV ".rev" /* Extension of protorev file */
63 #define PATH_EXT_REV_LOCK ".rev-lock" /* Extension of protorev lock file */
64 /* Names of files in legacy FS formats */
65 #define PATH_REV "rev" /* Proto rev file */
66 #define PATH_REV_LOCK "rev-lock" /* Proto rev (write) lock file */
68 /* The format number of this filesystem.
69 This is independent of the repository format number, and
70 independent of any other FS back ends. */
71 #define SVN_FS_FS__FORMAT_NUMBER 3
73 /* The minimum format number that supports svndiff version 1. */
74 #define SVN_FS_FS__MIN_SVNDIFF1_FORMAT 2
76 /* The minimum format number that supports transaction ID generation
77 using a transaction sequence in the transaction-current file. */
78 #define SVN_FS_FS__MIN_TXN_CURRENT_FORMAT 3
80 /* The minimum format number that supports the "layout" filesystem
81 format option. */
82 #define SVN_FS_FS__MIN_LAYOUT_FORMAT_OPTION_FORMAT 3
84 /* The minimum format number that stores protorevs in a separate directory. */
85 #define SVN_FS_FS__MIN_PROTOREVS_DIR_FORMAT 3
87 /* Maximum number of directories to cache dirents for.
88 This *must* be a power of 2 for DIR_CACHE_ENTRIES_MASK
89 to work. */
90 #define NUM_DIR_CACHE_ENTRIES 128
91 #define DIR_CACHE_ENTRIES_MASK(x) ((x) & (NUM_DIR_CACHE_ENTRIES - 1))
93 /* Maximum number of revroot ids to cache dirents for at a time. */
94 #define NUM_RRI_CACHE_ENTRIES 4096
96 /* Private FSFS-specific data shared between all svn_txn_t objects that
97 relate to a particular transaction in a filesystem (as identified
98 by transaction id and filesystem UUID). Objects of this type are
99 allocated in their own subpool of the common pool. */
100 struct fs_fs_shared_txn_data_t;
101 typedef struct fs_fs_shared_txn_data_t
103 /* The next transaction in the list, or NULL if there is no following
104 transaction. */
105 struct fs_fs_shared_txn_data_t *next;
107 /* This transaction's ID. For repositories whose format is less
108 than SVN_FS_FS__MIN_TXN_CURRENT_FORMAT, the ID is in the form
109 <rev>-<uniqueifier>, where <uniqueifier> runs from 0-99999 (see
110 create_txn_dir_pre_1_5() in fs_fs.c). For newer repositories,
111 the form is <rev>-<200 digit base 36 number> (see
112 create_txn_dir() in fs_fs.c). */
113 char txn_id[SVN_FS__TXN_MAX_LEN+1];
115 /* Whether the transaction's prototype revision file is locked for
116 writing by any thread in this process (including the current
117 thread; recursive locks are not permitted). This is effectively
118 a non-recursive mutex. */
119 svn_boolean_t being_written;
121 /* The pool in which this object has been allocated; a subpool of the
122 common pool. */
123 apr_pool_t *pool;
124 } fs_fs_shared_txn_data_t;
127 /* Private FSFS-specific data shared between all svn_fs_t objects that
128 relate to a particular filesystem, as identified by filesystem UUID.
129 Objects of this type are allocated in the common pool. */
130 typedef struct
132 /* A list of shared transaction objects for each transaction that is
133 currently active, or NULL if none are. All access to this list,
134 including the contents of the objects stored in it, is synchronised
135 under TXN_LIST_LOCK. */
136 fs_fs_shared_txn_data_t *txns;
138 /* A free transaction object, or NULL if there is no free object.
139 Access to this object is synchronised under TXN_LIST_LOCK. */
140 fs_fs_shared_txn_data_t *free_txn;
142 #if APR_HAS_THREADS
143 /* A lock for intra-process synchronization when accessing the TXNS list. */
144 apr_thread_mutex_t *txn_list_lock;
146 /* A lock for intra-process synchronization when grabbing the
147 repository write lock. */
148 apr_thread_mutex_t *fs_write_lock;
150 /* A lock for intra-process synchronization when locking the
151 transaction-current file. */
152 apr_thread_mutex_t *txn_current_lock;
153 #endif
155 /* The common pool, under which this object is allocated, subpools
156 of which are used to allocate the transaction objects. */
157 apr_pool_t *common_pool;
158 } fs_fs_shared_data_t;
160 typedef struct dag_node_t dag_node_t;
162 /* Structure for DAG-node cache. Cache items are arranged in a
163 circular LRU list with a dummy entry, and also indexed with a hash
164 table. Transaction nodes are cached within the individual txn
165 roots; revision nodes are cached together within the FS object. */
166 typedef struct dag_node_cache_t
168 const char *key; /* Lookup key for cached node: path
169 for txns; rev catenated with path
170 for revs */
171 dag_node_t *node; /* Cached node */
172 struct dag_node_cache_t *prev; /* Next node in LRU list */
173 struct dag_node_cache_t *next; /* Previous node in LRU list */
174 apr_pool_t *pool; /* Pool in which node is allocated */
175 } dag_node_cache_t;
178 /* Private (non-shared) FSFS-specific data for each svn_fs_t object. */
179 typedef struct
181 /* A cache of the last directory opened within the filesystem. */
182 svn_fs_id_t *dir_cache_id[NUM_DIR_CACHE_ENTRIES];
183 apr_hash_t *dir_cache[NUM_DIR_CACHE_ENTRIES];
184 apr_pool_t *dir_cache_pool[NUM_DIR_CACHE_ENTRIES];
186 /* The format number of this FS. */
187 int format;
188 /* The maximum number of files to store per directory (for sharded
189 layouts) or zero (for linear layouts). */
190 int max_files_per_dir;
192 /* The uuid of this FS. */
193 const char *uuid;
195 /* Caches of immutable data.
197 Both of these could be moved to fs_fs_shared_data_t to make them
198 last longer; on the other hand, this would require adding mutexes
199 for threaded builds.
202 /* A cache of revision root IDs, allocated in this subpool. (IDs
203 are so small that one pool per ID would be overkill;
204 unfortunately, this means the only way we expire cache entries is
205 by wiping the whole cache.) */
206 apr_hash_t *rev_root_id_cache;
207 apr_pool_t *rev_root_id_cache_pool;
209 /* DAG node cache for immutable nodes */
210 dag_node_cache_t rev_node_list;
211 apr_hash_t *rev_node_cache;
213 /* Data shared between all svn_fs_t objects for a given filesystem. */
214 fs_fs_shared_data_t *shared;
215 } fs_fs_data_t;
218 /*** Filesystem Transaction ***/
219 typedef struct
221 /* property list (const char * name, svn_string_t * value).
222 may be NULL if there are no properties. */
223 apr_hash_t *proplist;
225 /* node revision id of the root node. */
226 const svn_fs_id_t *root_id;
228 /* node revision id of the node which is the root of the revision
229 upon which this txn is base. (unfinished only) */
230 const svn_fs_id_t *base_id;
232 /* copies list (const char * copy_ids), or NULL if there have been
233 no copies in this transaction. */
234 apr_array_header_t *copies;
236 } transaction_t;
239 /*** Representation ***/
240 /* If you add fields to this, check to see if you need to change
241 * svn_fs_fs__rep_copy. */
242 typedef struct
244 /* MD5 checksum for the contents produced by this representation.
245 This checksum is for the contents the rep shows to consumers,
246 regardless of how the rep stores the data under the hood. It is
247 independent of the storage (fulltext, delta, whatever).
249 If all the bytes are 0, then for compatibility behave as though
250 this checksum matches the expected checksum. */
251 unsigned char checksum[APR_MD5_DIGESTSIZE];
253 /* Revision where this representation is located. */
254 svn_revnum_t revision;
256 /* Offset into the revision file where it is located. */
257 apr_off_t offset;
259 /* The size of the representation in bytes as seen in the revision
260 file. */
261 svn_filesize_t size;
263 /* The size of the fulltext of the representation. */
264 svn_filesize_t expanded_size;
266 /* Is this representation a transaction? */
267 const char *txn_id;
269 } representation_t;
272 /*** Node-Revision ***/
273 /* If you add fields to this, check to see if you need to change
274 * copy_node_revision in dag.c. */
275 typedef struct
277 /* node kind */
278 svn_node_kind_t kind;
280 /* The node-id for this node-rev. */
281 const svn_fs_id_t *id;
283 /* predecessor node revision id, or NULL if there is no predecessor
284 for this node revision */
285 const svn_fs_id_t *predecessor_id;
287 /* If this node-rev is a copy, where was it copied from? */
288 const char *copyfrom_path;
289 svn_revnum_t copyfrom_rev;
291 /* Helper for history tracing, root of the parent tree from whence
292 this node-rev was copied. */
293 svn_revnum_t copyroot_rev;
294 const char *copyroot_path;
296 /* number of predecessors this node revision has (recursively), or
297 -1 if not known (for backward compatibility). */
298 int predecessor_count;
300 /* representation key for this node's properties. may be NULL if
301 there are no properties. */
302 representation_t *prop_rep;
304 /* representation for this node's data. may be NULL if there is
305 no data. */
306 representation_t *data_rep;
308 /* path at which this node first came into existence. */
309 const char *created_path;
311 /* is this the unmodified root of a transaction? */
312 svn_boolean_t is_fresh_txn_root;
314 /* Number of nodes with svn:mergeinfo properties that are
315 descendants of this node (including it itself) */
316 apr_int64_t mergeinfo_count;
318 /* Does this node itself have svn:mergeinfo? */
319 svn_boolean_t has_mergeinfo;
321 } node_revision_t;
324 /*** Change ***/
325 typedef struct
327 /* Path of the change. */
328 const char *path;
330 /* Node revision ID of the change. */
331 const svn_fs_id_t *noderev_id;
333 /* The kind of change. */
334 svn_fs_path_change_kind_t kind;
336 /* Text or property mods? */
337 svn_boolean_t text_mod;
338 svn_boolean_t prop_mod;
340 /* Copyfrom revision and path. */
341 svn_revnum_t copyfrom_rev;
342 const char * copyfrom_path;
344 } change_t;
347 #ifdef __cplusplus
349 #endif /* __cplusplus */
351 #endif /* SVN_LIBSVN_FS_FS_H */