]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: update allocated tid when skipping committed entry in player 6552/head
authorMykola Golub <mgolub@mirantis.com>
Thu, 29 Oct 2015 14:07:23 +0000 (16:07 +0200)
committerMykola Golub <mgolub@mirantis.com>
Thu, 12 Nov 2015 11:33:44 +0000 (13:33 +0200)
Otherwise, if on image open, there are no any uncommitted entries in
journal, allocated tid is not updated to the latest commited and
recording always starts from tid=0.

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/journal/JournalPlayer.cc
src/test/journal/test_JournalPlayer.cc

index 5060117c11ab9ef36f62e1340db7d919b19c0fb7..2f971588abc7e66602321da341f99fddec1c7287 100644 (file)
@@ -242,6 +242,7 @@ int JournalPlayer::process_prefetch() {
       }
 
       ldout(m_cct, 20) << "skipping committed entry: " << entry << dendl;
+      m_journal_metadata->reserve_tid(entry.get_tag(), entry.get_tid());
       object_player->pop_front();
     }
 
index 8dcb95f63e5d2a74cc105527cca4edb499ae1c3f..adc445a6e952464ae0343fc6c1c9e6bfc7e5e55d 100644 (file)
@@ -184,6 +184,39 @@ TEST_F(TestJournalPlayer, Prefetch) {
   ASSERT_EQ(125U, last_tid);
 }
 
+TEST_F(TestJournalPlayer, PrefetchSkip) {
+  std::string oid = get_temp_oid();
+
+  journal::JournalPlayer::EntryPositions positions;
+  positions = {
+    cls::journal::EntryPosition("tag1", 125) };
+  cls::journal::ObjectSetPosition commit_position(0, positions);
+
+  ASSERT_EQ(0, create(oid));
+  ASSERT_EQ(0, client_register(oid));
+  ASSERT_EQ(0, client_commit(oid, commit_position));
+
+  journal::JournalMetadataPtr metadata = create_metadata(oid);
+  ASSERT_EQ(0, init_metadata(metadata));
+
+  journal::JournalPlayer *player = create_player(oid, metadata);
+
+  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 122));
+  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 123));
+  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 124));
+  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 125));
+
+  player->prefetch();
+
+  Entries entries;
+  ASSERT_TRUE(wait_for_entries(player, 0, &entries));
+  ASSERT_TRUE(wait_for_complete(player));
+
+  uint64_t last_tid;
+  ASSERT_TRUE(metadata->get_last_allocated_tid("tag1", &last_tid));
+  ASSERT_EQ(125U, last_tid);
+}
+
 TEST_F(TestJournalPlayer, PrefetchWithoutCommit) {
   std::string oid = get_temp_oid();