From 379fa3575002c6c69bf78b1310d30e3bdfa8dbbf Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 19 Jul 2016 19:11:02 -0700 Subject: [PATCH 1/2] osd_types: rename swap to claim, restrict to the non-tracking variant Signed-off-by: Samuel Just --- src/osd/PG.cc | 6 +++--- src/osd/osd_types.h | 7 ++----- src/test/osd/types.cc | 5 ++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 66cf81a3a0c..f14db8d7078 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -320,7 +320,7 @@ void PG::proc_master_log( assert(cct->_conf->osd_find_best_info_ignore_history_les || info.last_epoch_started >= info.history.last_epoch_started); - peer_missing[from].swap(omissing); + peer_missing[from].claim(omissing); } void PG::proc_replica_log( @@ -344,7 +344,7 @@ void PG::proc_replica_log( dout(20) << " after missing " << i->first << " need " << i->second.need << " have " << i->second.have << dendl; } - peer_missing[from].swap(omissing); + peer_missing[from].claim(omissing); } bool PG::proc_replica_info( @@ -7711,7 +7711,7 @@ boost::statechart::result PG::RecoveryState::WaitUpThru::react(const MLogRec& lo { dout(10) << "Noting missing from osd." << logevt.from << dendl; PG *pg = context< RecoveryMachine >().pg; - pg->peer_missing[logevt.from].swap(logevt.msg->missing); + pg->peer_missing[logevt.from].claim(logevt.msg->missing); pg->peer_info[logevt.from] = logevt.msg->info; return discard_event(); } diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index a2b8ba7d09b..7d755f7b386 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2884,13 +2884,10 @@ public: return item.have; } - void swap(pg_missing_set& o) { - for (auto &&i: missing) - tracker.changed(i.first); + void claim(pg_missing_set& o) { + static_assert(!TrackChanges, "Can't use claim with TrackChanges"); missing.swap(o.missing); rmissing.swap(o.rmissing); - for (auto &&i: missing) - tracker.changed(i.first); } /* diff --git a/src/test/osd/types.cc b/src/test/osd/types.cc index d4036a6db69..a2a853f2fdd 100644 --- a/src/test/osd/types.cc +++ b/src/test/osd/types.cc @@ -749,7 +749,7 @@ TEST(pg_missing_t, have_missing) EXPECT_TRUE(missing.have_missing()); } -TEST(pg_missing_t, swap) +TEST(pg_missing_t, claim) { hobject_t oid(object_t("objname"), "key", 123, 456, 0, ""); pg_missing_t missing; @@ -760,8 +760,7 @@ TEST(pg_missing_t, swap) pg_missing_t other; EXPECT_FALSE(other.have_missing()); - other.swap(missing); - EXPECT_FALSE(missing.have_missing()); + other.claim(missing); EXPECT_TRUE(other.have_missing()); } From 45995c9f63363462d82cfbdf2920a301bb9a7d58 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 19 Jul 2016 19:32:10 -0700 Subject: [PATCH 2/2] osd_types: fix type of ChangeTracker::clean() Signed-off-by: Samuel Just --- src/osd/osd_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 7d755f7b386..795ae7d854d 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2800,7 +2800,7 @@ public: template void get_changed(F &&f) const {} void flush() {} - void clean() { + bool is_clean() const { return true; } };