From: Mykola Golub Date: Mon, 1 Jul 2019 13:15:21 +0000 (+0100) Subject: journal: return error after first corruption detected X-Git-Tag: v15.1.0~2195^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=534a28cdd85ccddd2724e06e12d3391a983ed145;p=ceph.git journal: return error after first corruption detected No need for the ObjectPlayer to try to decode other entries if it is going to return -EBADMSG anyway. This also fixes the ObjectPlayer behaviour when it did not return error if the corrurption was at the object end. Signed-off-by: Mykola Golub --- diff --git a/src/journal/ObjectPlayer.cc b/src/journal/ObjectPlayer.cc index 0a85b8853f25..35d979c7155e 100644 --- a/src/journal/ObjectPlayer.cc +++ b/src/journal/ObjectPlayer.cc @@ -180,8 +180,7 @@ int ObjectPlayer::handle_fetch_complete(int r, const bufferlist &bl, break; } - if (!invalid && - !advance_to_last_pad_byte(m_read_bl_off + iter.get_off(), &iter, + if (!advance_to_last_pad_byte(m_read_bl_off + iter.get_off(), &iter, &pad_len, &partial_entry)) { invalid_start_off = m_read_bl_off + bl_off; invalid = true; @@ -193,10 +192,11 @@ int ObjectPlayer::handle_fetch_complete(int r, const bufferlist &bl, ldout(m_cct, 20) << ": partial pad detected, will re-fetch" << dendl; } - break; + } else { + lderr(m_cct) << ": detected corrupt journal entry at offset " + << invalid_start_off << dendl; } - lderr(m_cct) << ": detected corrupt journal entry at offset " - << invalid_start_off << dendl; + break; } ++iter; continue; diff --git a/src/test/journal/test_ObjectPlayer.cc b/src/test/journal/test_ObjectPlayer.cc index a12ba75cf0b8..c8774cab0852 100644 --- a/src/test/journal/test_ObjectPlayer.cc +++ b/src/test/journal/test_ObjectPlayer.cc @@ -155,25 +155,21 @@ TYPED_TEST(TestObjectPlayer, FetchCorrupt) { journal::Entry entry1(234, 123, this->create_payload(std::string(24, '1'))); journal::Entry entry2(234, 124, this->create_payload(std::string(24, '2'))); - journal::Entry entry3(234, 125, this->create_payload(std::string(24, '3'))); bufferlist bl; encode(entry1, bl); encode(this->create_payload("corruption" + std::string(1024, 'X')), bl); encode(entry2, bl); - encode(this->create_payload("corruption" + std::string(1024, 'Y')), bl); - encode(entry3, bl); ASSERT_EQ(0, this->append(this->get_object_name(oid), bl)); journal::ObjectPlayerPtr object = this->create_object(oid, 14); ASSERT_EQ(-EBADMSG, this->fetch(object)); - ASSERT_EQ(0, this->fetch(object)); journal::ObjectPlayer::Entries entries; object->get_entries(&entries); - ASSERT_EQ(3U, entries.size()); + ASSERT_EQ(1U, entries.size()); - journal::ObjectPlayer::Entries expected_entries = {entry1, entry2, entry3}; + journal::ObjectPlayer::Entries expected_entries = {entry1}; ASSERT_EQ(expected_entries, entries); }