revprops.h revision 362181
1290001Sglebius/* revprops.h --- everything needed to handle revprops in FSFS 2290001Sglebius * 3290001Sglebius * ==================================================================== 4290001Sglebius * Licensed to the Apache Software Foundation (ASF) under one 5290001Sglebius * or more contributor license agreements. See the NOTICE file 6290001Sglebius * distributed with this work for additional information 7290001Sglebius * regarding copyright ownership. The ASF licenses this file 8290001Sglebius * to you under the Apache License, Version 2.0 (the 9290001Sglebius * "License"); you may not use this file except in compliance 10290001Sglebius * with the License. You may obtain a copy of the License at 11290001Sglebius * 12290001Sglebius * http://www.apache.org/licenses/LICENSE-2.0 13290001Sglebius * 14290001Sglebius * Unless required by applicable law or agreed to in writing, 15290001Sglebius * software distributed under the License is distributed on an 16290001Sglebius * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17290001Sglebius * KIND, either express or implied. See the License for the 18290001Sglebius * specific language governing permissions and limitations 19290001Sglebius * under the License. 20290001Sglebius * ==================================================================== 21290001Sglebius */ 22290001Sglebius 23290001Sglebius#include "svn_fs.h" 24290001Sglebius 25290001Sglebius/* In the filesystem FS, pack all revprop shards up to min_unpacked_rev. 26290001Sglebius * 27290001Sglebius * NOTE: Keep the old non-packed shards around until after the format bump. 28290001Sglebius * Otherwise, re-running upgrade will drop the packed revprop shard but 29290001Sglebius * have no unpacked data anymore. Call upgrade_cleanup_pack_revprops after 30290001Sglebius * the bump. 31290001Sglebius * 32290001Sglebius * NOTIFY_FUNC and NOTIFY_BATON as well as CANCEL_FUNC and CANCEL_BATON are 33290001Sglebius * used in the usual way. Temporary allocations are done in SCRATCH_POOL. 34290001Sglebius */ 35290001Sglebiussvn_error_t * 36290001Sglebiussvn_fs_fs__upgrade_pack_revprops(svn_fs_t *fs, 37290001Sglebius svn_fs_upgrade_notify_t notify_func, 38290001Sglebius void *notify_baton, 39290001Sglebius svn_cancel_func_t cancel_func, 40290001Sglebius void *cancel_baton, 41290001Sglebius apr_pool_t *scratch_pool); 42290001Sglebius 43290001Sglebius/* In the filesystem FS, remove all non-packed revprop shards up to 44290001Sglebius * min_unpacked_rev. Temporary allocations are done in SCRATCH_POOL. 45290001Sglebius * 46290001Sglebius * NOTIFY_FUNC and NOTIFY_BATON as well as CANCEL_FUNC and CANCEL_BATON are 47290001Sglebius * used in the usual way. Cancellation is supported in the sense that we 48290001Sglebius * will cleanly abort the operation. However, there will be remnant shards 49290001Sglebius * that must be removed manually. 50290001Sglebius * 51290001Sglebius * See upgrade_pack_revprops for more info. 52290001Sglebius */ 53290001Sglebiussvn_error_t * 54290001Sglebiussvn_fs_fs__upgrade_cleanup_pack_revprops(svn_fs_t *fs, 55290001Sglebius svn_fs_upgrade_notify_t notify_func, 56290001Sglebius void *notify_baton, 57290001Sglebius svn_cancel_func_t cancel_func, 58290001Sglebius void *cancel_baton, 59290001Sglebius apr_pool_t *scratch_pool); 60290001Sglebius 61290001Sglebius/* Invalidate the revprop cache in FS. */ 62290001Sglebiusvoid 63290001Sglebiussvn_fs_fs__reset_revprop_cache(svn_fs_t *fs); 64290001Sglebius 65290001Sglebius/* Set *PROPS_SIZE_P to the size in bytes on disk of the revprops for 66290001Sglebius * revision REV in FS. The size excludes indexes. 67290001Sglebius */ 68290001Sglebiussvn_error_t * 69290001Sglebiussvn_fs_fs__get_revision_props_size(apr_off_t *props_size_p, 70290001Sglebius svn_fs_t *fs, 71290001Sglebius svn_revnum_t rev, 72290001Sglebius apr_pool_t *scratch_pool); 73290001Sglebius 74290001Sglebius/* Read the revprops for revision REV in FS and return them in *PROPERTIES_P. 75290001Sglebius * If REFRESH is set, clear the revprop cache before accessing the data. 76290001Sglebius * 77290001Sglebius * The result will be allocated in RESULT_POOL; SCRATCH_POOL is used for 78290001Sglebius * temporaries. 79290001Sglebius */ 80290001Sglebiussvn_error_t * 81290001Sglebiussvn_fs_fs__get_revision_proplist(apr_hash_t **proplist_p, 82290001Sglebius svn_fs_t *fs, 83290001Sglebius svn_revnum_t rev, 84290001Sglebius svn_boolean_t refresh, 85290001Sglebius apr_pool_t *result_pool, 86290001Sglebius apr_pool_t *scratch_pool); 87290001Sglebius 88290001Sglebius/* Set the revision property list of revision REV in filesystem FS to 89290001Sglebius PROPLIST. Use POOL for temporary allocations. */ 90290001Sglebiussvn_error_t * 91290001Sglebiussvn_fs_fs__set_revision_proplist(svn_fs_t *fs, 92290001Sglebius svn_revnum_t rev, 93290001Sglebius apr_hash_t *proplist, 94290001Sglebius apr_pool_t *pool); 95290001Sglebius 96290001Sglebius 97290001Sglebius/* Return TRUE, if for REVISION in FS, we can find the revprop pack file. 98290001Sglebius * Use POOL for temporary allocations. 99290001Sglebius * Set *MISSING, if the reason is a missing manifest or pack file. 100290001Sglebius */ 101290001Sglebiussvn_boolean_t 102290001Sglebiussvn_fs_fs__packed_revprop_available(svn_boolean_t *missing, 103290001Sglebius svn_fs_t *fs, 104290001Sglebius svn_revnum_t revision, 105290001Sglebius apr_pool_t *pool); 106290001Sglebius 107290001Sglebius 108290001Sglebius/****** Packing FSFS shards *********/ 109290001Sglebius 110290001Sglebius/* Copy revprop files for revisions [START_REV, END_REV) from SHARD_PATH 111290001Sglebius * to the pack file at PACK_FILE_NAME in PACK_FILE_DIR. 112290001Sglebius * 113290001Sglebius * The file sizes have already been determined and written to SIZES. 114290001Sglebius * Please note that this function will be executed while the filesystem 115290001Sglebius * has been locked and that revprops files will therefore not be modified 116290001Sglebius * while the pack is in progress. 117290001Sglebius * 118290001Sglebius * COMPRESSION_LEVEL defines how well the resulting pack file shall be 119290001Sglebius * compressed or whether is shall be compressed at all. TOTAL_SIZE is 120290001Sglebius * a hint on which initial buffer size we should use to hold the pack file 121290001Sglebius * content. 122290001Sglebius * 123290001Sglebius * If FLUSH_TO_DISK is non-zero, do not return until the data has actually 124290001Sglebius * been written on the disk. CANCEL_FUNC and CANCEL_BATON are used as usual. 125290001Sglebius * Temporary allocations are done in SCRATCH_POOL. 126290001Sglebius */ 127290001Sglebiussvn_error_t * 128290001Sglebiussvn_fs_fs__copy_revprops(const char *pack_file_dir, 129290001Sglebius const char *pack_filename, 130290001Sglebius const char *shard_path, 131290001Sglebius svn_revnum_t start_rev, 132290001Sglebius svn_revnum_t end_rev, 133290001Sglebius apr_array_header_t *sizes, 134290001Sglebius apr_size_t total_size, 135290001Sglebius int compression_level, 136290001Sglebius svn_boolean_t flush_to_disk, 137290001Sglebius svn_cancel_func_t cancel_func, 138290001Sglebius void *cancel_baton, 139290001Sglebius apr_pool_t *scratch_pool); 140290001Sglebius 141290001Sglebius/* In the filesystem FS, pack all revprop shards up to min_unpacked_rev. 142290001Sglebius * 143290001Sglebius * NOTE: Keep the old non-packed shards around until after the format bump. 144290001Sglebius * Otherwise, re-running upgrade will drop the packed revprop shard but 145290001Sglebius * have no unpacked data anymore. Call upgrade_cleanup_pack_revprops after 146290001Sglebius * the bump. 147290001Sglebius * 148290001Sglebius * If FLUSH_TO_DISK is non-zero, do not return until the data has actually 149290001Sglebius * been written on the disk. CANCEL_FUNC and CANCEL_BATON areused in the 150290001Sglebius * usual way. Temporary allocations are done in SCRATCH_POOL. 151290001Sglebius */ 152290001Sglebiussvn_error_t * 153290001Sglebiussvn_fs_fs__pack_revprops_shard(const char *pack_file_dir, 154290001Sglebius const char *shard_path, 155290001Sglebius apr_int64_t shard, 156290001Sglebius int max_files_per_dir, 157290001Sglebius apr_int64_t max_pack_size, 158290001Sglebius int compression_level, 159290001Sglebius svn_boolean_t flush_to_disk, 160290001Sglebius svn_cancel_func_t cancel_func, 161290001Sglebius void *cancel_baton, 162290001Sglebius apr_pool_t *scratch_pool); 163290001Sglebius 164290001Sglebius/* In the filesystem FS, remove all non-packed revprop shards up to 165290001Sglebius * min_unpacked_rev. Temporary allocations are done in SCRATCH_POOL. 166290001Sglebius * 167290001Sglebius * NOTIFY_FUNC and NOTIFY_BATON as well as CANCEL_FUNC and CANCEL_BATON are 168290001Sglebius * used in the usual way. Cancellation is supported in the sense that we 169290001Sglebius * will cleanly abort the operation. However, there will be remnant shards 170290001Sglebius * that must be removed manually. 171290001Sglebius * 172290001Sglebius * See upgrade_pack_revprops for more info. 173290001Sglebius */ 174290001Sglebiussvn_error_t * 175290001Sglebiussvn_fs_fs__delete_revprops_shard(const char *shard_path, 176290001Sglebius apr_int64_t shard, 177290001Sglebius int max_files_per_dir, 178290001Sglebius svn_cancel_func_t cancel_func, 179290001Sglebius void *cancel_baton, 180290001Sglebius apr_pool_t *scratch_pool); 181290001Sglebius