From a58b7b697f32b6da3d9414617a34bd9db349b24b Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Wed, 26 Apr 2017 01:12:04 -0700 Subject: [PATCH] osd/PG.cc: Optimistic estimation on PG.last_active PG may go through inactive state(such like peering) shortly during state transition, user usually want to only get alter just when PG is stucking in inactive for long enough time. Such monitoring depends on PG.last_active > cutoff, but we will not update PG.last_active if there is neither state change nor IO happened on this PG. As a result, PG.last_active may lag behind a long time, in idle cluster/pool. This patch update the last_active filed to now(), when we first find it as inactiv, as kind of optimistic estimation to solve the problem. Signed-off-by: Xiaoxi Chen --- src/osd/PG.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index f8c14131f6d..607fcd7883b 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2701,6 +2701,12 @@ void PG::publish_stats_to_osd() utime_t now = ceph_clock_now(); if (info.stats.state != state) { info.stats.last_change = now; + // Optimistic estimation, if we just find out an inactive PG, + // assumt it is active till now. + if (!(state & PG_STATE_ACTIVE) && + (info.stats.state & PG_STATE_ACTIVE)) + info.stats.last_active = now; + if ((state & PG_STATE_ACTIVE) && !(info.stats.state & PG_STATE_ACTIVE)) info.stats.last_became_active = now; -- 2.39.5