From: Mykola Golub Date: Thu, 29 Oct 2015 14:07:23 +0000 (+0200) Subject: journal: update allocated tid when skipping committed entry in player X-Git-Tag: v10.0.1~85^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F6552%2Fhead;p=ceph.git journal: update allocated tid when skipping committed entry in player 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 --- diff --git a/src/journal/JournalPlayer.cc b/src/journal/JournalPlayer.cc index 5060117c11ab..2f971588abc7 100644 --- a/src/journal/JournalPlayer.cc +++ b/src/journal/JournalPlayer.cc @@ -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(); } diff --git a/src/test/journal/test_JournalPlayer.cc b/src/test/journal/test_JournalPlayer.cc index 8dcb95f63e5d..adc445a6e952 100644 --- a/src/test/journal/test_JournalPlayer.cc +++ b/src/test/journal/test_JournalPlayer.cc @@ -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();