]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fire the finish_cap_snap() after buffer being flushed 40722/head
authorXiubo Li <xiubli@redhat.com>
Wed, 30 Dec 2020 01:41:01 +0000 (09:41 +0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 9 Apr 2021 09:01:35 +0000 (11:01 +0200)
When the inode has Fb cap and the used reference is none zero, the
cap snap flushing will be delayed, so we need to make sure it will
be invoked after the dirty buffer is flushed to osd.

Fixes: https://tracker.ceph.com/issues/48679
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit a34d0c242a73d7c29956b6894a430d9979225632)

src/client/Client.cc

index 06d3b510fa7e01d26874a4b647420f9c3eb4a10f..edb74a6c0ec40d7871c0da7949ba2b802a1ce1c8 100755 (executable)
@@ -3192,7 +3192,7 @@ void Client::put_cap_ref(Inode *in, int cap)
     int put_nref = 0;
     int drop = last & ~in->caps_issued();
     if (in->snapid == CEPH_NOSNAP) {
-      if ((last & CEPH_CAP_FILE_WR) &&
+      if ((last & (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER)) &&
          !in->cap_snaps.empty() &&
          in->cap_snaps.rbegin()->second.writing) {
        ldout(cct, 10) << __func__ << " finishing pending cap_snap on " << *in << dendl;
@@ -3707,6 +3707,7 @@ void Client::finish_cap_snap(Inode *in, CapSnap &capsnap, int used)
   }
 
   if (used & CEPH_CAP_FILE_BUFFER) {
+    capsnap.writing = 1;
     ldout(cct, 10) << __func__ << " " << *in << " cap_snap " << &capsnap << " used " << used
             << " WRBUFFER, delaying" << dendl;
   } else {
@@ -3782,7 +3783,7 @@ void Client::flush_snaps(Inode *in)
             << " on " << *in << dendl;
     if (capsnap.dirty_data || capsnap.writing)
       break;
-    
+
     capsnap.flush_tid = ++last_flush_tid;
     session->flushing_caps_tids.insert(capsnap.flush_tid);
     in->flushing_cap_tids[capsnap.flush_tid] = 0;