subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1708902 - /subversion/trunk/subversion/libsvn_fs_x/revprops.c
Date Thu, 15 Oct 2015 23:03:58 GMT
Author: stefan2
Date: Thu Oct 15 23:03:58 2015
New Revision: 1708902

URL: http://svn.apache.org/viewvc?rev=1708902&view=rev
Log:
Switch the FSX revprop code to take the revprop generation from the FS
instead of passing it through as a separate function parameter.

* subversion/libsvn_fs_x/revprops.c
  (read_revprop_generation,
   begin_revprop_change): Set the generation value inside FS instead
                          of returning it.
  (end_revprop_change): Take the generation value from FS and update it.
  (packed_revprops_t): Don't have a GENERATION element outside FS.
  (parse_revprop): Take the generation value from FS.
  (read_non_packed_revprop,
   parse_packed_revprops,
   read_pack_revprop): Update callers.
  (svn_fs_x__get_revision_proplist): Drop redundant docstring, take the
                                     generation value from FS and update
                                     callers.
  (switch_to_new_revprop,
   write_packed_revprop): Update callers. 

Modified:
    subversion/trunk/subversion/libsvn_fs_x/revprops.c

Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.c?rev=1708902&r1=1708901&r2=1708902&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.c Thu Oct 15 23:03:58 2015
@@ -225,12 +225,10 @@ revprop_generation_fixup(void *void_bato
   return SVN_NO_ERROR;
 }
 
-/* Read the current revprop generation and return it in *GENERATION.
-   Also, detect aborted / crashed writers and recover from that.
-   Use the access object in FS to set the shared mem values. */
+/* Read the current revprop generation of FS and its value in FS->FSAP_DATA.
+   Also, detect aborted / crashed writers and recover from that. */
 static svn_error_t *
-read_revprop_generation(apr_int64_t *generation,
-                        svn_fs_t *fs,
+read_revprop_generation(svn_fs_t *fs,
                         apr_pool_t *scratch_pool)
 {
   apr_int64_t current = 0;
@@ -275,18 +273,17 @@ read_revprop_generation(apr_int64_t *gen
     }
 
   /* return the value we just got */
-  *generation = current;
+  ffd->revprop_generation = current;
   return SVN_NO_ERROR;
 }
 
 /* Set the revprop generation in FS to the next odd number to indicate
-   that there is a revprop write process under way.  Return that value
-   in *GENERATION.  If the change times out, readers shall recover from
-   that state & re-read revprops.
+   that there is a revprop write process under way.  Update the value
+   in FS->FSAP_DATA accordingly.  If the change times out, readers shall
+   recover from that state & re-read revprops.
    This is a no-op for repo formats that don't support revprop caching. */
 static svn_error_t *
-begin_revprop_change(apr_int64_t *generation,
-                     svn_fs_t *fs,
+begin_revprop_change(svn_fs_t *fs,
                      apr_pool_t *scratch_pool)
 {
   svn_fs_x__data_t *ffd = fs->fsap_data;
@@ -295,33 +292,34 @@ begin_revprop_change(apr_int64_t *genera
   /* Set the revprop generation to an odd value to indicate
    * that a write is in progress.
    */
-  SVN_ERR(read_revprop_generation(generation, fs, scratch_pool));
-  ++*generation;
-  SVN_ERR_ASSERT(*generation % 2);
-  SVN_ERR(write_revprop_generation_file(fs, *generation, scratch_pool));
+  SVN_ERR(read_revprop_generation(fs, scratch_pool));
+  ++ffd->revprop_generation;
+  SVN_ERR_ASSERT(ffd->revprop_generation % 2);
+  SVN_ERR(write_revprop_generation_file(fs, ffd->revprop_generation,
+                                        scratch_pool));
 
   return SVN_NO_ERROR;
 }
 
 /* Set the revprop generation in FS to the next even generation after
-   the odd value in GENERATION to indicate that
+   the odd value in FS->FSAP_DATA to indicate that
    a) readers shall re-read revprops, and
    b) the write process has been completed (no recovery required).
    This is a no-op for repo formats that don't support revprop caching. */
 static svn_error_t *
 end_revprop_change(svn_fs_t *fs,
-                   apr_int64_t generation,
                    apr_pool_t *scratch_pool)
 {
   svn_fs_x__data_t *ffd = fs->fsap_data;
   SVN_ERR_ASSERT(ffd->has_write_lock);
-  SVN_ERR_ASSERT(generation % 2);
+  SVN_ERR_ASSERT(ffd->revprop_generation % 2);
 
   /* Set the revprop generation to an even value to indicate
    * that a write has been completed.  Since we held the write
    * lock, nobody else could have updated the file contents.
    */
-  SVN_ERR(write_revprop_generation_file(fs, generation + 1, scratch_pool));
+  SVN_ERR(write_revprop_generation_file(fs, ffd->revprop_generation + 1,
+                                        scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -335,9 +333,6 @@ typedef struct packed_revprops_t
   /* revision number to read (not necessarily the first in the pack) */
   svn_revnum_t revision;
 
-  /* current revprop generation. Used when populating the revprop cache */
-  apr_int64_t generation;
-
   /* the actual revision properties */
   apr_hash_t *properties;
 
@@ -381,8 +376,7 @@ typedef struct packed_revprops_t
 /* Parse the serialized revprops in CONTENT and return them in *PROPERTIES.
  * Also, put them into the revprop cache, if activated, for future use.
  * Three more parameters are being used to update the revprop cache: FS is
- * our file system, the revprops belong to REVISION and the global revprop
- * GENERATION is used as well.
+ * our file system, the revprops belong to REVISION.
  *
  * The returned hash will be allocated in RESULT_POOL, SCRATCH_POOL is
  * being used for temporary allocations.
@@ -391,7 +385,6 @@ static svn_error_t *
 parse_revprop(apr_hash_t **properties,
               svn_fs_t *fs,
               svn_revnum_t revision,
-              apr_int64_t generation,
               svn_string_t *content,
               apr_pool_t *result_pool,
               apr_pool_t *scratch_pool)
@@ -407,7 +400,7 @@ parse_revprop(apr_hash_t **properties,
       svn_fs_x__pair_cache_key_t key = { 0 };
 
       key.revision = revision;
-      key.second = generation;
+      key.second = ffd->revprop_generation;
       SVN_ERR(svn_cache__set(ffd->revprop_cache, &key, *properties,
                              scratch_pool));
     }
@@ -416,8 +409,7 @@ parse_revprop(apr_hash_t **properties,
 }
 
 /* Read the non-packed revprops for revision REV in FS, put them into the
- * revprop cache if activated and return them in *PROPERTIES.  GENERATION
- * is the current revprop generation.
+ * revprop cache if activated and return them in *PROPERTIES.
  *
  * If the data could not be read due to an otherwise recoverable error,
  * leave *PROPERTIES unchanged. No error will be returned in that case.
@@ -428,7 +420,6 @@ static svn_error_t *
 read_non_packed_revprop(apr_hash_t **properties,
                         svn_fs_t *fs,
                         svn_revnum_t rev,
-                        apr_int64_t generation,
                         apr_pool_t *result_pool,
                         apr_pool_t *scratch_pool)
 {
@@ -450,7 +441,7 @@ read_non_packed_revprop(apr_hash_t **pro
     }
 
   if (content)
-    SVN_ERR(parse_revprop(properties, fs, rev, generation,
+    SVN_ERR(parse_revprop(properties, fs, rev,
                           svn_stringbuf__morph_into_string(content),
                           result_pool, iterpool));
 
@@ -697,8 +688,7 @@ parse_packed_revprops(svn_fs_t *fs,
         {
           /* Parse (and possibly cache) the one revprop list we care about. */
           SVN_ERR(parse_revprop(&revprops->properties, fs, revision,
-                                revprops->generation, &serialized,
-                                result_pool, iterpool));
+                                &serialized, result_pool, iterpool));
           revprops->serialized_size = serialized.len;
 
           /* If we only wanted the revprops for REVISION then we are done. */
@@ -709,8 +699,7 @@ parse_packed_revprops(svn_fs_t *fs,
         {
           /* Parse and cache all other revprop lists. */
           apr_hash_t *properties;
-          SVN_ERR(parse_revprop(&properties, fs, revision,
-                                revprops->generation, &serialized,
+          SVN_ERR(parse_revprop(&properties, fs, revision, &serialized,
                                 iterpool, iterpool));
         }
 
@@ -729,9 +718,9 @@ parse_packed_revprops(svn_fs_t *fs,
 }
 
 /* In filesystem FS, read the packed revprops for revision REV into
- * *REVPROPS.  Use GENERATION to populate the revprop cache, if enabled.
- * If you want to modify revprop contents / update REVPROPS, READ_ALL
- * must be set.  Otherwise, only the properties of REV are being provided.
+ * *REVPROPS.  Populate the revprop cache, if enabled.  If you want to
+ * modify revprop contents / update REVPROPS, READ_ALL must be set.
+ * Otherwise, only the properties of REV are being provided.
  *
  * Allocate *PROPERTIES in RESULT_POOL and temporaries in SCRATCH_POOL.
  */
@@ -739,7 +728,6 @@ static svn_error_t *
 read_pack_revprop(packed_revprops_t **revprops,
                   svn_fs_t *fs,
                   svn_revnum_t rev,
-                  apr_int64_t generation,
                   svn_boolean_t read_all,
                   apr_pool_t *result_pool,
                   apr_pool_t *scratch_pool)
@@ -761,7 +749,6 @@ read_pack_revprop(packed_revprops_t **re
   /* initialize the result data structure */
   result = apr_pcalloc(result_pool, sizeof(*result));
   result->revision = rev;
-  result->generation = generation;
 
   /* try to read the packed revprops. This may require retries if we have
    * concurrent writers. */
@@ -791,7 +778,7 @@ read_pack_revprop(packed_revprops_t **re
        * consider it outdated, otherwise.
        */
       if (missing && has_revprop_cache(fs, iterpool))
-        SVN_ERR(read_revprop_generation(&result->generation, fs, iterpool));
+        SVN_ERR(read_revprop_generation(fs, iterpool));
     }
 
   /* the file content should be available now */
@@ -811,10 +798,6 @@ read_pack_revprop(packed_revprops_t **re
   return SVN_NO_ERROR;
 }
 
-/* Read the revprops for revision REV in FS and return them in *PROPERTIES_P.
- *
- * Allocations will be done in POOL.
- */
 svn_error_t *
 svn_fs_x__get_revision_proplist(apr_hash_t **proplist_p,
                                 svn_fs_t *fs,
@@ -824,7 +807,6 @@ svn_fs_x__get_revision_proplist(apr_hash
                                 apr_pool_t *scratch_pool)
 {
   svn_fs_x__data_t *ffd = fs->fsap_data;
-  apr_int64_t generation = 0;
 
   /* not found, yet */
   *proplist_p = NULL;
@@ -838,10 +820,10 @@ svn_fs_x__get_revision_proplist(apr_hash
       svn_boolean_t is_cached;
       svn_fs_x__pair_cache_key_t key = { 0 };
 
-      SVN_ERR(read_revprop_generation(&generation, fs, scratch_pool));
+      SVN_ERR(read_revprop_generation(fs, scratch_pool));
 
       key.revision = rev;
-      key.second = generation;
+      key.second = ffd->revprop_generation;
       SVN_ERR(svn_cache__get((void **) proplist_p, &is_cached,
                              ffd->revprop_cache, &key, result_pool));
       if (is_cached)
@@ -854,8 +836,7 @@ svn_fs_x__get_revision_proplist(apr_hash
   if (!svn_fs_x__is_packed_revprop(fs, rev))
     {
       svn_error_t *err = read_non_packed_revprop(proplist_p, fs, rev,
-                                                 generation, result_pool,
-                                                 scratch_pool);
+                                                 result_pool, scratch_pool);
       if (err)
         {
           if (!APR_STATUS_IS_ENOENT(err->apr_err))
@@ -872,7 +853,7 @@ svn_fs_x__get_revision_proplist(apr_hash
   if (!*proplist_p)
     {
       packed_revprops_t *revprops;
-      SVN_ERR(read_pack_revprop(&revprops, fs, rev, generation, FALSE,
+      SVN_ERR(read_pack_revprop(&revprops, fs, rev, FALSE,
                                 result_pool, scratch_pool));
       *proplist_p = revprops->properties;
     }
@@ -945,19 +926,17 @@ switch_to_new_revprop(svn_fs_t *fs,
                       svn_boolean_t bump_generation,
                       apr_pool_t *scratch_pool)
 {
-  apr_int64_t generation;
-
   /* Now, we may actually be replacing revprops. Make sure that all other
      threads and processes will know about this. */
   if (bump_generation)
-    SVN_ERR(begin_revprop_change(&generation, fs, scratch_pool));
+    SVN_ERR(begin_revprop_change(fs, scratch_pool));
 
   SVN_ERR(svn_fs_x__move_into_place(tmp_path, final_path, perms_reference,
                                     scratch_pool));
 
   /* Indicate that the update (if relevant) has been completed. */
   if (bump_generation)
-    SVN_ERR(end_revprop_change(fs, generation, scratch_pool));
+    SVN_ERR(end_revprop_change(fs, scratch_pool));
 
   /* Clean up temporary files, if necessary. */
   if (files_to_delete)
@@ -1179,7 +1158,6 @@ write_packed_revprop(const char **final_
 {
   svn_fs_x__data_t *ffd = fs->fsap_data;
   packed_revprops_t *revprops;
-  apr_int64_t generation = 0;
   svn_stream_t *stream;
   apr_file_t *file;
   svn_stringbuf_t *serialized;
@@ -1189,10 +1167,10 @@ write_packed_revprop(const char **final_
   /* read the current revprop generation. This value will not change
    * while we hold the global write lock to this FS. */
   if (has_revprop_cache(fs, scratch_pool))
-    SVN_ERR(read_revprop_generation(&generation, fs, scratch_pool));
+    SVN_ERR(read_revprop_generation(fs, scratch_pool));
 
   /* read contents of the current pack file */
-  SVN_ERR(read_pack_revprop(&revprops, fs, rev, generation, TRUE,
+  SVN_ERR(read_pack_revprop(&revprops, fs, rev, TRUE,
                             scratch_pool, scratch_pool));
 
   /* serialize the new revprops */



Mime
View raw message