]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: properly set CLIENTWRITEABLE flag for imported caps
authorYan, Zheng <zyan@redhat.com>
Fri, 10 Jul 2020 08:43:14 +0000 (16:43 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 25 Aug 2020 00:39:55 +0000 (08:39 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/Locker.cc
src/mds/Migrator.cc

index e2d30f1d514b7971d6312a9d5e1e20b7512446cd..dc41004a67d23eb6820ae03c63a7cc96fb28d8c9 100644 (file)
@@ -5416,6 +5416,9 @@ void Locker::file_eval(ScatterLock *lock, bool *need_issue)
            << " on " << *lock->get_parent() << dendl;
     simple_sync(lock, need_issue);
   }
+  else if (in->state_test(CInode::STATE_NEEDSRECOVER)) {
+    mds->mdcache->queue_file_recover(in);
+  }
 }
 
 
index 7c51d956be732750c2eca0f37914c9bca617f2b4..6703cba1b187b6a3a2080196e242b79901b56cb7 100644 (file)
@@ -2868,6 +2868,8 @@ void Migrator::import_reverse(CDir *dir)
 
        in->clear_dirty_parent();
 
+       in->state_clear(CInode::STATE_NEEDSRECOVER);
+
        in->authlock.clear_gather();
        in->linklock.clear_gather();
        in->dirfragtreelock.clear_gather();
@@ -2906,6 +2908,8 @@ void Migrator::import_reverse(CDir *dir)
        }
        if (cap->is_importing())
          in->remove_client_cap(q->first);
+       else
+         cap->clear_clientwriteable();
       }
       in->put(CInode::PIN_IMPORTINGCAPS);
     }
@@ -3278,6 +3282,10 @@ void Migrator::finish_import_inode_caps(CInode *in, mds_rank_t peer, bool auth_c
                                        const map<client_t,Capability::Export> &export_map,
                                        map<client_t,Capability::Import> &import_map)
 {
+  const auto& client_ranges = in->get_projected_inode()->client_ranges;
+  auto r = client_ranges.cbegin();
+  bool needs_recover = false;
+
   for (auto& it : export_map) {
     dout(10) << "for client." << it.first << " on " << *in << dendl;
 
@@ -3297,6 +3305,17 @@ void Migrator::finish_import_inode_caps(CInode *in, mds_rank_t peer, bool auth_c
        cap->mark_importing();
     }
 
+    if (auth_cap) {
+      while (r != client_ranges.cend() && r->first < it.first) {
+       needs_recover = true;
+       ++r;
+      }
+      if (r != client_ranges.cend() && r->first == it.first) {
+       cap->mark_clientwriteable();
+       ++r;
+      }
+    }
+
     // Always ask exporter mds to send cap export messages for auth caps.
     // For non-auth caps, ask exporter mds to send cap export messages to
     // clients who haven't opened sessions. The cap export messages will
@@ -3316,6 +3335,13 @@ void Migrator::finish_import_inode_caps(CInode *in, mds_rank_t peer, bool auth_c
     }
   }
 
+  if (auth_cap) {
+    if (r != client_ranges.cend())
+      needs_recover = true;
+    if (needs_recover)
+      in->state_set(CInode::STATE_NEEDSRECOVER);
+  }
+
   if (peer >= 0) {
     in->replica_caps_wanted = 0;
     in->put(CInode::PIN_IMPORTINGCAPS);