Author: stefan2
Date: Fri Feb 27 14:18:26 2015
New Revision: 1662684
URL: http://svn.apache.org/r1662684
Log:
On the fsx-1.10 branch:
Repare hiding the svn_fs_x__revision_file_t structure definition by
reducing the number of references to its packed stream elements.
* subversion/libsvn_fs_x/index.c
(auto_open_l2p_index): Explicitly return the stream.
(get_l2p_header_body,
get_l2p_page): Update callers. Only use the stream object provided by
auto_open_l2p_index instead of accessing it directly in
the revision file struct.
(auto_open_p2l_index): Explicitly return the stream.
(get_p2l_header,
get_p2l_page): Update callers. Only use the stream object provided by
auto_open_p2l_index instead of accessing it directly in
the revision file struct.
Modified:
subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.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=1662684&r1=1662683&r2=1662684&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
14:18:26 2015
@@ -1232,10 +1232,12 @@ expand_rle(apr_array_header_t *values,
}
/* If REV_FILE->L2P_STREAM is NULL, create a new stream for the log-to-phys
- * index for REVISION in FS and return it in REV_FILE.
+ * index for REVISION in FS using the rev / pack file provided by REV_FILE.
+ * Return the open stream in *STREAM.
*/
static svn_error_t *
-auto_open_l2p_index(svn_fs_x__revision_file_t *rev_file,
+auto_open_l2p_index(svn_fs_x__packed_number_stream_t **stream,
+ svn_fs_x__revision_file_t *rev_file,
svn_fs_t *fs,
svn_revnum_t revision)
{
@@ -1254,6 +1256,7 @@ auto_open_l2p_index(svn_fs_x__revision_f
rev_file->pool));
}
+ *stream = rev_file->l2p_stream;
return SVN_NO_ERROR;
}
@@ -1279,36 +1282,37 @@ get_l2p_header_body(l2p_header_t **heade
svn_revnum_t next_rev;
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__pair_cache_key_t key;
key.revision = rev_file->start_revision;
key.second = rev_file->is_packed;
- SVN_ERR(auto_open_l2p_index(rev_file, fs, revision));
- packed_stream_seek(rev_file->l2p_stream, 0);
+ SVN_ERR(auto_open_l2p_index(&stream, rev_file, fs, revision));
+ packed_stream_seek(stream, 0);
/* Read the table sizes. Check the data for plausibility and
* consistency with other bits. */
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->first_revision = (svn_revnum_t)value;
if (result->first_revision != rev_file->start_revision)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Index rev / pack file revision numbers do not match"));
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->revision_count = (int)value;
if ( result->revision_count != 1
&& result->revision_count != (apr_uint64_t)ffd->max_files_per_dir)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Invalid number of revisions in L2P index"));
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->page_size = (apr_uint32_t)value;
if (!result->page_size || (result->page_size & (result->page_size - 1)))
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("L2P index page size is not a power of two"));
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
page_count = (apr_size_t)value;
if (page_count < result->revision_count)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
@@ -1333,8 +1337,7 @@ get_l2p_header_body(l2p_header_t **heade
/* read per-revision page table sizes (i.e. number of pages per rev) */
page_table_index = 0;
result->page_table_index[0] = page_table_index;
- SVN_ERR(expand_rle(expanded_values, rev_file->l2p_stream,
- result->revision_count));
+ SVN_ERR(expand_rle(expanded_values, stream, result->revision_count));
for (i = 0; i < result->revision_count; ++i)
{
value = (apr_size_t)APR_ARRAY_IDX(expanded_values, i, apr_uint64_t);
@@ -1357,13 +1360,13 @@ get_l2p_header_body(l2p_header_t **heade
/* read actual page tables */
for (page = 0; page < page_count; ++page)
{
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
if (value == 0)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Empty L2P index page"));
result->page_table[page].size = (apr_uint32_t)value;
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
if (value > result->page_size)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Page exceeds L2P index page size"));
@@ -1372,7 +1375,7 @@ get_l2p_header_body(l2p_header_t **heade
}
/* correct the page description offsets */
- offset = packed_stream_offset(rev_file->l2p_stream);
+ offset = packed_stream_offset(stream);
for (page = 0; page < page_count; ++page)
{
result->page_table[page].offset = offset;
@@ -1472,10 +1475,11 @@ get_l2p_page(l2p_page_t **page,
l2p_page_t *result = apr_pcalloc(result_pool, sizeof(*result));
apr_uint64_t container_count;
apr_off_t *container_offsets;
+ svn_fs_x__packed_number_stream_t *stream;
/* open index file and select page */
- SVN_ERR(auto_open_l2p_index(rev_file, fs, start_revision));
- packed_stream_seek(rev_file->l2p_stream, table_entry->offset);
+ SVN_ERR(auto_open_l2p_index(&stream, rev_file, fs, start_revision));
+ packed_stream_seek(stream, table_entry->offset);
/* initialize the page content */
result->entry_count = table_entry->entry_count;
@@ -1486,12 +1490,12 @@ get_l2p_page(l2p_page_t **page,
/* container offsets array */
- SVN_ERR(packed_stream_get(&container_count, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&container_count, stream));
container_offsets = apr_pcalloc(result_pool,
container_count * sizeof(*result));
for (i = 0; i < container_count; ++i)
{
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
last_value += value;
container_offsets[i] = (apr_off_t)last_value - 1;
/* '-1' is represented as '0' in the index file */
@@ -1500,7 +1504,7 @@ get_l2p_page(l2p_page_t **page,
/* read all page entries (offsets in rev file and container sub-items) */
for (i = 0; i < result->entry_count; ++i)
{
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
if (value == 0)
{
result->offsets[i] = -1;
@@ -1509,7 +1513,7 @@ get_l2p_page(l2p_page_t **page,
else if (value <= container_count)
{
result->offsets[i] = container_offsets[value - 1];
- SVN_ERR(packed_stream_get(&value, rev_file->l2p_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->sub_items[i] = (apr_uint32_t)value;
}
else
@@ -1521,7 +1525,7 @@ get_l2p_page(l2p_page_t **page,
/* After reading all page entries, the read cursor must have moved by
* TABLE_ENTRY->SIZE bytes. */
- if ( packed_stream_offset(rev_file->l2p_stream)
+ if ( packed_stream_offset(stream)
!= table_entry->offset + table_entry->size)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("L2P actual page size does not match page table value."));
@@ -2384,9 +2388,11 @@ svn_fs_x__p2l_index_append(svn_checksum_
/* If REV_FILE->P2L_STREAM is NULL, create a new stream for the phys-to-log
* index for REVISION in FS using the rev / pack file provided by REV_FILE.
+ * Return the open stream in *STREAM.
*/
static svn_error_t *
-auto_open_p2l_index(svn_fs_x__revision_file_t *rev_file,
+auto_open_p2l_index(svn_fs_x__packed_number_stream_t **stream,
+ svn_fs_x__revision_file_t *rev_file,
svn_fs_t *fs,
svn_revnum_t revision)
{
@@ -2405,6 +2411,7 @@ auto_open_p2l_index(svn_fs_x__revision_f
rev_file->pool));
}
+ *stream = rev_file->p2l_stream;
return SVN_NO_ERROR;
}
@@ -2515,6 +2522,7 @@ get_p2l_header(p2l_header_t **header,
apr_off_t offset;
p2l_header_t *result;
svn_boolean_t is_cached = FALSE;
+ svn_fs_x__packed_number_stream_t *stream;
/* look for the header data in our cache */
svn_fs_x__pair_cache_key_t key;
@@ -2528,32 +2536,32 @@ 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(auto_open_p2l_index(rev_file, fs, key.revision));
- packed_stream_seek(rev_file->p2l_stream, 0);
+ SVN_ERR(auto_open_p2l_index(&stream, rev_file, fs, key.revision));
+ packed_stream_seek(stream, 0);
/* allocate result data structure */
result = apr_pcalloc(result_pool, sizeof(*result));
/* Read table sizes, check them for plausibility and allocate page array. */
- SVN_ERR(packed_stream_get(&value, rev_file->p2l_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->first_revision = (svn_revnum_t)value;
if (result->first_revision != rev_file->start_revision)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Index rev / pack file revision numbers do not match"));
- SVN_ERR(packed_stream_get(&value, rev_file->p2l_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->file_size = value;
if (result->file_size != (apr_uint64_t)rev_file->l2p_offset)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("Index offset and rev / pack file size do not match"));
- SVN_ERR(packed_stream_get(&value, rev_file->p2l_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->page_size = value;
if (!result->page_size || (result->page_size & (result->page_size - 1)))
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
_("P2L index page size is not a power of two"));
- SVN_ERR(packed_stream_get(&value, rev_file->p2l_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->page_count = (apr_size_t)value;
if (result->page_count != (result->file_size - 1) / result->page_size + 1)
return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
@@ -2566,12 +2574,12 @@ get_p2l_header(p2l_header_t **header,
result->offsets[0] = 0;
for (i = 0; i < result->page_count; ++i)
{
- SVN_ERR(packed_stream_get(&value, rev_file->p2l_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
result->offsets[i+1] = result->offsets[i] + (apr_off_t)value;
}
/* correct the offset values */
- offset = packed_stream_offset(rev_file->p2l_stream);
+ offset = packed_stream_offset(stream);
for (i = 0; i <= result->page_count; ++i)
result->offsets[i] += offset;
@@ -2732,14 +2740,15 @@ get_p2l_page(apr_array_header_t **entrie
= apr_array_make(result_pool, 16, sizeof(svn_fs_x__p2l_entry_t));
apr_off_t item_offset;
apr_off_t offset;
+ svn_fs_x__packed_number_stream_t *stream;
/* open index and navigate to page start */
- SVN_ERR(auto_open_p2l_index(rev_file, fs, start_revision));
- packed_stream_seek(rev_file->p2l_stream, start_offset);
+ SVN_ERR(auto_open_p2l_index(&stream, rev_file, fs, start_revision));
+ packed_stream_seek(stream, start_offset);
/* read rev file offset of the first page entry (all page entries will
* only store their sizes). */
- SVN_ERR(packed_stream_get(&value, rev_file->p2l_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
item_offset = (apr_off_t)value;
/* Special case: empty pages. */
@@ -2747,17 +2756,15 @@ get_p2l_page(apr_array_header_t **entrie
{
/* Empty page. This only happens if the first entry of the next page
* also covers this page (and possibly more) completely. */
- SVN_ERR(read_entry(rev_file->p2l_stream, &item_offset, start_revision,
- result));
+ SVN_ERR(read_entry(stream, &item_offset, start_revision, result));
}
else
{
/* Read non-empty page. */
do
{
- SVN_ERR(read_entry(rev_file->p2l_stream, &item_offset,
- start_revision, result));
- offset = packed_stream_offset(rev_file->p2l_stream);
+ SVN_ERR(read_entry(stream, &item_offset, start_revision, result));
+ offset = packed_stream_offset(stream);
}
while (offset < next_offset);
@@ -2771,9 +2778,9 @@ get_p2l_page(apr_array_header_t **entrie
* entry of the next page */
if (item_offset < page_start + page_size)
{
- SVN_ERR(packed_stream_get(&value, rev_file->p2l_stream));
+ SVN_ERR(packed_stream_get(&value, stream));
item_offset = (apr_off_t)value;
- SVN_ERR(read_entry(rev_file->p2l_stream, &item_offset,
+ SVN_ERR(read_entry(stream, &item_offset,
start_revision, result));
}
}