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/09/25 12:08:25 UTC

svn commit: r1627497 - in /subversion/trunk/subversion: libsvn_fs_fs/cached_data.c libsvn_fs_fs/index.c libsvn_fs_fs/index.h libsvn_fs_fs/pack.c libsvn_fs_fs/verify.c svnfsfs/dump-index-cmd.c svnfsfs/stats-cmd.c

Author: stefan2
Date: Thu Sep 25 10:08:24 2014
New Revision: 1627497

URL: http://svn.apache.org/r1627497
Log:
Switch FSFS index API functions that could actually use two different pool
parameters to the two-pool paradigm.

Although almost all current callers will pass the same (temporary) pool to
both parameters, this patch improves consistency, readability and
documentation.

* subversion/libsvn_fs_fs/index.h
  (svn_fs_fs__p2l_index_lookup,
   svn_fs_fs__p2l_entry_lookup,
   svn_fs_fs__l2p_get_max_ids): Accept two pools instead of one.

* subversion/libsvn_fs_fs/index.c
  (p2l_index_lookup): The POOL parameter is actually a SCRATCH_POOL. All
                      results are flat data stored in the pre-allocated
                      *ENTRIES result.
  (svn_fs_fs__l2p_get_max_ids,
   svn_fs_fs__p2l_index_lookup): Only the result array needs to be allocated
                                 in the RESULT_POOL. It contains flat data
                                 and no pointers.
  (svn_fs_fs__p2l_entry_lookup): Use the SCRATCH_POOL with function calls
                                 only require a temporary pool.

* subversion/libsvn_fs_fs/cached_data.c
  (svn_fs_fs__check_rep,
   block_read): Update caller by passing the same pool to both parameters.
                That pool is already for temporaries only.

* subversion/libsvn_fs_fs/pack.c
  (pack_range,
   append_revision): Same.
  (pack_log_addressed): Update caller, actually providing different pools.

* subversion/libsvn_fs_fs/verify.c
  (compare_l2p_to_p2l_index): Same.
  (compare_p2l_to_l2p_index,
   compare_p2l_to_rev): Update caller by passing the same temporary pool
                        to both parameters.

* subversion/svnfsfs/dump-index-cmd.c
  (dump_index): Same.

* subversion/svnfsfs/stats-cmd.c
  (read_log_rev_or_packfile): Same.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
    subversion/trunk/subversion/libsvn_fs_fs/index.c
    subversion/trunk/subversion/libsvn_fs_fs/index.h
    subversion/trunk/subversion/libsvn_fs_fs/pack.c
    subversion/trunk/subversion/libsvn_fs_fs/verify.c
    subversion/trunk/subversion/svnfsfs/dump-index-cmd.c
    subversion/trunk/subversion/svnfsfs/stats-cmd.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1627497&r1=1627496&r2=1627497&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Thu Sep 25 10:08:24 2014
@@ -937,8 +937,9 @@ svn_fs_fs__check_rep(representation_t *r
 
       /* This may fail if there is a background pack operation (can't auto-
          retry because the item offset lookup has to be redone as well). */
-      SVN_ERR(svn_fs_fs__p2l_entry_lookup(&entry, fs, rev_file, rep->revision,
-                                          offset, scratch_pool));
+      SVN_ERR(svn_fs_fs__p2l_entry_lookup(&entry, fs, rev_file,
+                                          rep->revision, offset,
+                                          scratch_pool, scratch_pool));
 
       if (   entry == NULL
           || entry->type < SVN_FS_FS__ITEM_TYPE_FILE_REP
@@ -3251,7 +3252,8 @@ block_read(void **result,
       block_start = offset - (offset % ffd->block_size);
       SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, fs, revision_file,
                                           revision, block_start,
-                                          ffd->block_size, scratch_pool));
+                                          ffd->block_size, scratch_pool,
+                                          scratch_pool));
 
       SVN_ERR(aligned_seek(fs, revision_file->file, &block_start, offset,
                            iterpool));

Modified: subversion/trunk/subversion/libsvn_fs_fs/index.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/index.c?rev=1627497&r1=1627496&r2=1627497&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/index.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/index.c Thu Sep 25 10:08:24 2014
@@ -1477,13 +1477,14 @@ svn_fs_fs__l2p_get_max_ids(apr_array_hea
                            svn_fs_t *fs,
                            svn_revnum_t start_rev,
                            apr_size_t count,
-                           apr_pool_t *pool)
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool)
 {
   l2p_header_t *header = NULL;
   svn_revnum_t revision;
   svn_revnum_t last_rev = (svn_revnum_t)(start_rev + count);
   svn_fs_fs__revision_file_t *rev_file;
-  apr_pool_t *header_pool = svn_pool_create(pool);
+  apr_pool_t *header_pool = svn_pool_create(scratch_pool);
 
   /* read index master data structure for the index covering START_REV */
   SVN_ERR(svn_fs_fs__open_pack_or_rev_file(&rev_file, fs, start_rev,
@@ -1494,7 +1495,7 @@ svn_fs_fs__l2p_get_max_ids(apr_array_hea
 
   /* Determine the length of the item index list for each rev.
    * Read new index headers as required. */
-  *max_ids = apr_array_make(pool, (int)count, sizeof(apr_uint64_t));
+  *max_ids = apr_array_make(result_pool, (int)count, sizeof(apr_uint64_t));
   for (revision = start_rev; revision < last_rev; ++revision)
     {
       apr_uint64_t full_page_count;
@@ -2374,7 +2375,7 @@ p2l_index_lookup(apr_array_header_t *ent
                  svn_revnum_t revision,
                  apr_off_t block_start,
                  apr_off_t block_end,
-                 apr_pool_t *pool)
+                 apr_pool_t *scratch_pool)
 {
   fs_fs_data_t *ffd = fs->fsap_data;
   svn_fs_fs__page_cache_key_t key;
@@ -2392,15 +2393,15 @@ p2l_index_lookup(apr_array_header_t *ent
 
   /* look for the fist page of the range in our cache */
   SVN_ERR(get_p2l_keys(&page_info, &key, rev_file, fs, revision, block_start,
-                       pool));
+                       scratch_pool));
   SVN_ERR(svn_cache__get_partial((void**)&local_result, &is_cached,
                                  ffd->p2l_page_cache, &key, p2l_entries_func,
-                                 &block, pool));
+                                 &block, scratch_pool));
 
   if (!is_cached)
     {
       svn_boolean_t end;
-      apr_pool_t *iterpool = svn_pool_create(pool);
+      apr_pool_t *iterpool = svn_pool_create(scratch_pool);
       apr_off_t original_page_start = page_info.page_start;
       int leaking_bucket = 4;
       p2l_page_info_baton_t prefetch_info = page_info;
@@ -2514,13 +2515,14 @@ svn_fs_fs__p2l_index_lookup(apr_array_he
                             svn_revnum_t revision,
                             apr_off_t block_start,
                             apr_off_t block_size,
-                            apr_pool_t *pool)
+                            apr_pool_t *result_pool,
+                            apr_pool_t *scratch_pool)
 {
   apr_off_t block_end = block_start + block_size;
 
   /* the receiving container */
   int last_count = 0;
-  apr_array_header_t *result = apr_array_make(pool, 16,
+  apr_array_header_t *result = apr_array_make(result_pool, 16,
                                               sizeof(svn_fs_fs__p2l_entry_t));
 
   /* Fetch entries page-by-page.  Since the p2l index is supposed to cover
@@ -2530,7 +2532,7 @@ svn_fs_fs__p2l_index_lookup(apr_array_he
     {
       svn_fs_fs__p2l_entry_t *entry;
       SVN_ERR(p2l_index_lookup(result, rev_file, fs, revision, block_start,
-                               block_end, pool));
+                               block_end, scratch_pool));
       SVN_ERR_ASSERT(result->nelts > 0);
 
       /* continue directly behind last item */
@@ -2623,7 +2625,8 @@ svn_fs_fs__p2l_entry_lookup(svn_fs_fs__p
                             svn_fs_fs__revision_file_t *rev_file,
                             svn_revnum_t revision,
                             apr_off_t offset,
-                            apr_pool_t *pool)
+                            apr_pool_t *result_pool,
+                            apr_pool_t *scratch_pool)
 {
   fs_fs_data_t *ffd = fs->fsap_data;
   svn_fs_fs__page_cache_key_t key = { 0 };
@@ -2634,17 +2637,19 @@ svn_fs_fs__p2l_entry_lookup(svn_fs_fs__p
 
   /* look for this info in our cache */
   SVN_ERR(get_p2l_keys(&page_info, &key, rev_file, fs, revision, offset,
-                       pool));
+                       scratch_pool));
   SVN_ERR(svn_cache__get_partial((void**)entry_p, &is_cached,
                                  ffd->p2l_page_cache, &key,
-                                 p2l_entry_lookup_func, &offset, pool));
+                                 p2l_entry_lookup_func, &offset,
+                                 result_pool));
   if (!is_cached)
     {
       /* do a standard index lookup.  This is will automatically prefetch
        * data to speed up future lookups. */
-      apr_array_header_t *entries = apr_array_make(pool, 1, sizeof(**entry_p));
+      apr_array_header_t *entries = apr_array_make(result_pool, 1,
+                                                   sizeof(**entry_p));
       SVN_ERR(p2l_index_lookup(entries, rev_file, fs, revision, offset,
-                               offset + 1, pool));
+                               offset + 1, scratch_pool));
 
       /* Find the entry that we want. */
       *entry_p = svn_sort__array_lookup(entries, &offset, NULL,

Modified: subversion/trunk/subversion/libsvn_fs_fs/index.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/index.h?rev=1627497&r1=1627496&r2=1627497&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/index.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/index.h Thu Sep 25 10:08:24 2014
@@ -157,10 +157,11 @@ svn_fs_fs__p2l_index_append(svn_fs_t *fs
 /* Use the phys-to-log mapping files in FS to build a list of entries
  * that (at least partly) overlap with the range given by BLOCK_START
  * offset and BLOCK_SIZE in the rep / pack file containing REVISION.
- * Return the array in *ENTRIES with svn_fs_fs__p2l_entry_t as elements.
- * REV_FILE determines whether to access single rev or pack file data.
- * If that is not available anymore (neither in cache nor on disk),
- * return an error.  Use POOL for allocations.
+ * Return the array in *ENTRIES with svn_fs_fs__p2l_entry_t as elements,
+ * allocated in RESULT_POOL.  REV_FILE determines whether to access single
+ * rev or pack file data.  If that is not available anymore (neither in
+ * cache nor on disk), return an error.  Use SCRATCH_POOL for temporary
+ * allocations.
  *
  * Note that (only) the first and the last mapping may cross a cluster
  * boundary.
@@ -172,14 +173,16 @@ svn_fs_fs__p2l_index_lookup(apr_array_he
                             svn_revnum_t revision,
                             apr_off_t block_start,
                             apr_off_t block_size,
-                            apr_pool_t *pool);
+                            apr_pool_t *result_pool,
+                            apr_pool_t *scratch_pool);
 
 /* Use the phys-to-log mapping files in FS to return the entry for the
  * item starting at global OFFSET in the rep file containing REVISION in
- * *ENTRY.  Sets *ENTRY to NULL if no item starts at exactly that offset.
- * REV_FILE determines whether to access single rev or pack file data.
- * If that is not available anymore (neither in cache nor on disk),
- * return an error.  Use POOL for allocations.
+ * *ENTRY, allocated in RESULT_POOL.  Sets *ENTRY to NULL if no item starts
+ * at exactly that offset.  REV_FILE determines whether to access single
+ * rev or pack file data.  If that is not available anymore (neither in
+ * cache nor on disk), return an error.  Use SCRATCH_POOL for temporary
+ * allocations.
  */
 svn_error_t *
 svn_fs_fs__p2l_entry_lookup(svn_fs_fs__p2l_entry_t **entry,
@@ -187,7 +190,8 @@ svn_fs_fs__p2l_entry_lookup(svn_fs_fs__p
                             svn_fs_fs__revision_file_t *rev_file,
                             svn_revnum_t revision,
                             apr_off_t offset,
-                            apr_pool_t *pool);
+                            apr_pool_t *result_pool,
+                            apr_pool_t *scratch_pool);
 
 /* For ITEM_INDEX within REV in FS, return the position in the respective
  * rev or pack file in *ABSOLUTE_POSITION.  If TXN_ID is not NULL, return
@@ -212,14 +216,16 @@ svn_fs_fs__item_offset(apr_off_t *absolu
 /* Use the log-to-phys indexes in FS to determine the maximum item indexes
  * assigned to revision START_REV to START_REV + COUNT - 1.  That is a
  * close upper limit to the actual number of items in the respective revs.
- * Return the results in *MAX_IDS,  allocated in POOL.
+ * Return the results in *MAX_IDS,  allocated in RESULT_POOL.
+ * Use SCRATCH_POOL for temporary allocations.
  */
 svn_error_t *
 svn_fs_fs__l2p_get_max_ids(apr_array_header_t **max_ids,
                            svn_fs_t *fs,
                            svn_revnum_t start_rev,
                            apr_size_t count,
-                           apr_pool_t *pool);
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool);
 
 /* In *OFFSET, return the last OFFSET in the pack / rev file containing.
  * REV_FILE determines whether to access single rev or pack file data.

Modified: subversion/trunk/subversion/libsvn_fs_fs/pack.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/pack.c?rev=1627497&r1=1627496&r2=1627497&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/pack.c Thu Sep 25 10:08:24 2014
@@ -1307,7 +1307,8 @@ pack_range(pack_context_t *context,
 
           SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, context->fs,
                                               rev_file, revision, offset,
-                                              ffd->p2l_page_size, iterpool));
+                                              ffd->p2l_page_size, iterpool,
+                                              iterpool));
 
           for (i = 0; i < entries->nelts; ++i)
             {
@@ -1441,7 +1442,8 @@ append_revision(pack_context_t *context,
       svn_pool_clear(iterpool);
       SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, context->fs, rev_file,
                                           context->start_rev, offset,
-                                          ffd->p2l_page_size, iterpool));
+                                          ffd->p2l_page_size, iterpool,
+                                          iterpool));
 
       for (i = 0; i < entries->nelts; ++i)
         {
@@ -1527,7 +1529,7 @@ pack_log_addressed(svn_fs_t *fs,
   /* phase 1: determine the size of the revisions to pack */
   SVN_ERR(svn_fs_fs__l2p_get_max_ids(&max_ids, fs, shard_rev,
                                      context.shard_end_rev - shard_rev,
-                                     pool));
+                                     pool, pool));
 
   /* pack revisions in ranges that don't exceed MAX_MEM */
   for (i = 0; i < max_ids->nelts; ++i)

Modified: subversion/trunk/subversion/libsvn_fs_fs/verify.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/verify.c?rev=1627497&r1=1627496&r2=1627497&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/verify.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/verify.c Thu Sep 25 10:08:24 2014
@@ -182,7 +182,8 @@ compare_l2p_to_p2l_index(svn_fs_t *fs,
                                            iterpool));
 
   /* determine the range of items to check for each revision */
-  SVN_ERR(svn_fs_fs__l2p_get_max_ids(&max_ids, fs, start, count, pool));
+  SVN_ERR(svn_fs_fs__l2p_get_max_ids(&max_ids, fs, start, count, pool,
+                                     iterpool));
 
   /* check all items in all revisions if the given range */
   for (i = 0; i < max_ids->nelts; ++i)
@@ -205,7 +206,8 @@ compare_l2p_to_p2l_index(svn_fs_t *fs,
 
           /* find the corresponding P2L entry */
           SVN_ERR(svn_fs_fs__p2l_entry_lookup(&p2l_entry, fs, rev_file,
-                                              revision, offset, iterpool));
+                                              revision, offset, iterpool,
+                                              iterpool));
 
           if (p2l_entry == NULL)
             return svn_error_createf(SVN_ERR_FS_ITEM_INDEX_INCONSISTENT,
@@ -282,7 +284,7 @@ compare_p2l_to_l2p_index(svn_fs_t *fs,
       /* get all entries for the current block */
       SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, fs, rev_file, start,
                                           offset, ffd->p2l_page_size,
-                                          iterpool));
+                                          iterpool, iterpool));
       if (entries->nelts == 0)
         return svn_error_createf(SVN_ERR_FS_ITEM_INDEX_CORRUPTION,
                                  NULL,
@@ -532,7 +534,7 @@ compare_p2l_to_rev(svn_fs_t *fs,
       /* get all entries for the current block */
       SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, fs, rev_file, start,
                                           offset, ffd->p2l_page_size,
-                                          iterpool));
+                                          iterpool, iterpool));
 
       /* process all entries (and later continue with the next block) */
       for (i = 0; i < entries->nelts; ++i)

Modified: subversion/trunk/subversion/svnfsfs/dump-index-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnfsfs/dump-index-cmd.c?rev=1627497&r1=1627496&r2=1627497&view=diff
==============================================================================
--- subversion/trunk/subversion/svnfsfs/dump-index-cmd.c (original)
+++ subversion/trunk/subversion/svnfsfs/dump-index-cmd.c Thu Sep 25 10:08:24 2014
@@ -93,7 +93,7 @@ dump_index(const char *path,
       svn_pool_clear(iterpool);
       SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, fs, rev_file, revision,
                                           offset, INDEX_BLOCK_SIZE,
-                                          iterpool));
+                                          iterpool, iterpool));
 
       /* Print entries for this block, one line per entry. */
       for (i = 0; i < entries->nelts && offset < max_offset; ++i)

Modified: subversion/trunk/subversion/svnfsfs/stats-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnfsfs/stats-cmd.c?rev=1627497&r1=1627496&r2=1627497&view=diff
==============================================================================
--- subversion/trunk/subversion/svnfsfs/stats-cmd.c (original)
+++ subversion/trunk/subversion/svnfsfs/stats-cmd.c Thu Sep 25 10:08:24 2014
@@ -1425,7 +1425,7 @@ read_log_rev_or_packfile(fs_t *fs,
       /* get all entries for the current block */
       SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, fs->fs, rev_file, base,
                                           offset, INDEX_BLOCK_SIZE,
-                                          iterpool));
+                                          iterpool, iterpool));
 
       /* process all entries (and later continue with the next block) */
       for (i = 0; i < entries->nelts; ++i)