From c7f4a6a0477b560aab330167480c91a343c4466c Mon Sep 17 00:00:00 2001 From: sageweil Date: Wed, 1 Aug 2007 20:53:18 +0000 Subject: [PATCH] prelim dn dir_offset work git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1588 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/mds/CDentry.h | 15 ++++++++++++++- branches/sage/mds/mds/CDir.cc | 16 ++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/branches/sage/mds/mds/CDentry.h b/branches/sage/mds/mds/CDentry.h index dff8a0cbaf2cc..d120a1a07ec9f 100644 --- a/branches/sage/mds/mds/CDentry.h +++ b/branches/sage/mds/mds/CDentry.h @@ -83,6 +83,8 @@ class CDentry : public MDSCacheObject, public LRUObject { version_t version; // dir version when last touched. version_t projected_version; // what it will be when i unlock/commit. + off_t dir_offset; + int auth_pins, nested_auth_pins; friend class Migrator; @@ -107,6 +109,7 @@ public: remote_ino(0), remote_d_type(0), inode(0), dir(0), version(0), projected_version(0), + dir_offset(0), auth_pins(0), nested_auth_pins(0), lock(this, LOCK_OTYPE_DN, WAIT_LOCK_OFFSET) { } CDentry(const string& n, CInode *in) : @@ -114,6 +117,7 @@ public: remote_ino(0), remote_d_type(0), inode(in), dir(0), version(0), projected_version(0), + dir_offset(0), auth_pins(0), nested_auth_pins(0), lock(this, LOCK_OTYPE_DN, WAIT_LOCK_OFFSET) { } CDentry(const string& n, inodeno_t ino, unsigned char dt, CInode *in=0) : @@ -121,6 +125,7 @@ public: remote_ino(ino), remote_d_type(dt), inode(in), dir(0), version(0), projected_version(0), + dir_offset(0), auth_pins(0), nested_auth_pins(0), lock(this, LOCK_OTYPE_DN, WAIT_LOCK_OFFSET) { } @@ -129,6 +134,10 @@ public: const string& get_name() const { return name; } inodeno_t get_ino(); + off_t get_dir_offset() { return dir_offset; } + void set_dir_offset(off_t o) { dir_offset = o; } + void clear_dir_offset() { dir_offset = 0; } + inodeno_t get_remote_ino() { return remote_ino; } unsigned char get_remote_d_type() { return remote_d_type; } void set_remote(inodeno_t ino, unsigned char d_type) { @@ -255,7 +264,7 @@ class CDentryDiscover { string dname; int replica_nonce; int lockstate; - + off_t dir_offset; inodeno_t remote_ino; unsigned char remote_d_type; @@ -264,6 +273,7 @@ public: CDentryDiscover(CDentry *dn, int nonce) : dname(dn->get_name()), replica_nonce(nonce), lockstate(dn->lock.get_replica_state()), + dir_offset(dn->get_dir_offset()), remote_ino(dn->get_remote_ino()), remote_d_type(dn->get_remote_d_type()) { } string& get_dname() { return dname; } @@ -273,6 +283,7 @@ public: unsigned char get_remote_d_type() { return remote_d_type; } void update_dentry(CDentry *dn) { + dn->set_dir_offset(dir_offset); dn->set_replica_nonce(replica_nonce); } void init_dentry_lock(CDentry *dn) { @@ -281,6 +292,7 @@ public: void _encode(bufferlist& bl) { ::_encode(dname, bl); + ::_encode(dir_offset, bl); ::_encode(remote_ino, bl); ::_encode(remote_d_type, bl); ::_encode(replica_nonce, bl); @@ -289,6 +301,7 @@ public: void _decode(bufferlist& bl, int& off) { ::_decode(dname, bl, off); + ::_decode(dir_offset, bl, off); ::_decode(remote_ino, bl, off); ::_decode(remote_d_type, bl, off); ::_decode(replica_nonce, bl, off); diff --git a/branches/sage/mds/mds/CDir.cc b/branches/sage/mds/mds/CDir.cc index db4b57ed33f8b..89480467f20ce 100644 --- a/branches/sage/mds/mds/CDir.cc +++ b/branches/sage/mds/mds/CDir.cc @@ -288,6 +288,7 @@ void CDir::link_remote_inode(CDentry *dn, inodeno_t ino, unsigned char d_type) assert(dn->is_null()); dn->set_remote(ino, d_type); nitems++; + dn->clear_dir_offset(); //assert(null_items.count(dn->name) == 1); //null_items.erase(dn->name); @@ -301,6 +302,7 @@ void CDir::link_primary_inode(CDentry *dn, CInode *in) assert(!dn->is_remote()); link_inode_work(dn,in); + dn->clear_dir_offset(); // remove from null list //assert(null_items.count(dn->name) == 1); @@ -338,6 +340,7 @@ void CDir::unlink_inode( CDentry *dn ) dout(12) << "unlink_inode " << *dn << " " << *dn->inode << endl; } + dn->clear_dir_offset(); unlink_inode_work(dn); // add to null list @@ -381,7 +384,7 @@ void CDir::try_remove_unlinked_dn(CDentry *dn) void CDir::unlink_inode_work( CDentry *dn ) { CInode *in = dn->inode; - + if (dn->is_remote()) { // remote if (in) @@ -799,6 +802,8 @@ void CDir::_fetched(bufferlist &bl) << endl; while (off < len) { + off_t dn_offset = off; + // marker char type = bl[off]; ++off; @@ -825,7 +830,7 @@ void CDir::_fetched(bufferlist &bl) } } else { // (remote) link - CDentry *dn = add_remote_dentry(dname, ino, d_type); + dn = add_remote_dentry(dname, ino, d_type); // link to inode? CInode *in = cache->get_inode(ino); // we may or may not have it. @@ -882,8 +887,8 @@ void CDir::_fetched(bufferlist &bl) cache->add_inode( in ); // link - add_primary_dentry(dname, in); - dout(12) << "_fetched got " << *in << " mode " << in->inode.mode << " mtime " << in->inode.mtime << endl; + dn = add_primary_dentry(dname, in); + dout(12) << "_fetched got " << *dn << " " << *in << endl; } } } else { @@ -891,6 +896,9 @@ void CDir::_fetched(bufferlist &bl) << " at pos " << off << endl; assert(0); } + + // make note of dentry position in the directory + dn->dir_offset = dn_offset; /** clean underwater item? * Underwater item is something that is dirty in our cache from -- 2.39.5