You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/10/29 23:27:03 UTC
svn commit: r1635317 [2/2] - in /subversion/trunk/subversion/libsvn_fs_x: ./
cached_data.c cached_data.h fs_x.c fs_x.h index.c index.h pack.c recovery.c
rev_file.c rev_file.h verify.c
Modified: subversion/trunk/subversion/libsvn_fs_x/pack.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/pack.c?rev=1635317&r1=1635316&r2=1635317&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/pack.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/pack.c Wed Oct 29 22:27:02 2014
@@ -476,7 +476,7 @@ static svn_error_t *
copy_item_to_temp(pack_context_t *context,
apr_array_header_t *entries,
apr_file_t *temp_file,
- apr_file_t *rev_file,
+ svn_fs_x__revision_file_t *rev_file,
svn_fs_x__p2l_entry_t *entry,
apr_pool_t *pool)
{
@@ -486,7 +486,8 @@ copy_item_to_temp(pack_context_t *contex
SVN_ERR(svn_io_file_seek(temp_file, APR_CUR, &new_entry->offset, pool));
APR_ARRAY_PUSH(entries, svn_fs_x__p2l_entry_t *) = new_entry;
- SVN_ERR(copy_file_data(context, temp_file, rev_file, entry->size, pool));
+ SVN_ERR(copy_file_data(context, temp_file, rev_file->file, entry->size,
+ pool));
return SVN_NO_ERROR;
}
@@ -561,12 +562,11 @@ get_item(pack_context_t *context,
*/
static svn_error_t *
copy_rep_to_temp(pack_context_t *context,
- apr_file_t *rev_file,
+ svn_fs_x__revision_file_t *rev_file,
svn_fs_x__p2l_entry_t *entry,
apr_pool_t *pool)
{
svn_fs_x__rep_header_t *rep_header;
- svn_stream_t *stream;
apr_off_t source_offset = entry->offset;
/* create a copy of ENTRY, make it point to the copy destination and
@@ -578,9 +578,7 @@ copy_rep_to_temp(pack_context_t *context
add_item_rep_mapping(context, entry);
/* read & parse the representation header */
- stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
- SVN_ERR(svn_fs_x__read_rep_header(&rep_header, stream, pool));
- svn_stream_close(stream);
+ SVN_ERR(svn_fs_x__read_rep_header(&rep_header, rev_file->stream, pool));
/* if the representation is a delta against some other rep, link the two */
if ( rep_header->type == svn_fs_x__rep_delta
@@ -596,9 +594,9 @@ copy_rep_to_temp(pack_context_t *context
}
/* copy the whole rep (including header!) to our temp file */
- SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &source_offset, pool));
- SVN_ERR(copy_file_data(context, context->reps_file, rev_file, entry->size,
- pool));
+ SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &source_offset, pool));
+ SVN_ERR(copy_file_data(context, context->reps_file, rev_file->file,
+ entry->size, pool));
return SVN_NO_ERROR;
}
@@ -679,7 +677,7 @@ tweak_path_for_ordering(const char *orig
*/
static svn_error_t *
copy_node_to_temp(pack_context_t *context,
- apr_file_t *rev_file,
+ svn_fs_x__revision_file_t *rev_file,
svn_fs_x__p2l_entry_t *entry,
apr_pool_t *pool)
{
@@ -687,13 +685,10 @@ copy_node_to_temp(pack_context_t *contex
sizeof(*path_order));
node_revision_t *noderev;
const char *sort_path;
- svn_stream_t *stream;
apr_off_t source_offset = entry->offset;
/* read & parse noderev */
- stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
- SVN_ERR(svn_fs_x__read_noderev(&noderev, stream, pool));
- svn_stream_close(stream);
+ SVN_ERR(svn_fs_x__read_noderev(&noderev, rev_file->stream, pool));
/* create a copy of ENTRY, make it point to the copy destination and
* store it in CONTEXT */
@@ -704,9 +699,9 @@ copy_node_to_temp(pack_context_t *contex
add_item_rep_mapping(context, entry);
/* copy the noderev to our temp file */
- SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &source_offset, pool));
- SVN_ERR(copy_file_data(context, context->reps_file, rev_file, entry->size,
- pool));
+ SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &source_offset, pool));
+ SVN_ERR(copy_file_data(context, context->reps_file, rev_file->file,
+ entry->size, pool));
/* if the node has a data representation, make that the node's "base".
* This will (often) cause the noderev to be placed right in front of
@@ -1284,8 +1279,9 @@ write_reps_containers(pack_context_t *co
= svn_fs_x__reps_builder_create(context->fs, container_pool);
apr_array_header_t *sub_items
= apr_array_make(pool, 64, sizeof(svn_fs_x__id_part_t));
- svn_stream_t *temp_stream
- = svn_stream_from_aprfile2(temp_file, TRUE, pool);
+ svn_fs_x__revision_file_t *file;
+
+ SVN_ERR(svn_fs_x__wrap_temp_rev_file(&file, context->fs, temp_file, pool));
/* copy all items in strict order */
for (i = entries->nelts-1; i >= 0; --i)
@@ -1331,8 +1327,8 @@ write_reps_containers(pack_context_t *co
iterpool));
SVN_ERR(svn_fs_x__get_representation_length(&representation.size,
&representation.expanded_size,
- context->fs, temp_file,
- temp_stream, entry, iterpool));
+ context->fs, file,
+ entry, iterpool));
SVN_ERR(svn_fs_x__get_contents(&stream, context->fs, &representation,
FALSE, iterpool));
contents = svn_stringbuf_create_ensure(representation.expanded_size,
@@ -1837,7 +1833,7 @@ pack_range(pack_context_t *context,
{
apr_off_t offset = 0;
apr_finfo_t finfo;
- apr_file_t *rev_file;
+ svn_fs_x__revision_file_t *rev_file;
/* Get the size of the file. */
const char *path = svn_dirent_join(context->shard_dir,
@@ -1845,10 +1841,8 @@ pack_range(pack_context_t *context,
revision),
revpool);
SVN_ERR(svn_io_stat(&finfo, path, APR_FINFO_SIZE, revpool));
-
- SVN_ERR(svn_io_file_open(&rev_file, path,
- APR_READ | APR_BUFFERED | APR_BINARY,
- APR_OS_DEFAULT, revpool));
+ SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, context->fs,
+ revision, revpool));
/* store the indirect array index */
APR_ARRAY_PUSH(context->rev_offsets, int) = context->reps->nelts;
@@ -1862,7 +1856,7 @@ pack_range(pack_context_t *context,
apr_array_header_t *entries;
svn_pool_clear(iterpool);
- SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, context->fs,
+ SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, context->fs, rev_file,
revision, offset,
ffd->p2l_page_size, iterpool));
@@ -1880,7 +1874,7 @@ pack_range(pack_context_t *context,
offset = entry->offset;
if (offset < finfo.size)
{
- SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset,
+ SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &offset,
iterpool));
if (entry->type == SVN_FS_X__ITEM_TYPE_CHANGES)
@@ -1962,7 +1956,7 @@ append_revision(pack_context_t *context,
fs_x_data_t *ffd = context->fs->fsap_data;
apr_off_t offset = 0;
apr_pool_t *iterpool = svn_pool_create(pool);
- apr_file_t *rev_file;
+ svn_fs_x__revision_file_t *rev_file;
apr_finfo_t finfo;
/* Get the size of the file. */
@@ -1973,11 +1967,10 @@ append_revision(pack_context_t *context,
SVN_ERR(svn_io_stat(&finfo, path, APR_FINFO_SIZE, pool));
/* Copy all the bits from the rev file to the end of the pack file. */
- SVN_ERR(svn_io_file_open(&rev_file, path,
- APR_READ | APR_BUFFERED | APR_BINARY,
- APR_OS_DEFAULT, pool));
- SVN_ERR(copy_file_data(context, context->pack_file, rev_file, finfo.size,
- iterpool));
+ SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, context->fs,
+ context->start_rev, pool));
+ SVN_ERR(copy_file_data(context, context->pack_file, rev_file->file,
+ finfo.size, iterpool));
/* mark the start of a new revision */
SVN_ERR(svn_fs_x__l2p_proto_index_add_revision(context->proto_l2p_index,
@@ -1990,9 +1983,9 @@ append_revision(pack_context_t *context,
/* read one cluster */
int i;
apr_array_header_t *entries;
- SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, context->fs,
- context->start_rev, offset,
- ffd->p2l_page_size, iterpool));
+ SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, context->fs, rev_file,
+ context->start_rev, offset,
+ ffd->p2l_page_size, iterpool));
for (i = 0; i < entries->nelts; ++i)
{
Modified: subversion/trunk/subversion/libsvn_fs_x/recovery.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/recovery.c?rev=1635317&r1=1635316&r2=1635317&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/recovery.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/recovery.c Wed Oct 29 22:27:02 2014
@@ -55,7 +55,7 @@ recover_get_largest_revision(svn_fs_t *f
while (1)
{
svn_error_t *err;
- apr_file_t *file;
+ svn_fs_x__revision_file_t *file;
svn_pool_clear(iterpool);
err = svn_fs_x__open_pack_or_rev_file(&file, fs, right, iterpool);
@@ -78,7 +78,7 @@ recover_get_largest_revision(svn_fs_t *f
{
svn_revnum_t probe = left + ((right - left) / 2);
svn_error_t *err;
- apr_file_t *file;
+ svn_fs_x__revision_file_t *file;
svn_pool_clear(iterpool);
err = svn_fs_x__open_pack_or_rev_file(&file, fs, probe, iterpool);
Copied: subversion/trunk/subversion/libsvn_fs_x/rev_file.c (from r1531982, subversion/branches/log-addressing/subversion/libsvn_fs_fs/rev_file.c)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/rev_file.c?p2=subversion/trunk/subversion/libsvn_fs_x/rev_file.c&p1=subversion/branches/log-addressing/subversion/libsvn_fs_fs/rev_file.c&r1=1531982&r2=1635317&rev=1635317&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_fs/rev_file.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/rev_file.c Wed Oct 29 22:27:02 2014
@@ -21,7 +21,7 @@
*/
#include "rev_file.h"
-#include "fs_fs.h"
+#include "fs_x.h"
#include "index.h"
#include "util.h"
@@ -29,15 +29,15 @@
#include "svn_private_config.h"
-void
-svn_fs_fs__init_revision_file(svn_fs_fs__revision_file_t *file,
+static void
+svn_fs_x__init_revision_file(svn_fs_x__revision_file_t *file,
svn_fs_t *fs,
svn_revnum_t revision,
apr_pool_t *pool)
{
- fs_fs_data_t *ffd = fs->fsap_data;
+ fs_x_data_t *ffd = fs->fsap_data;
- file->is_packed = svn_fs_fs__is_packed_rev(fs, revision);
+ file->is_packed = svn_fs_x__is_packed_rev(fs, revision);
file->start_revision = revision < ffd->min_unpacked_rev
? revision - (revision % ffd->max_files_per_dir)
: revision;
@@ -49,22 +49,21 @@ svn_fs_fs__init_revision_file(svn_fs_fs_
file->pool = pool;
}
-/* Core implementation of svn_fs_fs__open_pack_or_rev_file working on an
+/* Core implementation of svn_fs_x__open_pack_or_rev_file working on an
* existing, initialized FILE structure.
*/
static svn_error_t *
-open_pack_or_rev_file(svn_fs_fs__revision_file_t *file,
+open_pack_or_rev_file(svn_fs_x__revision_file_t *file,
svn_fs_t *fs,
svn_revnum_t rev,
apr_pool_t *pool)
{
- fs_fs_data_t *ffd = fs->fsap_data;
svn_error_t *err;
svn_boolean_t retry = FALSE;
do
{
- const char *path = svn_fs_fs__path_rev_absolute(fs, rev, pool);
+ const char *path = svn_fs_x__path_rev_absolute(fs, rev, pool);
apr_file_t *apr_file;
/* open the revision file in buffered r/o mode */
@@ -80,28 +79,19 @@ open_pack_or_rev_file(svn_fs_fs__revisio
if (err && APR_STATUS_IS_ENOENT(err->apr_err))
{
- if (ffd->format >= SVN_FS_FS__MIN_PACKED_FORMAT)
- {
- /* Could not open the file. This may happen if the
- * file once existed but got packed later. */
- svn_error_clear(err);
-
- /* if that was our 2nd attempt, leave it at that. */
- if (retry)
- return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
- _("No such revision %ld"), rev);
-
- /* We failed for the first time. Refresh cache & retry. */
- SVN_ERR(svn_fs_fs__update_min_unpacked_rev(fs, pool));
-
- retry = TRUE;
- }
- else
- {
- svn_error_clear(err);
- return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
- _("No such revision %ld"), rev);
- }
+ /* Could not open the file. This may happen if the
+ * file once existed but got packed later. */
+ svn_error_clear(err);
+
+ /* if that was our 2nd attempt, leave it at that. */
+ if (retry)
+ return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
+ _("No such revision %ld"), rev);
+
+ /* We failed for the first time. Refresh cache & retry. */
+ SVN_ERR(svn_fs_x__update_min_unpacked_rev(fs, pool));
+
+ retry = TRUE;
}
else
{
@@ -114,37 +104,37 @@ open_pack_or_rev_file(svn_fs_fs__revisio
}
svn_error_t *
-svn_fs_fs__open_pack_or_rev_file(svn_fs_fs__revision_file_t **file,
+svn_fs_x__open_pack_or_rev_file(svn_fs_x__revision_file_t **file,
svn_fs_t *fs,
svn_revnum_t rev,
apr_pool_t *pool)
{
*file = apr_palloc(pool, sizeof(**file));
- svn_fs_fs__init_revision_file(*file, fs, rev, pool);
+ svn_fs_x__init_revision_file(*file, fs, rev, pool);
return svn_error_trace(open_pack_or_rev_file(*file, fs, rev, pool));
}
svn_error_t *
-svn_fs_fs__reopen_revision_file(svn_fs_fs__revision_file_t *file,
+svn_fs_x__reopen_revision_file(svn_fs_x__revision_file_t *file,
svn_fs_t *fs,
svn_revnum_t rev)
{
if (file->file)
- svn_fs_fs__close_revision_file(file);
+ svn_fs_x__close_revision_file(file);
return svn_error_trace(open_pack_or_rev_file(file, fs, rev, file->pool));
}
svn_error_t *
-svn_fs_fs__open_proto_rev_file(svn_fs_fs__revision_file_t **file,
+svn_fs_x__open_proto_rev_file(svn_fs_x__revision_file_t **file,
svn_fs_t *fs,
- const svn_fs_fs__id_part_t *txn_id,
+ svn_fs_x__txn_id_t txn_id,
apr_pool_t *pool)
{
apr_file_t *apr_file;
SVN_ERR(svn_io_file_open(&apr_file,
- svn_fs_fs__path_txn_proto_rev(fs, txn_id, pool),
+ svn_fs_x__path_txn_proto_rev(fs, txn_id, pool),
APR_READ | APR_BUFFERED, APR_OS_DEFAULT, pool));
*file = apr_pcalloc(pool, sizeof(**file));
@@ -157,15 +147,30 @@ svn_fs_fs__open_proto_rev_file(svn_fs_fs
}
svn_error_t *
-svn_fs_fs__close_revision_file(svn_fs_fs__revision_file_t *file)
+svn_fs_x__wrap_temp_rev_file(svn_fs_x__revision_file_t **file,
+ svn_fs_t *fs,
+ apr_file_t *temp_file,
+ apr_pool_t *pool)
+{
+ *file = apr_pcalloc(pool, sizeof(**file));
+ (*file)->file = temp_file;
+ (*file)->is_packed = FALSE;
+ (*file)->start_revision = SVN_INVALID_REVNUM;
+ (*file)->stream = svn_stream_from_aprfile2(temp_file, TRUE, pool);
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_x__close_revision_file(svn_fs_x__revision_file_t *file)
{
if (file->stream)
SVN_ERR(svn_stream_close(file->stream));
if (file->file)
SVN_ERR(svn_io_file_close(file->file, file->pool));
- SVN_ERR(svn_fs_fs__packed_stream_close(file->l2p_stream));
- SVN_ERR(svn_fs_fs__packed_stream_close(file->p2l_stream));
+ SVN_ERR(svn_fs_x__packed_stream_close(file->l2p_stream));
+ SVN_ERR(svn_fs_x__packed_stream_close(file->p2l_stream));
file->file = NULL;
file->stream = NULL;
Copied: subversion/trunk/subversion/libsvn_fs_x/rev_file.h (from r1531982, subversion/branches/log-addressing/subversion/libsvn_fs_fs/rev_file.h)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/rev_file.h?p2=subversion/trunk/subversion/libsvn_fs_x/rev_file.h&p1=subversion/branches/log-addressing/subversion/libsvn_fs_fs/rev_file.h&r1=1531982&r2=1635317&rev=1635317&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_fs/rev_file.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/rev_file.h Wed Oct 29 22:27:02 2014
@@ -20,8 +20,8 @@
* ====================================================================
*/
-#ifndef SVN_LIBSVN_FS__REV_FILE_H
-#define SVN_LIBSVN_FS__REV_FILE_H
+#ifndef SVN_LIBSVN_FS_X__REV_FILE_H
+#define SVN_LIBSVN_FS_X__REV_FILE_H
#include "svn_fs.h"
#include "id.h"
@@ -35,12 +35,12 @@
/* Opaque index stream type.
*/
-typedef struct svn_fs_fs__packed_number_stream_t
- svn_fs_fs__packed_number_stream_t;
+typedef struct svn_fs_x__packed_number_stream_t
+ svn_fs_x__packed_number_stream_t;
/* All files and associated properties for START_REVISION.
*/
-typedef struct svn_fs_fs__revision_file_t
+typedef struct svn_fs_x__revision_file_t
{
/* first (potentially only) revision in the rev / pack file.
* SVN_INVALID_REVNUM for txn proto-rev files. */
@@ -56,33 +56,33 @@ typedef struct svn_fs_fs__revision_file_
svn_stream_t *stream;
/* the opened P2L index or NULL. Always NULL for txns. */
- svn_fs_fs__packed_number_stream_t *p2l_stream;
+ svn_fs_x__packed_number_stream_t *p2l_stream;
/* the opened L2P index or NULL. Always NULL for txns. */
- svn_fs_fs__packed_number_stream_t *l2p_stream;
+ svn_fs_x__packed_number_stream_t *l2p_stream;
/* pool containing this object */
apr_pool_t *pool;
-} svn_fs_fs__revision_file_t;
+} svn_fs_x__revision_file_t;
/* Initialize the FILE data structure for REVISION in FS without actually
* opening any files. Use POOL for all future allocations in FILE.
*/
void
-svn_fs_fs__init_revision_file(svn_fs_fs__revision_file_t *file,
- svn_fs_t *fs,
- svn_revnum_t revision,
- apr_pool_t *pool);
+svn_fs_x__init_revision_file(svn_fs_x__revision_file_t *file,
+ svn_fs_t *fs,
+ svn_revnum_t revision,
+ apr_pool_t *pool);
/* Open the correct revision file for REV. If the filesystem FS has
* been packed, *FILE will be set to the packed file; otherwise, set *FILE
* to the revision file for REV. Return SVN_ERR_FS_NO_SUCH_REVISION if the
* file doesn't exist. Use POOL for allocations. */
svn_error_t *
-svn_fs_fs__open_pack_or_rev_file(svn_fs_fs__revision_file_t **file,
- svn_fs_t *fs,
- svn_revnum_t rev,
- apr_pool_t *pool);
+svn_fs_x__open_pack_or_rev_file(svn_fs_x__revision_file_t **file,
+ svn_fs_t *fs,
+ svn_revnum_t rev,
+ apr_pool_t *pool);
/* Close previous files as well as streams in FILE (if open) and open the
* rev / pack file for REVISION in FS. This is useful when a pack operation
@@ -90,21 +90,30 @@ svn_fs_fs__open_pack_or_rev_file(svn_fs_
* wants to keep the same revision file data structure.
*/
svn_error_t *
-svn_fs_fs__reopen_revision_file(svn_fs_fs__revision_file_t *file,
- svn_fs_t *fs,
- svn_revnum_t revision);
+svn_fs_x__reopen_revision_file(svn_fs_x__revision_file_t *file,
+ svn_fs_t *fs,
+ svn_revnum_t revision);
/* Open the proto-rev file of transaction TXN_ID in FS and return it in *FILE.
* Use POOL for allocations. */
svn_error_t *
-svn_fs_fs__open_proto_rev_file(svn_fs_fs__revision_file_t **file,
- svn_fs_t *fs,
- const svn_fs_fs__id_part_t *txn_id,
- apr_pool_t *pool);
+svn_fs_x__open_proto_rev_file(svn_fs_x__revision_file_t **file,
+ svn_fs_t *fs,
+ svn_fs_x__txn_id_t txn_id,
+ apr_pool_t *pool);
+
+/* Wrap the TEMP_FILE, used in the context of FS, into a revision file struct
+ * and return it in *FILE.
+ * Use POOL for allocations. */
+svn_error_t *
+svn_fs_x__wrap_temp_rev_file(svn_fs_x__revision_file_t **file,
+ svn_fs_t *fs,
+ apr_file_t *temp_file,
+ apr_pool_t *pool);
/* Close all files and streams in FILE.
*/
svn_error_t *
-svn_fs_fs__close_revision_file(svn_fs_fs__revision_file_t *file);
+svn_fs_x__close_revision_file(svn_fs_x__revision_file_t *file);
#endif
Modified: subversion/trunk/subversion/libsvn_fs_x/verify.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/verify.c?rev=1635317&r1=1635316&r2=1635317&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/verify.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/verify.c Wed Oct 29 22:27:02 2014
@@ -150,6 +150,9 @@ compare_l2p_to_p2l_index(svn_fs_t *fs,
apr_pool_t *iterpool = svn_pool_create(pool);
apr_array_header_t *max_ids;
+ svn_fs_x__revision_file_t *rev_file;
+ SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, fs, start, pool));
+
/* determine the range of items to check for each revision */
SVN_ERR(svn_fs_x__l2p_get_max_ids(&max_ids, fs, start, count, pool));
@@ -171,13 +174,13 @@ compare_l2p_to_p2l_index(svn_fs_t *fs,
l2p_item.number = k;
/* get L2P entry. Ignore unused entries. */
- SVN_ERR(svn_fs_x__item_offset(&offset, &sub_item, fs, &l2p_item,
- iterpool));
+ SVN_ERR(svn_fs_x__item_offset(&offset, &sub_item, fs, rev_file,
+ &l2p_item, iterpool));
if (offset == -1)
continue;
/* find the corresponding P2L entry */
- SVN_ERR(svn_fs_x__p2l_item_lookup(&p2l_item, fs, start,
+ SVN_ERR(svn_fs_x__p2l_item_lookup(&p2l_item, fs, rev_file, start,
offset, sub_item, iterpool));
if (p2l_item == NULL)
@@ -232,8 +235,13 @@ compare_p2l_to_l2p_index(svn_fs_t *fs,
apr_off_t max_offset;
apr_off_t offset = 0;
+ /* common file access structure */
+ svn_fs_x__revision_file_t *rev_file;
+ SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, fs, start, pool));
+
/* get the size of the rev / pack file as covered by the P2L index */
- SVN_ERR(svn_fs_x__p2l_get_max_offset(&max_offset, fs, start, pool));
+ SVN_ERR(svn_fs_x__p2l_get_max_offset(&max_offset, fs, rev_file, start,
+ pool));
/* for all offsets in the file, get the P2L index entries and check
them against the L2P index */
@@ -244,8 +252,9 @@ compare_p2l_to_l2p_index(svn_fs_t *fs,
int i;
/* get all entries for the current block */
- SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, fs, start, offset,
- ffd->p2l_page_size, iterpool));
+ SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, fs, rev_file, start,
+ offset, ffd->p2l_page_size,
+ iterpool));
if (entries->nelts == 0)
return svn_error_createf(SVN_ERR_FS_INDEX_CORRUPTION,
NULL,
@@ -257,7 +266,7 @@ compare_p2l_to_l2p_index(svn_fs_t *fs,
last_entry
= &APR_ARRAY_IDX(entries, entries->nelts-1, svn_fs_x__p2l_entry_t);
offset = last_entry->offset + last_entry->size;
-
+
for (i = 0; i < entries->nelts; ++i)
{
apr_uint32_t k;
@@ -274,7 +283,7 @@ compare_p2l_to_l2p_index(svn_fs_t *fs,
= svn_fs_x__get_revnum(p2l_item->change_set);
SVN_ERR(svn_fs_x__item_offset(&l2p_offset, &sub_item, fs,
- p2l_item, iterpool));
+ rev_file, p2l_item, iterpool));
if (sub_item != k || l2p_offset != entry->offset)
return svn_error_createf(SVN_ERR_FS_INDEX_INCONSISTENT,
@@ -468,14 +477,15 @@ compare_p2l_to_rev(svn_fs_t *fs,
apr_pool_t *iterpool = svn_pool_create(pool);
apr_off_t max_offset;
apr_off_t offset = 0;
- apr_file_t *rev_file;
+ svn_fs_x__revision_file_t *rev_file;
/* open the pack / rev file that is covered by the p2l index */
SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, fs, start, pool));
/* check file size vs. range covered by index */
- SVN_ERR(svn_io_file_seek(rev_file, APR_END, &offset, pool));
- SVN_ERR(svn_fs_x__p2l_get_max_offset(&max_offset, fs, start, pool));
+ SVN_ERR(svn_io_file_seek(rev_file->file, APR_END, &offset, pool));
+ SVN_ERR(svn_fs_x__p2l_get_max_offset(&max_offset, fs, rev_file, start,
+ pool));
if (offset != max_offset)
return svn_error_createf(SVN_ERR_FS_INDEX_INCONSISTENT, NULL,
@@ -484,7 +494,8 @@ compare_p2l_to_rev(svn_fs_t *fs,
apr_off_t_toa(pool, offset), start,
apr_off_t_toa(pool, max_offset));
- SVN_ERR(svn_io_file_aligned_seek(rev_file, ffd->block_size, NULL, 0, pool));
+ SVN_ERR(svn_io_file_aligned_seek(rev_file->file, ffd->block_size, NULL, 0,
+ pool));
/* for all offsets in the file, get the P2L index entries and check
them against the L2P index */
@@ -496,8 +507,9 @@ compare_p2l_to_rev(svn_fs_t *fs,
svn_pool_clear(iterpool);
/* get all entries for the current block */
- SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, fs, start, offset,
- ffd->p2l_page_size, iterpool));
+ SVN_ERR(svn_fs_x__p2l_index_lookup(&entries, fs, rev_file, start,
+ offset, ffd->p2l_page_size,
+ iterpool));
/* process all entries (and later continue with the next block) */
for (i = 0; i < entries->nelts; ++i)
@@ -529,14 +541,16 @@ compare_p2l_to_rev(svn_fs_t *fs,
{
/* skip filler entry at the end of the p2l index */
if (entry->offset != max_offset)
- SVN_ERR(read_all_nul(rev_file, entry->size, pool));
+ SVN_ERR(read_all_nul(rev_file->file, entry->size, pool));
}
else if (entry->fnv1_checksum)
{
if (entry->size < STREAM_THRESHOLD)
- SVN_ERR(expected_buffered_checksum(rev_file, entry, pool));
+ SVN_ERR(expected_buffered_checksum(rev_file->file, entry,
+ pool));
else
- SVN_ERR(expected_streamed_checksum(rev_file, entry, pool));
+ SVN_ERR(expected_streamed_checksum(rev_file->file, entry,
+ pool));
}
/* advance offset */