subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1785053 - /subversion/trunk/subversion/libsvn_fs_fs/transaction.c
Date Wed, 01 Mar 2017 22:14:34 GMT
Author: stefan2
Date: Wed Mar  1 22:14:34 2017
New Revision: 1785053

URL: http://svn.apache.org/viewvc?rev=1785053&view=rev
Log:
In FSFS, explictly disable rep-sharing for directory representations.

Until now, directory reps would not be added to the rep-cache in any case
but we would still allow for other reps to replace a given new directory.
That was a mere side-effect of using the same code for directories as for
property hashes.  Now, we explicitly prevent rep-sharing even the rare
edge-case where a directory hash might accidentally match some file or
prop representation.

* subversion/libsvn_fs_fs/transaction.c
  (write_container_rep,
   write_container_delta_rep): Add option to disable explictly rep-sharing.
  (write_final_rev): Update caller, explicitly disabling rep-sharing for
                     directories.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/transaction.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1785053&r1=1785052&r2=1785053&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Wed Mar  1 22:14:34 2017
@@ -2678,11 +2678,16 @@ write_directory_to_stream(svn_stream_t *
 /* Write out the COLLECTION as a text representation to file FILE using
    WRITER.  In the process, record position, the total size of the dump and
    MD5 as well as SHA1 in REP.   Add the representation of type ITEM_TYPE to
-   the indexes if necessary.  If rep sharing has been enabled and REPS_HASH
-   is not NULL, it will be used in addition to the on-disk cache to find
-   earlier reps with the same content.  When such existing reps can be
-   found, we will truncate the one just written from the file and return
-   the existing rep.  Perform temporary allocations in SCRATCH_POOL. */
+   the indexes if necessary.
+
+   If ALLOW_REP_SHARING is FALSE, rep-sharing will not be used, regardless
+   of any other option and rep-sharing settings.  If rep sharing has been
+   enabled and REPS_HASH is not NULL, it will be used in addition to the
+   on-disk cache to find earlier reps with the same content.  If such
+   existing reps can be found, we will truncate the one just written from
+   the file and return the existing rep.
+
+   Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
 write_container_rep(representation_t *rep,
                     apr_file_t *file,
@@ -2690,13 +2695,13 @@ write_container_rep(representation_t *re
                     collection_writer_t writer,
                     svn_fs_t *fs,
                     apr_hash_t *reps_hash,
+                    svn_boolean_t allow_rep_sharing,
                     apr_uint32_t item_type,
                     apr_pool_t *scratch_pool)
 {
   svn_stream_t *stream;
   struct write_container_baton *whb;
   svn_checksum_ctx_t *fnv1a_checksum_ctx;
-  representation_t *old_rep;
   apr_off_t offset = 0;
 
   SVN_ERR(svn_io_file_get_offset(&offset, file, scratch_pool));
@@ -2727,17 +2732,21 @@ write_container_rep(representation_t *re
   /* Check and see if we already have a representation somewhere that's
      identical to the one we just wrote out. */
   rep->expanded_size = whb->size;
-  SVN_ERR(get_shared_rep(&old_rep, fs, rep, reps_hash, scratch_pool,
-                         scratch_pool));
-
-  if (old_rep)
+  if (allow_rep_sharing)
     {
-      /* We need to erase from the protorev the data we just wrote. */
-      SVN_ERR(svn_io_file_trunc(file, offset, scratch_pool));
+      representation_t *old_rep;
+      SVN_ERR(get_shared_rep(&old_rep, fs, rep, reps_hash, scratch_pool,
+                             scratch_pool));
 
-      /* Use the old rep for this content. */
-      memcpy(rep, old_rep, sizeof (*rep));
-      return SVN_NO_ERROR;
+      if (old_rep)
+        {
+          /* We need to erase from the protorev the data we just wrote. */
+          SVN_ERR(svn_io_file_trunc(file, offset, scratch_pool));
+
+          /* Use the old rep for this content. */
+          memcpy(rep, old_rep, sizeof (*rep));
+          return SVN_NO_ERROR;
+        }
     }
 
   /* Write out our cosmetic end marker. */
@@ -2772,11 +2781,14 @@ write_container_rep(representation_t *re
 /* Write out the COLLECTION pertaining to the NODEREV in FS as a deltified
    text representation to file FILE using WRITER.  In the process, record the
    total size and the md5 digest in REP and add the representation of type
-   ITEM_TYPE to the indexes if necessary.  If rep sharing has been enabled and
-   REPS_HASH is not NULL, it will be used in addition to the on-disk cache to
-   find earlier reps with the same content.  When such existing reps can be
-   found, we will truncate the one just written from the file and return the
-   existing rep.
+   ITEM_TYPE to the indexes if necessary.
+
+   If ALLOW_REP_SHARING is FALSE, rep-sharing will not be used, regardless
+   of any other option and rep-sharing settings.  If rep sharing has been
+   enabled and REPS_HASH is not NULL, it will be used in addition to the
+   on-disk cache to find earlier reps with the same content.  If such
+   existing reps can be found, we will truncate the one just written from
+   the file and return the existing rep.
 
    If ITEM_TYPE is IS_PROPS equals SVN_FS_FS__ITEM_TYPE_*_PROPS, assume
    that we want to a props representation as the base for our delta.
@@ -2790,6 +2802,7 @@ write_container_delta_rep(representation
                           svn_fs_t *fs,
                           node_revision_t *noderev,
                           apr_hash_t *reps_hash,
+                          svn_boolean_t allow_rep_sharing,
                           apr_uint32_t item_type,
                           apr_pool_t *scratch_pool)
 {
@@ -2799,7 +2812,6 @@ write_container_delta_rep(representation
   svn_stream_t *file_stream;
   svn_stream_t *stream;
   representation_t *base_rep;
-  representation_t *old_rep;
   svn_checksum_ctx_t *fnv1a_checksum_ctx;
   svn_stream_t *source;
   svn_fs_fs__rep_header_t header = { 0 };
@@ -2871,17 +2883,21 @@ write_container_delta_rep(representation
   /* Check and see if we already have a representation somewhere that's
      identical to the one we just wrote out. */
   rep->expanded_size = whb->size;
-  SVN_ERR(get_shared_rep(&old_rep, fs, rep, reps_hash, scratch_pool,
-                         scratch_pool));
-
-  if (old_rep)
+  if (allow_rep_sharing)
     {
-      /* We need to erase from the protorev the data we just wrote. */
-      SVN_ERR(svn_io_file_trunc(file, offset, scratch_pool));
+      representation_t *old_rep;
+      SVN_ERR(get_shared_rep(&old_rep, fs, rep, reps_hash, scratch_pool,
+                             scratch_pool));
 
-      /* Use the old rep for this content. */
-      memcpy(rep, old_rep, sizeof (*rep));
-      return SVN_NO_ERROR;
+      if (old_rep)
+        {
+          /* We need to erase from the protorev the data we just wrote. */
+          SVN_ERR(svn_io_file_trunc(file, offset, scratch_pool));
+
+          /* Use the old rep for this content. */
+          memcpy(rep, old_rep, sizeof (*rep));
+          return SVN_NO_ERROR;
+        }
     }
 
   /* Write out our cosmetic end marker. */
@@ -3095,13 +3111,14 @@ write_final_rev(const svn_fs_id_t **new_
             SVN_ERR(write_container_delta_rep(noderev->data_rep, file,
                                               entries,
                                               write_directory_to_stream,
-                                              fs, noderev, NULL,
+                                              fs, noderev, NULL, FALSE,
                                               SVN_FS_FS__ITEM_TYPE_DIR_REP,
                                               pool));
           else
             SVN_ERR(write_container_rep(noderev->data_rep, file, entries,
                                         write_directory_to_stream, fs, NULL,
-                                        SVN_FS_FS__ITEM_TYPE_DIR_REP, pool));
+                                        FALSE, SVN_FS_FS__ITEM_TYPE_DIR_REP,
+                                        pool));
 
           reset_txn_in_rep(noderev->data_rep);
 
@@ -3163,11 +3180,11 @@ write_final_rev(const svn_fs_id_t **new_
       if (ffd->deltify_properties)
         SVN_ERR(write_container_delta_rep(noderev->prop_rep, file, proplist,
                                           write_hash_to_stream, fs, noderev,
-                                          reps_hash, item_type, pool));
+                                          reps_hash, TRUE, item_type, pool));
       else
         SVN_ERR(write_container_rep(noderev->prop_rep, file, proplist,
                                     write_hash_to_stream, fs, reps_hash,
-                                    item_type, pool));
+                                    item_type, TRUE, pool));
 
       reset_txn_in_rep(noderev->prop_rep);
     }



Mime
View raw message