1 /* revprops.h --- everything needed to handle revprops in FSX
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_X_REVPROPS_H
24 #define SVN_LIBSVN_FS_X_REVPROPS_H
25 
26 #include "svn_fs.h"
27 
28 #include "batch_fsync.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
34 /* Auto-create / replace the revprop generation file in FS with its
35  * initial contents.  In any case, FS will not hold an open handle to
36  * it after this function succeeds.
37  *
38  * Use SCRATCH_POOL for temporary allocations.
39  */
40 svn_error_t *
41 svn_fs_x__reset_revprop_generation_file(svn_fs_t *fs,
42                                         apr_pool_t *scratch_pool);
43 
44 /* Invalidate the cached revprop generation value in FS->FSAP_DATA.
45  * This enforces a re-read upon the next revprop read. */
46 void
47 svn_fs_x__invalidate_revprop_generation(svn_fs_t *fs);
48 
49 /* Utility function serializing PROPLIST into FILE and adding the checksum.
50  * Use SCRATCH_POOL for temporary allocations.
51  *
52  * Call this only when creating initial revprop file contents.
53  * For modifications use svn_fs_x__set_revision_proplist.
54  */
55 svn_error_t *
56 svn_fs_x__write_non_packed_revprops(apr_file_t *file,
57                                     apr_hash_t *proplist,
58                                     apr_pool_t *scratch_pool);
59 
60 /* Read the revprops for revision REV in FS and return them in *PROPLIST_P.
61  * If BYPASS_CACHE is set, don't consult the disks but always read from disk.
62  * If REFRESH is set, update the revprop generation info; otherwise access
63  * potentially outdated cache data directly.
64  *
65  * Allocate the *PROPLIST_P in RESULT_POOL and use SCRATCH_POOL for temporary
66  * allocations.
67  */
68 svn_error_t *
69 svn_fs_x__get_revision_proplist(apr_hash_t **proplist_p,
70                                 svn_fs_t *fs,
71                                 svn_revnum_t rev,
72                                 svn_boolean_t bypass_cache,
73                                 svn_boolean_t refresh,
74                                 apr_pool_t *result_pool,
75                                 apr_pool_t *scratch_pool);
76 
77 /* Set the revision property list of revision REV in filesystem FS to
78    PROPLIST.  Use SCRATCH_POOL for temporary allocations. */
79 svn_error_t *
80 svn_fs_x__set_revision_proplist(svn_fs_t *fs,
81                                 svn_revnum_t rev,
82                                 apr_hash_t *proplist,
83                                 apr_pool_t *scratch_pool);
84 
85 
86 /* Return TRUE, if for REVISION in FS, we can find the revprop pack file.
87  * Use SCRATCH_POOL for temporary allocations.
88  * Set *MISSING, if the reason is a missing manifest or pack file.
89  */
90 svn_boolean_t
91 svn_fs_x__packed_revprop_available(svn_boolean_t *missing,
92                                    svn_fs_t *fs,
93                                    svn_revnum_t revision,
94                                    apr_pool_t *scratch_pool);
95 
96 
97 /****** Packing FSX shards *********/
98 
99 /* For the revprop SHARD at SHARD_PATH with exactly MAX_FILES_PER_DIR
100  * revprop files in it, create a packed shared at PACK_FILE_DIR in
101  * filesystem FS.  Schedule necessary fsync calls in BATCH.
102  *
103  * COMPRESSION_LEVEL defines how well the resulting pack file shall be
104  * compressed or whether is shall be compressed at all.  Individual pack
105  * file containing more than one revision will be limited to a size of
106  * MAX_PACK_SIZE bytes before compression.
107  *
108  * CANCEL_FUNC and CANCEL_BATON are used in the usual way.  Temporary
109  * allocations are done in SCRATCH_POOL.
110  */
111 svn_error_t *
112 svn_fs_x__pack_revprops_shard(svn_fs_t *fs,
113                               const char *pack_file_dir,
114                               const char *shard_path,
115                               apr_int64_t shard,
116                               int max_files_per_dir,
117                               apr_int64_t max_pack_size,
118                               int compression_level,
119                               svn_fs_x__batch_fsync_t *batch,
120                               svn_cancel_func_t cancel_func,
121                               void *cancel_baton,
122                               apr_pool_t *scratch_pool);
123 
124 #ifdef __cplusplus
125 }
126 #endif /* __cplusplus */
127 
128 #endif /* SVN_LIBSVN_FS_X_REVPROPS_H */
129