]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add ability of precise testing of placement group calculation. 8097/head
authorAdam Kupczyk <akupczyk@mirantis.com>
Mon, 14 Mar 2016 12:55:29 +0000 (13:55 +0100)
committerAdam Kupczyk <akupczyk@mirantis.com>
Wed, 30 Mar 2016 06:58:11 +0000 (08:58 +0200)
Now pool id can be passed and proper JENKINS hash is used.
Signed-off-by: Adam Kupczyk akupczyk@mirantis.com
src/crush/CrushTester.cc
src/crush/CrushTester.h
src/test/cli/crushtool/help.t
src/tools/crushtool.cc

index 2ebe8c23d87ee3cf385e1eafa32a4f0a3654d0fc..532c55ec7b9b20ec804be946a11551f797157476 100644 (file)
@@ -640,7 +640,11 @@ int CrushTester::test()
           if (use_crush) {
             if (output_mappings)
              err << "CRUSH"; // prepend CRUSH to placement output
-            crush.do_rule(r, x, out, nr, weight);
+            uint32_t real_x = x;
+            if (pool_id != -1) {
+              real_x = crush_hash32_2(CRUSH_HASH_RJENKINS1, x, (uint32_t)pool_id);
+            }
+            crush.do_rule(r, real_x, out, nr, weight);
           } else {
             if (output_mappings)
              err << "RNG"; // prepend RNG to placement output to denote simulation
index bd625f3dda8869879604405b6ac434267a95d75a..b05d1c3d4e0b6188fc91389d2e8400ca2b99ec11 100644 (file)
@@ -18,6 +18,7 @@ class CrushTester {
   int ruleset;
   int min_x, max_x;
   int min_rep, max_rep;
+  int64_t pool_id;
 
   int num_batches;
   bool use_crush;
@@ -172,6 +173,7 @@ public:
       ruleset(-1),
       min_x(-1), max_x(-1),
       min_rep(-1), max_rep(-1),
+      pool_id(-1),
       num_batches(1),
       use_crush(true),
       mark_down_device_ratio(0.0),
@@ -302,6 +304,11 @@ public:
   void set_min_x(int x) {
     min_x = x;
   }
+
+  void set_pool_id(int64_t x){
+    pool_id = x;
+  }
+
   int get_min_x() const {
     return min_x;
   }
index e5ead0824053ebb665015e430d467c77c1be5e4b..5db47e98b23389c4b8de8afab47211dad37f279a 100755 (executable)
@@ -69,6 +69,7 @@
         [--min-x x] [--max-x x] [--x x]
         [--min-rule r] [--max-rule r] [--rule r] [--ruleset rs]
         [--num-rep n]
+        [--pool-id n]      specifies pool id
         [--batches b]      split the CRUSH mapping into b > 1 rounds
         [--weight|-w devno weight]
                            where weight is 0 to 1.0
index 5d2d542066a69b2be9c2a601d110c6bb89536c22..54eed954fd7abe76559ac9b35c57e26fc0e657e3 100644 (file)
@@ -175,6 +175,7 @@ void usage()
   cout << "      [--min-x x] [--max-x x] [--x x]\n";
   cout << "      [--min-rule r] [--max-rule r] [--rule r] [--ruleset rs]\n";
   cout << "      [--num-rep n]\n";
+  cout << "      [--pool-id n]      specifies pool id\n";
   cout << "      [--batches b]      split the CRUSH mapping into b > 1 rounds\n";
   cout << "      [--weight|-w devno weight]\n";
   cout << "                         where weight is 0 to 1.0\n";
@@ -276,6 +277,7 @@ int main(int argc, const char **argv)
 
   int x;
   float y;
+  long long z;
 
   std::string val;
   std::ostringstream err;
@@ -448,6 +450,12 @@ int main(int argc, const char **argv)
        exit(EXIT_FAILURE);
       }
       tester.set_min_x(x);
+    } else if (ceph_argparse_witharg(args, i, &z, err, "--pool_id", (char*)NULL)) {
+      if (!err.str().empty()) {
+  cerr << err.str() << std::endl;
+  exit(EXIT_FAILURE);
+      }
+      tester.set_pool_id(z);
     } else if (ceph_argparse_witharg(args, i, &x, err, "--x", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;