]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: do not automatically recycle class for 'rm-device-class'
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 5 Aug 2017 07:34:58 +0000 (15:34 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 5 Aug 2017 10:44:59 +0000 (18:44 +0800)
This will prevent the current crush rule from referencing a non-existent
shadow tree and hence avoid a coredump such as below:

 0> 2017-08-05 09:54:19.943349 7f73887d6700 -1 /clove/vm/xxg/rpm/ceph/rpmbuild/BUILD/ceph-12.1.2.1/src/crush/CrushWrapper.cc: In function 'int CrushWrapper::get_rule_weight_osd_map(unsigned
 int, std::map<int, float>*)' thread 7f73887d6700 time 2017-08-05 09:54:19.941291
/clove/vm/xxg/rpm/ceph/rpmbuild/BUILD/ceph-12.1.2.1/src/crush/CrushWrapper.cc: 1631: FAILED assert(b)

 ceph version 12.1.2.1-11-gd0f812a (d0f812a3a757b319c26794f558b57770663ab324) luminous (rc)
 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x110) [0x7f7398b66ea0]
 2: (CrushWrapper::get_rule_weight_osd_map(unsigned int, std::map<int, float, std::less<int>, std::allocator<std::pair<int const, float> > >*)+0x54e) [0x7f7398daac4e]
 3: (PGMap::get_rule_avail(OSDMap const&, int) const+0x68) [0x7f73989a6428]
 4: (PGMap::get_rules_avail(OSDMap const&, std::map<int, long, std::less<int>, std::allocator<std::pair<int const, long> > >*) const+0x35c) [0x7f73989b748c]
 5: (PGMap::encode_digest(OSDMap const&, ceph::buffer::list&, unsigned long) const+0x16) [0x7f73989b7506]
 6: (DaemonServer::send_report()+0x2a4) [0x7f73989f5474]
 7: (DaemonServer::maybe_ready(int)+0x2f9) [0x7f73989f6129]
 8: (DaemonServer::ms_dispatch(Message*)+0xce) [0x7f73989ff68e]
 9: (DispatchQueue::entry()+0x792) [0x7f7398dd2a22]
 10: (DispatchQueue::DispatchThread::entry()+0xd) [0x7f7398c1429d]
 11: (()+0x7df3) [0x7f739640cdf3]
 12: (clone()+0x6d) [0x7f73954f23ed]

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
qa/standalone/crush/crush-classes.sh
src/crush/CrushWrapper.cc

index ee9c9092e6e5528a60e87d908c6691f09c352c62..1e6bf97b6fc89bdce57bda504495f48bce2b98b7 100755 (executable)
@@ -162,27 +162,19 @@ function TEST_mon_classes() {
     ceph osd crush tree --show-shadow | grep -q '~ccc' || return 1
     ceph osd crush rm-device-class 0 || return 1
     ceph osd tree | grep -q 'aaa' && return 1
-    ceph osd crush dump | grep -q '~aaa' && return 1
-    ceph osd crush tree --show-shadow | grep -q '~aaa' && return 1
-    ceph osd crush class ls | grep -q 'aaa' && return 1
+    ceph osd crush class ls | grep -q 'aaa' || return 1
     ceph osd crush rm-device-class 1 || return 1
     ceph osd tree | grep -q 'bbb' && return 1
-    ceph osd crush dump | grep -q '~bbb' && return 1
-    ceph osd crush tree --show-shadow | grep -q '~bbb' && return 1
-    ceph osd crush class ls | grep -q 'bbb' && return 1
+    ceph osd crush class ls | grep -q 'bbb' || return 1
     ceph osd crush rm-device-class 2 || return 1
     ceph osd tree | grep -q 'ccc' && return 1
-    ceph osd crush dump | grep -q '~ccc' && return 1
-    ceph osd crush tree --show-shadow | grep -q '~ccc' && return 1
-    ceph osd crush class ls | grep -q 'ccc' && return 1
+    ceph osd crush class ls | grep -q 'ccc' || return 1
     ceph osd crush set-device-class asdf all || return 1
     ceph osd tree | grep -q 'asdf' || return 1
     ceph osd crush dump | grep -q '~asdf' || return 1
     ceph osd crush tree --show-shadow | grep -q '~asdf' || return 1
     ceph osd crush rm-device-class all || return 1
     ceph osd tree | grep -q 'asdf' && return 1
-    ceph osd crush dump | grep -q '~asdf' && return 1
-    ceph osd crush tree --show-shadow | grep -q '~asdf' && return 1
 
     # test 'class rm' automatically recycles shadow trees
     ceph osd crush set-device-class asdf 0 1 2 || return 1
@@ -211,12 +203,6 @@ function TEST_mon_classes() {
     ceph osd crush dump | grep -q 'foo-host~abc' || return 1
     ceph osd crush tree --show-shadow | grep -q 'foo-host~abc' || return 1
     ceph osd crush rm-device-class osd.2 || return 1
-    ceph osd crush dump | grep -q 'foo~abc' && return 1
-    ceph osd crush tree --show-shadow | grep -q 'foo~abc' && return 1
-    ceph osd crush dump | grep -q 'foo-rack~abc' && return 1
-    ceph osd crush tree --show-shadow | grep -q 'foo-rack~abc' && return 1
-    ceph osd crush dump | grep -q 'foo-host~abc' && return 1
-    ceph osd crush tree --show-shadow | grep -q 'foo-host~abc' && return 1
     # restore class, so we can continue to test create-replicated
     ceph osd crush set-device-class abc osd.2 || return 1
 
index 9c03358aad3c87012e95e2d8d03bc226a8acab65..af641050d4660c94b33f0bbbf381834a311eac67 100644 (file)
@@ -1840,18 +1840,6 @@ int CrushWrapper::remove_device_class(CephContext *cct, int id, ostream *ss)
   }
   class_remove_item(id);
 
-  // note that there is no need to remove ourselves from shadow parent
-  // and reweight because we are going to destroy all shadow trees
-  // rebuild them all (if necessary) later.
-
-  // see if there is any osds that still reference this class
-  set<int> devices;
-  get_devices_by_class(class_name, &devices);
-  if (devices.empty()) {
-    // class has no more devices
-    remove_class_name(class_name);
-  }
-
   int r = rebuild_roots_with_classes();
   if (r < 0) {
     *ss << "unable to rebuild roots with class '" << class_name << "' "