fs_fs.h revision 362181
1/* fs_fs.h : interface to the native filesystem layer 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_FS_H 24#define SVN_LIBSVN_FS__FS_FS_H 25 26#include "fs.h" 27 28/* Read the 'format' file of fsfs filesystem FS and store its info in FS. 29 * Use SCRATCH_POOL for temporary allocations. */ 30svn_error_t * 31svn_fs_fs__read_format_file(svn_fs_t *fs, apr_pool_t *scratch_pool); 32 33/* Open the fsfs filesystem pointed to by PATH and associate it with 34 filesystem object FS. Use POOL for temporary allocations. 35 36 ### Some parts of *FS must have been initialized beforehand; some parts 37 (including FS->path) are initialized by this function. */ 38svn_error_t *svn_fs_fs__open(svn_fs_t *fs, 39 const char *path, 40 apr_pool_t *pool); 41 42/* Initialize parts of the FS data that are being shared across multiple 43 filesystem objects. Use COMMON_POOL for process-wide and POOL for 44 temporary allocations. Use COMMON_POOL_LOCK to ensure that the 45 initialization is serialized. */ 46svn_error_t *svn_fs_fs__initialize_shared_data(svn_fs_t *fs, 47 svn_mutex__t *common_pool_lock, 48 apr_pool_t *pool, 49 apr_pool_t *common_pool); 50 51/* Upgrade the fsfs filesystem FS. Indicate progress via the optional 52 * NOTIFY_FUNC callback using NOTIFY_BATON. The optional CANCEL_FUNC 53 * will periodically be called with CANCEL_BATON to allow for preemption. 54 * Use POOL for temporary allocations. */ 55svn_error_t *svn_fs_fs__upgrade(svn_fs_t *fs, 56 svn_fs_upgrade_notify_t notify_func, 57 void *notify_baton, 58 svn_cancel_func_t cancel_func, 59 void *cancel_baton, 60 apr_pool_t *pool); 61 62/* Set *YOUNGEST to the youngest revision in filesystem FS. Do any 63 temporary allocation in POOL. */ 64svn_error_t *svn_fs_fs__youngest_rev(svn_revnum_t *youngest, 65 svn_fs_t *fs, 66 apr_pool_t *pool); 67 68/* Return the shard size of filesystem FS. Return 0 for non-shared ones. */ 69int 70svn_fs_fs__shard_size(svn_fs_t *fs); 71 72/* Set *MIN_UNPACKED to the oldest non-packed revision in filesystem FS. 73 Do any temporary allocation in POOL. */ 74svn_error_t * 75svn_fs_fs__min_unpacked_rev(svn_revnum_t *min_unpacked, 76 svn_fs_t *fs, 77 apr_pool_t *pool); 78 79/* Return SVN_ERR_FS_NO_SUCH_REVISION if the given revision REV is newer 80 than the current youngest revision in FS or is simply not a valid 81 revision number, else return success. */ 82svn_error_t * 83svn_fs_fs__ensure_revision_exists(svn_revnum_t rev, 84 svn_fs_t *fs, 85 apr_pool_t *pool); 86 87/* Set *LENGTH to the be fulltext length of the node revision 88 specified by NODEREV. Use POOL for temporary allocations. */ 89svn_error_t *svn_fs_fs__file_length(svn_filesize_t *length, 90 node_revision_t *noderev, 91 apr_pool_t *pool); 92 93/* Return TRUE if the representation keys in A and B both point to the 94 same representation, else return FALSE. */ 95svn_boolean_t svn_fs_fs__noderev_same_rep_key(representation_t *a, 96 representation_t *b); 97 98/* Set *EQUAL to TRUE if the text representations in A and B within FS 99 have equal contents, else set it to FALSE. 100 Use SCRATCH_POOL for temporary allocations. */ 101svn_error_t * 102svn_fs_fs__file_text_rep_equal(svn_boolean_t *equal, 103 svn_fs_t *fs, 104 node_revision_t *a, 105 node_revision_t *b, 106 apr_pool_t *scratch_pool); 107 108/* Set *EQUAL to TRUE if the property representations in A and B within FS 109 have equal contents, else set it to FALSE. 110 Use SCRATCH_POOL for temporary allocations. */ 111svn_error_t * 112svn_fs_fs__prop_rep_equal(svn_boolean_t *equal, 113 svn_fs_t *fs, 114 node_revision_t *a, 115 node_revision_t *b, 116 apr_pool_t *scratch_pool); 117 118 119/* Return a copy of the representation REP allocated from POOL. */ 120representation_t *svn_fs_fs__rep_copy(representation_t *rep, 121 apr_pool_t *pool); 122 123 124/* Return the recorded checksum of type KIND for the text representation 125 of NODREV into CHECKSUM, allocating from POOL. If no stored checksum is 126 available, put all NULL into CHECKSUM. */ 127svn_error_t *svn_fs_fs__file_checksum(svn_checksum_t **checksum, 128 node_revision_t *noderev, 129 svn_checksum_kind_t kind, 130 apr_pool_t *pool); 131 132/* Return whether or not the given FS supports mergeinfo metadata. */ 133svn_boolean_t svn_fs_fs__fs_supports_mergeinfo(svn_fs_t *fs); 134 135/* Under the repository db PATH, create a FSFS repository with FORMAT, 136 * the given SHARD_SIZE. If USE_LOG_ADDRESSING is non-zero, repository 137 * will use logical addressing. If not supported by the respective format, 138 * the latter two parameters will be ignored. FS will be updated. 139 * 140 * The only file not being written is the 'format' file. This allows 141 * callers such as hotcopy to modify the contents before turning the 142 * tree into an accessible repository. 143 * 144 * Use POOL for temporary allocations. 145 */ 146svn_error_t * 147svn_fs_fs__create_file_tree(svn_fs_t *fs, 148 const char *path, 149 int format, 150 int shard_size, 151 svn_boolean_t use_log_addressing, 152 apr_pool_t *pool); 153 154/* Create a fs_fs fileysystem referenced by FS at path PATH. Get any 155 temporary allocations from POOL. 156 157 ### Some parts of *FS must have been initialized beforehand; some parts 158 (including FS->path) are initialized by this function. */ 159svn_error_t *svn_fs_fs__create(svn_fs_t *fs, 160 const char *path, 161 apr_pool_t *pool); 162 163/* Set the uuid of repository FS to UUID and the instance ID to INSTANCE_ID. 164 If any of them is NULL, use a newly generated UUID / ID instead. Ignore 165 INSTANCE_ID whenever instance IDs are not supported by the FS format. 166 Perform temporary allocations in POOL. */ 167svn_error_t *svn_fs_fs__set_uuid(svn_fs_t *fs, 168 const char *uuid, 169 const char *instance_id, 170 apr_pool_t *pool); 171 172/* Return the path to the 'current' file in FS. 173 Perform allocation in POOL. */ 174const char * 175svn_fs_fs__path_current(svn_fs_t *fs, apr_pool_t *pool); 176 177/* Write the format number and maximum number of files per directory 178 for FS, possibly expecting to overwrite a previously existing file. 179 180 Use POOL for temporary allocation. */ 181svn_error_t * 182svn_fs_fs__write_format(svn_fs_t *fs, 183 svn_boolean_t overwrite, 184 apr_pool_t *pool); 185 186/* Obtain a write lock on the filesystem FS in a subpool of POOL, call 187 BODY with BATON and that subpool, destroy the subpool (releasing the write 188 lock) and return what BODY returned. */ 189svn_error_t * 190svn_fs_fs__with_write_lock(svn_fs_t *fs, 191 svn_error_t *(*body)(void *baton, 192 apr_pool_t *pool), 193 void *baton, 194 apr_pool_t *pool); 195 196/* Obtain a pack operation lock on the filesystem FS in a subpool of POOL, 197 call BODY with BATON and that subpool, destroy the subpool (releasing the 198 write lock) and return what BODY returned. */ 199svn_error_t * 200svn_fs_fs__with_pack_lock(svn_fs_t *fs, 201 svn_error_t *(*body)(void *baton, 202 apr_pool_t *pool), 203 void *baton, 204 apr_pool_t *pool); 205 206/* Run BODY (with BATON and POOL) while the txn-current file 207 of FS is locked. */ 208svn_error_t * 209svn_fs_fs__with_txn_current_lock(svn_fs_t *fs, 210 svn_error_t *(*body)(void *baton, 211 apr_pool_t *pool), 212 void *baton, 213 apr_pool_t *pool); 214 215/* Obtain all locks on the filesystem FS in a subpool of POOL, call BODY 216 with BATON and that subpool, destroy the subpool (releasing the locks) 217 and return what BODY returned. 218 219 This combines svn_fs_fs__with_write_lock, svn_fs_fs__with_pack_lock, 220 and svn_fs_fs__with_txn_current_lock, ensuring correct lock ordering. */ 221svn_error_t * 222svn_fs_fs__with_all_locks(svn_fs_t *fs, 223 svn_error_t *(*body)(void *baton, 224 apr_pool_t *pool), 225 void *baton, 226 apr_pool_t *pool); 227 228/* Find the value of the property named PROPNAME in revision REV. 229 Return the contents in *VALUE_P. The contents will be allocated 230 from RESULT_POOL and SCRATCH_POOL is used for temporaries. 231 Invalidate any revprop cache is REFRESH is set. */ 232svn_error_t *svn_fs_fs__revision_prop(svn_string_t **value_p, svn_fs_t *fs, 233 svn_revnum_t rev, 234 const char *propname, 235 svn_boolean_t refresh, 236 apr_pool_t *result_pool, 237 apr_pool_t *scratch_pool); 238 239/* Change, add, or delete a property on a revision REV in filesystem 240 FS. NAME gives the name of the property, and value, if non-NULL, 241 gives the new contents of the property. If value is NULL, then the 242 property will be deleted. If OLD_VALUE_P is not NULL, do nothing unless the 243 preexisting value is *OLD_VALUE_P. Do any temporary allocation in POOL. */ 244svn_error_t *svn_fs_fs__change_rev_prop(svn_fs_t *fs, svn_revnum_t rev, 245 const char *name, 246 const svn_string_t *const *old_value_p, 247 const svn_string_t *value, 248 apr_pool_t *pool); 249 250/* If directory PATH does not exist, create it and give it the same 251 permissions as FS_PATH.*/ 252svn_error_t *svn_fs_fs__ensure_dir_exists(const char *path, 253 const char *fs_path, 254 apr_pool_t *pool); 255 256/* Update the node origin index for FS, recording the mapping from 257 NODE_ID to NODE_REV_ID. Use POOL for any temporary allocations. 258 259 Because this is just an "optional" cache, this function does not 260 return an error if the underlying storage is readonly; it still 261 returns an error for other error conditions. 262 */ 263svn_error_t * 264svn_fs_fs__set_node_origin(svn_fs_t *fs, 265 const svn_fs_fs__id_part_t *node_id, 266 const svn_fs_id_t *node_rev_id, 267 apr_pool_t *pool); 268 269/* Set *ORIGIN_ID to the node revision ID from which the history of 270 all nodes in FS whose "Node ID" is NODE_ID springs, as determined 271 by a look in the index. ORIGIN_ID needs to be parsed in an 272 FS-backend-specific way. Use POOL for allocations. 273 274 If there is no entry for NODE_ID in the cache, return NULL 275 in *ORIGIN_ID. */ 276svn_error_t * 277svn_fs_fs__get_node_origin(const svn_fs_id_t **origin_id, 278 svn_fs_t *fs, 279 const svn_fs_fs__id_part_t *node_id, 280 apr_pool_t *pool); 281 282 283/* Initialize all session-local caches in FS according to the global 284 cache settings. Use POOL for temporary allocations. 285 286 Please note that it is permissible for this function to set some 287 or all of these caches to NULL, regardless of any setting. */ 288svn_error_t * 289svn_fs_fs__initialize_caches(svn_fs_t *fs, apr_pool_t *pool); 290 291/* Initialize all transaction-local caches in FS according to the global 292 cache settings and make TXN_ID part of their key space. Use POOL for 293 allocations. 294 295 Please note that it is permissible for this function to set some or all 296 of these caches to NULL, regardless of any setting. */ 297svn_error_t * 298svn_fs_fs__initialize_txn_caches(svn_fs_t *fs, 299 const char *txn_id, 300 apr_pool_t *pool); 301 302/* Resets the svn_cache__t structures local to the current transaction in FS. 303 Calling it more than once per txn or from outside any txn is allowed. */ 304void 305svn_fs_fs__reset_txn_caches(svn_fs_t *fs); 306 307/* Scan all contents of the repository FS and return statistics in *STATS, 308 * allocated in RESULT_POOL. Report progress through PROGRESS_FUNC with 309 * PROGRESS_BATON, if PROGRESS_FUNC is not NULL. 310 * Use SCRATCH_POOL for temporary allocations. 311 */ 312svn_error_t * 313svn_fs_fs__get_stats(svn_fs_fs__stats_t **stats, 314 svn_fs_t *fs, 315 svn_fs_progress_notify_func_t progress_func, 316 void *progress_baton, 317 svn_cancel_func_t cancel_func, 318 void *cancel_baton, 319 apr_pool_t *result_pool, 320 apr_pool_t *scratch_pool); 321 322/* Read the P2L index for the rev / pack file containing REVISION in FS. 323 * For each index entry, invoke CALLBACK_FUNC with CALLBACK_BATON. 324 * If not NULL, call CANCEL_FUNC with CANCEL_BATON from time to time. 325 * Use SCRATCH_POOL for temporary allocations. 326 */ 327svn_error_t * 328svn_fs_fs__dump_index(svn_fs_t *fs, 329 svn_revnum_t revision, 330 svn_fs_fs__dump_index_func_t callback_func, 331 void *callback_baton, 332 svn_cancel_func_t cancel_func, 333 void *cancel_baton, 334 apr_pool_t *scratch_pool); 335 336 337/* Rewrite the respective index information of the rev / pack file in FS 338 * containing REVISION and use the svn_fs_fs__p2l_entry_t * array ENTRIES 339 * as the new index contents. Allocate temporaries from SCRATCH_POOL. 340 * 341 * Note that this becomes a no-op if ENTRIES is empty. You may use a zero- 342 * sized empty entry instead. 343 */ 344svn_error_t * 345svn_fs_fs__load_index(svn_fs_t *fs, 346 svn_revnum_t revision, 347 apr_array_header_t *entries, 348 apr_pool_t *scratch_pool); 349 350/* Set *REV_SIZE to the total size of objects belonging to revision REVISION 351 * in FS. The size includes revision properties and excludes indexes. 352 */ 353svn_error_t * 354svn_fs_fs__revision_size(apr_off_t *rev_size, 355 svn_fs_t *fs, 356 svn_revnum_t revision, 357 apr_pool_t *scratch_pool); 358 359/* Add missing entries to the rep-cache on the filesystem FS. Process data 360 * in revisions START_REV through END_REV inclusive. If START_REV is 361 * SVN_INVALID_REVNUM, start at revision 1; if END_REV is SVN_INVALID_REVNUM, 362 * end at the head revision. If the rep-cache does not exist, then create it. 363 * 364 * Indicate progress via the optional PROGRESS_FUNC callback using 365 * PROGRESS_BATON. The optional CANCEL_FUNC will periodically be called with 366 * CANCEL_BATON to allow cancellation. Use POOL for temporary allocations. 367 */ 368svn_error_t * 369svn_fs_fs__build_rep_cache(svn_fs_t *fs, 370 svn_revnum_t start_rev, 371 svn_revnum_t end_rev, 372 svn_fs_progress_notify_func_t progress_func, 373 void *progress_baton, 374 svn_cancel_func_t cancel_func, 375 void *cancel_baton, 376 apr_pool_t *pool); 377 378#endif 379