Client: Check CAS writes for multiple stripes after slicing them #175

Merged
vitalif merged 1 commits from koolkhel/vitastor:cas-multi-stripe into master 2026-11-25 20:33:56 +03:00
Contributor

Description

3bc5a186 ("Execute a forced sync before CAS if inode range has dirty data") moved the "atomic writes to multiple stripes are unsupported" check in cluster_client_t::execute_cas() above slice_rw(). op->parts is still empty at that point, so the check never fires. A CAS write or delete that crosses a stripe boundary then sends only its first part (try_send(op, 0, ...)) and reports success with the length of that part, while the rest of the range stays unchanged.

For example, with 128 KiB objects, an 8 KiB vitastor_c_write() at offset 124 KiB with check_version = current version + 1 returns 4096: the first object is written and its version is bumped, and the second object is untouched. A CAS delete over the same range returns 0, deletes the first object and leaves the second.

This PR does the check after slice_rw() again, as before 3bc5a186.

Tested: new test_cas_cross_object in test_cluster_client (replicated pool, immediate_commit=all). It fails on master (the write returns 4096, the delete returns 0, and both send their first part), and passes with the fix. A CAS write that ends exactly at the boundary is still sent whole. The rest of test_cluster_client passes.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description 3bc5a186 ("Execute a forced sync before CAS if inode range has dirty data") moved the "atomic writes to multiple stripes are unsupported" check in `cluster_client_t::execute_cas()` above `slice_rw()`. `op->parts` is still empty at that point, so the check never fires. A CAS write or delete that crosses a stripe boundary then sends only its first part (`try_send(op, 0, ...)`) and reports success with the length of that part, while the rest of the range stays unchanged. For example, with 128 KiB objects, an 8 KiB `vitastor_c_write()` at offset 124 KiB with `check_version` = current version + 1 returns 4096: the first object is written and its version is bumped, and the second object is untouched. A CAS delete over the same range returns 0, deletes the first object and leaves the second. This PR does the check after `slice_rw()` again, as before 3bc5a186. Tested: new `test_cas_cross_object` in `test_cluster_client` (replicated pool, `immediate_commit=all`). It fails on master (the write returns 4096, the delete returns 0, and both send their first part), and passes with the fix. A CAS write that ends exactly at the boundary is still sent whole. The rest of `test_cluster_client` passes. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-24 14:15:34 +03:00
3bc5a186 ("Execute a forced sync before CAS if inode range has dirty data")
moved the "atomic writes to multiple stripes are unsupported" check above
slice_rw(). op->parts is still empty there, so the check never fires: a
CAS write or delete that crosses a stripe boundary sends only its first
part and reports success with the length of that part, while the rest of
the range stays unchanged.

Do the check after slice_rw() again, as before 3bc5a186.
vitalif merged commit 7cb1edb522 into master 2026-11-25 20:33:56 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#175
No description provided.