From: Samuel Just Date: Thu, 30 May 2019 00:31:48 +0000 (-0700) Subject: osd/: clarify rebuilt_missing_with_deletes and set in init X-Git-Tag: v15.1.0~2580^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6d66072cc431664c12930f962456fac1c3d7316f;p=ceph.git osd/: clarify rebuilt_missing_with_deletes and set in init Updates PeeringState::init to set may_include_deletes_in_missing when possible to avoid needlessly rebuilding the missing set on the next map. The previous behavior was also subtly wrong as until the the next map the osd would be possibly adding deletes to the missing set without the flag having been set in the missing set on disk This patch also renames the flag to reflect the fact that it simply denotes wheter the may_include_deletes_in_missing omap entry needs to be written out. This may happen during rebuild_missing_set_with_deletes, but it'll also happen more commonly during init now. Signed-off-by: Samuel Just --- diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc index 2a99ea7d8442..8438873a37b6 100644 --- a/src/osd/PGLog.cc +++ b/src/osd/PGLog.cc @@ -644,7 +644,7 @@ void PGLog::write_log_and_missing( dirty_to_dups, dirty_from_dups, write_from_dups, - &rebuilt_missing_with_deletes, + &may_include_deletes_in_missing_dirty, (pg_log_debug ? &log_keys_debug : nullptr)); undirty(); } else { @@ -678,7 +678,7 @@ void PGLog::write_log_and_missing( const ghobject_t &log_oid, const pg_missing_tracker_t &missing, bool require_rollback, - bool *rebuilt_missing_with_deletes) + bool *may_include_deletes_in_missing_dirty) { _write_log_and_missing( t, km, log, coll, log_oid, @@ -692,7 +692,7 @@ void PGLog::write_log_and_missing( eversion_t::max(), eversion_t(), eversion_t(), - rebuilt_missing_with_deletes, nullptr); + may_include_deletes_in_missing_dirty, nullptr); } // static @@ -828,7 +828,7 @@ void PGLog::_write_log_and_missing( eversion_t dirty_to_dups, eversion_t dirty_from_dups, eversion_t write_from_dups, - bool *rebuilt_missing_with_deletes, // in/out param + bool *may_include_deletes_in_missing_dirty, // in/out param set *log_keys_debug ) { set to_remove; @@ -931,9 +931,9 @@ void PGLog::_write_log_and_missing( } // since we encode individual missing items instead of a whole // missing set, we need another key to store this bit of state - if (*rebuilt_missing_with_deletes) { + if (*may_include_deletes_in_missing_dirty) { (*km)["may_include_deletes_in_missing"] = bufferlist(); - *rebuilt_missing_with_deletes = false; + *may_include_deletes_in_missing_dirty = false; } missing.get_changed( [&](const hobject_t &obj) { @@ -975,7 +975,6 @@ void PGLog::rebuild_missing_set_with_deletes( } } missing.clear(); - missing.may_include_deletes = true; // go through the log and add items that are not present or older // versions on disk, just as if we were reading the log + metadata @@ -1014,5 +1013,6 @@ void PGLog::rebuild_missing_set_with_deletes( for (const auto& p : extra_missing) { missing.add(p.first, p.second.need, p.second.have, p.second.is_delete()); } - rebuilt_missing_with_deletes = true; + + set_missing_may_contain_deletes(); } diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index 55fc0a707a21..622c34a10ec7 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -571,7 +571,7 @@ protected: /// Log is clean on [dirty_to, dirty_from) bool touched_log; bool clear_divergent_priors; - bool rebuilt_missing_with_deletes = false; + bool may_include_deletes_in_missing_dirty = false; void mark_dirty_to(eversion_t to) { if (to > dirty_to) @@ -608,7 +608,7 @@ public: (dirty_to_dups != eversion_t()) || (dirty_from_dups != eversion_t::max()) || (write_from_dups != eversion_t::max()) || - rebuilt_missing_with_deletes; + may_include_deletes_in_missing_dirty; } void mark_log_for_rewrite() { @@ -618,8 +618,8 @@ public: mark_dirty_from_dups(eversion_t()); touched_log = false; } - bool get_rebuilt_missing_with_deletes() const { - return rebuilt_missing_with_deletes; + bool get_may_include_deletes_in_missing_dirty() const { + return may_include_deletes_in_missing_dirty; } protected: @@ -763,8 +763,9 @@ public: opg_log->mark_dirty_to_dups(eversion_t::max()); mark_dirty_to(eversion_t::max()); mark_dirty_to_dups(eversion_t::max()); - if (missing.may_include_deletes) - opg_log->rebuilt_missing_with_deletes = true; + if (missing.may_include_deletes) { + opg_log->set_missing_may_contain_deletes(); + } } void merge_from( @@ -839,6 +840,11 @@ public: const pg_log_t &olog, pg_missing_t& omissing, pg_shard_t from) const; + void set_missing_may_contain_deletes() { + missing.may_include_deletes = true; + may_include_deletes_in_missing_dirty = true; + } + void rebuild_missing_set_with_deletes(ObjectStore *store, ObjectStore::CollectionHandle& ch, const pg_info_t &info); @@ -1302,7 +1308,7 @@ public: eversion_t dirty_to_dups, eversion_t dirty_from_dups, eversion_t write_from_dups, - bool *rebuilt_missing_with_deletes, + bool *may_include_deletes_in_missing_dirty, set *log_keys_debug ); diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 138a69bc223c..a707e48426f6 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -728,12 +728,12 @@ void PeeringState::on_new_interval() << get_pg_log().get_missing() << dendl; if (!pg_log.get_missing().may_include_deletes && - get_osdmap()->test_flag(CEPH_OSDMAP_RECOVERY_DELETES)) { + !perform_deletes_during_peering()) { pl->rebuild_missing_set_with_deletes(pg_log); } ceph_assert( - pg_log.get_missing().may_include_deletes == get_osdmap()->test_flag( - CEPH_OSDMAP_RECOVERY_DELETES)); + pg_log.get_missing().may_include_deletes == + !perform_deletes_during_peering()); pl->on_new_interval(); } @@ -3354,6 +3354,10 @@ void PeeringState::init( info.stats.acting_primary = new_acting_primary; info.stats.mapping_epoch = info.history.same_interval_since; + if (!perform_deletes_during_peering()) { + pg_log.set_missing_may_contain_deletes(); + } + if (backfill) { psdout(10) << __func__ << ": Setting backfill" << dendl; info.set_last_backfill(hobject_t()); diff --git a/src/test/osd/TestPGLog.cc b/src/test/osd/TestPGLog.cc index 81bfad982427..0336276df2f8 100644 --- a/src/test/osd/TestPGLog.cc +++ b/src/test/osd/TestPGLog.cc @@ -2271,23 +2271,23 @@ TEST_F(PGLogTest, split_into_preserves_may_include_deletes) { clear(); { - rebuilt_missing_with_deletes = false; + may_include_deletes_in_missing_dirty = false; missing.may_include_deletes = true; PGLog child_log(cct); pg_t child_pg; split_into(child_pg, 6, &child_log); ASSERT_TRUE(child_log.get_missing().may_include_deletes); - ASSERT_TRUE(child_log.get_rebuilt_missing_with_deletes()); + ASSERT_TRUE(child_log.get_may_include_deletes_in_missing_dirty()); } { - rebuilt_missing_with_deletes = false; + may_include_deletes_in_missing_dirty = false; missing.may_include_deletes = false; PGLog child_log(cct); pg_t child_pg; split_into(child_pg, 6, &child_log); ASSERT_FALSE(child_log.get_missing().may_include_deletes); - ASSERT_FALSE(child_log.get_rebuilt_missing_with_deletes()); + ASSERT_FALSE(child_log.get_may_include_deletes_in_missing_dirty()); } }