]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: add feature CRUSH_V2 for new indep mode and SET_*_TRIES rule steps
authorSage Weil <sage@inktank.com>
Fri, 6 Dec 2013 21:58:51 +0000 (13:58 -0800)
committerSage Weil <sage@inktank.com>
Fri, 6 Dec 2013 22:24:03 +0000 (14:24 -0800)
Signed-off-by: Sage Weil <sage@inktank.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/include/ceph_features.h
src/osd/OSDMap.cc

index 5173ce244451dae01b56e73c62c45400a0dad71a..099d8a653e5d6defa669ef4e093335dce862b537 100644 (file)
@@ -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; i<crush->max_rules; i++) {
+    crush_rule *r = crush->rules[i];
+    if (!r)
+      continue;
+    for (unsigned j=0; j<r->len; 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<int>& roots) const
 {
index d1bdc19667b11c4637c8378d6ebdf818f16f865e..476641761c3a6b751f2f4370af1a5e1354e4f1bb 100644 (file)
@@ -158,6 +158,7 @@ public:
     return
       crush->chooseleaf_descend_once != 0;
   }
+  bool has_v2_rules() const;
 
   // bucket types
   int get_num_type_names() const {
index c0f01cc5430e0682ecf81766c78e493c4e4ebe9a..0ddf91f5d5cc2064324332e2729f9470e2f4eb3d 100644 (file)
@@ -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
index 6cb4ab60c54471e0c05e1c17ee09ba1dd90dffc7..23752bb2b4dca3bdcb1a2b103f667dd8716d14a0 100644 (file)
@@ -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<int64_t,pg_pool_t>::const_iterator p = pools.begin(); p != pools.end(); ++p) {