Merge remote-tracking branch 'gh/wip-4521-fix' into next

Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-04-17 15:03:03 -07:00
commit 4bf2448210
3 changed files with 50 additions and 0 deletions

View File

@ -4332,6 +4332,37 @@ out:
dout(10) << __func__ << " machine " << machine << " finished" << dendl;
}
void Monitor::StoreConverter::_convert_osdmap_full()
{
dout(10) << __func__ << dendl;
version_t first_committed =
store->get_int("osdmap", "first_committed");
version_t last_committed =
store->get_int("osdmap", "last_committed");
int err = 0;
for (version_t ver = first_committed; ver <= last_committed; ver++) {
if (!store->exists_bl_sn("osdmap_full", ver)) {
dout(20) << __func__ << " osdmap_full ver " << ver << " dne" << dendl;
err++;
continue;
}
bufferlist bl;
int r = store->get_bl_sn(bl, "osdmap_full", ver);
assert(r >= 0);
dout(20) << __func__ << " osdmap_full ver " << ver
<< " bl " << bl.length() << " bytes" << dendl;
string full_key = "full_" + stringify(ver);
MonitorDBStore::Transaction tx;
tx.put("osdmap", full_key, bl);
db->apply_transaction(tx);
}
dout(10) << __func__ << " found " << err << " conversion errors!" << dendl;
assert(err == 0);
}
void Monitor::StoreConverter::_convert_paxos()
{
dout(10) << __func__ << dendl;
@ -4384,5 +4415,11 @@ void Monitor::StoreConverter::_convert_machines()
for (; it != machine_names.end(); ++it) {
_convert_machines(*it);
}
// convert osdmap full versions
// this stays here as these aren't really an independent paxos
// machine, but rather machine-specific and don't fit on the
// _convert_machines(string) function.
_convert_osdmap_full();
dout(10) << __func__ << " finished" << dendl;
}

View File

@ -1507,6 +1507,7 @@ public:
void _convert_monitor();
void _convert_machines(string machine);
void _convert_osdmap_full();
void _convert_machines();
void _convert_paxos();
};

View File

@ -17,6 +17,7 @@
#include "messages/PaxosServiceMessage.h"
#include "include/Context.h"
#include "include/stringify.h"
#include <errno.h>
#include "Paxos.h"
#include "Monitor.h"
@ -918,6 +919,17 @@ public:
string key = mon->store->combine_strings(prefix, name);
return mon->store->exists(get_service_name(), key);
}
/**
* Checks if a given version @v exists
*
* @param prefix key's prefix
* @param v key's suffix
* @returns true if key exists; false otherwise.
*/
bool exists_version(const string& prefix, const version_t v) {
return exists_key(prefix, stringify(v));
}
/**
* @}
*/