]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: properly wake up scatter_nudge waiters after clearing scatter dirty
authorYan, Zheng <zyan@redhat.com>
Tue, 6 Dec 2016 14:52:32 +0000 (22:52 +0800)
committerYan, Zheng <zyan@redhat.com>
Fri, 9 Dec 2016 03:31:04 +0000 (11:31 +0800)
LogSegment::try_to_expire() calls Locker::scatter_nudge() for dirty
scatter locks. If lock's parent is non-auth, Locker::scatter_nudge()
waits on the stable bit of corresponding lock. There are some cases
that scatter locks get marked clean without involving lock state
transition. We need to wake up scatter_nudge waiters in these cases.

Also remove the code that clear dirty scatter locks after inode gets
imported. I can't see why we should do that.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/Migrator.cc
src/mds/Server.cc

index e4fd8ef5a8eef9937f56cbbfff2ff9c7a065a40b..306d9043384948b54fd0356c5c515f7859fd7b9c 100644 (file)
@@ -5055,6 +5055,9 @@ void Locker::handle_file_lock(ScatterLock *lock, MLock *m)
   case LOCK_AC_LOCKFLUSHED:
     (static_cast<ScatterLock *>(lock))->finish_flush();
     (static_cast<ScatterLock *>(lock))->clear_flushed();
+    // wake up scatter_nudge waiters
+    if (lock->is_stable())
+      lock->finish_waiters(SimpleLock::WAIT_STABLE);
     break;
     
   case LOCK_AC_MIX:
index 5b24edbdcb15f519e29960adba5e554d7480ab33..797dff718ffbf71b865a36d4a6bd42963b28c58b 100644 (file)
@@ -298,9 +298,7 @@ void MDCache::remove_inode(CInode *o)
   if (o->is_dirty_parent())
     o->clear_dirty_parent();
 
-  o->filelock.remove_dirty();
-  o->nestlock.remove_dirty();
-  o->dirfragtreelock.remove_dirty();
+  o->clear_scatter_dirty();
 
   o->item_open_file.remove_myself();
 
index 8bd3172f4b09b47732d252caf0c5be8468767bc2..64168a156400152682e90cacf6082100b0081157 100644 (file)
@@ -1831,11 +1831,6 @@ void Migrator::export_finish(CDir *dir)
   C_ContextsBase<MDSInternalContextBase, MDSInternalContextGather> *fin = new C_ContextsBase<MDSInternalContextBase, MDSInternalContextGather>(g_ceph_context);
   finish_export_dir(dir, ceph_clock_now(g_ceph_context), it->second.peer,
                    it->second.peer_imported, fin->contexts, &num_dentries);
-  dir->add_waiter(CDir::WAIT_UNFREEZE, fin);
-
-  // unfreeze
-  dout(7) << "export_finish unfreezing" << dendl;
-  dir->unfreeze_tree();
   
   // unpin bounds
   set<CDir*> bounds;
@@ -1855,8 +1850,17 @@ void Migrator::export_finish(CDir *dir)
 
   // no more auth subtree? clear scatter dirty
   if (!dir->get_inode()->is_auth() &&
-      !dir->get_inode()->has_subtree_root_dirfrag(mds->get_nodeid()))
+      !dir->get_inode()->has_subtree_root_dirfrag(mds->get_nodeid())) {
     dir->get_inode()->clear_scatter_dirty();
+    // wake up scatter_nudge waiters
+    dir->get_inode()->take_waiting(CInode::WAIT_ANY_MASK, fin->contexts);
+  }
+
+  dir->add_waiter(CDir::WAIT_UNFREEZE, fin);
+
+  // unfreeze
+  dout(7) << "export_finish unfreezing" << dendl;
+  dir->unfreeze_tree();
 
   // discard delayed expires
   cache->discard_delayed_expire(dir);
@@ -2389,9 +2393,13 @@ void Migrator::import_reverse(CDir *dir)
 
   cache->adjust_subtree_auth(dir, stat.peer);
 
+  C_ContextsBase<MDSInternalContextBase, MDSInternalContextGather> *fin = new C_ContextsBase<MDSInternalContextBase, MDSInternalContextGather>(g_ceph_context);
   if (!dir->get_inode()->is_auth() &&
-      !dir->get_inode()->has_subtree_root_dirfrag(mds->get_nodeid()))
+      !dir->get_inode()->has_subtree_root_dirfrag(mds->get_nodeid())) {
     dir->get_inode()->clear_scatter_dirty();
+    // wake up scatter_nudge waiters
+    dir->get_inode()->take_waiting(CInode::WAIT_ANY_MASK, fin->contexts);
+  }
 
   int num_dentries = 0;
   // adjust auth bits.
@@ -2427,8 +2435,10 @@ void Migrator::import_reverse(CDir *dir)
        if (in->is_dirty()) 
          in->mark_clean();
        in->clear_dirty_rstat();
-       if (!in->has_subtree_root_dirfrag(mds->get_nodeid()))
+       if (!in->has_subtree_root_dirfrag(mds->get_nodeid())) {
          in->clear_scatter_dirty();
+         in->take_waiting(CInode::WAIT_ANY_MASK, fin->contexts);
+       }
 
        in->clear_dirty_parent();
 
@@ -2452,6 +2462,8 @@ void Migrator::import_reverse(CDir *dir)
     }
   }
 
+  dir->add_waiter(CDir::WAIT_UNFREEZE, fin);
+
   if (stat.state == IMPORT_ACKING) {
     // remove imported caps
     for (map<CInode*,map<client_t,Capability::Export> >::iterator p = stat.peer_exports.begin();
@@ -2538,8 +2550,6 @@ void Migrator::import_reverse_unfreeze(CDir *dir)
   assert(dir);
   dout(7) << "import_reverse_unfreeze " << *dir << dendl;
   dir->unfreeze_tree();
-  list<MDSInternalContextBase*> ls;
-  mds->queue_waiters(ls);
   cache->discard_delayed_expire(dir);
   import_reverse_final(dir);
 }
@@ -2678,14 +2688,6 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last)
     return;
   }
 
-  // clear updated scatterlocks
-  /*
-  for (list<ScatterLock*>::iterator p = import_updated_scatterlocks[dir].begin();
-       p != import_updated_scatterlocks[dir].end();
-       ++p) 
-    (*p)->clear_updated();
-  */
-
   // remove pins
   set<CDir*> bounds;
   cache->get_subtree_bounds(dir, bounds);
index 40ae3b66dcfad35c21602ba46afcb755ac813bf8..bdfc58fd99b1927498660f29a6a8c6e44e6c646b 100644 (file)
@@ -6628,13 +6628,11 @@ version_t Server::_rename_prepare_import(MDRequestRef& mdr, CDentry *srcdn, buff
            mds->mdsmap->get_up_features());
   prepare_force_open_sessions(mdr->more()->imported_client_map, mdr->more()->sseq_map);
 
-  list<ScatterLock*> updated_scatterlocks;  // we clear_updated explicitly below
+  list<ScatterLock*> updated_scatterlocks;
   mdcache->migrator->decode_import_inode(srcdn, blp, 
                                         srcdn->authority().first,
                                         mdr->ls, 0,
                                         mdr->more()->cap_imports, updated_scatterlocks);
-  srcdnl->get_inode()->filelock.remove_dirty();  
-  srcdnl->get_inode()->nestlock.remove_dirty();  
 
   // hack: force back to !auth and clean, temporarily
   srcdnl->get_inode()->state_clear(CInode::STATE_AUTH);