Skip to content

Fixed race between cp_flush() and reset() - #939

Merged
nnastonen merged 1 commit into
eBay:dev/v8.xfrom
nnastonen:SDSTOR-26141_bitmap_alloc_reset_cp_flush_race
Oct 28, 2026
Merged

nnastonen merged 1 commit into
eBay:dev/v8.xfrom
nnastonen:SDSTOR-26141_bitmap_alloc_reset_cp_flush_race

Conversation

@nnastonen

@nnastonen nnastonen commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

When a chunk is reset (for example when HomeBlocks releases a destroyed volume's chunks), reset_block_allocator() deletes the chunk's bitmap meta blk and replaces the allocator with a new one. A CP flush running at the same time can still hold the old allocator and flush it afterwards. Depending on timing, one of two things happens:

  1. The old bitmap is written back. The flush saves the pre-reset bitmap as a new meta blk. After a crash, the reset chunk comes back with blocks still marked allocated, and that extra meta blk is never cleaned up.
  2. Crash. The flush updates the meta blk that the reset just deleted, with a null or freed cookie. _PRERELEASE builds assert ("null cookie!"); release builds hit a null dereference or a use-after-free.

Fix
Make BitmapBlkAllocator::reset() and cp_flush() mutually exclusive, and stop flushing an allocator once it has been reset.

SDSTOR-26141

@nnastonen
nnastonen force-pushed the SDSTOR-26141_bitmap_alloc_reset_cp_flush_race branch 4 times, most recently from d244810 to 868a80a Compare October 19, 2026 12:05
@nnastonen
nnastonen force-pushed the SDSTOR-26141_bitmap_alloc_reset_cp_flush_race branch 2 times, most recently from a27a146 to d218571 Compare October 19, 2026 17:02
@nnastonen
nnastonen requested a review from szmyd October 20, 2026 11:33
@nnastonen
nnastonen force-pushed the SDSTOR-26141_bitmap_alloc_reset_cp_flush_race branch from d218571 to dc2b243 Compare October 27, 2026 22:40
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (dev/v8.x@4d93ef5). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/lib/blkalloc/bitmap_blk_allocator.cpp 50.00% 0 Missing and 3 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff             @@
##             dev/v8.x     #939   +/-   ##
===========================================
  Coverage            ?   49.12%           
===========================================
  Files               ?      112           
  Lines               ?    12797           
  Branches            ?     6068           
===========================================
  Hits                ?     6287           
  Misses              ?     2473           
  Partials            ?     4037           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raakella1 raakella1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG!

@nnastonen
nnastonen merged commit 1829774 into eBay:dev/v8.x Oct 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants