Skip to content

Commit 885005b

Browse files
committed
mon/MDSMonitor: plug paxos when maybe manipulating the osdmap
Instead of tracking where exactly we're plugging PAXOS, just do it unconditionally whenever we modify pending and may change the osdmap. There is no downside to doing so; it simplifies the code. Fixes: https://tracker.ceph.com/issues/59314 Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
1 parent 05d60f0 commit 885005b

File tree

3 files changed

+31
-45
lines changed

3 files changed

+31
-45
lines changed

src/mon/FSCommands.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ class FsNewHandler : public FileSystemCommandHandler
146146
{
147147
}
148148

149-
bool batched_propose() override {
150-
return true;
151-
}
152-
153149
int handle(
154150
Monitor *mon,
155151
FSMap& fsmap,
@@ -934,10 +930,6 @@ class AddDataPoolHandler : public FileSystemCommandHandler
934930
: FileSystemCommandHandler("fs add_data_pool"), m_paxos(paxos)
935931
{}
936932

937-
bool batched_propose() override {
938-
return true;
939-
}
940-
941933
int handle(
942934
Monitor *mon,
943935
FSMap& fsmap,
@@ -1159,10 +1151,6 @@ class RenameFilesystemHandler : public FileSystemCommandHandler
11591151
{
11601152
}
11611153

1162-
bool batched_propose() override {
1163-
return true;
1164-
}
1165-
11661154
int handle(
11671155
Monitor *mon,
11681156
FSMap& fsmap,

src/mon/FSCommands.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ class FileSystemCommandHandler : protected CommandHandler
7979

8080
static std::list<std::shared_ptr<FileSystemCommandHandler> > load(Paxos *paxos);
8181

82-
virtual bool batched_propose() {
83-
return false;
84-
}
85-
8682
virtual int handle(
8783
Monitor *mon,
8884
FSMap &fsmap,

src/mon/MDSMonitor.cc

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -550,28 +550,35 @@ bool MDSMonitor::prepare_update(MonOpRequestRef op)
550550
auto m = op->get_req<PaxosServiceMessage>();
551551
dout(7) << "prepare_update " << *m << dendl;
552552

553-
switch (m->get_type()) {
554-
555-
case MSG_MDS_BEACON:
556-
return prepare_beacon(op);
553+
bool r = false;
557554

558-
case MSG_MON_COMMAND:
559-
try {
560-
return prepare_command(op);
561-
} catch (const bad_cmd_get& e) {
562-
bufferlist bl;
563-
mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed());
564-
return false; /* nothing to propose */
565-
}
555+
/* batch any changes to pending with any changes to osdmap */
556+
paxos.plug();
566557

567-
case MSG_MDS_OFFLOAD_TARGETS:
568-
return prepare_offload_targets(op);
569-
570-
default:
571-
ceph_abort();
558+
switch (m->get_type()) {
559+
case MSG_MDS_BEACON:
560+
r = prepare_beacon(op);
561+
break;
562+
case MSG_MON_COMMAND:
563+
try {
564+
r = prepare_command(op);
565+
} catch (const bad_cmd_get& e) {
566+
bufferlist bl;
567+
mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed());
568+
r = false;
569+
}
570+
break;
571+
case MSG_MDS_OFFLOAD_TARGETS:
572+
r = prepare_offload_targets(op);
573+
break;
574+
default:
575+
ceph_abort();
576+
break;
572577
}
573578

574-
return false; /* nothing to propose! */
579+
paxos.unplug();
580+
581+
return r;
575582
}
576583

577584
bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
@@ -1389,7 +1396,6 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op)
13891396

13901397
auto &pending = get_pending_fsmap_writeable();
13911398

1392-
bool batched_propose = false;
13931399
for (const auto &h : handlers) {
13941400
r = h->can_handle(prefix, op, pending, cmdmap, ss);
13951401
if (r == 1) {
@@ -1400,14 +1406,7 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op)
14001406
goto out;
14011407
}
14021408

1403-
batched_propose = h->batched_propose();
1404-
if (batched_propose) {
1405-
paxos.plug();
1406-
}
14071409
r = h->handle(&mon, pending, op, cmdmap, ss);
1408-
if (batched_propose) {
1409-
paxos.unplug();
1410-
}
14111410

14121411
if (r == -EAGAIN) {
14131412
// message has been enqueued for retry; return.
@@ -1448,9 +1447,6 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op)
14481447
// success.. delay reply
14491448
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, r, rs,
14501449
get_last_committed() + 1));
1451-
if (batched_propose) {
1452-
force_immediate_propose();
1453-
}
14541450
return true;
14551451
} else {
14561452
// reply immediately
@@ -2321,6 +2317,9 @@ void MDSMonitor::tick()
23212317

23222318
auto &pending = get_pending_fsmap_writeable();
23232319

2320+
/* batch any changes to pending with any changes to osdmap */
2321+
paxos.plug();
2322+
23242323
bool do_propose = false;
23252324
bool propose_osdmap = false;
23262325

@@ -2376,6 +2375,9 @@ void MDSMonitor::tick()
23762375
request_proposal(mon.osdmon());
23772376
}
23782377

2378+
/* allow MDSMonitor::propose_pending() to push the proposal through */
2379+
paxos.unplug();
2380+
23792381
if (do_propose) {
23802382
propose_pending();
23812383
}

0 commit comments

Comments
 (0)