subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bre...@apache.org
Subject svn commit: r1446467 - in /subversion/trunk/subversion: libsvn_fs_fs/fs_fs.c tests/libsvn_fs_fs/fs-pack-test.c
Date Fri, 15 Feb 2013 07:27:47 GMT
Author: breser
Date: Fri Feb 15 07:27:46 2013
New Revision: 1446467

URL: http://svn.apache.org/r1446467
Log:
Fix Issue #4320.  File hinting breaks when reading from a transaction commiting
the revision equal to the repo shard size.

* subversion/libsvn_fs_fs/fs_fs.c
  (create_rep_state_body): Test that rev_hint is a valid revnum.

* subversion/tests/libsvn_fs_fs/fs-pack-test.c
  (file_hint_at_shard_boundry, test_funcs): Add regression test for Issue #4320.

Found by: danielsh


Modified:
    subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
    subversion/trunk/subversion/tests/libsvn_fs_fs/fs-pack-test.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=1446467&r1=1446466&r2=1446467&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Fri Feb 15 07:27:46 2013
@@ -4386,12 +4386,14 @@ create_rep_state_body(struct rep_state *
 
   /* If the hint is
    * - given,
+   * - refers to a valid revision,
    * - refers to a packed revision,
    * - as does the rep we want to read, and
    * - refers to the same pack file as the rep
    * ...
    */
   if (   file_hint && rev_hint && *file_hint
+      && SVN_IS_VALID_REVNUM(*rev_hint)
       && *rev_hint < ffd->min_unpacked_rev
       && rep->revision < ffd->min_unpacked_rev
       && (   (*rev_hint / ffd->max_files_per_dir)

Modified: subversion/trunk/subversion/tests/libsvn_fs_fs/fs-pack-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs_fs/fs-pack-test.c?rev=1446467&r1=1446466&r2=1446467&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs_fs/fs-pack-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs_fs/fs-pack-test.c Fri Feb 15 07:27:46 2013
@@ -733,6 +733,61 @@ recover_fully_packed(const svn_test_opts
 #undef SHARD_SIZE
 
 /* ------------------------------------------------------------------------ */
+/* Regression test for issue #4320 (fsfs file-hinting fails when reading a rep
+   from the transaction that is commiting rev = SHARD_SIZE). */
+#define REPO_NAME "test-repo-file-hint-at-shard-boundry"
+#define SHARD_SIZE 4
+#define MAX_REV SHARD_SIZE - 1
+static svn_error_t *
+file_hint_at_shard_boundry(const svn_test_opts_t *opts,
+                           apr_pool_t *pool)
+{
+  apr_pool_t *subpool;
+  svn_fs_t *fs;
+  svn_fs_txn_t *txn;
+  svn_fs_root_t *txn_root;
+  const char *file_contents;
+  svn_stringbuf_t *retrieved_contents;
+  svn_error_t *err = SVN_NO_ERROR;
+
+  /* Bail (with success) on known-untestable scenarios */
+  if ((strcmp(opts->fs_type, "fsfs") != 0)
+      || (opts->server_minor_version && (opts->server_minor_version < 8)))
+    return SVN_NO_ERROR;
+
+  /* Create a packed FS and MAX_REV revisions */
+  SVN_ERR(create_packed_filesystem(REPO_NAME, opts, MAX_REV, SHARD_SIZE, pool));
+
+  /* Reopen the filesystem */
+  subpool = svn_pool_create(pool);
+  SVN_ERR(svn_fs_open(&fs, REPO_NAME, NULL, subpool));
+
+  /* Revision = SHARD_SIZE */ 
+  file_contents = get_rev_contents(SHARD_SIZE, subpool);
+  SVN_ERR(svn_fs_begin_txn(&txn, fs, MAX_REV, subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
+  SVN_ERR(svn_test__set_file_contents(txn_root, "iota", file_contents,
+                                      subpool));
+
+  /* Retrieve the file. */
+  SVN_ERR(svn_test__get_file_contents(txn_root, "iota", &retrieved_contents,
+                                      subpool));
+  if (strcmp(retrieved_contents->data, file_contents))
+    {
+      err = svn_error_create(SVN_ERR_TEST_FAILED, err,
+                              "Retrieved incorrect contents from iota.");
+    }
+
+  /* Close the repo. */
+  svn_pool_destroy(subpool);
+
+  return err; 
+}
+#undef REPO_NAME
+#undef MAX_REV
+#undef SHARD_SIZE
+
+/* ------------------------------------------------------------------------ */
 
 /* The test table.  */
 
@@ -755,5 +810,7 @@ struct svn_test_descriptor_t test_funcs[
                        "get/set huge packed revprops in FSFS"),
     SVN_TEST_OPTS_PASS(recover_fully_packed,
                        "recover a fully packed filesystem"),
+    SVN_TEST_OPTS_PASS(file_hint_at_shard_boundry,
+                       "test file hint at shard boundry"),
     SVN_TEST_NULL
   };



Mime
View raw message