From: Sage Weil Date: Mon, 4 Mar 2013 23:47:06 +0000 (-0800) Subject: client: unlink old_dentry on traceless rename reply X-Git-Tag: v0.60~121^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=974dc84f6ee7af74cc3b43b1fad4d84a0169369c;p=ceph.git client: unlink old_dentry on traceless rename reply Signed-off-by: Sage Weil --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 2f6feb245f75..e03cd2c7edde 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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: