Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd/osd_types: kill preferred field in pg_t #20567

Merged
merged 2 commits into from Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mon/OSDMonitor.cc
Expand Up @@ -1414,7 +1414,7 @@ bool OSDMonitor::is_pool_currently_all_bluestore(int64_t pool_id,
set<int> checked_osds;
for (unsigned ps = 0; ps < std::min(8u, pool.get_pg_num()); ++ps) {
vector<int> up, acting;
pg_t pgid(ps, pool_id, -1);
pg_t pgid(ps, pool_id);
osdmap.pg_to_up_acting_osds(pgid, up, acting);
for (int osd : up) {
if (checked_osds.find(osd) != checked_osds.end())
Expand Down
6 changes: 3 additions & 3 deletions src/mon/PGMap.cc
Expand Up @@ -1023,15 +1023,15 @@ void PGMap::Incremental::generate_test_instances(list<PGMap::Incremental*>& o)
o.back()->stamp = utime_t(123,345);
o.push_back(new Incremental);
o.back()->version = 2;
o.back()->pg_stat_updates[pg_t(1,2,3)] = pg_stat_t();
o.back()->pg_stat_updates[pg_t(1,2)] = pg_stat_t();
o.back()->osd_stat_updates[5] = osd_stat_t();
o.push_back(new Incremental);
o.back()->version = 3;
o.back()->osdmap_epoch = 1;
o.back()->pg_scan = 2;
o.back()->pg_stat_updates[pg_t(4,5,6)] = pg_stat_t();
o.back()->pg_stat_updates[pg_t(4,5)] = pg_stat_t();
o.back()->osd_stat_updates[6] = osd_stat_t();
o.back()->pg_remove.insert(pg_t(1,2,3));
o.back()->pg_remove.insert(pg_t(1,2));
o.back()->osd_stat_rm.insert(5);
}

Expand Down
41 changes: 0 additions & 41 deletions src/osd/OSD.cc
Expand Up @@ -3964,12 +3964,6 @@ void OSD::load_pgs()
continue;
}

if (pgid.preferred() >= 0) {
dout(10) << __func__ << ": skipping localized PG " << pgid << dendl;
// FIXME: delete it too, eventually
continue;
}

dout(10) << "pgid " << pgid << " coll " << coll_t(pgid) << dendl;
epoch_t map_epoch = 0;
int r = PG::peek_map_epoch(store, pgid, &map_epoch);
Expand Down Expand Up @@ -8171,11 +8165,6 @@ void OSD::handle_pg_create(OpRequestRef op)
continue;
pg_t on = p->first;

if (on.preferred() >= 0) {
dout(20) << "ignoring localized pg " << on << dendl;
continue;
}

if (!osdmap->have_pg_pool(on.pool())) {
dout(20) << "ignoring pg on deleted pool " << on << dendl;
continue;
Expand Down Expand Up @@ -8446,11 +8435,6 @@ void OSD::handle_pg_notify(OpRequestRef op)
for (auto it = m->get_pg_list().begin();
it != m->get_pg_list().end();
++it) {
if (it->first.info.pgid.preferred() >= 0) {
dout(20) << "ignoring localized pg " << it->first.info.pgid << dendl;
continue;
}

handle_pg_peering_evt(
spg_t(it->first.info.pgid.pgid, it->first.to),
it->first.info.history, it->second,
Expand All @@ -8477,11 +8461,6 @@ void OSD::handle_pg_log(OpRequestRef op)
if (!require_same_or_newer_map(op, m->get_epoch(), false))
return;

if (m->get_pgid().preferred() >= 0) {
dout(10) << "ignoring localized pg " << m->get_pgid() << dendl;
return;
}

op->mark_started();
handle_pg_peering_evt(
spg_t(m->get_pgid().pgid, m->to),
Expand Down Expand Up @@ -8511,11 +8490,6 @@ void OSD::handle_pg_info(OpRequestRef op)
for (auto p = m->pg_list.begin();
p != m->pg_list.end();
++p) {
if (p->first.info.pgid.preferred() >= 0) {
dout(10) << "ignoring localized pg " << p->first.info.pgid << dendl;
continue;
}

handle_pg_peering_evt(
spg_t(p->first.info.pgid.pgid, p->first.to),
p->first.info.history, p->second, p->first.epoch_sent,
Expand Down Expand Up @@ -8543,11 +8517,6 @@ void OSD::handle_pg_trim(OpRequestRef op)
if (!require_same_or_newer_map(op, m->epoch, false))
return;

if (m->pgid.preferred() >= 0) {
dout(10) << "ignoring localized pg " << m->pgid << dendl;
return;
}

op->mark_started();

PG *pg = _lookup_lock_pg(m->pgid);
Expand Down Expand Up @@ -8717,11 +8686,6 @@ void OSD::handle_pg_query(OpRequestRef op)
++it) {
spg_t pgid = it->first;

if (pgid.preferred() >= 0) {
dout(10) << "ignoring localized pg " << pgid << dendl;
continue;
}

if (service.splitting(pgid)) {
peering_wait_for_split[pgid].push_back(
PGPeeringEventRef(
Expand Down Expand Up @@ -8817,11 +8781,6 @@ void OSD::handle_pg_remove(OpRequestRef op)
it != m->pg_list.end();
++it) {
spg_t pgid = *it;
if (pgid.preferred() >= 0) {
dout(10) << "ignoring localized pg " << pgid << dendl;
continue;
}

enqueue_peering_evt(
pgid,
PGPeeringEventRef(
Expand Down
2 changes: 1 addition & 1 deletion src/osd/OSDMap.cc
Expand Up @@ -3731,7 +3731,7 @@ int OSDMap::summarize_mapping_stats(
vector<int> up, up2;
int up_primary;
for (unsigned ps = 0; ps < pi->get_pg_num(); ++ps) {
pg_t pgid(ps, pool_id, -1);
pg_t pgid(ps, pool_id);
total_pg += pi->get_size();
pg_to_up_acting_osds(pgid, &up, &up_primary, nullptr, nullptr);
for (int osd : up) {
Expand Down
46 changes: 11 additions & 35 deletions src/osd/osd_types.cc
Expand Up @@ -412,54 +412,34 @@ void osd_stat_t::generate_test_instances(std::list<osd_stat_t*>& o)

int pg_t::print(char *o, int maxlen) const
{
if (preferred() >= 0)
return snprintf(o, maxlen, "%llu.%xp%d", (unsigned long long)pool(), ps(), preferred());
else
return snprintf(o, maxlen, "%llu.%x", (unsigned long long)pool(), ps());
return snprintf(o, maxlen, "%llu.%x", (unsigned long long)pool(), ps());
}

bool pg_t::parse(const char *s)
{
uint64_t ppool;
uint32_t pseed;
int32_t pref;
int r = sscanf(s, "%llu.%xp%d", (long long unsigned *)&ppool, &pseed, &pref);
int r = sscanf(s, "%llu.%x", (long long unsigned *)&ppool, &pseed);
if (r < 2)
return false;
m_pool = ppool;
m_seed = pseed;
if (r == 3)
m_preferred = pref;
else
m_preferred = -1;
return true;
}

bool spg_t::parse(const char *s)
{
pgid.set_preferred(-1);
shard = shard_id_t::NO_SHARD;
uint64_t ppool;
uint32_t pseed;
int32_t pref;
uint32_t pshard;
int r = sscanf(s, "%llu.%x", (long long unsigned *)&ppool, &pseed);
if (r < 2)
return false;
pgid.set_pool(ppool);
pgid.set_ps(pseed);

const char *p = strchr(s, 'p');
if (p) {
r = sscanf(p, "p%d", &pref);
if (r == 1) {
pgid.set_preferred(pref);
} else {
return false;
}
}

p = strchr(s, 's');
const char *p = strchr(s, 's');
if (p) {
r = sscanf(p, "s%u", &pshard);
if (r == 1) {
Expand Down Expand Up @@ -522,7 +502,7 @@ bool pg_t::is_split(unsigned old_pg_num, unsigned new_pg_num, set<pg_t> *childre
if ((unsigned)ceph_stable_mod(s, old_pg_num, old_mask) == m_seed) {
split = true;
if (children)
children->insert(pg_t(s, m_pool, m_preferred));
children->insert(pg_t(s, m_pool));
}
}
}
Expand All @@ -534,7 +514,7 @@ bool pg_t::is_split(unsigned old_pg_num, unsigned new_pg_num, set<pg_t> *childre
unsigned o = ceph_stable_mod(x, old_pg_num, old_mask);
if (o == m_seed) {
split = true;
children->insert(pg_t(x, m_pool, m_preferred));
children->insert(pg_t(x, m_pool));
}
}
}
Expand Down Expand Up @@ -593,25 +573,21 @@ void pg_t::dump(Formatter *f) const
{
f->dump_unsigned("pool", m_pool);
f->dump_unsigned("seed", m_seed);
f->dump_int("preferred_osd", m_preferred);
}

void pg_t::generate_test_instances(list<pg_t*>& o)
{
o.push_back(new pg_t);
o.push_back(new pg_t(1, 2, -1));
o.push_back(new pg_t(13123, 3, -1));
o.push_back(new pg_t(131223, 4, 23));
o.push_back(new pg_t(1, 2));
o.push_back(new pg_t(13123, 3));
o.push_back(new pg_t(131223, 4));
}

char *pg_t::calc_name(char *buf, const char *suffix_backwords) const
{
while (*suffix_backwords)
*--buf = *suffix_backwords++;

if (m_preferred >= 0)
*--buf ='p';

buf = ritoa<uint32_t, 16>(m_seed, buf);

*--buf = '.';
Expand Down Expand Up @@ -2528,7 +2504,7 @@ void pg_stat_t::generate_test_instances(list<pg_stat_t*>& o)
a.ondisk_log_start = eversion_t(1, 5);
a.created = 6;
a.last_epoch_clean = 7;
a.parent = pg_t(1, 2, 3);
a.parent = pg_t(1, 2);
a.parent_split_bits = 12;
a.last_scrub = eversion_t(9, 10);
a.last_scrub_stamp = utime_t(11, 12);
Expand Down Expand Up @@ -2906,7 +2882,7 @@ void pg_info_t::generate_test_instances(list<pg_info_t*>& o)
list<pg_history_t*> h;
pg_history_t::generate_test_instances(h);
o.back()->history = *h.back();
o.back()->pgid = spg_t(pg_t(1, 2, -1), shard_id_t::NO_SHARD);
o.back()->pgid = spg_t(pg_t(1, 2), shard_id_t::NO_SHARD);
o.back()->last_update = eversion_t(3, 4);
o.back()->last_complete = eversion_t(5, 6);
o.back()->last_user_version = 2;
Expand Down Expand Up @@ -4527,7 +4503,7 @@ void pg_create_t::dump(Formatter *f) const
void pg_create_t::generate_test_instances(list<pg_create_t*>& o)
{
o.push_back(new pg_create_t);
o.push_back(new pg_create_t(1, pg_t(3, 4, -1), 2));
o.push_back(new pg_create_t(1, pg_t(3, 4), 2));
}


Expand Down
41 changes: 13 additions & 28 deletions src/osd/osd_types.h
Expand Up @@ -365,14 +365,13 @@ WRITE_CLASS_ENCODER(old_pg_t)
struct pg_t {
uint64_t m_pool;
uint32_t m_seed;
int32_t m_preferred;

pg_t() : m_pool(0), m_seed(0), m_preferred(-1) {}
pg_t(ps_t seed, uint64_t pool, int pref=-1) :
m_pool(pool), m_seed(seed), m_preferred(pref) {}
pg_t() : m_pool(0), m_seed(0) {}
pg_t(ps_t seed, uint64_t pool) :
m_pool(pool), m_seed(seed) {}
// cppcheck-suppress noExplicitConstructor
pg_t(const ceph_pg& cpg) :
m_pool(cpg.pool), m_seed(cpg.ps), m_preferred((__s16)cpg.preferred) {}
m_pool(cpg.pool), m_seed(cpg.ps) {}

// cppcheck-suppress noExplicitConstructor
pg_t(const old_pg_t& opg) {
Expand All @@ -384,7 +383,7 @@ struct pg_t {
assert(m_pool < 0xffffffffull);
o.v.pool = m_pool;
o.v.ps = m_seed;
o.v.preferred = (__s16)m_preferred;
o.v.preferred = (__s16)-1;
return o;
}

Expand All @@ -394,9 +393,6 @@ struct pg_t {
uint64_t pool() const {
return m_pool;
}
int32_t preferred() const {
return m_preferred;
}

static const uint8_t calc_name_buf_size = 36; // max length for max values len("18446744073709551615.ffffffff") + future suffix len("_head") + '\0'
char *calc_name(char *buf, const char *suffix_backwords) const;
Expand All @@ -407,9 +403,6 @@ struct pg_t {
void set_pool(uint64_t p) {
m_pool = p;
}
void set_preferred(int32_t osd) {
m_preferred = osd;
}

pg_t get_parent() const;
pg_t get_ancestor(unsigned old_pg_num) const;
Expand Down Expand Up @@ -441,15 +434,15 @@ struct pg_t {
encode(v, bl);
encode(m_pool, bl);
encode(m_seed, bl);
encode(m_preferred, bl);
encode((int32_t)-1, bl); // was preferred
}
void decode(bufferlist::iterator& bl) {
using ceph::decode;
__u8 v;
decode(v, bl);
decode(m_pool, bl);
decode(m_seed, bl);
decode(m_preferred, bl);
bl.advance(sizeof(int32_t)); // was preferred
}
void decode_old(bufferlist::iterator& bl) {
using ceph::decode;
Expand All @@ -464,33 +457,27 @@ WRITE_CLASS_ENCODER(pg_t)

inline bool operator<(const pg_t& l, const pg_t& r) {
return l.pool() < r.pool() ||
(l.pool() == r.pool() && (l.preferred() < r.preferred() ||
(l.preferred() == r.preferred() && (l.ps() < r.ps()))));
(l.pool() == r.pool() && (l.ps() < r.ps()));
}
inline bool operator<=(const pg_t& l, const pg_t& r) {
return l.pool() < r.pool() ||
(l.pool() == r.pool() && (l.preferred() < r.preferred() ||
(l.preferred() == r.preferred() && (l.ps() <= r.ps()))));
(l.pool() == r.pool() && (l.ps() <= r.ps()));
}
inline bool operator==(const pg_t& l, const pg_t& r) {
return l.pool() == r.pool() &&
l.preferred() == r.preferred() &&
l.ps() == r.ps();
}
inline bool operator!=(const pg_t& l, const pg_t& r) {
return l.pool() != r.pool() ||
l.preferred() != r.preferred() ||
l.ps() != r.ps();
}
inline bool operator>(const pg_t& l, const pg_t& r) {
return l.pool() > r.pool() ||
(l.pool() == r.pool() && (l.preferred() > r.preferred() ||
(l.preferred() == r.preferred() && (l.ps() > r.ps()))));
(l.pool() == r.pool() && (l.ps() > r.ps()));
}
inline bool operator>=(const pg_t& l, const pg_t& r) {
return l.pool() > r.pool() ||
(l.pool() == r.pool() && (l.preferred() > r.preferred() ||
(l.preferred() == r.preferred() && (l.ps() >= r.ps()))));
(l.pool() == r.pool() && (l.ps() >= r.ps()));
}

ostream& operator<<(ostream& out, const pg_t &pg);
Expand All @@ -501,7 +488,8 @@ namespace std {
size_t operator()( const pg_t& x ) const
{
static hash<uint32_t> H;
return H((x.pool() & 0xffffffff) ^ (x.pool() >> 32) ^ x.ps() ^ x.preferred());
// xor (s32)-1 in there to preserve original m_preferred result (paranoia!)
return H((x.pool() & 0xffffffff) ^ (x.pool() >> 32) ^ x.ps() ^ (int32_t)(-1));
}
};
} // namespace std
Expand All @@ -524,9 +512,6 @@ struct spg_t {
uint64_t pool() const {
return pgid.pool();
}
int32_t preferred() const {
return pgid.preferred();
}

static const uint8_t calc_name_buf_size = pg_t::calc_name_buf_size + 4; // 36 + len('s') + len("255");
char *calc_name(char *buf, const char *suffix_backwords) const;
Expand Down
2 changes: 1 addition & 1 deletion src/test/mon/test_mon_workloadgen.cc
Expand Up @@ -514,7 +514,7 @@ class OSDStub : public TestStub
<< " epoch " << pool_epoch << dendl;

for (ps_t ps = 0; ps < pool.get_pg_num(); ++ps) {
pg_t pgid(ps, pool_id, -1);
pg_t pgid(ps, pool_id);
pg_t parent;
dout(20) << __func__
<< " pgid " << pgid << " parent " << parent << dendl;
Expand Down