]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: trim pglog when pg is recovered
authorZhiqiang Wang <zhiqiang@xsky.com>
Wed, 4 Jan 2017 08:34:06 +0000 (16:34 +0800)
committerZhiqiang Wang <zhiqiang@xsky.com>
Fri, 13 Jan 2017 05:19:25 +0000 (13:19 +0800)
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 <zhiqiang@xsky.com>
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PrimaryLogPG.cc

index 0347b15117d991c19abbba8362cb812243381946..03e7d8f9756eb20d26e43c8e78b2cecaca030118 100644 (file)
@@ -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;
index 5d9e78bb83fb34b6793f876919138c9ce8e8d2fa..5b9903a7f90c0ec21d83ca459d43289ae620ea74 100644 (file)
@@ -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,
index 9c42f6da6e246b72047c848ea415964be5b5fa26..e150704cb6b9fd3eeb21ac3dd0d7a3370b5a9264 100644 (file)
@@ -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();
       }
     }