subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1512338 - /subversion/branches/log-addressing/subversion/libsvn_fs_fs/hotcopy.c
Date Fri, 09 Aug 2013 15:21:35 GMT
Author: stefan2
Date: Fri Aug  9 15:21:35 2013
New Revision: 1512338

URL: http://svn.apache.org/r1512338
Log:
On the log-addressing branch:  Make FSFS hotcopy handle logically
addressed shards.  The key here is to simply copy / clean up the
index files whenever we do the same to a rev / pack file.

* subversion/libsvn_fs_fs/hotcopy.c
  (hotcopy_copy_shard_file): copy indexes as well if quested by
                             the caller
  (hotcopy_copy_packed_shard): revprops don't have index files
  (hotcopy_remove_file): factor out utility from hotcopy_remove_files
  (hotcopy_remove_files): clean up index files upon request
  (hotcopy_remove_rev_files,
   hotcopy_remove_revprop_files,
   hotcopy_body): update callers

Modified:
    subversion/branches/log-addressing/subversion/libsvn_fs_fs/hotcopy.c

Modified: subversion/branches/log-addressing/subversion/libsvn_fs_fs/hotcopy.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_fs_fs/hotcopy.c?rev=1512338&r1=1512337&r2=1512338&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_fs/hotcopy.c (original)
+++ subversion/branches/log-addressing/subversion/libsvn_fs_fs/hotcopy.c Fri Aug  9 15:21:35
2013
@@ -228,12 +228,14 @@ hotcopy_io_copy_dir_recursively(const ch
 
 /* Copy an un-packed revision or revprop file for revision REV from SRC_SUBDIR
  * to DST_SUBDIR. Assume a sharding layout based on MAX_FILES_PER_DIR.
+ * If INCLUDE_INDEXES is set, copy rev index files as well.
  * Use SCRATCH_POOL for temporary allocations. */
 static svn_error_t *
 hotcopy_copy_shard_file(const char *src_subdir,
                         const char *dst_subdir,
                         svn_revnum_t rev,
                         int max_files_per_dir,
+                        svn_boolean_t include_indexes,
                         apr_pool_t *scratch_pool)
 {
   const char *src_subdir_shard = src_subdir,
@@ -257,6 +259,19 @@ hotcopy_copy_shard_file(const char *src_
   SVN_ERR(hotcopy_io_dir_file_copy(src_subdir_shard, dst_subdir_shard,
                                    apr_psprintf(scratch_pool, "%ld", rev),
                                    scratch_pool));
+
+  if (include_indexes)
+    {
+      SVN_ERR(hotcopy_io_dir_file_copy(src_subdir_shard, dst_subdir_shard,
+                                       apr_psprintf(scratch_pool, "%ld.l2p",
+                                                    rev),
+                                       scratch_pool));
+      SVN_ERR(hotcopy_io_dir_file_copy(src_subdir_shard, dst_subdir_shard,
+                                       apr_psprintf(scratch_pool, "%ld.p2l",
+                                                    rev),
+                                       scratch_pool));
+    }
+
   return SVN_NO_ERROR;
 }
 
@@ -312,7 +327,7 @@ hotcopy_copy_packed_shard(svn_revnum_t *
 
           SVN_ERR(hotcopy_copy_shard_file(src_subdir, dst_subdir,
                                           revprop_rev, max_files_per_dir,
-                                          iterpool));
+                                          FALSE, iterpool));
         }
       svn_pool_destroy(iterpool);
     }
@@ -321,7 +336,7 @@ hotcopy_copy_packed_shard(svn_revnum_t *
       /* revprop for revision 0 will never be packed */
       if (rev == 0)
         SVN_ERR(hotcopy_copy_shard_file(src_subdir, dst_subdir,
-                                        0, max_files_per_dir,
+                                        0, max_files_per_dir, FALSE,
                                         scratch_pool));
 
       /* packed revprops folder */
@@ -379,17 +394,33 @@ hotcopy_update_current(svn_revnum_t *dst
   return SVN_NO_ERROR;
 }
 
+/* Remove FILE in SHARD folder.  Use POOL for temporary allocations. */
+static svn_error_t *
+hotcopy_remove_file(const char *shard,
+                    const char *file,
+                    apr_pool_t *pool)
+{
+  const char *rev_path = svn_dirent_join(shard, file, pool);
+
+  /* Make the rev file writable and remove it. */
+  SVN_ERR(svn_io_set_file_read_write(rev_path, TRUE, pool));
+  SVN_ERR(svn_io_remove_file2(rev_path, TRUE, pool));
+
+  return SVN_NO_ERROR;
+}
+
 
 /* Remove revision or revprop files between START_REV (inclusive) and
- * END_REV (non-inclusive) from folder DST_SUBDIR in DST_FS.  Assume
- * sharding as per MAX_FILES_PER_DIR.
- * Use SCRATCH_POOL for temporary allocations. */
+ * END_REV (non-inclusive) from folder DST_SUBDIR in DST_FS.  Also,
+ * remove index files if REMOVE_INDEXES is set.  Assume sharding as per
+ * MAX_FILES_PER_DIR.  Use SCRATCH_POOL for temporary allocations. */
 static svn_error_t *
 hotcopy_remove_files(svn_fs_t *dst_fs,
                      const char *dst_subdir,
                      svn_revnum_t start_rev,
                      svn_revnum_t end_rev,
                      int max_files_per_dir,
+                     svn_boolean_t remove_indexes,
                      apr_pool_t *scratch_pool)
 {
   const char *shard;
@@ -404,7 +435,6 @@ hotcopy_remove_files(svn_fs_t *dst_fs,
   iterpool = svn_pool_create(scratch_pool);
   for (rev = start_rev; rev < end_rev; rev++)
     {
-      const char *path;
       svn_pool_clear(iterpool);
 
       /* If necessary, update paths for shard. */
@@ -415,13 +445,18 @@ hotcopy_remove_files(svn_fs_t *dst_fs,
         }
 
       /* remove files for REV */
-      path = svn_dirent_join(dst_subdir_shard,
-                             apr_psprintf(iterpool, "%ld", rev),
-                             iterpool);
-
-      /* Make the rev file writable and remove it. */
-      SVN_ERR(svn_io_set_file_read_write(path, TRUE, iterpool));
-      SVN_ERR(svn_io_remove_file2(path, TRUE, iterpool));
+      SVN_ERR(hotcopy_remove_file(dst_subdir_shard,
+                                  apr_psprintf(iterpool, "%ld", rev),
+                                  iterpool));
+      if (remove_indexes && svn_fs_fs__use_log_addressing(dst_fs, rev))
+        {
+          SVN_ERR(hotcopy_remove_file(dst_subdir_shard,
+                                      apr_psprintf(iterpool, "%ld.p2l", rev),
+                                      iterpool));
+          SVN_ERR(hotcopy_remove_file(dst_subdir_shard,
+                                      apr_psprintf(iterpool, "%ld.l2p", rev),
+                                      iterpool));
+        }
     }
 
   svn_pool_destroy(iterpool);
@@ -445,7 +480,7 @@ hotcopy_remove_rev_files(svn_fs_t *dst_f
                                                PATH_REVS_DIR,
                                                scratch_pool),
                                start_rev, end_rev,
-                               max_files_per_dir, scratch_pool));
+                               max_files_per_dir, TRUE, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -469,7 +504,7 @@ hotcopy_remove_revprop_files(svn_fs_t *d
                                                PATH_REVPROPS_DIR,
                                                scratch_pool),
                                start_rev ? start_rev : 1, end_rev,
-                               max_files_per_dir, scratch_pool));
+                               max_files_per_dir, FALSE, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -770,6 +805,7 @@ hotcopy_body(void *baton, apr_pool_t *po
       /* Copy the rev file. */
       err = hotcopy_copy_shard_file(src_subdir, dst_subdir,
                                     rev, max_files_per_dir,
+                                    svn_fs_fs__use_log_addressing(src_fs, rev),
                                     iterpool);
       if (err)
         {
@@ -820,7 +856,7 @@ hotcopy_body(void *baton, apr_pool_t *po
       /* Copy the revprop file. */
       SVN_ERR(hotcopy_copy_shard_file(revprop_src_subdir,
                                       revprop_dst_subdir,
-                                      rev, max_files_per_dir,
+                                      rev, max_files_per_dir, FALSE,
                                       iterpool));
 
       /* After completing a full shard, update 'current'. */



Mime
View raw message