]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: add setting for fs to enable standby-replay
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 22 Feb 2019 00:39:57 +0000 (16:39 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 28 Feb 2019 05:38:25 +0000 (21:38 -0800)
Operators now simply mark a file system as enabling standby-replay via

    ceph fs set <name> allow_standby_replay true

The MDSMonitor will assign available standbys to take on this role.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/include/ceph_fs.h
src/mds/MDSMap.h
src/mon/FSCommands.cc
src/mon/MDSMonitor.cc
src/mon/MonCommands.h

index 3bf4383358a0ca79d3f4b351fbc901bf471f3085..fd12b9f12541a16ce84b7f713a2e1ae473e164c0 100644 (file)
@@ -255,8 +255,9 @@ struct ceph_mon_subscribe_ack {
 #define CEPH_MDSMAP_ALLOW_SNAPS                  (1<<1)  /* cluster allowed to create snapshots */
 /* deprecated #define CEPH_MDSMAP_ALLOW_MULTIMDS (1<<2) cluster allowed to have >1 active MDS */
 /* deprecated #define CEPH_MDSMAP_ALLOW_DIRFRAGS (1<<3) cluster allowed to fragment directories */
-#define CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS        (1<<4)  /* cluster alllowed to enable MULTIMDS
-                                                           and SNAPS at the same time */
+#define CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS            (1<<4)  /* cluster alllowed to enable MULTIMDS
+                                                            and SNAPS at the same time */
+#define CEPH_MDSMAP_ALLOW_STANDBY_REPLAY         (1<<5)  /* cluster alllowed to enable MULTIMDS */
 
 #define CEPH_MDSMAP_DEFAULTS (CEPH_MDSMAP_ALLOW_SNAPS | \
                              CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS)
index a181a611dc4a36d2b4a011b2be53c2089adb5ed3..6916d0ad2bee74d01421b2bddd0ac9e9928cc675 100644 (file)
@@ -242,6 +242,15 @@ public:
   bool allows_snaps() const { return test_flag(CEPH_MDSMAP_ALLOW_SNAPS); }
   bool was_snaps_ever_allowed() const { return ever_allowed_features & CEPH_MDSMAP_ALLOW_SNAPS; }
 
+  void set_standby_replay_allowed() {
+    set_flag(CEPH_MDSMAP_ALLOW_STANDBY_REPLAY);
+    ever_allowed_features |= CEPH_MDSMAP_ALLOW_STANDBY_REPLAY;
+    explicitly_allowed_features |= CEPH_MDSMAP_ALLOW_STANDBY_REPLAY;
+  }
+  void clear_standby_replay_allowed() { clear_flag(CEPH_MDSMAP_ALLOW_STANDBY_REPLAY); }
+  bool allows_standby_replay() const { return test_flag(CEPH_MDSMAP_ALLOW_STANDBY_REPLAY); }
+  bool was_standby_replay_ever_allowed() const { return ever_allowed_features & CEPH_MDSMAP_ALLOW_STANDBY_REPLAY; }
+
   void set_multimds_snaps_allowed() {
     set_flag(CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS);
     ever_allowed_features |= CEPH_MDSMAP_ALLOW_MULTIMDS_SNAPS;
index 65685348f49103d1c01846568c289402476c7700..3cc78c0f30f2902732970b0057414636a5e01ded 100644 (file)
@@ -588,6 +588,21 @@ public:
       {
         fs->mds_map.set_session_autoclose((uint32_t)n);
       });
+    } else if (var == "allow_standby_replay") {
+      bool allow = false;
+      int r = parse_bool(val, &allow, ss);
+      if (r != 0) {
+        return r;
+      }
+
+      auto f = [allow](auto& fs) {
+        if (allow) {
+          fs->mds_map.set_standby_replay_allowed();
+        } else {
+          fs->mds_map.clear_standby_replay_allowed();
+        }
+      };
+      fsmap.modify_filesystem(fs->fscid, std::move(f));
     } else if (var == "min_compat_client") {
       int vno = ceph_release_from_name(val.c_str());
       if (vno <= 0) {
index 301b49aa80f30695204b05106f3053da42e4d786..521de9baa149ee0c2851cdd6bdd0e432192200a5 100644 (file)
@@ -1879,6 +1879,30 @@ bool MDSMonitor::maybe_promote_standby(FSMap &fsmap, Filesystem& fs)
     }
   }
 
+  if (fs.mds_map.allows_standby_replay() && !fs.mds_map.is_degraded()) {
+    // There were no failures to replace, so try using any available standbys
+    // as standby-replay daemons. Don't do this when the cluster is degraded
+    // as a standby-replay daemon may try to read a journal being migrated.
+    for (;;) {
+      auto standby_gid = fsmap.get_available_standby();
+      if (standby_gid == MDS_GID_NONE) break;
+      dout(20) << "standby available mds." << standby_gid << dendl;
+      bool changed = false;
+      for (const auto& rank : fs.mds_map.in) {
+        dout(20) << "exmaining " << rank << dendl;
+        if (fs.mds_map.is_followable(rank)) {
+          dout(1) << "  setting mds." << standby_gid
+                  << " to follow mds rank " << rank << dendl;
+          fsmap.assign_standby_replay(standby_gid, fs.fscid, rank);
+          do_propose = true;
+          changed = true;
+          break;
+        }
+      }
+      if (!changed) break;
+    }
+  }
+
   return do_propose;
 }
 
index d2d9812a5b04d4261692d14bfa1d9b9ac45af526..15326c09808f1344ef20834678eb190845b2e1ef 100644 (file)
@@ -396,7 +396,7 @@ COMMAND("fs set " \
        "name=var,type=CephChoices,strings=max_mds|max_file_size"
         "|allow_new_snaps|inline_data|cluster_down|allow_dirfrags|balancer" \
         "|standby_count_wanted|session_timeout|session_autoclose" \
-        "|down|joinable|min_compat_client " \
+        "|allow_standby_replay|down|joinable|min_compat_client " \
        "name=val,type=CephString "                                     \
        "name=yes_i_really_mean_it,type=CephBool,req=false",                    \
        "set fs parameter <var> to <val>", "mds", "rw")