From ab7ff0fcad9574ff1600c0888d83b7a53357464b Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Sat, 19 Jan 2019 20:40:11 -0800 Subject: [PATCH] mds: adapt drop cache for incremental trim Signed-off-by: Patrick Donnelly (cherry picked from commit b750b3bb25d3c0cbad7a24ad6c7fd215d1b16395) --- src/mds/MDSRank.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 2e392ce95ff37..d27251d6cf7ad 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -382,13 +382,20 @@ private: void trim_cache() { dout(20) << __func__ << dendl; - if (!mdcache->trim(UINT64_MAX)) { - cmd_err(f, "failed to trim cache"); - complete(-EINVAL); - return; + auto p = mdcache->trim(UINT64_MAX); + auto& throttled = p.first; + auto& count = p.second; + dout(10) << __func__ + << (throttled ? " (throttled)" : "") + << " trimmed " << count << " caps" << dendl; + if (throttled && count > 0) { + auto timer = new FunctionContext([this](int _) { + trim_cache(); + }); + mds->timer.add_event_after(1.0, timer); + } else { + cache_status(); } - - cache_status(); } void cache_status() { -- 2.39.5