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/01/11 02:09:52 UTC

svn commit: r1650843 - in /subversion/trunk/subversion/libsvn_fs_x: hotcopy.c hotcopy.h

Author: stefan2
Date: Sun Jan 11 01:09:52 2015
New Revision: 1650843

URL: http://svn.apache.org/r1650843
Log:
Continue migrating FSX to the two-pool paradigm.  Many single-pool functions
don't allocate a return value, i.e. their pools can immediately be renamed
to SCRATCH_POOL.  Do this for hotcopy.* .

* subversion/libsvn_fs_x/hotcopy.h
  (svn_fs_x__hotcopy_prepare_target,
   svn_fs_x__hotcopy): POOL is actually a SCRATCH_POOL.

* subversion/libsvn_fs_x/hotcopy.c
  (hotcopy_io_copy_dir_recursively,
   hotcopy_remove_file,
   remove_folder,
   hotcopy_revisions,
   hotcopy_body,
   hotcopy_locking_src_body,
   hotcopy_create_empty_dest,
   svn_fs_x__hotcopy_prepare_target,
   svn_fs_x__hotcopy): Same.

Modified:
    subversion/trunk/subversion/libsvn_fs_x/hotcopy.c
    subversion/trunk/subversion/libsvn_fs_x/hotcopy.h

Modified: subversion/trunk/subversion/libsvn_fs_x/hotcopy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/hotcopy.c?rev=1650843&r1=1650842&r2=1650843&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/hotcopy.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/hotcopy.c Sun Jan 11 01:09:52 2015
@@ -125,7 +125,7 @@ hotcopy_io_copy_dir_recursively(svn_bool
                                 svn_boolean_t copy_perms,
                                 svn_cancel_func_t cancel_func,
                                 void *cancel_baton,
-                                apr_pool_t *pool)
+                                apr_pool_t *scratch_pool)
 {
   svn_node_kind_t kind;
   apr_status_t status;
@@ -135,10 +135,10 @@ hotcopy_io_copy_dir_recursively(svn_bool
   apr_int32_t flags = APR_FINFO_TYPE | APR_FINFO_NAME;
 
   /* Make a subpool for recursion */
-  apr_pool_t *subpool = svn_pool_create(pool);
+  apr_pool_t *subpool = svn_pool_create(scratch_pool);
 
   /* The 'dst_path' is simply dst_parent/dst_basename */
-  dst_path = svn_dirent_join(dst_parent, dst_basename, pool);
+  dst_path = svn_dirent_join(dst_parent, dst_basename, scratch_pool);
 
   /* Sanity checks:  SRC and DST_PARENT are directories, and
      DST_BASENAME doesn't already exist in DST_PARENT. */
@@ -146,19 +146,20 @@ hotcopy_io_copy_dir_recursively(svn_bool
   if (kind != svn_node_dir)
     return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
                              _("Source '%s' is not a directory"),
-                             svn_dirent_local_style(src, pool));
+                             svn_dirent_local_style(src, scratch_pool));
 
   SVN_ERR(svn_io_check_path(dst_parent, &kind, subpool));
   if (kind != svn_node_dir)
     return svn_error_createf(SVN_ERR_NODE_UNEXPECTED_KIND, NULL,
                              _("Destination '%s' is not a directory"),
-                             svn_dirent_local_style(dst_parent, pool));
+                             svn_dirent_local_style(dst_parent,
+                                                    scratch_pool));
 
   SVN_ERR(svn_io_check_path(dst_path, &kind, subpool));
 
   /* Create the new directory. */
   /* ### TODO: copy permissions (needs apr_file_attrs_get()) */
-  SVN_ERR(svn_io_make_dir_recursively(dst_path, pool));
+  SVN_ERR(svn_io_make_dir_recursively(dst_path, scratch_pool));
 
   /* Loop over the dirents in SRC.  ('.' and '..' are auto-excluded) */
   SVN_ERR(svn_io_dir_open(&this_dir, src, subpool));
@@ -225,12 +226,12 @@ hotcopy_io_copy_dir_recursively(svn_bool
 
   if (! (APR_STATUS_IS_ENOENT(status)))
     return svn_error_wrap_apr(status, _("Can't read directory '%s'"),
-                              svn_dirent_local_style(src, pool));
+                              svn_dirent_local_style(src, scratch_pool));
 
   status = apr_dir_close(this_dir);
   if (status)
     return svn_error_wrap_apr(status, _("Error closing directory '%s'"),
-                              svn_dirent_local_style(src, pool));
+                              svn_dirent_local_style(src, scratch_pool));
 
   /* Free any memory used by recursion */
   svn_pool_destroy(subpool);
@@ -366,14 +367,14 @@ hotcopy_copy_packed_shard(svn_boolean_t
 }
 
 /* Remove file PATH, if it exists - even if it is read-only. 
- * Use POOL for temporary allocations. */
+ * Use SCRATCH_POOL for temporary allocations. */
 static svn_error_t *
 hotcopy_remove_file(const char *path,
-                    apr_pool_t *pool)
+                    apr_pool_t *scratch_pool)
 {
   /* Make the rev file writable and remove it. */
-  SVN_ERR(svn_io_set_file_read_write(path, TRUE, pool));
-  SVN_ERR(svn_io_remove_file2(path, TRUE, pool));
+  SVN_ERR(svn_io_set_file_read_write(path, TRUE, scratch_pool));
+  SVN_ERR(svn_io_remove_file2(path, TRUE, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -508,16 +509,17 @@ hotcopy_incremental_check_preconditions(
 
 /* Remove folder PATH.  Ignore errors due to the sub-tree not being empty.
  * CANCEL_FUNC and CANCEL_BATON do the usual thing.
- * Use POOL for temporary allocations.
+ * Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
 remove_folder(const char *path,
               svn_cancel_func_t cancel_func,
               void *cancel_baton,
-              apr_pool_t *pool)
+              apr_pool_t *scratch_pool)
 {
   svn_error_t *err = svn_io_remove_dir2(path, TRUE,
-                                        cancel_func, cancel_baton, pool);
+                                        cancel_func, cancel_baton,
+                                        scratch_pool);
 
   if (err && APR_STATUS_IS_ENOTEMPTY(err->apr_err))
     {
@@ -534,7 +536,7 @@ remove_folder(const char *path,
  * for every shard by updating the 'current' file if necessary.  Assume
  * the >= SVN_FS_FS__MIN_NO_GLOBAL_IDS_FORMAT filesystem format without
  * global next-ID counters.  Indicate progress via the optional NOTIFY_FUNC
- * callback using NOTIFY_BATON.  Use POOL for temporary allocations.
+ * callback using NOTIFY_BATON.  Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
 hotcopy_revisions(svn_fs_t *src_fs,
@@ -550,7 +552,7 @@ hotcopy_revisions(svn_fs_t *src_fs,
                   void* notify_baton,
                   svn_cancel_func_t cancel_func,
                   void* cancel_baton,
-                  apr_pool_t *pool)
+                  apr_pool_t *scratch_pool)
 {
   svn_fs_x__data_t *src_ffd = src_fs->fsap_data;
   int max_files_per_dir = src_ffd->max_files_per_dir;
@@ -561,9 +563,9 @@ hotcopy_revisions(svn_fs_t *src_fs,
 
   /* Copy the min unpacked rev, and read its value. */
   SVN_ERR(svn_fs_x__read_min_unpacked_rev(&src_min_unpacked_rev, src_fs,
-                                          pool));
+                                          scratch_pool));
   SVN_ERR(svn_fs_x__read_min_unpacked_rev(&dst_min_unpacked_rev, dst_fs,
-                                          pool));
+                                          scratch_pool));
 
   /* We only support packs coming from the hotcopy source.
     * The destination should not be packed independently from
@@ -578,7 +580,7 @@ hotcopy_revisions(svn_fs_t *src_fs,
                              src_min_unpacked_rev - 1);
 
   SVN_ERR(svn_io_dir_file_copy(src_fs->path, dst_fs->path,
-                               PATH_MIN_UNPACKED_REV, pool));
+                               PATH_MIN_UNPACKED_REV, scratch_pool));
 
   if (cancel_func)
     SVN_ERR(cancel_func(cancel_baton));
@@ -587,7 +589,7 @@ hotcopy_revisions(svn_fs_t *src_fs,
    * Copy the necessary rev files.
    */
 
-  iterpool = svn_pool_create(pool);
+  iterpool = svn_pool_create(scratch_pool);
   /* First, copy packed shards. */
   for (rev = 0; rev < src_min_unpacked_rev; rev += max_files_per_dir)
     {
@@ -738,7 +740,8 @@ struct hotcopy_body_baton {
  * write-lock is held.
  */
 static svn_error_t *
-hotcopy_body(void *baton, apr_pool_t *pool)
+hotcopy_body(void *baton,
+             apr_pool_t *scratch_pool)
 {
   struct hotcopy_body_baton *hbb = baton;
   svn_fs_t *src_fs = hbb->src_fs;
@@ -765,7 +768,7 @@ hotcopy_body(void *baton, apr_pool_t *po
    * ### an error from this function, and that renders the hotcopy
    * ### unusable anyway. */
   SVN_ERR(svn_io_dir_file_copy(src_fs->path, dst_fs->path, PATH_CONFIG,
-                               pool));
+                               scratch_pool));
 
   if (cancel_func)
     SVN_ERR(cancel_func(cancel_baton));
@@ -775,10 +778,10 @@ hotcopy_body(void *baton, apr_pool_t *po
    * of revisions than the destination.
    * This also catches the case where users accidentally swap the
    * source and destination arguments. */
-  SVN_ERR(svn_fs_x__read_current(&src_youngest, src_fs, pool));
+  SVN_ERR(svn_fs_x__read_current(&src_youngest, src_fs, scratch_pool));
   if (incremental)
     {
-      SVN_ERR(svn_fs_x__youngest_rev(&dst_youngest, dst_fs, pool));
+      SVN_ERR(svn_fs_x__youngest_rev(&dst_youngest, dst_fs, scratch_pool));
       if (src_youngest < dst_youngest)
         return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
                  _("The hotcopy destination already contains more revisions "
@@ -789,15 +792,17 @@ hotcopy_body(void *baton, apr_pool_t *po
   else
     dst_youngest = 0;
 
-  src_revs_dir = svn_dirent_join(src_fs->path, PATH_REVS_DIR, pool);
-  dst_revs_dir = svn_dirent_join(dst_fs->path, PATH_REVS_DIR, pool);
-  src_revprops_dir = svn_dirent_join(src_fs->path, PATH_REVPROPS_DIR, pool);
-  dst_revprops_dir = svn_dirent_join(dst_fs->path, PATH_REVPROPS_DIR, pool);
+  src_revs_dir = svn_dirent_join(src_fs->path, PATH_REVS_DIR, scratch_pool);
+  dst_revs_dir = svn_dirent_join(dst_fs->path, PATH_REVS_DIR, scratch_pool);
+  src_revprops_dir = svn_dirent_join(src_fs->path, PATH_REVPROPS_DIR,
+                                     scratch_pool);
+  dst_revprops_dir = svn_dirent_join(dst_fs->path, PATH_REVPROPS_DIR,
+                                     scratch_pool);
 
   /* Ensure that the required folders exist in the destination
    * before actually copying the revisions and revprops. */
-  SVN_ERR(svn_io_make_dir_recursively(dst_revs_dir, pool));
-  SVN_ERR(svn_io_make_dir_recursively(dst_revprops_dir, pool));
+  SVN_ERR(svn_io_make_dir_recursively(dst_revs_dir, scratch_pool));
+  SVN_ERR(svn_io_make_dir_recursively(dst_revprops_dir, scratch_pool));
 
   if (cancel_func)
     SVN_ERR(cancel_func(cancel_baton));
@@ -810,30 +815,33 @@ hotcopy_body(void *baton, apr_pool_t *po
                             incremental, src_revs_dir, dst_revs_dir,
                             src_revprops_dir, dst_revprops_dir,
                             notify_func, notify_baton,
-                            cancel_func, cancel_baton, pool));
-  SVN_ERR(svn_fs_x__write_current(dst_fs, src_youngest, pool));
+                            cancel_func, cancel_baton, scratch_pool));
+  SVN_ERR(svn_fs_x__write_current(dst_fs, src_youngest, scratch_pool));
 
   /* Replace the locks tree.
    * This is racy in case readers are currently trying to list locks in
    * the destination. However, we need to get rid of stale locks.
    * This is the simplest way of doing this, so we accept this small race. */
-  dst_subdir = svn_dirent_join(dst_fs->path, PATH_LOCKS_DIR, pool);
+  dst_subdir = svn_dirent_join(dst_fs->path, PATH_LOCKS_DIR, scratch_pool);
   SVN_ERR(svn_io_remove_dir2(dst_subdir, TRUE, cancel_func, cancel_baton,
-                             pool));
-  src_subdir = svn_dirent_join(src_fs->path, PATH_LOCKS_DIR, pool);
-  SVN_ERR(svn_io_check_path(src_subdir, &kind, pool));
+                             scratch_pool));
+  src_subdir = svn_dirent_join(src_fs->path, PATH_LOCKS_DIR, scratch_pool);
+  SVN_ERR(svn_io_check_path(src_subdir, &kind, scratch_pool));
   if (kind == svn_node_dir)
     SVN_ERR(svn_io_copy_dir_recursively(src_subdir, dst_fs->path,
                                         PATH_LOCKS_DIR, TRUE,
-                                        cancel_func, cancel_baton, pool));
+                                        cancel_func, cancel_baton,
+                                        scratch_pool));
 
   /* Now copy the node-origins cache tree. */
-  src_subdir = svn_dirent_join(src_fs->path, PATH_NODE_ORIGINS_DIR, pool);
-  SVN_ERR(svn_io_check_path(src_subdir, &kind, pool));
+  src_subdir = svn_dirent_join(src_fs->path, PATH_NODE_ORIGINS_DIR,
+                               scratch_pool);
+  SVN_ERR(svn_io_check_path(src_subdir, &kind, scratch_pool));
   if (kind == svn_node_dir)
     SVN_ERR(hotcopy_io_copy_dir_recursively(NULL, src_subdir, dst_fs->path,
                                             PATH_NODE_ORIGINS_DIR, TRUE,
-                                            cancel_func, cancel_baton, pool));
+                                            cancel_func, cancel_baton,
+                                            scratch_pool));
 
   /*
    * NB: Data copied below is only read by writers, not readers.
@@ -842,26 +850,27 @@ hotcopy_body(void *baton, apr_pool_t *po
 
   /* Copy the rep cache and then remove entries for revisions
    * younger than the destination's youngest revision. */
-  src_subdir = svn_dirent_join(src_fs->path, REP_CACHE_DB_NAME, pool);
-  dst_subdir = svn_dirent_join(dst_fs->path, REP_CACHE_DB_NAME, pool);
-  SVN_ERR(svn_io_check_path(src_subdir, &kind, pool));
+  src_subdir = svn_dirent_join(src_fs->path, REP_CACHE_DB_NAME, scratch_pool);
+  dst_subdir = svn_dirent_join(dst_fs->path, REP_CACHE_DB_NAME, scratch_pool);
+  SVN_ERR(svn_io_check_path(src_subdir, &kind, scratch_pool));
   if (kind == svn_node_file)
     {
       /* Copy the rep cache and then remove entries for revisions
        * that did not make it into the destination. */
-      SVN_ERR(svn_sqlite__hotcopy(src_subdir, dst_subdir, pool));
-      SVN_ERR(svn_fs_x__del_rep_reference(dst_fs, src_youngest, pool));
+      SVN_ERR(svn_sqlite__hotcopy(src_subdir, dst_subdir, scratch_pool));
+      SVN_ERR(svn_fs_x__del_rep_reference(dst_fs, src_youngest,
+                                          scratch_pool));
     }
 
   /* Copy the txn-current file. */
   SVN_ERR(svn_io_dir_file_copy(src_fs->path, dst_fs->path,
-                                PATH_TXN_CURRENT, pool));
+                                PATH_TXN_CURRENT, scratch_pool));
 
   /* If a revprop generation file exists in the source filesystem,
    * reset it to zero (since this is on a different path, it will not
    * overlap with data already in cache).  Also, clean up stale files
    * used for the named atomics implementation. */
-  SVN_ERR(svn_fs_x__reset_revprop_generation_file(dst_fs, pool));
+  SVN_ERR(svn_fs_x__reset_revprop_generation_file(dst_fs, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -870,12 +879,13 @@ hotcopy_body(void *baton, apr_pool_t *po
  * locks.
  */
 static svn_error_t *
-hotcopy_locking_src_body(void *baton, apr_pool_t *pool)
+hotcopy_locking_src_body(void *baton,
+                         apr_pool_t *scratch_pool)
 {
   struct hotcopy_body_baton *hbb = baton;
 
   return svn_error_trace(svn_fs_x__with_pack_lock(hbb->src_fs, hotcopy_body,
-                                                  baton, pool));
+                                                  baton, scratch_pool));
 }
 
 /* Create an empty filesystem at DST_FS at DST_PATH with the same
@@ -885,27 +895,30 @@ static svn_error_t *
 hotcopy_create_empty_dest(svn_fs_t *src_fs,
                           svn_fs_t *dst_fs,
                           const char *dst_path,
-                          apr_pool_t *pool)
+                          apr_pool_t *scratch_pool)
 {
   svn_fs_x__data_t *src_ffd = src_fs->fsap_data;
 
   /* Create the DST_FS repository with the same layout as SRC_FS. */
   SVN_ERR(svn_fs_x__create_file_tree(dst_fs, dst_path, src_ffd->format,
-                                     src_ffd->max_files_per_dir, pool));
+                                     src_ffd->max_files_per_dir,
+                                     scratch_pool));
 
   /* Copy the UUID.  Hotcopy destination receives a new instance ID, but
    * has the same filesystem UUID as the source. */
-  SVN_ERR(svn_fs_x__set_uuid(dst_fs, src_fs->uuid, NULL, pool));
+  SVN_ERR(svn_fs_x__set_uuid(dst_fs, src_fs->uuid, NULL, scratch_pool));
 
   /* Remove revision 0 contents.  Otherwise, it may not get overwritten
    * due to having a newer timestamp. */
-  SVN_ERR(hotcopy_remove_file(svn_fs_x__path_rev(dst_fs, 0, pool), pool));
-  SVN_ERR(hotcopy_remove_file(svn_fs_x__path_revprops(dst_fs, 0, pool),
-                              pool));
+  SVN_ERR(hotcopy_remove_file(svn_fs_x__path_rev(dst_fs, 0, scratch_pool),
+                              scratch_pool));
+  SVN_ERR(hotcopy_remove_file(svn_fs_x__path_revprops(dst_fs, 0,
+                                                      scratch_pool),
+                              scratch_pool));
 
   /* This filesystem is ready.  Stamp it with a format number.  Fail if
    * the 'format' file should already exist. */
-  SVN_ERR(svn_fs_x__write_format(dst_fs, FALSE, pool));
+  SVN_ERR(svn_fs_x__write_format(dst_fs, FALSE, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -915,7 +928,7 @@ svn_fs_x__hotcopy_prepare_target(svn_fs_
                                  svn_fs_t *dst_fs,
                                  const char *dst_path,
                                  svn_boolean_t incremental,
-                                 apr_pool_t *pool)
+                                 apr_pool_t *scratch_pool)
 {
   if (incremental)
     {
@@ -924,27 +937,31 @@ svn_fs_x__hotcopy_prepare_target(svn_fs_
 
       /* Check destination format to be sure we know how to incrementally
        * hotcopy to the destination FS. */
-      dst_format_abspath = svn_dirent_join(dst_path, PATH_FORMAT, pool);
-      SVN_ERR(svn_io_check_path(dst_format_abspath, &dst_format_kind, pool));
+      dst_format_abspath = svn_dirent_join(dst_path, PATH_FORMAT,
+                                           scratch_pool);
+      SVN_ERR(svn_io_check_path(dst_format_abspath, &dst_format_kind,
+                                scratch_pool));
       if (dst_format_kind == svn_node_none)
         {
           /* Destination doesn't exist yet. Perform a normal hotcopy to a
            * empty destination using the same configuration as the source. */
-          SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path, pool));
+          SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path,
+                                            scratch_pool));
         }
       else
         {
           /* Check the existing repository. */
-          SVN_ERR(svn_fs_x__open(dst_fs, dst_path, pool));
+          SVN_ERR(svn_fs_x__open(dst_fs, dst_path, scratch_pool));
           SVN_ERR(hotcopy_incremental_check_preconditions(src_fs, dst_fs,
-                                                          pool));
+                                                          scratch_pool));
         }
     }
   else
     {
       /* Start out with an empty destination using the same configuration
        * as the source. */
-      SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path, pool));
+      SVN_ERR(hotcopy_create_empty_dest(src_fs, dst_fs, dst_path,
+                                        scratch_pool));
     }
 
   return SVN_NO_ERROR;
@@ -958,7 +975,7 @@ svn_fs_x__hotcopy(svn_fs_t *src_fs,
                   void *notify_baton,
                   svn_cancel_func_t cancel_func,
                   void *cancel_baton,
-                  apr_pool_t *pool)
+                  apr_pool_t *scratch_pool)
 {
   struct hotcopy_body_baton hbb;
 
@@ -970,7 +987,7 @@ svn_fs_x__hotcopy(svn_fs_t *src_fs,
   hbb.cancel_func = cancel_func;
   hbb.cancel_baton = cancel_baton;
   SVN_ERR(svn_fs_x__with_all_locks(dst_fs, hotcopy_locking_src_body, &hbb,
-                                   pool));
+                                   scratch_pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_fs_x/hotcopy.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/hotcopy.h?rev=1650843&r1=1650842&r2=1650843&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/hotcopy.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/hotcopy.h Sun Jan 11 01:09:52 2015
@@ -27,19 +27,20 @@
 
 /* Create an empty copy of the fsfs filesystem SRC_FS into a new DST_FS at
  * DST_PATH.  If INCREMENTAL is TRUE, perform a few pre-checks only if
- * a repo already exists at DST_PATH. Use POOL for temporary allocations. */
+ * a repo already exists at DST_PATH.
+ * Use SCRATCH_POOL for temporary allocations. */
 svn_error_t *
 svn_fs_x__hotcopy_prepare_target(svn_fs_t *src_fs,
                                  svn_fs_t *dst_fs,
                                  const char *dst_path,
                                  svn_boolean_t incremental,
-                                 apr_pool_t *pool);
+                                 apr_pool_t *scratch_pool);
 
 /* Copy the fsfs filesystem SRC_FS into DST_FS. If INCREMENTAL is TRUE, do
  * not re-copy data which already exists in DST_FS.  Indicate progress via
- * the optional NOTIFY_FUNC callback using NOTIFY_BATON.  Use POOL for
- * temporary allocations. */
-svn_error_t *
+ * the optional NOTIFY_FUNC callback using NOTIFY_BATON.
+ * Use SCRATCH_POOL for temporary allocations. */
+svn_error_t * 
 svn_fs_x__hotcopy(svn_fs_t *src_fs,
                   svn_fs_t *dst_fs,
                   svn_boolean_t incremental,
@@ -47,6 +48,6 @@ svn_fs_x__hotcopy(svn_fs_t *src_fs,
                   void *notify_baton,
                   svn_cancel_func_t cancel_func,
                   void *cancel_baton,
-                  apr_pool_t *pool);
+                  apr_pool_t *scratch_pool);
 
 #endif