]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: detect completed cap flush
authorYan, Zheng <zyan@redhat.com>
Wed, 3 Jun 2015 11:12:13 +0000 (19:12 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 18 Aug 2015 08:49:50 +0000 (16:49 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/Locker.cc

index 7a4956381c2d39f6d14b59bc752c12b34bf732c6..3849ce464da05bb1af92847de31491ba9cba9166 100644 (file)
@@ -2454,11 +2454,12 @@ bool Locker::should_defer_client_cap_frozen(CInode *in)
  */
 void Locker::handle_client_caps(MClientCaps *m)
 {
+  Session *session = static_cast<Session *>(m->get_connection()->get_priv());
   client_t client = m->get_source().num();
 
   snapid_t follows = m->get_snap_follows();
   dout(7) << "handle_client_caps on " << m->get_ino()
-         << " follows " << follows 
+         << " tid " << m->get_client_tid() << " follows " << follows
          << " op " << ceph_cap_op_name(m->get_op()) << dendl;
 
   if (!mds->is_clientreplay() && !mds->is_active() && !mds->is_stopping()) {
@@ -2466,6 +2467,26 @@ void Locker::handle_client_caps(MClientCaps *m)
     return;
   }
 
+  if (m->get_client_tid() > 0 &&
+      session->have_completed_flush(m->get_client_tid())) {
+    dout(7) << "handle_client_caps already flushed tid " << m->get_client_tid()
+           << " for client." << client << dendl;
+    MClientCaps *ack;
+    if (m->get_op() == CEPH_CAP_OP_FLUSHSNAP) {
+      ack = new MClientCaps(CEPH_CAP_OP_FLUSHSNAP_ACK, m->get_ino(), 0, 0, 0, 0, 0,
+                           m->get_dirty(), 0, mds->get_osd_epoch_barrier());
+    } else {
+      ack = new MClientCaps(CEPH_CAP_OP_FLUSH_ACK, m->get_ino(), 0, m->get_cap_id(),
+                           m->get_seq(), m->get_caps(), 0, m->get_dirty(), 0,
+                           mds->get_osd_epoch_barrier());
+    }
+    ack->set_snap_follows(follows);
+    ack->set_client_tid(m->get_client_tid());
+    mds->send_message_client_counted(ack, m->get_connection());
+    m->put();
+    return;
+  }
+
   // "oldest flush tid" > 0 means client uses unique TID for each flush
   if (m->get_oldest_flush_tid() > 0) {
     if (session->trim_completed_flushes(m->get_oldest_flush_tid())) {