You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/04/11 22:26:54 UTC

svn commit: r1586768 - in /subversion/branches/thunder/subversion: include/private/svn_fs_util.h libsvn_fs_fs/cached_data.c libsvn_fs_fs/util.c libsvn_fs_util/thunder.c tests/libsvn_fs/fs-test.c

Author: stefan2
Date: Fri Apr 11 20:26:54 2014
New Revision: 1586768

URL: http://svn.apache.org/r1586768
Log:
On the thunder branch:  Replace the PATH+LOCATION identification
for the access location by a simple KEY.

The caller already had to combine various bits of information to
construct the "path" element, so adding one more is no extra burden.
Also, it makes the arbitrary nature of the location identifier more
apparent to the user.

* subversion/include/private/svn_fs_util.h
  (svn_fs__thunder_begin_access): Replace PATH+LOCATION by KEY.

* subversion/libsvn_fs_util/thunder.c
  (construct_key): No longer needed.
  (svn_fs__thunder_begin_access): Convert incoming key to a svn_stringbuf_t
                                  to match our internal representation.

* subversion/libsvn_fs_fs/util.c
  (svn_fs_fs__thundered_cache_get,
   svn_fs_fs__thundered_cache_get_partial): Construct the full key here now.

* subversion/libsvn_fs_fs/cached_data.c
  (block_read): Same.

* subversion/tests/libsvn_fs/fs-test.c
  (basic_thunder_interface): Update test case.

Modified:
    subversion/branches/thunder/subversion/include/private/svn_fs_util.h
    subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/thunder/subversion/libsvn_fs_fs/util.c
    subversion/branches/thunder/subversion/libsvn_fs_util/thunder.c
    subversion/branches/thunder/subversion/tests/libsvn_fs/fs-test.c

Modified: subversion/branches/thunder/subversion/include/private/svn_fs_util.h
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/include/private/svn_fs_util.h?rev=1586768&r1=1586767&r2=1586768&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/include/private/svn_fs_util.h (original)
+++ subversion/branches/thunder/subversion/include/private/svn_fs_util.h Fri Apr 11 20:26:54 2014
@@ -263,16 +263,17 @@ svn_fs__thunder_create(svn_fs__thunder_t
 svn_error_t *
 svn_fs__thunder_destroy(svn_fs__thunder_t *thunder);
 
-/* Request access to the data at PATH + LOCATION.  If the THUNDER registry
-   did not have no valid entry for this already, *ACCESS will receive a
-   token that the caller shall return by calling svn_fs__thunder_end_access.
-   The access token will expire automatically after THUNDER's configured
-   timeout.
-
-   If there is still a valid ACCESS object for the PATH + LOCATION, this
-   function will wait for that access to either end / complete or to timeout.
-   *ACCESS will be set to NULL in these cases.  If the access token had been
-   issued to the same thread already, this call will not block.
+/* Request access to the data location identified by KEY.  To prevent false
+   conflicts, repository path, revision number etc- should be included into
+   the KEY.  If the THUNDER registry did not have no valid entry for that
+   KEY already, *ACCESS will receive a token that the caller shall return
+   by calling svn_fs__thunder_end_access.  The access token will expire
+   automatically after THUNDER's configured timeout.
+
+   If there is still a valid ACCESS object for the KEY, this function will
+   wait for that access to either end / complete or to timeout.  *ACCESS
+   will be set to NULL in these cases.  If the access token had been issued
+   to the same thread already, this call will not block.
 
    A caller receiving a NULL *ACCESS may assume that some other thread
    already put the desired data into the cache.  Therefore, it should retry
@@ -281,8 +282,7 @@ svn_fs__thunder_destroy(svn_fs__thunder_
 svn_error_t *
 svn_fs__thunder_begin_access(svn_fs__thunder_access_t **access,
                              svn_fs__thunder_t *thunder,
-                             const char *path,
-                             apr_uint64_t location,
+                             const char *key,
                              apr_pool_t *pool);
 
 /* Return the ACCESS token.  This will unblock all threads blocked on the

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c?rev=1586768&r1=1586767&r2=1586768&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c Fri Apr 11 20:26:54 2014
@@ -2970,15 +2970,17 @@ block_read(void **result,
     {
       svn_error_t *err;
       svn_fs__thunder_access_t *access;
-      const char *filename;
+      const char *filename, *access_path;
 
       /* Begin coordinated thunder-aware access. */
       block_start = offset - (offset % ffd->block_size);
       SVN_ERR(svn_io_file_name_get(&filename, revision_file->file,
                                    scratch_pool));
+
+      access_path = apr_psprintf(scratch_pool, "%s:%" APR_UINT64_T_FMT,
+                                 filename, block_start);
       SVN_ERR(svn_fs__thunder_begin_access(&access, svn_fs_fs__get_thunder(),
-                                           filename, block_start,
-                                           scratch_pool));
+                                           access_path, scratch_pool));
 
       /* If we did not get the access token, retry the cache access if we
        * need to data at all. */

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/util.c?rev=1586768&r1=1586767&r2=1586768&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/util.c Fri Apr 11 20:26:54 2014
@@ -661,10 +661,12 @@ svn_fs_fs__thundered_cache_get(void **va
   SVN_ERR(svn_cache__get(value, found, cache, key, pool));
   if (!*found)
     {
-      const char *access_path = apr_psprintf(pool, "%s:%s:%ld",
-                                             fs->path, tag, revision);
+      const char *access_path = apr_psprintf(pool,
+                                             "%s:%s:%ld:%" APR_UINT64_T_FMT,
+                                             fs->path, tag, revision,
+                                             location);
       SVN_ERR(svn_fs__thunder_begin_access(access, svn_fs_fs__get_thunder(),
-                                           access_path, location, pool));
+                                           access_path, pool));
       if (!*access)
         SVN_ERR(svn_cache__get(value, found, cache, key, pool));
     }
@@ -691,10 +693,12 @@ svn_fs_fs__thundered_cache_get_partial(v
                                  pool));
   if (!*found)
     {
-      const char *access_path = apr_psprintf(pool, "%s:%s:%ld",
-                                             fs->path, tag, revision);
+      const char *access_path = apr_psprintf(pool,
+                                             "%s:%s:%ld:%" APR_UINT64_T_FMT,
+                                             fs->path, tag, revision,
+                                             location);
       SVN_ERR(svn_fs__thunder_begin_access(access, svn_fs_fs__get_thunder(),
-                                           access_path, location, pool));
+                                           access_path, pool));
       if (!*access)
         SVN_ERR(svn_cache__get_partial(value, found, cache, key, func, baton,
                                        pool));

Modified: subversion/branches/thunder/subversion/libsvn_fs_util/thunder.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_util/thunder.c?rev=1586768&r1=1586767&r2=1586768&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_util/thunder.c (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_util/thunder.c Fri Apr 11 20:26:54 2014
@@ -215,21 +215,6 @@ svn_fs__thunder_destroy(svn_fs__thunder_
   return SVN_NO_ERROR;
 }
 
-/* Return the combination of PATH and LOCATION as a single key allocated in
- * POOL.
- */
-static svn_stringbuf_t *
-construct_key(const char *path,
-              apr_uint64_t location,
-              apr_pool_t *pool)
-{
-  /* There are certainly more efficient ways to do it, but this good enough
-   * because the amount of data that the caller wants to process as part of
-   * the data access is several kB.  So, we can afford to trade a few cycles
-   * for simplicity. */
-  return svn_stringbuf_createf(pool, "%s:%" APR_UINT64_T_FMT, path, location);
-}
-
 /* Mark ACCESS as  begin used for KEY.
  *
  * Callers must serialize for ACCESS.
@@ -396,13 +381,12 @@ release_access(svn_fs__thunder_t *thunde
 svn_error_t *
 svn_fs__thunder_begin_access(svn_fs__thunder_access_t **access,
                              svn_fs__thunder_t *thunder,
-                             const char *path,
-                             apr_uint64_t location,
+                             const char *ckey,
                              apr_pool_t *pool)
 {
-  svn_stringbuf_t *key = construct_key(path, location, pool);
   access_t *internal_access;
   svn_boolean_t first;
+  svn_stringbuf_t *key = svn_stringbuf_create(ckey, pool);
 
   /* Get the current hash entry or create a new one (FIRST will then be TRUE).
    */

Modified: subversion/branches/thunder/subversion/tests/libsvn_fs/fs-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/tests/libsvn_fs/fs-test.c?rev=1586768&r1=1586767&r2=1586768&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/branches/thunder/subversion/tests/libsvn_fs/fs-test.c Fri Apr 11 20:26:54 2014
@@ -5319,8 +5319,7 @@ basic_thunder_interface(const svn_test_o
   SVN_ERR(svn_fs__thunder_create(&thunder, 10000, pool));
 
   /* Gain access and release it. */
-  SVN_ERR(svn_fs__thunder_begin_access(&access, thunder, "/some/path",
-                                       123456, pool));
+  SVN_ERR(svn_fs__thunder_begin_access(&access, thunder, "/some/path", pool));
   SVN_TEST_ASSERT(access);
   SVN_ERR(svn_fs__thunder_end_access(access));
 
@@ -5330,20 +5329,19 @@ basic_thunder_interface(const svn_test_o
   /* Re-acquiring an access is fine, too.   This time, we won't release it
    * to verify that unreleased access objects don't mess up the destruction
    * of the thunder_t instance. */
-  SVN_ERR(svn_fs__thunder_begin_access(&access, thunder, "/some/path",
-                                       123456, pool));
+  SVN_ERR(svn_fs__thunder_begin_access(&access, thunder, "/some/path", pool));
   SVN_TEST_ASSERT(access);
 
   /* Acquiring the same path twice is legal but the second attempt causes
    * a time out and no access object gets returned. */
-  SVN_ERR(svn_fs__thunder_begin_access(&access, thunder, "path2", 9, pool));
-  SVN_ERR(svn_fs__thunder_begin_access(&access2, thunder, "path2", 9, pool));
+  SVN_ERR(svn_fs__thunder_begin_access(&access, thunder, "path2:9", pool));
+  SVN_ERR(svn_fs__thunder_begin_access(&access2, thunder, "path2:9", pool));
 
   SVN_TEST_ASSERT(access);
   SVN_TEST_ASSERT(access2 == NULL);
 
   /* Gaining access to another path should be passible. */
-  SVN_ERR(svn_fs__thunder_begin_access(&access3, thunder, "path2", 91, pool));
+  SVN_ERR(svn_fs__thunder_begin_access(&access3, thunder, "path2:91", pool));
   SVN_TEST_ASSERT(access3);
 
   /* Now, release all three. */