1289177Speter/* revprops.h --- everything needed to handle revprops in FSFS
2289177Speter *
3289177Speter * ====================================================================
4289177Speter *    Licensed to the Apache Software Foundation (ASF) under one
5289177Speter *    or more contributor license agreements.  See the NOTICE file
6289177Speter *    distributed with this work for additional information
7289177Speter *    regarding copyright ownership.  The ASF licenses this file
8289177Speter *    to you under the Apache License, Version 2.0 (the
9289177Speter *    "License"); you may not use this file except in compliance
10289177Speter *    with the License.  You may obtain a copy of the License at
11289177Speter *
12289177Speter *      http://www.apache.org/licenses/LICENSE-2.0
13289177Speter *
14289177Speter *    Unless required by applicable law or agreed to in writing,
15289177Speter *    software distributed under the License is distributed on an
16289177Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17289177Speter *    KIND, either express or implied.  See the License for the
18289177Speter *    specific language governing permissions and limitations
19289177Speter *    under the License.
20289177Speter * ====================================================================
21289177Speter */
22289177Speter
23289177Speter#include "svn_fs.h"
24289177Speter
25289177Speter/* In the filesystem FS, pack all revprop shards up to min_unpacked_rev.
26289177Speter *
27289177Speter * NOTE: Keep the old non-packed shards around until after the format bump.
28289177Speter * Otherwise, re-running upgrade will drop the packed revprop shard but
29289177Speter * have no unpacked data anymore.  Call upgrade_cleanup_pack_revprops after
30289177Speter * the bump.
31289177Speter *
32289177Speter * NOTIFY_FUNC and NOTIFY_BATON as well as CANCEL_FUNC and CANCEL_BATON are
33289177Speter * used in the usual way.  Temporary allocations are done in SCRATCH_POOL.
34289177Speter */
35289177Spetersvn_error_t *
36289177Spetersvn_fs_fs__upgrade_pack_revprops(svn_fs_t *fs,
37289177Speter                                 svn_fs_upgrade_notify_t notify_func,
38289177Speter                                 void *notify_baton,
39289177Speter                                 svn_cancel_func_t cancel_func,
40289177Speter                                 void *cancel_baton,
41289177Speter                                 apr_pool_t *scratch_pool);
42289177Speter
43289177Speter/* In the filesystem FS, remove all non-packed revprop shards up to
44289177Speter * min_unpacked_rev.  Temporary allocations are done in SCRATCH_POOL.
45289177Speter *
46289177Speter * NOTIFY_FUNC and NOTIFY_BATON as well as CANCEL_FUNC and CANCEL_BATON are
47289177Speter * used in the usual way.  Cancellation is supported in the sense that we
48289177Speter * will cleanly abort the operation.  However, there will be remnant shards
49289177Speter * that must be removed manually.
50289177Speter *
51289177Speter * See upgrade_pack_revprops for more info.
52289177Speter */
53289177Spetersvn_error_t *
54289177Spetersvn_fs_fs__upgrade_cleanup_pack_revprops(svn_fs_t *fs,
55289177Speter                                         svn_fs_upgrade_notify_t notify_func,
56289177Speter                                         void *notify_baton,
57289177Speter                                         svn_cancel_func_t cancel_func,
58289177Speter                                         void *cancel_baton,
59289177Speter                                         apr_pool_t *scratch_pool);
60289177Speter
61362181Sdim/* Invalidate the revprop cache in FS. */
62362181Sdimvoid
63362181Sdimsvn_fs_fs__reset_revprop_cache(svn_fs_t *fs);
64362181Sdim
65362181Sdim/* Set *PROPS_SIZE_P to the size in bytes on disk of the revprops for
66362181Sdim * revision REV in FS. The size excludes indexes.
67362181Sdim */
68362181Sdimsvn_error_t *
69362181Sdimsvn_fs_fs__get_revision_props_size(apr_off_t *props_size_p,
70362181Sdim                                   svn_fs_t *fs,
71362181Sdim                                   svn_revnum_t rev,
72362181Sdim                                   apr_pool_t *scratch_pool);
73362181Sdim
74289177Speter/* Read the revprops for revision REV in FS and return them in *PROPERTIES_P.
75362181Sdim * If REFRESH is set, clear the revprop cache before accessing the data.
76289177Speter *
77362181Sdim * The result will be allocated in RESULT_POOL; SCRATCH_POOL is used for
78362181Sdim * temporaries.
79289177Speter */
80289177Spetersvn_error_t *
81289177Spetersvn_fs_fs__get_revision_proplist(apr_hash_t **proplist_p,
82289177Speter                                 svn_fs_t *fs,
83289177Speter                                 svn_revnum_t rev,
84362181Sdim                                 svn_boolean_t refresh,
85362181Sdim                                 apr_pool_t *result_pool,
86362181Sdim                                 apr_pool_t *scratch_pool);
87289177Speter
88289177Speter/* Set the revision property list of revision REV in filesystem FS to
89289177Speter   PROPLIST.  Use POOL for temporary allocations. */
90289177Spetersvn_error_t *
91289177Spetersvn_fs_fs__set_revision_proplist(svn_fs_t *fs,
92289177Speter                                 svn_revnum_t rev,
93289177Speter                                 apr_hash_t *proplist,
94289177Speter                                 apr_pool_t *pool);
95289177Speter
96289177Speter
97289177Speter/* Return TRUE, if for REVISION in FS, we can find the revprop pack file.
98289177Speter * Use POOL for temporary allocations.
99289177Speter * Set *MISSING, if the reason is a missing manifest or pack file.
100289177Speter */
101289177Spetersvn_boolean_t
102289177Spetersvn_fs_fs__packed_revprop_available(svn_boolean_t *missing,
103289177Speter                                    svn_fs_t *fs,
104289177Speter                                    svn_revnum_t revision,
105289177Speter                                    apr_pool_t *pool);
106289177Speter
107289177Speter
108289177Speter/****** Packing FSFS shards *********/
109289177Speter
110289177Speter/* Copy revprop files for revisions [START_REV, END_REV) from SHARD_PATH
111289177Speter * to the pack file at PACK_FILE_NAME in PACK_FILE_DIR.
112289177Speter *
113289177Speter * The file sizes have already been determined and written to SIZES.
114289177Speter * Please note that this function will be executed while the filesystem
115289177Speter * has been locked and that revprops files will therefore not be modified
116289177Speter * while the pack is in progress.
117289177Speter *
118289177Speter * COMPRESSION_LEVEL defines how well the resulting pack file shall be
119289177Speter * compressed or whether is shall be compressed at all.  TOTAL_SIZE is
120289177Speter * a hint on which initial buffer size we should use to hold the pack file
121289177Speter * content.
122289177Speter *
123362181Sdim * If FLUSH_TO_DISK is non-zero, do not return until the data has actually
124362181Sdim * been written on the disk.  CANCEL_FUNC and CANCEL_BATON are used as usual.
125362181Sdim * Temporary allocations are done in SCRATCH_POOL.
126289177Speter */
127289177Spetersvn_error_t *
128289177Spetersvn_fs_fs__copy_revprops(const char *pack_file_dir,
129289177Speter                         const char *pack_filename,
130289177Speter                         const char *shard_path,
131289177Speter                         svn_revnum_t start_rev,
132289177Speter                         svn_revnum_t end_rev,
133289177Speter                         apr_array_header_t *sizes,
134289177Speter                         apr_size_t total_size,
135289177Speter                         int compression_level,
136362181Sdim                         svn_boolean_t flush_to_disk,
137289177Speter                         svn_cancel_func_t cancel_func,
138289177Speter                         void *cancel_baton,
139289177Speter                         apr_pool_t *scratch_pool);
140289177Speter
141289177Speter/* In the filesystem FS, pack all revprop shards up to min_unpacked_rev.
142289177Speter *
143289177Speter * NOTE: Keep the old non-packed shards around until after the format bump.
144289177Speter * Otherwise, re-running upgrade will drop the packed revprop shard but
145289177Speter * have no unpacked data anymore.  Call upgrade_cleanup_pack_revprops after
146289177Speter * the bump.
147289177Speter *
148362181Sdim * If FLUSH_TO_DISK is non-zero, do not return until the data has actually
149362181Sdim * been written on the disk.  CANCEL_FUNC and CANCEL_BATON areused in the
150362181Sdim * usual way.  Temporary allocations are done in SCRATCH_POOL.
151289177Speter */
152289177Spetersvn_error_t *
153289177Spetersvn_fs_fs__pack_revprops_shard(const char *pack_file_dir,
154289177Speter                               const char *shard_path,
155289177Speter                               apr_int64_t shard,
156289177Speter                               int max_files_per_dir,
157362181Sdim                               apr_int64_t max_pack_size,
158289177Speter                               int compression_level,
159362181Sdim                               svn_boolean_t flush_to_disk,
160289177Speter                               svn_cancel_func_t cancel_func,
161289177Speter                               void *cancel_baton,
162289177Speter                               apr_pool_t *scratch_pool);
163289177Speter
164289177Speter/* In the filesystem FS, remove all non-packed revprop shards up to
165289177Speter * min_unpacked_rev.  Temporary allocations are done in SCRATCH_POOL.
166289177Speter *
167289177Speter * NOTIFY_FUNC and NOTIFY_BATON as well as CANCEL_FUNC and CANCEL_BATON are
168289177Speter * used in the usual way.  Cancellation is supported in the sense that we
169289177Speter * will cleanly abort the operation.  However, there will be remnant shards
170289177Speter * that must be removed manually.
171289177Speter *
172289177Speter * See upgrade_pack_revprops for more info.
173289177Speter */
174289177Spetersvn_error_t *
175289177Spetersvn_fs_fs__delete_revprops_shard(const char *shard_path,
176289177Speter                                 apr_int64_t shard,
177289177Speter                                 int max_files_per_dir,
178289177Speter                                 svn_cancel_func_t cancel_func,
179289177Speter                                 void *cancel_baton,
180289177Speter                                 apr_pool_t *scratch_pool);
181