mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] rust: block: add rbrd, a RAM backed block driver
@ 2026-11-17 23:32 Vitaly Wool
  2026-11-17 23:32 ` [PATCH 1/3] rust: block: add bio segment iteration and request accessors Vitaly Wool
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Vitaly Wool @ 2026-11-17 23:32 UTC (permalink / raw)
  To: Andreas Hindborg, Jens Axboe, Miguel Ojeda, Alice Ryhl
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Lorenzo Stoakes,
	Liam R . Howlett, linux-block, rust-for-linux, linux-mm,
	linux-kernel, Vitaly Wool

This series adds rbrd, a RAM backed block driver written in Rust that
works like brd, together with the Rust abstractions it needs:

1. bio segment iteration and request accessors for blk-mq drivers;
2. reference counting, raw pointer conversions and a bit spinlock in
   `page->private` for `Page`;
3. the driver itself, configured through configfs like rnull. Its pages
   are kept in a flat array of atomic page pointers, so finding, adding
   or removing a page takes no lock.

Unlike brd, rbrd never lets a read and a write copy the same page at
the same time: each copy holds the page's bit spinlock. brd allows
this race, so a read that overlaps a write can return a torn mix of
old and new data. In Rust the race would also be undefined behaviour.

This guarantee has a cost. rbrd is slower than brd, mostly for writes
(4k random O_DIRECT I/O, 8 vCPU guest, mean of 9 runs, kIOPS):

  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%

We think this is a small price for page integrity: a RAM disk is still
far faster than any real device, and a block device should never
return data that was never written. The gap has not been profiled
yet, so not all of it is necessarily due to the lock. With a single
lock for the whole device instead of one per page, 8-thread reads were
20-28% slower than brd.

The series is based on rust-next (v7.4-rc3). Patches 2 and 3 were
written with the Claude Code AI coding assistant, which also did the
testing.

Igor B (2):
  rust: block: add bio segment iteration and request accessors
  rust: page: add reference counting, raw pointers and a private bit
    lock

Vitaly Wool (1):
  rust: block: add rbrd, a RAM backed block driver

 MAINTAINERS                      |   1 +
 drivers/block/Kconfig            |   1 +
 drivers/block/Makefile           |   1 +
 drivers/block/rbrd/Kconfig       |  17 ++
 drivers/block/rbrd/Makefile      |   2 +
 drivers/block/rbrd/configfs.rs   | 188 ++++++++++++++
 drivers/block/rbrd/rbrd.rs       | 420 +++++++++++++++++++++++++++++++
 rust/bindings/bindings_helper.h  |   1 +
 rust/helpers/bit_spinlock.c      |  13 +
 rust/helpers/blk.c               |  14 ++
 rust/helpers/helpers.c           |   1 +
 rust/helpers/page.c              |  10 +
 rust/kernel/block.rs             |   1 +
 rust/kernel/block/bio.rs         | 253 +++++++++++++++++++
 rust/kernel/block/mq.rs          |   5 +-
 rust/kernel/block/mq/gen_disk.rs |  25 ++
 rust/kernel/block/mq/request.rs  |  81 +++++-
 rust/kernel/page.rs              | 160 ++++++++++++
 18 files changed, 1192 insertions(+), 2 deletions(-)
 create mode 100644 drivers/block/rbrd/Kconfig
 create mode 100644 drivers/block/rbrd/Makefile
 create mode 100644 drivers/block/rbrd/configfs.rs
 create mode 100644 drivers/block/rbrd/rbrd.rs
 create mode 100644 rust/helpers/bit_spinlock.c
 create mode 100644 rust/kernel/block/bio.rs

-- 
2.39.5


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-18 15:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 23:32 [PATCH 0/3] rust: block: add rbrd, a RAM backed block driver Vitaly Wool
2026-11-17 23:32 ` [PATCH 1/3] rust: block: add bio segment iteration and request accessors Vitaly Wool
2026-11-18 15:19   ` Andreas Hindborg
2026-11-17 23:32 ` [PATCH 2/3] rust: page: add reference counting, raw pointers and a private bit lock Vitaly Wool
2026-11-18 15:23   ` Andreas Hindborg
2026-11-17 23:32 ` [PATCH 3/3] rust: block: add rbrd, a RAM backed block driver Vitaly Wool
2026-11-18 11:43 ` [PATCH 0/3] " Jan Engelhardt
2026-11-18 14:48   ` Vitaly Wool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®