]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: unlink old_dentry on traceless rename reply
authorSage Weil <sage@inktank.com>
Mon, 4 Mar 2013 23:47:06 +0000 (15:47 -0800)
committerSage Weil <sage@inktank.com>
Fri, 8 Mar 2013 00:42:44 +0000 (16:42 -0800)
Signed-off-by: Sage Weil <sage@inktank.com>
src/client/Client.cc

index 2f6feb245f7585905bb58c68609124d871f4027d..e03cd2c7edde0a553d1a2265669da2fa4db89aa2 100644 (file)
@@ -1225,7 +1225,7 @@ int Client::make_request(MetaRequest *request,
          request->resend_mds = mdsmap->get_random_up_mds();
          continue;
        }
-      }        
+      }
       
       if (waiting_for_session.count(mds) == 0) {
        ldout(cct, 10) << "opening session to mds." << mds << dendl;
@@ -1292,15 +1292,22 @@ int Client::make_request(MetaRequest *request,
 
     if (request->target) {
       *ptarget = request->target;
+      ldout(cct, 20) << "make_request target is " << *request->target << dendl;
     } else {
       if (got_created_ino && (p = inode_map.find(vinodeno_t(created_ino, CEPH_NOSNAP))) != inode_map.end()) {
        (*ptarget) = p->second;
+       ldout(cct, 20) << "make_request created, target is " << **ptarget << dendl;
       } else {
        // we got a traceless reply, and need to look up what we just
        // created.  for now, do this by name.  someday, do this by the
        // ino... which we know!  FIXME.
        Inode *target = 0;  // ptarget may be NULL
        if (request->dentry) {
+         // rename is special: we handle old_dentry unlink explicitly in insert_dentry_inode(), so
+         // we need to compensate and do the same here.
+         if (request->old_dentry) {
+           unlink(request->old_dentry, false);
+         }
          ldout(cct, 10) << "make_request got traceless reply, looking up #"
                         << request->dentry->dir->parent_inode->ino << "/" << request->dentry->name
                         << " got_ino " << got_created_ino
@@ -7275,14 +7282,15 @@ int Client::_rename(Inode *fromdir, const char *fromname, Inode *todir, const ch
 
   req->inode = todir;
 
-  res = make_request(req, uid, gid);
+  Inode *target;
+  res = make_request(req, uid, gid, &target);
 
   ldout(cct, 10) << "rename result is " << res << dendl;
 
   // renamed item from our cache
 
   trim_cache();
-  ldout(cct, 3) << "rename(" << from << ", " << to << ") = " << res << dendl;
+  ldout(cct, 3) << "_rename(" << from << ", " << to << ") = " << res << dendl;
   return res;
 
  fail: