Skip to content

btree: make write buffer flush waits SRCU-aware#705

Closed
Komzpa wants to merge 1 commit into
koverstreet:masterfrom
Komzpa:komzpa/write-buffer-srcu-wait
Closed

btree: make write buffer flush waits SRCU-aware#705
Komzpa wants to merge 1 commit into
koverstreet:masterfrom
Komzpa:komzpa/write-buffer-srcu-wait

Conversation

@Komzpa

@Komzpa Komzpa commented Jun 29, 2026

Copy link
Copy Markdown

Summary

btree_write_buffer_flush_seq() currently drops the transaction SRCU read lock immediately with bch2_trans_unlock_long() before waiting for write-buffer pins to drain.

Switch that wait to the existing SRCU-aware trans_wait_event() pattern:

  • use bch2_trans_unlock() for the fast path;
  • wait on write_buffer_flush_wait through trans_wait_event();
  • let the helper escalate to dropping SRCU only if the wait blocks long enough.

This is a narrow companion to the broader SRCU/blocking-wait discussion in koverstreet/bcachefs#1069. It follows the maintainer-requested shape there without doing another blanket unlock_long() conversion.

Validation

  • git diff --check
  • make generate_version
  • BINDGEN=/home/kom/.cargo/bin/bindgen make -j32 fs/btree/write_buffer.o
  • BINDGEN=/home/kom/.cargo/bin/bindgen make -j32 bcachefs

@koverstreet

Copy link
Copy Markdown
Owner

Merged — cherry-picked onto master (bdf3476, authorship preserved). The unlock_long→unlock is required for trans_wait_event to have SRCU to manage, and it's safe: the only thing now running under the held SRCU read lock, fetch_wb_keys_from_journal(), is bounded (buf_lock + write-buffer lock + in-memory key copying — no indefinite wait or journal disk IO), and the actual unbounded wait is the SRCU-aware trans_wait_event. Thanks!

@koverstreet koverstreet closed this Jul 1, 2026
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.

2 participants