]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd rados command: Show snapset in list-inconsistent-snapset
authorDavid Zafman <dzafman@redhat.com>
Wed, 4 Apr 2018 23:09:39 +0000 (16:09 -0700)
committerDavid Zafman <dzafman@redhat.com>
Tue, 10 Apr 2018 20:51:48 +0000 (13:51 -0700)
Add SnapSet bufferlist to inconsistent_snapset_t

Partial fix for http://tracker.ceph.com/issues/23428

Signed-off-by: David Zafman <dzafman@redhat.com>
doc/rados/command/list-inconsistent-snap.json
qa/standalone/scrub/osd-scrub-snaps.sh
src/common/scrub_types.cc
src/include/rados/rados_types.hpp
src/osd/PrimaryLogPG.cc
src/tools/rados/rados.cc

index c1e7119d88a6e31ab01f3bebbbc968879181e7a3..55f1d53e95567089bd4d399f846b881e1d508adf 100644 (file)
@@ -51,7 +51,7 @@
                 "clone_missing"
               ]
             },
-            "minItems": 1,
+            "minItems": 0,
             "uniqueItems": true
           },
           "missing": {
index fa8a8e8412d03369b9b485cc864b363ef6696d91..aaaca4c547c294f4b771c1de2c76661000187ba8 100755 (executable)
@@ -288,6 +288,31 @@ function TEST_scrub_snaps() {
       "nspace": "",
       "name": "obj5"
     },
+    {
+      "name": "obj10",
+      "nspace": "",
+      "locator": "",
+      "snap": "head",
+      "snapset": {
+        "snap_context": {
+          "seq": 1,
+          "snaps": [
+            1
+          ]
+        },
+        "clones": [
+          {
+            "snap": 1,
+            "size": 1032,
+            "overlap": "????",
+            "snaps": [
+              1
+            ]
+          }
+        ]
+      },
+      "errors": []
+    },
     {
       "extra clones": [
         1
@@ -298,7 +323,41 @@ function TEST_scrub_snaps() {
       "snap": "head",
       "locator": "",
       "nspace": "",
-      "name": "obj11"
+      "name": "obj11",
+      "snapset": {
+        "snap_context": {
+          "seq": 1,
+          "snaps": [
+            1
+          ]
+        },
+        "clones": []
+      }
+    },
+    {
+      "name": "obj14",
+      "nspace": "",
+      "locator": "",
+      "snap": "head",
+      "snapset": {
+        "snap_context": {
+          "seq": 1,
+          "snaps": [
+            1
+          ]
+        },
+        "clones": [
+          {
+            "snap": 1,
+            "size": 1033,
+            "overlap": "[]",
+            "snaps": [
+              1
+            ]
+          }
+        ]
+      },
+      "errors": []
     },
     {
       "errors": [
@@ -330,7 +389,36 @@ function TEST_scrub_snaps() {
       "snap": "head",
       "locator": "",
       "nspace": "",
-      "name": "obj3"
+      "name": "obj3",
+      "snapset": {
+        "snap_context": {
+          "seq": 3,
+          "snaps": [
+            3,
+            2,
+            1
+          ]
+        },
+        "clones": [
+          {
+            "snap": 1,
+            "size": 1032,
+            "overlap": "[]",
+            "snaps": [
+              1
+            ]
+          },
+          {
+            "snap": 3,
+            "size": 256,
+            "overlap": "[]",
+            "snaps": [
+              3,
+              2
+            ]
+          }
+        ]
+      }
     },
     {
       "missing": [
@@ -342,7 +430,37 @@ function TEST_scrub_snaps() {
       "snap": "head",
       "locator": "",
       "nspace": "",
-      "name": "obj4"
+      "name": "obj4",
+      "snapset": {
+        "snap_context": {
+          "seq": 7,
+          "snaps": [
+            7,
+            6,
+            5,
+            4,
+            3,
+            2,
+            1
+          ]
+        },
+        "clones": [
+          {
+            "snap": 7,
+            "size": 1032,
+            "overlap": "[]",
+            "snaps": [
+              7,
+              6,
+              5,
+              4,
+              3,
+              2,
+              1
+            ]
+          }
+        ]
+      }
     },
     {
       "missing": [
@@ -359,7 +477,56 @@ function TEST_scrub_snaps() {
       "snap": "head",
       "locator": "",
       "nspace": "",
-      "name": "obj5"
+      "name": "obj5",
+      "snapset": {
+        "snap_context": {
+          "seq": 6,
+          "snaps": [
+            6,
+            5,
+            4,
+            3,
+            2,
+            1
+          ]
+        },
+        "clones": [
+          {
+            "snap": 1,
+            "size": 1032,
+            "overlap": "[]",
+            "snaps": [
+              1
+            ]
+          },
+          {
+            "snap": 2,
+            "size": 256,
+            "overlap": "[]",
+            "snaps": [
+              2
+            ]
+          },
+          {
+            "snap": 4,
+            "size": 512,
+            "overlap": "[]",
+            "snaps": [
+              4,
+              3
+            ]
+          },
+          {
+            "snap": 6,
+            "size": 1024,
+            "overlap": "[]",
+            "snaps": [
+              6,
+              5
+            ]
+          }
+        ]
+      }
     },
     {
       "extra clones": [
@@ -371,7 +538,16 @@ function TEST_scrub_snaps() {
       "snap": "head",
       "locator": "",
       "nspace": "",
-      "name": "obj6"
+      "name": "obj6",
+      "snapset": {
+        "snap_context": {
+          "seq": 1,
+          "snaps": [
+            1
+          ]
+        },
+        "clones": []
+      }
     },
     {
       "extra clones": [
@@ -383,7 +559,14 @@ function TEST_scrub_snaps() {
       "snap": "head",
       "locator": "",
       "nspace": "",
-      "name": "obj7"
+      "name": "obj7",
+      "snapset": {
+        "snap_context": {
+          "seq": 0,
+          "snaps": []
+        },
+        "clones": []
+      }
     },
     {
       "errors": [
@@ -392,7 +575,50 @@ function TEST_scrub_snaps() {
       "snap": "head",
       "locator": "",
       "nspace": "",
-      "name": "obj8"
+      "name": "obj8",
+      "snapset": {
+        "snap_context": {
+          "seq": 0,
+          "snaps": [
+            1
+          ]
+        },
+        "clones": [
+          {
+            "snap": 1,
+            "size": 1032,
+            "overlap": "[]",
+            "snaps": [
+              1
+            ]
+          }
+        ]
+      }
+    },
+    {
+      "name": "obj9",
+      "nspace": "",
+      "locator": "",
+      "snap": "head",
+      "snapset": {
+        "snap_context": {
+          "seq": 1,
+          "snaps": [
+            1
+          ]
+        },
+        "clones": [
+          {
+            "snap": 1,
+            "size": "????",
+            "overlap": "[]",
+            "snaps": [
+              1
+            ]
+          }
+        ]
+      },
+      "errors": []
     }
   ],
   "epoch": 20
index 2ba3bcf992c2ca607df7c1444eb5dba371cbec73..f86a8de75b4fe1da1d0d22126693ef0988730b37 100644 (file)
@@ -229,21 +229,25 @@ void inconsistent_snapset_wrapper::set_size_mismatch()
 
 void inconsistent_snapset_wrapper::encode(bufferlist& bl) const
 {
-  ENCODE_START(1, 1, bl);
+  ENCODE_START(2, 1, bl);
   encode(errors, bl);
   encode(object, bl);
   encode(clones, bl);
   encode(missing, bl);
+  encode(ss_bl, bl);
   ENCODE_FINISH(bl);
 }
 
 void inconsistent_snapset_wrapper::decode(bufferlist::iterator& bp)
 {
-  DECODE_START(1, bp);
+  DECODE_START(2, bp);
   decode(errors, bp);
   decode(object, bp);
   decode(clones, bp);
   decode(missing, bp);
+  if (struct_v >= 2) {
+    decode(ss_bl, bp);
+  }
   DECODE_FINISH(bp);
 }
 
index 21bd65f34f7c61e9cbf63e179967d3db58a7d2b5..bcbdb43200cb6267663622b886b0d071497205d3 100644 (file)
@@ -265,6 +265,7 @@ struct inconsistent_snapset_t {
   // Extra clones
   std::vector<snap_t> clones;
   std::vector<snap_t> missing;
+  ceph::bufferlist ss_bl;
 
   bool ss_attr_missing() const {     // Compatibility
     return errors & SNAPSET_MISSING;
index 346af0ab7bfee66b159df5f2c90b25ab7fa86a92..a82fb1075449e1d36d26caaf805c64ea1d6fcf56 100644 (file)
@@ -14375,6 +14375,7 @@ void PrimaryLogPG::scrub_snapshot_metadata(
   vector<snapid_t>::reverse_iterator curclone; // Defined only if snapset initialized
   unsigned missing = 0;
   inconsistent_snapset_wrapper soid_error, head_error;
+  unsigned soid_error_count = 0;
 
   for (map<hobject_t,ScrubMap::object>::reverse_iterator
        p = scrubmap.objects.rbegin(); p != scrubmap.objects.rend(); ++p) {
@@ -14496,6 +14497,7 @@ void PrimaryLogPG::scrub_snapshot_metadata(
       ++scrubber.shallow_errors;
       soid_error.set_headless();
       scrubber.store->add_snap_error(pool.id, soid_error);
+      ++soid_error_count;
       if (head && soid.get_head() == head->get_head())
        head_error.set_clone(soid.snap);
       continue;
@@ -14510,12 +14512,13 @@ void PrimaryLogPG::scrub_snapshot_metadata(
       }
 
       // Save previous head error information
-      if (head && head_error.errors)
+      if (head && (head_error.errors || soid_error_count))
        scrubber.store->add_snap_error(pool.id, head_error);
       // Set this as a new head object
       head = soid;
       missing = 0;
       head_error = soid_error;
+      soid_error_count = 0;
 
       dout(20) << __func__ << " " << mode << " new head " << head << dendl;
 
@@ -14532,6 +14535,7 @@ void PrimaryLogPG::scrub_snapshot_metadata(
         try {
          snapset = SnapSet(); // Initialize optional<> before decoding into it
          decode(snapset.get(), blp);
+          head_error.ss_bl.push_back(p->second.attrs[SS_ATTR]);
         } catch (buffer::error& e) {
          snapset = boost::none;
           osd->clog->error() << mode << " " << info.pgid << " " << soid
@@ -14613,8 +14617,10 @@ void PrimaryLogPG::scrub_snapshot_metadata(
 
       // what's next?
       ++curclone;
-      if (soid_error.errors)
+      if (soid_error.errors) {
         scrubber.store->add_snap_error(pool.id, soid_error);
+       ++soid_error_count;
+      }
     }
 
     scrub_cstat.add(stat);
@@ -14634,7 +14640,7 @@ void PrimaryLogPG::scrub_snapshot_metadata(
     log_missing(missing, head, osd->clog, info.pgid, __func__,
                mode, pool.info.allow_incomplete_clones());
   }
-  if (head && head_error.errors)
+  if (head && (head_error.errors || soid_error_count))
     scrubber.store->add_snap_error(pool.id, head_error);
 
   for (auto p = missing_digest.begin(); p != missing_digest.end(); ++p) {
index dbee5eaf2dd9a24be14a0e24b2a9e57163ae67e8..78feb4c38d650c743b7400701dc6a212fc340ce4 100644 (file)
@@ -1537,6 +1537,15 @@ static void dump_inconsistent(const inconsistent_snapset_t& inc,
 {
   dump_object_id(inc.object, f);
 
+  if (inc.ss_bl.length()) {
+    SnapSet ss;
+    bufferlist bl = inc.ss_bl;
+    bufferlist::iterator bliter = bl.begin();
+    decode(ss, bliter);  // Can't be corrupted
+    f.open_object_section("snapset");
+    ss.dump(&f);
+    f.close_section();
+  }
   f.open_array_section("errors");
   if (inc.snapset_missing())
     f.dump_string("error", "snapset_missing");