Merge remote-tracking branch 'gh/wip-swift' into next

Reviewed-by: Greg Farnum <greg@inktank.com>
This commit is contained in:
Sage Weil 2013-07-19 21:08:18 -07:00
commit 73b4003f65
3 changed files with 33 additions and 75 deletions

View File

@ -185,8 +185,11 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap)
mon->pgmon()->check_osd_map(osdmap.epoch);
}
update_logger();
check_subs();
share_map_with_random_osd();
update_logger();
process_failures();
// make sure our feature bits reflect the latest map
@ -294,9 +297,6 @@ void OSDMonitor::on_active()
{
update_logger();
send_to_waiting();
check_subs();
if (thrash_map) {
if (mon->is_leader()) {
if (thrash())
@ -310,22 +310,25 @@ void OSDMonitor::on_active()
mon->clog.info() << "osdmap " << osdmap << "\n";
if (!mon->is_leader()) {
kick_all_failures();
list<MOSDFailure*> ls;
take_all_failures(ls);
while (!ls.empty()) {
dispatch(ls.front());
ls.pop_front();
}
}
}
void OSDMonitor::on_shutdown()
{
dout(10) << __func__ << dendl;
map<epoch_t, list<PaxosServiceMessage*> >::iterator p = waiting_for_map.begin();
while (p != waiting_for_map.end()) {
while (!p->second.empty()) {
Message *m = p->second.front();
dout(20) << " discarding " << m << " " << *m << dendl;
m->put();
p->second.pop_front();
}
waiting_for_map.erase(p++);
// discard failure info, waiters
list<MOSDFailure*> ls;
take_all_failures(ls);
while (!ls.empty()) {
ls.front()->put();
ls.pop_front();
}
}
@ -1049,23 +1052,16 @@ void OSDMonitor::process_failures()
}
}
void OSDMonitor::kick_all_failures()
void OSDMonitor::take_all_failures(list<MOSDFailure*>& ls)
{
dout(10) << "kick_all_failures on " << failure_info.size() << " osds" << dendl;
assert(!mon->is_leader());
dout(10) << __func__ << " on " << failure_info.size() << " osds" << dendl;
list<MOSDFailure*> ls;
for (map<int,failure_info_t>::iterator p = failure_info.begin();
p != failure_info.end();
++p) {
p->second.take_report_messages(ls);
}
failure_info.clear();
while (!ls.empty()) {
dispatch(ls.front());
ls.pop_front();
}
}
@ -1311,7 +1307,6 @@ void OSDMonitor::_reply_map(PaxosServiceMessage *m, epoch_t e)
{
dout(7) << "_reply_map " << e
<< " from " << m->get_orig_source_inst()
<< " for " << m
<< dendl;
send_latest(m, e);
}
@ -1450,53 +1445,15 @@ bool OSDMonitor::prepare_remove_snaps(MRemoveSnaps *m)
// ---------------
// map helpers
void OSDMonitor::send_to_waiting()
{
dout(10) << "send_to_waiting " << osdmap.get_epoch() << dendl;
map<epoch_t, list<PaxosServiceMessage*> >::iterator p = waiting_for_map.begin();
while (p != waiting_for_map.end()) {
epoch_t from = p->first;
if (from) {
if (from <= osdmap.get_epoch()) {
while (!p->second.empty()) {
send_incremental(p->second.front(), from);
p->second.front()->put();
p->second.pop_front();
}
} else {
dout(10) << "send_to_waiting from " << from << dendl;
++p;
continue;
}
} else {
while (!p->second.empty()) {
send_full(p->second.front());
p->second.front()->put();
p->second.pop_front();
}
}
waiting_for_map.erase(p++);
}
}
void OSDMonitor::send_latest(PaxosServiceMessage *m, epoch_t start)
{
if (is_readable()) {
dout(5) << "send_latest to " << m->get_orig_source_inst()
<< " start " << start << dendl;
if (start == 0)
send_full(m);
else
send_incremental(m, start);
m->put();
} else {
dout(5) << "send_latest to " << m->get_orig_source_inst()
<< " start " << start << " later" << dendl;
waiting_for_map[start].push_back(m);
}
dout(5) << "send_latest to " << m->get_orig_source_inst()
<< " start " << start << dendl;
if (start == 0)
send_full(m);
else
send_incremental(m, start);
m->put();
}
@ -1651,6 +1608,7 @@ epoch_t OSDMonitor::blacklist(const entity_addr_t& a, utime_t until)
void OSDMonitor::check_subs()
{
dout(10) << __func__ << dendl;
string type = "osdmap";
if (mon->session_map.subs.count(type) == 0)
return;
@ -1664,6 +1622,8 @@ void OSDMonitor::check_subs()
void OSDMonitor::check_sub(Subscription *sub)
{
dout(10) << __func__ << " " << sub << " next " << sub->next
<< (sub->onetime ? " (onetime)":" (ongoing)") << dendl;
if (sub->next <= osdmap.get_epoch()) {
if (sub->next >= 1)
send_incremental(sub->next, sub->session->inst, sub->incremental_onetime);

View File

@ -118,8 +118,6 @@ public:
OSDMap osdmap;
private:
map<epoch_t, list<PaxosServiceMessage*> > waiting_for_map;
// [leader]
OSDMap::Incremental pending_inc;
map<int, failure_info_t> failure_info;
@ -192,7 +190,6 @@ private:
bool can_mark_in(int o);
// ...
void send_to_waiting(); // send current map to waiters.
MOSDMap *build_latest_full();
MOSDMap *build_incremental(epoch_t first, epoch_t last);
void send_full(PaxosServiceMessage *m);
@ -212,7 +209,7 @@ private:
bool prepare_failure(class MOSDFailure *m);
bool prepare_mark_me_down(class MOSDMarkMeDown *m);
void process_failures();
void kick_all_failures();
void take_all_failures(list<MOSDFailure*>& ls);
bool preprocess_boot(class MOSDBoot *m);
bool prepare_boot(class MOSDBoot *m);

View File

@ -438,8 +438,9 @@ public:
/**
* This is called when the Paxos state goes to active.
*
* @remarks It's a courtesy method, in case the class implementing this
* service has anything it wants/needs to do at that time.
* On the peon, this is after each election.
* On the leader, this is after each election, *and* after each completed
* proposal.
*
* @note This function may get called twice in certain recovery cases.
*/