]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: don't change flush TID when re-send cap flush
authorYan, Zheng <zyan@redhat.com>
Wed, 3 Jun 2015 09:40:16 +0000 (17:40 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 18 Aug 2015 08:49:49 +0000 (16:49 +0800)
Client::wait_sync_caps requires stable TIDs for flushing caps.

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

index 1fad25149c2a52d5180edc7e10c589dddac67577..0ba948128c30df967c31d5f2c839eb9d7b9b1442 100644 (file)
@@ -2876,7 +2876,8 @@ void Client::cap_delay_requeue(Inode *in)
 }
 
 void Client::send_cap(Inode *in, MetaSession *session, Cap *cap,
-                     int used, int want, int retain, int flush)
+                     int used, int want, int retain, int flush,
+                     ceph_tid_t flush_tid)
 {
   int held = cap->issued | cap->implemented;
   int revoking = cap->implemented & ~cap->issued;
@@ -2919,14 +2920,10 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap,
     cap->implemented &= cap->issued | used;
   }
 
-  uint64_t flush_tid = 0;
   snapid_t follows = 0;
 
-  if (flush) {
-    flush_tid = ++last_flush_tid;
-    in->flushing_cap_tids[flush_tid] = flush;
+  if (flush)
     follows = in->snaprealm->get_snap_context().seq;
-  }
   
   MClientCaps *m = new MClientCaps(op,
                                   in->ino,
@@ -3081,12 +3078,15 @@ void Client::check_caps(Inode *in, bool is_delayed)
 
   ack:
     int flushing;
-    if (in->auth_cap == cap && in->dirty_caps)
-      flushing = mark_caps_flushing(in);
-    else
+    ceph_tid_t flush_tid;
+    if (in->auth_cap == cap && in->dirty_caps) {
+      flushing = mark_caps_flushing(in, &flush_tid);
+    } else {
       flushing = 0;
+      flush_tid = 0;
+    }
 
-    send_cap(in, session, cap, cap_used, wanted, retain, flushing);
+    send_cap(in, session, cap, cap_used, wanted, retain, flushing, flush_tid);
   }
 }
 
@@ -3708,13 +3708,16 @@ void Client::mark_caps_dirty(Inode *in, int caps)
   in->dirty_caps |= caps;
 }
 
-int Client::mark_caps_flushing(Inode *in)
+int Client::mark_caps_flushing(Inode *in, ceph_tid_t* ptid)
 {
   MetaSession *session = in->auth_cap->session;
 
   int flushing = in->dirty_caps;
   assert(flushing);
 
+  ceph_tid_t flush_tid = ++last_flush_tid;
+  in->flushing_cap_tids[flush_tid] = flushing;
+
   if (!in->flushing_caps) {
     ldout(cct, 10) << "mark_caps_flushing " << ccap_string(flushing) << " " << *in << dendl;
     in->flushing_cap_seq = ++last_flush_seq;
@@ -3729,6 +3732,7 @@ int Client::mark_caps_flushing(Inode *in)
 
   session->flushing_caps.push_back(&in->flushing_cap_item);
 
+  *ptid = flush_tid;
   return flushing;
 }
 
@@ -3758,8 +3762,13 @@ void Client::flush_caps(Inode *in, MetaSession *session)
   Cap *cap = in->auth_cap;
   assert(cap->session == session);
 
-  send_cap(in, session, cap, get_caps_used(in), in->caps_wanted(),
-          (cap->issued | cap->implemented), in->flushing_caps);
+  for (map<ceph_tid_t,int>::iterator p = in->flushing_cap_tids.begin();
+       p != in->flushing_cap_tids.end();
+       ++p) {
+    send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()),
+            in->caps_wanted(), (cap->issued | cap->implemented),
+            p->second, p->first);
+  }
 }
 
 void Client::wait_sync_caps(Inode *in, ceph_tid_t want)
index 6fa4c235b74e022b339ad5695f187cbaf740dfc9..b6ea21ba7eb60c5f15fff08c4b6575db4fbec606 100644 (file)
@@ -535,7 +535,7 @@ protected:
   void remove_all_caps(Inode *in);
   void remove_session_caps(MetaSession *session);
   void mark_caps_dirty(Inode *in, int caps);
-  int mark_caps_flushing(Inode *in);
+  int mark_caps_flushing(Inode *in, ceph_tid_t *ptid);
   void flush_caps();
   void flush_caps(Inode *in, MetaSession *session);
   void kick_flushing_caps(MetaSession *session);
@@ -557,7 +557,8 @@ protected:
   void handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, class MClientCaps *m);
   void cap_delay_requeue(Inode *in);
   void send_cap(Inode *in, MetaSession *session, Cap *cap,
-               int used, int want, int retain, int flush);
+               int used, int want, int retain, int flush,
+               ceph_tid_t flush_tid);
   void check_caps(Inode *in, bool is_delayed);
   void get_cap_ref(Inode *in, int cap);
   void put_cap_ref(Inode *in, int cap);