mds: add MDSMap method for creating null MDSMap

It's not necessary to distribute a CompatSet with the null mdsmap. We
only need to communicate that the MDS is not part of any map.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2021-03-17 09:55:04 -07:00
parent 0256ae010f
commit 4a10b6016f
2 changed files with 11 additions and 15 deletions

View File

@ -167,6 +167,13 @@ public:
static CompatSet get_compat_set_default();
static CompatSet get_compat_set_base(); // pre v0.20
static MDSMap create_null_mdsmap() {
MDSMap null_map;
/* Use the largest epoch so it's always bigger than whatever the MDS has. */
null_map.epoch = std::numeric_limits<decltype(epoch)>::max();
return null_map;
}
bool get_inline_data_enabled() const { return inline_data_enabled; }
void set_inline_data_enabled(bool enabled) { inline_data_enabled = enabled; }

View File

@ -414,10 +414,7 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op)
* know which FS it was part of. Nor does this matter. Sending an empty
* MDSMap is sufficient for getting the MDS to respawn.
*/
MDSMap null_map;
null_map.epoch = fsmap.epoch;
null_map.compat = fsmap.compat;
auto m = make_message<MMDSMap>(mon.monmap->fsid, null_map);
auto m = make_message<MMDSMap>(mon.monmap->fsid, MDSMap::create_null_mdsmap());
mon.send_reply(op, m.detach());
return true;
} else {
@ -713,11 +710,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op)
*/
wait_for_finished_proposal(op, new LambdaContext([op, this](int r){
if (r >= 0) {
const auto& fsmap = get_fsmap();
MDSMap null_map;
null_map.epoch = fsmap.epoch;
null_map.compat = fsmap.compat;
auto m = make_message<MMDSMap>(mon.monmap->fsid, null_map);
auto m = make_message<MMDSMap>(mon.monmap->fsid, MDSMap::create_null_mdsmap());
mon.send_reply(op, m.detach());
} else {
dispatch(op); // try again
@ -909,10 +902,7 @@ void MDSMonitor::_updated(MonOpRequestRef op)
if (m->get_state() == MDSMap::STATE_STOPPED) {
// send the map manually (they're out of the map, so they won't get it automatic)
MDSMap null_map;
null_map.epoch = fsmap.epoch;
null_map.compat = fsmap.compat;
auto m = make_message<MMDSMap>(mon.monmap->fsid, null_map);
auto m = make_message<MMDSMap>(mon.monmap->fsid, MDSMap::create_null_mdsmap());
mon.send_reply(op, m.detach());
} else {
auto beacon = make_message<MMDSBeacon>(mon.monmap->fsid,
@ -1788,8 +1778,7 @@ void MDSMonitor::check_sub(Subscription *sub)
// Work out the effective latest epoch
const MDSMap *mds_map = nullptr;
MDSMap null_map;
null_map.compat = fsmap.compat;
MDSMap null_map = MDSMap::create_null_mdsmap();
if (fscid == FS_CLUSTER_ID_NONE) {
// For a client, we should have already dropped out
ceph_assert(is_mds);