]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: properly update client_snap_caps when splitting snap inode
authorYan, Zheng <zyan@redhat.com>
Tue, 21 Jun 2016 08:20:58 +0000 (16:20 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 20 Jul 2016 02:33:44 +0000 (10:33 +0800)
update the new snap inode's client_snap_caps according to the old
snap inode.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 4883779935219817c7e391940a025be1679daeb5)

src/mds/CInode.cc
src/mds/CInode.h
src/mds/MDCache.cc

index 718c0bc2f8d982c43ff6a722f4f94eb9eaf4f91c..df0b2bbeb49a6ce0c2c6c1b3499113ca5772fd05 100644 (file)
@@ -311,20 +311,23 @@ void CInode::remove_need_snapflush(CInode *snapin, snapid_t snapid, client_t cli
   }
 }
 
-void CInode::split_need_snapflush(CInode *cowin, CInode *in)
+bool CInode::split_need_snapflush(CInode *cowin, CInode *in)
 {
   dout(10) << "split_need_snapflush [" << cowin->first << "," << cowin->last << "] for " << *cowin << dendl;
+  bool need_flush = false;
   for (compact_map<snapid_t, set<client_t> >::iterator p = client_need_snapflush.lower_bound(cowin->first);
        p != client_need_snapflush.end() && p->first < in->first; ) {
     compact_map<snapid_t, set<client_t> >::iterator q = p;
     ++p;
     assert(!q->second.empty());
-    if (cowin->last >= q->first)
+    if (cowin->last >= q->first) {
       cowin->auth_pin(this);
-    else
+      need_flush = true;
+    } else
       client_need_snapflush.erase(q);
     in->auth_unpin(this);
   }
+  return need_flush;
 }
 
 void CInode::mark_dirty_rstat()
index 8f27bf0580badfe12464c2ace5a91436caa7f46a..5ed80a617547a12c6698f592f3d3f1566ba818d9 100644 (file)
@@ -566,7 +566,7 @@ public:
 
   void add_need_snapflush(CInode *snapin, snapid_t snapid, client_t client);
   void remove_need_snapflush(CInode *snapin, snapid_t snapid, client_t client);
-  void split_need_snapflush(CInode *cowin, CInode *in);
+  bool split_need_snapflush(CInode *cowin, CInode *in);
 
 protected:
 
index ddf46842276fba923b33118a2f5e117142552d3c..a0f2fa02a6d40d71ea12cf435c36bd36c0a87480 100644 (file)
@@ -1540,7 +1540,21 @@ CInode *MDCache::cow_inode(CInode *in, snapid_t last)
   if (in->last != CEPH_NOSNAP) {
     CInode *head_in = get_inode(in->ino());
     assert(head_in);
-    head_in->split_need_snapflush(oldin, in);
+    if (head_in->split_need_snapflush(oldin, in)) {
+      oldin->client_snap_caps = in->client_snap_caps;
+      for (compact_map<int,set<client_t> >::iterator p = in->client_snap_caps.begin();
+          p != in->client_snap_caps.end();
+          ++p) {
+       SimpleLock *lock = oldin->get_lock(p->first);
+       assert(lock);
+       for (auto q = p->second.begin(); q != p->second.end(); ++q) {
+         oldin->auth_pin(lock);
+         lock->set_state(LOCK_SNAP_SYNC);  // gathering
+         lock->get_wrlock(true);
+       }
+      }
+    }
+    return oldin;
   }
 
   // clone caps?