Author: stefan2
Date: Fri Feb 27 22:53:56 2015
New Revision: 1662845
URL: http://svn.apache.org/r1662845
Log:
On the fsx-1.10 branch:
Make FSX footer data access go through an interface instead of accessing
the revision file struct directly.
* subversion/libsvn_fs_x/rev_file.h
(svn_fs_x__index_info_t): New structure, factored out from ...
(svn_fs_x__revision_file_t): ... this.
(svn_fs_x__rev_file_l2p_info,
svn_fs_x__rev_file_p2l_info): Declare new access functions.
* subversion/libsvn_fs_x/rev_file.c
(create_revision_file,
svn_fs_x__auto_read_footer,
svn_fs_x__rev_file_l2p_index,
svn_fs_x__rev_file_p2l_index): Update struct element access.
(svn_fs_x__rev_file_l2p_info,
svn_fs_x__rev_file_p2l_info): Implement.
* subversion/libsvn_fs_x/index.c
(get_l2p_header_body,
get_p2l_header): Use the new accessor functions to get the index info.
* subversion/libsvn_fs_x/pack.c
(pack_range): Same.
* subversion/libsvn_fs_x/verify.c
(verify_index_checksum,
verify_index_checksums,
compare_p2l_to_rev): Same.
Modified:
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/pack.c
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c?rev=1662845&r1=1662844&r2=1662845&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c Fri Feb 27
22:53:56 2015
@@ -1243,12 +1243,15 @@ get_l2p_header_body(l2p_header_t **heade
apr_array_header_t *expanded_values
= apr_array_make(scratch_pool, 16, sizeof(apr_uint64_t));
svn_fs_x__packed_number_stream_t *stream;
+ svn_fs_x__index_info_t index_info;
svn_fs_x__pair_cache_key_t key;
key.revision = rev_file->start_revision;
key.second = rev_file->is_packed;
+ /* Access the L2P index stream. */
SVN_ERR(svn_fs_x__rev_file_l2p_index(&stream, rev_file));
+ SVN_ERR(svn_fs_x__rev_file_l2p_info(&index_info, rev_file));
packed_stream_seek(stream, 0);
/* Read the table sizes. Check the data for plausibility and
@@ -1277,7 +1280,7 @@ get_l2p_header_body(l2p_header_t **heade
if (page_count < result->revision_count)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Fewer L2P index pages than revisions"));
- if (page_count > (rev_file->p2l_offset - rev_file->l2p_offset) / 2)
+ if (page_count > (index_info.end - index_info.start) / 2)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("L2P index page count implausibly large"));
@@ -2444,6 +2447,7 @@ get_p2l_header(p2l_header_t **header,
p2l_header_t *result;
svn_boolean_t is_cached = FALSE;
svn_fs_x__packed_number_stream_t *stream;
+ svn_fs_x__index_info_t l2p_index_info;
/* look for the header data in our cache */
svn_fs_x__pair_cache_key_t key;
@@ -2458,6 +2462,7 @@ get_p2l_header(p2l_header_t **header,
/* not found -> must read it from disk.
* Open index file or position read pointer to the begin of the file */
SVN_ERR(svn_fs_x__rev_file_p2l_index(&stream, rev_file));
+ SVN_ERR(svn_fs_x__rev_file_l2p_info(&l2p_index_info, rev_file));
packed_stream_seek(stream, 0);
/* allocate result data structure */
@@ -2472,7 +2477,7 @@ get_p2l_header(p2l_header_t **header,
SVN_ERR(packed_stream_get(&value, stream));
result->file_size = value;
- if (result->file_size != (apr_uint64_t)rev_file->l2p_offset)
+ if (result->file_size != (apr_uint64_t)l2p_index_info.start)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Index offset and rev / pack file size do not match"));
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/pack.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/pack.c?rev=1662845&r1=1662844&r2=1662845&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/pack.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/pack.c Fri Feb 27
22:53:56 2015
@@ -1722,18 +1722,19 @@ pack_range(pack_context_t *context,
{
apr_off_t offset = 0;
svn_fs_x__revision_file_t *rev_file;
+ svn_fs_x__index_info_t l2p_index_info;
/* Get the rev file dimensions (mainly index locations). */
SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, context->fs,
revision, revpool, iterpool));
- SVN_ERR(svn_fs_x__auto_read_footer(rev_file));
+ SVN_ERR(svn_fs_x__rev_file_l2p_info(&l2p_index_info, rev_file));
/* store the indirect array index */
APR_ARRAY_PUSH(context->rev_offsets, int) = context->reps->nelts;
/* read the phys-to-log index file until we covered the whole rev file.
* That index contains enough info to build both target indexes from it.
*/
- while (offset < rev_file->l2p_offset)
+ while (offset < l2p_index_info.start)
{
/* read one cluster */
int i;
@@ -1757,7 +1758,7 @@ pack_range(pack_context_t *context,
/* process entry while inside the rev file */
offset = entry->offset;
- if (offset < rev_file->l2p_offset)
+ if (offset < l2p_index_info.start)
{
SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &offset,
iterpool));
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c?rev=1662845&r1=1662844&r2=1662845&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c Fri Feb 27
22:53:56 2015
@@ -48,11 +48,12 @@ create_revision_file(svn_fs_t *fs,
file->p2l_stream = NULL;
file->l2p_stream = NULL;
file->block_size = ffd->block_size;
- file->l2p_offset = -1;
- file->l2p_checksum = NULL;
- file->p2l_offset = -1;
- file->p2l_checksum = NULL;
- file->footer_offset = -1;
+ file->l2p_info.start = -1;
+ file->l2p_info.end = -1;
+ file->l2p_info.checksum = NULL;
+ file->p2l_info.start = -1;
+ file->p2l_info.end = -1;
+ file->p2l_info.checksum = NULL;
file->pool = result_pool;
return file;
@@ -232,7 +233,7 @@ svn_fs_x__open_pack_or_rev_file_writable
svn_error_t *
svn_fs_x__auto_read_footer(svn_fs_x__revision_file_t *file)
{
- if (file->l2p_offset == -1)
+ if (file->l2p_info.start == -1)
{
apr_off_t filesize = 0;
unsigned char footer_length;
@@ -258,11 +259,14 @@ svn_fs_x__auto_read_footer(svn_fs_x__rev
footer->data[footer->len] = '\0';
/* Extract index locations. */
- SVN_ERR(svn_fs_x__parse_footer(&file->l2p_offset, &file->l2p_checksum,
- &file->p2l_offset, &file->p2l_checksum,
+ SVN_ERR(svn_fs_x__parse_footer(&file->l2p_info.start,
+ &file->l2p_info.checksum,
+ &file->p2l_info.start,
+ &file->p2l_info.checksum,
footer, file->start_revision,
file->pool));
- file->footer_offset = filesize - footer_length - 1;
+ file->l2p_info.end = file->p2l_info.start;
+ file->p2l_info.end = filesize - footer_length - 1;
}
return SVN_NO_ERROR;
@@ -308,8 +312,8 @@ svn_fs_x__rev_file_l2p_index(svn_fs_x__p
SVN_ERR(svn_fs_x__auto_read_footer(file));
SVN_ERR(svn_fs_x__packed_stream_open(&file->l2p_stream,
file->file,
- file->l2p_offset,
- file->p2l_offset,
+ file->l2p_info.start,
+ file->l2p_info.end,
SVN_FS_X__L2P_STREAM_PREFIX,
(apr_size_t)file->block_size,
file->pool,
@@ -329,8 +333,8 @@ svn_fs_x__rev_file_p2l_index(svn_fs_x__p
SVN_ERR(svn_fs_x__auto_read_footer(file));
SVN_ERR(svn_fs_x__packed_stream_open(&file->p2l_stream,
file->file,
- file->p2l_offset,
- file->footer_offset,
+ file->p2l_info.start,
+ file->p2l_info.end,
SVN_FS_X__P2L_STREAM_PREFIX,
(apr_size_t)file->block_size,
file->pool,
@@ -341,6 +345,26 @@ svn_fs_x__rev_file_p2l_index(svn_fs_x__p
return SVN_NO_ERROR;
}
+svn_error_t *
+svn_fs_x__rev_file_l2p_info(svn_fs_x__index_info_t *info,
+ svn_fs_x__revision_file_t *file)
+{
+ SVN_ERR(svn_fs_x__auto_read_footer(file));
+ *info = file->l2p_info;
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_x__rev_file_p2l_info(svn_fs_x__index_info_t *info,
+ svn_fs_x__revision_file_t *file)
+{
+ SVN_ERR(svn_fs_x__auto_read_footer(file));
+ *info = file->p2l_info;
+
+ return SVN_NO_ERROR;
+}
+
svn_error_t *
svn_fs_x__close_revision_file(svn_fs_x__revision_file_t *file)
{
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h
URL:
http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h?rev=1662845&r1=1662844&r2=1662845&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h Fri Feb 27
22:53:56 2015
@@ -38,6 +38,20 @@
typedef struct svn_fs_x__packed_number_stream_t
svn_fs_x__packed_number_stream_t;
+/* Location and content meta data for an index. */
+typedef struct svn_fs_x__index_info_t
+{
+ /* Offset within the pack / rev file at which the index data starts. */
+ apr_off_t start;
+
+ /* First offset behind the index data. */
+ apr_off_t end;
+
+ /* MD5 checksum on the whole on-disk representation of the index. */
+ svn_checksum_t *checksum;
+
+} svn_fs_x__index_info_t;
+
/* Data file, including indexes data, and associated properties for
* START_REVISION. As the FILE is kept open, background pack operations
* will not cause access to this file to fail.
@@ -67,28 +81,13 @@ typedef struct svn_fs_x__revision_file_t
* use aligned seek() without having the FS handy. */
apr_off_t block_size;
- /* Offset within FILE at which the rev data ends and the L2P index
- * data starts. Less than P2L_OFFSET. -1 if svn_fs_fs__auto_read_footer
- * has not been called, yet. */
- apr_off_t l2p_offset;
-
- /* MD5 checksum on the whole on-disk representation of the L2P index.
- * NULL if svn_fs_fs__auto_read_footer has not been called, yet. */
- svn_checksum_t *l2p_checksum;
-
- /* Offset within FILE at which the L2P index ends and the P2L index
- * data starts. Greater than L2P_OFFSET. -1 if svn_fs_fs__auto_read_footer
- * has not been called, yet. */
- apr_off_t p2l_offset;
-
- /* MD5 checksum on the whole on-disk representation of the P2L index.
- * NULL if svn_fs_fs__auto_read_footer has not been called, yet. */
- svn_checksum_t *p2l_checksum;
-
- /* Offset within FILE at which the P2L index ends and the footer starts.
- * Greater than P2L_OFFSET. -1 if svn_fs_fs__auto_read_footer has not
- * been called, yet. */
- apr_off_t footer_offset;
+ /* Info on the L2P index within FILE.
+ * Elements are -1 / NULL until svn_fs_x__auto_read_footer gets called. */
+ svn_fs_x__index_info_t l2p_info;
+
+ /* Info on the P2L index within FILE.
+ * Elements are -1 / NULL until svn_fs_x__auto_read_footer gets called. */
+ svn_fs_x__index_info_t p2l_info;
/* pool containing this object */
apr_pool_t *pool;
@@ -162,6 +161,18 @@ svn_error_t *
svn_fs_x__rev_file_p2l_index(svn_fs_x__packed_number_stream_t **stream,
svn_fs_x__revision_file_t *file);
+/* Copy the L2P index info for FILE into *INFO.
+ */
+svn_error_t *
+svn_fs_x__rev_file_l2p_info(svn_fs_x__index_info_t *info,
+ svn_fs_x__revision_file_t *file);
+
+/* Copy the P2L index info for FILE into *INFO.
+ */
+svn_error_t *
+svn_fs_x__rev_file_p2l_info(svn_fs_x__index_info_t *info,
+ svn_fs_x__revision_file_t *file);
+
/* Close all files and streams in FILE.
*/
svn_error_t *
Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c?rev=1662845&r1=1662844&r2=1662845&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c Fri Feb 27
22:53:56 2015
@@ -143,21 +143,19 @@ verify_rep_cache(svn_fs_t *fs,
static svn_error_t *
verify_index_checksum(apr_file_t *file,
const char *name,
- apr_off_t start,
- apr_off_t end,
- svn_checksum_t *expected,
+ svn_fs_x__index_info_t *index_info,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *scratch_pool)
{
unsigned char buffer[SVN__STREAM_CHUNK_SIZE];
- apr_off_t size = end - start;
+ apr_off_t size = index_info->end - index_info->start;
svn_checksum_t *actual;
svn_checksum_ctx_t *context
= svn_checksum_ctx_create(svn_checksum_md5, scratch_pool);
/* Calculate the index checksum. */
- SVN_ERR(svn_io_file_seek(file, APR_SET, &start, scratch_pool));
+ SVN_ERR(svn_io_file_seek(file, APR_SET, &index_info->start, scratch_pool));
while (size > 0)
{
apr_size_t to_read = size > sizeof(buffer)
@@ -175,12 +173,13 @@ verify_index_checksum(apr_file_t *file,
SVN_ERR(svn_checksum_final(&actual, context, scratch_pool));
/* Verify that it matches the expected checksum. */
- if (!svn_checksum_match(expected, actual))
+ if (!svn_checksum_match(index_info->checksum, actual))
{
const char *file_name;
SVN_ERR(svn_io_file_name_get(&file_name, file, scratch_pool));
- SVN_ERR(svn_checksum_mismatch_err(expected, actual, scratch_pool,
+ SVN_ERR(svn_checksum_mismatch_err(index_info->checksum, actual,
+ scratch_pool,
_("%s checksum mismatch in file %s"),
name, file_name));
}
@@ -201,20 +200,19 @@ verify_index_checksums(svn_fs_t *fs,
apr_pool_t *scratch_pool)
{
svn_fs_x__revision_file_t *rev_file;
+ svn_fs_x__index_info_t l2p_index_info;
+ svn_fs_x__index_info_t p2l_index_info;
/* Open the rev / pack file and read the footer */
SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, fs, start,
scratch_pool, scratch_pool));
- SVN_ERR(svn_fs_x__auto_read_footer(rev_file));
+ SVN_ERR(svn_fs_x__rev_file_l2p_info(&l2p_index_info, rev_file));
+ SVN_ERR(svn_fs_x__rev_file_p2l_info(&p2l_index_info, rev_file));
/* Verify the index contents against the checksum from the footer. */
- SVN_ERR(verify_index_checksum(rev_file->file, "L2P index",
- rev_file->l2p_offset, rev_file->p2l_offset,
- rev_file->l2p_checksum,
+ SVN_ERR(verify_index_checksum(rev_file->file, "L2P index", &l2p_index_info,
cancel_func, cancel_baton, scratch_pool));
- SVN_ERR(verify_index_checksum(rev_file->file, "P2L index",
- rev_file->p2l_offset, rev_file->footer_offset,
- rev_file->p2l_checksum,
+ SVN_ERR(verify_index_checksum(rev_file->file, "P2L index", &p2l_index_info,
cancel_func, cancel_baton, scratch_pool));
/* Done. */
@@ -588,22 +586,23 @@ compare_p2l_to_rev(svn_fs_t *fs,
apr_off_t max_offset;
apr_off_t offset = 0;
svn_fs_x__revision_file_t *rev_file;
+ svn_fs_x__index_info_t l2p_index_info;
/* 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, scratch_pool,
iterpool));
/* check file size vs. range covered by index */
- SVN_ERR(svn_fs_x__auto_read_footer(rev_file));
+ SVN_ERR(svn_fs_x__rev_file_l2p_info(&l2p_index_info, rev_file));
SVN_ERR(svn_fs_x__p2l_get_max_offset(&max_offset, fs, rev_file, start,
scratch_pool));
- if (rev_file->l2p_offset != max_offset)
+ if (l2p_index_info.start != max_offset)
return svn_error_createf(SVN_ERR_FS_INDEX_INCONSISTENT, NULL,
_("File size of %s for revision r%ld does "
"not match p2l index size of %s"),
apr_off_t_toa(scratch_pool,
- rev_file->l2p_offset),
+ l2p_index_info.start),
start,
apr_off_t_toa(scratch_pool,
max_offset));