Skip to content

tests/bcachefs: test journal flush SRCU liveness - #99

Open
Komzpa wants to merge 2 commits into
koverstreet:masterfrom
Komzpa:agent/pr783-journal-srcu-20260718
Open

tests/bcachefs: test journal flush SRCU liveness#99
Komzpa wants to merge 2 commits into
koverstreet:masterfrom
Komzpa:agent/pr783-journal-srcu-20260718

Conversation

@Komzpa

@Komzpa Komzpa commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds journal_flush_srcu_liveness.ktest for the SRCU/journal-liveness shape in
koverstreet/bcachefs-tools#783.

The test mounts a 3-device debug bcachefs filesystem, delays journal flushes,
constrains move writeback concurrency, runs foreground fio pressure, and
evacuates a source device. It fails if the stress window emits either:

  • btree trans held srcu lock
  • bch2_journal_flush_seq stuck?

After the stress window it remounts read-only, unmounts, runs
bcachefs fsck -ny, and checks for bcachefs leak/error/device-error reports.

Current Source-PR Status

This was originally paired with
koverstreet/bcachefs-tools#790, but that PR is now
closed after upstream review rejected the broad SRCU-unlock approach and split
the useful pieces out.

The surviving source-side journal-reclaim work is
koverstreet/bcachefs-tools#792. This ktest should not be
read as a red-to-green reproducer for that PR: it is a regression/smoke oracle
for the journal-flush/SRCU liveness invariant from
koverstreet/bcachefs-tools#783.

Scope Update After Coverage Audit

This is not a failing reproducer for
koverstreet/bcachefs-tools#783. It passes unpatched
origin/testing at 838ead8957377100c58b501fc1c50816cb7e7da2 as well as the
historical koverstreet/bcachefs-tools#790 branch, so there is no red-to-green
transition.

I also tried a closer member-stall prototype that suspends a source member with
dmsetup suspend during bcachefs device evacuate. The initial oracle treated
any bch2_journal_flush_seq stuck? as failure, but that is too strict when the
test deliberately suspends a member for longer than the journal warning
threshold. With the oracle narrowed to post-resume non-recovery or
btree trans held srcu lock, the prototype passes current unpatched
koverstreet/bcachefs-tools origin/testing, while still showing the expected
journal-stuck diagnostics during the artificial suspend.

That prototype is therefore not included in this PR as a regression test.

Testing

  • git diff --check origin/master..HEAD
  • bash -n tests/fs/bcachefs/journal_flush_srcu_liveness.ktest
  • tests/fs/bcachefs/journal_flush_srcu_liveness.ktest list-tests
  • tests/fs/bcachefs/journal_flush_srcu_liveness.ktest deps
  • Full VM run against unpatched koverstreet/bcachefs-tools origin/testing
    at 838ead8957377100c58b501fc1c50816cb7e7da2, confirming this is not a red
    reproducer:
    • bcachefs module loaded in guest: version: v1.38.8-161-g838ead895737
    • result: ========= PASSED journal_flush_srcu_liveness in 69s
    • result: TEST SUCCESS
  • Full VM run against the original paired source fix at
    fd929bb4241a885b8ce62f0f5b2412f247b13699:
    • bcachefs module loaded in guest: version: v1.38.8-162-gfd929bb4241a
    • result: ========= PASSED journal_flush_srcu_liveness in 24s
    • result: TEST SUCCESS
    • log oracle found no btree trans held srcu lock
    • log oracle found no bch2_journal_flush_seq stuck?
  • Full VM run against historical koverstreet/bcachefs-tools#790 source head
    58f07184dbe66dcfa01d8ef021d1326fa4027a2f:
    • bcachefs module loaded in guest: version: v1.38.8-182-g58f07184dbe6
    • result: ========= PASSED journal_flush_srcu_liveness in 114s
    • result: TEST SUCCESS
    • log oracle found no btree trans held srcu lock
    • log oracle found no bch2_journal_flush_seq stuck?

VM proof

VM run against master bcachefs-tools (kernel 7.2.0-rc4): journal_flush_srcu_liveness PASSED in 32s -- delayed journal flushes plus constrained move-writeback concurrency and foreground fio pressure on a 3-device debug fs completed without an SRCU/journal-liveness warning, source evacuated.

Komzpa added 2 commits August 17, 2026 00:39
Add a standalone bcachefs ktest for the issue #783 shape: delayed
journal flushes, a constrained move write window, destination fsync
pressure, and source device evacuation.

The test keeps BCACHEFS_DEBUG enabled, clears dmesg immediately before
the stress window, and fails if the workload emits either 'btree trans
held srcu lock' or 'bch2_journal_flush_seq stuck?'. It also treats a
timed-out evacuate or read-only shutdown as a liveness failure and dumps
journal/reconcile/moving context state for diagnosis.
@Komzpa
Komzpa force-pushed the agent/pr783-journal-srcu-20260718 branch from 59c1c8e to 9e48127 Compare August 16, 2026 21:29
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.

1 participant