osd: Fix scrub object state pins: crash when the object becomes clean, leak in scrub_recalc_state #158

Open
koolkhel wants to merge 3 commits from koolkhel/vitastor:scrub-recalc-pin into master

3 Commits

Author SHA1 Message Date
00123a74e2 osd: Check pins also after a read that waited behind a delete
test_read_enoent_waits_behind_running_delete is the only test where a
read comes back to a replaced object state and drops its pin on the old
one. Assert that no state in the PG is left pinned there too.
2026-11-23 23:58:57 +03:00
b95ac3cfc4 osd: Check that a failed primary read drops its object state pins
The read path pins the object state since 3bf0b45a, but no test checked
that the pin is released. Assert that no state in the PG is left pinned
after the read fails with EIO and the object is marked corrupted.
2026-11-23 21:48:00 +03:00
8c8aeed4c6 osd: Fix scrub object state pins: crash when the object becomes clean, leak in scrub_recalc_state
3bf0b45a made scrub pin its object state and pass ref=true to
mark_object(). mark_object() then increments the ref count of the new
state, but add_object_to_set() returns NULL when the object becomes
clean, so a scrub that drops a vanished misplaced copy segfaults. Reads
and writes that mark objects corrupted with ref=true have the same path.

scrub_recalc_state() still called mark_object() with ref=false. When it
swapped states, the pin stayed on the old state, which then leaked with
no objects, and the final deref in continue_primary_scrub() decremented
the new, unpinned state: its ref_count wrapped around, or a write to the
same object lost its pin.
2026-11-23 11:32:20 +03:00