]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: hide stray dentries and inodes that are purging
authorSage Weil <sage@newdream.net>
Tue, 14 Apr 2009 13:48:51 +0000 (06:48 -0700)
committerSage Weil <sage@newdream.net>
Tue, 14 Apr 2009 13:48:51 +0000 (06:48 -0700)
Otherwise we get unwanted references when the inode is supposed to
die.

src/mds/CInode.h
src/mds/MDCache.cc
src/mds/Server.cc

index 6e2f0a4d27b30d5f0adf01c3f9f608896115912a..c7594301c1aba637bfef525c20dcaca8ae6cf206 100644 (file)
@@ -112,6 +112,7 @@ class CInode : public MDSCacheObject {
   static const int STATE_NEEDSRECOVER = (1<<11);
   static const int STATE_RECOVERING =   (1<<12);
   static const int STATE_NO_SIZE_CHECK = (1<<13);
+  static const int STATE_PURGING =     (1<<14);
 
   // -- waiters --
   static const __u64 WAIT_DIR         = (1<<0);
index 7adf5cf8e4e0de007e4efcf7f5bde96804f6a4ae..8aa3be98a6ad746b3dbda4ebe3b01f087fb00b95 100644 (file)
@@ -5538,6 +5538,8 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req,     // who
     }
     return 1;
   }
+  if (cur->state_test(CInode::STATE_PURGING))
+    return -ESTALE;
 
   // start trace
   if (pdnvec)
@@ -6753,6 +6755,7 @@ void MDCache::purge_stray(CDentry *dn)
 
   dn->state_set(CDentry::STATE_PURGING);
   dn->get(CDentry::PIN_PURGING);
+  in->state_set(CInode::STATE_PURGING);
 
   
   // CHEAT.  there's no real need to journal our intent to purge, since
index 600f3d22e647af703de70b98cadba114eecff646..eb5f3e7bf7a447fa8a220a088be7631f437a3895 100644 (file)
@@ -413,6 +413,8 @@ void Server::handle_client_reconnect(MClientReconnect *m)
         p != m->realms.end();
         p++) {
       CInode *in = mdcache->get_inode(inodeno_t(p->ino));
+      if (in && in->state_test(CInode::STATE_PURGING))
+       continue;
       if (in) {
        assert(in->snaprealm);
        if (in->snaprealm->have_past_parents_open()) {
@@ -438,6 +440,8 @@ void Server::handle_client_reconnect(MClientReconnect *m)
        mdcache->last_cap_id = p->second.capinfo.cap_id;
 
       CInode *in = mdcache->get_inode(p->first);
+      if (in && in->state_test(CInode::STATE_PURGING))
+       continue;
       if (in && in->is_auth()) {
        // we recovered it, and it's ours.  take note.
        dout(15) << "open cap realm " << inodeno_t(p->second.capinfo.snaprealm)
@@ -1697,10 +1701,14 @@ void Server::handle_client_lookup_hash(MDRequest *mdr)
   MClientRequest *req = mdr->client_request;
 
   CInode *in = mdcache->get_inode(req->get_filepath().get_ino());
+  if (in && in->state_test(CInode::STATE_PURGING)) {
+    reply_request(mdr, -ESTALE);
+    return;
+  }
   if (!in) {
     // try the directory
     CInode *diri = mdcache->get_inode(req->get_filepath2().get_ino());
-    if (!diri) {
+    if (!diri || diri->state_test(CInode::STATE_PURGING)) {
       reply_request(mdr, -ESTALE);
       return;
     }
@@ -2066,6 +2074,9 @@ void Server::handle_client_readdir(MDRequest *mdr)
     if (offset && strcmp(dn->get_name().c_str(), offset) <= 0)
       continue;
 
+    if (dn->state_test(CDentry::STATE_PURGING))
+      continue;
+
     bool dnp = dn->use_projected(client, mdr);
     CDentry::linkage_t *dnl = dnp ? dn->get_projected_linkage() : dn->get_linkage();
 
@@ -4884,7 +4895,7 @@ void Server::handle_client_lssnap(MDRequest *mdr)
 
   // traverse to path
   CInode *diri = mdcache->get_inode(req->get_filepath().get_ino());
-  if (!diri) {
+  if (!diri || diri->state_test(CInode::STATE_PURGING)) {
      reply_request(mdr, -ESTALE);
      return;
   }
@@ -4965,7 +4976,7 @@ void Server::handle_client_mksnap(MDRequest *mdr)
   MClientRequest *req = mdr->client_request;
 
   CInode *diri = mdcache->get_inode(req->get_filepath().get_ino());
-  if (!diri) {
+  if (!diri || diri->state_test(CInode::STATE_PURGING)) {
     reply_request(mdr, -ESTALE);
     return;
   }
@@ -5133,7 +5144,7 @@ void Server::handle_client_rmsnap(MDRequest *mdr)
   MClientRequest *req = mdr->client_request;
 
   CInode *diri = mdcache->get_inode(req->get_filepath().get_ino());
-  if (!diri) {
+  if (!diri || diri->state_test(CInode::STATE_PURGING)) {
     reply_request(mdr, -ESTALE);
     return;
   }