Skip to content

perf(ext2,virtio-blk): bounded POSIX writeback, metadata read cache, and pipelined JBD2 I/O - #144

Merged
YUZHEthefool merged 2 commits into
mainfrom
perf/ext2-block-io-fastpath
Nov 28, 2026
Merged

YUZHEthefool merged 2 commits into
mainfrom
perf/ext2-block-io-fastpath

Conversation

@YUZHEthefool

@YUZHEthefool YUZHEthefool commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Bounded POSIX buffered writeback (kernel/vfs/ext2.rs, kernel/vfs/traits.rs, kernel/vfs/types.rs, kernel/vfs/operations.rs, kernel/vfs/ext2/namespace.rs, kernel/vfs/ext2/tree.rs):
    • Buffers non-O_SYNC/O_DSYNC writes on 4 KiB coalescing devices in physical-frame-backed Ext2PageFrame pages (capped at 128 pages / 32 dirty inodes per mount, zero pressure on the 1 MiB boot unledgered heap).
    • Preserves POSIX read-your-writes coherence, O_APPEND atomicity under write_lock, unlink-while-open retention until final Drop, short-lived create+write+unlink RAM discard, and recoverable ENOSPC/NoMem error handling without poisoning the mount.
    • Flushes via ordered-data JBD2 on fsync() / sync_file_range() / sync() / umount() (serialized before mount detachment) / Drop for Ext2Fs, preserving mtime == ctime recovery grammar invariants.
  • Post-mount write-through metadata read cache (MetadataBlockCache, 16x2-way):
    • Enabled strictly after mount & recovery validation on 4 KiB coalescing devices; updates cached slots in place on write and invalidates fail-closed on any write error.
  • Coalesced & pipelined JBD2/VirtIO-blk writes (kernel/block/src/lib.rs, kernel/block/src/virtio/blk.rs, kernel/vfs/ext2.rs):
    • Added BlockDevice::supports_coalesced_write() (default false so synthetic/fault-injection test doubles retain exact per-block boundaries) and BlockDevice::write_batch_sync() with 2-request pipelining in VirtioBlkDevice::do_write_pair() (Legacy DMA pool gated on mm::dma::is_iommu_legacy()).
    • Backed Ext2Journal staging buffers (superblock_image, tx_images, checkpoint_buf) with physical frames (Ext2BlockBuf) on bare-metal and fallible Vec<u8> under any(test, feature = "host_harness").
    • Coalesces pre-commit [J[0]|J[1]|images] pipelined with full-block ordered data, coalesces sorted contiguous checkpoint home runs, and defers post-clear flush fix: resolve 24/25 issues from December 2025 security audit #4 on coalescing devices while preserving exact JBD2 crash recovery.

KVM Benchmark vs Linux 7.2.15 (4c / 8c / 16c)

Workload Baseline (main@3fd447e) After Speedup Ratio vs Linux 7.2.15
combined (4c / 8c / 16c, hb/s) 20.6 / 21.0 / 18.0 120.0 / 85.0 / 53.0 5.8x / 4.0x / 2.9x 0.70x / 0.97x / 2.15x (was 0.09x / 0.21x / 0.68x)
block (4c / 8c / 16c, commits/s) 812.1 / 821.0 / 716.3 851.8 / 700.4 / 716.2 — 0.88x / 0.76x / 0.89x (was 0.70x / 0.72x / 0.68x)

Verification

  • Static gates: make fmt-check, make lint-fetch-add, make lint-smap, make lint-repr-c-copy, make lint-fallible — all PASS.
  • Hosted suite: scripts/tools/hosted_subcrate_tests.sh — all PASS (vfs 94/94, block 27/27, ext2_mut_image --features host_harness built cleanly).
  • Real KVM SIGKILL crash-recovery gate (STRESS_PROFILES=block STRESS_DURATION=5 STRESS_ACCEL=kvm): captured active Zero-Intent JBD2 transaction on attempt 1/6, recovered cleanly on exact disk, e2fsck -fn clean, validate-block-durability passed, Failed: 0.
  • Devbox gates: make clippy, make test-ring3-mm, make test-smp-4core (passed=67 deferred=0 failed=0, 4 CPUs online, 0 exceptions) — all PASS.
  • Independent adversarial security/crash-safety audit (gpt-6-astra): VERDICT: CLEAN.

@github-actions github-actions Bot added area: memory Allocators, page tables, COW, admission, cache, and OOM area: storage/VFS VFS, filesystems, block I/O, and storage images area: tooling/CI Build system, scripts, hooks, automation, and repository tooling size: XL At least 1000 review lines, excluding generated/binary artifacts performance Measured performance or resource-usage work labels Nov 28, 2026
@github-actions github-actions Bot added the area: process/ABI Processes, syscalls, usercopy, signals, ELF, and Linux ABI label Nov 28, 2026
@YUZHEthefool
YUZHEthefool merged commit 9f654f4 into main Nov 28, 2026
16 checks passed
@YUZHEthefool
YUZHEthefool deleted the perf/ext2-block-io-fastpath branch November 28, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: memory Allocators, page tables, COW, admission, cache, and OOM area: process/ABI Processes, syscalls, usercopy, signals, ELF, and Linux ABI area: storage/VFS VFS, filesystems, block I/O, and storage images area: tooling/CI Build system, scripts, hooks, automation, and repository tooling performance Measured performance or resource-usage work size: XL At least 1000 review lines, excluding generated/binary artifacts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant