]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: add crush_version
authorSage Weil <sage@redhat.com>
Wed, 7 Jun 2017 03:31:59 +0000 (23:31 -0400)
committerSage Weil <sage@redhat.com>
Thu, 15 Jun 2017 15:18:47 +0000 (11:18 -0400)
Increment it every time our embedded crush map updates.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h
src/test/cli/osdmaptool/clobber.t
src/test/cli/osdmaptool/create-print.t
src/test/cli/osdmaptool/create-racks.t

index 8097b8636a33cbf2458ca34f28b2f04d59a02768..eed5a3d3f7abc5201f6e2f42fb620cfef316bf74 100644 (file)
@@ -1792,6 +1792,13 @@ int OSDMap::apply_incremental(const Incremental &inc)
     auto blp = bl.begin();
     crush.reset(new CrushWrapper);
     crush->decode(blp);
+    if (require_osd_release >= CEPH_RELEASE_LUMINOUS) {
+      // only increment if this is a luminous-encoded osdmap, lest
+      // the mon's crush_version diverge from what the osds or others
+      // are decoding and applying on their end.  if we won't encode
+      // it in the canonical version, don't change it.
+      ++crush_version;
+    }
   }
 
   calc_num_osds();
@@ -2311,7 +2318,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
   ENCODE_START(8, 7, bl);
 
   {
-    uint8_t v = 5;
+    uint8_t v = 6;
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       v = 3;
     }
@@ -2374,6 +2381,9 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
       assert(pg_upmap.empty());
       assert(pg_upmap_items.empty());
     }
+    if (v >= 6) {
+      ::encode(crush_version, bl);
+    }
     ENCODE_FINISH(bl); // client-usable data
   }
 
@@ -2584,7 +2594,7 @@ void OSDMap::decode(bufferlist::iterator& bl)
    * Since we made it past that hurdle, we can use our normal paths.
    */
   {
-    DECODE_START(5, bl); // client-usable data
+    DECODE_START(6, bl); // client-usable data
     // base
     ::decode(fsid, bl);
     ::decode(epoch, bl);
@@ -2639,6 +2649,9 @@ void OSDMap::decode(bufferlist::iterator& bl)
       pg_upmap.clear();
       pg_upmap_items.clear();
     }
+    if (struct_v >= 6) {
+      ::decode(crush_version, bl);
+    }
     DECODE_FINISH(bl); // client-usable data
   }
 
@@ -2758,6 +2771,7 @@ void OSDMap::dump(Formatter *f) const
   f->dump_stream("created") << get_created();
   f->dump_stream("modified") << get_modified();
   f->dump_string("flags", get_flag_string());
+  f->dump_unsigned("crush_version", get_crush_version());
   f->dump_float("full_ratio", full_ratio);
   f->dump_float("backfillfull_ratio", backfillfull_ratio);
   f->dump_float("nearfull_ratio", nearfull_ratio);
@@ -2972,6 +2986,7 @@ void OSDMap::print(ostream& out) const
       << "modified " << get_modified() << "\n";
 
   out << "flags " << get_flag_string() << "\n";
+  out << "crush_version " << get_crush_version() << "\n";
   out << "full_ratio " << full_ratio << "\n";
   out << "backfillfull_ratio " << backfillfull_ratio << "\n";
   out << "nearfull_ratio " << nearfull_ratio << "\n";
index 264fc5f7fcfe69b340409a2051d45536fe48a6e9..b9e05afd67a2b922fd23d277dee1a0e239d91a9f 100644 (file)
@@ -554,6 +554,8 @@ private:
   uint32_t get_crc() const { return crc; }
 
   ceph::shared_ptr<CrushWrapper> crush;       // hierarchical map
+private:
+  uint32_t crush_version = 1;
 
   friend class OSDMonitor;
 
@@ -606,6 +608,10 @@ public:
 
   void set_epoch(epoch_t e);
 
+  uint32_t get_crush_version() const {
+    return crush_version;
+  }
+
   /* stamps etc */
   const utime_t& get_created() const { return created; }
   const utime_t& get_modified() const { return modified; }
index b1d134e702bfa75758ee2cf10bad9ba5f508f211..8719b23984c6a57b4ffad448f2bf19615680cfd6 100644 (file)
@@ -19,6 +19,7 @@
   created \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   modified \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   flags 
+  crush_version 1
   full_ratio 0
   backfillfull_ratio 0
   nearfull_ratio 0
@@ -44,6 +45,7 @@
   created \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   modified \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   flags 
+  crush_version 1
   full_ratio 0
   backfillfull_ratio 0
   nearfull_ratio 0
index 539de8e96430e70a5a16e9424a2b5f539f10281f..022a32e711686d39ccdfed5c712654a37c1b0e31 100644 (file)
@@ -78,6 +78,7 @@
   created \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   modified \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   flags 
+  crush_version 1
   full_ratio 0
   backfillfull_ratio 0
   nearfull_ratio 0
index b55243a9515b3ca0748220c971bb70221e1a3c24..08eacba8893e614b7bd844b049722c2451f689c2 100644 (file)
   created \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   modified \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ (re)
   flags 
+  crush_version 1
   full_ratio 0
   backfillfull_ratio 0
   nearfull_ratio 0