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 2013/02/05 10:24:09 UTC

svn commit: r1442514 - in /subversion/branches/fsfs-format7/subversion/libsvn_fs_fs: cached_data.c cached_data.h fs_fs.c transaction.c

Author: stefan2
Date: Tue Feb  5 09:24:08 2013
New Revision: 1442514

URL: http://svn.apache.org/viewvc?rev=1442514&view=rev
Log:
On the fsfs-format7 branch: get everything to compile, link and test again.
Due to the refactorings on our branch, we need to adapt the source structure.

* subversion/libsvn_fs_fs/cached_data.h
  (svn_fs_fs__rep_chain_length): declare new internal API function

* subversion/libsvn_fs_fs/cached_data.c
  (svn_fs_fs__rep_chain_length): implement new internal API function,
   taken from choose_delta_base

* subversion/libsvn_fs_fs/fs_fs.c
  (verify_walker): baton is always available; call svn_fs_fs__check_rep
   to actually verify the given revision

* subversion/libsvn_fs_fs/transaction.c
  (verify_walker): drop local declaration as it is no longer needed
  (choose_delta_base): call the new svn_fs_fs__rep_chain_length() API
   to check for delta chain lengths
  (get_shared_rep): call svn_fs_fs__check_rep directly

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.h
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c?rev=1442514&r1=1442513&r2=1442514&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c Tue Feb  5 09:24:08 2013
@@ -563,6 +563,62 @@ svn_fs_fs__check_rep(representation_t *r
   return SVN_NO_ERROR;
 }
 
+/* .
+   Do any allocations in POOL. */
+svn_error_t *
+svn_fs_fs__rep_chain_length(int *chain_length,
+                            representation_t *rep,
+                            svn_fs_t *fs,
+                            apr_pool_t *pool)
+{
+  int count = 0;
+  apr_pool_t *sub_pool = svn_pool_create(pool);
+  
+  /* Check whether the length of the deltification chain is acceptable.
+   * Otherwise, shared reps may form a non-skipping delta chain in
+   * extreme cases. */
+  representation_t base_rep = *rep;
+
+  /* re-use open files between iterations */
+  svn_revnum_t rev_hint = SVN_INVALID_REVNUM;
+  apr_file_t *file_hint = NULL;
+
+  svn_fs_fs__rep_header_t *header;
+
+  /* follow the delta chain towards the end but for at most
+   * MAX_CHAIN_LENGTH steps. */
+  do
+    {
+      rep_state_t *rep_state;
+      SVN_ERR(create_rep_state_body(&rep_state,
+                                    &header,
+                                    &file_hint,
+                                    &rev_hint,
+                                    &base_rep,
+                                    fs,
+                                    sub_pool));
+
+      base_rep.revision = header->base_revision;
+      base_rep.item_index = header->base_item_index;
+      base_rep.size = header->base_length;
+      base_rep.txn_id = NULL;
+
+      ++count;
+      if (count % 16 == 0)
+        {
+          rev_hint = SVN_INVALID_REVNUM;
+          file_hint = NULL;
+          svn_pool_clear(sub_pool);
+        }
+    }
+  while (header->is_delta && header->base_revision);
+
+  *chain_length = count;
+  svn_pool_destroy(sub_pool);
+
+  return SVN_NO_ERROR;
+}
+
 
 struct rep_read_baton
 {

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.h?rev=1442514&r1=1442513&r2=1442514&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.h Tue Feb  5 09:24:08 2013
@@ -53,6 +53,15 @@ svn_fs_fs__check_rep(representation_t *r
                      svn_fs_t *fs,
                      apr_pool_t *pool);
 
+/* Follow the representation delta chain in FS starting with REP.  The
+   number of reps (including REP) in the chain will be returned in
+   *CHAIN_LENGTH.  Do any allocations in POOL. */
+svn_error_t *
+svn_fs_fs__rep_chain_length(int *chain_length,
+                            representation_t *rep,
+                            svn_fs_t *fs,
+                            apr_pool_t *pool);
+
 /* Set *CONTENTS to be a readable svn_stream_t that receives the text
    representation REP as seen in filesystem FS.
    Use POOL for temporary allocations. */

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c?rev=1442514&r1=1442513&r2=1442514&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c Tue Feb  5 09:24:08 2013
@@ -1370,53 +1370,39 @@ verify_walker(representation_t *rep,
               svn_fs_t *fs,
               apr_pool_t *scratch_pool)
 {
-  struct rep_state *rs;
-  struct rep_args *rep_args;
+  verify_walker_baton_t *walker_baton = baton;
+  apr_file_t * previous_file;
 
-  if (baton)
+  /* notify and free resources periodically */
+  if (   walker_baton->iteration_count > 1000
+      || walker_baton->file_count > 16)
     {
-      verify_walker_baton_t *walker_baton = baton;
-      apr_file_t * previous_file;
-
-      /* notify and free resources periodically */
-      if (   walker_baton->iteration_count > 1000
-          || walker_baton->file_count > 16)
+      if (   walker_baton->notify_func
+          && rep->revision != walker_baton->last_notified_revision)
         {
-          if (   walker_baton->notify_func
-              && rep->revision != walker_baton->last_notified_revision)
-            {
-              walker_baton->notify_func(rep->revision,
-                                        walker_baton->notify_baton,
-                                        scratch_pool);
-              walker_baton->last_notified_revision = rep->revision;
-            }
-
-          svn_pool_clear(walker_baton->pool);
-          
-          walker_baton->iteration_count = 0;
-          walker_baton->file_count = 0;
-          walker_baton->file_hint = NULL;
-          walker_baton->rev_hint = SVN_INVALID_REVNUM;
+          walker_baton->notify_func(rep->revision,
+                                    walker_baton->notify_baton,
+                                    scratch_pool);
+          walker_baton->last_notified_revision = rep->revision;
         }
 
-      /* access the repo data */
-      previous_file = walker_baton->file_hint;
-      SVN_ERR(create_rep_state(&rs, &rep_args, &walker_baton->file_hint,
-                               &walker_baton->rev_hint, rep, fs,
-                               walker_baton->pool));
-
-      /* update resource usage counters */
-      walker_baton->iteration_count++;
-      if (previous_file != walker_baton->file_hint)
-        walker_baton->file_count++;
-    }
-  else
-    {
-      /* ### Should this be using read_rep_line() directly? */
-      SVN_ERR(create_rep_state(&rs, &rep_args, NULL, NULL, rep, fs,
-                               scratch_pool));
+      svn_pool_clear(walker_baton->pool);
+
+      walker_baton->iteration_count = 0;
+      walker_baton->file_count = 0;
+      walker_baton->file_hint = NULL;
+      walker_baton->rev_hint = SVN_INVALID_REVNUM;
     }
 
+  /* access the repo data */
+  previous_file = walker_baton->file_hint;
+  SVN_ERR(svn_fs_fs__check_rep(rep, fs, walker_baton->pool));
+
+  /* update resource usage counters */
+  walker_baton->iteration_count++;
+  if (previous_file != walker_baton->file_hint)
+    walker_baton->file_count++;
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c?rev=1442514&r1=1442513&r2=1442514&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Tue Feb  5 09:24:08 2013
@@ -60,12 +60,6 @@ static txn_vtable_t txn_vtable = {
   svn_fs_fs__change_txn_props
 };
 
-static svn_error_t *
-verify_walker(representation_t *rep,
-              void *baton,
-              svn_fs_t *fs,
-              apr_pool_t *scratch_pool);
-
 /* Functions for working with shared transaction data. */
 
 /* Return the transaction object for transaction TXN_ID from the
@@ -1849,48 +1843,13 @@ choose_delta_base(representation_t **rep
    * from the node-rev parent chain. */
   if (*rep && maybe_shared_rep)
     {
-      /* Check whether the length of the deltification chain is acceptable.
-       * Otherwise, shared reps may form a non-skipping delta chain in
-       * extreme cases. */
-      apr_pool_t *sub_pool = svn_pool_create(pool);
-      representation_t base_rep = **rep;
+      int chain_length = 0;
+      SVN_ERR(svn_fs_fs__rep_chain_length(&chain_length, *rep, fs, pool));
       
       /* Some reasonable limit, depending on how acceptable longer linear
        * chains are in this repo.  Also, allow for some minimal chain. */
-      int max_chain_length = 2 * (int)ffd->max_linear_deltification + 2;
-
-      /* re-use open files between iterations */
-      svn_revnum_t rev_hint = SVN_INVALID_REVNUM;
-      apr_file_t *file_hint = NULL;
-
-      /* follow the delta chain towards the end but for at most
-       * MAX_CHAIN_LENGTH steps. */
-      for (; max_chain_length; --max_chain_length)
-        {
-          struct rep_state *rep_state;
-          struct rep_args *rep_args;
-
-          SVN_ERR(create_rep_state_body(&rep_state,
-                                        &rep_args,
-                                        &file_hint,
-                                        &rev_hint,
-                                        &base_rep,
-                                        fs,
-                                        sub_pool));
-          if (!rep_args->is_delta  || !rep_args->base_revision)
-            break;
-
-          base_rep.revision = rep_args->base_revision;
-          base_rep.offset = rep_args->base_offset;
-          base_rep.size = rep_args->base_length;
-          base_rep.txn_id = NULL;
-        }
-
-      /* start new delta chain if the current one has grown too long */
-      if (max_chain_length == 0)
+      if (chain_length >= 2 * (int)ffd->max_linear_deltification + 2)
         *rep = NULL;
-
-      svn_pool_destroy(sub_pool);
     }
 
   /* verify that the reps don't form a degenerated '*/
@@ -2050,7 +2009,7 @@ get_shared_rep(representation_t **old_re
       if (err == SVN_NO_ERROR)
         {
           if (*old_rep)
-            SVN_ERR(verify_walker(*old_rep, NULL, fs, pool));
+            SVN_ERR(svn_fs_fs__check_rep(*old_rep, fs, pool));
         }
       else if (err->apr_err == SVN_ERR_FS_CORRUPT
                || SVN_ERROR_IN_CATEGORY(err->apr_err,