]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: properly setup need_snapflush for snapped inode
authorYan, Zheng <zyan@redhat.com>
Fri, 5 Jan 2018 01:51:19 +0000 (09:51 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 30 Jan 2018 08:25:11 +0000 (16:25 +0800)
MDCache::cow_inode() checks "cap->issued() & CEPH_CAP_ANY_WR" to decide
if it needs to setup need_snapflush for the new snapped inode.
Locker::handle_client_caps() should call Locker::_do_cap_update() first,
then update issued caps. Otherwise MDCache::cow_inode() will fail to
setup need_snapflush if cap messages flushes dirty caps and releases the
same caps.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/Locker.cc

index df65779239fc989e33bf7597ead3f322e02d9252..edea4cb065024289de0287f4a769aa5f3351298d 100644 (file)
@@ -2868,19 +2868,32 @@ void Locker::handle_client_caps(MClientCaps *m)
       caps &= cap->issued();
     }
     
-    cap->confirm_receipt(m->get_seq(), caps);
     dout(10) << " follows " << follows
             << " retains " << ccap_string(m->get_caps())
             << " dirty " << ccap_string(m->get_dirty())
             << " on " << *in << dendl;
 
+    if (m->get_dirty() && in->is_auth()) {
+      dout(7) << " flush client." << client << " dirty " << ccap_string(m->get_dirty())
+             << " seq " << m->get_seq() << " on " << *in << dendl;
+      ack = new MClientCaps(CEPH_CAP_OP_FLUSH_ACK, in->ino(), 0, cap->get_cap_id(), m->get_seq(),
+                           m->get_caps(), 0, m->get_dirty(), 0, mds->get_osd_epoch_barrier());
+      ack->set_client_tid(m->get_client_tid());
+      ack->set_oldest_flush_tid(m->get_oldest_flush_tid());
+    }
+
+    bool need_flush = m->flags & MClientCaps::FLAG_SYNC;
+    bool updated = in->is_auth() &&
+                  _do_cap_update(in, cap, m->get_dirty(), follows, m, ack, &need_flush);
+
+    cap->confirm_receipt(m->get_seq(), caps);
 
     // missing/skipped snapflush?
-    //  The client MAY send a snapflush if it is issued WR/EXCL caps, but
-    //  presently only does so when it has actual dirty metadata.  But, we
-    //  set up the need_snapflush stuff based on the issued caps.
-    //  We can infer that the client WONT send a FLUSHSNAP once they have
-    //  released all WR/EXCL caps (the FLUSHSNAP always comes before the cap
+    //  The client MAY send a snapflush if it is issued WR/EXCL caps,
+    //  but only does so when it has actual dirty metadata. We set up
+    //  the need_snapflush stuff based on the issued caps. We can infer
+    //  that the client WONT send a FLUSHSNAP once they have released
+    //  all WR/EXCL caps (the FLUSHSNAP always comes before the cap
     //  update/release).
     if (!head_in->client_need_snapflush.empty()) {
       if (!(cap->issued() & CEPH_CAP_ANY_FILE_WR) &&
@@ -2894,18 +2907,8 @@ void Locker::handle_client_caps(MClientCaps *m)
     }
     if (cap->need_snapflush() && !(m->flags & MClientCaps::FLAG_PENDING_CAPSNAP))
       cap->clear_needsnapflush();
-    
-    if (m->get_dirty() && in->is_auth()) {
-      dout(7) << " flush client." << client << " dirty " << ccap_string(m->get_dirty()) 
-             << " seq " << m->get_seq() << " on " << *in << dendl;
-      ack = new MClientCaps(CEPH_CAP_OP_FLUSH_ACK, in->ino(), 0, cap->get_cap_id(), m->get_seq(),
-                           m->get_caps(), 0, m->get_dirty(), 0, mds->get_osd_epoch_barrier());
-      ack->set_client_tid(m->get_client_tid());
-      ack->set_oldest_flush_tid(m->get_oldest_flush_tid());
-    }
 
     // filter wanted based on what we could ever give out (given auth/replica status)
-    bool need_flush = m->flags & MClientCaps::FLAG_SYNC;
     int new_wanted = m->get_wanted() & head_in->get_caps_allowed_ever();
     if (new_wanted != cap->wanted()) {
       if (!need_flush && (new_wanted & ~cap->pending())) {
@@ -2916,8 +2919,7 @@ void Locker::handle_client_caps(MClientCaps *m)
       adjust_cap_wanted(cap, new_wanted, m->get_issue_seq());
     }
       
-    if (in->is_auth() &&
-       _do_cap_update(in, cap, m->get_dirty(), follows, m, ack, &need_flush)) {
+    if (updated) {
       // updated
       eval(in, CEPH_CAP_LOCKS);