Author: stefan2
Date: Fri May 23 22:09:23 2014
New Revision: 1597202

URL: http://svn.apache.org/r1597202
Log:
Sync'ing FSX with FSFS:
Make FSX indexes precisely track the rev / pack file size such
added data is always detected even if the block sizes change.
This does not merge specific revisions.

* index.c
  (p2l_header_t): Add member for rev / pack file size.
  (svn_fs_x__p2l_index_create): Store the original file size
                                in our index file.
  (get_p2l_header): Load that info again.
  (p2l_get_max_offset_func,
   svn_fs_x__p2l_get_max_offset): Use the precise file size
                    instead of a multiple of the block size.

Modified:
    subversion/trunk/subversion/libsvn_fs_x/index.c

Modified: subversion/trunk/subversion/libsvn_fs_x/index.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/index.c?rev=1597202&r1=1597201&r2=1597202&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/index.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/index.c Fri May 23 22:09:23 2014
@@ -130,6 +130,9 @@ typedef struct p2l_header_t
   /* number of pages / clusters in that rev file */
   apr_size_t page_count;
 
+  /* number of bytes in the rev file */
+  apr_uint64_t file_size;
+
   /* offsets of the pages / cluster descriptions within the index file */
   apr_off_t *offsets;
 } p2l_header_t;
@@ -1816,6 +1819,7 @@ svn_fs_x__p2l_index_create(svn_fs_t *fs,
   apr_uint64_t last_page_end = 0;
   apr_size_t last_buffer_size = 0;  /* byte offset in the spill buffer at
                                        the begin of the current revision */
+  apr_uint64_t file_size = 0;
 
   /* temporary data structures that collect the data which will be moved
      to the target file in a second step */
@@ -1877,6 +1881,8 @@ svn_fs_x__p2l_index_create(svn_fs_t *fs,
          at the end the of the last page. */
       if (eof)
         {
+          file_size = last_entry_end;
+
           entry.offset = last_entry_end;
           entry.size = APR_ALIGN(entry.offset, page_size) - entry.offset;
           entry.type = 0;
@@ -1959,6 +1965,9 @@ svn_fs_x__p2l_index_create(svn_fs_t *fs,
                                  encode_uint(encoded, revision),
                                  NULL, local_pool));
   SVN_ERR(svn_io_file_write_full(index_file, encoded,
+                                 encode_uint(encoded, file_size),
+                                 NULL, local_pool));
+  SVN_ERR(svn_io_file_write_full(index_file, encoded,
                                  encode_uint(encoded, page_size),
                                  NULL, local_pool));
 
@@ -2126,6 +2135,8 @@ get_p2l_header(p2l_header_t **header,
   SVN_ERR(packed_stream_get(&value, *stream));
   result->first_revision = (svn_revnum_t)value;
   SVN_ERR(packed_stream_get(&value, *stream));
+  result->file_size = value;
+  SVN_ERR(packed_stream_get(&value, *stream));
   result->page_size = value;
   SVN_ERR(packed_stream_get(&value, *stream));
   result->page_count = (apr_size_t)value;
@@ -2935,7 +2946,7 @@ p2l_get_max_offset_func(void **out,
                         apr_pool_t *result_pool)
 {
   const p2l_header_t *header = data;
-  apr_off_t max_offset = header->page_size * header->page_count;
+  apr_off_t max_offset = header->file_size;
   *out = apr_pmemdup(result_pool, &max_offset, sizeof(max_offset));
 
   return SVN_NO_ERROR;
@@ -2968,8 +2979,8 @@ svn_fs_x__p2l_get_max_offset(apr_off_t *
     }
 
   SVN_ERR(get_p2l_header(&header, &stream, fs, revision, pool, pool));
-  *offset = header->page_count * header->page_size;
-  
+  *offset = header->file_size;
+
   /* make sure we close files after usage */
   SVN_ERR(packed_stream_close(stream));
 


Reply via email to