]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMap: handle CRUSH_ITEM_NONE in acting sets
authorSamuel Just <sam.just@inktank.com>
Wed, 12 Feb 2014 18:45:07 +0000 (10:45 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 18 Feb 2014 04:12:13 +0000 (20:12 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 49d905aef4c5cd28a339d4946aaa5bdf139f8332..2934b0e87e271b376491ae30ecf5ff6995aabcd7 100644 (file)
@@ -1375,7 +1375,13 @@ int OSDMap::_pg_to_osds(const pg_pool_t& pool, pg_t pg,
 
   _remove_nonexistent_osds(pool, *osds);
 
-  *primary = (osds->empty() ? -1 : osds->front());
+  *primary = -1;
+  for (unsigned i = 0; i < osds->size(); ++i) {
+    if ((*osds)[i] != CRUSH_ITEM_NONE) {
+      *primary = (*osds)[i];
+      break;
+    }
+  }
   if (ppps)
     *ppps = pps;
 
@@ -1470,17 +1476,29 @@ void OSDMap::_get_temp_osds(const pg_pool_t& pool, pg_t pg,
   temp_pg->clear();
   if (p != pg_temp->end()) {
     for (unsigned i=0; i<p->second.size(); i++) {
-      if (!exists(p->second[i]) || is_down(p->second[i]))
-       continue;
-      temp_pg->push_back(p->second[i]);
+      if (!exists(p->second[i]) || is_down(p->second[i])) {
+       if (pool.can_shift_osds()) {
+         continue;
+       } else {
+         temp_pg->push_back(CRUSH_ITEM_NONE);
+       }
+      } else {
+       temp_pg->push_back(p->second[i]);
+      }
     }
   }
   map<pg_t,int>::const_iterator pp = primary_temp->find(pg);
   *temp_primary = -1;
-  if (pp != primary_temp->end())
+  if (pp != primary_temp->end()) {
     *temp_primary = pp->second;
-  else if (!temp_pg->empty()) // apply pg_temp's primary
-    *temp_primary = temp_pg->front();
+  } else if (!temp_pg->empty()) { // apply pg_temp's primary
+    for (unsigned i = 0; i < temp_pg->size(); ++i) {
+      if ((*temp_pg)[i] != CRUSH_ITEM_NONE) {
+       *temp_primary = (*temp_pg)[i];
+       break;
+      }
+    }
+  }
 }
 
 int OSDMap::pg_to_osds(pg_t pg, vector<int> *raw, int *primary) const
index a5d0869afa988a7fb28493ef92ccaa99e9b903a4..4c626cc437b4a5dcd195be4743232aa054cad5be 100644 (file)
@@ -619,8 +619,6 @@ public:
   void pg_to_up_acting_osds(pg_t pg, vector<int>& up, vector<int>& acting) const {
     int up_primary, acting_primary;
     pg_to_up_acting_osds(pg, &up, &up_primary, &acting, &acting_primary);
-    assert(up.empty() || up_primary == up.front());
-    assert(acting.empty() || acting_primary == acting.front());
   }
   bool pg_is_ec(pg_t pg) const {
     map<int64_t, pg_pool_t>::const_iterator i = pools.find(pg.pool());