]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: handle bad purge queue item encoding
authorYan, Zheng <zyan@redhat.com>
Tue, 9 Oct 2018 03:46:56 +0000 (11:46 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 9 Oct 2018 04:25:30 +0000 (12:25 +0800)
The bad encoding was introduced by commit a88f8d5eb4

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/PurgeQueue.cc

index 8ca2ceaf7120058f591ef0425c9231097626e4f8..5b9ca61cfed2184662b45b37ded7a7aae995854e 100644 (file)
@@ -56,15 +56,39 @@ void PurgeItem::encode(bufferlist &bl) const
 void PurgeItem::decode(bufferlist::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.advance(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);
 }