]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: dedup pg-upmap[-items] 16239/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 10 Jul 2017 10:51:38 +0000 (18:51 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 10 Jul 2017 18:14:07 +0000 (02:14 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/OSDMonitor.cc

index 92c9b9ddba776cebda9b818f28cc3899bb5ba196..7196783bcc41ac73ffc373f509d2f584b7dcf712 100644 (file)
@@ -9047,9 +9047,20 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
             err = -ENOENT;
             goto reply;
           }
+          auto it = std::find(new_pg_upmap.begin(), new_pg_upmap.end(), osd);
+          if (it != new_pg_upmap.end()) {
+            ss << "osd." << osd << " already exists, ";
+            continue;
+          }
           new_pg_upmap.push_back(osd);
         }
 
+        if (new_pg_upmap.empty()) {
+          ss << "no valid upmap items(pairs) is specified";
+          err = -EINVAL;
+          goto reply;
+        }
+
         pending_inc.new_pg_upmap[pgid] = mempool::osdmap::vector<int32_t>(
           new_pg_upmap.begin(), new_pg_upmap.end());
         ss << "set " << pgid << " pg_upmap mapping to " << new_pg_upmap;
@@ -9093,6 +9104,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
         for (auto p = id_vec.begin(); p != id_vec.end(); ++p) {
           int from = *p++;
           int to = *p;
+          if (from == to) {
+            ss << "from osd." << from << " == to osd." << to << ", ";
+            continue;
+          }
           if (!osdmap.exists(from)) {
             ss << "osd." << from << " does not exist";
             err = -ENOENT;
@@ -9110,6 +9125,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
         out.resize(out.size() - 1); // drop last ','
         out += "]";
 
+        if (new_pg_upmap_items.empty()) {
+          ss << "no valid upmap items(pairs) is specified";
+          err = -EINVAL;
+          goto reply;
+        }
+
         pending_inc.new_pg_upmap_items[pgid] =
           mempool::osdmap::vector<pair<int32_t,int32_t>>(
           new_pg_upmap_items.begin(), new_pg_upmap_items.end());