{
Monitor::StoreConverter converter(g_conf->mon_data);
- if (converter.needs_conversion())
+ int ret = converter.needs_conversion();
+ if (ret > 0) {
assert(!converter.convert());
+ } else if (ret < 0) {
+ derr << "found errors while attempting to convert the monitor store: "
+ << cpp_strerror(ret) << dendl;
+ exit(1);
+ }
}
MonitorDBStore store(g_conf->mon_data);
if (err < 0) {
cerr << argv[0] << ": error opening mon data store at '"
<< g_conf->mon_data << "': " << cpp_strerror(err) << std::endl;
- cerr << "Have you run '--mkfs'?" << std::endl;
exit(1);
}
assert(err == 0);
return (features.incompat.contains(CEPH_MON_FEATURE_INCOMPAT_GV));
}
-bool Monitor::StoreConverter::needs_conversion()
+int Monitor::StoreConverter::needs_conversion()
{
- bool ret = false;
+ int ret = 0;
dout(10) << __func__ << dendl;
_init();
dout(1) << "check for old monitor store format" << dendl;
int err = store->mount();
if (err < 0) {
- dout(0) << "unable to mount monitor store; are you sure it exists?" << dendl;
- dout(0) << "error: " << cpp_strerror(err) << dendl;
- assert(0 == "non-existent store in mon data directory");
+ if (err == -ENOENT) {
+ derr << "unable to mount monitor store: "
+ << cpp_strerror(err) << dendl;
+ } else {
+ derr << "it appears that another monitor is running: "
+ << cpp_strerror(err) << dendl;
+ }
+ ret = err;
+ goto out;
}
- assert(!store->mount());
+ assert(err == 0);
bufferlist magicbl;
if (store->exists_bl_ss("magic", 0)) {
if (_check_gv_store()) {
dout(1) << "found old GV monitor store format "
<< "-- should convert!" << dendl;
- ret = true;
+ ret = 1;
} else {
dout(0) << "Existing monitor store has not been converted "
<< "to 0.52 (bobtail) format" << dendl;
}
}
assert(!store->umount());
+ } else {
+ if (db->exists("mon_convert", "on_going")) {
+ ret = -EEXIST;
+ derr << "there is an on-going (maybe aborted?) conversion." << dendl;
+ derr << "you should check what happened" << dendl;
+ }
}
+out:
_deinit();
return ret;
}
highest_last_pn(0), highest_accepted_pn(0)
{ }
- bool needs_conversion();
+ /**
+ * Check if store needs to be converted from old format to a
+ * k/v store.
+ *
+ * @returns 0 if store doesn't need conversion; 1 if it does; <0 if error
+ */
+ int needs_conversion();
int convert();
private: