From: Sage Weil Date: Fri, 6 Dec 2013 21:58:51 +0000 (-0800) Subject: crush: add feature CRUSH_V2 for new indep mode and SET_*_TRIES rule steps X-Git-Tag: v0.74~16^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c853019475e7061565b885bb3bdf44d8f83f958c;p=ceph.git crush: add feature CRUSH_V2 for new indep mode and SET_*_TRIES rule steps Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 5173ce244451..099d8a653e5d 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -6,6 +6,23 @@ #define dout_subsys ceph_subsys_crush +bool CrushWrapper::has_v2_rules() const +{ + // check rules for use of indep or new SET_* rule steps + for (unsigned i=0; imax_rules; i++) { + crush_rule *r = crush->rules[i]; + if (!r) + continue; + for (unsigned j=0; jlen; j++) { + if (r->steps[j].op == CRUSH_RULE_CHOOSE_INDEP || + r->steps[j].op == CRUSH_RULE_CHOOSELEAF_INDEP || + r->steps[j].op == CRUSH_RULE_SET_CHOOSE_TRIES || + r->steps[j].op == CRUSH_RULE_SET_CHOOSELEAF_TRIES) + return true; + } + } + return false; +} void CrushWrapper::find_takes(set& roots) const { diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index d1bdc19667b1..476641761c3a 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -158,6 +158,7 @@ public: return crush->chooseleaf_descend_once != 0; } + bool has_v2_rules() const; // bucket types int get_num_type_names() const { diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h index c0f01cc5430e..0ddf91f5d5cc 100644 --- a/src/include/ceph_features.h +++ b/src/include/ceph_features.h @@ -40,6 +40,7 @@ #define CEPH_FEATURE_MON_SCRUB (1ULL<<33) #define CEPH_FEATURE_OSD_PACKED_RECOVERY (1ULL<<34) #define CEPH_FEATURE_OSD_CACHEPOOL (1ULL<<35) +#define CEPH_FEATURE_CRUSH_V2 (1ULL<<36) /* new indep; SET_* steps */ /* * The introduction of CEPH_FEATURE_OSD_SNAPMAPPER caused the feature @@ -102,7 +103,8 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) { CEPH_FEATURE_OSD_SNAPMAPPER | \ CEPH_FEATURE_MON_SCRUB | \ CEPH_FEATURE_OSD_PACKED_RECOVERY | \ - CEPH_FEATURE_OSD_CACHEPOOL | \ + CEPH_FEATURE_OSD_CACHEPOOL | \ + CEPH_FEATURE_CRUSH_V2 | \ 0ULL) #define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL @@ -112,6 +114,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) { */ #define CEPH_FEATURES_CRUSH \ (CEPH_FEATURE_CRUSH_TUNABLES | \ - CEPH_FEATURE_CRUSH_TUNABLES2) + CEPH_FEATURE_CRUSH_TUNABLES2 | \ + CEPH_FEATURE_CRUSH_V2) #endif diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 6cb4ab60c544..23752bb2b4dc 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -751,6 +751,8 @@ uint64_t OSDMap::get_features(uint64_t *pmask) const features |= CEPH_FEATURE_CRUSH_TUNABLES; if (crush->has_nondefault_tunables2()) features |= CEPH_FEATURE_CRUSH_TUNABLES2; + if (crush->has_v2_rules()) + features |= CEPH_FEATURE_CRUSH_V2; mask |= CEPH_FEATURES_CRUSH; for (map::const_iterator p = pools.begin(); p != pools.end(); ++p) {