From: Sage Weil Date: Mon, 2 May 2016 19:55:50 +0000 (-0400) Subject: mon/MonitorDBStore: remember kv backend type X-Git-Tag: v11.0.0~136^2~10^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=905bfb1edf9febdb6bf137c3f768a290f64aaa0b;p=ceph.git mon/MonitorDBStore: remember kv backend type If it is specified, use it; otherwise, go by the config option. Record the type when creating the store. Signed-off-by: Sage Weil --- diff --git a/PendingReleaseNotes b/PendingReleaseNotes index e69de29bb2d1..4bd1329589e6 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -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. diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index 95b14a33435e..ecba241093ea 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -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();