Author: stefan2
Date: Fri Mar 29 10:39:18 2013
New Revision: 1462436
URL: http://svn.apache.org/r1462436
Log:
Introduce the concept of namespaces to FSFS caching. We already use
"prefixes" to separate keys from different repos. Now, we can add
another element to the prefix and we will do so if we need to ensure
that all data get read from disk at least initially.
Make all verification code use a unique cache namespace.
* subversion/include/svn_fs.h
(SVN_FS_CONFIG_FSFS_CACHE_NS): declare new config option
* subversion/libsvn_fs_fs/caching.c
(read_config): read namespace from config
(svn_fs_fs__initialize_caches): add namespace to prefix
* subversion/libsvn_fs_fs/fs_fs.c
(verify_as_revision_before_current_plus_plus): use unique namespace
instead of disabling caches altogether
* subversion/svnadmin/svnadmin.c
(open_repos): use unique namespace for all ops
Modified:
subversion/trunk/subversion/include/svn_fs.h
subversion/trunk/subversion/libsvn_fs_fs/caching.c
subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
subversion/trunk/subversion/svnadmin/svnadmin.c
Modified: subversion/trunk/subversion/include/svn_fs.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_fs.h?rev=1462436&r1=1462435&r2=1462436&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_fs.h (original)
+++ subversion/trunk/subversion/include/svn_fs.h Fri Mar 29 10:39:18 2013
@@ -95,6 +95,21 @@ typedef struct svn_fs_t svn_fs_t;
*/
#define SVN_FS_CONFIG_FSFS_CACHE_REVPROPS "fsfs-cache-revprops"
+/** Select the cache namespace. If you potentially share the cache with
+ * another FS object for the same repository, objects read through one FS
+ * will not need to be read again for the other. In most cases, that is
+ * a very desirable behavior and the default is, therefore, an empty
+ * namespace.
+ *
+ * If you want to be sure that your FS instance will actually read all
+ * requested data at least once, you need to specify a separate namespace
+ * for it. All repository verification code, for instance, should use
+ * some GUID here that is different each time you open an FS instance.
+ *
+ * @since New in 1.8.
+ */
+#define SVN_FS_CONFIG_FSFS_CACHE_NS "fsfs-cache-namespace"
+
/* Note to maintainers: if you add further SVN_FS_CONFIG_FSFS_CACHE_* knobs,
update fs_fs.c:verify_as_revision_before_current_plus_plus(). */
Modified: subversion/trunk/subversion/libsvn_fs_fs/caching.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/caching.c?rev=1462436&r1=1462435&r2=1462436&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/caching.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/caching.c Fri Mar 29 10:39:18 2013
@@ -41,11 +41,18 @@
/* Return a memcache in *MEMCACHE_P for FS if it's configured to use
memcached, or NULL otherwise. Also, sets *FAIL_STOP to a boolean
indicating whether cache errors should be returned to the caller or
- just passed to the FS warning handler. Use FS->pool for allocating
- the memcache, and POOL for temporary allocations. */
+ just passed to the FS warning handler.
+
+ *CACHE_TXDELTAS, *CACHE_FULLTEXTS and *CACHE_REVPROPS flags will be set
+ according to FS->CONFIG. *CACHE_NAMESPACE receives the cache prefix
+ to use.
+
+ Use FS->pool for allocating the memcache and CACHE_NAMESPACE, and POOL
+ for temporary allocations. */
static svn_error_t *
read_config(svn_memcache_t **memcache_p,
svn_boolean_t *fail_stop,
+ const char **cache_namespace,
svn_boolean_t *cache_txdeltas,
svn_boolean_t *cache_fulltexts,
svn_boolean_t *cache_revprops,
@@ -57,6 +64,18 @@ read_config(svn_memcache_t **memcache_p,
SVN_ERR(svn_cache__make_memcache_from_config(memcache_p, ffd->config,
fs->pool));
+ /* No cache namespace by default. I.e. all FS instances share the
+ * cached data. If you specify different namespaces, the data will
+ * share / compete for the same cache memory but keys will not match
+ * across namespaces and, thus, cached data will not be shared between
+ * namespaces.
+ */
+ *cache_namespace
+ = apr_pstrdup(fs->pool,
+ svn_hash__get_cstring(fs->config,
+ SVN_FS_CONFIG_FSFS_CACHE_NS,
+ ""));
+
/* don't cache text deltas by default.
* Once we reconstructed the fulltexts from the deltas,
* these deltas are rarely re-used. Therefore, only tools
@@ -302,16 +321,20 @@ svn_fs_fs__initialize_caches(svn_fs_t *f
svn_boolean_t cache_txdeltas;
svn_boolean_t cache_fulltexts;
svn_boolean_t cache_revprops;
+ const char *cache_namespace;
/* Evaluating the cache configuration. */
SVN_ERR(read_config(&memcache,
&no_handler,
+ &cache_namespace,
&cache_txdeltas,
&cache_fulltexts,
&cache_revprops,
fs,
pool));
+ prefix = apr_pstrcat(pool, "ns:", cache_namespace, ":", prefix, NULL);
+
membuffer = svn_cache__get_global_membuffer_cache();
/* Make the cache for revision roots. For the vast majority of
Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=1462436&r1=1462435&r2=1462436&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Fri Mar 29 10:39:18 2013
@@ -8282,14 +8282,12 @@ verify_as_revision_before_current_plus_p
SVN_ERR_ASSERT(ffd->svn_fs_open_);
- fs_config = apr_hash_make(pool);
- svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_DELTAS, "0");
- svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_FULLTEXTS, "0");
- svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_REVPROPS, "0");
- /* ### TODO: are there any other intra-process caches that FS populated
- and FT will read from? Can we disable those (for FT at least)?
+ /* 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);
+ svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_NS,
+ svn_uuid_generate(pool));
SVN_ERR(ffd->svn_fs_open_(&ft, fs->path,
fs_config,
pool));
Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1462436&r1=1462435&r2=1462436&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Fri Mar 29 10:39:18 2013
@@ -116,6 +116,8 @@ open_repos(svn_repos_t **repos,
svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_DELTAS, "1");
svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_FULLTEXTS, "1");
svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_REVPROPS, "2");
+ svn_hash_sets(fs_config, SVN_FS_CONFIG_FSFS_CACHE_NS,
+ svn_uuid_generate(pool));
/* now, open the requested repository */
SVN_ERR(svn_repos_open2(repos, path, fs_config, pool));