From 15d1fd48ba9be7ec8bdfb73aa4973057e816a161 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 28 Mar 2016 18:35:39 -0700 Subject: [PATCH] MDSMap: switch from booleans to flags for feature enablement logging Signed-off-by: Greg Farnum --- src/mds/FSMap.cc | 17 +++++++++++++---- src/mds/MDSMap.cc | 25 ++++++++++++++++++------- src/mds/MDSMap.h | 12 ++++++------ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 67029180c12fa..92e9a1026cb4c 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -341,11 +341,20 @@ void FSMap::decode(bufferlist::iterator& p) if (ev >= 4) ::decode(legacy_mds_map.last_failure_osd_epoch, p); if (ev >= 6) { - ::decode(legacy_mds_map.ever_allowed_snaps, p); - ::decode(legacy_mds_map.explicitly_allowed_snaps, p); + if (ev < 10) { + // previously this was a bool about snaps, not a flag map + bool flag; + ::decode(flag, p); + legacy_mds_map.ever_allowed_features = flag ? CEPH_MDSMAP_ALLOW_SNAPS : 0; + ::decode(flag, p); + legacy_mds_map.explicitly_allowed_features = flag ? CEPH_MDSMAP_ALLOW_SNAPS : 0; + } else { + ::decode(legacy_mds_map.ever_allowed_features, p); + ::decode(legacy_mds_map.explicitly_allowed_features, p); + } } else { - legacy_mds_map.ever_allowed_snaps = true; - legacy_mds_map.explicitly_allowed_snaps = false; + legacy_mds_map.ever_allowed_features = CEPH_MDSMAP_ALLOW_SNAPS; + legacy_mds_map.explicitly_allowed_features = 0; } if (ev >= 7) ::decode(legacy_mds_map.inline_data_enabled, p); diff --git a/src/mds/MDSMap.cc b/src/mds/MDSMap.cc index 9a7c26f282251..16b6b2d4f99e2 100644 --- a/src/mds/MDSMap.cc +++ b/src/mds/MDSMap.cc @@ -134,6 +134,8 @@ void MDSMap::dump(Formatter *f) const { f->dump_int("epoch", epoch); f->dump_unsigned("flags", flags); + f->dump_unsigned("ever_allowed_features", ever_allowed_features); + f->dump_unsigned("explicitly_allowed_features", explicitly_allowed_features); f->dump_stream("created") << created; f->dump_stream("modified") << modified; f->dump_int("tableserver", tableserver); @@ -547,7 +549,7 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const ::encode(cas_pool, bl); // kclient ignores everything from here - __u16 ev = 9; + __u16 ev = 10; ::encode(ev, bl); ::encode(compat, bl); ::encode(metadata_pool, bl); @@ -560,8 +562,8 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const ::encode(failed, bl); ::encode(stopped, bl); ::encode(last_failure_osd_epoch, bl); - ::encode(ever_allowed_snaps, bl); - ::encode(explicitly_allowed_snaps, bl); + ::encode(ever_allowed_features, bl); + ::encode(explicitly_allowed_features, bl); ::encode(inline_data_enabled, bl); ::encode(enabled, bl); ::encode(fs_name, bl); @@ -624,11 +626,20 @@ void MDSMap::decode(bufferlist::iterator& p) if (ev >= 4) ::decode(last_failure_osd_epoch, p); if (ev >= 6) { - ::decode(ever_allowed_snaps, p); - ::decode(explicitly_allowed_snaps, p); + if (ev < 10) { + // previously this was a bool about snaps, not a flag map + bool flag; + ::decode(flag, p); + legacy_mds_map.ever_allowed_features = flag ? CEPH_MDSMAP_ALLOW_SNAPS : 0; + ::decode(flag, p); + legacy_mds_map.explicitly_allowed_features = flag ? CEPH_MDSMAP_ALLOW_SNAPS : 0; + } else { + ::decode(ever_allowed_features, p); + ::decode(explicitly_allowed_features, p); + } } else { - ever_allowed_snaps = true; - explicitly_allowed_snaps = false; + ever_allowed_features = CEPH_MDSMAP_ALLOW_SNAPS; + explicitly_allowed_features = 0; } if (ev >= 7) ::decode(inline_data_enabled, p); diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index 2842f93a169b1..597270e08e159 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -209,8 +209,8 @@ protected: std::map up; // who is in those roles std::map mds_info; - bool ever_allowed_snaps; //< the cluster has ever allowed snap creation - bool explicitly_allowed_snaps; //< the user has explicitly enabled snap creation + uint8_t ever_allowed_features; //< bitmap of features the cluster has allowed + uint8_t explicitly_allowed_features; //< bitmap of features explicitly enabled bool inline_data_enabled; @@ -235,8 +235,8 @@ public: cas_pool(-1), metadata_pool(0), max_mds(0), - ever_allowed_snaps(false), - explicitly_allowed_snaps(false), + ever_allowed_features(0), + explicitly_allowed_features(0), inline_data_enabled(false), cached_up_features(0) { } @@ -259,8 +259,8 @@ public: void set_snaps_allowed() { set_flag(CEPH_MDSMAP_ALLOW_SNAPS); - ever_allowed_snaps = true; - explicitly_allowed_snaps = true; + ever_allowed_features |= CEPH_MDSMAP_ALLOW_SNAPS; + explicitly_allowed_features |= CEPH_MDSMAP_ALLOW_SNAPS; } bool allows_snaps() { return test_flag(CEPH_MDSMAP_ALLOW_SNAPS); } void clear_snaps_allowed() { clear_flag(CEPH_MDSMAP_ALLOW_SNAPS); } -- 2.39.5