You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2011/07/13 20:58:55 UTC

svn commit: r1146226 - in /subversion/trunk/subversion/libsvn_fs_fs: fs_fs.c rep-cache-db.sql rep-cache.c rep-cache.h

Author: danielsh
Date: Wed Jul 13 18:58:55 2011
New Revision: 1146226

URL: http://svn.apache.org/viewvc?rev=1146226&view=rev
Log:
Implement svn_fs_verify() for FSFS.

* subversion/libsvn_fs_fs/fs_fs.c
  (svn_fs_fs__verify): Fill in.
  (verify_walker): New.

* subversion/libsvn_fs_fs/rep-cache-db.sql
  (STMT_GET_ALL_REPS): New.

* subversion/libsvn_fs_fs/rep-cache.h
  (svn_fs_fs__walk_rep_reference): New.

* subversion/libsvn_fs_fs/rep-cache.c
  (svn_fs_fs__walk_rep_reference): New.
  (svn_pools.h): Include.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
    subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql
    subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c
    subversion/trunk/subversion/libsvn_fs_fs/rep-cache.h

Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=1146226&r1=1146225&r2=1146226&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Wed Jul 13 18:58:55 2011
@@ -1323,17 +1323,6 @@ svn_fs_fs__upgrade(svn_fs_t *fs, apr_poo
 }
 
 
-/** Verifying. **/
-svn_error_t *
-svn_fs_fs__verify(svn_fs_t *fs,
-                  svn_cancel_func_t cancel_func,
-                  void *cancel_baton,
-                  apr_pool_t *pool)
-{
-  return SVN_NO_ERROR; /* ### Not implemented. Should dereference rep-cache */
-}
-
-
 /* SVN_ERR-like macros for dealing with recoverable errors on mutable files
  *
  * Revprops, current, and txn-current files are mutable; that is, they
@@ -7786,3 +7775,37 @@ svn_fs_fs__pack(svn_fs_t *fs,
   pb.cancel_baton = cancel_baton;
   return svn_fs_fs__with_write_lock(fs, pack_body, &pb, pool);
 }
+
+
+/** Verifying. **/
+
+static svn_error_t *
+verify_walker(representation_t *rep,
+              svn_fs_t *fs,
+              apr_pool_t *scratch_pool)
+{
+  struct rep_state *rs;
+  struct rep_args *rep_args;
+
+  /* ### Should this be using read_rep_line() directly? */
+  SVN_ERR(create_rep_state(&rs, &rep_args, rep, fs, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_fs__verify(svn_fs_t *fs,
+                  svn_cancel_func_t cancel_func,
+                  void *cancel_baton,
+                  apr_pool_t *pool)
+{
+  fs_fs_data_t *ffd = fs->fsap_data;
+
+  if (ffd->rep_sharing_allowed == FALSE)
+    return SVN_NO_ERROR;
+
+  /* Don't take any lock. */
+  SVN_ERR(svn_fs_fs__walk_rep_reference(fs, verify_walker, pool));
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql?rev=1146226&r1=1146225&r2=1146226&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache-db.sql Wed Jul 13 18:58:55 2011
@@ -45,3 +45,10 @@ WHERE hash = ?1
 -- STMT_SET_REP
 INSERT OR FAIL INTO rep_cache (hash, revision, offset, size, expanded_size)
 VALUES (?1, ?2, ?3, ?4, ?5)
+
+
+-- STMT_GET_ALL_REPS
+SELECT hash, revision, offset, size, expanded_size
+FROM rep_cache
+
+

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=1146226&r1=1146225&r2=1146226&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache.c Wed Jul 13 18:58:55 2011
@@ -20,6 +20,8 @@
  * ====================================================================
  */
 
+#include "svn_pools.h"
+
 #include "svn_private_config.h"
 
 #include "fs_fs.h"
@@ -117,6 +119,66 @@ svn_fs_fs__open_rep_cache(svn_fs_t *fs,
   return svn_error_quick_wrap(err, _("Couldn't open rep-cache database"));
 }
 
+svn_error_t *
+svn_fs_fs__walk_rep_reference(svn_fs_t *fs,
+                              svn_error_t *(*walker)(representation_t *,
+                                                     svn_fs_t *, 
+                                                     apr_pool_t *),
+                              apr_pool_t *pool)
+{
+  fs_fs_data_t *ffd = fs->fsap_data;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+  int iterations = 0;
+
+  apr_pool_t *iterpool = svn_pool_create(pool);
+
+  /* Don't check ffd->rep_sharing_allowed. */
+  SVN_ERR_ASSERT(ffd->format >= SVN_FS_FS__MIN_REP_SHARING_FORMAT);
+
+  if (! ffd->rep_cache_db)
+    SVN_ERR(svn_fs_fs__open_rep_cache(fs, pool));
+
+  /* Get the statement. (There are no arguments to bind.) */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, ffd->rep_cache_db,
+                                    STMT_GET_ALL_REPS));
+
+  /* Walk the cache entries. */
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  while (have_row)
+    {
+      representation_t *rep;
+      const char *sha1_digest;
+      
+      /* Clear ITERPOOL occasionally. */
+      if (iterations++ % 16 == 0)
+        svn_pool_clear(iterpool);
+
+      /* Construct a representation_t. */
+      rep = apr_pcalloc(pool, sizeof(*rep));
+      sha1_digest = svn_sqlite__column_text(stmt, 0, iterpool);
+      SVN_ERR(svn_checksum_parse_hex(&rep->sha1_checksum,
+                                     svn_checksum_sha1, sha1_digest,
+                                     iterpool));
+      rep->revision = svn_sqlite__column_revnum(stmt, 1);
+      rep->offset = svn_sqlite__column_int64(stmt, 2);
+      rep->size = svn_sqlite__column_int64(stmt, 3);
+      rep->expanded_size = svn_sqlite__column_int64(stmt, 4);
+
+      /* Sanity check. */
+      if (rep)
+        SVN_ERR(rep_has_been_born(rep, fs, pool));
+
+      /* Walk. */
+      SVN_ERR(walker(rep, fs, iterpool));
+
+      SVN_ERR(svn_sqlite__step(&have_row, stmt));
+    }
+
+  SVN_ERR(svn_sqlite__reset(stmt));
+
+  return SVN_NO_ERROR;
+}
 /* This function's caller ignores most errors it returns.
    If you extend this function, check the callsite to see if you have
    to make it not-ignore additional error codes.  */

Modified: subversion/trunk/subversion/libsvn_fs_fs/rep-cache.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rep-cache.h?rev=1146226&r1=1146225&r2=1146226&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rep-cache.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rep-cache.h Wed Jul 13 18:58:55 2011
@@ -40,6 +40,14 @@ svn_error_t *
 svn_fs_fs__open_rep_cache(svn_fs_t *fs,
                           apr_pool_t *pool);
 
+/* Iterate all representations currently in FS's cache. */
+svn_error_t *
+svn_fs_fs__walk_rep_reference(svn_fs_t *fs,
+                              svn_error_t *(*walker)(representation_t *rep,
+                                                     svn_fs_t *fs, 
+                                                     apr_pool_t *scratch_pool),
+                              apr_pool_t *pool);
+
 /* Return the representation REP in FS which has fulltext CHECKSUM.
    REP is allocated in POOL.  If the rep cache database has not been
    opened, just set *REP to NULL. */