]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: adjust snaprealm parents in link helpers
authorSage Weil <sage@newdream.net>
Thu, 7 Aug 2008 14:42:07 +0000 (07:42 -0700)
committerSage Weil <sage@newdream.net>
Thu, 7 Aug 2008 14:42:07 +0000 (07:42 -0700)
src/TODO
src/mds/CDir.cc
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/journal.cc
src/mds/snap.cc
src/mds/snap.h

index 85ddb4eb2cc7e857a9bc184eac96513a701308a3..2b8b99ebd0d91803f7e25fd657aadad5e6253282 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -23,17 +23,6 @@ big items
 snaps on mds
 - cap release probably needs ack by mds.  or, mds needs to possibly initiate recovery on import?  no, release should pbly just be acked by mds... like it was way back when... bah!
 
-- client snap caps
-  - NO CAP STATE FOR SNAPPED INODES.  
-  - mds grants open access (yes/no), but there is no state, since there is no concurrency.
-    (mds doesn't grant access until filelock it is readable, i.e., snapped data has flushed)
-  - client _should_ only send FLUSHSNAP _after_ data is flushed.  this will require much more sophisticated barriers in the client's cache.
-  - reconnect should map caps into snaprealms, and include snaprealm state, such that those can be brought in sync w/ the mds.
-  - reconnect does _not_ need any per-cap snap-related info.
-
-- mds open within snapshot
-- client snap read
-
 - mds server ops
   - link rollback
   - rename rollback
@@ -43,14 +32,7 @@ snaps on mds
   - build snaprealm for any hardlinked file
   - include snaps for all (primary+remote) parents
 
-- does snap_follows in MClientFileCaps properly handle snap deletion?
-
 snaps on osd
-- clean up snap context packaging..
-  - seq, not just snap list
-  - keep newest object around on osd?
-  - hmm, can we eliminate the snap list for reads?
-  - fix cloning on unlinked file (where snaps=[], but head may have follows_snap attr)
 - figure out how to fix up rados logging
 - snap collections
 - garbage collection
index f665a9cd87f60f2dfefa1c539ab8fd9b970d0656..dbba58f2dfc0309c401e4efeaddc135d9537ca2b 100644 (file)
@@ -405,6 +405,10 @@ void CDir::link_inode_work( CDentry *dn, CInode *in)
 
   if (in->inode.anchored + in->nested_anchors)
     dn->adjust_nested_anchors(in->nested_anchors + in->inode.anchored);
+
+  // verify open snaprealm parent
+  if (in->snaprealm)
+    in->snaprealm->adjust_parent();
 }
 
 void CDir::unlink_inode( CDentry *dn )
index 9d2d9caaaf31ac3ec529557a389e6e2e5628f03a..2bb71a4976c4643e663ec11fd2f2633138cbc43d 100644 (file)
@@ -825,12 +825,6 @@ void MDCache::adjust_subtree_after_rename(CInode *diri, CDir *olddir)
 {
   dout(10) << "adjust_subtree_after_rename " << *diri << " from " << *olddir << dendl;
 
-  // fix up snaprealms
-  assert(diri->snaprealm);
-  SnapRealm *newparent = diri->parent->dir->inode->find_snaprealm();
-  if (newparent != diri->snaprealm->parent)
-    diri->snaprealm->change_open_parent_to(newparent);
-
   //show_subtrees();
 
   // adjust subtree
@@ -959,6 +953,7 @@ int MDCache::num_subtrees_fullnonauth()
 // ===================================
 // journal and snap/cow helpers
 
+
 /*
  * find first inode in cache that follows given snapid.  otherwise, return current.
  */
@@ -1067,8 +1062,10 @@ void MDCache::journal_cow_dentry(Mutation *mut, EMetaBlob *metablob, CDentry *dn
       follows = in->find_snaprealm()->get_newest_snap();
 
     // already cloned?
-    if (follows < in->first)
+    if (follows < in->first) {
+      dout(10) << "journal_cow_dentry follows " << follows << " < first on " << *in << dendl;
       return;
+    }
 
     in->cow_old_inode(follows, in->get_previous_projected_inode());
 
@@ -1088,8 +1085,10 @@ void MDCache::journal_cow_dentry(Mutation *mut, EMetaBlob *metablob, CDentry *dn
       follows = dn->dir->inode->find_snaprealm()->get_newest_snap();
     
     // already cloned?
-    if (follows < dn->first)
+    if (follows < dn->first) {
+      dout(10) << "journal_cow_dentry follows " << follows << " < first on " << *dn << dendl;
       return;
+    }
        
     // update dn.first before adding old dentry to cdir's map
     snapid_t oldfirst = dn->first;
index da146020fe8fed48ebf79b1fab4adcd819ae31b0..d37da220b91e8dcf846c0eef04e075491ec1268b 100644 (file)
@@ -508,7 +508,7 @@ public:
   void request_drop_locks(MDRequest *r);
   void request_cleanup(MDRequest *r);
 
-  // journal helpers
+  // journal/snap helpers
   CInode *pick_inode_snap(CInode *in, snapid_t follows);
   CInode *cow_inode(CInode *in, snapid_t last);
   void journal_cow_dentry(Mutation *mut, EMetaBlob *metablob, CDentry *dn, snapid_t follows=CEPH_NOSNAP);
index 6cf82b7227068bae344fe017d7fba0858967af44..e2640c28880ba7387f6ef248375d5d897af2347e 100644 (file)
@@ -372,7 +372,6 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
        assert(dn->last == p->dnlast);
       }
 
-      bool do_snap_split = false;
       CInode *in = mds->mdcache->get_inode(p->inode.ino, p->dnlast);
       if (!in) {
        in = new CInode(mds->mdcache, true, p->dnfirst, p->dnlast);
@@ -380,9 +379,12 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
        in->xattrs = p->xattrs;
        if (in->inode.is_dir()) {
          in->dirfragtree = p->dirfragtree;
-         in->decode_snap_blob(p->snapbl);
-         if (in->snaprealm)
-           do_snap_split = true;
+         /*
+          * we can do this before linking hte inode bc the split_at would
+          * be a no-op.. we have no children (namely open snaprealms) to
+          * divy up 
+          */
+         in->decode_snap_blob(p->snapbl);  
        }
        if (in->inode.is_symlink()) in->symlink = p->symlink;
        mds->mdcache->add_inode(in);
@@ -409,10 +411,7 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
        in->xattrs = p->xattrs;
        if (in->inode.is_dir()) {
          in->dirfragtree = p->dirfragtree;
-         bool had = in->snaprealm ? true:false;
          in->decode_snap_blob(p->snapbl);
-         if (!had && in->snaprealm)
-           do_snap_split = true;
        }
        if (in->inode.is_symlink()) in->symlink = p->symlink;
        if (p->dirty) in->_mark_dirty(logseg);
@@ -425,15 +424,6 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
          dout(10) << "EMetaBlob.replay for [" << p->dnfirst << "," << p->dnlast << "] had " << *in << dendl;
        }
        in->first = p->dnfirst;
-
-       // verify open snaprealm parent
-       if (in->snaprealm) {
-         SnapRealm *actual = in->get_parent_dn()->get_dir()->inode->find_snaprealm();
-         if (actual != in->snaprealm->parent) {
-           dout(10) << "EMetaBlob.replay  fixing snaprealm open parent" << dendl;
-           in->snaprealm->change_open_parent_to(actual);
-         }
-       }
       }
     }
 
index f2220c1dfc2aa16f99c9a90a3b033ec9fc63e63b..ff9a1006966d741b2dca9bb60b33896deb162b2c 100644 (file)
@@ -188,7 +188,7 @@ void SnapRealm::check_cache()
   build_snap_set(cached_snaps, cached_seq, cached_last_created, cached_last_destroyed,
                 0, CEPH_NOSNAP);
   
-  dout(10) << "check_cache " << cached_snaps
+  dout(10) << "check_cache rebuilt " << cached_snaps
           << " seq " << seq
           << " cached_seq " << cached_seq
           << " cached_last_created " << cached_last_created
@@ -334,6 +334,20 @@ snapid_t SnapRealm::resolve_snapname(const string& n, inodeno_t atino, snapid_t
 }
 
 
+void SnapRealm::adjust_parent()
+{
+  SnapRealm *newparent = inode->get_parent_dn()->get_dir()->get_inode()->find_snaprealm();
+  if (newparent != parent) {
+    dout(10) << "adjust_parent " << parent << " -> " << newparent << dendl;
+    if (parent)
+      parent->open_children.erase(this);
+    parent = newparent;
+    if (parent)
+      parent->open_children.insert(this);
+    
+    invalidate_cached_snaps();
+  }
+}
 
 void SnapRealm::split_at(SnapRealm *child)
 {
@@ -463,4 +477,6 @@ void SnapRealm::add_past_parent(SnapRealm *oldparent)
   }
   current_parent_since = MAX(oldlast, newlast) + 1;
   dout(10) << "add_past_parent current_parent_since " << current_parent_since << dendl;
+
+  invalidate_cached_snaps();
 }
index b4c1a61cbd31641d963652148da1766aaada2ee0..b37349b92f466d03ba6d632da6280c07415b69e0 100644 (file)
@@ -194,13 +194,8 @@ struct SnapRealm {
     return cached_seq;
   }
 
-  void change_open_parent_to(SnapRealm *newp) {
-    if (parent)
-      parent->open_children.erase(this);
-    parent = newp;
-    if (parent)
-      parent->open_children.insert(this);
-  }
+  void adjust_parent();
+
   void split_at(SnapRealm *child);
   void join(SnapRealm *child);