]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client:make sure only to update dir dist from auth mds 42937/head
authorjhonxue <jhonxue@tencent.com>
Tue, 27 Jul 2021 04:18:20 +0000 (12:18 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 26 Aug 2021 16:28:29 +0000 (12:28 -0400)
Fixes: https://tracker.ceph.com/issues/51857
Signed-off-by: Xue Yantao <xueyantao2114@163.com>
(cherry picked from commit 1cafa0868797d67583031de63c10150a87fd05a4)

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

index 7d052bad879d590ef52a64b787ee6f8a4ee15314..5400400598c1b4b3c6b6c9a3553bff7d79dd811d 100644 (file)
@@ -1123,7 +1123,7 @@ void Client::update_dentry_lease(Dentry *dn, LeaseStat *dlease, utime_t from, Me
 /*
  * update MDS location cache for a single inode
  */
-void Client::update_dir_dist(Inode *in, DirStat *dst)
+void Client::update_dir_dist(Inode *in, DirStat *dst, mds_rank_t from)
 {
   // auth
   ldout(cct, 20) << "got dirfrag map for " << in->ino << " frag " << dst->frag << " to mds " << dst->auth << dendl;
@@ -1137,12 +1137,14 @@ void Client::update_dir_dist(Inode *in, DirStat *dst)
     _fragmap_remove_non_leaves(in);
   }
 
-  // replicated
-  in->dir_replicated = !dst->dist.empty();
-  if (!dst->dist.empty())
-    in->frag_repmap[dst->frag].assign(dst->dist.begin(), dst->dist.end()) ;
-  else
-    in->frag_repmap.erase(dst->frag);
+  // replicated, only update from auth mds reply
+  if (from == dst->auth) {
+    in->dir_replicated = !dst->dist.empty();
+    if (!dst->dist.empty())
+      in->frag_repmap[dst->frag].assign(dst->dist.begin(), dst->dist.end()) ;
+    else
+      in->frag_repmap.erase(dst->frag);
+  }
 }
 
 void Client::clear_dir_complete_and_ordered(Inode *diri, bool complete)
@@ -1432,7 +1434,8 @@ Inode* Client::insert_trace(MetaRequest *request, MetaSession *session)
   if (reply->head.is_dentry) {
     diri = add_update_inode(&dirst, request->sent_stamp, session,
                            request->perms);
-    update_dir_dist(diri, &dst);  // dir stat info is attached to ..
+    mds_rank_t from_mds = mds_rank_t(reply->get_source().num());
+    update_dir_dist(diri, &dst, from_mds);  // dir stat info is attached to ..
 
     if (in) {
       Dir *dir = diri->open_dir();
index 88e8f4429a6d4d6ddbe245f1e0391e2cc868bdab..f24301f0b2aaf87a615fd22a454c77408564426f 100644 (file)
@@ -776,7 +776,7 @@ public:
   void unlock_fh_pos(Fh *f);
 
   // metadata cache
-  void update_dir_dist(Inode *in, DirStat *st);
+  void update_dir_dist(Inode *in, DirStat *st, mds_rank_t from);
 
   void clear_dir_complete_and_ordered(Inode *diri, bool complete);
   void insert_readdir_results(MetaRequest *request, MetaSession *session, Inode *diri);