From 08eaca61be8efe3aabfbcdec6fc817bbc376fa25 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 13 Nov 2017 09:27:56 -0600 Subject: [PATCH] crush/CrushWrapper: get_full_location by name Signed-off-by: Sage Weil --- src/crush/CrushWrapper.cc | 12 ++++++++++++ src/crush/CrushWrapper.h | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 4262783d690..c72a8acedf2 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -684,6 +684,18 @@ map CrushWrapper::get_full_location(int id) const return full_location; } +int CrushWrapper::get_full_location(const string& name, + map *ploc) +{ + build_rmaps(); + auto p = name_rmap.find(name); + if (p == name_rmap.end()) { + return -ENOENT; + } + *ploc = get_full_location(p->second); + return 0; +} + int CrushWrapper::get_full_location_ordered(int id, vector >& path) const { if (!item_exists(id)) diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 8671306455f..5d306c50846 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -698,6 +698,13 @@ public: */ map get_full_location(int id) const; + /** + * return location map for a item, by name + */ + int get_full_location( + const string& name, + std::map *ploc); + /* * identical to get_full_location(int id) although it returns the type/name * pairs in the order they occur in the hierarchy. @@ -906,6 +913,7 @@ public: static int parse_loc_multimap(const std::vector& args, std::multimap *ploc); + /** * get an item's weight * -- 2.39.5