From ba6196a8036f8e2d13e59c43ff91232b86ac2366 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 2 Jul 2021 08:49:51 +0800 Subject: [PATCH] client: flush the mdlog in unsafe requests' relevant and auth MDSes only Do not flush the mdlog in all the MDSes, which may make no sense for specific inode. Fixes: https://tracker.ceph.com/issues/51518 Signed-off-by: Xiubo Li (cherry picked from commit 0fc091f361e8f091557383bde6709911d1f80242) --- src/client/Client.cc | 24 ++++++++++++++++++++++-- src/client/Client.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 7d052bad879..52d8ce38672 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6313,9 +6313,29 @@ void Client::_close_sessions() } } +void Client::flush_mdlog_sync(Inode *in) +{ + if (in->unsafe_ops.empty()) { + return; + } + + std::set anchor; + for (auto &&p : in->unsafe_ops) { + anchor.emplace(p->mds); + } + if (in->auth_cap) { + anchor.emplace(in->auth_cap->session->mds_num); + } + + for (auto &rank : anchor) { + auto session = &mds_sessions.at(rank); + flush_mdlog(session); + } +} + void Client::flush_mdlog_sync() { - if (mds_requests.empty()) + if (mds_requests.empty()) return; for (auto &p : mds_sessions) { flush_mdlog(&p.second); @@ -10565,7 +10585,7 @@ int Client::_fsync(Inode *in, bool syncdataonly) } else ldout(cct, 10) << "no metadata needs to commit" << dendl; if (!syncdataonly && !in->unsafe_ops.empty()) { - flush_mdlog_sync(); + flush_mdlog_sync(in); MetaRequest *req = in->unsafe_ops.back(); ldout(cct, 15) << "waiting on unsafe requests, last tid " << req->get_tid() << dendl; diff --git a/src/client/Client.h b/src/client/Client.h index 88e8f4429a6..aa6ef0653c5 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -797,6 +797,7 @@ public: vinodeno_t map_faked_ino(ino_t ino); //notify the mds to flush the mdlog + void flush_mdlog_sync(Inode *in); void flush_mdlog_sync(); void flush_mdlog(MetaSession *session); -- 2.47.3