int put_nref = 0;
int drop = last & ~in->caps_issued();
if (in->snapid == CEPH_NOSNAP) {
- if ((last & (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER)) &&
+ if ((last & CEPH_CAP_FILE_WR) &&
!in->cap_snaps.empty() &&
in->cap_snaps.rbegin()->second.writing) {
ldout(cct, 10) << __func__ << " finishing pending cap_snap on " << *in << dendl;
signal_cond_list(in->waitfor_commit);
ldout(cct, 5) << __func__ << " dropped last FILE_BUFFER ref on " << *in << dendl;
++put_nref;
+
+ if (!in->cap_snaps.empty()) {
+ flush_snaps(in);
+ }
}
}
if (last & CEPH_CAP_FILE_CACHE) {
}
if (used & CEPH_CAP_FILE_BUFFER) {
- capsnap.writing = 1;
ldout(cct, 10) << __func__ << " " << *in << " cap_snap " << &capsnap << " used " << used
- << " WRBUFFER, delaying" << dendl;
+ << " WRBUFFER, trigger to flush dirty buffer" << dendl;
+
+ /* trigger to flush the buffer */
+ _flush(in, new C_Client_FlushComplete(this, in));
} else {
capsnap.dirty_data = 0;
flush_snaps(in);