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 04:59:53 UTC

svn commit: r1586544 - in /subversion/branches/thunder/subversion/libsvn_fs_fs: cached_data.c revprops.c

Author: stefan2
Date: Fri Apr 11 02:59:53 2014
New Revision: 1586544

URL: http://svn.apache.org/r1586544
Log:
On the thunder branch:
Make revprop, file fulltext and directory access THUNDER-aware.

Because fulltexts are being read as streams, we can't return the access
token in the same function that aquired it but must add it to the stream
context / baton. 

* subversion/libsvn_fs_fs/revprops.c
  (svn_fs_fs__get_revision_proplist): Use the THUNDER-aware cache lookup.

* subversion/libsvn_fs_fs/cached_data.c
  (rep_read_baton): Add the ACCESS token such that we may release it
                    once we are done with the read.
  (rep_read_get_baton): Store ACCESS token in stream baton.
  (rep_read_contents): Release token as soon as we read all data.
  (svn_fs_fs__get_contents): Use the THUNDER-aware cache lookup and pass
                             the access token to the stream constructor
  (svn_fs_fs__rep_contents_dir): Use the THUNDER-aware cache lookup.

Modified:
    subversion/branches/thunder/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/thunder/subversion/libsvn_fs_fs/revprops.c

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=1586544&r1=1586543&r2=1586544&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 02:59:53 2014
@@ -1049,6 +1049,11 @@ struct rep_read_baton
   /* The key for the fulltext cache for this rep, if there is a
      fulltext cache. */
   pair_cache_key_t fulltext_cache_key;
+
+  /* Access token we should release after reading the fulltext.
+     May be NULL. */
+  svn_fs__thunder_access_t *access;
+
   /* The text we've been reading, if we're going to cache it. */
   svn_stringbuf_t *current_fulltext;
 
@@ -1350,12 +1355,14 @@ build_rep_list(apr_array_header_t **list
    filesystem FS and store it in *RB_P.  If FULLTEXT_CACHE_KEY is not
    NULL, it is the rep's key in the fulltext cache, and a stringbuf
    must be allocated to store the text.  Perform all allocations in
-   POOL.  If rep is mutable, it must be for file contents. */
+   POOL.  Store the ACCESS token to be released once the read as been
+   completed.  If rep is mutable, it must be for file contents. */
 static svn_error_t *
 rep_read_get_baton(struct rep_read_baton **rb_p,
                    svn_fs_t *fs,
                    representation_t *rep,
                    pair_cache_key_t fulltext_cache_key,
+                   svn_fs__thunder_access_t *access,
                    apr_pool_t *pool)
 {
   struct rep_read_baton *b;
@@ -1371,6 +1378,7 @@ rep_read_get_baton(struct rep_read_baton
   b->len = rep->expanded_size;
   b->off = 0;
   b->fulltext_cache_key = fulltext_cache_key;
+  b->access = access;
   b->pool = svn_pool_create(pool);
   b->filehandle_pool = svn_pool_create(pool);
 
@@ -1749,12 +1757,24 @@ rep_read_contents(void *baton,
         }
     }
 
-  if (rb->off == rb->len && rb->current_fulltext)
+  /* End of representation? */
+  if (rb->off == rb->len)
     {
-      fs_fs_data_t *ffd = rb->fs->fsap_data;
-      SVN_ERR(svn_cache__set(ffd->fulltext_cache, &rb->fulltext_cache_key,
-                             rb->current_fulltext, rb->pool));
-      rb->current_fulltext = NULL;
+      /* Cache fulltext, if enabled. */
+      if (rb->current_fulltext)
+        {
+          fs_fs_data_t *ffd = rb->fs->fsap_data;
+          SVN_ERR(svn_cache__set(ffd->fulltext_cache, &rb->fulltext_cache_key,
+                                rb->current_fulltext, rb->pool));
+          rb->current_fulltext = NULL;
+        }
+
+      /* Return access token, if we have one. */
+      if (rb->access)
+        {
+          SVN_ERR(svn_fs__thunder_end_access(rb->access));
+          rb->access = NULL;
+        }
     }
 
   return SVN_NO_ERROR;
@@ -1777,6 +1797,7 @@ svn_fs_fs__get_contents(svn_stream_t **c
       pair_cache_key_t fulltext_cache_key = { 0 };
       svn_filesize_t len = rep->expanded_size ? rep->expanded_size : rep->size;
       struct rep_read_baton *rb;
+      svn_fs__thunder_access_t *access = NULL;
 
       /* Cache lookup, if the fulltext may be cached. */
       fulltext_cache_key.revision = rep->revision;
@@ -1787,9 +1808,13 @@ svn_fs_fs__get_contents(svn_stream_t **c
         {
           svn_stringbuf_t *fulltext;
           svn_boolean_t is_cached;
-          SVN_ERR(svn_cache__get((void **) &fulltext, &is_cached,
-                                 ffd->fulltext_cache, &fulltext_cache_key,
-                                 pool));
+          SVN_ERR(svn_fs_fs__thundered_cache_get((void **) &fulltext,
+                                                 &is_cached, &access, fs,
+                                                 "TXT", rep->revision,
+                                                 rep->item_index,
+                                                 ffd->fulltext_cache,
+                                                 &fulltext_cache_key,
+                                                 pool));
           if (is_cached)
             {
               *contents_p = svn_stream_from_stringbuf(fulltext, pool);
@@ -1805,7 +1830,8 @@ svn_fs_fs__get_contents(svn_stream_t **c
 
       /* Create the object chain for reconstruction from deltas or for
          reading plain text, depending on on-disk representation. */
-      SVN_ERR(rep_read_get_baton(&rb, fs, rep, fulltext_cache_key, pool));
+      SVN_ERR(rep_read_get_baton(&rb, fs, rep, fulltext_cache_key, access,
+                                 pool));
 
       *contents_p = svn_stream_create(rb, pool);
       svn_stream_set_read2(*contents_p, NULL /* only full read support */,
@@ -2254,6 +2280,7 @@ svn_fs_fs__rep_contents_dir(apr_array_he
 {
   pair_cache_key_t pair_key = { 0 };
   const void *key;
+  svn_fs__thunder_access_t *access;
 
   /* find the cache we may use */
   svn_cache__t *cache = locate_dir_cache(fs, &key, &pair_key, noderev,
@@ -2262,8 +2289,11 @@ svn_fs_fs__rep_contents_dir(apr_array_he
     {
       svn_boolean_t found;
 
-      SVN_ERR(svn_cache__get((void **)entries_p, &found, cache, key,
-                             result_pool));
+      SVN_ERR(svn_fs_fs__thundered_cache_get((void **)entries_p, &found,
+                                             &access, fs, "DIR", 
+                                             noderev->data_rep->revision,
+                                             noderev->data_rep->item_index,
+                                             cache, key, result_pool));
       if (found)
         return SVN_NO_ERROR;
     }
@@ -2276,6 +2306,9 @@ svn_fs_fs__rep_contents_dir(apr_array_he
   if (cache)
     SVN_ERR(svn_cache__set(cache, key, *entries_p, scratch_pool));
 
+  /* Others may now retry the cache lookup */
+  SVN_ERR(svn_fs__thunder_end_access(access));
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/thunder/subversion/libsvn_fs_fs/revprops.c
URL: http://svn.apache.org/viewvc/subversion/branches/thunder/subversion/libsvn_fs_fs/revprops.c?rev=1586544&r1=1586543&r2=1586544&view=diff
==============================================================================
--- subversion/branches/thunder/subversion/libsvn_fs_fs/revprops.c (original)
+++ subversion/branches/thunder/subversion/libsvn_fs_fs/revprops.c Fri Apr 11 02:59:53 2014
@@ -950,6 +950,7 @@ svn_fs_fs__get_revision_proplist(apr_has
 {
   fs_fs_data_t *ffd = fs->fsap_data;
   apr_int64_t generation = 0;
+  svn_fs__thunder_access_t *access = NULL;
 
   /* not found, yet */
   *proplist_p = NULL;
@@ -967,8 +968,10 @@ svn_fs_fs__get_revision_proplist(apr_has
 
       key.revision = rev;
       key.second = generation;
-      SVN_ERR(svn_cache__get((void **) proplist_p, &is_cached,
-                             ffd->revprop_cache, &key, pool));
+      SVN_ERR(svn_fs_fs__thundered_cache_get((void **) proplist_p,
+                                             &is_cached, &access, fs,
+                                             "REVPROPS", rev, 0,
+                                             ffd->revprop_cache, &key, pool));
       if (is_cached)
         return SVN_NO_ERROR;
     }
@@ -1001,6 +1004,8 @@ svn_fs_fs__get_revision_proplist(apr_has
       *proplist_p = revprops->properties;
     }
 
+  SVN_ERR(svn_fs__thunder_end_access(access));
+
   /* The revprops should have been there. Did we get them? */
   if (!*proplist_p)
     return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,