From bfa63666bb40c7939aa4da3c2c8f43a7022a78e8 Mon Sep 17 00:00:00 2001 From: jhonxue Date: Thu, 30 Jul 2020 14:40:16 +0800 Subject: [PATCH] cephfs-journal-tool: fix wrong read_offset when get missing objects Fixes: https://tracker.ceph.com/issues/45575 Signed-off-by: Xue Yantao --- src/tools/cephfs/JournalScanner.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/tools/cephfs/JournalScanner.cc b/src/tools/cephfs/JournalScanner.cc index f81c33d0489db..ea9d6ddf99452 100644 --- a/src/tools/cephfs/JournalScanner.cc +++ b/src/tools/cephfs/JournalScanner.cc @@ -194,8 +194,15 @@ int JournalScanner::scan_events() } objects_missing.push_back(obj_offset); - gap = true; - gap_start = read_offset; + if (!gap) { + gap_start = read_offset; + gap = true; + } + if (read_buf.length() > 0) { + read_offset += read_buf.length(); + read_buf.clear(); + } + read_offset += object_size - offset_in_obj; continue; } else { dout(4) << "Read 0x" << std::hex << this_object.length() << std::dec @@ -229,7 +236,8 @@ int JournalScanner::scan_events() } } while (read_buf.length() >= sizeof(JournalStream::sentinel)); dout(4) << "read_buf size is " << read_buf.length() << dendl; - } else { + } + { dout(10) << "Parsing data, 0x" << std::hex << read_buf.length() << std::dec << " bytes available" << dendl; while(true) { // TODO: detect and handle legacy format journals: can do many things -- 2.39.5