]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MDSMonitor: plug paxos when maybe manipulating the osdmap 50908/head
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 5 Apr 2023 20:30:48 +0000 (16:30 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 30 May 2023 16:34:26 +0000 (12:34 -0400)
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>
src/mon/FSCommands.cc
src/mon/FSCommands.h
src/mon/MDSMonitor.cc

index 7ea2921c57e882a8225ece104cd7557849bbff5e..4ea716acaf50dfdac554bcd558e047a92f25b5bc 100644 (file)
@@ -146,10 +146,6 @@ class FsNewHandler : public FileSystemCommandHandler
   {
   }
 
-  bool batched_propose() override {
-    return true;
-  }
-
   int handle(
       Monitor *mon,
       FSMap& fsmap,
@@ -934,10 +930,6 @@ class AddDataPoolHandler : public FileSystemCommandHandler
     : FileSystemCommandHandler("fs add_data_pool"), m_paxos(paxos)
   {}
 
-  bool batched_propose() override {
-    return true;
-  }
-
   int handle(
       Monitor *mon,
       FSMap& fsmap,
@@ -1159,10 +1151,6 @@ class RenameFilesystemHandler : public FileSystemCommandHandler
   {
   }
 
-  bool batched_propose() override {
-    return true;
-  }
-
   int handle(
       Monitor *mon,
       FSMap& fsmap,
index a8714129693cf86bac7df0ff8ab5d5c4482f72ed..cd9009724e089d9e28843d6892690097ca245c2b 100644 (file)
@@ -79,10 +79,6 @@ public:
 
   static std::list<std::shared_ptr<FileSystemCommandHandler> > load(Paxos *paxos);
 
-  virtual bool batched_propose() {
-    return false;
-  }
-
   virtual int handle(
     Monitor *mon,
     FSMap &fsmap,
index 385f831710b44b8416807a6dede4e3bbfa12d76d..25339b02571059f9eb19badaedb23299e5d6069d 100644 (file)
@@ -550,28 +550,35 @@ bool MDSMonitor::prepare_update(MonOpRequestRef op)
   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)
@@ -1389,7 +1396,6 @@ bool MDSMonitor::prepare_command(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) {
@@ -1400,14 +1406,7 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op)
       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.
@@ -1448,9 +1447,6 @@ out:
     // 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
@@ -2321,6 +2317,9 @@ void MDSMonitor::tick()
 
   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;
 
@@ -2376,6 +2375,9 @@ void MDSMonitor::tick()
     request_proposal(mon.osdmon());
   }
 
+  /* allow MDSMonitor::propose_pending() to push the proposal through */
+  paxos.unplug();
+
   if (do_propose) {
     propose_pending();
   }