1289177Speter/* revprops.h --- everything needed to handle revprops in FSX
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
23362181Sdim#ifndef SVN_LIBSVN_FS_X_REVPROPS_H
24362181Sdim#define SVN_LIBSVN_FS_X_REVPROPS_H
25289177Speter
26289177Speter#include "svn_fs.h"
27289177Speter
28362181Sdim#include "batch_fsync.h"
29362181Sdim
30289177Speter#ifdef __cplusplus
31289177Speterextern "C" {
32289177Speter#endif /* __cplusplus */
33289177Speter
34289177Speter/* Auto-create / replace the revprop generation file in FS with its
35289177Speter * initial contents.  In any case, FS will not hold an open handle to
36289177Speter * it after this function succeeds.
37289177Speter *
38289177Speter * Use SCRATCH_POOL for temporary allocations.
39289177Speter */
40289177Spetersvn_error_t *
41289177Spetersvn_fs_x__reset_revprop_generation_file(svn_fs_t *fs,
42289177Speter                                        apr_pool_t *scratch_pool);
43289177Speter
44362181Sdim/* Invalidate the cached revprop generation value in FS->FSAP_DATA.
45362181Sdim * This enforces a re-read upon the next revprop read. */
46362181Sdimvoid
47362181Sdimsvn_fs_x__invalidate_revprop_generation(svn_fs_t *fs);
48289177Speter
49362181Sdim/* Utility function serializing PROPLIST into FILE and adding the checksum.
50362181Sdim * Use SCRATCH_POOL for temporary allocations.
51289177Speter *
52362181Sdim * Call this only when creating initial revprop file contents.
53362181Sdim * For modifications use svn_fs_x__set_revision_proplist.
54289177Speter */
55289177Spetersvn_error_t *
56362181Sdimsvn_fs_x__write_non_packed_revprops(apr_file_t *file,
57362181Sdim                                    apr_hash_t *proplist,
58362181Sdim                                    apr_pool_t *scratch_pool);
59289177Speter
60289177Speter/* Read the revprops for revision REV in FS and return them in *PROPLIST_P.
61289177Speter * If BYPASS_CACHE is set, don't consult the disks but always read from disk.
62362181Sdim * If REFRESH is set, update the revprop generation info; otherwise access
63362181Sdim * potentially outdated cache data directly.
64289177Speter *
65289177Speter * Allocate the *PROPLIST_P in RESULT_POOL and use SCRATCH_POOL for temporary
66289177Speter * allocations.
67289177Speter */
68289177Spetersvn_error_t *
69289177Spetersvn_fs_x__get_revision_proplist(apr_hash_t **proplist_p,
70289177Speter                                svn_fs_t *fs,
71289177Speter                                svn_revnum_t rev,
72289177Speter                                svn_boolean_t bypass_cache,
73362181Sdim                                svn_boolean_t refresh,
74289177Speter                                apr_pool_t *result_pool,
75289177Speter                                apr_pool_t *scratch_pool);
76289177Speter
77289177Speter/* Set the revision property list of revision REV in filesystem FS to
78289177Speter   PROPLIST.  Use SCRATCH_POOL for temporary allocations. */
79289177Spetersvn_error_t *
80289177Spetersvn_fs_x__set_revision_proplist(svn_fs_t *fs,
81289177Speter                                svn_revnum_t rev,
82289177Speter                                apr_hash_t *proplist,
83289177Speter                                apr_pool_t *scratch_pool);
84289177Speter
85289177Speter
86289177Speter/* Return TRUE, if for REVISION in FS, we can find the revprop pack file.
87289177Speter * Use SCRATCH_POOL for temporary allocations.
88289177Speter * Set *MISSING, if the reason is a missing manifest or pack file.
89289177Speter */
90289177Spetersvn_boolean_t
91289177Spetersvn_fs_x__packed_revprop_available(svn_boolean_t *missing,
92289177Speter                                   svn_fs_t *fs,
93289177Speter                                   svn_revnum_t revision,
94289177Speter                                   apr_pool_t *scratch_pool);
95289177Speter
96289177Speter
97289177Speter/****** Packing FSX shards *********/
98289177Speter
99289177Speter/* For the revprop SHARD at SHARD_PATH with exactly MAX_FILES_PER_DIR
100362181Sdim * revprop files in it, create a packed shared at PACK_FILE_DIR in
101362181Sdim * filesystem FS.  Schedule necessary fsync calls in BATCH.
102289177Speter *
103289177Speter * COMPRESSION_LEVEL defines how well the resulting pack file shall be
104289177Speter * compressed or whether is shall be compressed at all.  Individual pack
105289177Speter * file containing more than one revision will be limited to a size of
106289177Speter * MAX_PACK_SIZE bytes before compression.
107289177Speter *
108289177Speter * CANCEL_FUNC and CANCEL_BATON are used in the usual way.  Temporary
109289177Speter * allocations are done in SCRATCH_POOL.
110289177Speter */
111289177Spetersvn_error_t *
112362181Sdimsvn_fs_x__pack_revprops_shard(svn_fs_t *fs,
113362181Sdim                              const char *pack_file_dir,
114289177Speter                              const char *shard_path,
115289177Speter                              apr_int64_t shard,
116289177Speter                              int max_files_per_dir,
117362181Sdim                              apr_int64_t max_pack_size,
118289177Speter                              int compression_level,
119362181Sdim                              svn_fs_x__batch_fsync_t *batch,
120289177Speter                              svn_cancel_func_t cancel_func,
121289177Speter                              void *cancel_baton,
122289177Speter                              apr_pool_t *scratch_pool);
123289177Speter
124289177Speter#ifdef __cplusplus
125289177Speter}
126289177Speter#endif /* __cplusplus */
127289177Speter
128362181Sdim#endif /* SVN_LIBSVN_FS_X_REVPROPS_H */
129