From: Patrick Donnelly Date: Fri, 22 Feb 2019 00:39:57 +0000 (-0800) Subject: mon: add setting for fs to enable standby-replay X-Git-Tag: v14.1.1~93^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0f7614720e9ffee746c977d24876ff4ea8571275;p=ceph-ci.git mon: add setting for fs to enable standby-replay Operators now simply mark a file system as enabling standby-replay via ceph fs set allow_standby_replay true The MDSMonitor will assign available standbys to take on this role. Signed-off-by: Patrick Donnelly --- diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 3bf4383358a..fd12b9f1254 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -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) diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index a181a611dc4..6916d0ad2be 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -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; diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 65685348f49..3cc78c0f30f 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -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) { diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 301b49aa80f..521de9baa14 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -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; } diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index d2d9812a5b0..15326c09808 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 to ", "mds", "rw")