From 56a852d7f8458459d1d59f7ed0ec68aafddf2941 Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 13 Sep 2007 04:03:45 +0000 Subject: [PATCH] client tweaks from destro replay git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1839 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/client/Client.cc | 17 ++++++++++++++++- trunk/ceph/client/Client.h | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/trunk/ceph/client/Client.cc b/trunk/ceph/client/Client.cc index dfae5e5ae3298..b4bd9a5bffc05 100644 --- a/trunk/ceph/client/Client.cc +++ b/trunk/ceph/client/Client.cc @@ -1486,6 +1486,7 @@ int Client::unmount() } } + //if (0) {// hack while (lru.lru_get_size() > 0 || !inode_map.empty()) { dout(2) << "cache still has " << lru.lru_get_size() @@ -1497,6 +1498,7 @@ int Client::unmount() } assert(lru.lru_get_size() == 0); assert(inode_map.empty()); + //} // unsafe writes if (!g_conf.client_oc) { @@ -1667,6 +1669,15 @@ int Client::_rename(const char *from, const char *to) MClientReply *reply = make_request(req); int res = reply->get_result(); + if (res == 0) { + // remove from local cache + filepath fp(to); + Dentry *dn = lookup(fp); + if (dn) { + assert(dn->inode); + unlink(dn); + } + } insert_trace(reply); delete reply; dout(10) << "rename result is " << res << dendl; @@ -3313,7 +3324,9 @@ int Client::ll_lookup(inodeno_t parent, const char *name, struct stat *attr) // get the inode if (diri->dir && diri->dir->dentries.count(dname)) { - in = diri->dir->dentries[dname]->inode; + Dentry *dn = diri->dir->dentries[dname]; + touch_dn(dn); + in = dn->inode; } else { string path; diri->make_path(path); @@ -3480,6 +3493,8 @@ int Client::ll_readlink(inodeno_t ino, const char **value) tout << ino.val << std::endl; Inode *in = _ll_get_inode(ino); + if (in->dn) touch_dn(in->dn); + int r = 0; if (in->inode.is_symlink()) { *value = in->symlink->c_str(); diff --git a/trunk/ceph/client/Client.h b/trunk/ceph/client/Client.h index 1671637105d0a..69da16b6e84d5 100644 --- a/trunk/ceph/client/Client.h +++ b/trunk/ceph/client/Client.h @@ -567,6 +567,7 @@ protected: // link to inode dn->inode = in; + assert(in->dn == 0); in->dn = dn; in->get(); @@ -578,6 +579,7 @@ protected: void unlink(Dentry *dn) { Inode *in = dn->inode; + assert(in->dn == dn); // unlink from inode if (dn->inode->dir) dn->put(); // dir -> dn pin @@ -602,9 +604,9 @@ protected: // newdn, attach to inode. don't touch inode ref. Dentry *newdn = new Dentry; + newdn->dir = dir; newdn->name = name; newdn->inode = in; - newdn->dir = dir; in->dn = newdn; if (in->dir) { // dir -> dn pin -- 2.39.5