max_events = g_conf().get_val<int64_t>("mds_log_max_events");
skip_corrupt_events = g_conf().get_val<bool>("mds_log_skip_corrupt_events");
skip_unbounded_events = g_conf().get_val<bool>("mds_log_skip_unbounded_events");
+ upkeep_thread = std::thread(&MDLog::log_trim_upkeep, this);
}
MDLog::~MDLog()
}
}
+ upkeep_log_trim_shutdown = true;
+ cond.notify_one();
+
+ mds->mds_lock.unlock();
+ upkeep_thread.join();
+ mds->mds_lock.lock();
+
// Replay thread can be stuck inside e.g. Journaler::wait_for_readable,
// so we need to shutdown the journaler first.
if (journaler) {
}
}
-void MDLog::trim(int m)
+void MDLog::log_trim_upkeep(void) {
+ dout(10) << dendl;
+
+ std::unique_lock mds_lock(mds->mds_lock);
+ while (!upkeep_log_trim_shutdown.load()) {
+ if (mds->is_active() || mds->is_stopping()) {
+ trim();
+ }
+
+ cond.wait_for(mds_lock, g_conf().get_val<std::chrono::milliseconds>("mds_log_trim_upkeep_interval"));
+ }
+ dout(10) << __func__ << ": finished" << dendl;
+}
+
+void MDLog::trim()
{
int max_ev = max_events;
- if (m >= 0)
- max_ev = m;
if (mds->mdcache->is_readonly()) {
dout(10) << "trim, ignoring read-only FS" << dendl;
void MDLog::try_expire(LogSegment *ls, int op_prio)
{
+ ceph_assert(ceph_mutex_is_locked(mds->mds_lock));
MDSGatherBuilder gather_bld(g_ceph_context);
ls->try_to_expire(mds, gather_bld, op_prio);
}
void trim_expired_segments();
- void trim(int max=-1);
int trim_all();
void create(MDSContext *onfinish); // fresh, empty log!
void _trim_expired_segments();
void write_head(MDSContext *onfinish);
+ void trim();
+ void log_trim_upkeep(void);
+
bool debug_subtrees;
std::atomic_uint64_t event_large_threshold; // accessed by submit thread
uint64_t events_per_segment;
// log trimming decay counter
DecayCounter log_trim_counter;
+
+ // log trimming upkeeper thread
+ std::thread upkeep_thread;
+ // guarded by mds_lock
+ std::condition_variable_any cond;
+ std::atomic<bool> upkeep_log_trim_shutdown{false};
};
#endif
// update average session uptime
sessionmap.update_average_session_age();
- if (is_active() || is_stopping()) {
- mdlog->trim(); // NOT during recovery!
- }
-
// ...
if (is_clientreplay() || is_active() || is_stopping()) {
server->clear_laggy_clients();
// shut down?
if (is_stopping()) {
- mdlog->trim();
if (mdcache->shutdown_pass()) {
uint64_t pq_progress = 0 ;
uint64_t pq_total = 0;