From: xie xingguo Date: Fri, 30 Jun 2017 13:57:49 +0000 (+0800) Subject: osd/OSD: automatically set device class on start X-Git-Tag: v12.1.1~42^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0c885d6800435d6f9b31cdf521f8106206617e65;p=ceph.git osd/OSD: automatically set device class on start Signed-off-by: xie xingguo --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index b1f88440d0fb..e4d5174779f1 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index caf2bb779c64..4f1e9b8f45eb 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -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 } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index e60f906b3977..acb9041eaec9 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2113,6 +2113,17 @@ public: bool is_rotational() override; + string get_default_device_class() override { + string device_class; + map 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); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 7a1e295b673d..1392be7a01cc 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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\", ") + diff --git a/src/test/crush/crush-choose-args.sh b/src/test/crush/crush-choose-args.sh index c0aefb23834f..709d875d8007 100755 --- a/src/test/crush/crush-choose-args.sh +++ b/src/test/crush/crush-choose-args.sh @@ -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 diff --git a/src/test/crush/crush-classes.sh b/src/test/crush/crush-classes.sh index 76245779d59c..ac8ec2052dd9 100755 --- a/src/test/crush/crush-classes.sh +++ b/src/test/crush/crush-classes.sh @@ -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 diff --git a/src/test/osd/osd-fast-mark-down.sh b/src/test/osd/osd-fast-mark-down.sh index 5c8f420fecbb..051b7d32815a 100755 --- a/src/test/osd/osd-fast-mark-down.sh +++ b/src/test/osd/osd-fast-mark-down.sh @@ -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)