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
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
}
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);
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\", ") +
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
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
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 "
# 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)