]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: flush the mdlog in unsafe requests' relevant and auth MDSes only 42173/head
authorXiubo Li <xiubli@redhat.com>
Fri, 2 Jul 2021 00:49:51 +0000 (08:49 +0800)
committerXiubo Li <xiubli@redhat.com>
Mon, 5 Jul 2021 01:55:55 +0000 (09:55 +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>
src/client/Client.cc
src/client/Client.h

index 3533f3d6f4b75a26e8548f7b6ff4ba826a0ae2fb..166fc1737e8988795f68f767b623bae96a87b5e1 100644 (file)
@@ -6282,9 +6282,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);
@@ -10536,7 +10556,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 5dc1565290973d7e9503729a77f465f7d9d64908..6e2e96528be11ce934e407aa17938989ce5938f9 100644 (file)
@@ -799,6 +799,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);