]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: handle bad purge queue item encoding 33449/head
authorYan, Zheng <zyan@redhat.com>
Tue, 9 Oct 2018 03:46:56 +0000 (11:46 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 21 Feb 2020 23:56:25 +0000 (15:56 -0800)
The bad encoding was introduced by commit a88f8d5eb4

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit ba06fcbe3e8345dc2c4c4c3dc3bcc18acf5ab076)
Conflicts:
        src/mds/PurgeQueue.cc: advance changed to +=
Fixes: https://tracker.ceph.com/issues/36635
Note: This commit from v13.2.3 fixes a bad backport in v13.2.2. It is
      also required in Octopus/Nautilus to handle upgrades.

src/mds/PurgeQueue.cc

index 0c8b45c0cbbd145ef7fc080f46e7946ebe0cdd1b..a671325b5191c90fc01db915b1daa18047240363 100644 (file)
@@ -57,15 +57,39 @@ void PurgeItem::encode(bufferlist &bl) const
 void PurgeItem::decode(bufferlist::const_iterator &p)
 {
   DECODE_START(2, p);
-  decode((uint8_t&)action, p);
-  decode(ino, p);
-  decode(size, p);
-  decode(layout, p);
-  decode(old_pools, p);
-  decode(snapc, p);
-  decode(fragtree, p);
-  if (struct_v >= 2) {
-    decode(stamp, p);
+  bool done = false;
+  if (struct_v == 1) {
+    auto p_start = p;
+    try {
+      // bad encoding introduced by v13.2.2
+      decode(stamp, p);
+      decode(pad_size, p);
+      p += pad_size;
+      decode((uint8_t&)action, p);
+      decode(ino, p);
+      decode(size, p);
+      decode(layout, p);
+      decode(old_pools, p);
+      decode(snapc, p);
+      decode(fragtree, p);
+      if (p.get_off() > struct_end)
+       throw buffer::end_of_buffer();
+      done = true;
+    } catch (const buffer::error &e) {
+      p = p_start;
+    }
+  }
+  if (!done) {
+    decode((uint8_t&)action, p);
+    decode(ino, p);
+    decode(size, p);
+    decode(layout, p);
+    decode(old_pools, p);
+    decode(snapc, p);
+    decode(fragtree, p);
+    if (struct_v >= 2) {
+      decode(stamp, p);
+    }
   }
   DECODE_FINISH(p);
 }