freenode
Kernel & Low-Level

Rust RAM disk promises intact pages, but overlaps existing work

rbrd serializes copies that brd allows to tear, yet its first numbers were mixed and key abstractions were already in flight.

Vitaly Wool and Igor Belousov have proposed rbrd, a RAM-backed block driver in Rust that behaves like the long-standing brd driver but refuses a race brd still allows. On brd, a read that overlaps a write of the same page can return a torn mix of old and new bytes. rbrd holds a per-page bit spinlock for the duration of each copy, so a read never shares a page with a write. Wool argued that a block device should never return data that was never written, and that the race would also be undefined behaviour in Rust.

The series is also a bid to grow the Rust block layer past the null driver. Today's abstractions can start and finish a request, but a driver that moves data cannot inspect the operation, sector, or length, or walk the bios. Belousov added bio and request accessors, discard advertising, and Page operations for extra references, raw pointers, and a lock stored in the page's private field. rbrd itself is created through configfs, like the existing Rust null device. Pages live in a flat array of atomic pointers, so lookup, insert, and discard take no device-wide lock. Unwritten reads return zeroes; discards free pages they fully cover.

The integrity guarantee was sold with numbers that did not survive first contact. On an eight-vCPU guest, 4K random direct I/O showed rbrd about 2 to 22 percent slower than brd, worst on multi-threaded writes. Jan Engelhardt called that a free improvement for staying in C and not submitting the same page twice. Wool replied that those runs were on a Raspberry Pi under QEMU, and posted Ryzen 9 medians in which rbrd was faster: roughly 12 to 19 percent on sequential reads and as much as about 50 percent on 4K random writes, depending on vCPU count. He said the stronger machine should have been in the cover letter, and that the original gap had not been profiled, so the lock may not explain all of it.

Andreas Hindborg, who maintains the Rust block work, said the bio and request pieces had already been submitted, with a rebase on the current rust-next available, and that most of the Page reference-counting work is part of his Ownable series, with a separate page posting planned this week covering both reference-counted and frozen pages. Two of the three patches were written and tested with an AI coding assistant.