]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: rebuild shadow tree on "crush create-or-move/move"
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 25 Jul 2017 06:15:24 +0000 (14:15 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 26 Jul 2017 14:30:59 +0000 (22:30 +0800)
This patch solves the problem below:

./bin/ceph osd crush move osd.0 root=foo rack=foo-rack host=foo-host
moved item id 0 name 'osd.0' to location {host=foo-host,rack=foo-rack,root=foo} in crush map

 ./bin/ceph osd crush rule create-replicated foo-rule foo host ssd
Error EINVAL: root foo has no devices with class ssd

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

index 93900f052f18a49cc20baa88f14963e01c286703..b6b38a9a9f03eab8682ed52b6d4476f376504c28 100755 (executable)
@@ -162,6 +162,8 @@ function TEST_mon_classes() {
     if [ "$out" == "" ]; then
         return 1
     fi
+
+    ceph osd crush rule create-replicated foo-rule foo host abc || return 1
 }
 
 main crush-classes "$@"
index f11374ca09aba7069d7419926c9e3786d28856e4..c9845e792cbe36619fd842a4ee58958b1b9f56c6 100644 (file)
@@ -953,6 +953,12 @@ int CrushWrapper::insert_item(
       ldout(cct, 5) << "insert_item max_devices now " << crush->max_devices
                    << dendl;
     }
+    r = rebuild_roots_with_classes();
+    if (r < 0) {
+      ldout(cct, 0) << __func__ << " unable to rebuild roots with classes: "
+                    << cpp_strerror(r) << dendl;
+      return r;
+    }
     return 0;
   }