]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PrimaryLogPG: do not use approx_size() for log trimming 18338/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 17 Oct 2017 01:55:57 +0000 (09:55 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 17 Oct 2017 07:42:08 +0000 (15:42 +0800)
There might be holes on log versions, thus the approx_size()
should (almost) always overestimate the actual number of log entries.
As a result, we might be at the risk of accessing violation
while searching for the oldest log entry to keep in the log list later.

Fix the above problem by counting the precise number of current
log entries instead.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/PrimaryLogPG.cc

index 99a4230da78950aca6ca5d91d09fb4c67951be8a..6b68a4f552ff2ac02c30f769b991590fc417e977 100644 (file)
@@ -1539,10 +1539,11 @@ void PrimaryLogPG::calc_trim_to()
   eversion_t limit = MIN(
     min_last_complete_ondisk,
     pg_log.get_can_rollback_to());
+  size_t log_size = pg_log.get_log().log.size();
   if (limit != eversion_t() &&
       limit != pg_trim_to &&
-      pg_log.get_log().approx_size() > target) {
-    size_t num_to_trim = pg_log.get_log().approx_size() - target;
+      log_size > target) {
+    size_t num_to_trim = log_size - target;
     if (num_to_trim < cct->_conf->osd_pg_log_trim_min) {
       return;
     }