]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
* destdn auth opens any dirfrags under srci
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Thu, 28 Jun 2007 05:14:29 +0000 (05:14 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Thu, 28 Jun 2007 05:14:29 +0000 (05:14 +0000)
* minor cleanup in path_traverse for dir discovers

git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1453 29311d96-e01e-0410-9327-a35deaab8ce9

branches/sage/cephmds2/mds/MDCache.cc
branches/sage/cephmds2/mds/Server.cc

index 548676dddb905938b88b7b71ab49444c55fa09b8..ce412fb734c43054380325db797a51a4027c346e 100644 (file)
@@ -725,7 +725,7 @@ void MDCache::adjust_subtree_after_rename(CInode *diri, CDir *olddir)
 {
   dout(10) << "adjust_subtree_after_rename " << *diri << " from " << *olddir << endl;
 
-  show_subtrees();
+  //show_subtrees();
 
   list<CDir*> dfls;
   diri->get_dirfrags(dfls);
@@ -3210,13 +3210,13 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req,     // who
       } else {
         // discover?
         assert(!cur->is_auth());
-        if (cur->is_waiter_for(CInode::WAIT_DIR)) {
-          dout(10) << "traverse: need dir, already doing discover for " << *cur << endl;
-        } 
-       else if (cur->is_ambiguous_auth()) {
+        if (cur->is_ambiguous_auth()) {
          dout(10) << "traverse: need dir, waiting for single auth on " << *cur << endl;
          cur->add_waiter(CInode::WAIT_SINGLEAUTH, _get_waiter(mdr, req));
          return 1;
+       } else if (dir_discovers.count(cur->ino())) {
+          dout(10) << "traverse: need dir, already doing discover for " << *cur << endl;
+         assert(cur->is_waiter_for(CInode::WAIT_DIR));
        } else {
          filepath want = path.postfixpath(depth);
          dout(10) << "traverse: need dir, doing discover, want " << want.get_path() 
@@ -3238,7 +3238,7 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req,     // who
     // frozen?
     /*
     if (curdir->is_frozen()) {
-      // doh!
+    // doh!
       // FIXME: traverse is allowed?
       dout(7) << "traverse: " << *curdir << " is frozen, waiting" << endl;
       curdir->add_waiter(CDir::WAIT_UNFREEZE, _get_waiter(mdr, req));
@@ -3248,9 +3248,9 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req,     // who
     */
 
     // must read directory hard data (permissions, x bit) to traverse
-    if (!noperm && !mds->locker->simple_rdlock_try(&cur->authlock, _get_waiter(mdr, req))) {
+    if (!noperm && 
+       !mds->locker->simple_rdlock_try(&cur->authlock, _get_waiter(mdr, req))) 
       return 1;
-    }
     
     // check permissions?
     // XXX
@@ -4497,8 +4497,11 @@ void MDCache::handle_discover_reply(MDiscoverReply *m)
     dis->set_base_dir_frag(fg);    
     mds->send_message_mds(dis, hint, MDS_PORT_CACHE);
     
-    // note the dangling discover
-    dir_discovers[cur->ino()].insert(hint);
+    // note the dangling discover... but only if it's already noted in dir_discovers (i.e. someone is waiting)
+    if (dir_discovers.count(cur->ino())) {
+      dir_discovers[cur->ino()].insert(hint);
+      assert(cur->is_waiter_for(CInode::WAIT_DIR));
+    }
   }
   else if (m->is_flag_error_dir()) {
     // dir error at the end there?
index 053034f844de92935bb7099697e98a90363d7cd9..468b49ff63a12ad40091fc89c06beb32d266c6bd 100644 (file)
@@ -2757,6 +2757,28 @@ void Server::handle_client_rename(MDRequest *mdr)
   // set done_locking flag, to avoid problems with wrlock moving auth target
   mdr->done_locking = true;
 
+  // -- open all srcdn inode frags, if any --
+  // we need these open so that auth can properly delegate from inode to dirfrags
+  // after the inode is _ours_.
+  if (srcdn->is_primary() && 
+      !srcdn->is_auth() && 
+      srci->is_dir()) {
+    dout(10) << "srci is remote dir, opening all frags" << endl;
+    list<frag_t> frags;
+    srci->dirfragtree.get_leaves(frags);
+    for (list<frag_t>::iterator p = frags.begin();
+        p != frags.end();
+        ++p) {
+      CDir *dir = srci->get_dirfrag(*p);
+      if (dir) {
+       dout(10) << " opened " << *dir << endl;
+       mdr->pin(dir);
+      } else {
+       mdcache->open_remote_dir(srci, *p, new C_MDS_RetryRequest(mdcache, mdr));
+       return;
+      }
+    }
+  }
 
   // -- declare now --
   if (mdr->now == utime_t())
@@ -2796,6 +2818,7 @@ void Server::handle_client_rename(MDRequest *mdr)
        indis->_encode(req->stray);
        dirdis->_encode(req->stray);
        dndis->_encode(req->stray);
+       delete indis;
        delete dirdis;
        delete dndis;
       }
@@ -3164,6 +3187,7 @@ void Server::handle_slave_rename_prep(MDRequest *mdr)
   CDentry *destdn = trace[trace.size()-1];
   dout(10) << " destdn " << *destdn << endl;
   mdr->pin(destdn);
+  
       
   // discover srcdn
   filepath srcpath(mdr->slave_request->srcdnpath);