]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonitorDBStore: remember kv backend type
authorSage Weil <sage@redhat.com>
Mon, 2 May 2016 19:55:50 +0000 (15:55 -0400)
committerSage Weil <sage@redhat.com>
Tue, 3 May 2016 14:41:07 +0000 (10:41 -0400)
If it is specified, use it; otherwise, go by the config
option.

Record the type when creating the store.

Signed-off-by: Sage Weil <sage@redhat.com>
PendingReleaseNotes
src/mon/MonitorDBStore.h

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4bd1329589e64bdd26d57dce76b3b1567f788a1a 100644 (file)
@@ -0,0 +1,12 @@
+11.0.0
+------
+
+* If you have manually specified the monitor user rocksdb via the
+  ``mon keyvaluedb = rocksdb`` option, you will need to manually add a file
+  to the mon data directory to preserve this option::
+
+     echo rocksdb > /var/lib/ceph/mon/ceph-`hostname`/kv_backend
+
+  New monitors will now use rocksdb by default, but if that file is
+  not present, existing monitors will use leveldb.  The ``mon keyvaluedb`` option
+  now only affects the backend chosen when a monitor is created.
index 95b14a33435e780192f09caf57b47d64c67355f4..ecba241093ea3f521c1534713fef4817ea4f683a 100644 (file)
@@ -579,7 +579,7 @@ class MonitorDBStore
     assert(r >= 0);
   }
 
-  void _open() {
+  void _open(string kv_type) {
     string::const_reverse_iterator rit;
     int pos = 0;
     for (rit = path.rbegin(); rit != path.rend(); ++rit, ++pos) {
@@ -591,11 +591,11 @@ class MonitorDBStore
     string full_path = os.str();
 
     KeyValueDB *db_ptr = KeyValueDB::create(g_ceph_context,
-                                           g_conf->mon_keyvaluedb,
+                                           kv_type,
                                            full_path);
     if (!db_ptr) {
       derr << __func__ << " error initializing "
-          << g_conf->mon_keyvaluedb << " db back storage in "
+          << kv_type << " db back storage in "
           << full_path << dendl;
       assert(0 != "MonitorDBStore: error initializing keyvaluedb back storage");
     }
@@ -618,15 +618,20 @@ class MonitorDBStore
       }
       do_dump = true;
     }
-    if (g_conf->mon_keyvaluedb == "rocksdb")
+    if (kv_type == "rocksdb")
       db->init(g_conf->mon_rocksdb_options);
     else
       db->init();
   }
 
   int open(ostream &out) {
-    _open();
-    int r = db->open(out);
+    string kv_type;
+    int r = read_meta("kv_backend", &kv_type);
+    if (r < 0 || kv_type.length() == 0)
+      kv_type = "leveldb";
+
+    _open(kv_type);
+    r = db->open(out);
     if (r < 0)
       return r;
     io_work.start();
@@ -635,8 +640,17 @@ class MonitorDBStore
   }
 
   int create_and_open(ostream &out) {
-    _open();
-    int r = db->create_and_open(out);
+    // record the type before open
+    string kv_type;
+    int r = read_meta("kv_backend", &kv_type);
+    if (r < 0) {
+      kv_type = g_conf->mon_keyvaluedb;
+      r = write_meta("kv_backend", kv_type);
+      if (r < 0)
+       return r;
+    }
+    _open(kv_type);
+    r = db->create_and_open(out);
     if (r < 0)
       return r;
     io_work.start();