From 207846f89fd7d83fc8ef12e99eb1f87a42be1f44 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 13 Feb 2017 12:01:40 +0000 Subject: [PATCH] mds: write_head when reading in PurgeQueue Previously write_head calls were only generated on the write side, so if you had a big queue and were just working through consuming it, you wouldn't record your progress, and on a daemon restart would end up repeating a load of work. Signed-off-by: John Spray --- src/mds/PurgeQueue.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/mds/PurgeQueue.cc b/src/mds/PurgeQueue.cc index 40ece7ecb5064..b8a59798ba07f 100644 --- a/src/mds/PurgeQueue.cc +++ b/src/mds/PurgeQueue.cc @@ -384,22 +384,38 @@ void PurgeQueue::execute_item_complete( if (iter == in_flight.begin()) { // This was the lowest journal position in flight, so we can now // safely expire the journal up to here. + dout(10) << "expiring to 0x" << std::hex << expire_to << std::dec << dendl; journaler.set_expire_pos(expire_to); - journaler.trim(); + } else { + // This is completely fine, we're not supposed to purge files in + // order when doing them in parallel. + dout(10) << "non-sequential completion, not expiring anything" << dendl; } - dout(10) << "completed item for ino 0x" << std::hex << iter->second.ino - << std::dec << dendl; - ops_in_flight -= _calculate_ops(iter->second); logger->set(l_pq_executing_ops, ops_in_flight); + dout(10) << "completed item for ino 0x" << std::hex << iter->second.ino + << std::dec << dendl; + in_flight.erase(iter); logger->set(l_pq_executing, in_flight.size()); + dout(10) << "in_flight.size() now " << in_flight.size() << dendl; logger->inc(l_pq_executed); _consume(); + + // Have we gone idle? If so, do an extra write_head now instead of + // waiting for next flush after journaler_write_head_interval. + // Also do this periodically even if not idle, so that the persisted + // expire_pos doesn't fall too far behind our progress when consuming + // a very long queue. + if (in_flight.empty() || journaler.write_head_needed()) { + journaler.write_head(new FunctionContext([this](int r){ + journaler.trim(); + })); + } } void PurgeQueue::update_op_limit(const MDSMap &mds_map) -- 2.39.5