return _pg_to_osds(*pool, pg, raw);
}
-int OSDMap::pg_to_acting_osds(pg_t pg, vector<int>& acting) const
-{
- const pg_pool_t *pool = get_pg_pool(pg.pool());
- if (!pool)
- return 0;
- vector<int> raw;
- _pg_to_osds(*pool, pg, raw);
- if (!_raw_to_temp_osds(*pool, pg, raw, acting))
- _raw_to_up_osds(pg, raw, acting);
- return acting.size();
-}
-
void OSDMap::pg_to_raw_up(pg_t pg, vector<int>& up) const
{
const pg_pool_t *pool = get_pg_pool(pg.pool());
_raw_to_up_osds(pg, raw, up);
}
-void OSDMap::pg_to_up_acting_osds(pg_t pg, vector<int>& up, vector<int>& acting) const
+void OSDMap::_pg_to_up_acting_osds(pg_t pg, vector<int> *up, vector<int>& acting) const
{
const pg_pool_t *pool = get_pg_pool(pg.pool());
if (!pool)
return;
vector<int> raw;
+ vector<int> *_up = (up ? up : new vector<int>);
_pg_to_osds(*pool, pg, raw);
- _raw_to_up_osds(pg, raw, up);
+ _raw_to_up_osds(pg, raw, *up);
if (!_raw_to_temp_osds(*pool, pg, raw, acting))
- acting = up;
+ acting = *_up;
+ if (_up != up)
+ delete _up;
}
int OSDMap::calc_pg_rank(int osd, vector<int>& acting, int nrep)
bool _raw_to_temp_osds(const pg_pool_t& pool, pg_t pg, vector<int>& raw, vector<int>& temp) const;
+ /// map to up and acting. Only provides up if pointer is non-NULL
+ void _pg_to_up_acting_osds(pg_t pg, vector<int> *up,
+ vector<int>& acting) const;
+
public:
/***
* This is suitable only for looking at raw CRUSH outputs. It skips
*/
int pg_to_osds(pg_t pg, vector<int>& raw) const;
/// map a pg to its acting set. @return acting set size
- int pg_to_acting_osds(pg_t pg, vector<int>& acting) const;
+ int pg_to_acting_osds(pg_t pg, vector<int>& acting) const {
+ _pg_to_up_acting_osds(pg, NULL, acting);
+ return acting.size();
+ }
/**
* This does not apply temp overrides and should not be used
* by anybody for data mapping purposes.
* also find the up set useful for things like deciding what to
* set as pg_temp.
*/
- void pg_to_up_acting_osds(pg_t pg, vector<int>& up, vector<int>& acting) const;
+ void pg_to_up_acting_osds(pg_t pg, vector<int>& up,
+ vector<int>& acting) const {
+ _pg_to_up_acting_osds(pg, &up, acting);
+ }
int64_t lookup_pg_pool_name(const string& name) {
if (name_pool.count(name))