subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1662689 - in /subversion/branches/fsx-1.10/subversion/libsvn_fs_x: index.c index.h rev_file.c rev_file.h
Date Fri, 27 Feb 2015 14:48:52 GMT
Author: stefan2
Date: Fri Feb 27 14:48:52 2015
New Revision: 1662689

URL: http://svn.apache.org/r1662689
Log:
On the fsx-1.10 branch:
Access the packed stream elements of svn_fs_x__revision_file_t through
access functions only.

To do this, we need to promote some local definitions to private API.

* subversion/libsvn_fs_x/rev_file.h
  (svn_fs_x__rev_file_l2p_index,
   svn_fs_x__rev_file_p2l_index): Declare new acccess functions.

* subversion/libsvn_fs_x/rev_file.c
  (svn_fs_x__rev_file_l2p_index,
   svn_fs_x__rev_file_p2l_index): Implement them. Take the logic from the
                                  former auto_open_* functions in index.c.

* subversion/libsvn_fs_x/index.h
  (SVN_FS_X__L2P_STREAM_PREFIX,
   SVN_FS_X__P2L_STREAM_PREFIX): Move here from index.c and add the
                                 SVN_FS_X__ prefix.
  (svn_fs_x__packed_stream_open): Rename former packed_stream_open and
                                  make it available as private API.

* subversion/libsvn_fs_x/index.c
  (L2P_STREAM_PREFIX,
   P2L_STREAM_PREFIX): Remove here.
  (STREAM_PREFIX_LEN): Update.
  (packed_stream_open): Rename to ...
  (svn_fs_x__packed_stream_open): ... this and make it non-static.

  (svn_fs_x__l2p_index_append): Update macro reference.
  (auto_open_l2p_index): Remove.
  (get_l2p_header_body, 
   get_l2p_page): Call the new rev_file accessor function instead.

  (svn_fs_x__p2l_index_append): Update macro reference.
  (auto_open_p2l_index): Remove.
  (get_p2l_header,
   get_p2l_page): Call the new rev_file accessor function instead.

Modified:
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.h
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c?rev=1662689&r1=1662688&r2=1662689&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.c Fri Feb 27 14:48:52 2015
@@ -61,15 +61,9 @@ const apr_uint64_t off_t_max = (sizeof(a
  */
 #define P2L_PROTO_INDEX_ENTRY_SIZE (6 * sizeof(apr_uint64_t))
 
-/* We put this string in front of the L2P index header. */
-#define L2P_STREAM_PREFIX "L2P-INDEX\n"
-
-/* We put this string in front of the P2L index header. */
-#define P2L_STREAM_PREFIX "P2L-INDEX\n"
-
 /* Size of the buffer that will fit the index header prefixes. */
-#define STREAM_PREFIX_LEN MAX(sizeof(L2P_STREAM_PREFIX), \
-                              sizeof(P2L_STREAM_PREFIX))
+#define STREAM_PREFIX_LEN MAX(sizeof(SVN_FS_X__L2P_STREAM_PREFIX), \
+                              sizeof(SVN_FS_X__P2L_STREAM_PREFIX))
 
 /* Page tables in the log-to-phys index file exclusively contain entries
  * of this type to describe position and size of a given page.
@@ -348,20 +342,15 @@ packed_stream_read(svn_fs_x__packed_numb
   return SVN_NO_ERROR;
 }
 
-/* Create and open a packed number stream reading from offsets START to
- * END in FILE and return it in *STREAM.  Access the file in chunks of
- * BLOCK_SIZE bytes.  Expect the stream to be prefixed by STREAM_PREFIX.
- * Allocate *STREAM in RESULT_POOL and use SCRATCH_POOL for temporaries.
- */
-static svn_error_t *
-packed_stream_open(svn_fs_x__packed_number_stream_t **stream,
-                   apr_file_t *file,
-                   apr_off_t start,
-                   apr_off_t end,
-                   const char *stream_prefix,
-                   apr_size_t block_size,
-                   apr_pool_t *result_pool,
-                   apr_pool_t *scratch_pool)
+svn_error_t *
+svn_fs_x__packed_stream_open(svn_fs_x__packed_number_stream_t **stream,
+                             apr_file_t *file,
+                             apr_off_t start,
+                             apr_off_t end,
+                             const char *stream_prefix,
+                             apr_size_t block_size,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool)
 {
   char buffer[STREAM_PREFIX_LEN + 1] = { 0 };
   apr_size_t len = strlen(stream_prefix);
@@ -1038,7 +1027,7 @@ svn_fs_x__l2p_index_append(svn_checksum_
 
 
   /* write header info */
-  SVN_ERR(svn_stream_puts(stream, L2P_STREAM_PREFIX));
+  SVN_ERR(svn_stream_puts(stream, SVN_FS_X__L2P_STREAM_PREFIX));
   SVN_ERR(stream_write_encoded(stream, revision));
   SVN_ERR(stream_write_encoded(stream, page_counts->nelts));
   SVN_ERR(stream_write_encoded(stream, ffd->l2p_page_size));
@@ -1231,35 +1220,6 @@ expand_rle(apr_array_header_t *values,
   return SVN_NO_ERROR;
 }
 
-/* If REV_FILE->L2P_STREAM is NULL, create a new stream for the log-to-phys
- * index for REVISION in FS using the rev / pack file provided by REV_FILE.
- * Return the open stream in *STREAM.
- */
-static svn_error_t *
-auto_open_l2p_index(svn_fs_x__packed_number_stream_t **stream,
-                    svn_fs_x__revision_file_t *rev_file,
-                    svn_fs_t *fs,
-                    svn_revnum_t revision)
-{
-  if (rev_file->l2p_stream == NULL)
-    {
-      svn_fs_x__data_t *ffd = fs->fsap_data;
-
-      SVN_ERR(svn_fs_x__auto_read_footer(rev_file));
-      SVN_ERR(packed_stream_open(&rev_file->l2p_stream,
-                                 rev_file->file,
-                                 rev_file->l2p_offset,
-                                 rev_file->p2l_offset,
-                                 L2P_STREAM_PREFIX,
-                                 (apr_size_t)ffd->block_size,
-                                 rev_file->pool,
-                                 rev_file->pool));
-    }
-
-  *stream = rev_file->l2p_stream;
-  return SVN_NO_ERROR;
-}
-
 /* Read the header data structure of the log-to-phys index for REVISION
  * in FS and return it in *HEADER, allocated in RESULT_POOL.  Use REV_FILE
  * to access on-disk data.  Use SCRATCH_POOL for temporary allocations.
@@ -1288,7 +1248,7 @@ get_l2p_header_body(l2p_header_t **heade
   key.revision = rev_file->start_revision;
   key.second = rev_file->is_packed;
 
-  SVN_ERR(auto_open_l2p_index(&stream, rev_file, fs, revision));
+  SVN_ERR(svn_fs_x__rev_file_l2p_index(&stream, rev_file));
   packed_stream_seek(stream, 0);
 
   /* Read the table sizes.  Check the data for plausibility and
@@ -1478,7 +1438,7 @@ get_l2p_page(l2p_page_t **page,
   svn_fs_x__packed_number_stream_t *stream;
 
   /* open index file and select page */
-  SVN_ERR(auto_open_l2p_index(&stream, rev_file, fs, start_revision));
+  SVN_ERR(svn_fs_x__rev_file_l2p_index(&stream, rev_file));
   packed_stream_seek(stream, table_entry->offset);
 
   /* initialize the page content */
@@ -2363,7 +2323,7 @@ svn_fs_x__p2l_index_append(svn_checksum_
                                    result_pool);
 
   /* write the start revision, file size and page size */
-  SVN_ERR(svn_stream_puts(stream, P2L_STREAM_PREFIX));
+  SVN_ERR(svn_stream_puts(stream, SVN_FS_X__P2L_STREAM_PREFIX));
   SVN_ERR(stream_write_encoded(stream, revision));
   SVN_ERR(stream_write_encoded(stream, file_size));
   SVN_ERR(stream_write_encoded(stream, page_size));
@@ -2386,35 +2346,6 @@ svn_fs_x__p2l_index_append(svn_checksum_
   return SVN_NO_ERROR;
 }
 
-/* If REV_FILE->P2L_STREAM is NULL, create a new stream for the phys-to-log
- * index for REVISION in FS using the rev / pack file provided by REV_FILE.
- * Return the open stream in *STREAM.
- */
-static svn_error_t *
-auto_open_p2l_index(svn_fs_x__packed_number_stream_t **stream,
-                    svn_fs_x__revision_file_t *rev_file,
-                    svn_fs_t *fs,
-                    svn_revnum_t revision)
-{
-  if (rev_file->p2l_stream == NULL)
-    {
-      svn_fs_x__data_t *ffd = fs->fsap_data;
-
-      SVN_ERR(svn_fs_x__auto_read_footer(rev_file));
-      SVN_ERR(packed_stream_open(&rev_file->p2l_stream,
-                                 rev_file->file,
-                                 rev_file->p2l_offset,
-                                 rev_file->footer_offset,
-                                 P2L_STREAM_PREFIX,
-                                 (apr_size_t)ffd->block_size,
-                                 rev_file->pool,
-                                 rev_file->pool));
-    }
-
-  *stream = rev_file->p2l_stream;
-  return SVN_NO_ERROR;
-}
-
 /* Data structure that describes which p2l page info shall be extracted
  * from the cache and contains the fields that receive the result.
  */
@@ -2536,7 +2467,7 @@ get_p2l_header(p2l_header_t **header,
 
   /* not found -> must read it from disk.
    * Open index file or position read pointer to the begin of the file */
-  SVN_ERR(auto_open_p2l_index(&stream, rev_file, fs, key.revision));
+  SVN_ERR(svn_fs_x__rev_file_p2l_index(&stream, rev_file));
   packed_stream_seek(stream, 0);
 
   /* allocate result data structure */
@@ -2743,7 +2674,7 @@ get_p2l_page(apr_array_header_t **entrie
   svn_fs_x__packed_number_stream_t *stream;
 
   /* open index and navigate to page start */
-  SVN_ERR(auto_open_p2l_index(&stream, rev_file, fs, start_revision));
+  SVN_ERR(svn_fs_x__rev_file_p2l_index(&stream, rev_file));
   packed_stream_seek(stream, start_offset);
 
   /* read rev file offset of the first page entry (all page entries will

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.h?rev=1662689&r1=1662688&r2=1662689&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.h (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/index.h Fri Feb 27 14:48:52 2015
@@ -53,6 +53,28 @@
 #define SVN_FS_X__ITEM_TYPE_REPS_CONT    10  /* item is a representations
                                                  container */
 
+/* We put this string in front of the L2P index header. */
+#define SVN_FS_X__L2P_STREAM_PREFIX "L2P-INDEX\n"
+
+/* We put this string in front of the P2L index header. */
+#define SVN_FS_X__P2L_STREAM_PREFIX "P2L-INDEX\n"
+
+
+/* Create and open a packed number stream reading from offsets START to
+ * END in FILE and return it in *STREAM.  Access the file in chunks of
+ * BLOCK_SIZE bytes.  Expect the stream to be prefixed by STREAM_PREFIX.
+ * Allocate *STREAM in RESULT_POOL and use SCRATCH_POOL for temporaries.
+ */
+svn_error_t *
+svn_fs_x__packed_stream_open(svn_fs_x__packed_number_stream_t **stream,
+                             apr_file_t *file,
+                             apr_off_t start,
+                             apr_off_t end,
+                             const char *stream_prefix,
+                             apr_size_t block_size,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool);
+
 /* (user visible) entry in the phys-to-log index.  It describes a section
  * of some packed / non-packed rev file as containing a specific item.
  * There must be no overlapping / conflicting entries.

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c?rev=1662689&r1=1662688&r2=1662689&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c Fri Feb 27 14:48:52 2015
@@ -300,6 +300,48 @@ svn_fs_x__wrap_temp_rev_file(svn_fs_x__r
 }
 
 svn_error_t *
+svn_fs_x__rev_file_l2p_index(svn_fs_x__packed_number_stream_t **stream,
+                             svn_fs_x__revision_file_t *file)
+{
+  if (file->l2p_stream == NULL)
+    {
+      SVN_ERR(svn_fs_x__auto_read_footer(file));
+      SVN_ERR(svn_fs_x__packed_stream_open(&file->l2p_stream,
+                                           file->file,
+                                           file->l2p_offset,
+                                           file->p2l_offset,
+                                           SVN_FS_X__L2P_STREAM_PREFIX,
+                                           (apr_size_t)file->block_size,
+                                           file->pool,
+                                           file->pool));
+    }
+
+  *stream = file->l2p_stream;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_x__rev_file_p2l_index(svn_fs_x__packed_number_stream_t **stream,
+                             svn_fs_x__revision_file_t *file)
+{
+  if (file->p2l_stream== NULL)
+    {
+      SVN_ERR(svn_fs_x__auto_read_footer(file));
+      SVN_ERR(svn_fs_x__packed_stream_open(&file->p2l_stream,
+                                           file->file,
+                                           file->p2l_offset,
+                                           file->footer_offset,
+                                           SVN_FS_X__P2L_STREAM_PREFIX,
+                                           (apr_size_t)file->block_size,
+                                           file->pool,
+                                           file->pool));
+    }
+
+  *stream = file->p2l_stream;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_fs_x__close_revision_file(svn_fs_x__revision_file_t *file)
 {
   if (file->stream)

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h?rev=1662689&r1=1662688&r2=1662689&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h Fri Feb 27 14:48:52 2015
@@ -146,6 +146,22 @@ svn_fs_x__wrap_temp_rev_file(svn_fs_x__r
                              apr_file_t *temp_file,
                              apr_pool_t *result_pool);
 
+/* Access functions */
+
+/* Set *STREAM to the shared L2P data stream of FILE.  Initializes the
+ * stream on demand.
+ */
+svn_error_t *
+svn_fs_x__rev_file_l2p_index(svn_fs_x__packed_number_stream_t **stream,
+                             svn_fs_x__revision_file_t *file);
+
+/* Set *STREAM to the shared P2L data stream of FILE.  Initializes the
+ * stream on demand.
+ */
+svn_error_t *
+svn_fs_x__rev_file_p2l_index(svn_fs_x__packed_number_stream_t **stream,
+                             svn_fs_x__revision_file_t *file);
+
 /* Close all files and streams in FILE.
  */
 svn_error_t *



Mime
View raw message