]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add sanity check for invalid m/w of liber8tion
authorYan Jun <yan.jun8@zte.com.cn>
Tue, 3 Sep 2019 14:16:04 +0000 (22:16 +0800)
committerYan Jun <yan.jun8@zte.com.cn>
Mon, 9 Sep 2019 12:00:20 +0000 (20:00 +0800)
Signed-off-by: Yan Jun <yan.jun8@zte.com.cn>
src/erasure-code/jerasure/ErasureCodeJerasure.cc

index 5a732c2e6345e742995313f54f908246cad84dae..3a780de811cb7771fa42f5c14ae81068d3be1475 100644 (file)
@@ -191,8 +191,6 @@ int ErasureCodeJerasureReedSolomonVandermonde::parse(ErasureCodeProfile &profile
   if (w != 8 && w != 16 && w != 32) {
     *ss << "ReedSolomonVandermonde: w=" << w
        << " must be one of {8, 16, 32} : revert to " << DEFAULT_W << std::endl;
-    profile["w"] = "8";
-    err |= to_int("w", profile, &w, DEFAULT_W, ss);
     err = -EINVAL;
   }
   err |= to_bool("jerasure-per-chunk-alignment", profile,
@@ -247,8 +245,6 @@ int ErasureCodeJerasureReedSolomonRAID6::parse(ErasureCodeProfile &profile,
   if (w != 8 && w != 16 && w != 32) {
     *ss << "ReedSolomonRAID6: w=" << w
        << " must be one of {8, 16, 32} : revert to 8 " << std::endl;
-    profile["w"] = "8";
-    err |= to_int("w", profile, &w, DEFAULT_W, ss);
     err = -EINVAL;
   }
   return err;
@@ -488,10 +484,16 @@ int ErasureCodeJerasureLiber8tion::parse(ErasureCodeProfile &profile,
                                         ostream *ss)
 {
   int err = ErasureCodeJerasure::parse(profile, ss);
-  profile.erase("m");
-  err |= to_int("m", profile, &m, DEFAULT_M, ss);
-  profile.erase("w");
-  err |= to_int("w", profile, &w, DEFAULT_W, ss);
+  if (m != stoi(DEFAULT_M)) {
+    *ss << "liber8tion: m=" << m << " must be " << DEFAULT_M
+        << " for liber8tion: revert to " << DEFAULT_M << std::endl;
+    err = -EINVAL;
+  }
+  if (w != stoi(DEFAULT_W)) {
+    *ss << "liber8tion: w=" << w << " must be " << DEFAULT_W
+        << " for liber8tion: revert to " << DEFAULT_W << std::endl;
+    err = -EINVAL;
+  }
   err |= to_int("packetsize", profile, &packetsize, DEFAULT_PACKETSIZE, ss);
 
   bool error = false;