From: Greg Farnum Date: Mon, 21 Sep 2009 18:13:55 +0000 (-0700) Subject: uclient: changed link and insert_dentry_inode to behave with pre-built dentrys X-Git-Tag: v0.16~104 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=425dcc1dc5421dc8d2b94b8116689530953efda5;p=ceph.git uclient: changed link and insert_dentry_inode to behave with pre-built dentrys --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 3d9ad338eee3f..d632acafb9972 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -487,17 +487,21 @@ void Client::insert_dentry_inode(Dir *dir, const string& dname, LeaseStat *dleas << dendl; if (dn) { - if (dn->inode->vino() == in->vino()) { - touch_dn(dn); - dout(12) << " had dentry " << dname - << " with correct vino " << dn->inode->vino() - << dendl; + if (dn->inode) { + if (dn->inode->vino() == in->vino()) { + touch_dn(dn); + dout(12) << " had dentry " << dname + << " with correct vino " << dn->inode->vino() + << dendl; + } else { + dout(12) << " had dentry " << dname + << " with WRONG vino " << dn->inode->vino() + << dendl; + unlink(dn, true); + dn = NULL; + } } else { - dout(12) << " had dentry " << dname - << " with WRONG vino " << dn->inode->vino() - << dendl; - unlink(dn, true); - dn = NULL; + link(dir, dname, in, dn); } } @@ -969,7 +973,7 @@ void Client::encode_dentry_release(Dentry *dn, MClientRequest *req, */ void Client::encode_cap_releases(MetaRequest *req, int mds) { dout(20) << "encode_cap_releases enter (req: " - << req << ", mds: " << mds << dendl; + << req << ", mds: " << mds << ")" << dendl; if (req->inode_drop) encode_inode_release(req->inode, req->request, mds, req->inode_drop, diff --git a/src/client/Client.h b/src/client/Client.h index f0786c92d1d1c..2c8c3e7d27e3e 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -948,15 +948,20 @@ protected: /** * Don't call this with in==NULL, use get_or_create for that + * leave dn set to default NULL unless you're trying to add + * a new inode to a pre-created Dentry */ - Dentry* link(Dir *dir, const string& name, Inode *in) { - Dentry *dn = new Dentry; - dn->name = name; - - // link to dir - dn->dir = dir; - //cout << "link dir " << dir->parent_inode->ino << " '" << name << "' -> inode " << in->ino << endl; - dir->dentries[dn->name] = dn; + Dentry* link(Dir *dir, const string& name, Inode *in, Dentry *dn=NULL) { + if (!dn) { //create a new Dentry + dn = new Dentry; + dn->name = name; + + // link to dir + dn->dir = dir; + //cout << "link dir " << dir->parent_inode->ino << " '" << name << "' -> inode " << in->ino << endl; + dir->dentries[dn->name] = dn; + lru.lru_insert_mid(dn); // mid or top? + } if (in) { // link to inode dn->inode = in; @@ -967,7 +972,6 @@ protected: if (in->dir) dn->get(); // dir -> dn pin } - lru.lru_insert_mid(dn); // mid or top? return dn; }