client: Fix CAS writes and buffer cleanup with write-back and immediate_commit #196

Merged
vitalif merged 2 commits from koolkhel/vitastor:cas-writeback-immediate-commit into master 2026-11-26 16:05:53 +03:00

2 Commits

Author SHA1 Message Date
67f2fe826c client: Delete written-back buffers with immediate_commit again
21066a09 deletes buffers in the flush callback when immediate_commit is
on, because no SYNC ever removes them then. Since 2e223f03 a flush op
carries its flush_id, so continue_rw() marks its buffers as written,
with flush_id 0, before the callback runs, and delete_flush() finds
nothing. The buffers then stay forever: memory grows with every range
written, and reads are answered from them with version 0, so a CAS
write retried after -EINTR never sees the real version. Skip
mark_flush_written() for immediate_commit ops, as handle_op_part()
already does for mark_flush_written_to().

Also run test_cas with IMMEDIATE_COMMIT=1. It fails without the
previous commit ("CAS write data lost") and without this one ("read
returned version 0").
2026-11-26 15:38:43 +03:00
62c4d267a6 client: Flush the write-back cache before CAS writes with immediate_commit
execute_cas() runs a SYNC before a CAS write over dirty write-back data
only when the pool's immediate_commit is not "all". But the write-back
cache also holds writes for immediate_commit=all pools, so there the CAS
write went to the OSD first, succeeded against the old version, and the
older cached write overwrote it at the next flush. Check enable_writeback
here like the other write-back checks in cluster_client.cpp do.
2026-11-26 15:38:43 +03:00