auto m = op->get_req<PaxosServiceMessage>();
dout(7) << "prepare_update " << *m << dendl;
- switch (m->get_type()) {
-
- case MSG_MDS_BEACON:
- return prepare_beacon(op);
+ bool r = false;
- case MSG_MON_COMMAND:
- try {
- return prepare_command(op);
- } catch (const bad_cmd_get& e) {
- bufferlist bl;
- mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed());
- return false; /* nothing to propose */
- }
+ /* batch any changes to pending with any changes to osdmap */
+ paxos.plug();
- case MSG_MDS_OFFLOAD_TARGETS:
- return prepare_offload_targets(op);
-
- default:
- ceph_abort();
+ switch (m->get_type()) {
+ case MSG_MDS_BEACON:
+ r = prepare_beacon(op);
+ break;
+ case MSG_MON_COMMAND:
+ try {
+ r = prepare_command(op);
+ } catch (const bad_cmd_get& e) {
+ bufferlist bl;
+ mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed());
+ r = false;
+ }
+ break;
+ case MSG_MDS_OFFLOAD_TARGETS:
+ r = prepare_offload_targets(op);
+ break;
+ default:
+ ceph_abort();
+ break;
}
- return false; /* nothing to propose! */
+ paxos.unplug();
+
+ return r;
}
bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
auto &pending = get_pending_fsmap_writeable();
- bool batched_propose = false;
for (const auto &h : handlers) {
r = h->can_handle(prefix, op, pending, cmdmap, ss);
if (r == 1) {
goto out;
}
- batched_propose = h->batched_propose();
- if (batched_propose) {
- paxos.plug();
- }
r = h->handle(&mon, pending, op, cmdmap, ss);
- if (batched_propose) {
- paxos.unplug();
- }
if (r == -EAGAIN) {
// message has been enqueued for retry; return.
// success.. delay reply
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, r, rs,
get_last_committed() + 1));
- if (batched_propose) {
- force_immediate_propose();
- }
return true;
} else {
// reply immediately
auto &pending = get_pending_fsmap_writeable();
+ /* batch any changes to pending with any changes to osdmap */
+ paxos.plug();
+
bool do_propose = false;
bool propose_osdmap = false;
request_proposal(mon.osdmon());
}
+ /* allow MDSMonitor::propose_pending() to push the proposal through */
+ paxos.unplug();
+
if (do_propose) {
propose_pending();
}