From 6cdc4f8fda11dd397f4b05acdcf66e7522e5a681 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 2 Jun 2013 12:50:13 +0200 Subject: [PATCH] merge_old_entry arguments info and oe are changed to const because there is no side effect. The PGLog::clear function is added to reset all data members to the same state they have after the object is constructed. Signed-off-by: Loic Dachary --- src/osd/PGLog.cc | 12 ++++++++++-- src/osd/PGLog.h | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc index 638a78697db2..cc897e00ae8d 100644 --- a/src/osd/PGLog.cc +++ b/src/osd/PGLog.cc @@ -21,7 +21,7 @@ #define dout_subsys ceph_subsys_osd -//////////////////// PGLog //////////////////// +//////////////////// PGLog::IndexedLog //////////////////// void PGLog::IndexedLog::split_into( pg_t child_pgid, @@ -103,6 +103,14 @@ ostream& PGLog::IndexedLog::print(ostream& out) const //////////////////// PGLog //////////////////// +void PGLog::clear() { + ondisklog.zero(); + ondisklog.has_checksums = true; + ondisklog.divergent_priors.clear(); + missing.clear(); + log.zero(); +} + void PGLog::clear_info_log( pg_t pgid, const hobject_t &infos_oid, @@ -251,7 +259,7 @@ void PGLog::proc_replica_log(ObjectStore::Transaction& t, * * return true if entry is not divergent. */ -bool PGLog::merge_old_entry(ObjectStore::Transaction& t, pg_log_entry_t& oe, pg_info_t& info, list& remove_snap, bool &dirty_log) +bool PGLog::merge_old_entry(ObjectStore::Transaction& t, const pg_log_entry_t& oe, const pg_info_t& info, list& remove_snap, bool &dirty_log) { if (oe.soid > info.last_backfill) { dout(20) << "merge_old_entry had " << oe << " : beyond last_backfill" << dendl; diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index cfb17f16ce24..c1a5195828fe 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -235,6 +235,9 @@ protected: IndexedLog log; public: + + void clear(); + //////////////////// get or set missing //////////////////// const pg_missing_t& get_missing() const { return missing; } @@ -352,8 +355,8 @@ public: pg_missing_t& omissing, int from); protected: - bool merge_old_entry(ObjectStore::Transaction& t, pg_log_entry_t& oe, - pg_info_t& info, list& remove_snap, bool &dirty_log); + bool merge_old_entry(ObjectStore::Transaction& t, const pg_log_entry_t& oe, + const pg_info_t& info, list& remove_snap, bool &dirty_log); public: void rewind_divergent_log(ObjectStore::Transaction& t, eversion_t newhead, pg_info_t &info, list& remove_snap, -- 2.47.3