From c644e24411891ed831c0cde4cf5796d9c51b463a Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 27 Aug 2024 13:51:00 -0700 Subject: [PATCH] mon/OSDMonitor: check crush features in crush_rule_create_erasure Also adjusts validate_crush_against_features to use an ostream& rather than a stringstream&. Fixes: https://tracker.ceph.com/issues/67755 Signed-off-by: Samuel Just (cherry picked from commit 1d6b4d4a507a1241a5e03016231e8160ef4b8f92) (cherry picked from commit e8f5b905f0f4887a7515e97799f43a2893e26f4c) --- src/mon/OSDMonitor.cc | 7 ++++++- src/mon/OSDMonitor.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 7bfd4e2cacc4f..a1593fe14ece4 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7500,6 +7500,11 @@ int OSDMonitor::crush_rule_create_erasure(const string &name, erasure_code.reset(); if (err < 0) return err; + + if (!validate_crush_against_features(&newcrush, *ss)) { + return -EINVAL; + } + *rule = err; pending_inc.crush.clear(); newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); @@ -7575,7 +7580,7 @@ int OSDMonitor::check_cluster_features(uint64_t features, } bool OSDMonitor::validate_crush_against_features(const CrushWrapper *newcrush, - stringstream& ss) + ostream &ss) { OSDMap::Incremental new_pending = pending_inc; encode(*newcrush, new_pending.crush, mon.get_quorum_con_features()); diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 398daf9243e10..f522f2b4c0b09 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -358,7 +358,7 @@ private: * @returns true if the map is passable, false otherwise */ bool validate_crush_against_features(const CrushWrapper *newcrush, - std::stringstream &ss); + std::ostream &ss); void check_osdmap_subs(); void share_map_with_random_osd(); -- 2.39.5