]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: flush the mdlog in unsafe requests' relevant and auth MDSes only 42925/head
authorXiubo Li <xiubli@redhat.com>
Fri, 2 Jul 2021 00:49:51 +0000 (08:49 +0800)
committerXiubo Li <xiubli@redhat.com>
Mon, 30 Aug 2021 14:28:35 +0000 (22:28 +0800)
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 <xiubli@redhat.com>
(cherry picked from commit 0fc091f361e8f091557383bde6709911d1f80242)

src/client/Client.cc
src/client/Client.h

index 7d052bad879d590ef52a64b787ee6f8a4ee15314..52d8ce38672763ad3587efe730b5d1cdb22e57a6 100644 (file)
@@ -6313,9 +6313,29 @@ void Client::_close_sessions()
   }
 }
 
+void Client::flush_mdlog_sync(Inode *in)
+{
+  if (in->unsafe_ops.empty()) {
+    return;
+  }
+
+  std::set<mds_rank_t> 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;
index 88e8f4429a6d4d6ddbe245f1e0391e2cc868bdab..aa6ef0653c5b1b5c40a9ecbae453d6d400a7966b 100644 (file)
@@ -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);