Skip to content

Commit 6262351

Browse files
committed
client: always add one new capsnap if Fb is used and Fw is not used
If we set the 'writing' to 1 when the 'Fb' caps is used then later if we have any dirty caps it will be skipped and will reuse the existing capsnap, which is incorrect. At the same time trigger to flush the buffer when making snapshot and if the Fb is being used. Fixes: https://tracker.ceph.com/issues/59343 Signed-off-by: Xiubo Li <[email protected]>
1 parent e85f582 commit 6262351

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/client/Client.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,7 +3575,7 @@ void Client::put_cap_ref(Inode *in, int cap)
35753575
int put_nref = 0;
35763576
int drop = last & ~in->caps_issued();
35773577
if (in->snapid == CEPH_NOSNAP) {
3578-
if ((last & (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER)) &&
3578+
if ((last & CEPH_CAP_FILE_WR) &&
35793579
!in->cap_snaps.empty() &&
35803580
in->cap_snaps.rbegin()->second.writing) {
35813581
ldout(cct, 10) << __func__ << " finishing pending cap_snap on " << *in << dendl;
@@ -3589,6 +3589,10 @@ void Client::put_cap_ref(Inode *in, int cap)
35893589
signal_cond_list(in->waitfor_commit);
35903590
ldout(cct, 5) << __func__ << " dropped last FILE_BUFFER ref on " << *in << dendl;
35913591
++put_nref;
3592+
3593+
if (!in->cap_snaps.empty()) {
3594+
flush_snaps(in);
3595+
}
35923596
}
35933597
}
35943598
if (last & CEPH_CAP_FILE_CACHE) {
@@ -4104,9 +4108,11 @@ void Client::finish_cap_snap(Inode *in, CapSnap &capsnap, int used)
41044108
}
41054109

41064110
if (used & CEPH_CAP_FILE_BUFFER) {
4107-
capsnap.writing = 1;
41084111
ldout(cct, 10) << __func__ << " " << *in << " cap_snap " << &capsnap << " used " << used
4109-
<< " WRBUFFER, delaying" << dendl;
4112+
<< " WRBUFFER, trigger to flush dirty buffer" << dendl;
4113+
4114+
/* trigger to flush the buffer */
4115+
_flush(in, new C_Client_FlushComplete(this, in));
41104116
} else {
41114117
capsnap.dirty_data = 0;
41124118
flush_snaps(in);

0 commit comments

Comments
 (0)