You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/10/16 01:39:06 UTC

svn commit: r1708904 - in /subversion/trunk/subversion/libsvn_fs_x: fs.c fs_x.c fs_x.h revprops.c revprops.h verify.c

Author: stefan2
Date: Thu Oct 15 23:39:06 2015
New Revision: 1708904

URL: http://svn.apache.org/viewvc?rev=1708904&view=rev
Log:
Finally wire the new FS API "refresh" hint with FSX' revprop access.

Apart from passing the API parameters through, the only thing we change
is that the "refresh" option controls whether we read the generation
number from disk (possibly invalidating the cache).

* subversion/libsvn_fs_x/revprops.h
  (svn_fs_x__invalidate_revprop_generation): Declare a new utility API.
  (svn_fs_x__get_revision_proplist): Add the REFRESH option.

* subversion/libsvn_fs_x/revprops.c
  (svn_fs_x__invalidate_revprop_generation): Implement the new API.
  (is_generation_valid): New utility function.
  (parse_revprop): Assert that we got the "re-read generation after
                   invalidation" logic right.
  (svn_fs_x__get_revision_proplist): Only read the revprop generation
                                     if necessary.

* subversion/libsvn_fs_x/fs_x.h
  (svn_fs_x__revision_prop): Add the REFRESH option.

* subversion/libsvn_fs_x/fs_x.c
  (svn_fs_x__revision_prop): Pass through the REFRESH option.
  (change_rev_prop_body): Update caller.

* subversion/libsvn_fs_x/verify.c
  (verify_revprops): Update caller.

* subversion/libsvn_fs_x/fs.c
  (x_refresh_revprops): Call our new invalidation API.
  (x_revision_prop): This wrapper is no longer needed.
  (x_revision_proplist): Pass through the REFRESH option.
  (fs_vtable): Call into svn_fs_x__revision_prop directly. 
  (initialize_fs_struct): Ensure that the revprop generation is
                          initialially marked as invalid / unknown.

Modified:
    subversion/trunk/subversion/libsvn_fs_x/fs.c
    subversion/trunk/subversion/libsvn_fs_x/fs_x.c
    subversion/trunk/subversion/libsvn_fs_x/fs_x.h
    subversion/trunk/subversion/libsvn_fs_x/revprops.c
    subversion/trunk/subversion/libsvn_fs_x/revprops.h
    subversion/trunk/subversion/libsvn_fs_x/verify.c

Modified: subversion/trunk/subversion/libsvn_fs_x/fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/fs.c?rev=1708904&r1=1708903&r2=1708904&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/fs.c Thu Oct 15 23:39:06 2015
@@ -222,23 +222,7 @@ static svn_error_t *
 x_refresh_revprops(svn_fs_t *fs,
                    apr_pool_t *scratch_pool)
 {
-  return SVN_NO_ERROR;
-}
-
-/* Wrapper around svn_fs_x__revision_prop() adapting between function
-   signatures. */
-static svn_error_t *
-x_revision_prop(svn_string_t **value_p,
-                svn_fs_t *fs,
-                svn_revnum_t rev,
-                const char *propname,
-                svn_boolean_t refresh,
-                apr_pool_t *result_pool,
-                apr_pool_t *scratch_pool)
-{
-  SVN_ERR(svn_fs_x__revision_prop(value_p, fs, rev, propname, result_pool,
-                                  scratch_pool));
-
+  svn_fs_x__invalidate_revprop_generation(fs);
   return SVN_NO_ERROR;
 }
 
@@ -254,7 +238,8 @@ x_revision_proplist(apr_hash_t **proplis
 {
   /* No need to bypass the caches for r/o access to revprops. */
   SVN_ERR(svn_fs_x__get_revision_proplist(proplist_p, fs, rev, FALSE,
-                                          result_pool, scratch_pool));
+                                          refresh, result_pool,
+                                          scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -292,7 +277,7 @@ x_begin_txn(svn_fs_txn_t **txn_p,
 static fs_vtable_t fs_vtable = {
   svn_fs_x__youngest_rev,
   x_refresh_revprops,
-  x_revision_prop,
+  svn_fs_x__revision_prop,
   x_revision_proplist,
   svn_fs_x__change_rev_prop,
   x_set_uuid,
@@ -323,6 +308,8 @@ static svn_error_t *
 initialize_fs_struct(svn_fs_t *fs)
 {
   svn_fs_x__data_t *ffd = apr_pcalloc(fs->pool, sizeof(*ffd));
+  ffd->revprop_generation = -1;
+
   fs->vtable = &fs_vtable;
   fs->fsap_data = ffd;
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_fs_x/fs_x.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/fs_x.c?rev=1708904&r1=1708903&r2=1708904&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/fs_x.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/fs_x.c Thu Oct 15 23:39:06 2015
@@ -1115,13 +1115,14 @@ svn_fs_x__revision_prop(svn_string_t **v
                         svn_fs_t *fs,
                         svn_revnum_t rev,
                         const char *propname,
+                        svn_boolean_t refresh,
                         apr_pool_t *result_pool,
                         apr_pool_t *scratch_pool)
 {
   apr_hash_t *table;
 
   SVN_ERR(svn_fs__check_fs(fs, TRUE));
-  SVN_ERR(svn_fs_x__get_revision_proplist(&table, fs, rev, FALSE,
+  SVN_ERR(svn_fs_x__get_revision_proplist(&table, fs, rev, FALSE, refresh,
                                           scratch_pool, scratch_pool));
 
   *value_p = svn_string_dup(svn_hash_gets(table, propname), result_pool);
@@ -1154,7 +1155,7 @@ change_rev_prop_body(void *baton,
      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));
+                                          TRUE, scratch_pool, scratch_pool));
   present_value = svn_hash_gets(table, cb->name);
 
   if (cb->old_value_p)

Modified: subversion/trunk/subversion/libsvn_fs_x/fs_x.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/fs_x.h?rev=1708904&r1=1708903&r2=1708904&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/fs_x.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/fs_x.h Thu Oct 15 23:39:06 2015
@@ -160,12 +160,15 @@ svn_fs_x__write_format(svn_fs_t *fs,
 
 /* Find the value of the property named PROPNAME in transaction REV.
    Return the contents in *VALUE_P, allocated from RESULT_POOL.
+   If REFRESH is not set, continue using the potentially outdated
+   revprop generation value in FS->FSAP_DATA.
    Use SCRATCH_POOL for temporary allocations. */
 svn_error_t *
 svn_fs_x__revision_prop(svn_string_t **value_p,
                         svn_fs_t *fs,
                         svn_revnum_t rev,
                         const char *propname,
+                        svn_boolean_t refresh,
                         apr_pool_t *result_pool,
                         apr_pool_t *scratch_pool);
 

Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.c?rev=1708904&r1=1708903&r2=1708904&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.c Thu Oct 15 23:39:06 2015
@@ -277,6 +277,21 @@ read_revprop_generation(svn_fs_t *fs,
   return SVN_NO_ERROR;
 }
 
+void
+svn_fs_x__invalidate_revprop_generation(svn_fs_t *fs)
+{
+  svn_fs_x__data_t *ffd = fs->fsap_data;
+  ffd->revprop_generation = -1;
+}
+
+/* Return TRUE if the revprop generation value in FS->FSAP_DATA is valid. */
+static svn_boolean_t
+is_generation_valid(svn_fs_t *fs)
+{
+  svn_fs_x__data_t *ffd = fs->fsap_data;
+  return ffd->revprop_generation >= 0;
+}
+
 /* Set the revprop generation in FS to the next odd number to indicate
    that there is a revprop write process under way.  Update the value
    in FS->FSAP_DATA accordingly.  If the change times out, readers shall
@@ -399,6 +414,8 @@ parse_revprop(apr_hash_t **properties,
       svn_fs_x__data_t *ffd = fs->fsap_data;
       svn_fs_x__pair_cache_key_t key = { 0 };
 
+      SVN_ERR_ASSERT(is_generation_valid(fs));
+
       key.revision = revision;
       key.second = ffd->revprop_generation;
       SVN_ERR(svn_cache__set(ffd->revprop_cache, &key, *properties,
@@ -803,6 +820,7 @@ svn_fs_x__get_revision_proplist(apr_hash
                                 svn_fs_t *fs,
                                 svn_revnum_t rev,
                                 svn_boolean_t bypass_cache,
+                                svn_boolean_t refresh,
                                 apr_pool_t *result_pool,
                                 apr_pool_t *scratch_pool)
 {
@@ -814,14 +832,16 @@ svn_fs_x__get_revision_proplist(apr_hash
   /* should they be available at all? */
   SVN_ERR(svn_fs_x__ensure_revision_exists(rev, fs, scratch_pool));
 
+  /* Ensure that the revprop generation info is valid. */
+  if (refresh || !is_generation_valid(fs))
+    SVN_ERR(read_revprop_generation(fs, scratch_pool));
+
   /* Try cache lookup first. */
   if (!bypass_cache && has_revprop_cache(fs, scratch_pool))
     {
       svn_boolean_t is_cached;
       svn_fs_x__pair_cache_key_t key = { 0 };
 
-      SVN_ERR(read_revprop_generation(fs, scratch_pool));
-
       key.revision = rev;
       key.second = ffd->revprop_generation;
       SVN_ERR(svn_cache__get((void **) proplist_p, &is_cached,

Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.h?rev=1708904&r1=1708903&r2=1708904&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.h Thu Oct 15 23:39:06 2015
@@ -39,8 +39,15 @@ svn_error_t *
 svn_fs_x__reset_revprop_generation_file(svn_fs_t *fs,
                                         apr_pool_t *scratch_pool);
 
+/* Invalidate the cached revprop generation value in FS->FSAP_DATA.
+ * This enforces a re-read upon the next revprop read. */
+void
+svn_fs_x__invalidate_revprop_generation(svn_fs_t *fs);
+
 /* Read the revprops for revision REV in FS and return them in *PROPLIST_P.
  * If BYPASS_CACHE is set, don't consult the disks but always read from disk.
+ * If REFRESH is set, update the revprop generation info; otherwise access
+ * potentially outdated cache data directly.
  *
  * Allocate the *PROPLIST_P in RESULT_POOL and use SCRATCH_POOL for temporary
  * allocations.
@@ -50,6 +57,7 @@ svn_fs_x__get_revision_proplist(apr_hash
                                 svn_fs_t *fs,
                                 svn_revnum_t rev,
                                 svn_boolean_t bypass_cache,
+                                svn_boolean_t refresh,
                                 apr_pool_t *result_pool,
                                 apr_pool_t *scratch_pool);
 

Modified: subversion/trunk/subversion/libsvn_fs_x/verify.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/verify.c?rev=1708904&r1=1708903&r2=1708904&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/verify.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/verify.c Thu Oct 15 23:39:06 2015
@@ -701,7 +701,7 @@ verify_revprops(svn_fs_t *fs,
       /* Access the svn:date revprop.
        * This implies parsing all revprops for that revision. */
       SVN_ERR(svn_fs_x__revision_prop(&date, fs, revision,
-                                      SVN_PROP_REVISION_DATE,
+                                      SVN_PROP_REVISION_DATE, TRUE,
                                       iterpool, iterpool));
 
       /* The time stamp is the only revprop that, if given, needs to