]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: pass proper old snap context to queue_cap_snap() 7495/head
authorYan, Zheng <zyan@redhat.com>
Wed, 9 Mar 2016 13:50:45 +0000 (21:50 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 9 Mar 2016 14:06:25 +0000 (22:06 +0800)
the snap realm for split point can be newly created, its snap context
is empty in this case.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc

index 31f31f86e99d3ee2589ecb64514b894e83f1dbd5..869bc437b59d695920b3958ba082f8c969653c75 100644 (file)
@@ -4176,7 +4176,7 @@ bool Client::adjust_realm_parent(SnapRealm *realm, inodeno_t parent)
 static bool has_new_snaps(const SnapContext& old_snapc,
                          const SnapContext& new_snapc)
 {
-       return !new_snapc.snaps.empty() && new_snapc.snaps[0] > old_snapc.seq;
+  return !new_snapc.snaps.empty() && new_snapc.snaps[0] > old_snapc.seq;
 }
 
 
@@ -4281,9 +4281,8 @@ void Client::handle_snap(MClientSnap *m)
 
   got_mds_push(session);
 
-  list<Inode*> to_move;
+  map<Inode*, SnapContext> to_move;
   SnapRealm *realm = 0;
-  SnapContext old_snapc;
 
   if (m->head.op == CEPH_SNAP_OP_SPLIT) {
     assert(m->head.split);
@@ -4295,7 +4294,6 @@ void Client::handle_snap(MClientSnap *m)
     // flush, then move, ino's.
     realm = get_snap_realm(info.ino());
     ldout(cct, 10) << " splitting off " << *realm << dendl;
-    old_snapc = realm->get_snap_context();
     for (vector<inodeno_t>::iterator p = m->split_inos.begin();
         p != m->split_inos.end();
         ++p) {
@@ -4313,8 +4311,8 @@ void Client::handle_snap(MClientSnap *m)
 
 
        in->snaprealm_item.remove_myself();
+       to_move[in] = in->snaprealm->get_snap_context();
        put_snap_realm(in->snaprealm);
-       to_move.push_back(in);
       }
     }
 
@@ -4334,15 +4332,14 @@ void Client::handle_snap(MClientSnap *m)
   update_snap_trace(m->bl, m->head.op != CEPH_SNAP_OP_DESTROY);
 
   if (realm) {
-    bool queue_snap = has_new_snaps(old_snapc, realm->get_snap_context());
-    for (list<Inode*>::iterator p = to_move.begin(); p != to_move.end(); ++p) {
-      Inode *in = *p;
+    for (auto p = to_move.begin(); p != to_move.end(); ++p) {
+      Inode *in = p->first;
       in->snaprealm = realm;
       realm->inodes_with_caps.push_back(&in->snaprealm_item);
       realm->nref++;
       // queue for snap writeback
-      if (queue_snap)
-       queue_cap_snap(in, old_snapc);
+      if (has_new_snaps(p->second, realm->get_snap_context()))
+       queue_cap_snap(in, p->second);
     }
     put_snap_realm(realm);
   }