]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: cdir fetch/commit versioned dentries
authorSage Weil <sage@newdream.net>
Wed, 9 Jul 2008 23:28:35 +0000 (16:28 -0700)
committerSage Weil <sage@newdream.net>
Wed, 9 Jul 2008 23:28:35 +0000 (16:28 -0700)
src/TODO
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/MDCache.h

index 3967b9e9e97b7b7984ed5d6cfc306bbf4cf0611f..de923208ba23bcd34bcace2892b1304a951648fd 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -234,6 +234,12 @@ todo
 - mds metadata versioning
   - (dir) inode versions..
 
+- cdir fetch/store versioned dentries
+- migrator import/export of versioned dentries, inodes... drop them on export...
+- emetablob.. journaling a versioned update..
+
+- path_traverse handling of .snapshot?
+
   primary file link -> old inode
   primary dir link -> multiversion inode
   remote link -> multiversion inode
index 8a973d4b87f0f752d00060bd60ca40f28e8b4af9..049945d18589cdc631b5ce5af5c506b6f40d448d 100644 (file)
@@ -121,9 +121,9 @@ public:
 
  public:
   // cons
-  CDentry(const nstring& n, CInode *in) :
+  CDentry(const nstring& n, CInode *in, snapid_t f=0, snapid_t l=CEPH_NOSNAP) :
     name(n),
-    first(0), last(CEPH_NOSNAP),
+    first(f), last(l),
     remote_ino(0), remote_d_type(0),
     inode(in), dir(0),
     version(0), projected_version(0),
@@ -131,9 +131,10 @@ public:
     dir_offset(0),
     auth_pins(0), nested_auth_pins(0), nested_anchors(0),
     lock(this, CEPH_LOCK_DN, WAIT_LOCK_OFFSET) { }
-  CDentry(const nstring& n, inodeno_t ino, unsigned char dt, CInode *in=0) :
+  CDentry(const nstring& n, inodeno_t ino, unsigned char dt, CInode *in=0,
+         snapid_t f=0, snapid_t l=CEPH_NOSNAP) :
     name(n),
-    first(0), last(CEPH_NOSNAP),
+    first(f), last(l),
     remote_ino(ino), remote_d_type(dt),
     inode(in), dir(0),
     version(0), projected_version(0),
index 573b14a604699117b700cfe298f1470f3be100f4..1dc2b872a6e58d7639de894c4abab59fbd541fc1 100644 (file)
@@ -189,13 +189,14 @@ CDir::CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth) :
  * linking fun
  */
 
-CDentry* CDir::add_null_dentry(const nstring& dname)
+CDentry* CDir::add_null_dentry(const nstring& dname,
+                              snapid_t first, snapid_t last)
 {
   // foreign
   assert(lookup(dname) == 0);
   
   // create dentry
-  CDentry* dn = new CDentry(dname, 0);
+  CDentry* dn = new CDentry(dname, NULL, first, last);
   if (is_auth()) 
     dn->state_set(CDentry::STATE_AUTH);
   cache->lru.lru_insert_mid(dn);
@@ -221,13 +222,14 @@ CDentry* CDir::add_null_dentry(const nstring& dname)
 }
 
 
-CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in) 
+CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in,
+                                 snapid_t first, snapid_t last) 
 {
   // primary
   assert(lookup(dname) == 0);
   
   // create dentry
-  CDentry* dn = new CDentry(dname, 0);
+  CDentry* dn = new CDentry(dname, NULL, first, last);
   if (is_auth()) 
     dn->state_set(CDentry::STATE_AUTH);
   cache->lru.lru_insert_mid(dn);
@@ -252,13 +254,14 @@ CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in)
   return dn;
 }
 
-CDentry* CDir::add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type) 
+CDentry* CDir::add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type,
+                                snapid_t first, snapid_t last) 
 {
   // foreign
   assert(lookup(dname) == 0);
   
   // create dentry
-  CDentry* dn = new CDentry(dname, ino, d_type);
+  CDentry* dn = new CDentry(dname, ino, d_type, NULL, first, last);
   if (is_auth()) 
     dn->state_set(CDentry::STATE_AUTH);
   cache->lru.lru_insert_mid(dn);
@@ -1003,9 +1006,14 @@ void CDir::_fetched(bufferlist &bl)
     // dname
     string dname;
     ::decode(dname, p);
-    dout(24) << "_fetched parsed marker '" << type << "' dname '" << dname << dendl;
+    snapid_t first, last;
+    ::decode(first, p);
+    ::decode(last, p);
+    dout(24) << "_fetched parsed marker '" << type << "' dname '" << dname
+            << " [" << first << "," << last << "]"
+            << dendl;
     
-    CDentry *dn = lookup(dname);  // existing dentry?
+    CDentry *dn = lookup(dname, first);  // existing dentry?
 
     if (type == 'L') {
       // hard link
@@ -1022,7 +1030,7 @@ void CDir::_fetched(bufferlist &bl)
         }
       } else {
        // (remote) link
-       dn = add_remote_dentry(dname, ino, d_type);
+       dn = add_remote_dentry(dname, ino, d_type, first, last);
        
        // link to inode?
        CInode *in = cache->get_inode(ino);   // we may or may not have it.
@@ -1063,8 +1071,8 @@ void CDir::_fetched(bufferlist &bl)
       } else {
        // add inode
        CInode *in = 0;
-       if (cache->have_inode(inode.ino)) {
-         in = cache->get_inode(inode.ino);
+       if (cache->have_inode(inode.ino, first)) {
+         in = cache->get_inode(inode.ino, first);
          dout(-12) << "_fetched  got (but i already had) " << *in 
                   << " mode " << in->inode.mode 
                   << " mtime " << in->inode.mtime << dendl;
@@ -1073,6 +1081,7 @@ void CDir::_fetched(bufferlist &bl)
          // inode
          in = new CInode(cache);
          in->inode = inode;
+         in->snapid = first;
          
          // symlink?
          if (in->is_symlink()) 
@@ -1086,7 +1095,7 @@ void CDir::_fetched(bufferlist &bl)
          cache->add_inode( in );
        
          // link
-         dn = add_primary_dentry(dname, in);
+         dn = add_primary_dentry(dname, in, first, last);
          dout(12) << "_fetched  got " << *dn << " " << *in << dendl;
 
          //in->hack_accessed = false;
@@ -1277,7 +1286,9 @@ void CDir::_commit(version_t want)
       
       // marker, name, ino
       bl.append( "L", 1 );         // remote link
-      ::encode(it->first, bl);
+      ::encode(dn->name, bl);
+      ::encode(dn->first, bl);
+      ::encode(dn->last, bl);
       ::encode(ino, bl);
       ::encode(d_type, bl);
     } else {
@@ -1289,7 +1300,9 @@ void CDir::_commit(version_t want)
   
       // marker, name, inode, [symlink string]
       bl.append( "I", 1 );         // inode
-      ::encode(it->first, bl);
+      ::encode(dn->name, bl);
+      ::encode(dn->first, bl);
+      ::encode(dn->last, bl);
       ::encode(in->inode, bl);
       
       if (in->is_symlink()) {
index ea59183eb5f8a3a738a0f264d23683479ac5ad3a..c34c0827e184f8c8055255108acc3163c3ee7bd6 100644 (file)
@@ -300,9 +300,12 @@ protected:
       return iter->second;
   }
 
-  CDentry* add_null_dentry(const nstring& dname);
-  CDentry* add_primary_dentry(const nstring& dname, CInode *in);
-  CDentry* add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type);
+  CDentry* add_null_dentry(const nstring& dname, 
+                          snapid_t first=0, snapid_t last=CEPH_NOSNAP);
+  CDentry* add_primary_dentry(const nstring& dname, CInode *in, 
+                             snapid_t first=0, snapid_t last=CEPH_NOSNAP);
+  CDentry* add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type, 
+                            snapid_t first=0, snapid_t last=CEPH_NOSNAP);
   void remove_dentry( CDentry *dn );         // delete dentry
   void link_remote_inode( CDentry *dn, inodeno_t ino, unsigned char d_type);
   void link_remote_inode( CDentry *dn, CInode *in );
index 655dca54c0259ba0522c27f2a29ac593ee67fe8c..82c4b30acf0378a1a4dec8db7db29c59b33de1c7 100644 (file)
@@ -653,9 +653,9 @@ public:
   bool did_shutdown_log_cap;
 
   // inode_map
-  bool have_inode( inodeno_t ino ) { return have_inode(vinodeno_t(ino, 0)); }
-  bool have_inode( vinodeno_t vino ) { return inode_map.count(vino) ? true:false; }
-  CInode* get_inode( inodeno_t ino, snapid_t s=0 ) {
+  bool have_inode(inodeno_t ino, snapid_t snap=0) { return have_inode(vinodeno_t(ino, snap)); }
+  bool have_inode(vinodeno_t vino) { return inode_map.count(vino) ? true:false; }
+  CInode* get_inode(inodeno_t ino, snapid_t s=0) {
     vinodeno_t vino(ino,s);
     if (have_inode(vino))
       return inode_map[vino];