]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Don't crash if OI_ATTR attribute is missing or corrupt
authorDavid Zafman <dzafman@redhat.com>
Mon, 28 Sep 2015 17:59:42 +0000 (10:59 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 25 Feb 2016 20:50:25 +0000 (12:50 -0800)
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit e0b39650028205e9d9e314b75c444cc8cf055a31)

src/osd/PG.cc
src/osd/osd_types.h

index 634dc5656055fc0e69429fd8fd0dccdfa53226e1..43f320552f8e0efd06bdf10c9e1afa4ab8295eb9 100644 (file)
@@ -3600,8 +3600,18 @@ void PG::_scan_snaps(ScrubMap &smap)
     if (hoid.snap < CEPH_MAXSNAP) {
       // fake nlinks for old primaries
       bufferlist bl;
+      if (o.attrs.find(OI_ATTR) == o.attrs.end()) {
+       o.nlinks = 0;
+       continue;
+      }
       bl.push_back(o.attrs[OI_ATTR]);
-      object_info_t oi(bl);
+      object_info_t oi;
+      try {
+       oi = bl;
+      } catch(...) {
+       o.nlinks = 0;
+       continue;
+      }
       if (oi.snaps.empty()) {
        // Just head
        o.nlinks = 1;
index b058c135ce2ac2e9a0a81769a509428e03b39f4e..7557494a0af4a700f9bf0e7210cea2d5d20ebd8a 100644 (file)
@@ -2987,6 +2987,10 @@ struct object_info_t {
   object_info_t(bufferlist& bl) {
     decode(bl);
   }
+  object_info_t operator=(bufferlist& bl) {
+    decode(bl);
+    return *this;
+  }
 };
 WRITE_CLASS_ENCODER(object_info_t)