From 48e0d0b803d3314ab0fbc50d558502d894460ace Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 15 Jun 2021 11:25:31 +0800 Subject: [PATCH] mds: try to flush the mdlog when requesting the rdlock After client requests' early_reply() the mdlog won't be flushed immediately, but it will hold the write lock. So if the client sends another request to a different MDS daemon, which then needs to request read lock, then it maybe stuck at most for 5 seconds. Let's try to flush the mdlog which might release the write locks after mdlog is successfully flushed. Fixes: https://tracker.ceph.com/issues/51069 Signed-off-by: Xiubo Li (cherry picked from commit 63f7a165ec6bbf9cb1bded29f8bc5c017c01c768) --- src/mds/Locker.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index a2fbe76625ab..cab6051b2f4f 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -4624,6 +4624,17 @@ bool Locker::simple_sync(SimpleLock *lock, bool *need_issue) gather++; if (lock->is_cached()) invalidate_lock_caches(lock); + + // After a client request is early replied the mdlog won't be flushed + // immediately, but before safe replied the request will hold the write + // locks. So if the client sends another request to a different MDS + // daemon, which then needs to request read lock from current MDS daemon, + // then that daemon maybe stuck at most for 5 seconds. Which will lead + // the client stuck at most 5 seconds. + // + // Let's try to flush the mdlog when the write lock is held, which will + // release the write locks after mdlog is successfully flushed. + mds->mdlog->flush(); } if (lock->get_parent()->is_replicated() && old_state == LOCK_MIX) { -- 2.47.3