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 2017/05/16 18:20:41 UTC

svn commit: r1795351 - in /subversion/trunk/subversion/libsvn_fs_fs: fs.h fs_fs.c transaction.c

Author: stefan2
Date: Tue May 16 18:20:41 2017
New Revision: 1795351

URL: http://svn.apache.org/viewvc?rev=1795351&view=rev
Log:
Make verify-before-commit a configurable option in FSFS.

The option causes FSFS to verify each new revision immediately before
finalizing the commit (bumping the 'current' revision number).

It is useful to be able to enable this after repository corruption has been
observed that is suspected to be bug-induced.

The option is disabled by default in release-mode builds, and enabled by
default in debug-mode builds. Previously, the verification was permanently
disabled in release-mode builds and enabled in debug-mode builds.

* subversion/libsvn_fs_fs/fs_fs.c
  (read_config): Read the option.
  (write_config): Write a template for the option.

* subversion/libsvn_fs_fs/fs.h
  (CONFIG_OPTION_VERIFY_BEFORE_COMMIT): New.
  (fs_fs_data_t): Store the option value.

* subversion/libsvn_fs_fs/transaction.c
  (verify_as_revision_before_current_plus_plus): Rename to ...
  (verify_before_commit): ... this and compile unconditionally,
    not just in debug builds.
  (commit_body): Call the function only if the option is enabled.

Patch by: julianfoad (with minor tweaks by me)

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/fs.h
    subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
    subversion/trunk/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/fs.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs.h?rev=1795351&r1=1795350&r2=1795351&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs.h Tue May 16 18:20:41 2017
@@ -117,6 +117,7 @@ extern "C" {
 #define CONFIG_OPTION_P2L_PAGE_SIZE      "p2l-page-size"
 #define CONFIG_SECTION_DEBUG             "debug"
 #define CONFIG_OPTION_PACK_AFTER_COMMIT  "pack-after-commit"
+#define CONFIG_OPTION_VERIFY_BEFORE_COMMIT "verify-before-commit"
 
 /* The format number of this filesystem.
    This is independent of the repository format number, and
@@ -475,6 +476,9 @@ typedef struct fs_fs_data_t
   /* Pack after every commit. */
   svn_boolean_t pack_after_commit;
 
+  /* Verify each new revision before commit. */
+  svn_boolean_t verify_before_commit;
+
   /* Per-instance filesystem ID, which provides an additional level of
      uniqueness for filesystems that share the same UUID, but should
      still be distinguishable (e.g. backups produced by svn_fs_hotcopy()

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=1795351&r1=1795350&r2=1795351&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Tue May 16 18:20:41 2017
@@ -816,6 +816,17 @@ read_config(fs_fs_data_t *ffd,
     {
       ffd->pack_after_commit = FALSE;
     }
+#ifdef SVN_DEBUG
+  SVN_ERR(svn_config_get_bool(config, &ffd->verify_before_commit,
+                              CONFIG_SECTION_DEBUG,
+                              CONFIG_OPTION_VERIFY_BEFORE_COMMIT,
+                              TRUE));
+#else
+  SVN_ERR(svn_config_get_bool(config, &ffd->verify_before_commit,
+                              CONFIG_SECTION_DEBUG,
+                              CONFIG_OPTION_VERIFY_BEFORE_COMMIT,
+                              FALSE));
+#endif
 
   /* memcached configuration */
   SVN_ERR(svn_cache__make_memcache_from_config(&ffd->memcache, config,
@@ -1020,6 +1031,13 @@ write_config(svn_fs_t *fs,
 "### Must be a power of 2."                                                  NL
 "### p2l-page-size is given in kBytes and with a default of 1024 kBytes."    NL
 "# " CONFIG_OPTION_P2L_PAGE_SIZE " = 1024"                                   NL
+""                                                                           NL
+"[" CONFIG_SECTION_DEBUG "]"                                                 NL
+"###"                                                                        NL
+"### Whether to verify each new revision immediately before finalizing"      NL
+"### the commit. The default is false in release-mode builds, and true"      NL
+"### in debug-mode builds."                                                  NL
+"# " CONFIG_OPTION_VERIFY_BEFORE_COMMIT " = false"                           NL
 ;
 #undef NL
   return svn_io_file_create(svn_dirent_join(fs->path, PATH_CONFIG, pool),

Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1795351&r1=1795350&r2=1795351&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Tue May 16 18:20:41 2017
@@ -3421,11 +3421,10 @@ write_final_changed_path_info(apr_off_t
    Intended to be called as the very last step in a commit before 'current'
    is bumped.  This implies that we are holding the write lock. */
 static svn_error_t *
-verify_as_revision_before_current_plus_plus(svn_fs_t *fs,
-                                            svn_revnum_t new_rev,
-                                            apr_pool_t *pool)
+verify_before_commit(svn_fs_t *fs,
+                     svn_revnum_t new_rev,
+                     apr_pool_t *pool)
 {
-#ifdef SVN_DEBUG
   fs_fs_data_t *ffd = fs->fsap_data;
   svn_fs_t *ft; /* fs++ == ft */
   svn_fs_root_t *root;
@@ -3455,7 +3454,6 @@ verify_as_revision_before_current_plus_p
   SVN_ERR_ASSERT(root->is_txn_root == FALSE && root->rev == new_rev);
   SVN_ERR_ASSERT(ft_ffd->youngest_rev_cache == new_rev);
   SVN_ERR(svn_fs_fs__verify_root(root, pool));
-#endif /* SVN_DEBUG */
 
   return SVN_NO_ERROR;
 }
@@ -3875,8 +3873,13 @@ commit_body(void *baton, apr_pool_t *poo
   SVN_ERR(write_final_revprop(revprop_filename, old_rev_filename,
                               cb->txn, ffd->flush_to_disk, pool));
 
+  /* Run paranoia checks. */
+  if (ffd->verify_before_commit)
+    {
+      SVN_ERR(verify_before_commit(cb->fs, new_rev, pool));
+    }
+
   /* Update the 'current' file. */
-  SVN_ERR(verify_as_revision_before_current_plus_plus(cb->fs, new_rev, pool));
   SVN_ERR(write_final_current(cb->fs, txn_id, new_rev, start_node_id,
                               start_copy_id, pool));