You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by iv...@apache.org on 2015/09/11 17:51:34 UTC

svn commit: r1702504 [6/19] - in /subversion/branches/reuse-ra-session: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ contrib/hook-scripts/ notes/ subversion/bindings/ctypes-python/csvn/ext/ subversion/bindings/javahl/native/ s...

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/caching.c
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/caching.c?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/caching.c (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/caching.c Fri Sep 11 15:51:30 2015
@@ -23,8 +23,7 @@
 #include "fs.h"
 #include "fs_x.h"
 #include "id.h"
-#include "dag.h"
-#include "tree.h"
+#include "dag_cache.h"
 #include "index.h"
 #include "changes.h"
 #include "noderevs.h"
@@ -260,42 +259,42 @@ init_callbacks(svn_cache__t *cache,
                svn_cache__error_handler_t error_handler,
                apr_pool_t *pool)
 {
-  if (cache != NULL)
-    {
 #ifdef SVN_DEBUG_CACHE_DUMP_STATS
 
-      /* schedule printing the access statistics upon pool cleanup,
-       * i.e. end of FSX session.
-       */
-      dump_cache_baton_t *baton;
-
-      baton = apr_palloc(pool, sizeof(*baton));
-      baton->pool = pool;
-      baton->cache = cache;
-
-      apr_pool_cleanup_register(pool,
-                                baton,
-                                dump_cache_statistics,
-                                apr_pool_cleanup_null);
-#endif
+  /* schedule printing the access statistics upon pool cleanup,
+   * i.e. end of FSX session.
+   */
+  dump_cache_baton_t *baton;
 
-      if (error_handler)
-        SVN_ERR(svn_cache__set_error_handler(cache,
-                                             error_handler,
-                                             fs,
-                                             pool));
+  baton = apr_palloc(pool, sizeof(*baton));
+  baton->pool = pool;
+  baton->cache = cache;
+
+  apr_pool_cleanup_register(pool,
+                            baton,
+                            dump_cache_statistics,
+                            apr_pool_cleanup_null);
+#endif
 
-    }
+  if (error_handler)
+    SVN_ERR(svn_cache__set_error_handler(cache,
+                                          error_handler,
+                                          fs,
+                                          pool));
 
   return SVN_NO_ERROR;
 }
 
 /* Sets *CACHE_P to cache instance based on provided options.
- * Creates memcache if MEMCACHE is not NULL. Creates membuffer cache if
- * MEMBUFFER is not NULL. Fallbacks to inprocess cache if MEMCACHE and
- * MEMBUFFER are NULL and pages is non-zero.  Sets *CACHE_P to NULL
- * otherwise.  Use the given PRIORITY class for the new cache.  If it
- * is 0, then use the default priority class.
+ *
+ * If DUMMY_CACHE is set, create a null cache.  Otherwise, creates a memcache
+ * if MEMCACHE is not NULL or a membuffer cache if MEMBUFFER is not NULL.
+ * Falls back to inprocess cache if no other cache type has been selected
+ * and PAGES is not 0.  Create a null cache otherwise.
+ *
+ * Use the given PRIORITY class for the new cache.  If PRIORITY is 0, then
+ * use the default priority class. HAS_NAMESPACE indicates whether we
+ * prefixed this cache instance with a namespace.
  *
  * Unless NO_HANDLER is true, register an error handler that reports errors
  * as warnings to the FS warning callback.
@@ -313,8 +312,10 @@ create_cache(svn_cache__t **cache_p,
              apr_ssize_t klen,
              const char *prefix,
              apr_uint32_t priority,
+             svn_boolean_t has_namespace,
              svn_fs_t *fs,
              svn_boolean_t no_handler,
+             svn_boolean_t dummy_cache,
              apr_pool_t *result_pool,
              apr_pool_t *scratch_pool)
 {
@@ -324,7 +325,11 @@ create_cache(svn_cache__t **cache_p,
   if (priority == 0)
     priority = SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY;
 
-  if (memcache)
+  if (dummy_cache)
+    {
+      SVN_ERR(svn_cache__create_null(cache_p, prefix, result_pool));
+    }
+  else if (memcache)
     {
       SVN_ERR(svn_cache__create_memcache(cache_p, memcache,
                                          serializer, deserializer, klen,
@@ -335,9 +340,12 @@ create_cache(svn_cache__t **cache_p,
     }
   else if (membuffer)
     {
+      /* We assume caches with namespaces to be relatively short-lived,
+       * i.e. their data will not be needed after a while. */
       SVN_ERR(svn_cache__create_membuffer_cache(
                 cache_p, membuffer, serializer, deserializer,
-                klen, prefix, priority, FALSE, result_pool, scratch_pool));
+                klen, prefix, priority, FALSE, has_namespace,
+                result_pool, scratch_pool));
     }
   else if (pages)
     {
@@ -347,7 +355,7 @@ create_cache(svn_cache__t **cache_p,
     }
   else
     {
-      *cache_p = NULL;
+      SVN_ERR(svn_cache__create_null(cache_p, prefix, result_pool));
     }
 
   SVN_ERR(init_callbacks(*cache_p, fs, error_handler, result_pool));
@@ -372,6 +380,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
   svn_boolean_t cache_fulltexts;
   svn_boolean_t cache_revprops;
   const char *cache_namespace;
+  svn_boolean_t has_namespace;
 
   /* Evaluating the cache configuration. */
   SVN_ERR(read_config(&cache_namespace,
@@ -383,6 +392,7 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
 
   prefix = apr_pstrcat(scratch_pool, "ns:", cache_namespace, ":", prefix,
                        SVN_VA_NULL);
+  has_namespace = strlen(cache_namespace) > 0;
 
   membuffer = svn_cache__get_global_membuffer_cache();
 
@@ -407,21 +417,6 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                               apr_pool_cleanup_null);
 #endif
 
-  /* Rough estimate: revision DAG nodes have size around 320 bytes, so
-   * let's put 16 on a page. */
-  SVN_ERR(create_cache(&(ffd->rev_node_cache),
-                       NULL,
-                       membuffer,
-                       1024, 16,
-                       svn_fs_x__dag_serialize,
-                       svn_fs_x__dag_deserialize,
-                       APR_HASH_KEY_STRING,
-                       apr_pstrcat(scratch_pool, prefix, "DAG", SVN_VA_NULL),
-                       SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
-                       fs,
-                       no_handler,
-                       fs->pool, scratch_pool));
-
   /* 1st level DAG node cache */
   ffd->dag_node_cache = svn_fs_x__create_dag_cache(fs->pool);
 
@@ -435,24 +430,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        sizeof(svn_fs_x__id_t),
                        apr_pstrcat(scratch_pool, prefix, "DIR", SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
-                       fs->pool, scratch_pool));
-
-  /* Only 16 bytes per entry (a revision number + the corresponding offset).
-     Since we want ~8k pages, that means 512 entries per page. */
-  SVN_ERR(create_cache(&(ffd->packed_offset_cache),
-                       NULL,
-                       membuffer,
-                       32, 1,
-                       svn_fs_x__serialize_manifest,
-                       svn_fs_x__deserialize_manifest,
-                       sizeof(svn_revnum_t),
-                       apr_pstrcat(scratch_pool, prefix, "PACK-MANIFEST",
-                                   SVN_VA_NULL),
-                       SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
-                       fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
 
   /* initialize node revision cache, if caching has been enabled */
@@ -466,8 +446,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "NODEREVS",
                                    SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
 
   /* initialize representation header cache, if caching has been enabled */
@@ -481,8 +462,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "REPHEADER",
                                    SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
 
   /* initialize node change list cache, if caching has been enabled */
@@ -496,136 +478,90 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "CHANGES",
                                    SVN_VA_NULL),
                        0,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
 
   /* if enabled, cache fulltext and other derived information */
-  if (cache_fulltexts)
-    {
-      SVN_ERR(create_cache(&(ffd->fulltext_cache),
-                           ffd->memcache,
-                           membuffer,
-                           0, 0, /* Do not use inprocess cache */
-                           /* Values are svn_stringbuf_t */
-                           NULL, NULL,
-                           sizeof(svn_fs_x__pair_cache_key_t),
-                           apr_pstrcat(scratch_pool, prefix, "TEXT",
-                                       SVN_VA_NULL),
-                           SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
-                           fs,
-                           no_handler,
-                           fs->pool, scratch_pool));
-
-      SVN_ERR(create_cache(&(ffd->properties_cache),
-                           NULL,
-                           membuffer,
-                           0, 0, /* Do not use inprocess cache */
-                           svn_fs_x__serialize_properties,
-                           svn_fs_x__deserialize_properties,
-                           sizeof(svn_fs_x__pair_cache_key_t),
-                           apr_pstrcat(scratch_pool, prefix, "PROP",
-                                       SVN_VA_NULL),
-                           SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
-                           fs,
-                           no_handler,
-                           fs->pool, scratch_pool));
-
-      SVN_ERR(create_cache(&(ffd->mergeinfo_cache),
-                           NULL,
-                           membuffer,
-                           0, 0, /* Do not use inprocess cache */
-                           svn_fs_x__serialize_mergeinfo,
-                           svn_fs_x__deserialize_mergeinfo,
-                           APR_HASH_KEY_STRING,
-                           apr_pstrcat(scratch_pool, prefix, "MERGEINFO",
-                                       SVN_VA_NULL),
-                           0,
-                           fs,
-                           no_handler,
-                           fs->pool, scratch_pool));
-
-      SVN_ERR(create_cache(&(ffd->mergeinfo_existence_cache),
-                           NULL,
-                           membuffer,
-                           0, 0, /* Do not use inprocess cache */
-                           /* Values are svn_stringbuf_t */
-                           NULL, NULL,
-                           APR_HASH_KEY_STRING,
-                           apr_pstrcat(scratch_pool, prefix, "HAS_MERGEINFO",
-                                       SVN_VA_NULL),
-                           0,
-                           fs,
-                           no_handler,
-                           fs->pool, scratch_pool));
-    }
-  else
-    {
-      ffd->fulltext_cache = NULL;
-      ffd->properties_cache = NULL;
-      ffd->mergeinfo_cache = NULL;
-      ffd->mergeinfo_existence_cache = NULL;
-    }
+  SVN_ERR(create_cache(&(ffd->fulltext_cache),
+                       ffd->memcache,
+                       membuffer,
+                       0, 0, /* Do not use inprocess cache */
+                       /* Values are svn_stringbuf_t */
+                       NULL, NULL,
+                       sizeof(svn_fs_x__pair_cache_key_t),
+                       apr_pstrcat(scratch_pool, prefix, "TEXT",
+                                   SVN_VA_NULL),
+                       SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+                       has_namespace,
+                       fs,
+                       no_handler, !cache_fulltexts,
+                       fs->pool, scratch_pool));
+
+  SVN_ERR(create_cache(&(ffd->properties_cache),
+                       NULL,
+                       membuffer,
+                       0, 0, /* Do not use inprocess cache */
+                       svn_fs_x__serialize_properties,
+                       svn_fs_x__deserialize_properties,
+                       sizeof(svn_fs_x__pair_cache_key_t),
+                       apr_pstrcat(scratch_pool, prefix, "PROP",
+                                   SVN_VA_NULL),
+                       SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+                       has_namespace,
+                       fs,
+                       no_handler, !cache_fulltexts,
+                       fs->pool, scratch_pool));
 
   /* if enabled, cache revprops */
-  if (cache_revprops)
-    {
-      SVN_ERR(create_cache(&(ffd->revprop_cache),
-                           NULL,
-                           membuffer,
-                           0, 0, /* Do not use inprocess cache */
-                           svn_fs_x__serialize_properties,
-                           svn_fs_x__deserialize_properties,
-                           sizeof(svn_fs_x__pair_cache_key_t),
-                           apr_pstrcat(scratch_pool, prefix, "REVPROP",
-                                       SVN_VA_NULL),
-                           SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
-                           fs,
-                           no_handler,
-                           fs->pool, scratch_pool));
-    }
-  else
-    {
-      ffd->revprop_cache = NULL;
-    }
+  SVN_ERR(create_cache(&(ffd->revprop_cache),
+                       NULL,
+                       membuffer,
+                       0, 0, /* Do not use inprocess cache */
+                       svn_fs_x__serialize_properties,
+                       svn_fs_x__deserialize_properties,
+                       sizeof(svn_fs_x__pair_cache_key_t),
+                       apr_pstrcat(scratch_pool, prefix, "REVPROP",
+                                   SVN_VA_NULL),
+                       SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+                       has_namespace,
+                       fs,
+                       no_handler, !cache_revprops,
+                       fs->pool, scratch_pool));
 
   /* if enabled, cache text deltas and their combinations */
-  if (cache_txdeltas)
-    {
-      SVN_ERR(create_cache(&(ffd->txdelta_window_cache),
-                           NULL,
-                           membuffer,
-                           0, 0, /* Do not use inprocess cache */
-                           svn_fs_x__serialize_txdelta_window,
-                           svn_fs_x__deserialize_txdelta_window,
-                           sizeof(svn_fs_x__window_cache_key_t),
-                           apr_pstrcat(scratch_pool, prefix, "TXDELTA_WINDOW",
-                                       SVN_VA_NULL),
-                           SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
-                           fs,
-                           no_handler,
-                           fs->pool, scratch_pool));
-
-      SVN_ERR(create_cache(&(ffd->combined_window_cache),
-                           NULL,
-                           membuffer,
-                           0, 0, /* Do not use inprocess cache */
-                           /* Values are svn_stringbuf_t */
-                           NULL, NULL,
-                           sizeof(svn_fs_x__window_cache_key_t),
-                           apr_pstrcat(scratch_pool, prefix, "COMBINED_WINDOW",
-                                       SVN_VA_NULL),
-                           SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
-                           fs,
-                           no_handler,
-                           fs->pool, scratch_pool));
-    }
-  else
-    {
-      ffd->txdelta_window_cache = NULL;
-      ffd->combined_window_cache = NULL;
-    }
+  SVN_ERR(create_cache(&(ffd->txdelta_window_cache),
+                       NULL,
+                       membuffer,
+                       0, 0, /* Do not use inprocess cache */
+                       svn_fs_x__serialize_txdelta_window,
+                       svn_fs_x__deserialize_txdelta_window,
+                       sizeof(svn_fs_x__window_cache_key_t),
+                       apr_pstrcat(scratch_pool, prefix, "TXDELTA_WINDOW",
+                                   SVN_VA_NULL),
+                       SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
+                       has_namespace,
+                       fs,
+                       no_handler, !cache_txdeltas,
+                       fs->pool, scratch_pool));
+
+  SVN_ERR(create_cache(&(ffd->combined_window_cache),
+                       NULL,
+                       membuffer,
+                       0, 0, /* Do not use inprocess cache */
+                       /* Values are svn_stringbuf_t */
+                       NULL, NULL,
+                       sizeof(svn_fs_x__window_cache_key_t),
+                       apr_pstrcat(scratch_pool, prefix, "COMBINED_WINDOW",
+                                   SVN_VA_NULL),
+                       SVN_CACHE__MEMBUFFER_LOW_PRIORITY,
+                       has_namespace,
+                       fs,
+                       no_handler, !cache_txdeltas,
+                       fs->pool, scratch_pool));
 
+  /* Caches for our various container types. */
   SVN_ERR(create_cache(&(ffd->noderevs_container_cache),
                        NULL,
                        membuffer,
@@ -636,8 +572,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "NODEREVSCNT",
                                    SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
   SVN_ERR(create_cache(&(ffd->changes_container_cache),
                        NULL,
@@ -649,8 +586,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "CHANGESCNT",
                                    SVN_VA_NULL),
                        0,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
   SVN_ERR(create_cache(&(ffd->reps_container_cache),
                        NULL,
@@ -662,10 +600,12 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "REPSCNT",
                                    SVN_VA_NULL),
                        0,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
 
+  /* Cache index info. */
   SVN_ERR(create_cache(&(ffd->l2p_header_cache),
                        NULL,
                        membuffer,
@@ -677,8 +617,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "L2P_HEADER",
                                    SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
   SVN_ERR(create_cache(&(ffd->l2p_page_cache),
                        NULL,
@@ -691,8 +632,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "L2P_PAGE",
                                    SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
   SVN_ERR(create_cache(&(ffd->p2l_header_cache),
                        NULL,
@@ -704,8 +646,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "P2L_HEADER",
                                    SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
   SVN_ERR(create_cache(&(ffd->p2l_page_cache),
                        NULL,
@@ -717,8 +660,9 @@ svn_fs_x__initialize_caches(svn_fs_t *fs
                        apr_pstrcat(scratch_pool, prefix, "P2L_PAGE",
                                    SVN_VA_NULL),
                        SVN_CACHE__MEMBUFFER_HIGH_PRIORITY,
+                       has_namespace,
                        fs,
-                       no_handler,
+                       no_handler, FALSE,
                        fs->pool, scratch_pool));
 
   return SVN_NO_ERROR;

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.c
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.c?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.c (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.c Fri Sep 11 15:51:30 2015
@@ -222,7 +222,7 @@ svn_error_t *
 svn_fs_x__changes_get_list(apr_array_header_t **list,
                            const svn_fs_x__changes_t *changes,
                            apr_size_t idx,
-                           apr_pool_t *pool)
+                           apr_pool_t *result_pool)
 {
   int first;
   int last;
@@ -235,7 +235,7 @@ svn_fs_x__changes_get_list(apr_array_hea
   /* validate index */
   if (idx + 1 >= (apr_size_t)changes->offsets->nelts)
     return svn_error_createf(SVN_ERR_FS_CONTAINER_INDEX, NULL,
-                             apr_psprintf(pool,
+                             apr_psprintf(result_pool,
                                           _("Changes list index %%%s"
                                             " exceeds container size %%d"),
                                           APR_SIZE_T_FMT),
@@ -246,18 +246,19 @@ svn_fs_x__changes_get_list(apr_array_hea
   last = APR_ARRAY_IDX(changes->offsets, (int)idx + 1, int);
 
   /* construct result */
-  *list = apr_array_make(pool, last - first, sizeof(svn_fs_x__change_t*));
+  *list = apr_array_make(result_pool, last - first,
+                         sizeof(svn_fs_x__change_t*));
   for (i = first; i < last; ++i)
     {
       const binary_change_t *binary_change
         = &APR_ARRAY_IDX(changes->changes, i, binary_change_t);
 
       /* convert BINARY_CHANGE into a standard FSX svn_fs_x__change_t */
-      svn_fs_x__change_t *change = apr_pcalloc(pool, sizeof(*change));
+      svn_fs_x__change_t *change = apr_pcalloc(result_pool, sizeof(*change));
       change->path.data = svn_fs_x__string_table_get(changes->paths,
                                                      binary_change->path,
                                                      &change->path.len,
-                                                     pool);
+                                                     result_pool);
 
       if (binary_change->noderev_id.change_set != SVN_FS_X__INVALID_CHANGE_SET)
         change->noderev_id = binary_change->noderev_id;
@@ -276,7 +277,7 @@ svn_fs_x__changes_get_list(apr_array_hea
           = svn_fs_x__string_table_get(changes->paths,
                                         binary_change->copyfrom_path,
                                         NULL,
-                                        pool);
+                                        result_pool);
 
       /* add it to the result */
       APR_ARRAY_PUSH(*list, svn_fs_x__change_t*) = change;
@@ -437,14 +438,14 @@ svn_error_t *
 svn_fs_x__deserialize_changes_container(void **out,
                                          void *data,
                                          apr_size_t data_len,
-                                         apr_pool_t *pool)
+                                         apr_pool_t *result_pool)
 {
   svn_fs_x__changes_t *changes = (svn_fs_x__changes_t *)data;
 
   /* de-serialize sub-structures */
   svn_fs_x__deserialize_string_table(changes, &changes->paths);
-  svn_fs_x__deserialize_apr_array(changes, &changes->changes, pool);
-  svn_fs_x__deserialize_apr_array(changes, &changes->offsets, pool);
+  svn_fs_x__deserialize_apr_array(changes, &changes->changes, result_pool);
+  svn_fs_x__deserialize_apr_array(changes, &changes->offsets, result_pool);
 
   /* done */
   *out = changes;

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.h
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.h?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.h (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/changes.h Fri Sep 11 15:51:30 2015
@@ -20,8 +20,8 @@
  * ====================================================================
  */
 
-#ifndef SVN_LIBSVN_FS__CHANGES_H
-#define SVN_LIBSVN_FS__CHANGES_H
+#ifndef SVN_LIBSVN_FS_X_CHANGES_H
+#define SVN_LIBSVN_FS_X_CHANGES_H
 
 #include "svn_io.h"
 #include "fs.h"
@@ -78,7 +78,7 @@ svn_error_t *
 svn_fs_x__changes_get_list(apr_array_header_t **list,
                            const svn_fs_x__changes_t *changes,
                            apr_size_t idx,
-                           apr_pool_t *pool);
+                           apr_pool_t *result_pool);
 
 /* I/O interface. */
 
@@ -114,7 +114,7 @@ svn_error_t *
 svn_fs_x__deserialize_changes_container(void **out,
                                         void *data,
                                         apr_size_t data_len,
-                                        apr_pool_t *pool);
+                                        apr_pool_t *result_pool);
 
 /* Implements svn_cache__partial_getter_func_t for svn_fs_x__changes_t,
  * setting *OUT to the change list (apr_array_header_t *) selected by

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.c
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.c?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.c (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.c Fri Sep 11 15:51:30 2015
@@ -1,4 +1,4 @@
-/* dag.c : DAG-like interface filesystem, private to libsvn_fs
+/* dag.c : DAG-like interface filesystem
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -41,6 +41,7 @@
 #include "svn_private_config.h"
 #include "private/svn_temp_serializer.h"
 #include "temp_serializer.h"
+#include "dag_cache.h"
 
 
 /* Initializing a filesystem.  */
@@ -50,34 +51,12 @@ struct dag_node_t
   /* The filesystem this dag node came from. */
   svn_fs_t *fs;
 
-  /* The node revision ID for this dag node.  */
-  svn_fs_x__id_t id;
-
-  /* In the special case that this node is the root of a transaction
-     that has not yet been modified, the revision of this node is the
-     respective txn's base rev.  Otherwise, this is SVN_INVALID_REVNUM
-     for txn nodes and the respective crev for committed nodes.
-     (Used in svn_fs_node_created_rev.) */
-  svn_revnum_t revision;
-
-  /* The node's type (file, dir, etc.) */
-  svn_node_kind_t kind;
-
-  /* The node's NODE-REVISION, or NULL if we haven't read it in yet.
-     This is allocated in this node's POOL.
-
-     If you're willing to respect all the rules above, you can munge
-     this yourself, but you're probably better off just calling
-     `get_node_revision' and `set_node_revision', which take care of
-     things for you.  */
+  /* The node's NODE-REVISION. */
   svn_fs_x__noderev_t *node_revision;
 
   /* The pool to allocate NODE_REVISION in. */
   apr_pool_t *node_pool;
 
-  /* the path at which this node was created. */
-  const char *created_path;
-
   /* Directory entry lookup hint to speed up consecutive calls to
      svn_fs_x__rep_contents_dir_entry(). Only used for directory nodes.
      Any value is legal but should default to APR_SIZE_MAX. */
@@ -90,20 +69,20 @@ struct dag_node_t
 svn_node_kind_t
 svn_fs_x__dag_node_kind(dag_node_t *node)
 {
-  return node->kind;
+  return node->node_revision->kind;
 }
 
 const svn_fs_x__id_t *
 svn_fs_x__dag_get_id(const dag_node_t *node)
 {
-  return &node->id;
+  return &node->node_revision->noderev_id;
 }
 
 
 const char *
 svn_fs_x__dag_get_created_path(dag_node_t *node)
 {
-  return node->created_path;
+  return node->node_revision->created_path;
 }
 
 
@@ -144,94 +123,35 @@ copy_node_revision(svn_fs_x__noderev_t *
 }
 
 
-/* Set *NODEREV_P to the cached node-revision for NODE.
-   If the node-revision was not already cached in NODE, read it in,
-   allocating the cache in NODE->NODE_POOL.
-
-   If you plan to change the contents of NODE, be careful!  We're
-   handing you a pointer directly to our cached node-revision, not
-   your own copy.  If you change it as part of some operation, but
-   then some Berkeley DB function deadlocks or gets an error, you'll
-   need to back out your changes, or else the cache will reflect
-   changes that never got committed.  It's probably best not to change
-   the structure at all.  */
-static svn_error_t *
-get_node_revision(svn_fs_x__noderev_t **noderev_p,
-                  dag_node_t *node)
-{
-  /* If we've already got a copy, there's no need to read it in.  */
-  if (! node->node_revision)
-    {
-      svn_fs_x__noderev_t *noderev;
-      apr_pool_t *scratch_pool = svn_pool_create(node->node_pool);
-
-      SVN_ERR(svn_fs_x__get_node_revision(&noderev, node->fs, &node->id,
-                                          node->node_pool, scratch_pool));
-      node->node_revision = noderev;
-      svn_pool_destroy(scratch_pool);
-    }
-
-  /* Now NODE->node_revision is set.  */
-  *noderev_p = node->node_revision;
-  return SVN_NO_ERROR;
-}
-
-/* Return the node revision ID of NODE.  The value returned is shared
-   with NODE, and will be deallocated when NODE is.  */
-svn_error_t *
-svn_fs_x__dag_get_node_id(svn_fs_x__id_t *node_id,
-                          dag_node_t *node)
+const svn_fs_x__id_t *
+svn_fs_x__dag_get_node_id(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-  SVN_ERR(get_node_revision(&noderev, node));
-
-  *node_id = noderev->node_id;
-  return SVN_NO_ERROR;
+  return &node->node_revision->node_id;
 }
 
-/* Return the node revision ID of NODE.  The value returned is shared
-   with NODE, and will be deallocated when NODE is.  */
-svn_error_t *
-svn_fs_x__dag_get_copy_id(svn_fs_x__id_t *copy_id,
-                          dag_node_t *node)
+const svn_fs_x__id_t *
+svn_fs_x__dag_get_copy_id(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-  SVN_ERR(get_node_revision(&noderev, node));
-
-  *copy_id = noderev->copy_id;
-  return SVN_NO_ERROR;
+  return &node->node_revision->copy_id;
 }
 
-/* Return the node ID of NODE.  The value returned is shared with NODE,
-   and will be deallocated when NODE is.  */
-svn_error_t *
-svn_fs_x__dag_related_node(svn_boolean_t *same,
-                           dag_node_t *lhs,
+svn_boolean_t
+svn_fs_x__dag_related_node(dag_node_t *lhs,
                            dag_node_t *rhs)
 {
-  svn_fs_x__id_t lhs_node, rhs_node;
-
-  SVN_ERR(svn_fs_x__dag_get_node_id(&lhs_node, lhs));
-  SVN_ERR(svn_fs_x__dag_get_node_id(&rhs_node, rhs));
-  *same = svn_fs_x__id_eq(&lhs_node, &rhs_node);
-
-  return SVN_NO_ERROR;
+  return svn_fs_x__id_eq(&lhs->node_revision->node_id,
+                         &rhs->node_revision->node_id);
 }
 
-svn_error_t *
-svn_fs_x__dag_same_line_of_history(svn_boolean_t *same,
-                                   dag_node_t *lhs,
+svn_boolean_t
+svn_fs_x__dag_same_line_of_history(dag_node_t *lhs,
                                    dag_node_t *rhs)
 {
-  svn_fs_x__noderev_t *lhs_noderev, *rhs_noderev;
-
-  SVN_ERR(get_node_revision(&lhs_noderev, lhs));
-  SVN_ERR(get_node_revision(&rhs_noderev, rhs));
-
-  *same = svn_fs_x__id_eq(&lhs_noderev->node_id, &rhs_noderev->node_id)
-       && svn_fs_x__id_eq(&lhs_noderev->copy_id, &rhs_noderev->copy_id);
+  svn_fs_x__noderev_t *lhs_noderev = lhs->node_revision;
+  svn_fs_x__noderev_t *rhs_noderev = rhs->node_revision;
 
-  return SVN_NO_ERROR;
+  return svn_fs_x__id_eq(&lhs_noderev->node_id, &rhs_noderev->node_id)
+      && svn_fs_x__id_eq(&lhs_noderev->copy_id, &rhs_noderev->copy_id);
 }
 
 svn_boolean_t
@@ -240,7 +160,6 @@ svn_fs_x__dag_check_mutable(const dag_no
   return svn_fs_x__is_txn(svn_fs_x__dag_get_id(node)->change_set);
 }
 
-
 svn_error_t *
 svn_fs_x__dag_get_node(dag_node_t **node,
                        svn_fs_t *fs,
@@ -254,7 +173,6 @@ svn_fs_x__dag_get_node(dag_node_t **node
   /* Construct the node. */
   new_node = apr_pcalloc(result_pool, sizeof(*new_node));
   new_node->fs = fs;
-  new_node->id = *id;
   new_node->hint = APR_SIZE_MAX;
 
   /* Grab the contents so we can inspect the node's kind and created path. */
@@ -263,17 +181,6 @@ svn_fs_x__dag_get_node(dag_node_t **node
   new_node->node_pool = result_pool;
   new_node->node_revision = noderev;
 
-  /* Initialize the KIND and CREATED_PATH attributes */
-  new_node->kind = noderev->kind;
-  new_node->created_path = noderev->created_path;
-
-  /* Support our quirky svn_fs_node_created_rev API.
-     Untouched txn roots report the base rev as theirs. */
-  new_node->revision
-    = (  svn_fs_x__is_fresh_txn_root(noderev)
-       ? svn_fs_x__get_revnum(noderev->predecessor_id.change_set)
-       : svn_fs_x__get_revnum(id->change_set));
-
   /* Return a fresh new node */
   *node = new_node;
   return SVN_NO_ERROR;
@@ -283,76 +190,50 @@ svn_fs_x__dag_get_node(dag_node_t **node
 svn_revnum_t
 svn_fs_x__dag_get_revision(const dag_node_t *node)
 {
-  return node->revision;
+  svn_fs_x__noderev_t *noderev = node->node_revision;
+  return (  svn_fs_x__is_fresh_txn_root(noderev)
+          ? svn_fs_x__get_revnum(noderev->predecessor_id.change_set)
+          : svn_fs_x__get_revnum(noderev->noderev_id.change_set));
 }
 
-
-svn_error_t *
-svn_fs_x__dag_get_predecessor_id(svn_fs_x__id_t *id_p,
-                                 dag_node_t *node)
+const svn_fs_x__id_t *
+svn_fs_x__dag_get_predecessor_id(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  SVN_ERR(get_node_revision(&noderev, node));
-  *id_p = noderev->predecessor_id;
-
-  return SVN_NO_ERROR;
+  return &node->node_revision->predecessor_id;
 }
 
-
-svn_error_t *
-svn_fs_x__dag_get_predecessor_count(int *count,
-                                    dag_node_t *node)
+int
+svn_fs_x__dag_get_predecessor_count(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  SVN_ERR(get_node_revision(&noderev, node));
-  *count = noderev->predecessor_count;
-  return SVN_NO_ERROR;
+  return node->node_revision->predecessor_count;
 }
 
-svn_error_t *
-svn_fs_x__dag_get_mergeinfo_count(apr_int64_t *count,
-                                  dag_node_t *node)
+apr_int64_t
+svn_fs_x__dag_get_mergeinfo_count(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  SVN_ERR(get_node_revision(&noderev, node));
-  *count = noderev->mergeinfo_count;
-  return SVN_NO_ERROR;
+  return node->node_revision->mergeinfo_count;
 }
 
-svn_error_t *
-svn_fs_x__dag_has_mergeinfo(svn_boolean_t *has_mergeinfo,
-                            dag_node_t *node)
+svn_boolean_t
+svn_fs_x__dag_has_mergeinfo(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  SVN_ERR(get_node_revision(&noderev, node));
-  *has_mergeinfo = noderev->has_mergeinfo;
-  return SVN_NO_ERROR;
+  return node->node_revision->has_mergeinfo;
 }
 
-svn_error_t *
-svn_fs_x__dag_has_descendants_with_mergeinfo(svn_boolean_t *do_they,
-                                             dag_node_t *node)
+svn_boolean_t
+svn_fs_x__dag_has_descendants_with_mergeinfo(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
+  svn_fs_x__noderev_t *noderev = node->node_revision;
 
-  if (node->kind != svn_node_dir)
-    {
-      *do_they = FALSE;
-      return SVN_NO_ERROR;
-    }
+  if (noderev->kind != svn_node_dir)
+      return FALSE;
 
-  SVN_ERR(get_node_revision(&noderev, node));
   if (noderev->mergeinfo_count > 1)
-    *do_they = TRUE;
+    return TRUE;
   else if (noderev->mergeinfo_count == 1 && !noderev->has_mergeinfo)
-    *do_they = TRUE;
-  else
-    *do_they = FALSE;
-  return SVN_NO_ERROR;
+    return TRUE;
+
+  return FALSE;
 }
 
 
@@ -362,16 +243,15 @@ svn_fs_x__dag_has_descendants_with_merge
 
 /* Set *ID_P to the noderev-id for entry NAME in PARENT.  If no such
    entry, set *ID_P to NULL but do not error. */
-static svn_error_t *
-dir_entry_id_from_node(svn_fs_x__id_t *id_p,
+svn_error_t *
+svn_fs_x__dir_entry_id(svn_fs_x__id_t *id_p,
                        dag_node_t *parent,
                        const char *name,
                        apr_pool_t *scratch_pool)
 {
   svn_fs_x__dirent_t *dirent;
-  svn_fs_x__noderev_t *noderev;
+  svn_fs_x__noderev_t *noderev = parent->node_revision;
 
-  SVN_ERR(get_node_revision(&noderev, parent));
   if (noderev->kind != svn_node_dir)
     return svn_error_create(SVN_ERR_FS_NOT_DIRECTORY, NULL,
                             _("Can't get entries of non-directory"));
@@ -411,14 +291,16 @@ set_entry(dag_node_t *parent,
           svn_fs_x__txn_id_t txn_id,
           apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *parent_noderev;
-
-  /* Get the parent's node-revision. */
-  SVN_ERR(get_node_revision(&parent_noderev, parent));
+  svn_fs_x__noderev_t *parent_noderev = parent->node_revision;
 
   /* Set the new entry. */
-  return svn_fs_x__set_entry(parent->fs, txn_id, parent_noderev, name, id,
-                             kind, parent->node_pool, scratch_pool);
+  SVN_ERR(svn_fs_x__set_entry(parent->fs, txn_id, parent_noderev, name, id,
+                              kind, parent->node_pool, scratch_pool));
+
+  /* Update cached data. */
+  svn_fs_x__update_dag_cache(parent);
+
+  return SVN_NO_ERROR;
 }
 
 
@@ -439,7 +321,8 @@ make_entry(dag_node_t **child_p,
            apr_pool_t *result_pool,
            apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t new_noderev, *parent_noderev;
+  svn_fs_x__noderev_t new_noderev;
+  svn_fs_x__noderev_t *parent_noderev = parent->node_revision;
 
   /* Make sure that NAME is a single path component. */
   if (! svn_path_is_single_path_component(name))
@@ -448,7 +331,7 @@ make_entry(dag_node_t **child_p,
        _("Attempted to create a node with an illegal name '%s'"), name);
 
   /* Make sure that parent is a directory */
-  if (parent->kind != svn_node_dir)
+  if (parent_noderev->kind != svn_node_dir)
     return svn_error_create
       (SVN_ERR_FS_NOT_DIRECTORY, NULL,
        _("Attempted to create entry in non-directory parent"));
@@ -464,7 +347,6 @@ make_entry(dag_node_t **child_p,
   new_noderev.kind = is_dir ? svn_node_dir : svn_node_file;
   new_noderev.created_path = svn_fspath__join(parent_path, name, result_pool);
 
-  SVN_ERR(get_node_revision(&parent_noderev, parent));
   new_noderev.copyroot_path = apr_pstrdup(result_pool,
                                           parent_noderev->copyroot_path);
   new_noderev.copyroot_rev = parent_noderev->copyroot_rev;
@@ -495,9 +377,7 @@ svn_fs_x__dag_dir_entries(apr_array_head
                           apr_pool_t *result_pool,
                           apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  SVN_ERR(get_node_revision(&noderev, node));
+  svn_fs_x__noderev_t *noderev = node->node_revision;
 
   if (noderev->kind != svn_node_dir)
     return svn_error_create(SVN_ERR_FS_NOT_DIRECTORY, NULL,
@@ -517,7 +397,7 @@ svn_fs_x__dag_set_entry(dag_node_t *node
                         apr_pool_t *scratch_pool)
 {
   /* Check it's a directory. */
-  if (node->kind != svn_node_dir)
+  if (node->node_revision->kind != svn_node_dir)
     return svn_error_create
       (SVN_ERR_FS_NOT_DIRECTORY, NULL,
        _("Attempted to set entry in non-directory node"));
@@ -541,16 +421,8 @@ svn_fs_x__dag_get_proplist(apr_hash_t **
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-  apr_hash_t *proplist = NULL;
-
-  SVN_ERR(get_node_revision(&noderev, node));
-
-  SVN_ERR(svn_fs_x__get_proplist(&proplist, node->fs, noderev, result_pool,
-                                 scratch_pool));
-
-  *proplist_p = proplist;
-
+  SVN_ERR(svn_fs_x__get_proplist(proplist_p, node->fs, node->node_revision,
+                                 result_pool, scratch_pool));
   return SVN_NO_ERROR;
 }
 
@@ -560,37 +432,51 @@ svn_fs_x__dag_set_proplist(dag_node_t *n
                            apr_hash_t *proplist,
                            apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-
   /* Sanity check: this node better be mutable! */
   if (! svn_fs_x__dag_check_mutable(node))
     {
-      svn_string_t *idstr = svn_fs_x__id_unparse(&node->id, scratch_pool);
+      svn_string_t *idstr
+        = svn_fs_x__id_unparse(&node->node_revision->noderev_id,
+                               scratch_pool);
       return svn_error_createf
         (SVN_ERR_FS_NOT_MUTABLE, NULL,
          "Can't set proplist on *immutable* node-revision %s",
          idstr->data);
     }
 
-  /* Go get a fresh NODE-REVISION for this node. */
-  SVN_ERR(get_node_revision(&noderev, node));
-
   /* Set the new proplist. */
-  return svn_fs_x__set_proplist(node->fs, noderev, proplist, scratch_pool);
+  SVN_ERR(svn_fs_x__set_proplist(node->fs, node->node_revision, proplist,
+                                 scratch_pool));
+  svn_fs_x__update_dag_cache(node);
+
+  return SVN_NO_ERROR;
 }
 
+/* Write NODE's NODEREV element to disk.  Update the DAG cache.
+   Use SCRATCH_POOL for temporary allocations. */
+static svn_error_t *
+noderev_changed(dag_node_t *node,
+                apr_pool_t *scratch_pool)
+{
+  SVN_ERR(svn_fs_x__put_node_revision(node->fs, node->node_revision,
+                                      scratch_pool));
+  svn_fs_x__update_dag_cache(node);
+
+  return SVN_NO_ERROR;
+}
 
 svn_error_t *
 svn_fs_x__dag_increment_mergeinfo_count(dag_node_t *node,
                                         apr_int64_t increment,
                                         apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *noderev;
+  svn_fs_x__noderev_t *noderev = node->node_revision;
 
   /* Sanity check: this node better be mutable! */
   if (! svn_fs_x__dag_check_mutable(node))
     {
-      svn_string_t *idstr = svn_fs_x__id_unparse(&node->id, scratch_pool);
+      svn_string_t *idstr = svn_fs_x__id_unparse(&noderev->noderev_id,
+                                                 scratch_pool);
       return svn_error_createf
         (SVN_ERR_FS_NOT_MUTABLE, NULL,
          "Can't increment mergeinfo count on *immutable* node-revision %s",
@@ -600,13 +486,11 @@ svn_fs_x__dag_increment_mergeinfo_count(
   if (increment == 0)
     return SVN_NO_ERROR;
 
-  /* Go get a fresh NODE-REVISION for this node. */
-  SVN_ERR(get_node_revision(&noderev, node));
-
   noderev->mergeinfo_count += increment;
   if (noderev->mergeinfo_count < 0)
     {
-      svn_string_t *idstr = svn_fs_x__id_unparse(&node->id, scratch_pool);
+      svn_string_t *idstr = svn_fs_x__id_unparse(&noderev->noderev_id,
+                                                 scratch_pool);
       return svn_error_createf
         (SVN_ERR_FS_CORRUPT, NULL,
          apr_psprintf(scratch_pool,
@@ -617,7 +501,8 @@ svn_fs_x__dag_increment_mergeinfo_count(
     }
   if (noderev->mergeinfo_count > 1 && noderev->kind == svn_node_file)
     {
-      svn_string_t *idstr = svn_fs_x__id_unparse(&node->id, scratch_pool);
+      svn_string_t *idstr = svn_fs_x__id_unparse(&noderev->noderev_id,
+                                                 scratch_pool);
       return svn_error_createf
         (SVN_ERR_FS_CORRUPT, NULL,
          apr_psprintf(scratch_pool,
@@ -628,7 +513,7 @@ svn_fs_x__dag_increment_mergeinfo_count(
     }
 
   /* Flush it out. */
-  return svn_fs_x__put_node_revision(node->fs, noderev, scratch_pool);
+  return noderev_changed(node, scratch_pool);
 }
 
 svn_error_t *
@@ -636,55 +521,38 @@ svn_fs_x__dag_set_has_mergeinfo(dag_node
                                 svn_boolean_t has_mergeinfo,
                                 apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-
   /* Sanity check: this node better be mutable! */
   if (! svn_fs_x__dag_check_mutable(node))
     {
-      svn_string_t *idstr = svn_fs_x__id_unparse(&node->id, scratch_pool);
+      svn_string_t *idstr
+        = svn_fs_x__id_unparse(&node->node_revision->noderev_id,
+                               scratch_pool);
       return svn_error_createf
         (SVN_ERR_FS_NOT_MUTABLE, NULL,
          "Can't set mergeinfo flag on *immutable* node-revision %s",
          idstr->data);
     }
 
-  /* Go get a fresh NODE-REVISION for this node. */
-  SVN_ERR(get_node_revision(&noderev, node));
-
-  noderev->has_mergeinfo = has_mergeinfo;
+  node->node_revision->has_mergeinfo = has_mergeinfo;
 
   /* Flush it out. */
-  return svn_fs_x__put_node_revision(node->fs, noderev, scratch_pool);
+  return noderev_changed(node, scratch_pool);
 }
 
 
 /*** Roots. ***/
 
 svn_error_t *
-svn_fs_x__dag_revision_root(dag_node_t **node_p,
-                            svn_fs_t *fs,
-                            svn_revnum_t rev,
-                            apr_pool_t *result_pool,
-                            apr_pool_t *scratch_pool)
-{
-  svn_fs_x__id_t root_id;
-
-  svn_fs_x__init_rev_root(&root_id, rev);
-  return svn_fs_x__dag_get_node(node_p, fs, &root_id, result_pool,
-                                scratch_pool);
-}
-
-
-svn_error_t *
-svn_fs_x__dag_txn_root(dag_node_t **node_p,
-                       svn_fs_t *fs,
-                       svn_fs_x__txn_id_t txn_id,
-                       apr_pool_t *result_pool,
-                       apr_pool_t *scratch_pool)
+svn_fs_x__dag_root(dag_node_t **node_p,
+                   svn_fs_t *fs,
+                   svn_fs_x__change_set_t change_set,
+                   apr_pool_t *result_pool,
+                   apr_pool_t *scratch_pool)
 {
   svn_fs_x__id_t root_id;
+  root_id.change_set = change_set;
+  root_id.number = SVN_FS_X__ITEM_INDEX_ROOT_NODE;
 
-  svn_fs_x__init_txn_root(&root_id, txn_id);
   return svn_fs_x__dag_get_node(node_p, fs, &root_id, result_pool,
                                 scratch_pool);
 }
@@ -734,14 +602,11 @@ svn_fs_x__dag_clone_child(dag_node_t **c
     }
   else
     {
-      svn_fs_x__noderev_t *noderev, *parent_noderev;
-
-      /* Go get a fresh NODE-REVISION for current child node. */
-      SVN_ERR(get_node_revision(&noderev, cur_entry));
+      svn_fs_x__noderev_t *noderev = cur_entry->node_revision;
 
       if (is_parent_copyroot)
         {
-          SVN_ERR(get_node_revision(&parent_noderev, parent));
+          svn_fs_x__noderev_t *parent_noderev = parent->node_revision;
           noderev->copyroot_rev = parent_noderev->copyroot_rev;
           noderev->copyroot_path = apr_pstrdup(scratch_pool,
                                                parent_noderev->copyroot_path);
@@ -796,7 +661,7 @@ delete_if_mutable(svn_fs_t *fs,
     return SVN_NO_ERROR;
 
   /* Else it's mutable.  Recurse on directories... */
-  if (node->kind == svn_node_dir)
+  if (node->node_revision->kind == svn_node_dir)
     {
       apr_array_header_t *entries;
       int i;
@@ -829,13 +694,13 @@ svn_fs_x__dag_delete(dag_node_t *parent,
                      svn_fs_x__txn_id_t txn_id,
                      apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *parent_noderev;
+  svn_fs_x__noderev_t *parent_noderev = parent->node_revision;
   svn_fs_t *fs = parent->fs;
   svn_fs_x__dirent_t *dirent;
   apr_pool_t *subpool;
 
   /* Make sure parent is a directory. */
-  if (parent->kind != svn_node_dir)
+  if (parent_noderev->kind != svn_node_dir)
     return svn_error_createf
       (SVN_ERR_FS_NOT_DIRECTORY, NULL,
        "Attempted to delete entry '%s' from *non*-directory node", name);
@@ -852,9 +717,9 @@ svn_fs_x__dag_delete(dag_node_t *parent,
       (SVN_ERR_FS_NOT_SINGLE_PATH_COMPONENT, NULL,
        "Attempted to delete a node with an illegal name '%s'", name);
 
-  /* Get a fresh NODE-REVISION for the parent node. */
-  SVN_ERR(get_node_revision(&parent_noderev, parent));
-
+  /* We allocate a few potentially heavy temporary objects (file buffers
+     and directories).  Make sure we don't keep them around for longer
+     than necessary. */
   subpool = svn_pool_create(scratch_pool);
 
   /* Search this directory for a dirent with that NAME. */
@@ -871,13 +736,13 @@ svn_fs_x__dag_delete(dag_node_t *parent,
        "Delete failed--directory has no entry '%s'", name);
 
   /* If mutable, remove it and any mutable children from db. */
-  SVN_ERR(delete_if_mutable(parent->fs, &dirent->id, scratch_pool));
-  svn_pool_destroy(subpool);
+  SVN_ERR(delete_if_mutable(parent->fs, &dirent->id, subpool));
 
   /* Remove this entry from its parent's entries list. */
-  return svn_fs_x__set_entry(parent->fs, txn_id, parent_noderev, name,
-                             NULL, svn_node_unknown, parent->node_pool,
-                             scratch_pool);
+  SVN_ERR(set_entry(parent, name, NULL, svn_node_unknown, txn_id, subpool));
+
+  svn_pool_destroy(subpool);
+  return SVN_NO_ERROR;
 }
 
 
@@ -916,23 +781,16 @@ svn_fs_x__dag_get_contents(svn_stream_t
                            dag_node_t *file,
                            apr_pool_t *result_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-  svn_stream_t *contents;
-
   /* Make sure our node is a file. */
-  if (file->kind != svn_node_file)
+  if (file->node_revision->kind != svn_node_file)
     return svn_error_createf
       (SVN_ERR_FS_NOT_FILE, NULL,
        "Attempted to get textual contents of a *non*-file node");
 
-  /* Go get a fresh node-revision for FILE. */
-  SVN_ERR(get_node_revision(&noderev, file));
-
   /* Get a stream to the contents. */
-  SVN_ERR(svn_fs_x__get_contents(&contents, file->fs,
-                                 noderev->data_rep, TRUE, result_pool));
-
-  *contents_p = contents;
+  SVN_ERR(svn_fs_x__get_contents(contents_p, file->fs,
+                                 file->node_revision->data_rep, TRUE,
+                                 result_pool));
 
   return SVN_NO_ERROR;
 }
@@ -945,23 +803,16 @@ svn_fs_x__dag_get_file_delta_stream(svn_
                                     apr_pool_t *result_pool,
                                     apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *src_noderev;
-  svn_fs_x__noderev_t *tgt_noderev;
+  svn_fs_x__noderev_t *src_noderev = source ? source->node_revision : NULL;
+  svn_fs_x__noderev_t *tgt_noderev = target->node_revision;
 
   /* Make sure our nodes are files. */
-  if ((source && source->kind != svn_node_file)
-      || target->kind != svn_node_file)
+  if ((source && src_noderev->kind != svn_node_file)
+      || tgt_noderev->kind != svn_node_file)
     return svn_error_createf
       (SVN_ERR_FS_NOT_FILE, NULL,
        "Attempted to get textual contents of a *non*-file node");
 
-  /* Go get fresh node-revisions for the nodes. */
-  if (source)
-    SVN_ERR(get_node_revision(&src_noderev, source));
-  else
-    src_noderev = NULL;
-  SVN_ERR(get_node_revision(&tgt_noderev, target));
-
   /* Get the delta stream. */
   return svn_fs_x__get_file_delta_stream(stream_p, target->fs,
                                          src_noderev, tgt_noderev,
@@ -976,13 +827,8 @@ svn_fs_x__dag_try_process_file_contents(
                                         void* baton,
                                         apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  /* Go get fresh node-revisions for the nodes. */
-  SVN_ERR(get_node_revision(&noderev, node));
-
   return svn_fs_x__try_process_file_contents(success, node->fs,
-                                             noderev,
+                                             node->node_revision,
                                              processor, baton, scratch_pool);
 }
 
@@ -991,18 +837,13 @@ svn_error_t *
 svn_fs_x__dag_file_length(svn_filesize_t *length,
                           dag_node_t *file)
 {
-  svn_fs_x__noderev_t *noderev;
-
   /* Make sure our node is a file. */
-  if (file->kind != svn_node_file)
+  if (file->node_revision->kind != svn_node_file)
     return svn_error_createf
       (SVN_ERR_FS_NOT_FILE, NULL,
        "Attempted to get length of a *non*-file node");
 
-  /* Go get a fresh node-revision for FILE, and . */
-  SVN_ERR(get_node_revision(&noderev, file));
-
-  return svn_fs_x__file_length(length, noderev);
+  return svn_fs_x__file_length(length, file->node_revision);
 }
 
 
@@ -1012,16 +853,13 @@ svn_fs_x__dag_file_checksum(svn_checksum
                             svn_checksum_kind_t kind,
                             apr_pool_t *result_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  if (file->kind != svn_node_file)
+  if (file->node_revision->kind != svn_node_file)
     return svn_error_createf
       (SVN_ERR_FS_NOT_FILE, NULL,
        "Attempted to get checksum of a *non*-file node");
 
-  SVN_ERR(get_node_revision(&noderev, file));
-
-  return svn_fs_x__file_checksum(checksum, noderev, kind, result_pool);
+  return svn_fs_x__file_checksum(checksum, file->node_revision, kind,
+                                 result_pool);
 }
 
 
@@ -1030,11 +868,8 @@ svn_fs_x__dag_get_edit_stream(svn_stream
                               dag_node_t *file,
                               apr_pool_t *result_pool)
 {
-  svn_fs_x__noderev_t *noderev;
-  svn_stream_t *ws;
-
   /* Make sure our node is a file. */
-  if (file->kind != svn_node_file)
+  if (file->node_revision->kind != svn_node_file)
     return svn_error_createf
       (SVN_ERR_FS_NOT_FILE, NULL,
        "Attempted to set textual contents of a *non*-file node");
@@ -1045,13 +880,8 @@ svn_fs_x__dag_get_edit_stream(svn_stream
       (SVN_ERR_FS_NOT_MUTABLE, NULL,
        "Attempted to set textual contents of an immutable node");
 
-  /* Get the node revision. */
-  SVN_ERR(get_node_revision(&noderev, file));
-
-  SVN_ERR(svn_fs_x__set_contents(&ws, file->fs, noderev, result_pool));
-
-  *contents = ws;
-
+  SVN_ERR(svn_fs_x__set_contents(contents, file->fs, file->node_revision,
+                                 result_pool));
   return SVN_NO_ERROR;
 }
 
@@ -1072,9 +902,10 @@ svn_fs_x__dag_finalize_edits(dag_node_t
         return svn_checksum_mismatch_err(checksum, file_checksum,
                                          scratch_pool,
                                          _("Checksum mismatch for '%s'"),
-                                         file->created_path);
+                                         file->node_revision->created_path);
     }
 
+  svn_fs_x__update_dag_cache(file);
   return SVN_NO_ERROR;
 }
 
@@ -1086,101 +917,14 @@ svn_fs_x__dag_dup(const dag_node_t *node
   /* Allocate our new node. */
   dag_node_t *new_node = apr_pmemdup(result_pool, node, sizeof(*new_node));
 
-  /* Only copy cached svn_fs_x__noderev_t for immutable nodes. */
-  if (node->node_revision && !svn_fs_x__dag_check_mutable(node))
-    {
-      new_node->node_revision = copy_node_revision(node->node_revision,
-                                                   result_pool);
-      new_node->created_path = new_node->node_revision->created_path;
-    }
-  else
-    {
-      new_node->node_revision = NULL;
-      new_node->created_path = apr_pstrdup(result_pool, node->created_path);
-    }
-
+  /* Copy sub-structures. */
+  new_node->node_revision = copy_node_revision(node->node_revision,
+                                               result_pool);
   new_node->node_pool = result_pool;
 
   return new_node;
 }
 
-dag_node_t *
-svn_fs_x__dag_copy_into_pool(dag_node_t *node,
-                             apr_pool_t *result_pool)
-{
-  return (node->node_pool == result_pool
-            ? node
-            : svn_fs_x__dag_dup(node, result_pool));
-}
-
-svn_error_t *
-svn_fs_x__dag_serialize(void **data,
-                        apr_size_t *data_len,
-                        void *in,
-                        apr_pool_t *pool)
-{
-  dag_node_t *node = in;
-  svn_stringbuf_t *serialized;
-
-  /* create an serialization context and serialize the dag node as root */
-  svn_temp_serializer__context_t *context =
-      svn_temp_serializer__init(node,
-                                sizeof(*node),
-                                1024 - SVN_TEMP_SERIALIZER__OVERHEAD,
-                                pool);
-
-  /* for mutable nodes, we will _never_ cache the noderev */
-  if (node->node_revision && !svn_fs_x__dag_check_mutable(node))
-    {
-      svn_fs_x__noderev_serialize(context, &node->node_revision);
-    }
-  else
-    {
-      svn_temp_serializer__set_null(context,
-                                    (const void * const *)&node->node_revision);
-      svn_temp_serializer__add_string(context, &node->created_path);
-    }
-
-  /* The deserializer will use its own pool. */
-  svn_temp_serializer__set_null(context,
-                                (const void * const *)&node->node_pool);
-
-  /* return serialized data */
-  serialized = svn_temp_serializer__get(context);
-  *data = serialized->data;
-  *data_len = serialized->len;
-
-  return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_fs_x__dag_deserialize(void **out,
-                          void *data,
-                          apr_size_t data_len,
-                          apr_pool_t *pool)
-{
-  dag_node_t *node = (dag_node_t *)data;
-  if (data_len == 0)
-    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                            _("Empty noderev in cache"));
-
-  /* Copy the _full_ buffer as it also contains the sub-structures. */
-  node->fs = NULL;
-
-  /* fixup all references to sub-structures */
-  svn_fs_x__noderev_deserialize(node, &node->node_revision, pool);
-  node->node_pool = pool;
-
-  if (node->node_revision)
-    node->created_path = node->node_revision->created_path;
-  else
-    svn_temp_deserializer__resolve(node, (void**)&node->created_path);
-
-  /* return result */
-  *out = node;
-
-  return SVN_NO_ERROR;
-}
 
 svn_error_t *
 svn_fs_x__dag_open(dag_node_t **child_p,
@@ -1192,7 +936,7 @@ svn_fs_x__dag_open(dag_node_t **child_p,
   svn_fs_x__id_t node_id;
 
   /* Ensure that NAME exists in PARENT's entry list. */
-  SVN_ERR(dir_entry_id_from_node(&node_id, parent, name, scratch_pool));
+  SVN_ERR(svn_fs_x__dir_entry_id(&node_id, parent, name, scratch_pool));
   if (! svn_fs_x__id_used(&node_id))
     {
       *child_p = NULL;
@@ -1219,13 +963,12 @@ svn_fs_x__dag_copy(dag_node_t *to_node,
 
   if (preserve_history)
     {
-      svn_fs_x__noderev_t *from_noderev, *to_noderev;
+      svn_fs_x__noderev_t *to_noderev;
       svn_fs_x__id_t copy_id;
       svn_fs_t *fs = svn_fs_x__dag_get_fs(from_node);
 
       /* Make a copy of the original node revision. */
-      SVN_ERR(get_node_revision(&from_noderev, from_node));
-      to_noderev = copy_node_revision(from_noderev, scratch_pool);
+      to_noderev = copy_node_revision(from_node->node_revision, scratch_pool);
 
       /* Reserve a copy ID for this new copy. */
       SVN_ERR(svn_fs_x__reserve_copy_id(&copy_id, fs, txn_id, scratch_pool));
@@ -1253,7 +996,8 @@ svn_fs_x__dag_copy(dag_node_t *to_node,
     }
 
   /* Set the entry in to_node to the new id. */
-  return svn_fs_x__dag_set_entry(to_node, entry, id, from_node->kind,
+  return svn_fs_x__dag_set_entry(to_node, entry, id,
+                                 from_node->node_revision->kind,
                                  txn_id, scratch_pool);
 }
 
@@ -1269,7 +1013,8 @@ svn_fs_x__dag_things_different(svn_boole
                                svn_boolean_t strict,
                                apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *noderev1, *noderev2;
+  svn_fs_x__noderev_t *noderev1 = node1->node_revision;
+  svn_fs_x__noderev_t *noderev2 = node2->node_revision;
   svn_fs_t *fs;
   svn_boolean_t same;
 
@@ -1280,10 +1025,6 @@ svn_fs_x__dag_things_different(svn_boole
 
   fs = svn_fs_x__dag_get_fs(node1);
 
-  /* The node revision skels for these two nodes. */
-  SVN_ERR(get_node_revision(&noderev1, node1));
-  SVN_ERR(get_node_revision(&noderev2, node2));
-
   /* Compare property keys. */
   if (props_changed != NULL)
     {
@@ -1300,48 +1041,25 @@ svn_fs_x__dag_things_different(svn_boole
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
+void
 svn_fs_x__dag_get_copyroot(svn_revnum_t *rev,
                            const char **path,
                            dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  /* Go get a fresh node-revision for NODE. */
-  SVN_ERR(get_node_revision(&noderev, node));
-
-  *rev = noderev->copyroot_rev;
-  *path = noderev->copyroot_path;
-
-  return SVN_NO_ERROR;
+  *rev = node->node_revision->copyroot_rev;
+  *path = node->node_revision->copyroot_path;
 }
 
-svn_error_t *
-svn_fs_x__dag_get_copyfrom_rev(svn_revnum_t *rev,
-                               dag_node_t *node)
+svn_revnum_t
+svn_fs_x__dag_get_copyfrom_rev(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  /* Go get a fresh node-revision for NODE. */
-  SVN_ERR(get_node_revision(&noderev, node));
-
-  *rev = noderev->copyfrom_rev;
-
-  return SVN_NO_ERROR;
+  return node->node_revision->copyfrom_rev;
 }
 
-svn_error_t *
-svn_fs_x__dag_get_copyfrom_path(const char **path,
-                                dag_node_t *node)
+const char *
+svn_fs_x__dag_get_copyfrom_path(dag_node_t *node)
 {
-  svn_fs_x__noderev_t *noderev;
-
-  /* Go get a fresh node-revision for NODE. */
-  SVN_ERR(get_node_revision(&noderev, node));
-
-  *path = noderev->copyfrom_path;
-
-  return SVN_NO_ERROR;
+  return node->node_revision->copyfrom_path;
 }
 
 svn_error_t *
@@ -1349,20 +1067,17 @@ svn_fs_x__dag_update_ancestry(dag_node_t
                               dag_node_t *source,
                               apr_pool_t *scratch_pool)
 {
-  svn_fs_x__noderev_t *source_noderev, *target_noderev;
+  svn_fs_x__noderev_t *source_noderev = source->node_revision;
+  svn_fs_x__noderev_t *target_noderev = target->node_revision;
 
   if (! svn_fs_x__dag_check_mutable(target))
     return svn_error_createf
       (SVN_ERR_FS_NOT_MUTABLE, NULL,
        _("Attempted to update ancestry of non-mutable node"));
 
-  SVN_ERR(get_node_revision(&source_noderev, source));
-  SVN_ERR(get_node_revision(&target_noderev, target));
-
   target_noderev->predecessor_id = source_noderev->noderev_id;
   target_noderev->predecessor_count = source_noderev->predecessor_count;
   target_noderev->predecessor_count++;
 
-  return svn_fs_x__put_node_revision(target->fs, target_noderev,
-                                     scratch_pool);
+  return noderev_changed(target, scratch_pool);
 }

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.h
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.h?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.h (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/dag.h Fri Sep 11 15:51:30 2015
@@ -1,4 +1,4 @@
-/* dag.h : DAG-like interface filesystem, private to libsvn_fs
+/* dag.h : DAG-like interface filesystem
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -20,8 +20,8 @@
  * ====================================================================
  */
 
-#ifndef SVN_LIBSVN_FS_DAG_H
-#define SVN_LIBSVN_FS_DAG_H
+#ifndef SVN_LIBSVN_FS_X_DAG_H
+#define SVN_LIBSVN_FS_X_DAG_H
 
 #include "svn_fs.h"
 #include "svn_delta.h"
@@ -82,28 +82,6 @@ dag_node_t *
 svn_fs_x__dag_dup(const dag_node_t *node,
                   apr_pool_t *result_pool);
 
-/* If NODE has been allocated in POOL, return NODE.  Otherwise, return
-   a copy created in RESULT_POOL with svn_fs_fs__dag_dup. */
-dag_node_t *
-svn_fs_x__dag_copy_into_pool(dag_node_t *node,
-                             apr_pool_t *result_pool);
-
-/* Serialize a DAG node, except don't try to preserve the 'fs' member.
-   Implements svn_cache__serialize_func_t */
-svn_error_t *
-svn_fs_x__dag_serialize(void **data,
-                        apr_size_t *data_len,
-                        void *in,
-                        apr_pool_t *pool);
-
-/* Deserialize a DAG node, leaving the 'fs' member as NULL.
-   Implements svn_cache__deserialize_func_t */
-svn_error_t *
-svn_fs_x__dag_deserialize(void **out,
-                          void *data,
-                          apr_size_t data_len,
-                          apr_pool_t *pool);
-
 /* Return the filesystem containing NODE.  */
 svn_fs_t *
 svn_fs_x__dag_get_fs(dag_node_t *node);
@@ -128,27 +106,23 @@ svn_fs_x__dag_get_id(const dag_node_t *n
 
 /* Return the node ID of NODE.  The value returned is shared with NODE,
    and will be deallocated when NODE is.  */
-svn_error_t *
-svn_fs_x__dag_get_node_id(svn_fs_x__id_t *node_id,
-                          dag_node_t *node);
+const svn_fs_x__id_t *
+svn_fs_x__dag_get_node_id(dag_node_t *node);
 
 /* Return the copy ID of NODE.  The value returned is shared with NODE,
    and will be deallocated when NODE is.  */
-svn_error_t *
-svn_fs_x__dag_get_copy_id(svn_fs_x__id_t *copy_id,
-                          dag_node_t *node);
+const svn_fs_x__id_t *
+svn_fs_x__dag_get_copy_id(dag_node_t *node);
 
-/* Set *SAME to TRUE, if nodes LHS and RHS have the same node ID. */
-svn_error_t *
-svn_fs_x__dag_related_node(svn_boolean_t *same,
-                           dag_node_t *lhs,
+/* Return TRUE, iff nodes LHS and RHS have the same node ID. */
+svn_boolean_t
+svn_fs_x__dag_related_node(dag_node_t *lhs,
                            dag_node_t *rhs);
 
-/* Set *SAME to TRUE, if nodes LHS and RHS have the same node and copy IDs.
+/* Return TRUE, iff nodes LHS and RHS have the same node and copy IDs.
  */
-svn_error_t *
-svn_fs_x__dag_same_line_of_history(svn_boolean_t *same,
-                                   dag_node_t *lhs,
+svn_boolean_t
+svn_fs_x__dag_same_line_of_history(dag_node_t *lhs,
                                    dag_node_t *rhs);
 
 /* Return the created path of NODE.  The value returned is shared
@@ -157,41 +131,31 @@ const char *
 svn_fs_x__dag_get_created_path(dag_node_t *node);
 
 
-/* Set *ID_P to the node revision ID of NODE's immediate predecessor.
+/* Return the node revision ID of NODE's immediate predecessor.
  */
-svn_error_t *
-svn_fs_x__dag_get_predecessor_id(svn_fs_x__id_t *id_p,
-                                 dag_node_t *node);
-
+const svn_fs_x__id_t *
+svn_fs_x__dag_get_predecessor_id(dag_node_t *node);
 
-/* Set *COUNT to the number of predecessors NODE has (recursively).
+/* Return the number of predecessors NODE has (recursively).
  */
-/* ### This function is currently only used by 'verify'. */
-svn_error_t *
-svn_fs_x__dag_get_predecessor_count(int *count,
-                                    dag_node_t *node);
+int
+svn_fs_x__dag_get_predecessor_count(dag_node_t *node);
 
-/* Set *COUNT to the number of node under NODE (inclusive) with
-   svn:mergeinfo properties.
+/* Return the number of node under NODE (inclusive) with svn:mergeinfo
+   properties.
  */
-svn_error_t *
-svn_fs_x__dag_get_mergeinfo_count(apr_int64_t *count,
-                                  dag_node_t *node);
+apr_int64_t
+svn_fs_x__dag_get_mergeinfo_count(dag_node_t *node);
 
-/* Set *DO_THEY to a flag indicating whether or not NODE is a
-   directory with at least one descendant (not including itself) with
-   svn:mergeinfo.
+/* Return TRUE, iff NODE is a directory with at least one descendant (not
+   including itself) with svn:mergeinfo.
  */
-svn_error_t *
-svn_fs_x__dag_has_descendants_with_mergeinfo(svn_boolean_t *do_they,
-                                             dag_node_t *node);
+svn_boolean_t
+svn_fs_x__dag_has_descendants_with_mergeinfo(dag_node_t *node);
 
-/* Set *HAS_MERGEINFO to a flag indicating whether or not NODE itself
-   has svn:mergeinfo set on it.
- */
-svn_error_t *
-svn_fs_x__dag_has_mergeinfo(svn_boolean_t *has_mergeinfo,
-                            dag_node_t *node);
+/* Return TRUE, iff NODE itself has svn:mergeinfo set on it.  */
+svn_boolean_t
+svn_fs_x__dag_has_mergeinfo(dag_node_t *node);
 
 /* Return non-zero IFF NODE is currently mutable. */
 svn_boolean_t
@@ -252,25 +216,15 @@ svn_fs_x__dag_set_has_mergeinfo(dag_node
 /* Revision and transaction roots.  */
 
 
-/* Open the root of revision REV of filesystem FS, allocating from
+/* Open the root of change set CHANGE_SET of filesystem FS, allocating from
    RESULT_POOL.  Set *NODE_P to the new node.  Use SCRATCH_POOL for
    temporary allocations.*/
 svn_error_t *
-svn_fs_x__dag_revision_root(dag_node_t **node_p,
-                            svn_fs_t *fs,
-                            svn_revnum_t rev,
-                            apr_pool_t *result_pool,
-                            apr_pool_t *scratch_pool);
-
-
-/* Set *NODE_P to the root of transaction TXN_ID in FS, allocating
-   from RESULT_POOL.  Use SCRATCH_POOL for temporary allocations. */
-svn_error_t *
-svn_fs_x__dag_txn_root(dag_node_t **node_p,
-                       svn_fs_t *fs,
-                       svn_fs_x__txn_id_t txn_id,
-                       apr_pool_t *result_pool,
-                       apr_pool_t *scratch_pool);
+svn_fs_x__dag_root(dag_node_t **node_p,
+                   svn_fs_t *fs,
+                   svn_fs_x__change_set_t change_set,
+                   apr_pool_t *result_pool,
+                   apr_pool_t *scratch_pool);
 
 
 /* Directories.  */
@@ -289,6 +243,14 @@ svn_fs_x__dag_open(dag_node_t **child_p,
                    apr_pool_t *scratch_pool);
 
 
+/* Set *ID_P to the noderev-id for entry NAME in PARENT.  If no such
+   entry exists, set *ID_P to "unused" but do not error. */
+svn_error_t *
+svn_fs_x__dir_entry_id(svn_fs_x__id_t *id_p,
+                       dag_node_t *parent,
+                       const char *name,
+                       apr_pool_t *scratch_pool);
+
 /* Set *ENTRIES_P to an array of NODE's entries, sorted by entry names,
    and the values are svn_fs_x__dirent_t. The returned table (and elements)
    is allocated in RESULT_POOL, temporaries in SCRATCH_POOL. */
@@ -548,22 +510,20 @@ svn_fs_x__dag_things_different(svn_boole
 /* Set *REV and *PATH to the copyroot revision and path of node NODE, or
    to SVN_INVALID_REVNUM and NULL if no copyroot exists.
  */
-svn_error_t *
+void
 svn_fs_x__dag_get_copyroot(svn_revnum_t *rev,
                            const char **path,
                            dag_node_t *node);
 
-/* Set *REV to the copyfrom revision associated with NODE.
+/* Return the copyfrom revision associated with NODE.
  */
-svn_error_t *
-svn_fs_x__dag_get_copyfrom_rev(svn_revnum_t *rev,
-                               dag_node_t *node);
+svn_revnum_t
+svn_fs_x__dag_get_copyfrom_rev(dag_node_t *node);
 
-/* Set *PATH to the copyfrom path associated with NODE.
+/* Return the copyfrom path associated with NODE.
  */
-svn_error_t *
-svn_fs_x__dag_get_copyfrom_path(const char **path,
-                                dag_node_t *node);
+const char *
+svn_fs_x__dag_get_copyfrom_path(dag_node_t *node);
 
 /* Update *TARGET so that SOURCE is it's predecessor.
 
@@ -577,4 +537,4 @@ svn_fs_x__dag_update_ancestry(dag_node_t
 }
 #endif /* __cplusplus */
 
-#endif /* SVN_LIBSVN_FS_DAG_H */
+#endif /* SVN_LIBSVN_FS_X_DAG_H */

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.c?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.c (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.c Fri Sep 11 15:51:30 2015
@@ -32,6 +32,7 @@
 #include "svn_delta.h"
 #include "svn_version.h"
 #include "svn_pools.h"
+#include "batch_fsync.h"
 #include "fs.h"
 #include "fs_x.h"
 #include "pack.h"
@@ -663,6 +664,8 @@ svn_fs_x__init(const svn_version_t *load
                              loader_version->major);
   SVN_ERR(svn_ver_check_list2(x_version(), checklist, svn_ver_equal));
 
+  SVN_ERR(svn_fs_x__batch_fsync_init());
+
   *vtable = &library_vtable;
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.h?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.h (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs.h Fri Sep 11 15:51:30 2015
@@ -1,4 +1,4 @@
-/* fs.h : interface to Subversion filesystem, private to libsvn_fs
+/* fs.h : interface to Subversion filesystem
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -20,8 +20,8 @@
  * ====================================================================
  */
 
-#ifndef SVN_LIBSVN_FS_X_H
-#define SVN_LIBSVN_FS_X_H
+#ifndef SVN_LIBSVN_FS_X_FS_H
+#define SVN_LIBSVN_FS_X_FS_H
 
 #include <apr_pools.h>
 #include <apr_hash.h>
@@ -53,14 +53,14 @@ extern "C" {
 #define PATH_FORMAT           "format"           /* Contains format number */
 #define PATH_UUID             "uuid"             /* Contains UUID */
 #define PATH_CURRENT          "current"          /* Youngest revision */
+#define PATH_NEXT             "next"             /* Revision begin written. */
 #define PATH_LOCK_FILE        "write-lock"       /* Revision lock file */
 #define PATH_PACK_LOCK_FILE   "pack-lock"        /* Pack lock file */
 #define PATH_REVS_DIR         "revs"             /* Directory of revisions */
-#define PATH_REVPROPS_DIR     "revprops"         /* Directory of revprops */
 #define PATH_TXNS_DIR         "transactions"     /* Directory of transactions */
-#define PATH_NODE_ORIGINS_DIR "node-origins"     /* Lazy node-origin cache */
 #define PATH_TXN_PROTOS_DIR   "txn-protorevs"    /* Directory of proto-revs */
 #define PATH_TXN_CURRENT      "txn-current"      /* File with next txn key */
+#define PATH_TXN_NEXT         "txn-next"         /* Will become txn-current */
 #define PATH_TXN_CURRENT_LOCK "txn-current-lock" /* Lock for txn-current */
 #define PATH_LOCKS_DIR        "locks"            /* Directory of locks */
 #define PATH_MIN_UNPACKED_REV "min-unpacked-rev" /* Oldest revision which
@@ -81,8 +81,6 @@ extern "C" {
 /* Names of special files and file extensions for transactions */
 #define PATH_CHANGES       "changes"       /* Records changes made so far */
 #define PATH_TXN_PROPS     "props"         /* Transaction properties */
-#define PATH_TXN_PROPS_FINAL "props-final" /* Final transaction properties
-                                              before moving to revprops */
 #define PATH_NEXT_IDS      "next-ids"      /* Next temporary ID assignments */
 #define PATH_PREFIX_NODE   "node."         /* Prefix for node filename */
 #define PATH_EXT_TXN       ".txn"          /* Extension of txn dir */
@@ -124,7 +122,11 @@ extern "C" {
    Note: If you bump this, please update the switch statement in
          svn_fs_x__create() as well.
  */
-#define SVN_FS_X__FORMAT_NUMBER   1
+#define SVN_FS_X__FORMAT_NUMBER   2
+
+/* Latest experimental format number.  Experimental formats are only
+   compatible with themselves. */
+#define SVN_FS_X__EXPERIMENTAL_FORMAT_NUMBER   2
 
 /* On most operating systems apr implements file locks per process, not
    per file.  On Windows apr implements the locking as per file handle
@@ -179,11 +181,15 @@ typedef struct svn_fs_x__shared_data_t
      declaration here.  Any subset may be acquired and held at any given
      time but their relative acquisition order must not change.
 
-     (lock 'txn-current' before 'pack' before 'write' before 'txn-list') */
+     (lock 'pack' before 'write' before 'txn-current' before 'txn-list') */
 
   /* A lock for intra-process synchronization when accessing the TXNS list. */
   svn_mutex__t *txn_list_lock;
 
+  /* A lock for intra-process synchronization when locking the
+     txn-current file. */
+  svn_mutex__t *txn_current_lock;
+
   /* A lock for intra-process synchronization when grabbing the
      repository write lock. */
   svn_mutex__t *fs_write_lock;
@@ -192,10 +198,6 @@ typedef struct svn_fs_x__shared_data_t
      repository pack operation lock. */
   svn_mutex__t *fs_pack_lock;
 
-  /* A lock for intra-process synchronization when locking the
-     txn-current file. */
-  svn_mutex__t *txn_current_lock;
-
   /* The common pool, under which this object is allocated, subpools
      of which are used to allocate the transaction objects. */
   apr_pool_t *common_pool;
@@ -281,13 +283,9 @@ typedef struct svn_fs_x__data_t
      e.g. memcached may be ignored as caching is an optional feature. */
   svn_boolean_t fail_stop;
 
-  /* Caches native dag_node_t* instances and acts as a 1st level cache */
+  /* Caches native dag_node_t* instances */
   svn_fs_x__dag_cache_t *dag_node_cache;
 
-  /* DAG node cache for immutable nodes.  Maps (revision, fspath)
-     to (dag_node_t *). This is the 2nd level cache for DAG nodes. */
-  svn_cache__t *rev_node_cache;
-
   /* A cache of the contents of immutable directories; maps from
      unparsed FS ID to a apr_hash_t * mapping (const char *) dirent
      names to (svn_fs_x__dirent_t *). */
@@ -307,12 +305,6 @@ typedef struct svn_fs_x__data_t
   /* Node properties cache.  Maps from rep key to apr_hash_t. */
   svn_cache__t *properties_cache;
 
-  /* Pack manifest cache; a cache mapping (svn_revnum_t) shard number to
-     a manifest; and a manifest is a mapping from (svn_revnum_t) revision
-     number offset within a shard to (apr_off_t) byte-offset in the
-     respective pack file. */
-  svn_cache__t *packed_offset_cache;
-
   /* Cache for txdelta_window_t objects;
    * the key is svn_fs_x__window_cache_key_t */
   svn_cache__t *txdelta_window_cache;
@@ -345,15 +337,6 @@ typedef struct svn_fs_x__data_t
      (revision, item index) pair */
   svn_cache__t *rep_header_cache;
 
-  /* Cache for svn_mergeinfo_t objects; the key is a combination of
-     revision, inheritance flags and path. */
-  svn_cache__t *mergeinfo_cache;
-
-  /* Cache for presence of svn_mergeinfo_t on a noderev; the key is a
-     combination of revision, inheritance flags and path; value is "1"
-     if the node has mergeinfo, "0" if it doesn't. */
-  svn_cache__t *mergeinfo_existence_cache;
-
   /* Cache for l2p_header_t objects; the key is (revision, is-packed).
      Will be NULL for pre-format7 repos */
   svn_cache__t *l2p_header_cache;
@@ -420,6 +403,10 @@ typedef struct svn_fs_x__data_t
   /* Pointer to svn_fs_open. */
   svn_error_t *(*svn_fs_open_)(svn_fs_t **, const char *, apr_hash_t *,
                                apr_pool_t *, apr_pool_t *);
+
+  /* If not 0, this is a pre-allocated transaction ID that can just be
+     used for a new txn without needing to consult 'txn-current'. */
+  apr_uint64_t next_txn_id;
 } svn_fs_x__data_t;
 
 
@@ -571,4 +558,4 @@ typedef struct svn_fs_x__change_t
 }
 #endif /* __cplusplus */
 
-#endif /* SVN_LIBSVN_FS_X_H */
+#endif /* SVN_LIBSVN_FS_X_FS_H */

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_id.c
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_id.c?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_id.c (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_id.c Fri Sep 11 15:51:30 2015
@@ -85,6 +85,13 @@ struct svn_fs_x__id_context_t
      is not.*/
   const char *fs_path;
 
+  /* If FS is NULL, this points to svn_fs_open() as passed to the library. */
+  svn_error_t *(*svn_fs_open_)(svn_fs_t **,
+      const char *,
+      apr_hash_t *,
+      apr_pool_t *,
+      apr_pool_t *);
+
   /* Pool that this context struct got allocated in. */
   apr_pool_t *owner;
 
@@ -118,11 +125,14 @@ static apr_status_t
 fs_cleanup(void *baton)
 {
   svn_fs_x__id_context_t *context = baton;
+  svn_fs_x__data_t *ffd = context->fs->fsap_data;
 
   /* Remember the FS_PATH to potentially reopen and mark the FS as n/a. */
   context->fs_path = apr_pstrdup(context->owner, context->fs->path);
+  context->svn_fs_open_ = ffd->svn_fs_open_;
   context->fs = NULL;
 
+
   /* No need for further notifications because from now on, everything is
      allocated in OWNER. */
   apr_pool_cleanup_kill(context->owner, context, owner_cleanup);
@@ -137,8 +147,12 @@ get_fs(svn_fs_x__id_context_t *context)
 {
   if (!context->fs)
     {
-      svn_error_t *err = svn_fs_open2(&context->fs, context->fs_path, NULL,
-                                      context->owner, context->owner);
+      svn_error_t *err;
+
+      SVN_ERR_ASSERT_NO_RETURN(context->svn_fs_open_);
+
+      err = context->svn_fs_open_(&context->fs, context->fs_path, NULL,
+                                  context->owner, context->owner);
       if (err)
         {
           svn_error_clear(err);

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.c
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.c?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.c (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.c Fri Sep 11 15:51:30 2015
@@ -95,13 +95,27 @@ check_format(int format)
 {
   /* Put blacklisted versions here. */
 
-  /* We support all formats from 1-current simultaneously */
-  if (1 <= format && format <= SVN_FS_X__FORMAT_NUMBER)
+  /* We support any format if it matches the current format. */
+  if (format == SVN_FS_X__FORMAT_NUMBER)
+    return SVN_NO_ERROR;
+
+  /* Experimental formats are only supported if they match the current, but
+   * that case has already been handled. So, reject any experimental format.
+   */
+  if (SVN_FS_X__EXPERIMENTAL_FORMAT_NUMBER >= format)
+    return svn_error_createf(SVN_ERR_FS_UNSUPPORTED_FORMAT, NULL,
+      _("Unsupported experimental FSX format '%d' found; current format is '%d'"),
+      format, SVN_FS_X__FORMAT_NUMBER);
+
+  /* By default, we will support any non-experimental format released so far.
+   */
+  if (format <= SVN_FS_X__FORMAT_NUMBER)
     return SVN_NO_ERROR;
 
   return svn_error_createf(SVN_ERR_FS_UNSUPPORTED_FORMAT, NULL,
-     _("Expected FS format between '1' and '%d'; found format '%d'"),
-     SVN_FS_X__FORMAT_NUMBER, format);
+     _("Expected FSX format between '%d' and '%d'; found format '%d'"),
+     SVN_FS_X__EXPERIMENTAL_FORMAT_NUMBER + 1, SVN_FS_X__FORMAT_NUMBER,
+     format);
 }
 
 /* Read the format file at PATH and set *PFORMAT to the format version found
@@ -850,6 +864,7 @@ write_revision_zero(svn_fs_t *fs,
   apr_array_header_t *index_entries;
   svn_fs_x__p2l_entry_t *entry;
   svn_fs_x__revision_file_t *rev_file;
+  apr_file_t *apr_file;
   const char *l2p_proto_index, *p2l_proto_index;
 
   /* Construct a skeleton r0 with no indexes. */
@@ -896,15 +911,16 @@ write_revision_zero(svn_fs_t *fs,
 
   /* Now re-open r0, create proto-index files from our entries and
       rewrite the index section of r0. */
-  SVN_ERR(svn_fs_x__open_pack_or_rev_file_writable(&rev_file, fs, 0,
-                                                   subpool, subpool));
+  SVN_ERR(svn_fs_x__rev_file_open_writable(&rev_file, fs, 0,
+                                           subpool, subpool));
   SVN_ERR(svn_fs_x__p2l_index_from_p2l_entries(&p2l_proto_index, fs,
                                                rev_file, index_entries,
                                                subpool, subpool));
   SVN_ERR(svn_fs_x__l2p_index_from_p2l_entries(&l2p_proto_index, fs,
                                                index_entries,
                                                subpool, subpool));
-  SVN_ERR(svn_fs_x__add_index_data(fs, rev_file->file, l2p_proto_index,
+  SVN_ERR(svn_fs_x__rev_file_get(&apr_file, rev_file));
+  SVN_ERR(svn_fs_x__add_index_data(fs, apr_file, l2p_proto_index,
                                    p2l_proto_index, 0, subpool));
   SVN_ERR(svn_fs_x__close_revision_file(rev_file));
 
@@ -935,14 +951,9 @@ svn_fs_x__create_file_tree(svn_fs_t *fs,
 
   /* Create the revision data directories. */
   SVN_ERR(svn_io_make_dir_recursively(
-                              svn_fs_x__path_rev_shard(fs, 0, scratch_pool),
+                              svn_fs_x__path_shard(fs, 0, scratch_pool),
                               scratch_pool));
 
-  /* Create the revprops directory. */
-  SVN_ERR(svn_io_make_dir_recursively(
-                         svn_fs_x__path_revprops_shard(fs, 0, scratch_pool),
-                         scratch_pool));
-
   /* Create the transaction directory. */
   SVN_ERR(svn_io_make_dir_recursively(
                                   svn_fs_x__path_txns_dir(fs, scratch_pool),
@@ -1133,17 +1144,18 @@ change_rev_prop_body(void *baton,
 {
   change_rev_prop_baton_t *cb = baton;
   apr_hash_t *table;
+  const svn_string_t *present_value;
 
   /* Read current revprop values from disk (never from cache).
      Even if somehow the cache got out of sync, we want to make sure that
      we read, update and write up-to-date data. */
   SVN_ERR(svn_fs_x__get_revision_proplist(&table, cb->fs, cb->rev, TRUE,
                                           scratch_pool, scratch_pool));
+  present_value = svn_hash_gets(table, cb->name);
 
   if (cb->old_value_p)
     {
       const svn_string_t *wanted_value = *cb->old_value_p;
-      const svn_string_t *present_value = svn_hash_gets(table, cb->name);
       if ((!wanted_value != !present_value)
           || (wanted_value && present_value
               && !svn_string_compare(wanted_value, present_value)))
@@ -1156,6 +1168,13 @@ change_rev_prop_body(void *baton,
         }
       /* Fall through. */
     }
+
+  /* If the prop-set is a no-op, skip the actual write. */
+  if ((!present_value && !cb->value)
+      || (present_value && cb->value
+          && svn_string_compare(present_value, cb->value)))
+    return SVN_NO_ERROR;
+
   svn_hash_sets(table, cb->name, cb->value);
 
   return svn_fs_x__set_revision_proplist(cb->fs, cb->rev, table,
@@ -1205,8 +1224,11 @@ svn_fs_x__info_format(int *fs_format,
     {
     case 1:
       break;
+    case 2:
+      (*supports_version)->minor = 10;
+      break;
 #ifdef SVN_DEBUG
-# if SVN_FS_X__FORMAT_NUMBER != 1
+# if SVN_FS_X__FORMAT_NUMBER != 2
 #  error "Need to add a 'case' statement here"
 # endif
 #endif

Modified: subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.h
URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.h?rev=1702504&r1=1702503&r2=1702504&view=diff
==============================================================================
--- subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.h (original)
+++ subversion/branches/reuse-ra-session/subversion/libsvn_fs_x/fs_x.h Fri Sep 11 15:51:30 2015
@@ -1,4 +1,4 @@
-/* fs_x.h : interface to the native filesystem layer
+/* fs_x.h : interface to the FSX layer
  *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
@@ -20,8 +20,8 @@
  * ====================================================================
  */
 
-#ifndef SVN_LIBSVN_FS__FS_X_H
-#define SVN_LIBSVN_FS__FS_X_H
+#ifndef SVN_LIBSVN_FS_X_FS_X_H
+#define SVN_LIBSVN_FS_X_FS_X_H
 
 #include "fs.h"