]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix mds damaged due to unexpected journal length 24463/head
authorZhi Zhang <willzzhang@tencent.com>
Thu, 20 Sep 2018 02:55:46 +0000 (10:55 +0800)
committerPrashant D <pdhange@redhat.com>
Sun, 7 Oct 2018 22:44:50 +0000 (18:44 -0400)
We used first next_safe_pos in pending_safe to update journal's safe_pos, but
it might not be flushed at this time, so journal's header may get incorrect
write_pos in some case, which could cause mds damaged.

This fix is trying to use current min next_safe_pos in pending_safe to update
journal's safe_pos.

Signed-off-by: Zhi Zhang <zhangz.david@outlook.com>
(cherry picked from commit d17790f299c282dff9c28569b10c46a54b4cfd51)

Conflicts:
src/osdc/Journaler.cc : Resolved in _finish_flush

src/osdc/Journaler.cc

index 63cf435e4c056663ff880abd1e5e8b8c30686498..939fbba2891c627385eb91075533b4708a94a790 100644 (file)
@@ -530,11 +530,12 @@ void Journaler::_finish_flush(int r, uint64_t start, ceph::real_time stamp)
   // adjust safe_pos
   auto it = pending_safe.find(start);
   assert(it != pending_safe.end());
+  uint64_t min_next_safe_pos = pending_safe.begin()->second;
   pending_safe.erase(it);
   if (pending_safe.empty())
     safe_pos = next_safe_pos;
   else
-    safe_pos = pending_safe.begin()->second;
+    safe_pos = min_next_safe_pos;
 
   ldout(cct, 10) << "_finish_flush safe from " << start
                 << ", pending_safe " << pending_safe