]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-journal-tool: fix wrong read_offset when get missing objects 37479/head
authorjhonxue <jhonxue@tencent.com>
Thu, 30 Jul 2020 06:40:16 +0000 (14:40 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 29 Sep 2020 16:56:47 +0000 (18:56 +0200)
Fixes: https://tracker.ceph.com/issues/45575
Signed-off-by: Xue Yantao <jhonxue@tencent.com>
(cherry picked from commit bfa63666bb40c7939aa4da3c2c8f43a7022a78e8)

src/tools/cephfs/JournalScanner.cc

index f81c33d0489db9caf40dc38b855e569834ecc63e..ea9d6ddf994525964776d9bdd849d61e8afbddfe 100644 (file)
@@ -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