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 21:22:31 UTC

svn commit: r1650960 [1/2] - in /subversion/trunk/subversion/libsvn_fs_x: transaction.c transaction.h

Author: stefan2
Date: Sun Jan 11 20:22:30 2015
New Revision: 1650960

URL: http://svn.apache.org/r1650960
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 transaction.* .

* subversion/libsvn_fs_x/transaction.c
  (with_lock_baton_t): The callback gets passed in a scratch pool.
  (with_lock,
   create_lock_baton,
   svn_fs_x__with_write_lock,
   svn_fs_x__with_pack_lock,
   svn_fs_x__with_txn_current_lock,
   svn_fs_x__with_all_locks,
   unlock_proto_rev_body,
   unlock_proto_rev,
   get_writable_proto_rev_body,
   auto_truncate_proto_rev,
   purge_shared_txn_body,
   purge_shared_txn,
   svn_fs_x__put_node_revision,
   unparse_dir_entry,
   unparse_dir_entries,
   create_new_txn_noderev_from_rev,
   get_and_increment_txn_key_body,
   svn_fs_x__create_txn,
   set_txn_proplist,
   svn_fs_x__change_txn_prop,
   svn_fs_x__change_txn_props,
   store_l2p_index_entry,
   store_p2l_index_entry,
   allocate_item_index,
   write_next_ids,
   read_next_ids,
   get_new_txn_node_id,
   svn_fs_x__reserve_copy_id,
   svn_fs_x__create_node,
   svn_fs_x__purge_txn,
   svn_fs_x__abort_txn,
   svn_fs_x__set_entry,
   svn_fs_x__add_change,
   shards_spanned,
   digests_final,
   svn_fs_x__create_successor,
   svn_fs_x__set_proplist): POOL is actually a SCRATCH_POOL.
  (collection_writer_t): The pool passed in is a scratch pool.
  (write_hash_to_stream,
   write_directory_to_stream,
   validate_root_noderev,
   write_final_rev,
   write_final_changed_path_info,
   verify_as_revision_before_current_plus_plus,
   verify_locks,
   svn_fs_x__add_index_data,
   commit_body,
   svn_fs_x__commit,
   svn_fs_x__delete_node_revision,
   svn_fs_x__get_base_rev): POOL is actually a SCRATCH_POOL.

* subversion/libsvn_fs_x/transaction.h
  (svn_fs_x__with_write_lock,
   svn_fs_x__with_pack_lock,
   svn_fs_x__with_txn_current_lock,
   svn_fs_x__with_all_locks,
   svn_fs_x__put_node_revision,
   svn_fs_x__txn_changes_fetch,
   svn_fs_x__change_txn_prop,
   svn_fs_x__change_txn_props,
   svn_fs_x__reserve_copy_id,
   svn_fs_x__create_node,
   svn_fs_x__purge_txn,
   svn_fs_x__abort_txn,
   svn_fs_x__set_entry,
   svn_fs_x__add_change,
   svn_fs_x__create_successor,
   svn_fs_x__set_proplist,
   svn_fs_x__add_index_data,
   svn_fs_x__commit,
   svn_fs_x__delete_node_revision,
   svn_fs_x__get_base_rev): Same.

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

Modified: subversion/trunk/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/transaction.c?rev=1650960&r1=1650959&r2=1650960&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/transaction.c Sun Jan 11 20:22:30 2015
@@ -233,7 +233,7 @@ typedef struct with_lock_baton_t
   /* Function body to execute after we acquired the lock.
      This may be user-provided or a nested call to with_lock(). */
   svn_error_t *(*body)(void *baton,
-                       apr_pool_t *pool);
+                       apr_pool_t *scratch_pool);
 
   /* Baton to pass to BODY; possibly NULL.
      This may be user-provided or a nested lock baton instance. */
@@ -299,11 +299,11 @@ with_some_lock_file(with_lock_baton_t *b
 
 /* Wraps with_some_lock_file, protecting it with BATON->MUTEX.
 
-   POOL is unused here and only provided for signature compatibility with
-   WITH_LOCK_BATON_T.BODY. */
+   SCRATCH_POOL is unused here and only provided for signature compatibility
+   with WITH_LOCK_BATON_T.BODY. */
 static svn_error_t *
 with_lock(void *baton,
-          apr_pool_t *pool)
+          apr_pool_t *scratch_pool)
 {
   with_lock_baton_t *lock_baton = baton;
   SVN_MUTEX__WITH_LOCK(lock_baton->mutex, with_some_lock_file(lock_baton));
@@ -361,7 +361,7 @@ static with_lock_baton_t *
 create_lock_baton(svn_fs_t *fs,
                   lock_id_t lock_id,
                   svn_error_t *(*body)(void *baton,
-                                       apr_pool_t *pool),
+                                       apr_pool_t *scratch_pool),
                   void *baton,
                   apr_pool_t *pool)
 {
@@ -428,56 +428,59 @@ chain_lock_baton(lock_id_t lock_id,
 svn_error_t *
 svn_fs_x__with_write_lock(svn_fs_t *fs,
                           svn_error_t *(*body)(void *baton,
-                                               apr_pool_t *pool),
+                                               apr_pool_t *scratch_pool),
                           void *baton,
-                          apr_pool_t *pool)
+                          apr_pool_t *scratch_pool)
 {
   return svn_error_trace(
-           with_lock(create_lock_baton(fs, write_lock, body, baton, pool),
-                     pool));
+           with_lock(create_lock_baton(fs, write_lock, body, baton,
+                                       scratch_pool),
+                     scratch_pool));
 }
 
 svn_error_t *
 svn_fs_x__with_pack_lock(svn_fs_t *fs,
                          svn_error_t *(*body)(void *baton,
-                                              apr_pool_t *pool),
+                                              apr_pool_t *scratch_pool),
                          void *baton,
-                         apr_pool_t *pool)
+                         apr_pool_t *scratch_pool)
 {
   return svn_error_trace(
-           with_lock(create_lock_baton(fs, pack_lock, body, baton, pool),
-                     pool));
+           with_lock(create_lock_baton(fs, pack_lock, body, baton,
+                                       scratch_pool),
+                     scratch_pool));
 }
 
 svn_error_t *
 svn_fs_x__with_txn_current_lock(svn_fs_t *fs,
                                 svn_error_t *(*body)(void *baton,
-                                                     apr_pool_t *pool),
+                                                     apr_pool_t *scratch_pool),
                                 void *baton,
-                                apr_pool_t *pool)
+                                apr_pool_t *scratch_pool)
 {
   return svn_error_trace(
-           with_lock(create_lock_baton(fs, txn_lock, body, baton, pool),
-                     pool));
+           with_lock(create_lock_baton(fs, txn_lock, body, baton,
+                                       scratch_pool),
+                     scratch_pool));
 }
 
 svn_error_t *
 svn_fs_x__with_all_locks(svn_fs_t *fs,
                          svn_error_t *(*body)(void *baton,
-                                              apr_pool_t *pool),
+                                              apr_pool_t *scratch_pool),
                          void *baton,
-                         apr_pool_t *pool)
+                         apr_pool_t *scratch_pool)
 {
   /* Be sure to use the correct lock ordering as documented in
      fs_fs_shared_data_t.  The lock chain is being created in 
      innermost (last to acquire) -> outermost (first to acquire) order. */
   with_lock_baton_t *lock_baton
-    = create_lock_baton(fs, write_lock, body, baton, pool);
+    = create_lock_baton(fs, write_lock, body, baton, scratch_pool);
 
   lock_baton = chain_lock_baton(pack_lock, lock_baton);
   lock_baton = chain_lock_baton(txn_lock, lock_baton);
 
-  return svn_error_trace(with_lock(lock_baton, pool));
+  return svn_error_trace(with_lock(lock_baton, scratch_pool));
 }
 
 
@@ -491,7 +494,9 @@ struct unlock_proto_rev_baton
 
 /* Callback used in the implementation of unlock_proto_rev(). */
 static svn_error_t *
-unlock_proto_rev_body(svn_fs_t *fs, const void *baton, apr_pool_t *pool)
+unlock_proto_rev_body(svn_fs_t *fs,
+                      const void *baton,
+                      apr_pool_t *scratch_pool)
 {
   const struct unlock_proto_rev_baton *b = baton;
   apr_file_t *lockfile = b->lockcookie;
@@ -501,24 +506,24 @@ unlock_proto_rev_body(svn_fs_t *fs, cons
   if (!txn)
     return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                              _("Can't unlock unknown transaction '%s'"),
-                             svn_fs_x__txn_name(b->txn_id, pool));
+                             svn_fs_x__txn_name(b->txn_id, scratch_pool));
   if (!txn->being_written)
     return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                              _("Can't unlock nonlocked transaction '%s'"),
-                             svn_fs_x__txn_name(b->txn_id, pool));
+                             svn_fs_x__txn_name(b->txn_id, scratch_pool));
 
   apr_err = apr_file_unlock(lockfile);
   if (apr_err)
     return svn_error_wrap_apr
       (apr_err,
        _("Can't unlock prototype revision lockfile for transaction '%s'"),
-       svn_fs_x__txn_name(b->txn_id, pool));
+       svn_fs_x__txn_name(b->txn_id, scratch_pool));
   apr_err = apr_file_close(lockfile);
   if (apr_err)
     return svn_error_wrap_apr
       (apr_err,
        _("Can't close prototype revision lockfile for transaction '%s'"),
-       svn_fs_x__txn_name(b->txn_id, pool));
+       svn_fs_x__txn_name(b->txn_id, scratch_pool));
 
   txn->being_written = FALSE;
 
@@ -529,18 +534,18 @@ unlock_proto_rev_body(svn_fs_t *fs, cons
    FS using cookie LOCKCOOKIE.  The original prototype revision file must
    have been closed _before_ calling this function.
 
-   Perform temporary allocations in POOL. */
+   Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 unlock_proto_rev(svn_fs_t *fs,
                  svn_fs_x__txn_id_t txn_id,
                  void *lockcookie,
-                 apr_pool_t *pool)
+                 apr_pool_t *scratch_pool)
 {
   struct unlock_proto_rev_baton b;
 
   b.txn_id = txn_id;
   b.lockcookie = lockcookie;
-  return with_txnlist_lock(fs, unlock_proto_rev_body, &b, pool);
+  return with_txnlist_lock(fs, unlock_proto_rev_body, &b, scratch_pool);
 }
 
 /* A structure used by get_writable_proto_rev() and
@@ -553,7 +558,9 @@ struct get_writable_proto_rev_baton
 
 /* Callback used in the implementation of get_writable_proto_rev(). */
 static svn_error_t *
-get_writable_proto_rev_body(svn_fs_t *fs, const void *baton, apr_pool_t *pool)
+get_writable_proto_rev_body(svn_fs_t *fs,
+                            const void *baton,
+                            apr_pool_t *scratch_pool)
 {
   const struct get_writable_proto_rev_baton *b = baton;
   void **lockcookie = b->lockcookie;
@@ -567,7 +574,7 @@ get_writable_proto_rev_body(svn_fs_t *fs
                                "of transaction '%s' because a previous "
                                "representation is currently being written by "
                                "this process"),
-                             svn_fs_x__txn_name(b->txn_id, pool));
+                             svn_fs_x__txn_name(b->txn_id, scratch_pool));
 
 
   /* We know that no thread in this process is writing to the proto-rev
@@ -580,7 +587,7 @@ get_writable_proto_rev_body(svn_fs_t *fs
     apr_file_t *lockfile;
     apr_status_t apr_err;
     const char *lockfile_path
-      = svn_fs_x__path_txn_proto_rev_lock(fs, b->txn_id, pool);
+      = svn_fs_x__path_txn_proto_rev_lock(fs, b->txn_id, scratch_pool);
 
     /* Open the proto-rev lockfile, creating it if necessary, as it may
        not exist if the transaction dates from before the lockfiles were
@@ -590,13 +597,14 @@ get_writable_proto_rev_body(svn_fs_t *fs
            that forces us to create a subpool just to be able to unlock
            the file, which seems a waste. */
     SVN_ERR(svn_io_file_open(&lockfile, lockfile_path,
-                             APR_WRITE | APR_CREATE, APR_OS_DEFAULT, pool));
+                             APR_WRITE | APR_CREATE, APR_OS_DEFAULT,
+                             scratch_pool));
 
     apr_err = apr_file_lock(lockfile,
                             APR_FLOCK_EXCLUSIVE | APR_FLOCK_NONBLOCK);
     if (apr_err)
       {
-        svn_error_clear(svn_io_file_close(lockfile, pool));
+        svn_error_clear(svn_io_file_close(lockfile, scratch_pool));
 
         if (APR_STATUS_IS_EAGAIN(apr_err))
           return svn_error_createf(SVN_ERR_FS_REP_BEING_WRITTEN, NULL,
@@ -604,11 +612,13 @@ get_writable_proto_rev_body(svn_fs_t *fs
                                      "file of transaction '%s' because a "
                                      "previous representation is currently "
                                      "being written by another process"),
-                                   svn_fs_x__txn_name(b->txn_id, pool));
+                                   svn_fs_x__txn_name(b->txn_id,
+                                                      scratch_pool));
 
         return svn_error_wrap_apr(apr_err,
                                   _("Can't get exclusive lock on file '%s'"),
-                                  svn_dirent_local_style(lockfile_path, pool));
+                                  svn_dirent_local_style(lockfile_path,
+                                                         scratch_pool));
       }
 
     *lockcookie = lockfile;
@@ -626,37 +636,37 @@ get_writable_proto_rev_body(svn_fs_t *fs
 
    If the prototype revision file is too short, we can't do much but bail out.
 
-   Perform all allocations in POOL. */
+   Perform all allocations in SCRATCH_POOL. */
 static svn_error_t *
 auto_truncate_proto_rev(svn_fs_t *fs,
                         apr_file_t *proto_rev,
                         apr_off_t actual_length,
                         svn_fs_x__txn_id_t txn_id,
-                        apr_pool_t *pool)
+                        apr_pool_t *scratch_pool)
 {
   /* Determine file range covered by the proto-index so far.  Note that
      we always append to both file, i.e. the last index entry also
      corresponds to the last addition in the rev file. */
-  const char *path = svn_fs_x__path_p2l_proto_index(fs, txn_id, pool);
+  const char *path = svn_fs_x__path_p2l_proto_index(fs, txn_id, scratch_pool);
   apr_file_t *file;
   apr_off_t indexed_length;
 
-  SVN_ERR(svn_fs_x__p2l_proto_index_open(&file, path, pool));
+  SVN_ERR(svn_fs_x__p2l_proto_index_open(&file, path, scratch_pool));
   SVN_ERR(svn_fs_x__p2l_proto_index_next_offset(&indexed_length, file,
-                                                pool));
-  SVN_ERR(svn_io_file_close(file, pool));
+                                                scratch_pool));
+  SVN_ERR(svn_io_file_close(file, scratch_pool));
 
   /* Handle mismatches. */
   if (indexed_length < actual_length)
-    SVN_ERR(svn_io_file_trunc(proto_rev, indexed_length, pool));
+    SVN_ERR(svn_io_file_trunc(proto_rev, indexed_length, scratch_pool));
   else if (indexed_length > actual_length)
     return svn_error_createf(SVN_ERR_FS_INDEX_INCONSISTENT,
                              NULL,
                              _("p2l proto index offset %s beyond proto"
                                "rev file size %s for TXN %s"),
-                             apr_off_t_toa(pool, indexed_length),
-                             apr_off_t_toa(pool, actual_length),
-                             svn_fs_x__txn_name(txn_id, pool));
+                             apr_off_t_toa(scratch_pool, indexed_length),
+                             apr_off_t_toa(scratch_pool, actual_length),
+                             svn_fs_x__txn_name(txn_id, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -724,7 +734,9 @@ get_writable_proto_rev(apr_file_t **file
 
 /* Callback used in the implementation of purge_shared_txn(). */
 static svn_error_t *
-purge_shared_txn_body(svn_fs_t *fs, const void *baton, apr_pool_t *pool)
+purge_shared_txn_body(svn_fs_t *fs,
+                      const void *baton,
+                      apr_pool_t *scratch_pool)
 {
   svn_fs_x__txn_id_t txn_id = *(const svn_fs_x__txn_id_t *)baton;
 
@@ -734,13 +746,13 @@ purge_shared_txn_body(svn_fs_t *fs, cons
 }
 
 /* Purge the shared data for transaction TXN_ID in filesystem FS.
-   Perform all allocations in POOL. */
+   Perform all temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 purge_shared_txn(svn_fs_t *fs,
                  svn_fs_x__txn_id_t txn_id,
-                 apr_pool_t *pool)
+                 apr_pool_t *scratch_pool)
 {
-  return with_txnlist_lock(fs, purge_shared_txn_body, &txn_id, pool);
+  return with_txnlist_lock(fs, purge_shared_txn_body, &txn_id, scratch_pool);
 }
 
 
@@ -748,7 +760,7 @@ svn_error_t *
 svn_fs_x__put_node_revision(svn_fs_t *fs,
                             svn_fs_x__noderev_t *noderev,
                             svn_boolean_t fresh_txn_root,
-                            apr_pool_t *pool)
+                            apr_pool_t *scratch_pool)
 {
   apr_file_t *noderev_file;
   const svn_fs_x__id_t *id = &noderev->noderev_id;
@@ -758,18 +770,18 @@ svn_fs_x__put_node_revision(svn_fs_t *fs
   if (! svn_fs_x__is_txn(id->change_set))
     return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                              _("Attempted to write to non-transaction '%s'"),
-                             svn_fs_x__id_unparse(id, pool)->data);
+                             svn_fs_x__id_unparse(id, scratch_pool)->data);
 
   SVN_ERR(svn_io_file_open(&noderev_file,
-                           svn_fs_x__path_txn_node_rev(fs, id, pool),
+                           svn_fs_x__path_txn_node_rev(fs, id, scratch_pool),
                            APR_WRITE | APR_CREATE | APR_TRUNCATE
-                           | APR_BUFFERED, APR_OS_DEFAULT, pool));
+                           | APR_BUFFERED, APR_OS_DEFAULT, scratch_pool));
 
   SVN_ERR(svn_fs_x__write_noderev(svn_stream_from_aprfile2(noderev_file, TRUE,
-                                                           pool),
-                                  noderev, pool));
+                                                           scratch_pool),
+                                  noderev, scratch_pool));
 
-  SVN_ERR(svn_io_file_close(noderev_file, pool));
+  SVN_ERR(svn_io_file_close(noderev_file, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -819,29 +831,29 @@ store_sha1_rep_mapping(svn_fs_t *fs,
 static svn_error_t *
 unparse_dir_entry(svn_fs_x__dirent_t *dirent,
                   svn_stream_t *stream,
-                  apr_pool_t *pool)
+                  apr_pool_t *scratch_pool)
 {
   const char *val
-    = apr_psprintf(pool, "%s %s",
+    = apr_psprintf(scratch_pool, "%s %s",
                    (dirent->kind == svn_node_file) ? SVN_FS_X__KIND_FILE
                                                    : SVN_FS_X__KIND_DIR,
-                   svn_fs_x__id_unparse(&dirent->id, pool)->data);
+                   svn_fs_x__id_unparse(&dirent->id, scratch_pool)->data);
 
-  SVN_ERR(svn_stream_printf(stream, pool, "K %" APR_SIZE_T_FMT "\n%s\n"
-                            "V %" APR_SIZE_T_FMT "\n%s\n",
+  SVN_ERR(svn_stream_printf(stream, scratch_pool, "K %" APR_SIZE_T_FMT
+                            "\n%s\nV %" APR_SIZE_T_FMT "\n%s\n",
                             strlen(dirent->name), dirent->name,
                             strlen(val), val));
   return SVN_NO_ERROR;
 }
 
 /* Write the directory given as array of dirent structs in ENTRIES to STREAM.
-   Perform temporary allocations in POOL. */
+   Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 unparse_dir_entries(apr_array_header_t *entries,
                     svn_stream_t *stream,
-                    apr_pool_t *pool)
+                    apr_pool_t *scratch_pool)
 {
-  apr_pool_t *iterpool = svn_pool_create(pool);
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   int i;
   for (i = 0; i < entries->nelts; ++i)
     {
@@ -852,7 +864,8 @@ unparse_dir_entries(apr_array_header_t *
       SVN_ERR(unparse_dir_entry(dirent, stream, iterpool));
     }
 
-  SVN_ERR(svn_stream_printf(stream, pool, "%s\n", SVN_HASH_TERMINATOR));
+  SVN_ERR(svn_stream_printf(stream, scratch_pool, "%s\n",
+                            SVN_HASH_TERMINATOR));
 
   svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
@@ -1124,15 +1137,16 @@ svn_fs_x__txn_changes_fetch(apr_hash_t *
 
 /* Copy a revision node-rev SRC into the current transaction TXN_ID in
    the filesystem FS.  This is only used to create the root of a transaction.
-   Allocations are from POOL.  */
+   Temporary allocations are from SCRATCH_POOL.  */
 static svn_error_t *
 create_new_txn_noderev_from_rev(svn_fs_t *fs,
                                 svn_fs_x__txn_id_t txn_id,
                                 svn_fs_x__id_t *src,
-                                apr_pool_t *pool)
+                                apr_pool_t *scratch_pool)
 {
   svn_fs_x__noderev_t *noderev;
-  SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, src, pool, pool));
+  SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, src, scratch_pool,
+                                      scratch_pool));
 
   /* This must be a root node. */
   SVN_ERR_ASSERT(   noderev->node_id.number == 0
@@ -1150,7 +1164,7 @@ create_new_txn_noderev_from_rev(svn_fs_t
   /* For the transaction root, the copyroot never changes. */
   svn_fs_x__init_txn_root(&noderev->noderev_id, txn_id);
 
-  return svn_fs_x__put_node_revision(fs, noderev, TRUE, pool);
+  return svn_fs_x__put_node_revision(fs, noderev, TRUE, scratch_pool);
 }
 
 /* A structure used by get_and_increment_txn_key_body(). */
@@ -1164,10 +1178,12 @@ struct get_and_increment_txn_key_baton {
    the current base 36 value in PATH_TXN_CURRENT and increments it.
    It returns the original value by the baton. */
 static svn_error_t *
-get_and_increment_txn_key_body(void *baton, apr_pool_t *pool)
+get_and_increment_txn_key_body(void *baton,
+                               apr_pool_t *scratch_pool)
 {
   struct get_and_increment_txn_key_baton *cb = baton;
-  const char *txn_current_filename = svn_fs_x__path_txn_current(cb->fs, pool);
+  const char *txn_current_filename = svn_fs_x__path_txn_current(cb->fs,
+                                                                scratch_pool);
   const char *tmp_filename;
   char new_id_str[SVN_INT64_BUFFER_SIZE];
 
@@ -1180,12 +1196,13 @@ get_and_increment_txn_key_body(void *bat
   /* Increment the key and add a trailing \n to the string so the
      txn-current file has a newline in it. */
   SVN_ERR(svn_io_write_unique(&tmp_filename,
-                              svn_dirent_dirname(txn_current_filename, pool),
+                              svn_dirent_dirname(txn_current_filename,
+                                                 scratch_pool),
                               new_id_str,
                               svn__ui64tobase36(new_id_str, cb->txn_number+1),
-                              svn_io_file_del_none, pool));
+                              svn_io_file_del_none, scratch_pool));
   SVN_ERR(svn_fs_x__move_into_place(tmp_filename, txn_current_filename,
-                                    txn_current_filename, pool));
+                                    txn_current_filename, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1297,29 +1314,31 @@ get_txn_proplist(apr_hash_t *proplist,
 }
 
 /* Save the property list PROPS as the revprops for transaction TXN_ID
-   in FS.  Perform temporary allocations in POOL. */
+   in FS.  Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 set_txn_proplist(svn_fs_t *fs,
                  svn_fs_x__txn_id_t txn_id,
                  apr_hash_t *props,
                  svn_boolean_t final,
-                 apr_pool_t *pool)
+                 apr_pool_t *scratch_pool)
 {
   svn_stringbuf_t *buf;
   svn_stream_t *stream;
 
   /* Write out the new file contents to BUF. */
-  buf = svn_stringbuf_create_ensure(1024, pool);
-  stream = svn_stream_from_stringbuf(buf, pool);
-  SVN_ERR(svn_hash_write2(props, stream, SVN_HASH_TERMINATOR, pool));
+  buf = svn_stringbuf_create_ensure(1024, scratch_pool);
+  stream = svn_stream_from_stringbuf(buf, scratch_pool);
+  SVN_ERR(svn_hash_write2(props, stream, SVN_HASH_TERMINATOR, scratch_pool));
   SVN_ERR(svn_stream_close(stream));
 
   /* Open the transaction properties file and write new contents to it. */
   SVN_ERR(svn_io_write_atomic((final 
-                               ? svn_fs_x__path_txn_props_final(fs, txn_id, pool)
-                               : svn_fs_x__path_txn_props(fs, txn_id, pool)),
+                               ? svn_fs_x__path_txn_props_final(fs, txn_id,
+                                                                scratch_pool)
+                               : svn_fs_x__path_txn_props(fs, txn_id,
+                                                          scratch_pool)),
                               buf->data, buf->len,
-                              NULL /* copy_perms_path */, pool));
+                              NULL /* copy_perms_path */, scratch_pool));
   return SVN_NO_ERROR;
 }
 
@@ -1328,29 +1347,30 @@ svn_error_t *
 svn_fs_x__change_txn_prop(svn_fs_txn_t *txn,
                           const char *name,
                           const svn_string_t *value,
-                          apr_pool_t *pool)
+                          apr_pool_t *scratch_pool)
 {
-  apr_array_header_t *props = apr_array_make(pool, 1, sizeof(svn_prop_t));
+  apr_array_header_t *props = apr_array_make(scratch_pool, 1,
+                                             sizeof(svn_prop_t));
   svn_prop_t prop;
 
   prop.name = name;
   prop.value = value;
   APR_ARRAY_PUSH(props, svn_prop_t) = prop;
 
-  return svn_fs_x__change_txn_props(txn, props, pool);
+  return svn_fs_x__change_txn_props(txn, props, scratch_pool);
 }
 
 svn_error_t *
 svn_fs_x__change_txn_props(svn_fs_txn_t *txn,
                            const apr_array_header_t *props,
-                           apr_pool_t *pool)
+                           apr_pool_t *scratch_pool)
 {
   fs_txn_data_t *ftd = txn->fsap_data;
-  apr_hash_t *txn_prop = apr_hash_make(pool);
+  apr_hash_t *txn_prop = apr_hash_make(scratch_pool);
   int i;
   svn_error_t *err;
 
-  err = get_txn_proplist(txn_prop, txn->fs, ftd->txn_id, pool);
+  err = get_txn_proplist(txn_prop, txn->fs, ftd->txn_id, scratch_pool);
   /* Here - and here only - we need to deal with the possibility that the
      transaction property file doesn't yet exist.  The rest of the
      implementation assumes that the file exists, but we're called to set the
@@ -1367,14 +1387,15 @@ svn_fs_x__change_txn_props(svn_fs_txn_t
       if (svn_hash_gets(txn_prop, SVN_FS__PROP_TXN_CLIENT_DATE)
           && !strcmp(prop->name, SVN_PROP_REVISION_DATE))
         svn_hash_sets(txn_prop, SVN_FS__PROP_TXN_CLIENT_DATE,
-                      svn_string_create("1", pool));
+                      svn_string_create("1", scratch_pool));
 
       svn_hash_sets(txn_prop, prop->name, prop->value);
     }
 
   /* Create a new version of the file and write out the new props. */
   /* Open the transaction properties file. */
-  SVN_ERR(set_txn_proplist(txn->fs, ftd->txn_id, txn_prop, FALSE, pool));
+  SVN_ERR(set_txn_proplist(txn->fs, ftd->txn_id, txn_prop, FALSE,
+                           scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1407,52 +1428,52 @@ svn_fs_x__get_txn(svn_fs_x__transaction_
 
 /* If it is supported by the format of file system FS, store the (ITEM_INDEX,
  * OFFSET) pair in the log-to-phys proto index file of transaction TXN_ID.
- * Use POOL for allocations.
+ * Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
 store_l2p_index_entry(svn_fs_t *fs,
                       svn_fs_x__txn_id_t txn_id,
                       apr_off_t offset,
                       apr_uint64_t item_index,
-                      apr_pool_t *pool)
+                      apr_pool_t *scratch_pool)
 {
-  const char *path = svn_fs_x__path_l2p_proto_index(fs, txn_id, pool);
+  const char *path = svn_fs_x__path_l2p_proto_index(fs, txn_id, scratch_pool);
   apr_file_t *file;
-  SVN_ERR(svn_fs_x__l2p_proto_index_open(&file, path, pool));
+  SVN_ERR(svn_fs_x__l2p_proto_index_open(&file, path, scratch_pool));
   SVN_ERR(svn_fs_x__l2p_proto_index_add_entry(file, offset, 0,
-                                              item_index, pool));
-  SVN_ERR(svn_io_file_close(file, pool));
+                                              item_index, scratch_pool));
+  SVN_ERR(svn_io_file_close(file, scratch_pool));
 
   return SVN_NO_ERROR;
 }
 
 /* If it is supported by the format of file system FS, store ENTRY in the
  * phys-to-log proto index file of transaction TXN_ID.
- * Use POOL for allocations.
+ * Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
 store_p2l_index_entry(svn_fs_t *fs,
                       svn_fs_x__txn_id_t txn_id,
                       svn_fs_x__p2l_entry_t *entry,
-                      apr_pool_t *pool)
+                      apr_pool_t *scratch_pool)
 {
-  const char *path = svn_fs_x__path_p2l_proto_index(fs, txn_id, pool);
+  const char *path = svn_fs_x__path_p2l_proto_index(fs, txn_id, scratch_pool);
   apr_file_t *file;
-  SVN_ERR(svn_fs_x__p2l_proto_index_open(&file, path, pool));
-  SVN_ERR(svn_fs_x__p2l_proto_index_add_entry(file, entry, pool));
-  SVN_ERR(svn_io_file_close(file, pool));
+  SVN_ERR(svn_fs_x__p2l_proto_index_open(&file, path, scratch_pool));
+  SVN_ERR(svn_fs_x__p2l_proto_index_add_entry(file, entry, scratch_pool));
+  SVN_ERR(svn_io_file_close(file, scratch_pool));
 
   return SVN_NO_ERROR;
 }
 
 /* Allocate an item index in the transaction TXN_ID of file system FS and
- * return it in *ITEM_INDEX.  Use POOL for allocations.
+ * return it in *ITEM_INDEX.  Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
 allocate_item_index(apr_uint64_t *item_index,
                     svn_fs_t *fs,
                     svn_fs_x__txn_id_t txn_id,
-                    apr_pool_t *pool)
+                    apr_pool_t *scratch_pool)
 {
   apr_file_t *file;
   char buffer[SVN_INT64_BUFFER_SIZE] = { 0 };
@@ -1463,12 +1484,13 @@ allocate_item_index(apr_uint64_t *item_i
 
   /* read number */
   SVN_ERR(svn_io_file_open(&file,
-                            svn_fs_x__path_txn_item_index(fs, txn_id, pool),
+                            svn_fs_x__path_txn_item_index(fs, txn_id,
+                                                          scratch_pool),
                             APR_READ | APR_WRITE
                             | APR_CREATE | APR_BUFFERED,
-                            APR_OS_DEFAULT, pool));
+                            APR_OS_DEFAULT, scratch_pool));
   SVN_ERR(svn_io_file_read_full2(file, buffer, sizeof(buffer)-1,
-                                  &read, &eof, pool));
+                                  &read, &eof, scratch_pool));
   if (read)
     SVN_ERR(svn_cstring_atoui64(item_index, buffer));
   else
@@ -1478,9 +1500,9 @@ allocate_item_index(apr_uint64_t *item_i
   to_write = svn__ui64toa(buffer, *item_index + 1);
 
   /* write it back to disk */
-  SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, pool));
-  SVN_ERR(svn_io_file_write_full(file, buffer, to_write, NULL, pool));
-  SVN_ERR(svn_io_file_close(file, pool));
+  SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, scratch_pool));
+  SVN_ERR(svn_io_file_write_full(file, buffer, to_write, NULL, scratch_pool));
+  SVN_ERR(svn_io_file_close(file, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1489,13 +1511,13 @@ allocate_item_index(apr_uint64_t *item_i
    COPY_ID for transaction TXN_ID in filesystem FS.  The next node-id is
    used both for creating new unique nodes for the given transaction, as
    well as uniquifying representations.  Perform temporary allocations in
-   POOL. */
+   SCRATCH_POOL. */
 static svn_error_t *
 write_next_ids(svn_fs_t *fs,
                svn_fs_x__txn_id_t txn_id,
                apr_uint64_t node_id,
                apr_uint64_t copy_id,
-               apr_pool_t *pool)
+               apr_pool_t *scratch_pool)
 {
   apr_file_t *file;
   char buffer[2 * SVN_INT64_BUFFER_SIZE + 2];
@@ -1508,30 +1530,33 @@ write_next_ids(svn_fs_t *fs,
   *(p++) = '\0';
 
   SVN_ERR(svn_io_file_open(&file,
-                           svn_fs_x__path_txn_next_ids(fs, txn_id, pool),
+                           svn_fs_x__path_txn_next_ids(fs, txn_id,
+                                                       scratch_pool),
                            APR_WRITE | APR_TRUNCATE,
-                           APR_OS_DEFAULT, pool));
-  SVN_ERR(svn_io_file_write_full(file, buffer, p - buffer, NULL, pool));
-  return svn_io_file_close(file, pool);
+                           APR_OS_DEFAULT, scratch_pool));
+  SVN_ERR(svn_io_file_write_full(file, buffer, p - buffer, NULL,
+                                 scratch_pool));
+  return svn_io_file_close(file, scratch_pool);
 }
 
 /* Find out what the next unique node-id and copy-id are for
    transaction TXN_ID in filesystem FS.  Store the results in *NODE_ID
    and *COPY_ID.  The next node-id is used both for creating new unique
    nodes for the given transaction, as well as uniquifying representations.
-   Perform all allocations in POOL. */
+   Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 read_next_ids(apr_uint64_t *node_id,
               apr_uint64_t *copy_id,
               svn_fs_t *fs,
               svn_fs_x__txn_id_t txn_id,
-              apr_pool_t *pool)
+              apr_pool_t *scratch_pool)
 {
   svn_stringbuf_t *buf;
   const char *str;
   SVN_ERR(svn_fs_x__read_content(&buf,
-                            svn_fs_x__path_txn_next_ids(fs, txn_id, pool),
-                            pool));
+                                 svn_fs_x__path_txn_next_ids(fs, txn_id,
+                                                             scratch_pool),
+                                 scratch_pool));
 
   /* Parse this into two separate strings. */
 
@@ -1553,22 +1578,23 @@ read_next_ids(apr_uint64_t *node_id,
 /* Get a new and unique to this transaction node-id for transaction
    TXN_ID in filesystem FS.  Store the new node-id in *NODE_ID_P.
    Node-ids are guaranteed to be unique to this transction, but may
-   not necessarily be sequential.  Perform all allocations in POOL. */
+   not necessarily be sequential.
+   Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 get_new_txn_node_id(svn_fs_x__id_t *node_id_p,
                     svn_fs_t *fs,
                     svn_fs_x__txn_id_t txn_id,
-                    apr_pool_t *pool)
+                    apr_pool_t *scratch_pool)
 {
   apr_uint64_t node_id, copy_id;
 
   /* First read in the current next-ids file. */
-  SVN_ERR(read_next_ids(&node_id, &copy_id, fs, txn_id, pool));
+  SVN_ERR(read_next_ids(&node_id, &copy_id, fs, txn_id, scratch_pool));
 
   node_id_p->change_set = svn_fs_x__change_set_by_txn(txn_id);
   node_id_p->number = node_id;
 
-  SVN_ERR(write_next_ids(fs, txn_id, ++node_id, copy_id, pool));
+  SVN_ERR(write_next_ids(fs, txn_id, ++node_id, copy_id, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1577,17 +1603,17 @@ svn_error_t *
 svn_fs_x__reserve_copy_id(svn_fs_x__id_t *copy_id_p,
                           svn_fs_t *fs,
                           svn_fs_x__txn_id_t txn_id,
-                          apr_pool_t *pool)
+                          apr_pool_t *scratch_pool)
 {
   apr_uint64_t node_id, copy_id;
 
   /* First read in the current next-ids file. */
-  SVN_ERR(read_next_ids(&node_id, &copy_id, fs, txn_id, pool));
+  SVN_ERR(read_next_ids(&node_id, &copy_id, fs, txn_id, scratch_pool));
 
   copy_id_p->change_set = svn_fs_x__change_set_by_txn(txn_id);
   copy_id_p->number = copy_id;
 
-  SVN_ERR(write_next_ids(fs, txn_id, node_id, ++copy_id, pool));
+  SVN_ERR(write_next_ids(fs, txn_id, node_id, ++copy_id, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1597,10 +1623,10 @@ svn_fs_x__create_node(svn_fs_t *fs,
                       svn_fs_x__noderev_t *noderev,
                       const svn_fs_x__id_t *copy_id,
                       svn_fs_x__txn_id_t txn_id,
-                      apr_pool_t *pool)
+                      apr_pool_t *scratch_pool)
 {
   /* Get a new node-id for this node. */
-  SVN_ERR(get_new_txn_node_id(&noderev->node_id, fs, txn_id, pool));
+  SVN_ERR(get_new_txn_node_id(&noderev->node_id, fs, txn_id, scratch_pool));
 
   /* Assign copy-id. */
   noderev->copy_id = *copy_id;
@@ -1608,9 +1634,9 @@ svn_fs_x__create_node(svn_fs_t *fs,
   /* Noderev-id = Change set and item number within this change set. */
   noderev->noderev_id.change_set = svn_fs_x__change_set_by_txn(txn_id);
   SVN_ERR(allocate_item_index(&noderev->noderev_id.number, fs, txn_id,
-                              pool));
+                              scratch_pool));
 
-  SVN_ERR(svn_fs_x__put_node_revision(fs, noderev, FALSE, pool));
+  SVN_ERR(svn_fs_x__put_node_revision(fs, noderev, FALSE, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1618,27 +1644,27 @@ svn_fs_x__create_node(svn_fs_t *fs,
 svn_error_t *
 svn_fs_x__purge_txn(svn_fs_t *fs,
                     const char *txn_id_str,
-                    apr_pool_t *pool)
+                    apr_pool_t *scratch_pool)
 {
   svn_fs_x__txn_id_t txn_id;
   SVN_ERR(svn_fs_x__txn_by_name(&txn_id, txn_id_str));
 
   /* Remove the shared transaction object associated with this transaction. */
-  SVN_ERR(purge_shared_txn(fs, txn_id, pool));
+  SVN_ERR(purge_shared_txn(fs, txn_id, scratch_pool));
   /* Remove the directory associated with this transaction. */
-  SVN_ERR(svn_io_remove_dir2(svn_fs_x__path_txn_dir(fs, txn_id, pool),
-                             FALSE, NULL, NULL, pool));
+  SVN_ERR(svn_io_remove_dir2(svn_fs_x__path_txn_dir(fs, txn_id, scratch_pool),
+                             FALSE, NULL, NULL, scratch_pool));
 
   /* Delete protorev and its lock, which aren't in the txn
       directory.  It's OK if they don't exist (for example, if this
       is post-commit and the proto-rev has been moved into
       place). */
   SVN_ERR(svn_io_remove_file2(
-                  svn_fs_x__path_txn_proto_rev(fs, txn_id, pool),
-                  TRUE, pool));
+                  svn_fs_x__path_txn_proto_rev(fs, txn_id, scratch_pool),
+                  TRUE, scratch_pool));
   SVN_ERR(svn_io_remove_file2(
-                  svn_fs_x__path_txn_proto_rev_lock(fs, txn_id, pool),
-                  TRUE, pool));
+                  svn_fs_x__path_txn_proto_rev_lock(fs, txn_id, scratch_pool),
+                  TRUE, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1646,13 +1672,13 @@ svn_fs_x__purge_txn(svn_fs_t *fs,
 
 svn_error_t *
 svn_fs_x__abort_txn(svn_fs_txn_t *txn,
-                    apr_pool_t *pool)
+                    apr_pool_t *scratch_pool)
 {
   SVN_ERR(svn_fs__check_fs(txn->fs, TRUE));
 
   /* Now, purge the transaction. */
-  SVN_ERR_W(svn_fs_x__purge_txn(txn->fs, txn->id, pool),
-            apr_psprintf(pool, _("Transaction '%s' cleanup failed"),
+  SVN_ERR_W(svn_fs_x__purge_txn(txn->fs, txn->id, scratch_pool),
+            apr_psprintf(scratch_pool, _("Transaction '%s' cleanup failed"),
                          txn->id));
 
   return SVN_NO_ERROR;
@@ -1665,15 +1691,16 @@ svn_fs_x__set_entry(svn_fs_t *fs,
                     const char *name,
                     const svn_fs_x__id_t *id,
                     svn_node_kind_t kind,
-                    apr_pool_t *pool)
+                    apr_pool_t *scratch_pool)
 {
   svn_fs_x__representation_t *rep = parent_noderev->data_rep;
   const char *filename
-    = svn_fs_x__path_txn_node_children(fs, &parent_noderev->noderev_id, pool);
+    = svn_fs_x__path_txn_node_children(fs, &parent_noderev->noderev_id,
+                                       scratch_pool);
   apr_file_t *file;
   svn_stream_t *out;
   svn_fs_x__data_t *ffd = fs->fsap_data;
-  apr_pool_t *subpool = svn_pool_create(pool);
+  apr_pool_t *subpool = svn_pool_create(scratch_pool);
 
   if (!rep || !svn_fs_x__is_txn(rep->id.change_set))
     {
@@ -1685,25 +1712,26 @@ svn_fs_x__set_entry(svn_fs_t *fs,
                                          subpool, subpool));
       SVN_ERR(svn_io_file_open(&file, filename,
                                APR_WRITE | APR_CREATE | APR_BUFFERED,
-                               APR_OS_DEFAULT, pool));
-      out = svn_stream_from_aprfile2(file, TRUE, pool);
+                               APR_OS_DEFAULT, scratch_pool));
+      out = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
       SVN_ERR(unparse_dir_entries(entries, out, subpool));
 
       svn_pool_clear(subpool);
 
       /* Mark the node-rev's data rep as mutable. */
-      rep = apr_pcalloc(pool, sizeof(*rep));
+      rep = apr_pcalloc(scratch_pool, sizeof(*rep));
       rep->id.change_set = svn_fs_x__change_set_by_txn(txn_id);
       rep->id.number = SVN_FS_X__ITEM_INDEX_UNUSED;
       parent_noderev->data_rep = rep;
-      SVN_ERR(svn_fs_x__put_node_revision(fs, parent_noderev, FALSE, pool));
+      SVN_ERR(svn_fs_x__put_node_revision(fs, parent_noderev, FALSE,
+                                          scratch_pool));
     }
   else
     {
       /* The directory rep is already mutable, so just open it for append. */
       SVN_ERR(svn_io_file_open(&file, filename, APR_WRITE | APR_APPEND,
-                               APR_OS_DEFAULT, pool));
-      out = svn_stream_from_aprfile2(file, TRUE, pool);
+                               APR_OS_DEFAULT, scratch_pool));
+      out = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
     }
 
   /* update directory cache */
@@ -1763,17 +1791,18 @@ svn_fs_x__add_change(svn_fs_t *fs,
                      svn_node_kind_t node_kind,
                      svn_revnum_t copyfrom_rev,
                      const char *copyfrom_path,
-                     apr_pool_t *pool)
+                     apr_pool_t *scratch_pool)
 {
   apr_file_t *file;
   svn_fs_x__change_t change;
-  apr_hash_t *changes = apr_hash_make(pool);
+  apr_hash_t *changes = apr_hash_make(scratch_pool);
 
   /* Not using APR_BUFFERED to append change in one atomic write operation. */
   SVN_ERR(svn_io_file_open(&file,
-                           svn_fs_x__path_txn_changes(fs, txn_id, pool),
+                           svn_fs_x__path_txn_changes(fs, txn_id,
+                                                      scratch_pool),
                            APR_APPEND | APR_WRITE | APR_CREATE,
-                           APR_OS_DEFAULT, pool));
+                           APR_OS_DEFAULT, scratch_pool));
 
   change.path.data = path;
   change.path.len = strlen(path);
@@ -1787,13 +1816,14 @@ svn_fs_x__add_change(svn_fs_t *fs,
   change.copyfrom_known = TRUE;
   change.copyfrom_rev = copyfrom_rev;
   if (copyfrom_path)
-    change.copyfrom_path = apr_pstrdup(pool, copyfrom_path);
+    change.copyfrom_path = apr_pstrdup(scratch_pool, copyfrom_path);
 
   svn_hash_sets(changes, path, &change);
-  SVN_ERR(svn_fs_x__write_changes(svn_stream_from_aprfile2(file, TRUE, pool),
-                                  fs, changes, FALSE, pool));
+  SVN_ERR(svn_fs_x__write_changes(svn_stream_from_aprfile2(file, TRUE,
+                                                           scratch_pool),
+                                  fs, changes, FALSE, scratch_pool));
 
-  return svn_io_file_close(file, pool);
+  return svn_io_file_close(file, scratch_pool);
 }
 
 /* This baton is used by the representation writing streams.  It keeps
@@ -1860,14 +1890,15 @@ rep_write_contents(void *baton,
 }
 
 /* Set *SPANNED to the number of shards touched when walking WALK steps on
- * NODEREV's predecessor chain in FS.  Use POOL for temporary allocations.
+ * NODEREV's predecessor chain in FS.
+ * Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
 shards_spanned(int *spanned,
                svn_fs_t *fs,
                svn_fs_x__noderev_t *noderev,
                int walk,
-               apr_pool_t *pool)
+               apr_pool_t *scratch_pool)
 {
   svn_fs_x__data_t *ffd = fs->fsap_data;
   int shard_size = ffd->max_files_per_dir;
@@ -1875,13 +1906,14 @@ shards_spanned(int *spanned,
 
   int count = walk ? 1 : 0; /* The start of a walk already touches a shard. */
   svn_revnum_t shard, last_shard = ffd->youngest_rev_cache / shard_size;
-  iterpool = svn_pool_create(pool);
+  iterpool = svn_pool_create(scratch_pool);
   while (walk-- && noderev->predecessor_count)
     {
       svn_fs_x__id_t id = noderev->predecessor_id;
 
       svn_pool_clear(iterpool);
-      SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, &id, pool, iterpool));
+      SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, &id, scratch_pool,
+                                          iterpool));
       shard = svn_fs_x__get_revnum(id.change_set) / shard_size;
       if (shard != last_shard)
         {
@@ -2248,19 +2280,19 @@ get_shared_rep(svn_fs_x__representation_
 }
 
 /* Copy the hash sum calculation results from MD5_CTX, SHA1_CTX into REP.
- * Use POOL for allocations.
+ * Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
 digests_final(svn_fs_x__representation_t *rep,
               const svn_checksum_ctx_t *md5_ctx,
               const svn_checksum_ctx_t *sha1_ctx,
-              apr_pool_t *pool)
+              apr_pool_t *scratch_pool)
 {
   svn_checksum_t *checksum;
 
-  SVN_ERR(svn_checksum_final(&checksum, md5_ctx, pool));
+  SVN_ERR(svn_checksum_final(&checksum, md5_ctx, scratch_pool));
   memcpy(rep->md5_digest, checksum->digest, svn_checksum_size(checksum));
-  SVN_ERR(svn_checksum_final(&checksum, sha1_ctx, pool));
+  SVN_ERR(svn_checksum_final(&checksum, sha1_ctx, scratch_pool));
   rep->has_sha1 = checksum != NULL;
   if (rep->has_sha1)
     memcpy(rep->sha1_digest, checksum->digest, svn_checksum_size(checksum));
@@ -2404,22 +2436,22 @@ svn_fs_x__create_successor(svn_fs_t *fs,
                            svn_fs_x__noderev_t *new_noderev,
                            const svn_fs_x__id_t *copy_id,
                            svn_fs_x__txn_id_t txn_id,
-                           apr_pool_t *pool)
+                           apr_pool_t *scratch_pool)
 {
   new_noderev->copy_id = *copy_id;
   new_noderev->noderev_id.change_set = svn_fs_x__change_set_by_txn(txn_id);
   SVN_ERR(allocate_item_index(&new_noderev->noderev_id.number, fs, txn_id,
-                              pool));
+                              scratch_pool));
 
   if (! new_noderev->copyroot_path)
     {
       new_noderev->copyroot_path
-        = apr_pstrdup(pool, new_noderev->created_path);
+        = apr_pstrdup(scratch_pool, new_noderev->created_path);
       new_noderev->copyroot_rev
         = svn_fs_x__get_revnum(new_noderev->noderev_id.change_set);
     }
 
-  SVN_ERR(svn_fs_x__put_node_revision(fs, new_noderev, FALSE, pool));
+  SVN_ERR(svn_fs_x__put_node_revision(fs, new_noderev, FALSE, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -2428,20 +2460,20 @@ svn_error_t *
 svn_fs_x__set_proplist(svn_fs_t *fs,
                        svn_fs_x__noderev_t *noderev,
                        apr_hash_t *proplist,
-                       apr_pool_t *pool)
+                       apr_pool_t *scratch_pool)
 {
   const svn_fs_x__id_t *id = &noderev->noderev_id;
-  const char *filename = svn_fs_x__path_txn_node_props(fs, id, pool);
+  const char *filename = svn_fs_x__path_txn_node_props(fs, id, scratch_pool);
   apr_file_t *file;
   svn_stream_t *out;
 
   /* Dump the property list to the mutable property file. */
   SVN_ERR(svn_io_file_open(&file, filename,
                            APR_WRITE | APR_CREATE | APR_TRUNCATE
-                           | APR_BUFFERED, APR_OS_DEFAULT, pool));
-  out = svn_stream_from_aprfile2(file, TRUE, pool);
-  SVN_ERR(svn_hash_write2(proplist, out, SVN_HASH_TERMINATOR, pool));
-  SVN_ERR(svn_io_file_close(file, pool));
+                           | APR_BUFFERED, APR_OS_DEFAULT, scratch_pool));
+  out = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
+  SVN_ERR(svn_hash_write2(proplist, out, SVN_HASH_TERMINATOR, scratch_pool));
+  SVN_ERR(svn_io_file_close(file, scratch_pool));
 
   /* Mark the node-rev's prop rep as mutable, if not already done. */
   if (!noderev->prop_rep
@@ -2449,11 +2481,11 @@ svn_fs_x__set_proplist(svn_fs_t *fs,
     {
       svn_fs_x__txn_id_t txn_id
         = svn_fs_x__get_txn_id(noderev->noderev_id.change_set);
-      noderev->prop_rep = apr_pcalloc(pool, sizeof(*noderev->prop_rep));
+      noderev->prop_rep = apr_pcalloc(scratch_pool, sizeof(*noderev->prop_rep));
       noderev->prop_rep->id.change_set = id->change_set;
       SVN_ERR(allocate_item_index(&noderev->prop_rep->id.number, fs,
-                                  txn_id, pool));
-      SVN_ERR(svn_fs_x__put_node_revision(fs, noderev, FALSE, pool));
+                                  txn_id, scratch_pool));
+      SVN_ERR(svn_fs_x__put_node_revision(fs, noderev, FALSE, scratch_pool));
     }
 
   return SVN_NO_ERROR;
@@ -2491,17 +2523,19 @@ write_container_handler(void *baton,
 
 /* Callback function type.  Write the data provided by BATON into STREAM. */
 typedef svn_error_t *
-(* collection_writer_t)(svn_stream_t *stream, void *baton, apr_pool_t *pool);
+(* collection_writer_t)(svn_stream_t *stream,
+                        void *baton,
+                        apr_pool_t *scratch_pool);
 
 /* Implement collection_writer_t writing the C string->svn_string_t hash
    given as BATON. */
 static svn_error_t *
 write_hash_to_stream(svn_stream_t *stream,
                      void *baton,
-                     apr_pool_t *pool)
+                     apr_pool_t *scratch_pool)
 {
   apr_hash_t *hash = baton;
-  SVN_ERR(svn_hash_write2(hash, stream, SVN_HASH_TERMINATOR, pool));
+  SVN_ERR(svn_hash_write2(hash, stream, SVN_HASH_TERMINATOR, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -2511,10 +2545,10 @@ write_hash_to_stream(svn_stream_t *strea
 static svn_error_t *
 write_directory_to_stream(svn_stream_t *stream,
                           void *baton,
-                          apr_pool_t *pool)
+                          apr_pool_t *scratch_pool)
 {
   apr_array_header_t *dir = baton;
-  SVN_ERR(unparse_dir_entries(dir, stream, pool));
+  SVN_ERR(unparse_dir_entries(dir, stream, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -2671,7 +2705,7 @@ write_container_delta_rep(svn_fs_x__repr
 }
 
 /* Sanity check ROOT_NODEREV, a candidate for being the root node-revision
-   of (not yet committed) revision REV in FS.  Use POOL for temporary
+   of (not yet committed) revision REV in FS.  Use SCRATCH_POOL for temporary
    allocations.
 
    If you change this function, consider updating svn_fs_x__verify() too.
@@ -2680,7 +2714,7 @@ static svn_error_t *
 validate_root_noderev(svn_fs_t *fs,
                       svn_fs_x__noderev_t *root_noderev,
                       svn_revnum_t rev,
-                      apr_pool_t *pool)
+                      apr_pool_t *scratch_pool)
 {
   svn_revnum_t head_revnum = rev-1;
   int head_predecessor_count;
@@ -2695,7 +2729,8 @@ validate_root_noderev(svn_fs_t *fs,
     /* Get /@HEAD's noderev. */
     svn_fs_x__init_rev_root(&head_root_id, head_revnum);
     SVN_ERR(svn_fs_x__get_node_revision(&head_root_noderev, fs,
-                                        &head_root_id, pool, pool));
+                                        &head_root_id, scratch_pool,
+                                        scratch_pool));
 
     head_predecessor_count = head_root_noderev->predecessor_count;
   }
@@ -2764,7 +2799,7 @@ get_final_id(svn_fs_x__id_t *part,
    node-revision.  It is only controls additional sanity checking
    logic.
 
-   Temporary allocations are also from POOL. */
+   Temporary allocations are also from SCRATCH_POOL. */
 static svn_error_t *
 write_final_rev(svn_fs_x__id_t *new_id_p,
                 apr_file_t *file,
@@ -2776,7 +2811,7 @@ write_final_rev(svn_fs_x__id_t *new_id_p
                 apr_hash_t *reps_hash,
                 apr_pool_t *reps_pool,
                 svn_boolean_t at_root,
-                apr_pool_t *pool)
+                apr_pool_t *scratch_pool)
 {
   svn_fs_x__noderev_t *noderev;
   apr_off_t my_offset;
@@ -2796,8 +2831,9 @@ write_final_rev(svn_fs_x__id_t *new_id_p
       return SVN_NO_ERROR;
     }
 
-  subpool = svn_pool_create(pool);
-  SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, id, pool, subpool));
+  subpool = svn_pool_create(scratch_pool);
+  SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, id, scratch_pool,
+                                      subpool));
 
   if (noderev->kind == svn_node_dir)
     {
@@ -2806,11 +2842,12 @@ write_final_rev(svn_fs_x__id_t *new_id_p
 
       /* This is a directory.  Write out all the children first. */
 
-      SVN_ERR(svn_fs_x__rep_contents_dir(&entries, fs, noderev, pool,
+      SVN_ERR(svn_fs_x__rep_contents_dir(&entries, fs, noderev, scratch_pool,
                                          subpool));
       for (i = 0; i < entries->nelts; ++i)
         {
-          svn_fs_x__dirent_t *dirent = APR_ARRAY_IDX(entries, i, svn_fs_x__dirent_t *);
+          svn_fs_x__dirent_t *dirent = APR_ARRAY_IDX(entries, i,
+                                                     svn_fs_x__dirent_t *);
 
           svn_pool_clear(subpool);
           SVN_ERR(write_final_rev(&new_id, file, rev, fs, &dirent->id,
@@ -2831,7 +2868,7 @@ write_final_rev(svn_fs_x__id_t *new_id_p
                                             write_directory_to_stream,
                                             fs, txn_id, noderev, NULL,
                                             SVN_FS_X__ITEM_TYPE_DIR_REP,
-                                            rev, pool));
+                                            rev, scratch_pool));
         }
     }
   else
@@ -2857,14 +2894,14 @@ write_final_rev(svn_fs_x__id_t *new_id_p
       apr_uint32_t item_type = noderev->kind == svn_node_dir
                              ? SVN_FS_X__ITEM_TYPE_DIR_PROPS
                              : SVN_FS_X__ITEM_TYPE_FILE_PROPS;
-      SVN_ERR(svn_fs_x__get_proplist(&proplist, fs, noderev, pool));
+      SVN_ERR(svn_fs_x__get_proplist(&proplist, fs, noderev, scratch_pool));
 
       noderev->prop_rep->id.change_set = change_set;
 
       SVN_ERR(write_container_delta_rep(noderev->prop_rep, file, proplist,
                                         write_hash_to_stream, fs, txn_id,
                                         noderev, reps_hash, item_type, rev,
-                                        pool));
+                                        scratch_pool));
     }
 
   /* Convert our temporary ID into a permanent revision one. */
@@ -2875,10 +2912,10 @@ write_final_rev(svn_fs_x__id_t *new_id_p
   if (noderev->copyroot_rev == SVN_INVALID_REVNUM)
     noderev->copyroot_rev = rev;
 
-  SVN_ERR(svn_fs_x__get_file_offset(&my_offset, file, pool));
+  SVN_ERR(svn_fs_x__get_file_offset(&my_offset, file, scratch_pool));
 
   SVN_ERR(store_l2p_index_entry(fs, txn_id, my_offset,
-                                noderev->noderev_id.number, pool));
+                                noderev->noderev_id.number, scratch_pool));
   new_id = noderev->noderev_id;
 
   if (ffd->rep_sharing_allowed)
@@ -2922,13 +2959,14 @@ write_final_rev(svn_fs_x__id_t *new_id_p
 
   /* Write out our new node-revision. */
   if (at_root)
-    SVN_ERR(validate_root_noderev(fs, noderev, rev, pool));
+    SVN_ERR(validate_root_noderev(fs, noderev, rev, scratch_pool));
 
   file_stream = svn_checksum__wrap_write_stream_fnv1a_32x4(
                                   &entry.fnv1_checksum,
-                                  svn_stream_from_aprfile2(file, TRUE, pool),
-                                  pool);
-  SVN_ERR(svn_fs_x__write_noderev(file_stream, noderev, pool));
+                                  svn_stream_from_aprfile2(file, TRUE,
+                                                           scratch_pool),
+                                  scratch_pool);
+  SVN_ERR(svn_fs_x__write_noderev(file_stream, noderev, scratch_pool));
   SVN_ERR(svn_stream_close(file_stream));
 
   /* reference the root noderev from the log-to-phys index */
@@ -2936,13 +2974,13 @@ write_final_rev(svn_fs_x__id_t *new_id_p
   noderev_id.change_set = SVN_FS_X__INVALID_CHANGE_SET;
 
   entry.offset = my_offset;
-  SVN_ERR(svn_fs_x__get_file_offset(&my_offset, file, pool));
+  SVN_ERR(svn_fs_x__get_file_offset(&my_offset, file, scratch_pool));
   entry.size = my_offset - entry.offset;
   entry.type = SVN_FS_X__ITEM_TYPE_NODEREV;
   entry.item_count = 1;
   entry.items = &noderev_id;
 
-  SVN_ERR(store_p2l_index_entry(fs, txn_id, &entry, pool));
+  SVN_ERR(store_p2l_index_entry(fs, txn_id, &entry, scratch_pool));
 
   /* Return our ID that references the revision file. */
   *new_id_p = new_id;
@@ -2954,7 +2992,7 @@ write_final_rev(svn_fs_x__id_t *new_id_p
    permanent rev-file FILE representing NEW_REV in filesystem FS.  *OFFSET_P
    is set the to offset in the file of the beginning of this information.
    NEW_REV is the revision currently being committed.
-   Perform temporary allocations in POOL. */
+   Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 write_final_changed_path_info(apr_off_t *offset_p,
                               apr_file_t *file,
@@ -2962,7 +3000,7 @@ write_final_changed_path_info(apr_off_t
                               svn_fs_x__txn_id_t txn_id,
                               apr_hash_t *changed_paths,
                               svn_revnum_t new_rev,
-                              apr_pool_t *pool)
+                              apr_pool_t *scratch_pool)
 {
   apr_off_t offset;
   svn_stream_t *stream;
@@ -2970,28 +3008,29 @@ write_final_changed_path_info(apr_off_t
   svn_fs_x__id_t rev_item
     = {SVN_INVALID_REVNUM, SVN_FS_X__ITEM_INDEX_CHANGES};
 
-  SVN_ERR(svn_fs_x__get_file_offset(&offset, file, pool));
+  SVN_ERR(svn_fs_x__get_file_offset(&offset, file, scratch_pool));
 
   /* write to target file & calculate checksum */
   stream = svn_checksum__wrap_write_stream_fnv1a_32x4(&entry.fnv1_checksum,
-                             svn_stream_from_aprfile2(file, TRUE, pool),
-                             pool);
-  SVN_ERR(svn_fs_x__write_changes(stream, fs, changed_paths, TRUE, pool));
+                         svn_stream_from_aprfile2(file, TRUE, scratch_pool),
+                         scratch_pool);
+  SVN_ERR(svn_fs_x__write_changes(stream, fs, changed_paths, TRUE,
+                                  scratch_pool));
   SVN_ERR(svn_stream_close(stream));
 
   *offset_p = offset;
 
   /* reference changes from the indexes */
   entry.offset = offset;
-  SVN_ERR(svn_fs_x__get_file_offset(&offset, file, pool));
+  SVN_ERR(svn_fs_x__get_file_offset(&offset, file, scratch_pool));
   entry.size = offset - entry.offset;
   entry.type = SVN_FS_X__ITEM_TYPE_CHANGES;
   entry.item_count = 1;
   entry.items = &rev_item;
 
-  SVN_ERR(store_p2l_index_entry(fs, txn_id, &entry, pool));
+  SVN_ERR(store_p2l_index_entry(fs, txn_id, &entry, scratch_pool));
   SVN_ERR(store_l2p_index_entry(fs, txn_id, entry.offset,
-                                SVN_FS_X__ITEM_INDEX_CHANGES, pool));
+                                SVN_FS_X__ITEM_INDEX_CHANGES, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -3005,7 +3044,7 @@ write_final_changed_path_info(apr_off_t
 static svn_error_t *
 verify_as_revision_before_current_plus_plus(svn_fs_t *fs,
                                             svn_revnum_t new_rev,
-                                            apr_pool_t *pool)
+                                            apr_pool_t *scratch_pool)
 {
 #ifdef SVN_DEBUG
   svn_fs_x__data_t *ffd = fs->fsap_data;
@@ -3019,13 +3058,13 @@ verify_as_revision_before_current_plus_p
   /* make sure FT does not simply return data cached by other instances
    * but actually retrieves it from disk at least once.
    */
-  fs_config = apr_hash_make(pool);
+  fs_config = apr_hash_make(scratch_pool);
   svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_NS,
-                           svn_uuid_generate(pool));
+                           svn_uuid_generate(scratch_pool));
   SVN_ERR(ffd->svn_fs_open_(&ft, fs->path,
                             fs_config,
-                            pool,
-                            pool));
+                            scratch_pool,
+                            scratch_pool));
   ft_ffd = ft->fsap_data;
   /* Don't let FT consult rep-cache.db, either. */
   ft_ffd->rep_sharing_allowed = FALSE;
@@ -3033,10 +3072,10 @@ verify_as_revision_before_current_plus_p
   /* Time travel! */
   ft_ffd->youngest_rev_cache = new_rev;
 
-  SVN_ERR(svn_fs_x__revision_root(&root, ft, new_rev, pool));
+  SVN_ERR(svn_fs_x__revision_root(&root, ft, new_rev, scratch_pool));
   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_x__verify_root(root, pool));
+  SVN_ERR(svn_fs_x__verify_root(root, scratch_pool));
 #endif /* SVN_DEBUG */
 
   return SVN_NO_ERROR;
@@ -3049,7 +3088,7 @@ static svn_error_t *
 verify_locks(svn_fs_t *fs,
              svn_fs_x__txn_id_t txn_id,
              apr_hash_t *changed_paths,
-             apr_pool_t *pool)
+             apr_pool_t *scratch_pool)
 {
   apr_pool_t *iterpool;
   apr_array_header_t *changed_paths_sorted;
@@ -3059,12 +3098,12 @@ verify_locks(svn_fs_t *fs,
   /* Make an array of the changed paths, and sort them depth-first-ily.  */
   changed_paths_sorted = svn_sort__hash(changed_paths,
                                         svn_sort_compare_items_as_paths,
-                                        pool);
+                                        scratch_pool);
 
   /* Now, traverse the array of changed paths, verify locks.  Note
      that if we need to do a recursive verification a path, we'll skip
      over children of that path when we get to them. */
-  iterpool = svn_pool_create(pool);
+  iterpool = svn_pool_create(scratch_pool);
   for (i = 0; i < changed_paths_sorted->nelts; i++)
     {
       const svn_sort__item_t *item;
@@ -3105,7 +3144,7 @@ verify_locks(svn_fs_t *fs,
       if (recurse)
         {
           if (! last_recursed)
-            last_recursed = svn_stringbuf_create(path, pool);
+            last_recursed = svn_stringbuf_create(path, scratch_pool);
           else
             svn_stringbuf_set(last_recursed, path);
         }
@@ -3180,7 +3219,7 @@ svn_fs_x__add_index_data(svn_fs_t *fs,
                          const char *l2p_proto_index,
                          const char *p2l_proto_index,
                          svn_revnum_t revision,
-                         apr_pool_t *pool)
+                         apr_pool_t *scratch_pool)
 {
   apr_off_t l2p_offset;
   apr_off_t p2l_offset;
@@ -3191,26 +3230,28 @@ svn_fs_x__add_index_data(svn_fs_t *fs,
 
   /* Append the actual index data to the pack file. */
   l2p_offset = 0;
-  SVN_ERR(svn_io_file_seek(file, APR_END, &l2p_offset, pool));
+  SVN_ERR(svn_io_file_seek(file, APR_END, &l2p_offset, scratch_pool));
   SVN_ERR(svn_fs_x__l2p_index_append(&l2p_checksum, fs, file,
                                      l2p_proto_index, revision,
-                                     pool, pool));
+                                     scratch_pool, scratch_pool));
 
   p2l_offset = 0;
-  SVN_ERR(svn_io_file_seek(file, APR_END, &p2l_offset, pool));
+  SVN_ERR(svn_io_file_seek(file, APR_END, &p2l_offset, scratch_pool));
   SVN_ERR(svn_fs_x__p2l_index_append(&p2l_checksum, fs, file,
                                      p2l_proto_index, revision,
-                                     pool, pool));
+                                     scratch_pool, scratch_pool));
 
   /* Append footer. */
   footer = svn_fs_x__unparse_footer(l2p_offset, l2p_checksum, 
-                                    p2l_offset, p2l_checksum, pool, pool);
+                                    p2l_offset, p2l_checksum, scratch_pool,
+                                    scratch_pool);
   SVN_ERR(svn_io_file_write_full(file, footer->data, footer->len, NULL,
-                                 pool));
+                                 scratch_pool));
 
   footer_length = footer->len;
   SVN_ERR_ASSERT(footer_length == footer->len);
-  SVN_ERR(svn_io_file_write_full(file, &footer_length, 1, NULL, pool));
+  SVN_ERR(svn_io_file_write_full(file, &footer_length, 1, NULL,
+                                 scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -3229,7 +3270,8 @@ struct commit_baton {
    This implements the svn_fs_x__with_write_lock() 'body' callback
    type.  BATON is a 'struct commit_baton *'. */
 static svn_error_t *
-commit_body(void *baton, apr_pool_t *pool)
+commit_body(void *baton,
+            apr_pool_t *scratch_pool)
 {
   struct commit_baton *cb = baton;
   svn_fs_x__data_t *ffd = cb->fs->fsap_data;
@@ -3257,10 +3299,10 @@ commit_body(void *baton, apr_pool_t *poo
      mode for the final rev.  We must be sure to detect that cause because
      the failure would only manifest once the new revision got committed.
    */
-  SVN_ERR(svn_fs_x__read_format_file(cb->fs, pool));
+  SVN_ERR(svn_fs_x__read_format_file(cb->fs, scratch_pool));
 
   /* Get the current youngest revision. */
-  SVN_ERR(svn_fs_x__youngest_rev(&old_rev, cb->fs, pool));
+  SVN_ERR(svn_fs_x__youngest_rev(&old_rev, cb->fs, scratch_pool));
 
   /* Check to make sure this transaction is based off the most recent
      revision. */
@@ -3271,41 +3313,42 @@ commit_body(void *baton, apr_pool_t *poo
   /* We need the changes list for verification as well as for writing it
      to the final rev file. */
   SVN_ERR(svn_fs_x__txn_changes_fetch(&changed_paths, cb->fs, txn_id,
-                                      pool));
+                                      scratch_pool));
 
   /* Locks may have been added (or stolen) between the calling of
      previous svn_fs.h functions and svn_fs_commit_txn(), so we need
      to re-examine every changed-path in the txn and re-verify all
      discovered locks. */
-  SVN_ERR(verify_locks(cb->fs, txn_id, changed_paths, pool));
+  SVN_ERR(verify_locks(cb->fs, txn_id, changed_paths, scratch_pool));
 
   /* We are going to be one better than this puny old revision. */
   new_rev = old_rev + 1;
 
   /* Get a write handle on the proto revision file. */
   SVN_ERR(get_writable_proto_rev(&proto_file, &proto_file_lockcookie,
-                                 cb->fs, txn_id, pool));
-  SVN_ERR(svn_fs_x__get_file_offset(&initial_offset, proto_file, pool));
+                                 cb->fs, txn_id, scratch_pool));
+  SVN_ERR(svn_fs_x__get_file_offset(&initial_offset, proto_file,
+                                    scratch_pool));
 
   /* Write out all the node-revisions and directory contents. */
   svn_fs_x__init_txn_root(&root_id, txn_id);
   SVN_ERR(write_final_rev(&new_root_id, proto_file, new_rev, cb->fs, &root_id,
                           initial_offset, cb->reps_to_cache, cb->reps_hash,
-                          cb->reps_pool, TRUE, pool));
+                          cb->reps_pool, TRUE, scratch_pool));
 
   /* Write the changed-path information. */
   SVN_ERR(write_final_changed_path_info(&changed_path_offset, proto_file,
                                         cb->fs, txn_id, changed_paths,
-                                        new_rev, pool));
+                                        new_rev, scratch_pool));
 
   /* Append the index data to the rev file. */
   SVN_ERR(svn_fs_x__add_index_data(cb->fs, proto_file,
-                      svn_fs_x__path_l2p_proto_index(cb->fs, txn_id, pool),
-                      svn_fs_x__path_p2l_proto_index(cb->fs, txn_id, pool),
-                      new_rev, pool));
+                svn_fs_x__path_l2p_proto_index(cb->fs, txn_id, scratch_pool),
+                svn_fs_x__path_p2l_proto_index(cb->fs, txn_id, scratch_pool),
+                new_rev, scratch_pool));
 
-  SVN_ERR(svn_io_file_flush_to_disk(proto_file, pool));
-  SVN_ERR(svn_io_file_close(proto_file, pool));
+  SVN_ERR(svn_io_file_flush_to_disk(proto_file, scratch_pool));
+  SVN_ERR(svn_io_file_close(proto_file, scratch_pool));
 
   /* We don't unlock the prototype revision file immediately to avoid a
      race with another caller writing to the prototype revision file
@@ -3319,30 +3362,32 @@ commit_body(void *baton, apr_pool_t *poo
       /* Create the revs shard. */
         {
           const char *new_dir
-            = svn_fs_x__path_rev_shard(cb->fs, new_rev, pool);
-          svn_error_t *err = svn_io_dir_make(new_dir, APR_OS_DEFAULT, pool);
+            = svn_fs_x__path_rev_shard(cb->fs, new_rev, scratch_pool);
+          svn_error_t *err = svn_io_dir_make(new_dir, APR_OS_DEFAULT,
+                                             scratch_pool);
           if (err && !APR_STATUS_IS_EEXIST(err->apr_err))
             return svn_error_trace(err);
           svn_error_clear(err);
           SVN_ERR(svn_io_copy_perms(svn_dirent_join(cb->fs->path,
                                                     PATH_REVS_DIR,
-                                                    pool),
-                                    new_dir, pool));
+                                                    scratch_pool),
+                                    new_dir, scratch_pool));
         }
 
       /* Create the revprops shard. */
       SVN_ERR_ASSERT(! svn_fs_x__is_packed_revprop(cb->fs, new_rev));
         {
           const char *new_dir
-            = svn_fs_x__path_revprops_shard(cb->fs, new_rev, pool);
-          svn_error_t *err = svn_io_dir_make(new_dir, APR_OS_DEFAULT, pool);
+            = svn_fs_x__path_revprops_shard(cb->fs, new_rev, scratch_pool);
+          svn_error_t *err = svn_io_dir_make(new_dir, APR_OS_DEFAULT,
+                                             scratch_pool);
           if (err && !APR_STATUS_IS_EEXIST(err->apr_err))
             return svn_error_trace(err);
           svn_error_clear(err);
           SVN_ERR(svn_io_copy_perms(svn_dirent_join(cb->fs->path,
                                                     PATH_REVPROPS_DIR,
-                                                    pool),
-                                    new_dir, pool));
+                                                    scratch_pool),
+                                    new_dir, scratch_pool));
         }
     }
 
@@ -3351,29 +3396,34 @@ commit_body(void *baton, apr_pool_t *poo
      ### This "breaks" the transaction by removing the protorev file
      ### but the revision is not yet complete.  If this commit does
      ### not complete for any reason the transaction will be lost. */
-  old_rev_filename = svn_fs_x__path_rev_absolute(cb->fs, old_rev, pool);
+  old_rev_filename = svn_fs_x__path_rev_absolute(cb->fs, old_rev,
+                                                 scratch_pool);
 
-  rev_filename = svn_fs_x__path_rev(cb->fs, new_rev, pool);
-  proto_filename = svn_fs_x__path_txn_proto_rev(cb->fs, txn_id, pool);
+  rev_filename = svn_fs_x__path_rev(cb->fs, new_rev, scratch_pool);
+  proto_filename = svn_fs_x__path_txn_proto_rev(cb->fs, txn_id,
+                                                scratch_pool);
   SVN_ERR(svn_fs_x__move_into_place(proto_filename, rev_filename,
-                                    old_rev_filename, pool));
+                                    old_rev_filename, scratch_pool));
 
   /* Now that we've moved the prototype revision file out of the way,
      we can unlock it (since further attempts to write to the file
      will fail as it no longer exists).  We must do this so that we can
      remove the transaction directory later. */
-  SVN_ERR(unlock_proto_rev(cb->fs, txn_id, proto_file_lockcookie, pool));
+  SVN_ERR(unlock_proto_rev(cb->fs, txn_id, proto_file_lockcookie,
+                           scratch_pool));
 
   /* Move the revprops file into place. */
   SVN_ERR_ASSERT(! svn_fs_x__is_packed_revprop(cb->fs, new_rev));
-  SVN_ERR(write_final_revprop(&revprop_filename, cb->txn, txn_id, pool));
-  final_revprop = svn_fs_x__path_revprops(cb->fs, new_rev, pool);
+  SVN_ERR(write_final_revprop(&revprop_filename, cb->txn, txn_id,
+                              scratch_pool));
+  final_revprop = svn_fs_x__path_revprops(cb->fs, new_rev, scratch_pool);
   SVN_ERR(svn_fs_x__move_into_place(revprop_filename, final_revprop,
-                                    old_rev_filename, pool));
+                                    old_rev_filename, scratch_pool));
 
   /* Update the 'current' file. */
-  SVN_ERR(verify_as_revision_before_current_plus_plus(cb->fs, new_rev, pool));
-  SVN_ERR(svn_fs_x__write_current(cb->fs, new_rev, pool));
+  SVN_ERR(verify_as_revision_before_current_plus_plus(cb->fs, new_rev,
+                                                      scratch_pool));
+  SVN_ERR(svn_fs_x__write_current(cb->fs, new_rev, scratch_pool));
 
   /* At this point the new revision is committed and globally visible
      so let the caller know it succeeded by giving it the new revision
@@ -3385,7 +3435,7 @@ commit_body(void *baton, apr_pool_t *poo
   ffd->youngest_rev_cache = new_rev;
 
   /* Remove this transaction directory. */
-  SVN_ERR(svn_fs_x__purge_txn(cb->fs, cb->txn->id, pool));
+  SVN_ERR(svn_fs_x__purge_txn(cb->fs, cb->txn->id, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -3416,7 +3466,7 @@ svn_error_t *
 svn_fs_x__commit(svn_revnum_t *new_rev_p,
                  svn_fs_t *fs,
                  svn_fs_txn_t *txn,
-                 apr_pool_t *pool)
+                 apr_pool_t *scratch_pool)
 {
   struct commit_baton cb;
   svn_fs_x__data_t *ffd = fs->fsap_data;
@@ -3427,10 +3477,10 @@ svn_fs_x__commit(svn_revnum_t *new_rev_p
 
   if (ffd->rep_sharing_allowed)
     {
-      cb.reps_to_cache = apr_array_make(pool, 5,
+      cb.reps_to_cache = apr_array_make(scratch_pool, 5,
                                         sizeof(svn_fs_x__representation_t *));
-      cb.reps_hash = apr_hash_make(pool);
-      cb.reps_pool = pool;
+      cb.reps_hash = apr_hash_make(scratch_pool);
+      cb.reps_pool = scratch_pool;
     }
   else
     {
@@ -3439,14 +3489,14 @@ svn_fs_x__commit(svn_revnum_t *new_rev_p
       cb.reps_pool = NULL;
     }
 
-  SVN_ERR(svn_fs_x__with_write_lock(fs, commit_body, &cb, pool));
+  SVN_ERR(svn_fs_x__with_write_lock(fs, commit_body, &cb, scratch_pool));
 
   /* At this point, *NEW_REV_P has been set, so errors below won't affect
      the success of the commit.  (See svn_fs_commit_txn().)  */
 
   if (ffd->rep_sharing_allowed)
     {
-      SVN_ERR(svn_fs_x__open_rep_cache(fs, pool));
+      SVN_ERR(svn_fs_x__open_rep_cache(fs, scratch_pool));
 
       /* Write new entries to the rep-sharing database.
        *
@@ -3457,7 +3507,7 @@ svn_fs_x__commit(svn_revnum_t *new_rev_p
              (reader/writer) commits for the duration of the below call.
              Maybe write in batches? */
       SVN_SQLITE__WITH_TXN(
-        write_reps_to_cache(fs, cb.reps_to_cache, pool),
+        write_reps_to_cache(fs, cb.reps_to_cache, scratch_pool),
         ffd->rep_cache_db);
     }
 
@@ -3565,16 +3615,18 @@ svn_fs_x__txn_proplist(apr_hash_t **tabl
 svn_error_t *
 svn_fs_x__delete_node_revision(svn_fs_t *fs,
                                const svn_fs_x__id_t *id,
-                               apr_pool_t *pool)
+                               apr_pool_t *scratch_pool)
 {
   svn_fs_x__noderev_t *noderev;
-  SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, id, pool, pool));
+  SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, id, scratch_pool,
+                                      scratch_pool));
 
   /* Delete any mutable property representation. */
   if (noderev->prop_rep
       && svn_fs_x__is_txn(noderev->prop_rep->id.change_set))
-    SVN_ERR(svn_io_remove_file2(svn_fs_x__path_txn_node_props(fs, id, pool),
-                                FALSE, pool));
+    SVN_ERR(svn_io_remove_file2(svn_fs_x__path_txn_node_props(fs, id,
+                                                              scratch_pool),
+                                FALSE, scratch_pool));
 
   /* Delete any mutable data representation. */
   if (noderev->data_rep
@@ -3584,16 +3636,17 @@ svn_fs_x__delete_node_revision(svn_fs_t
       svn_fs_x__data_t *ffd = fs->fsap_data;
       const svn_fs_x__id_t *key = id;
 
-      SVN_ERR(svn_io_remove_file2(svn_fs_x__path_txn_node_children(fs, id,
-                                                                   pool),
-                                  FALSE, pool));
+      SVN_ERR(svn_io_remove_file2(
+                  svn_fs_x__path_txn_node_children(fs, id, scratch_pool),
+                  FALSE, scratch_pool));
 
       /* remove the corresponding entry from the cache, if such exists */
-      SVN_ERR(svn_cache__set(ffd->dir_cache, key, NULL, pool));
+      SVN_ERR(svn_cache__set(ffd->dir_cache, key, NULL, scratch_pool));
     }
 
-  return svn_io_remove_file2(svn_fs_x__path_txn_node_rev(fs, id, pool),
-                             FALSE, pool);
+  return svn_io_remove_file2(svn_fs_x__path_txn_node_rev(fs,
+                                                         id, scratch_pool),
+                             FALSE, scratch_pool);
 }
 
 
@@ -3604,10 +3657,10 @@ svn_error_t *
 svn_fs_x__get_base_rev(svn_revnum_t *revnum,
                        svn_fs_t *fs,
                        svn_fs_x__txn_id_t txn_id,
-                       apr_pool_t *pool)
+                       apr_pool_t *scratch_pool)
 {
   svn_fs_x__transaction_t *txn;
-  SVN_ERR(svn_fs_x__get_txn(&txn, fs, txn_id, pool));
+  SVN_ERR(svn_fs_x__get_txn(&txn, fs, txn_id, scratch_pool));
   *revnum = txn->base_rev;
 
   return SVN_NO_ERROR;