]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MDSMonitor: avoid crash when decoding old FSMap epochs 43615/head
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 12 Oct 2021 18:00:50 +0000 (14:00 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 21 Oct 2021 02:33:28 +0000 (22:33 -0400)
Fixes: https://tracker.ceph.com/issues/52820
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 631360a41ab2ad93445d35a9730200beef2bebab)

src/mds/FSMap.cc
src/mon/MDSMonitor.cc

index 9508e8df2c9ea4934da906ca422c661781c90a96..9be570e537a75307601083fa81ee5c1953df7f3d 100644 (file)
@@ -641,6 +641,7 @@ void FSMap::encode(bufferlist& bl, uint64_t features) const
 
 void FSMap::decode(bufferlist::const_iterator& p)
 {
+  struct_version = 0;
   DECODE_START(STRUCT_VERSION, p);
   DECODE_OLDEST(7);
   struct_version = struct_v;
index 419447befa42ffc81db616dd6f1f6d68c9e8d3bd..ac2bd2d15759044524d138ebe49e5edaffcc88e2 100644 (file)
@@ -2306,7 +2306,12 @@ void MDSMonitor::tick()
         derr << "could not get version " << v << dendl;
         ceph_abort();
       }
-      fsmap.decode(bl);
+      try {
+        fsmap.decode(bl);
+      } catch (const ceph::buffer::malformed_input& e) {
+        dout(5) << "flushing old fsmap struct because unable to decode FSMap: " << e.what() << dendl;
+      }
+      /* N.B. FSMap::is_struct_old is also true for undecoded (failed to decode) FSMap */
       if (fsmap.is_struct_old()) {
         dout(5) << "fsmap struct is too old; proposing to flush out old versions" << dendl;
         do_propose = true;