subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1711377 - in /subversion/trunk/subversion: libsvn_fs_x/batch_fsync.c libsvn_fs_x/revprops.c libsvn_fs_x/transaction.c tests/libsvn_fs_x/fs-x-pack-test.c
Date Thu, 29 Oct 2015 23:04:11 GMT
Author: stefan2
Date: Thu Oct 29 23:04:10 2015
New Revision: 1711377

URL: http://svn.apache.org/viewvc?rev=1711377&view=rev
Log:
Make the batch fsync object in FSX easier to use:
When we create a new file through svn_fs_x__batch_fsync_open_file,
implicitly call svn_fs_x__batch_fsync_new_path if necessary.

* subversion/libsvn_fs_x/batch_fsync.c
  (internal_open_file): Test whether a new file will be created and
                        schedule any necessary additional fsyncs.

* subversion/libsvn_fs_x/revprops.c
  (svn_fs_x__pack_revprops_shard): Remove redundant call.

* subversion/libsvn_fs_x/transaction.c
  (write_final_revprop,
   write_next_file): Same.

* subversion/tests/libsvn_fs_x/fs-x-pack-test.c
  (test_batch_fsync): Same.

Modified:
    subversion/trunk/subversion/libsvn_fs_x/batch_fsync.c
    subversion/trunk/subversion/libsvn_fs_x/revprops.c
    subversion/trunk/subversion/libsvn_fs_x/transaction.c
    subversion/trunk/subversion/tests/libsvn_fs_x/fs-x-pack-test.c

Modified: subversion/trunk/subversion/libsvn_fs_x/batch_fsync.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/batch_fsync.c?rev=1711377&r1=1711376&r2=1711377&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/batch_fsync.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/batch_fsync.c Thu Oct 29 23:04:10 2015
@@ -327,6 +327,8 @@ internal_open_file(apr_file_t **file,
   svn_error_t *err;
   apr_pool_t *pool;
   to_sync_t *to_sync;
+  svn_node_kind_t kind;
+  svn_boolean_t is_new_file;
 
   /* If we already have a handle for PATH, return that. */
   to_sync = svn_hash_gets(batch->files, path);
@@ -336,9 +338,30 @@ internal_open_file(apr_file_t **file,
       return SVN_NO_ERROR;
     }
 
+  /* Calling fsync in PATH is going to be expensive in any case, so we can
+   * allow for some extra overhead figuring out whether the file already
+   * exists.  If it doesn't, be sure to schedule parent folder updates, if
+   * required on this platform.
+   *
+   * See svn_fs_x__batch_fsync_new_path() for when such extra fsyncs may be
+   * needed at all. */
+
+#ifdef SVN_ON_POSIX
+
+  is_new_file = FALSE;
+  if (flags & APR_CREATE)
+    {
+      /* We might actually be about to create a new file.
+       * Check whether the file already exists. */
+      SVN_ERR(svn_io_check_path(path, &kind, scratch_pool));
+      is_new_file = kind == svn_node_none;
+    }
+
+#endif
+
   /* To be able to process each file in a separate thread, they must use
    * separate, thread-safe pools.  Allocating a sub-pool from the standard
-   * thread-pool achieves exactly that. */
+   * memory pool achieves exactly that. */
   pool = svn_pool_create(NULL);
   err = svn_io_file_open(file, path, flags, APR_OS_DEFAULT, pool);
   if (err)
@@ -357,6 +380,16 @@ internal_open_file(apr_file_t **file,
                 apr_pstrdup(apr_hash_pool_get(batch->files), path),
                 to_sync);
 
+  /* If we just created a new file, schedule any additional necessary fsyncs.
+   * Note that this can only recurse once since the parent folder already
+   * exists on disk. */
+#ifdef SVN_ON_POSIX
+
+  if (is_new_file)
+    SVN_ERR(svn_fs_x__batch_fsync_new_path(batch, path, scratch_pool));
+
+#endif
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.c?rev=1711377&r1=1711376&r2=1711377&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.c Thu Oct 29 23:04:10 2015
@@ -1590,8 +1590,6 @@ svn_fs_x__pack_revprops_shard(svn_fs_t *
   /* Create the manifest file stream. */
   SVN_ERR(svn_fs_x__batch_fsync_open_file(&manifest_file, batch,
                                           manifest_file_path, scratch_pool));
-  SVN_ERR(svn_fs_x__batch_fsync_new_path(batch, manifest_file_path,
-                                         scratch_pool));
   manifest_stream = svn_stream_from_aprfile2(manifest_file, TRUE,
                                              scratch_pool);
 

Modified: subversion/trunk/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/transaction.c?rev=1711377&r1=1711376&r2=1711377&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/transaction.c Thu Oct 29 23:04:10 2015
@@ -3486,7 +3486,6 @@ write_final_revprop(const char **path,
   /* Create a file at the final revprops location. */
   *path = svn_fs_x__path_revprops(txn->fs, revision, result_pool);
   SVN_ERR(svn_fs_x__batch_fsync_open_file(&file, batch, *path, scratch_pool));
-  SVN_ERR(svn_fs_x__batch_fsync_new_path(batch, *path, scratch_pool));
 
   /* Write the new contents to the final revprops file. */
   stream = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
@@ -3651,7 +3650,6 @@ write_next_file(svn_fs_t *fs,
 
   /* Create / open the 'next' file. */
   SVN_ERR(svn_fs_x__batch_fsync_open_file(&file, batch, path, scratch_pool));
-  SVN_ERR(svn_fs_x__batch_fsync_new_path(batch, path, scratch_pool));
 
   /* Write its contents. */
   buf = apr_psprintf(scratch_pool, "%ld\n", revision);

Modified: subversion/trunk/subversion/tests/libsvn_fs_x/fs-x-pack-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs_x/fs-x-pack-test.c?rev=1711377&r1=1711376&r2=1711377&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs_x/fs-x-pack-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs_x/fs-x-pack-test.c Thu Oct 29 23:04:10 2015
@@ -888,7 +888,6 @@ test_batch_fsync(const svn_test_opts_t *
       apr_size_t len = strlen(path);
 
       SVN_ERR(svn_fs_x__batch_fsync_open_file(&file, batch, path, pool));
-      SVN_ERR(svn_fs_x__batch_fsync_new_path(batch, path, pool));
 
       SVN_ERR(svn_io_file_write(file, path, &len, pool));
     }
@@ -906,7 +905,6 @@ test_batch_fsync(const svn_test_opts_t *
       apr_size_t len = strlen(path);
 
       SVN_ERR(svn_fs_x__batch_fsync_open_file(&file, batch, path, pool));
-      SVN_ERR(svn_fs_x__batch_fsync_new_path(batch, path, pool));
 
       SVN_ERR(svn_io_file_write(file, path, &len, pool));
     }
@@ -923,7 +921,6 @@ test_batch_fsync(const svn_test_opts_t *
       apr_size_t len = strlen(path);
 
       SVN_ERR(svn_fs_x__batch_fsync_open_file(&file, batch, path, pool));
-      SVN_ERR(svn_fs_x__batch_fsync_new_path(batch, path, pool));
 
       SVN_ERR(svn_io_file_write(file, path, &len, pool));
     }



Mime
View raw message