]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mds/Migrator.cc
update sources to v12.1.0
[ceph.git] / ceph / src / mds / Migrator.cc
index 67796cf5a214ecf4d85316fe06685d26629c9c6e..aafd89c2820c6ae66dbe8712eae9b28575a9a3d1 100644 (file)
@@ -755,11 +755,11 @@ void Migrator::get_export_lock_set(CDir *dir, set<SimpleLock*>& locks)
 }
 
 
-class C_M_ExportTargetWait : public MigratorContext {
+class C_M_ExportDirWait : public MigratorContext {
   MDRequestRef mdr;
   int count;
 public:
-  C_M_ExportTargetWait(Migrator *m, MDRequestRef mdr, int count)
+  C_M_ExportDirWait(Migrator *m, MDRequestRef mdr, int count)
    : MigratorContext(m), mdr(mdr), count(count) {}
   void finish(int r) override {
     mig->dispatch_export_dir(mdr, count);
@@ -781,6 +781,10 @@ void Migrator::export_dir(CDir *dir, mds_rank_t dest)
     dout(7) << "read-only FS, no exports for now" << dendl;
     return;
   }
+  if (!mds->mdsmap->is_active(dest)) {
+    dout(7) << "dest not active, no exports for now" << dendl;
+    return;
+  }
   if (mds->is_cluster_degraded()) {
     dout(7) << "cluster degraded, no exports for now" << dendl;
     return;
@@ -884,13 +888,13 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count)
       export_try_cancel(dir);
       return;
     }
-    mds->wait_for_mdsmap(mds->mdsmap->get_epoch(), new C_M_ExportTargetWait(this, mdr, count+1));
+    mds->wait_for_mdsmap(mds->mdsmap->get_epoch(), new C_M_ExportDirWait(this, mdr, count+1));
     return;
   }
 
   if (!dir->inode->get_parent_dn()) {
     dout(7) << "waiting for dir to become stable before export: " << *dir << dendl;
-    dir->add_waiter(CDir::WAIT_CREATED, new C_M_ExportTargetWait(this, mdr, 1));
+    dir->add_waiter(CDir::WAIT_CREATED, new C_M_ExportDirWait(this, mdr, 1));
     return;
   }
 
@@ -1498,13 +1502,6 @@ void Migrator::finish_export_inode(CInode *in, utime_t now, mds_rank_t peer,
   in->finish_export(now);
   
   finish_export_inode_caps(in, peer, peer_imported);
-
-  // *** other state too?
-
-  // move to end of LRU so we drop out of cache quickly!
-  if (in->get_parent_dn()) 
-    cache->lru.lru_bottouch(in->get_parent_dn());
-
 }
 
 uint64_t Migrator::encode_export_dir(bufferlist& exportbl,
@@ -1690,17 +1687,13 @@ void Migrator::handle_export_ack(MExportDirAck *m)
   set<CDir*> bounds;
   cache->get_subtree_bounds(dir, bounds);
 
-  // list us second, them first.
-  // this keeps authority().first in sync with subtree auth state in the journal.
-  cache->adjust_subtree_auth(dir, it->second.peer, mds->get_nodeid());
-
   // log completion. 
   //  include export bounds, to ensure they're in the journal.
-  EExport *le = new EExport(mds->mdlog, dir);
+  EExport *le = new EExport(mds->mdlog, dir, it->second.peer);;
   mds->mdlog->start_entry(le);
 
   le->metablob.add_dir_context(dir, EMetaBlob::TO_ROOT);
-  le->metablob.add_dir( dir, false );
+  le->metablob.add_dir(dir, false);
   for (set<CDir*>::iterator p = bounds.begin();
        p != bounds.end();
        ++p) {
@@ -1710,6 +1703,10 @@ void Migrator::handle_export_ack(MExportDirAck *m)
     le->metablob.add_dir(bound, false);
   }
 
+  // list us second, them first.
+  // this keeps authority().first in sync with subtree auth state in the journal.
+  cache->adjust_subtree_auth(dir, it->second.peer, mds->get_nodeid());
+
   // log export completion, then finish (unfreeze, trigger finish context, etc.)
   mds->mdlog->submit_entry(le, new C_MDS_ExportFinishLogged(this, dir));
   mds->mdlog->flush();
@@ -2165,6 +2162,7 @@ void Migrator::handle_export_prep(MExportDirPrep *m)
   if (!m->did_assim()) {
     assert(it != import_state.end());
     assert(it->second.state == IMPORT_DISCOVERED);
+    assert(it->second.peer == oldauth);
     diri = cache->get_inode(m->get_dirfrag().ino);
     assert(diri);
     bufferlist::iterator p = m->basedir.begin();
@@ -2179,6 +2177,7 @@ void Migrator::handle_export_prep(MExportDirPrep *m)
       return;
     }
     assert(it->second.state == IMPORT_PREPPING);
+    assert(it->second.peer == oldauth);
 
     dir = cache->get_dirfrag(m->get_dirfrag());
     assert(dir);
@@ -2371,27 +2370,29 @@ void Migrator::handle_export_dir(MExportDir *m)
   assert (g_conf->mds_kill_import_at != 5);
   CDir *dir = cache->get_dirfrag(m->dirfrag);
   assert(dir);
+
+  mds_rank_t oldauth = mds_rank_t(m->get_source().num());
+  dout(7) << "handle_export_dir importing " << *dir << " from " << oldauth << dendl;
+
+  assert(!dir->is_auth());
   
   map<dirfrag_t,import_state_t>::iterator it = import_state.find(m->dirfrag);
   assert(it != import_state.end());
   assert(it->second.state == IMPORT_PREPPED);
   assert(it->second.tid == m->get_tid());
+  assert(it->second.peer == oldauth);
 
   utime_t now = ceph_clock_now();
-  mds_rank_t oldauth = mds_rank_t(m->get_source().num());
-  dout(7) << "handle_export_dir importing " << *dir << " from " << oldauth << dendl;
-  assert(dir->is_auth() == false);
 
   if (!dir->get_inode()->dirfragtree.is_leaf(dir->get_frag()))
     dir->get_inode()->dirfragtree.force_to_leaf(g_ceph_context, dir->get_frag());
 
   cache->show_subtrees();
 
-  C_MDS_ImportDirLoggedStart *onlogged = new C_MDS_ImportDirLoggedStart(
-      this, dir, mds_rank_t(m->get_source().num()));
+  C_MDS_ImportDirLoggedStart *onlogged = new C_MDS_ImportDirLoggedStart(this, dir, oldauth);
 
   // start the journal entry
-  EImportStart *le = new EImportStart(mds->mdlog, dir->dirfrag(), m->bounds);
+  EImportStart *le = new EImportStart(mds->mdlog, dir->dirfrag(), m->bounds, oldauth);
   mds->mdlog->start_entry(le);
 
   le->metablob.add_dir_context(dir);