]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: refuse to start if release > recorded min_osd_release + 2 31858/head
authorSage Weil <sage@redhat.com>
Mon, 28 Jan 2019 20:58:26 +0000 (14:58 -0600)
committerNathan Cutler <ncutler@suse.com>
Mon, 9 Dec 2019 22:12:14 +0000 (23:12 +0100)
If we try to start up the objectstore, we may make writeable changes to
(say) rocksdb that are not backwards compatible.  This happens, for
example, if you start a mimic osd.  Even if the compatset checks fail,
rocksdb may have written something that is not backwards compatible.

Fixes: http://tracker.ceph.com/issues/38076
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 9f7713a905d67441b28371e4494e9447319d2129)

Conflicts:
src/ceph_osd.cc
- include common/version.h for ceph_release()
- use exit instead of forker.exit

src/ceph_osd.cc
src/osd/OSD.cc
src/osd/OSD.h

index efab291e6d9d39d34424a7c1a3e9d2d37ae8c65a..0fcd8681bab35ea4be1905081d0128f1427f3d53 100644 (file)
@@ -27,6 +27,7 @@ using namespace std;
 #include "include/ceph_features.h"
 
 #include "common/config.h"
+#include "common/version.h"
 
 #include "mon/MonMap.h"
 
@@ -403,8 +404,10 @@ flushjournal_out:
   
   string magic;
   uuid_d cluster_fsid, osd_fsid;
+  int require_osd_release = 0;
   int w;
-  int r = OSD::peek_meta(store, magic, cluster_fsid, osd_fsid, w);
+  int r = OSD::peek_meta(store, &magic, &cluster_fsid, &osd_fsid, &w,
+                        &require_osd_release);
   if (r < 0) {
     derr << TEXT_RED << " ** ERROR: unable to open OSD superblock on "
         << g_conf->osd_data << ": " << cpp_strerror(-r)
@@ -434,6 +437,14 @@ flushjournal_out:
     exit(0);
   }
 
+  if (require_osd_release > 0 &&
+      require_osd_release + 2 < ceph_release()) {
+    derr << "OSD's recorded require_osd_release " << require_osd_release
+        << " + 2 < this release " << ceph_release()
+        << "; you can only upgrade 2 releases at a time" << dendl;
+    exit(1);
+  }
+
   pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC
                                 |CEPH_PICK_ADDRESS_CLUSTER);
 
index 776a63fb37738a46231df77152655bb8af39b8a9..4222d456d8362a38b8c69077a1dd1552a0cd9622 100644 (file)
@@ -1890,37 +1890,46 @@ int OSD::write_meta(CephContext *cct, ObjectStore *store, uuid_d& cluster_fsid,
   return 0;
 }
 
-int OSD::peek_meta(ObjectStore *store, std::string& magic,
-                  uuid_d& cluster_fsid, uuid_d& osd_fsid, int& whoami)
+int OSD::peek_meta(ObjectStore *store,
+                  std::string *magic,
+                  uuid_d *cluster_fsid,
+                  uuid_d *osd_fsid,
+                  int *whoami,
+                  int *require_osd_release)
 {
   string val;
 
   int r = store->read_meta("magic", &val);
   if (r < 0)
     return r;
-  magic = val;
+  *magic = val;
 
   r = store->read_meta("whoami", &val);
   if (r < 0)
     return r;
-  whoami = atoi(val.c_str());
+  *whoami = atoi(val.c_str());
 
   r = store->read_meta("ceph_fsid", &val);
   if (r < 0)
     return r;
-  r = cluster_fsid.parse(val.c_str());
+  r = cluster_fsid->parse(val.c_str());
   if (!r)
     return -EINVAL;
 
   r = store->read_meta("fsid", &val);
   if (r < 0) {
-    osd_fsid = uuid_d();
+    *osd_fsid = uuid_d();
   } else {
-    r = osd_fsid.parse(val.c_str());
+    r = osd_fsid->parse(val.c_str());
     if (!r)
       return -EINVAL;
   }
 
+  r = store->read_meta("require_osd_release", &val);
+  if (r >= 0) {
+    *require_osd_release = atoi(val.c_str());
+  }
+
   return 0;
 }
 
index 2f7e3c7c8cbda59f896aec1c62b92ef011e06587..52a281bc368a3bc7a2ed47fa6d5922532de19aad 100644 (file)
@@ -2502,8 +2502,12 @@ private:
   float get_osd_recovery_sleep();
 
 public:
-  static int peek_meta(ObjectStore *store, string& magic,
-                      uuid_d& cluster_fsid, uuid_d& osd_fsid, int& whoami);
+  static int peek_meta(ObjectStore *store,
+                      string *magic,
+                      uuid_d *cluster_fsid,
+                      uuid_d *osd_fsid,
+                      int *whoami,
+                      int *min_osd_release);
   
 
   // startup/shutdown