osd/osd_types: pg_t: add is_merge_target()

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2018-06-15 07:09:04 -05:00
parent e95556041b
commit ca8dfd35c8
3 changed files with 13 additions and 4 deletions

View File

@ -3471,11 +3471,9 @@ bool PastIntervals::is_new_interval(
// merge source
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)) ||
pgid.is_merge_target(old_pg_num_pending, new_pg_num_pending) ||
// merge target
(pgid.ps() < new_pg_num &&
pgid.is_split(new_pg_num, old_pg_num, 0)) ||
pgid.is_merge_target(old_pg_num, new_pg_num) ||
old_sort_bitwise != new_sort_bitwise ||
old_recovery_deletes != new_recovery_deletes;
}

View File

@ -413,6 +413,9 @@ struct pg_t {
bool is_split(unsigned old_pg_num, unsigned new_pg_num, set<pg_t> *pchildren) const;
bool is_merge_source(unsigned old_pg_num, unsigned new_pg_num, pg_t *parent) const;
bool is_merge_target(unsigned old_pg_num, unsigned new_pg_num) const {
return ps() < new_pg_num && is_split(new_pg_num, old_pg_num, nullptr);
}
/**
* Returns b such that for all object o:
@ -541,6 +544,9 @@ struct spg_t {
}
return is_split;
}
bool is_merge_target(unsigned old_pg_num, unsigned new_pg_num) const {
return pgid.is_merge_target(old_pg_num, new_pg_num);
}
bool is_merge_source(unsigned old_pg_num, unsigned new_pg_num,
spg_t *parent) const {
spg_t out = *this;

View File

@ -811,21 +811,26 @@ TEST(pg_t, merge)
b = pgid.is_merge_source(8, 7, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(3, 0));
ASSERT_TRUE(parent.is_merge_target(8, 7));
b = pgid.is_merge_source(8, 5, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(3, 0));
ASSERT_TRUE(parent.is_merge_target(8, 5));
b = pgid.is_merge_source(8, 4, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(3, 0));
ASSERT_TRUE(parent.is_merge_target(8, 4));
b = pgid.is_merge_source(8, 3, &parent);
ASSERT_TRUE(b);
ASSERT_EQ(parent, pg_t(1, 0));
ASSERT_TRUE(parent.is_merge_target(8, 4));
b = pgid.is_merge_source(9, 8, &parent);
ASSERT_FALSE(b);
ASSERT_FALSE(parent.is_merge_target(9, 8));
}
TEST(pg_missing_t, constructor)