}
// pg -> (up osd list)
-void OSDMap::_raw_to_up_osds(pg_t pg, const vector<int>& raw,
+void OSDMap::_raw_to_up_osds(const pg_pool_t& pool, const vector<int>& raw,
vector<int> *up, int *primary) const
{
- up->clear();
- for (unsigned i=0; i<raw.size(); i++) {
- if (!exists(raw[i]) || is_down(raw[i]))
- continue;
- up->push_back(raw[i]);
+ if (pool.can_shift_osds()) {
+ // shift left
+ up->clear();
+ for (unsigned i=0; i<raw.size(); i++) {
+ if (!exists(raw[i]) || is_down(raw[i]))
+ continue;
+ up->push_back(raw[i]);
+ }
+ *primary = (up->empty() ? -1 : up->front());
+ } else {
+ // set down/dne devices to NONE
+ *primary = -1;
+ up->resize(raw.size());
+ for (int i = raw.size() - 1; i >= 0; --i) {
+ if (!exists(raw[i]) || is_down(raw[i])) {
+ (*up)[i] = CRUSH_ITEM_NONE;
+ } else {
+ *primary = (*up)[i] = raw[i];
+ }
+ }
}
- *primary = (up->empty() ? -1 : up->front());
}
void OSDMap::_get_temp_osds(const pg_pool_t& pool, pg_t pg,
}
vector<int> raw;
_pg_to_osds(*pool, pg, &raw, primary);
- _raw_to_up_osds(pg, raw, up, primary);
+ _raw_to_up_osds(*pool, raw, up, primary);
}
void OSDMap::_pg_to_up_acting_osds(pg_t pg, vector<int> *up, int *up_primary,
int _up_primary;
int _acting_primary;
_pg_to_osds(*pool, pg, &raw, &_up_primary);
- _raw_to_up_osds(pg, raw, &_up, &_up_primary);
+ _raw_to_up_osds(*pool, raw, &_up, &_up_primary);
_get_temp_osds(*pool, pg, &_acting, &_acting_primary);
if (_acting.empty())
_acting = _up;
void _remove_nonexistent_osds(const pg_pool_t& pool, vector<int>& osds) const;
/// pg -> (up osd list)
- void _raw_to_up_osds(pg_t pg, const vector<int>& raw,
+ void _raw_to_up_osds(const pg_pool_t& pool, const vector<int>& raw,
vector<int> *up, int *primary) const;
/**