]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: return error after first corruption detected 28820/head
authorMykola Golub <mgolub@suse.com>
Mon, 1 Jul 2019 13:15:21 +0000 (14:15 +0100)
committerMykola Golub <mgolub@suse.com>
Mon, 1 Jul 2019 19:09:56 +0000 (20:09 +0100)
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 <mgolub@suse.com>
src/journal/ObjectPlayer.cc
src/test/journal/test_ObjectPlayer.cc

index 0a85b8853f254ef63b7a9bc30a3ad4af5fe8545e..35d979c7155eaa6c5f3e3ba9a96e26c192cd7ad5 100644 (file)
@@ -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;
index a12ba75cf0b84aff5263dc906a257d5e803480c7..c8774cab08524f971b03a73dbfdc6986c562a8e9 100644 (file)
@@ -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);
 }