RBRD is a Rust RAM disk with a real safety bill
A three-patch series posted on 17 November adds rbrd, a RAM-backed block driver written in Rust that behaves like Linux's existing brd driver. The interesting part is not that Rust can implement a block device. It is that the patch set comes with a measured cost: the Rust version gives up roughly 19% of single-threaded write throughput and 22% of eight-threaded write throughput to guarantee that a read never observes a half-written page. That is a real trade-off, not a language advertisement, and it is the kind of trade-off kernel maintainers will have to argue about on the merits.
The series was posted by Vitaly Wool of Konsulko. It includes the driver and the Rust abstractions it needs: bio segment iteration and request accessors for blk-mq drivers, reference counting and raw pointer conversions for Page, and a bit spinlock stored in page->private. The driver is configured through configfs, like rnull, and keeps its pages in a flat array of atomic page pointers. Finding, adding, or removing a page therefore takes no lock. The locking is reserved for the copy itself.
What the driver actually does
A RAM disk is simple in principle: keep pages in memory, expose them as a block device, and copy data in and out. Linux's brd driver already does this in C. RBRD is not a new storage format or a new interface; it is a second implementation of the same idea, written to exercise Rust-for-Linux abstractions that did not exist before.
That matters because kernel Rust has spent years in the proving-ground phase. Early Rust code in the kernel was mostly bindings, sample modules, and small drivers. RBRD is closer to the kind of component that has to survive real I/O, real concurrency, and real performance review. The patch series touches 18 files and adds 1,192 lines. The driver itself is 420 lines, with another 188 lines for configfs support. The rest is infrastructure: block-layer abstractions, page helpers, and build glue. If this lands, other Rust block drivers can reuse that work.
The flat atomic page array is a deliberate design choice. The driver can locate a page, install a new one, or remove one without taking a device-wide lock. That avoids turning every I/O into a contention point and keeps the fast path simple. The per-page bit spinlock is only taken when a copy is actually in progress.
The abstractions are the real deliverable
The driver itself is 420 lines. The more important part of the series may be the 253 lines of bio support and the 160 lines of page support that make it possible. Rust-for-Linux has block abstractions, but they were not designed for a driver that needs to walk bio segments and hold a per-page lock while copying. The patch set adds those pieces, and if they are accepted, every future Rust block driver can use them.
That is how kernel Rust has progressed: a driver exposes a missing abstraction, the abstraction is reviewed on its own terms, and the next driver starts further ahead. The page helpers are a good example. A Page is a core kernel type with a lifetime and locking rules that do not map cleanly to Rust's ownership model. The patch adds reference counting, raw pointer conversions, and a bit spinlock stored in page->private. Each of those is a small, dangerous primitive. Getting them wrong would produce a driver that compiles and corrupts memory.
The cover letter lists Igor B as the author of the first two patches and Vitaly Wool as the author of the driver. That division is worth noting because it shows the work is not one person's clever driver. It is a small stack: block-layer access, page lifetime, and the device. Reviewers will evaluate each layer separately, and a rejection at the bottom can sink the top even if the driver is sound.
Configfs support is another integration detail that matters more than it looks. rnull uses configfs, and RBRD follows that pattern so it can be configured without a custom module parameter interface. That is not glamorous, but it is the kind of thing that determines whether a driver is usable in test harnesses and CI. A RAM disk that requires a rebuild to change its size is less useful than one that can be configured at runtime.
The race that C tolerates
The existing brd driver allows a read and a write to copy the same page at the same time. In practice, a read that overlaps a write can return a torn mix of old and new bytes. That is not a theoretical concern for a block device: a file system or application expects a read to return data that was actually written, not a byte-level blend of two writes.
RBRD forbids that overlap. Each copy holds the page's bit spinlock, so a read and a write cannot be in the same page at once. The patch cover letter is blunt about why: in Rust, the race would also be undefined behaviour. The language's aliasing rules do not permit a mutable and an immutable reference to the same memory to be live at the same time, and a data race is not a valid implementation strategy. The lock is what makes the Rust code sound and what gives the driver its page-integrity guarantee.
This is a useful example of how Rust changes the conversation in kernel work. The C driver's race is a bug, but it is a bug that has survived because RAM disks are fast, the window is small, and most workloads do not hit it. Rust does not magically detect the race at compile time; the programmer still had to design the locking. What Rust does is make the unsound version harder to write and easier to reject in review. The cost is that the safe version is slower.
The benchmark is small and honest
The cover letter includes a benchmark table: 4K random O_DIRECT I/O, an 8-vCPU guest, mean of nine runs, measured in kIOPS. The numbers compare brd and rbrd directly.
| Test | brd | rbrd | Change |
|---|---|---|---|
| Read, 8 threads | 2048 | 2012 | -2% |
| Read, 1 thread | 512 | 463 | -10% |
| Write, 1 thread | 583 | 470 | -19% |
| Write, 4 threads | 1693 | 1472 | -13% |
| Write, 8 threads | 2004 | 1563 | -22% |
The read numbers are close at high concurrency and weaker at one thread. The write numbers are the problem. A 22% drop at eight threads is large enough that anyone using a RAM disk for a write-heavy test harness, a build cache, or a temporary database will notice. The authors do not hide that. They say the gap has not been profiled, so not all of it is necessarily due to the lock. They also report that a single device-wide lock, instead of one lock per page, made eight-thread reads 20-28% slower than brd. The per-page design is clearly the better of the two locking strategies, but it does not make the cost disappear.
The benchmark is also narrow. It uses one block size, one I/O pattern, one guest configuration, and a mean of nine runs. It does not show tail latency, which is often what matters for interactive workloads. It does not break down CPU time in the copy path. It does not test memory pressure or page reclaim. Those gaps are normal for an RFC, but they matter for the upstream decision. A maintainer is more likely to accept a safety-driven slowdown if the cost is understood and bounded than if it is a unexplained percentage.
Why the penalty is a hard sell
Kernel performance culture is conservative for good reason. A RAM disk is supposed to be the fastest block device in the system. If a Rust implementation is slower than the C one, the obvious question is why anyone should switch. The authors' answer is page integrity: a block device should never return data that was never written. That is a strong correctness argument, but it is not free, and the kernel already has mechanisms for coordinating I/O.
The use cases for brd are also narrower than they once were. RAM is expensive, and most temporary storage now lives on NVMe or in memory-backed file systems such as tmpfs. RAM disks still show up in testing, simulation, and environments where a block device is required but the backing store should not touch disk. In those cases, correctness may matter more than raw throughput. A test that reads a torn page can produce a false failure that is much more expensive than a 19% write slowdown.
There is a second question: should the C driver be fixed instead? The patch does not propose changing brd; it adds a separate driver. That is a reasonable way to prototype the guarantee without forcing every existing brd user onto a slower path. It also means the kernel would carry two RAM disk drivers with different semantics. If RBRD is accepted, the documentation will need to be explicit about the difference, because "use the RAM disk" is no longer a single choice.
The strongest argument for RBRD may be that it exercises the Rust block-layer abstractions under a realistic workload. The driver is not a toy, and the benchmark is not a microbenchmark of a single function. Even if the performance penalty keeps it out of the default configuration, the abstractions and the review feedback are valuable. That is a common pattern in kernel Rust: the first user of an abstraction is often a driver that would not exist in C.
The AI-assistance disclosure
The cover letter says patches 2 and 3 were written with the Claude Code AI coding assistant, which also did the testing. That disclosure is notable because the kernel community is currently arguing about AI-generated patches and reviewer load. The Btrfs project, for example, is reviewing a proposed AGENTS.md file that would set expectations for both human newcomers and AI agents because reviewers are spending too much time on low-value, verbose submissions.
The disclosure does not tell us whether RBRD is good or bad. A patch is not suspicious merely because an assistant helped write it, and it is not trustworthy merely because a human typed it. What matters is whether the abstractions are correct, whether the locking is sound, whether the benchmark is reproducible, and whether the code is maintainable. The fact that the assistant also did the testing is more interesting than the authorship: testing is where AI-generated code often gets into trouble, because a model can produce a plausible test that exercises the happy path and misses the race.
For reviewers, the practical lesson is to ask for the same evidence they would ask from any contributor: a reproducer, a performance profile, and a clear statement of what is guaranteed. The cover letter provides most of that, but the missing profile is a real gap. If the 19-22% write penalty is mostly lock contention, a different locking scheme might recover some of it. If it is mostly cache-line bouncing or copy overhead, the fix is different. Without a profile, the discussion is stuck at the level of the headline number.
What to watch
The series is based on rust-next and targets v7.4-rc3. It is out for review, not merged. The next steps are predictable: reviewers will ask about the page locking, the block-layer abstractions, and the benchmark methodology. Someone will ask whether the C driver can be fixed, and someone else will ask whether a separate driver is worth the maintenance cost. The answers will determine whether RBRD becomes the first real Rust block driver in the mainline or remains a useful experiment.
For Rust developers outside the kernel, the patch is a good reminder that safety claims are only meaningful when they are attached to a cost. RBRD does not claim to be faster. It claims to be correct, and it shows the bill. That is a more honest sales pitch than most, and it is the right starting point for a kernel discussion.
Sources
- RBRD patch series on the Rust for Linux mailing list
- Phoronix: RBRD, a RAM-backed Linux block driver written in Rust
- Btrfs AGENTS.md proposal on the kernel mailing list