From 5f4b2170df536d2cc46086bbd0a4ff427bfa0f4c Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 11 Aug 2020 10:03:11 +0800 Subject: [PATCH] client: defer cancelling the timer event If there has to much data need to flush or the osd couldn't handle writting the data to disk and response on time, the client will be blacklisted by mds. Let's just defer cancelling the timer event just before closing the mds sessions. Fixes: https://tracker.ceph.com/issues/46905 Signed-off-by: Xiubo Li --- src/client/Client.cc | 25 ++++++++++++++----------- src/client/Client.h | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index a2c7dcc1ddb..2a96ea71eef 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6217,6 +6217,7 @@ void Client::_unmount(bool abort) deleg_timeout = 0; if (abort) { + mount_aborted = true; // Abort all mds sessions _abort_mds_sessions(-ENOTCONN); @@ -6234,13 +6235,6 @@ void Client::_unmount(bool abort) return mds_requests.empty(); }); - { - std::scoped_lock l(timer_lock); - if (tick_event) - timer.cancel_event(tick_event); - tick_event = 0; - } - cwd.reset(); // clean up any unclosed files @@ -6327,6 +6321,13 @@ void Client::_unmount(bool abort) traceout.close(); } + { + std::scoped_lock l(timer_lock); + if (tick_event) + timer.cancel_event(tick_event); + tick_event = 0; + } + _close_sessions(); mref_writer.update_state(CLIENT_UNMOUNTED); @@ -6401,7 +6402,7 @@ void Client::tick() } } - if (mdsmap->get_epoch()) { + if (!mount_aborted && mdsmap->get_epoch()) { // renew caps? utime_t el = now - last_cap_renew; if (el > mdsmap->get_session_timeout() / 3.0) @@ -6415,13 +6416,15 @@ void Client::tick() while (!p.end()) { Inode *in = *p; ++p; - if (in->hold_caps_until > now) + if (!mount_aborted && in->hold_caps_until > now) break; delayed_list.pop_front(); - check_caps(in, CHECK_CAPS_NODELAY); + if (!mount_aborted) + check_caps(in, CHECK_CAPS_NODELAY); } - collect_and_send_metrics(); + if (!mount_aborted) + collect_and_send_metrics(); trim_cache(true); diff --git a/src/client/Client.h b/src/client/Client.h index b1d9ba9f969..c1b4f57c1a4 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1367,6 +1367,7 @@ private: ceph::unordered_set opened_dirs; uint64_t fd_gen = 1; + bool mount_aborted = false; bool blocklisted = false; ceph::unordered_map inode_map; -- 2.47.3