subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1503718 - in /subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs: fs.c fs_fs.c fs_fs.h verify.c verify.h
Date Tue, 16 Jul 2013 13:54:13 GMT
Author: stefan2
Date: Tue Jul 16 13:54:13 2013
New Revision: 1503718

URL: http://svn.apache.org/r1503718
Log:
On the fsfs-improvements branch:  Move repository verification
code from fs_fs.* to a new verify.* pair of files.

Also, factor out the actual checks from the svn_fs_fs__verify
function such that more checks may be added later easily.

* subversion/libsvn_fs_fs/verify.h
  (): new file
  (svn_fs_fs__verify): move declaration here from fs_fs.h

* subversion/libsvn_fs_fs/verify.c
  (): new file, code taken from fs_fs.c
  (verify_walker_baton_t,
   verify_walker): moved here
  (verify_rep_cache): factored out from svn_fs_fs__verify
  (svn_fs_fs__verify): stripped down to parameter checks

* subversion/libsvn_fs_fs/fs_fs.h
  (): new file
  (svn_fs_fs__verify): move declaration to verify.h

* subversion/libsvn_fs_fs/fs_fs.c
  (verify_walker_baton_t,
   verify_walker,
   svn_fs_fs__verify): code moved to verify.c
  (get_shared_rep): update caller

* subversion/libsvn_fs_fs/fs.c
  (): #include new header

Added:
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.c
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.h
Modified:
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.c
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.c
    subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.h

Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.c?rev=1503718&r1=1503717&r2=1503718&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.c Tue Jul 16 13:54:13
2013
@@ -41,6 +41,7 @@
 #include "pack.h"
 #include "rep-cache.h"
 #include "revprops.h"
+#include "verify.h"
 #include "svn_private_config.h"
 #include "private/svn_fs_util.h"
 

Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.c?rev=1503718&r1=1503717&r2=1503718&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.c Tue Jul 16 13:54:13
2013
@@ -125,12 +125,6 @@ static txn_vtable_t txn_vtable = {
 static svn_error_t *
 get_youngest(svn_revnum_t *youngest_p, const char *fs_path, apr_pool_t *pool);
 
-static svn_error_t *
-verify_walker(representation_t *rep,
-              void *baton,
-              svn_fs_t *fs,
-              apr_pool_t *scratch_pool);
-
 /* Pathname helper functions */
 
 static const char *
@@ -2806,7 +2800,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, NULL, NULL, pool));
         }
       else if (err->apr_err == SVN_ERR_FS_CORRUPT
                || SVN_ERROR_IN_CATEGORY(err->apr_err,
@@ -5088,151 +5082,6 @@ svn_fs_fs__begin_txn(svn_fs_txn_t **txn_
 }
 
 
-/** Verifying. **/
-
-/* Baton type expected by verify_walker().  The purpose is to reuse open
- * rev / pack file handles between calls.  Its contents need to be cleaned
- * periodically to limit resource usage.
- */
-typedef struct verify_walker_baton_t
-{
-  /* number of calls to verify_walker() since the last clean */
-  int iteration_count;
-
-  /* number of files opened since the last clean */
-  int file_count;
-
-  /* progress notification callback to invoke periodically (may be NULL) */
-  svn_fs_progress_notify_func_t notify_func;
-
-  /* baton to use with NOTIFY_FUNC */
-  void *notify_baton;
-
-  /* remember the last revision for which we called notify_func */
-  svn_revnum_t last_notified_revision;
-
-  /* current file handle (or NULL) */
-  apr_file_t *file_hint;
-
-  /* corresponding revision (or SVN_INVALID_REVNUM) */
-  svn_revnum_t rev_hint;
-
-  /* pool to use for the file handles etc. */
-  apr_pool_t *pool;
-} verify_walker_baton_t;
-
-/* Used by svn_fs_fs__verify().
-   Implements svn_fs_fs__walk_rep_reference().walker.  */
-static svn_error_t *
-verify_walker(representation_t *rep,
-              void *baton,
-              svn_fs_t *fs,
-              apr_pool_t *scratch_pool)
-{
-  if (baton)
-    {
-      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)
-            {
-              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;
-        }
-
-      /* access the repo data */
-      previous_file = walker_baton->file_hint;
-      SVN_ERR(svn_fs_fs__check_rep(rep, fs, &walker_baton->file_hint,
-                                   &walker_baton->rev_hint,
-                                   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(svn_fs_fs__check_rep(rep, fs, NULL, NULL, scratch_pool));
-    }
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_fs_fs__verify(svn_fs_t *fs,
-                  svn_revnum_t start,
-                  svn_revnum_t end,
-                  svn_fs_progress_notify_func_t notify_func,
-                  void *notify_baton,
-                  svn_cancel_func_t cancel_func,
-                  void *cancel_baton,
-                  apr_pool_t *pool)
-{
-  fs_fs_data_t *ffd = fs->fsap_data;
-  svn_boolean_t exists;
-  svn_revnum_t youngest = ffd->youngest_rev_cache; /* cache is current */
-
-  if (ffd->format < SVN_FS_FS__MIN_REP_SHARING_FORMAT)
-    return SVN_NO_ERROR;
-
-  /* Input validation. */
-  if (! SVN_IS_VALID_REVNUM(start))
-    start = 0;
-  if (! SVN_IS_VALID_REVNUM(end))
-    end = youngest;
-  SVN_ERR(ensure_revision_exists(fs, start, pool));
-  SVN_ERR(ensure_revision_exists(fs, end, pool));
-
-  /* rep-cache verification. */
-  SVN_ERR(svn_fs_fs__exists_rep_cache(&exists, fs, pool));
-  if (exists)
-    {
-      /* provide a baton to allow the reuse of open file handles between
-         iterations (saves 2/3 of OS level file operations). */
-      verify_walker_baton_t *baton = apr_pcalloc(pool, sizeof(*baton));
-      baton->rev_hint = SVN_INVALID_REVNUM;
-      baton->pool = svn_pool_create(pool);
-      baton->last_notified_revision = SVN_INVALID_REVNUM;
-      baton->notify_func = notify_func;
-      baton->notify_baton = notify_baton;
-
-      /* tell the user that we are now ready to do *something* */
-      if (notify_func)
-        notify_func(SVN_INVALID_REVNUM, notify_baton, baton->pool);
-
-      /* Do not attempt to walk the rep-cache database if its file does
-         not exist,  since doing so would create it --- which may confuse
-         the administrator.   Don't take any lock. */
-      SVN_ERR(svn_fs_fs__walk_rep_reference(fs, start, end,
-                                            verify_walker, baton,
-                                            cancel_func, cancel_baton,
-                                            pool));
-
-      /* walker resource cleanup */
-      svn_pool_destroy(baton->pool);
-    }
-
-  return SVN_NO_ERROR;
-}
-
-
 /** Hotcopy. **/
 
 /* Like svn_io_dir_file_copy(), but doesn't copy files that exist at

Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.h?rev=1503718&r1=1503717&r2=1503718&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.h (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs_fs.h Tue Jul 16 13:54:13
2013
@@ -45,20 +45,6 @@ svn_error_t *svn_fs_fs__upgrade(svn_fs_t
                                 void *cancel_baton,
                                 apr_pool_t *pool);
 
-/* Verify metadata in fsfs filesystem FS.  Limit the checks to revisions
- * START to END where possible.  Indicate progress via the optional
- * NOTIFY_FUNC callback using NOTIFY_BATON.  The optional CANCEL_FUNC
- * will periodically be called with CANCEL_BATON to allow for preemption.
- * Use POOL for temporary allocations. */
-svn_error_t *svn_fs_fs__verify(svn_fs_t *fs,
-                               svn_revnum_t start,
-                               svn_revnum_t end,
-                               svn_fs_progress_notify_func_t notify_func,
-                               void *notify_baton,
-                               svn_cancel_func_t cancel_func,
-                               void *cancel_baton,
-                               apr_pool_t *pool);
-
 /* Copy the fsfs filesystem SRC_FS at SRC_PATH into a new copy DST_FS at
  * DST_PATH. If INCREMENTAL is TRUE, do not re-copy data which already
  * exists in DST_FS. Use POOL for temporary allocations. */

Added: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.c?rev=1503718&view=auto
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.c (added)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.c Tue Jul 16 13:54:13
2013
@@ -0,0 +1,198 @@
+/* verify.c --- verification of FSFS filesystems
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+#include "verify.h"
+#include "fs_fs.h"
+
+#include "cached_data.h"
+#include "rep-cache.h"
+#include "util.h"
+
+#include "../libsvn_fs/fs-loader.h"
+
+#include "svn_private_config.h"
+
+
+/** Verifying. **/
+
+/* Baton type expected by verify_walker().  The purpose is to reuse open
+ * rev / pack file handles between calls.  Its contents need to be cleaned
+ * periodically to limit resource usage.
+ */
+typedef struct verify_walker_baton_t
+{
+  /* number of calls to verify_walker() since the last clean */
+  int iteration_count;
+
+  /* number of files opened since the last clean */
+  int file_count;
+
+  /* progress notification callback to invoke periodically (may be NULL) */
+  svn_fs_progress_notify_func_t notify_func;
+
+  /* baton to use with NOTIFY_FUNC */
+  void *notify_baton;
+
+  /* remember the last revision for which we called notify_func */
+  svn_revnum_t last_notified_revision;
+
+  /* current file handle (or NULL) */
+  apr_file_t *file_hint;
+
+  /* corresponding revision (or SVN_INVALID_REVNUM) */
+  svn_revnum_t rev_hint;
+
+  /* pool to use for the file handles etc. */
+  apr_pool_t *pool;
+} verify_walker_baton_t;
+
+/* Used by svn_fs_fs__verify().
+   Implements svn_fs_fs__walk_rep_reference().walker.  */
+static svn_error_t *
+verify_walker(representation_t *rep,
+              void *baton,
+              svn_fs_t *fs,
+              apr_pool_t *scratch_pool)
+{
+  if (baton)
+    {
+      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)
+            {
+              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;
+        }
+
+      /* access the repo data */
+      previous_file = walker_baton->file_hint;
+      SVN_ERR(svn_fs_fs__check_rep(rep, fs, &walker_baton->file_hint,
+                                   &walker_baton->rev_hint,
+                                   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(svn_fs_fs__check_rep(rep, fs, NULL, NULL, scratch_pool));
+    }
+
+  return SVN_NO_ERROR;
+}
+
+/* Verify the rep cache DB's consistency with our rev / pack data.
+ * The function signature is similar to svn_fs_fs__verify.
+ * The values of START and END have already been auto-selected and
+ * verified.
+ */
+static svn_error_t *
+verify_rep_cache(svn_fs_t *fs,
+                 svn_revnum_t start,
+                 svn_revnum_t end,
+                 svn_fs_progress_notify_func_t notify_func,
+                 void *notify_baton,
+                 svn_cancel_func_t cancel_func,
+                 void *cancel_baton,
+                 apr_pool_t *pool)
+{
+  svn_boolean_t exists;
+
+  /* rep-cache verification. */
+  SVN_ERR(svn_fs_fs__exists_rep_cache(&exists, fs, pool));
+  if (exists)
+    {
+      /* provide a baton to allow the reuse of open file handles between
+         iterations (saves 2/3 of OS level file operations). */
+      verify_walker_baton_t *baton = apr_pcalloc(pool, sizeof(*baton));
+      baton->rev_hint = SVN_INVALID_REVNUM;
+      baton->pool = svn_pool_create(pool);
+      baton->last_notified_revision = SVN_INVALID_REVNUM;
+      baton->notify_func = notify_func;
+      baton->notify_baton = notify_baton;
+
+      /* tell the user that we are now ready to do *something* */
+      if (notify_func)
+        notify_func(SVN_INVALID_REVNUM, notify_baton, baton->pool);
+
+      /* Do not attempt to walk the rep-cache database if its file does
+         not exist,  since doing so would create it --- which may confuse
+         the administrator.   Don't take any lock. */
+      SVN_ERR(svn_fs_fs__walk_rep_reference(fs, start, end,
+                                            verify_walker, baton,
+                                            cancel_func, cancel_baton,
+                                            pool));
+
+      /* walker resource cleanup */
+      svn_pool_destroy(baton->pool);
+    }
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_fs__verify(svn_fs_t *fs,
+                  svn_revnum_t start,
+                  svn_revnum_t end,
+                  svn_fs_progress_notify_func_t notify_func,
+                  void *notify_baton,
+                  svn_cancel_func_t cancel_func,
+                  void *cancel_baton,
+                  apr_pool_t *pool)
+{
+  fs_fs_data_t *ffd = fs->fsap_data;
+  svn_revnum_t youngest = ffd->youngest_rev_cache; /* cache is current */
+
+  /* Input validation. */
+  if (! SVN_IS_VALID_REVNUM(start))
+    start = 0;
+  if (! SVN_IS_VALID_REVNUM(end))
+    end = youngest;
+  SVN_ERR(svn_fs_fs__revision_exists(start, fs, pool));
+  SVN_ERR(svn_fs_fs__revision_exists(end, fs, pool));
+
+  /* rep cache consistency */
+  if (ffd->format >= SVN_FS_FS__MIN_REP_SHARING_FORMAT)
+    SVN_ERR(verify_rep_cache(fs, start, end, notify_func, notify_baton,
+                             cancel_func, cancel_baton, pool));
+
+  return SVN_NO_ERROR;
+}

Added: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.h?rev=1503718&view=auto
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.h (added)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/verify.h Tue Jul 16 13:54:13
2013
@@ -0,0 +1,42 @@
+/* verify.h : verification interface of the native filesystem layer
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+#ifndef SVN_LIBSVN_FS__VERIFY_H
+#define SVN_LIBSVN_FS__VERIFY_H
+
+#include "fs.h"
+
+/* Verify metadata in fsfs filesystem FS.  Limit the checks to revisions
+ * START to END where possible.  Indicate progress via the optional
+ * NOTIFY_FUNC callback using NOTIFY_BATON.  The optional CANCEL_FUNC
+ * will periodically be called with CANCEL_BATON to allow for preemption.
+ * Use POOL for temporary allocations. */
+svn_error_t *svn_fs_fs__verify(svn_fs_t *fs,
+                               svn_revnum_t start,
+                               svn_revnum_t end,
+                               svn_fs_progress_notify_func_t notify_func,
+                               void *notify_baton,
+                               svn_cancel_func_t cancel_func,
+                               void *cancel_baton,
+                               apr_pool_t *pool);
+
+#endif



Mime
View raw message