]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSD: automatically set device class on start
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 30 Jun 2017 13:57:49 +0000 (21:57 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 10 Jul 2017 00:45:36 +0000 (08:45 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/common/config_opts.h
src/os/ObjectStore.h
src/os/bluestore/BlueStore.h
src/osd/OSD.cc
src/test/crush/crush-choose-args.sh
src/test/crush/crush-classes.sh
src/test/osd/osd-fast-mark-down.sh

index b1f88440d0fbf9055ba62b58a38860185d9df175..e4d5174779f1b42f5cbecb14319348055186b7bb 100644 (file)
@@ -689,6 +689,7 @@ OPTION(osd_crush_update_weight_set, OPT_BOOL, true) // update weight set while u
 OPTION(osd_crush_chooseleaf_type, OPT_INT, 1) // 1 = host
 OPTION(osd_pool_use_gmt_hitset, OPT_BOOL, true) // try to use gmt for hitset archive names if all osds in cluster support it.
 OPTION(osd_crush_update_on_start, OPT_BOOL, true)
+OPTION(osd_class_update_on_start, OPT_BOOL, true) // automatically set device class on start
 OPTION(osd_crush_initial_weight, OPT_DOUBLE, -1) // if >=0, the initial weight is for newly added osds.
 OPTION(osd_pool_default_crush_rule, OPT_INT, -1)
 OPTION(osd_pool_erasure_code_stripe_unit, OPT_U32, 4096) // in bytes
index caf2bb779c644684a973072669190101210bea2f..4f1e9b8f45ebcd6a0bd74b34d800f168434719d8 100644 (file)
@@ -1575,6 +1575,10 @@ public:
     return true;
   }
 
+  virtual string get_default_device_class() {
+    return is_rotational() ? "hdd" : "ssd";
+  }
+
   virtual bool can_sort_nibblewise() {
     return false;   // assume a backend cannot, unless it says otherwise
   }
index e60f906b3977ee65775b6f4f931b35d6a2528d90..acb9041eaec9f64414f7d54991e3b4dc167af201 100644 (file)
@@ -2113,6 +2113,17 @@ public:
 
   bool is_rotational() override;
 
+  string get_default_device_class() override {
+    string device_class;
+    map<string, string> metadata;
+    collect_metadata(&metadata);
+    auto it = metadata.find("bluestore_bdev_type");
+    if (it != metadata.end()) {
+      device_class = it->second;
+    }
+    return device_class;
+  }
+
   static int get_block_device_fsid(CephContext* cct, const string& path,
                                   uuid_d *fsid);
 
index 7a1e295b673dd8f603321a615941ff6dbec09d41..1392be7a01cc5411b6f907387d62eeb68bcda8ec 100644 (file)
@@ -3436,10 +3436,20 @@ int OSD::update_crush_location()
 
 int OSD::update_crush_device_class()
 {
+  if (!cct->_conf->osd_class_update_on_start) {
+    dout(10) << __func__ << " osd_class_update_on_start = false" << dendl;
+    return 0;
+  }
+
   string device_class;
   int r = store->read_meta("crush_device_class", &device_class);
-  if (r < 0)
+  if (r < 0 || device_class.empty()) {
+    device_class = store->get_default_device_class();
+  }
+
+  if (device_class.empty()) {
     return 0;
+  }
 
   string cmd =
     string("{\"prefix\": \"osd crush set-device-class\", ") +
index c0aefb23834fce9c27ea8c29074c5cf4bececa9e..709d875d80074a393795f23de2528bd145da3e18 100755 (executable)
@@ -28,6 +28,12 @@ function run() {
     CEPH_ARGS+="--mon-host=$CEPH_MON "
     CEPH_ARGS+="--crush-location=root=default,host=HOST "
     CEPH_ARGS+="--osd-crush-initial-weight=3 "
+    #
+    # Disable device auto class feature for now.
+    # The device class is non-deterministic and will
+    # crash the crushmap comparison below.
+    #
+    CEPH_ARGS+="--osd-class-update-on-start=false "
 
     local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
     for func in $funcs ; do
index 76245779d59c98c6964e623389ad7ce35248540d..ac8ec2052dd9b3a3cefe5b35ed1df1ba0609f3ea 100755 (executable)
@@ -26,6 +26,10 @@ function run() {
     export CEPH_ARGS
     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
     CEPH_ARGS+="--mon-host=$CEPH_MON "
+    #
+    # Disable auto-class, so we can inject device class manually below
+    #
+    CEPH_ARGS+="--osd-class-update-on-start=false "
 
     local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
     for func in $funcs ; do
index 5c8f420fecbb4d3863d90575d470968d5a2ef897..051b7d32815a2a7df88473675a7af0d162648cb7 100755 (executable)
@@ -28,6 +28,25 @@ function run() {
     export CEPH_ARGS
     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
     CEPH_ARGS+="--mon-host=$CEPH_MON "
+    #
+    # Disable device auto class feature for this testing,
+    # as it will automatically make root clones based on new class types
+    # and hence affect the down osd counting.
+    # E.g.,
+    #
+    # ID WEIGHT  TYPE NAME                                            UP/DOWN REWEIGHT PRIMARY-AFFINITY 
+    # -4 3.00000 root default~hdd                                                                       
+    # -3 3.00000     host gitbuilder-ceph-rpm-centos7-amd64-basic~hdd                                   
+    #  0 1.00000         osd.0                                           down  1.00000          1.00000 
+    #  1 1.00000         osd.1                                             up  1.00000          1.00000 
+    #  2 1.00000         osd.2                                             up  1.00000          1.00000 
+    # -1 3.00000 root default                                                                           
+    # -2 3.00000     host gitbuilder-ceph-rpm-centos7-amd64-basic                                       
+    #  0 1.00000         osd.0                                           down  1.00000          1.00000 
+    #  1 1.00000         osd.1                                             up  1.00000          1.00000 
+    #  2 1.00000         osd.2                                             up  1.00000          1.00000   
+    #
+    CEPH_ARGS+="--osd-class-update-on-start=false "
     
     OLD_ARGS=$CEPH_ARGS
     CEPH_ARGS+="--osd-fast-fail-on-connection-refused=false "
@@ -53,7 +72,7 @@ function test_fast_kill() {
    # create cluster with 3 osds
    setup $dir || return 1
    run_mon $dir a --osd_pool_default_size=3 || return 1
-    run_mgr $dir x || return 1
+   run_mgr $dir x || return 1
    for oi in {0..2}; do
      run_osd $dir $oi || return 1
      pids[$oi]=$(cat $dir/osd.$oi.pid)