]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #27962 from xiexingguo/wip-jira-3756
authorKefu Chai <kchai@redhat.com>
Thu, 9 May 2019 07:07:48 +0000 (15:07 +0800)
committerGitHub <noreply@github.com>
Thu, 9 May 2019 07:07:48 +0000 (15:07 +0800)
mgr/DaemonServer: safe-to-destroy - do not consider irrelevant pgs

Reviewed-by: Yan Jun <yan.jun8@zte.com.cn>
Reviewed-by: Sage Weil <sage@redhat.com>
1  2 
src/mgr/DaemonServer.cc

index e2dc616ab53c2e4fc71071ca0b81f746413a1591,102937bc1197ebeeabba352821621f551f8ad7d4..9a773c8492c56abd8da6ab73f69023201e93f2a5
@@@ -1349,12 -1349,38 +1349,39 @@@ bool DaemonServer::_handle_command
            safe_to_destroy.insert(osd);
            continue;  // clearly safe to destroy
          }
+           set<int64_t> pools;
+           osdmap.get_pool_ids_by_osd(g_ceph_context, osd, &pools);
+           if (pools.empty()) {
+             // osd does not belong to any pools yet
+             safe_to_destroy.insert(osd);
+             continue;
+           }
+           if (osdmap.is_down(osd) && osdmap.is_out(osd)) {
+             // if osd is down&out and all relevant pools are active+clean,
+             // then should be safe to destroy
+             bool all_osd_pools_active_clean = true;
+             for (auto &ps: pg_map.pg_stat) {
+               auto& pg = ps.first;
+               auto state = ps.second.state;
+               if (!pools.count(pg.pool()))
+                 continue;
+               if ((state & (PG_STATE_ACTIVE | PG_STATE_CLEAN)) !=
+                            (PG_STATE_ACTIVE | PG_STATE_CLEAN)) {
+                 all_osd_pools_active_clean = false;
+                 break;
+               }
+             }
+             if (all_osd_pools_active_clean) {
+               safe_to_destroy.insert(osd);
+               continue;
+             }
+           }
          auto q = pg_map.num_pg_by_osd.find(osd);
          if (q != pg_map.num_pg_by_osd.end()) {
 -          if (q->second.acting > 0 || q->second.up > 0) {
 +          if (q->second.acting > 0 || q->second.up_not_acting > 0) {
              active_osds.insert(osd);
 -            affected_pgs += q->second.acting + q->second.up;
 +            // XXX: For overlapping PGs, this counts them again
 +            affected_pgs += q->second.acting + q->second.up_not_acting;
              continue;
            }
          }