From dfde0e60f0afb80b661b6a1cd2ae5d540fecf29c Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 5 Apr 2025 12:21:14 +0300 Subject: [PATCH] Do not allow reweight > 1 --- mon/osd_tree.js | 2 +- src/cmd/cli_modify_osd.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mon/osd_tree.js b/mon/osd_tree.js index 1607fcc9..d4f7e610 100644 --- a/mon/osd_tree.js +++ b/mon/osd_tree.js @@ -15,7 +15,7 @@ function get_osd_tree(global_config, state) const stat = state.osd.stats[osd_num]; const osd_cfg = state.config.osd[osd_num]; let reweight = osd_cfg == null ? 1 : Number(osd_cfg.reweight); - if (reweight < 0 || isNaN(reweight)) + if (isNaN(reweight) || reweight < 0 || reweight > 0) reweight = 1; if (stat && stat.size && reweight && (state.osd.state[osd_num] || Number(stat.time) >= down_time || osd_cfg && osd_cfg.noout)) diff --git a/src/cmd/cli_modify_osd.cpp b/src/cmd/cli_modify_osd.cpp index 5fc39230..0cd3ca77 100644 --- a/src/cmd/cli_modify_osd.cpp +++ b/src/cmd/cli_modify_osd.cpp @@ -58,6 +58,12 @@ struct osd_changer_t state = 100; return; } + if (set_reweight && new_reweight > 1) + { + result = (cli_result_t){ .err = EINVAL, .text = "Reweight can't be larger than 1" }; + state = 100; + return; + } parent->etcd_txn(json11::Json::object { { "success", json11::Json::array { json11::Json::object {