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 2015/04/17 17:56:12 UTC

svn commit: r1674341 - in /subversion/trunk/subversion/libsvn_fs_fs: cached_data.c cached_data.h rep-cache.c

Author: stefan2
Date: Fri Apr 17 15:56:12 2015
New Revision: 1674341

URL: http://svn.apache.org/r1674341
Log:
Extend the EXPANDED_SIZE fixup in FSFS to data read from the rep_cache.db.

To make that easier, teach the fixup code to open the rev / pack file on
demand (virtually never happens) because we don't have a open one available
in the rep-cache reader.

* subversion/libsvn_fs_fs/cached_data.c
  (fixup_expanded_size): Open revisison file on demand and rename to ...
  (svn_fs_fs__fixup_expanded_size): ... this non-static func.
  (fixup_node_revision): Update caller. Lose rev file argument as well.
  (get_node_revision_body,
   block_read_noderev): Update caller.

* subversion/libsvn_fs_fs/cached_data.h
  (svn_fs_fs__fixup_expanded_size): Declare as private API.

* subversion/libsvn_fs_fs/rep-cache.c
  (svn_fs_fs__get_rep_reference): Call the fixup for any representation
                                  read from the rep-cache.db.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.h
    subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1674341&r1=1674340&r2=1674341&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Fri Apr 17 15:56:12 2015
@@ -286,21 +286,13 @@ use_block_read(svn_fs_t *fs)
   return svn_fs_fs__use_log_addressing(fs) && ffd->use_block_read;
 }
 
-/* Resolve a FSFS quirk: if REP in REVISION_FILE within FS is a "PLAIN"
- * representation, its EXPANDED_SIZE element may be 0, in which case its
- * value has to be taken from SIZE.
- *
- * This function ensures that EXPANDED_SIZE in REP always contains the
- * actual value. No-op if REP is NULL.  Uses SCRATCH_POOL for temporaries.
- */
-static svn_error_t *
-fixup_expanded_size(svn_fs_t *fs,
-                    representation_t *rep,
-                    svn_fs_fs__revision_file_t *revision_file,
-                    apr_pool_t *scratch_pool)
+svn_error_t *
+svn_fs_fs__fixup_expanded_size(svn_fs_t *fs,
+                               representation_t *rep,
+                               apr_pool_t *scratch_pool)
 {
   svn_checksum_t *empty_md5;
-  apr_off_t offset;
+  svn_fs_fs__revision_file_t *revision_file;
   svn_fs_fs__rep_header_t *rep_header;
 
   /* Anything to do at all?
@@ -345,11 +337,11 @@ fixup_expanded_size(svn_fs_t *fs,
   /* We still have the two options, PLAIN or DELTA rep.  At this point, we
    * are in an extremely unlikely case and can spend some time to figure it
    * out.  So, let's just look at the representation header. */
-  SVN_ERR(svn_fs_fs__item_offset(&offset, fs, revision_file, rep->revision,
-                                 NULL, rep->item_index, scratch_pool));
-  SVN_ERR(aligned_seek(fs, revision_file->file, NULL, offset, scratch_pool));
+  SVN_ERR(open_and_seek_revision(&revision_file, fs, rep->revision,
+                                 rep->item_index, scratch_pool));
   SVN_ERR(svn_fs_fs__read_rep_header(&rep_header, revision_file->stream,
                                      scratch_pool, scratch_pool));
+  SVN_ERR(svn_fs_fs__close_revision_file(revision_file));
 
   /* Only for PLAIN reps do we have to correct EXPANDED_SIZE. */
   if (rep_header->type == svn_fs_fs__rep_plain)
@@ -358,23 +350,22 @@ fixup_expanded_size(svn_fs_t *fs,
   return SVN_NO_ERROR;
 }
 
-/* Correct known issues with committed NODEREV read from REVISION_FILE
- * within FS. Uses SCRATCH_POOL for temporaries.
+/* Correct known issues with committed NODEREV in FS.
+ * Uses SCRATCH_POOL for temporaries.
  */
 static svn_error_t *
 fixup_node_revision(svn_fs_t *fs,
                     node_revision_t *noderev,
-                    svn_fs_fs__revision_file_t *revision_file,
                     apr_pool_t *scratch_pool)
 {
   /* Workaround issue #4031: is-fresh-txn-root in revision files. */
   noderev->is_fresh_txn_root = FALSE;
 
   /* Make sure EXPANDED_SIZE has the correct value for every rep. */
-  SVN_ERR(fixup_expanded_size(fs, noderev->data_rep, revision_file,
-                              scratch_pool));
-  SVN_ERR(fixup_expanded_size(fs, noderev->prop_rep, revision_file,
-                              scratch_pool));
+  SVN_ERR(svn_fs_fs__fixup_expanded_size(fs, noderev->data_rep,
+                                         scratch_pool));
+  SVN_ERR(svn_fs_fs__fixup_expanded_size(fs, noderev->prop_rep,
+                                         scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -469,8 +460,7 @@ get_node_revision_body(node_revision_t *
                                           revision_file->stream,
                                           result_pool,
                                           scratch_pool));
-          SVN_ERR(fixup_node_revision(fs, *noderev_p, revision_file,
-                                      scratch_pool));
+          SVN_ERR(fixup_node_revision(fs, *noderev_p, scratch_pool));
 
           /* The noderev is not in cache, yet. Add it, if caching has been enabled. */
           if (ffd->node_revision_cache)
@@ -3292,7 +3282,7 @@ block_read_noderev(node_revision_t **nod
   /* read node rev from revision file */
   SVN_ERR(svn_fs_fs__read_noderev(noderev_p, stream,
                                   result_pool, scratch_pool));
-  SVN_ERR(fixup_node_revision(fs, *noderev_p, rev_file, scratch_pool));
+  SVN_ERR(fixup_node_revision(fs, *noderev_p, scratch_pool));
 
   if (ffd->node_revision_cache)
     SVN_ERR(svn_cache__set(ffd->node_revision_cache, &key, *noderev_p,

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.h?rev=1674341&r1=1674340&r2=1674341&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.h Fri Apr 17 15:56:12 2015
@@ -30,6 +30,18 @@
 
 
 
+/* Resolve a FSFS quirk: if REP in FS is a "PLAIN" representation, its
+ * EXPANDED_SIZE element may be 0, in which case its value has to be taken
+ * from SIZE.
+ *
+ * This function ensures that EXPANDED_SIZE in REP always contains the
+ * actual value. No-op if REP is NULL.  Uses SCRATCH_POOL for temporaries.
+ */
+svn_error_t *
+svn_fs_fs__fixup_expanded_size(svn_fs_t *fs,
+                               representation_t *rep,
+                               apr_pool_t *scratch_pool);
+
 /* Set *NODEREV_P to the node-revision for the node ID in FS.  Do any
    allocations in POOL. */
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c?rev=1674341&r1=1674340&r2=1674341&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c Fri Apr 17 15:56:12 2015
@@ -24,6 +24,7 @@
 
 #include "svn_private_config.h"
 
+#include "cached_data.h"
 #include "fs_fs.h"
 #include "fs.h"
 #include "rep-cache.h"
@@ -273,6 +274,8 @@ svn_fs_fs__get_rep_reference(representat
       (*rep)->item_index = svn_sqlite__column_int64(stmt, 1);
       (*rep)->size = svn_sqlite__column_int64(stmt, 2);
       (*rep)->expanded_size = svn_sqlite__column_int64(stmt, 3);
+
+      SVN_ERR(svn_fs_fs__fixup_expanded_size(fs, *rep, pool));
     }
   else
     *rep = NULL;