]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge PR #25052 into master
authorSage Weil <sage@redhat.com>
Fri, 16 Nov 2018 13:11:15 +0000 (07:11 -0600)
committerSage Weil <sage@redhat.com>
Fri, 16 Nov 2018 13:11:15 +0000 (07:11 -0600)
* refs/pull/25052/head:
mgr: lock pg_map too for osd_pool_stats and notify_osdmap
mgr/DaemonServer: use with_osdmap_and_pgmap instead of nested calls
mgr/ClusterState: add with_osdmap_and_pgmap

Reviewed-by: Kefu Chai <kchai@redhat.com>
1  2 
src/mgr/DaemonServer.cc

index cd6c6dd94e26536e6c2ef8cae5121a7b803a0cb6,13ceb8941d0491d9660fdd61971a3b80b31a40ef..9d1458f6eab58e0a94f16bd96ceb8651f1dd2ca4
@@@ -1298,39 -1290,33 +1290,37 @@@ bool DaemonServer::_handle_command
            num_active_clean += p.second;
          }
        }
-       cluster_state.with_osdmap([&](const OSDMap& osdmap) {
-           for (auto osd : osds) {
-             if (!osdmap.exists(osd)) {
-                 safe_to_destroy.insert(osd);
-               continue;  // clearly safe to destroy
-             }
-             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) {
-                 active_osds.insert(osd);
-                 affected_pgs += q->second.acting + q->second.up;
-                 continue;
-               }
-             }
-             if (num_active_clean < pg_map.num_pg) {
-               // all pgs aren't active+clean; we need to be careful.
-               auto p = pg_map.osd_stat.find(osd);
-               if (p == pg_map.osd_stat.end()) {
-                 missing_stats.insert(osd);
-                   continue;
-               } else if (p->second.num_pgs > 0) {
-                 stored_pgs.insert(osd);
-                   continue;
-               }
-             }
-               safe_to_destroy.insert(osd);
+       for (auto osd : osds) {
+         if (!osdmap.exists(osd)) {
+           safe_to_destroy.insert(osd);
+           continue;  // clearly safe to destroy
+         }
+         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) {
+             active_osds.insert(osd);
+             affected_pgs += q->second.acting + q->second.up;
+             continue;
            }
-         });
+         }
+         if (num_active_clean < pg_map.num_pg) {
+           // all pgs aren't active+clean; we need to be careful.
+           auto p = pg_map.osd_stat.find(osd);
+           if (p == pg_map.osd_stat.end()) {
+             missing_stats.insert(osd);
+             continue;
+           } else if (p->second.num_pgs > 0) {
+             stored_pgs.insert(osd);
+             continue;
+           }
+         }
+         safe_to_destroy.insert(osd);
+       }
        });
 +    if (r && prefix == "osd safe-to-destroy") {
 +      cmdctx->reply(r, ss); // regardless of formatter
 +      return true;
 +    }
      if (!r && (!active_osds.empty() ||
                 !missing_stats.empty() || !stored_pgs.empty())) {
         if (!safe_to_destroy.empty()) {