]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: clean_pg_remaps
authorSage Weil <sage@redhat.com>
Wed, 15 Mar 2017 22:08:30 +0000 (18:08 -0400)
committerSage Weil <sage@redhat.com>
Tue, 28 Mar 2017 14:12:09 +0000 (10:12 -0400)
Helper to clean out no-op pg_remap cruft:

- pg_remap entries that match the raw result
- pg_remap_items entries where the 'from' part of the (from,to)
  set isn't present.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index f33ae5c1af35030c9ae8a7b964e3cfa5b138c4b6..c4e388f86cfba277d1eabbb43202d804a218289c 100644 (file)
@@ -3315,6 +3315,49 @@ int OSDMap::summarize_mapping_stats(
   return 0;
 }
 
+
+int OSDMap::clean_remaps(
+  CephContext *cct,
+  Incremental *pending_inc)
+{
+  ldout(cct, 10) << __func__ << dendl;
+  int changed = 0;
+  for (auto& p : pg_remap) {
+    vector<int> raw;
+    int primary;
+    pg_to_raw_osds(p.first, &raw, &primary);
+    if (raw == p.second) {
+      ldout(cct, 10) << " removing redundant pg_remap " << p.first << " "
+                    << p.second << dendl;
+      pending_inc->old_pg_remap.insert(p.first);
+      ++changed;
+    }
+  }
+  for (auto& p : pg_remap_items) {
+    vector<int> raw;
+    int primary;
+    pg_to_raw_osds(p.first, &raw, &primary);
+    vector<pair<int,int>> newmap;
+    for (auto& q : p.second) {
+      if (std::find(raw.begin(), raw.end(), q.first) != raw.end()) {
+       newmap.push_back(q);
+      }
+    }
+    if (newmap.empty()) {
+      ldout(cct, 10) << " removing no-op pg_remap_items " << p.first << " "
+                    << p.second << dendl;
+      pending_inc->old_pg_remap_items.insert(p.first);
+      ++changed;
+    } else if (newmap != p.second) {
+      ldout(cct, 10) << " simplifying partially no-op pg_remap_items "
+                    << p.first << " " << p.second << " -> " << newmap << dendl;
+      pending_inc->new_pg_remap_items[p.first] = newmap;
+      ++changed;
+    }
+  }
+  return changed;
+}
+
 bool OSDMap::try_pg_remap(
   CephContext *cct,
   pg_t pg,                       ///< pg to potentially remap
index 4221b2e0fb34b1b3e2b7fd62ea7ab24a406b58e3..856793bdaa23c1c01c9d92c7720a79292cd1c4c8 100644 (file)
@@ -861,6 +861,9 @@ public:
     return calc_pg_role(osd, group, nrep) >= 0;
   }
 
+  int clean_remaps(
+    CephContext *cct,
+    Incremental *pending_inc);
 
   bool try_pg_remap(
     CephContext *cct,