From: Zhiqiang Wang Date: Wed, 4 Jan 2017 08:34:06 +0000 (+0800) Subject: osd: trim pglog when pg is recovered X-Git-Tag: v12.0.3~128^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=900e9a8de1f460f76c151ede3548b0728cd4d707;p=ceph.git osd: trim pglog when pg is recovered In the current code, primary initiates pglog trim or peers inform primary to trim when finishing recovery of the last object on it. However, the pg is still in degraded/recovering/backfilling state at that time and then the max log entries are kept. If there are no IOs on this pg, it will hold up to the max number of log entries in the memory, even if it's totally recovered. Signed-off-by: Zhiqiang Wang --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 0347b15117d..03e7d8f9756 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8135,10 +8135,8 @@ void OSD::handle_pg_trim(OpRequestRef op) dout(10) << *pg << " replica osd." << from << " lcod " << m->trim_to << dendl; pg->peer_last_complete_ondisk[pg_shard_t(from, m->pgid.shard)] = m->trim_to; - if (pg->calc_min_last_complete_ondisk()) { - dout(10) << *pg << " min lcod now " << pg->min_last_complete_ondisk << dendl; - pg->trim_peers(); - } + // trim log when the pg is recovered + pg->calc_min_last_complete_ondisk(); } else { // primary is instructing us to trim ObjectStore::Transaction t; diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 5d9e78bb83f..5b9903a7f90 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -6554,6 +6554,9 @@ PG::RecoveryState::Recovered::Recovered(my_context ctx) pg->publish_stats_to_osd(); } + // trim pglog on recovered + pg->trim_log(); + // adjust acting set? (e.g. because backfill completed...) bool history_les_bound = false; if (pg->acting != pg->up && !pg->choose_acting(auth_log_shard, diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 9c42f6da6e2..e150704cb6b 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -9636,9 +9636,7 @@ void PrimaryLogPG::_committed_pushed_object( last_complete_ondisk), get_osdmap()->get_epoch()); } else { - // we are the primary. tell replicas to trim? - if (calc_min_last_complete_ondisk()) - trim_peers(); + calc_min_last_complete_ondisk(); } }