osd/osd_types: pg_t::is_merge -> is_merge_source

This only checks if a pg is a merge source, not whether it is a merge
target.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2018-06-14 17:45:55 -05:00
parent 7f2e439641
commit e95556041b
3 changed files with 15 additions and 12 deletions

View File

@ -558,8 +558,10 @@ unsigned pg_t::get_split_bits(unsigned pg_num) const {
return p - 1;
}
bool pg_t::is_merge(unsigned old_pg_num, unsigned new_pg_num,
pg_t *parent) const
bool pg_t::is_merge_source(
unsigned old_pg_num,
unsigned new_pg_num,
pg_t *parent) const
{
if (m_seed < old_pg_num &&
m_seed >= new_pg_num) {
@ -3465,9 +3467,9 @@ bool PastIntervals::is_new_interval(
old_size != new_size ||
pgid.is_split(old_pg_num, new_pg_num, 0) ||
// pre-merge source
pgid.is_merge(old_pg_num_pending, new_pg_num_pending, 0) ||
pgid.is_merge_source(old_pg_num_pending, new_pg_num_pending, 0) ||
// merge source
pgid.is_merge(old_pg_num, new_pg_num, 0) ||
pgid.is_merge_source(old_pg_num, new_pg_num, 0) ||
// pre-merge target
(pgid.ps() < new_pg_num_pending &&
pgid.is_split(new_pg_num_pending, old_pg_num_pending, 0)) ||

View File

@ -412,7 +412,7 @@ struct pg_t {
bool is_split(unsigned old_pg_num, unsigned new_pg_num, set<pg_t> *pchildren) const;
bool is_merge(unsigned old_pg_num, unsigned new_pg_num, pg_t *parent) const;
bool is_merge_source(unsigned old_pg_num, unsigned new_pg_num, pg_t *parent) const;
/**
* Returns b such that for all object o:
@ -541,9 +541,10 @@ struct spg_t {
}
return is_split;
}
bool is_merge(unsigned old_pg_num, unsigned new_pg_num, spg_t *parent) const {
bool is_merge_source(unsigned old_pg_num, unsigned new_pg_num,
spg_t *parent) const {
spg_t out = *this;
bool r = pgid.is_merge(old_pg_num, new_pg_num, &out.pgid);
bool r = pgid.is_merge_source(old_pg_num, new_pg_num, &out.pgid);
if (r && parent) {
*parent = out;
}

View File

@ -808,23 +808,23 @@ TEST(pg_t, merge)
bool b;
pgid = pg_t(7, 0);
b = pgid.is_merge(8, 7, &parent);
b = pgid.is_merge_source(8, 7, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(3, 0));
b = pgid.is_merge(8, 5, &parent);
b = pgid.is_merge_source(8, 5, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(3, 0));
b = pgid.is_merge(8, 4, &parent);
b = pgid.is_merge_source(8, 4, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(3, 0));
b = pgid.is_merge(8, 3, &parent);
b = pgid.is_merge_source(8, 3, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(1, 0));
b = pgid.is_merge(9, 8, &parent);
b = pgid.is_merge_source(9, 8, &parent);
ASSERT_FALSE(b);
}