Linux-mm Archive on lore.kernel.org
 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; 11+ 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] 11+ messages in thread

* [PATCH 1/3] rust: block: add bio segment iteration and request accessors
  2026-11-17 23:32 [PATCH 0/3] rust: block: add rbrd, a RAM backed block driver Vitaly Wool
@ 2026-11-17 23:32 ` Vitaly Wool
  2026-11-18 15:19   ` Andreas Hindborg
  2026-11-18 23:36   ` sashiko-bot
  2026-11-17 23:32 ` [PATCH 2/3] rust: page: add reference counting, raw pointers and a private bit lock Vitaly Wool
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ 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, Igor B, Vitaly Wool

From: Igor B <igor.b@beldev.am>

The Rust blk-mq abstractions only cover what the null block driver
needs: requests can be started and ended, but a driver cannot find out
what a request asks for or reach its data.

For a driver that actually transfers data we need:

- A `bio` module with a `Bio` wrapper, an iterator over the bios of a
  request and an iterator over the single-page segments of a bio, the
  equivalent of rq_for_each_segment(). Segments can be copied to and
  from a `Page` and zeroed, with bounds checks. Iteration goes through
  two new C helpers wrapping bio_iter_iovec() and
  bio_advance_iter_single(), so the multi-page bvec handling stays in
  C.

- `Request::command()`, `Request::sector()`, `Request::bytes()` and
  `Request::bio_iter()`, exposing the operation, start sector, length
  and bios of a request. REQ_OP_MASK is added as a constant helper,
  since bindgen cannot evaluate it.

- `GenDiskBuilder::max_hw_discard_sectors()` and
  `GenDiskBuilder::discard_granularity()`, so drivers can advertise
  discard support.

These are used by the rbrd driver added in forthcoming patch.

Signed-off-by: Igor Belousov <igor.b@beldev.am>
Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>
---
 rust/bindings/bindings_helper.h  |   1 +
 rust/helpers/blk.c               |  14 ++
 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 +++++++++-
 7 files changed, 378 insertions(+), 2 deletions(-)
 create mode 100644 rust/kernel/block/bio.rs

diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index 3791af0aadc7..99b25d35b80a 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -124,6 +124,7 @@ const gfp_t RUST_CONST_HELPER___GFP_ZERO = __GFP_ZERO;
 const gfp_t RUST_CONST_HELPER___GFP_HIGHMEM = ___GFP_HIGHMEM;
 const gfp_t RUST_CONST_HELPER___GFP_NOWARN = ___GFP_NOWARN;
 const blk_features_t RUST_CONST_HELPER_BLK_FEAT_ROTATIONAL = BLK_FEAT_ROTATIONAL;
+const blk_opf_t RUST_CONST_HELPER_REQ_OP_MASK = REQ_OP_MASK;
 const fop_flags_t RUST_CONST_HELPER_FOP_UNSIGNED_OFFSET = FOP_UNSIGNED_OFFSET;
 
 const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;
diff --git a/rust/helpers/blk.c b/rust/helpers/blk.c
index 20c512e46a7a..f82cdb3b0875 100644
--- a/rust/helpers/blk.c
+++ b/rust/helpers/blk.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <linux/bio.h>
 #include <linux/blk-mq.h>
 #include <linux/blkdev.h>
 
@@ -12,3 +13,16 @@ __rust_helper struct request *rust_helper_blk_mq_rq_from_pdu(void *pdu)
 {
 	return blk_mq_rq_from_pdu(pdu);
 }
+
+__rust_helper struct bio_vec rust_helper_bio_iter_iovec(struct bio *bio,
+							 const struct bvec_iter *iter)
+{
+	return bio_iter_iovec(bio, *iter);
+}
+
+__rust_helper void rust_helper_bio_advance_iter_single(const struct bio *bio,
+							struct bvec_iter *iter,
+							unsigned int bytes)
+{
+	bio_advance_iter_single(bio, iter, bytes);
+}
diff --git a/rust/kernel/block.rs b/rust/kernel/block.rs
index 32c8d865afb6..17de727bc104 100644
--- a/rust/kernel/block.rs
+++ b/rust/kernel/block.rs
@@ -2,6 +2,7 @@
 
 //! Types for working with the block layer.
 
+pub mod bio;
 pub mod mq;
 
 /// Bit mask for masking out [`SECTOR_SIZE`].
diff --git a/rust/kernel/block/bio.rs b/rust/kernel/block/bio.rs
new file mode 100644
index 000000000000..183f9ae6d48d
--- /dev/null
+++ b/rust/kernel/block/bio.rs
@@ -0,0 +1,253 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! Types for working with the C `struct bio`.
+//!
+//! C header: [`include/linux/bio.h`](srctree/include/linux/bio.h)
+//! C header: [`include/linux/blk_types.h`](srctree/include/linux/blk_types.h)
+
+use crate::{
+    bindings,
+    page::Page,
+    prelude::*,
+    types::Opaque, //
+};
+use core::{
+    marker::PhantomData,
+    ptr, //
+};
+
+/// A wrapper around a C [`struct bio`].
+///
+/// # Invariants
+///
+/// `self.0` is a valid `struct bio` that is part of a request owned by the
+/// driver. Neither the bio nor its data pages are released while a `&Bio` is
+/// alive.
+///
+/// [`struct bio`]: srctree/include/linux/blk_types.h
+#[repr(transparent)]
+pub struct Bio(Opaque<bindings::bio>);
+
+impl Bio {
+    /// Create a reference to a [`Bio`] from a raw pointer.
+    ///
+    /// # Safety
+    ///
+    /// `ptr` must point to a valid `struct bio` that stays valid, and is not
+    /// modified by anyone but the holder of the returned reference, for the
+    /// duration of `'a`.
+    pub(crate) unsafe fn from_raw<'a>(ptr: *mut bindings::bio) -> &'a Self {
+        // SAFETY: `Bio` is `repr(transparent)` over `bindings::bio`, and the
+        // safety requirements of this function make the reference valid.
+        unsafe { &*ptr.cast::<Self>() }
+    }
+
+    fn raw(&self) -> *mut bindings::bio {
+        self.0.get()
+    }
+
+    /// Return the start sector of the bio.
+    pub fn sector(&self) -> u64 {
+        // SAFETY: By the type invariant `self.raw()` is valid. Taking the field
+        // by value avoids creating a reference into the packed `bi_iter`.
+        let iter = unsafe { (*self.raw()).bi_iter };
+        iter.bi_sector
+    }
+
+    /// Return the remaining size of the bio in bytes.
+    pub fn size(&self) -> u32 {
+        // SAFETY: By the type invariant `self.raw()` is valid.
+        let iter = unsafe { (*self.raw()).bi_iter };
+        iter.bi_size
+    }
+
+    /// Return an iterator over the single-page segments of this bio.
+    ///
+    /// This is the equivalent of the C `bio_for_each_segment()` macro.
+    pub fn segment_iter(&self) -> SegmentIter<'_> {
+        SegmentIter {
+            bio: self,
+            // SAFETY: By the type invariant `self.raw()` is valid.
+            iter: unsafe { (*self.raw()).bi_iter },
+        }
+    }
+
+    /// Return the next bio in the chain, if any.
+    pub(crate) fn next(&self) -> Option<&Self> {
+        // SAFETY: By the type invariant `self.raw()` is valid.
+        let next = unsafe { (*self.raw()).bi_next };
+        if next.is_null() {
+            None
+        } else {
+            // SAFETY: Bios chained to a request owned by the driver are valid
+            // for as long as the request is owned by the driver, which by the
+            // type invariant outlives `&self`.
+            Some(unsafe { Self::from_raw(next) })
+        }
+    }
+}
+
+/// An iterator over the [`Bio`]s of a request.
+///
+/// Created by [`Request::bio_iter`](super::mq::Request::bio_iter).
+pub struct BioIter<'a> {
+    pub(crate) bio: Option<&'a Bio>,
+}
+
+impl<'a> Iterator for BioIter<'a> {
+    type Item = &'a Bio;
+
+    fn next(&mut self) -> Option<&'a Bio> {
+        let current = self.bio?;
+        self.bio = current.next();
+        Some(current)
+    }
+}
+
+/// An iterator over the single-page segments of a [`Bio`].
+pub struct SegmentIter<'a> {
+    bio: &'a Bio,
+    iter: bindings::bvec_iter,
+}
+
+impl<'a> Iterator for SegmentIter<'a> {
+    type Item = Segment<'a>;
+
+    fn next(&mut self) -> Option<Segment<'a>> {
+        if self.iter.bi_size == 0 {
+            return None;
+        }
+
+        let sector = self.iter.bi_sector;
+
+        // SAFETY: By the type invariant of `Bio`, `self.bio.raw()` is valid,
+        // and `self.iter` is a copy of its `bi_iter` that was only advanced
+        // through `bio_advance_iter_single`, so it is within bounds.
+        let bvec = unsafe { bindings::bio_iter_iovec(self.bio.raw(), &self.iter) };
+
+        // SAFETY: As above. `bvec.bv_len` is at most `self.iter.bi_size`.
+        unsafe { bindings::bio_advance_iter_single(self.bio.raw(), &mut self.iter, bvec.bv_len) };
+
+        // INVARIANT: `bio_iter_iovec` returns a segment that does not cross a
+        // page boundary and that lies within the data buffer of the bio.
+        Some(Segment {
+            bvec,
+            sector,
+            _p: PhantomData,
+        })
+    }
+}
+
+/// A single-page segment of the data buffer of a [`Bio`].
+///
+/// # Invariants
+///
+/// - `bvec.bv_page` is a valid page for the lifetime `'a`.
+/// - `bvec.bv_offset + bvec.bv_len <= PAGE_SIZE`.
+pub struct Segment<'a> {
+    bvec: bindings::bio_vec,
+    sector: u64,
+    _p: PhantomData<&'a Bio>,
+}
+
+impl Segment<'_> {
+    /// Return the length of the segment in bytes.
+    pub fn len(&self) -> usize {
+        self.bvec.bv_len as usize
+    }
+
+    /// Return `true` if the segment is empty.
+    pub fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
+
+    /// Return the device sector this segment starts at.
+    pub fn sector(&self) -> u64 {
+        self.sector
+    }
+
+    /// Map the segment and call `f` with a pointer to byte `off` of the
+    /// segment, after checking that `off..off + len` is within the segment.
+    fn with_mapped(&self, off: usize, len: usize, f: impl FnOnce(*mut u8) -> Result) -> Result {
+        match off.checked_add(len) {
+            Some(end) if end <= self.len() => {}
+            _ => return Err(EINVAL),
+        }
+
+        // SAFETY: By the type invariant, `bv_page` is a valid page.
+        let mapped = unsafe { bindings::kmap_local_page(self.bvec.bv_page) };
+        let addr = mapped.cast::<u8>();
+
+        // SAFETY: By the type invariant and the check above,
+        // `bv_offset + off + len <= PAGE_SIZE`, so the result is within the
+        // mapped page.
+        let res = f(unsafe { addr.add(self.bvec.bv_offset as usize + off) });
+
+        // SAFETY: `mapped` was returned by the `kmap_local_page` call above,
+        // and any mapping created by `f` has already been released, so
+        // mappings are released in reverse order.
+        unsafe { bindings::kunmap_local(mapped) };
+
+        res
+    }
+
+    /// Copy `len` bytes starting at byte `off` of this segment into `dst`
+    /// starting at `dst_off`.
+    ///
+    /// Returns [`EINVAL`] if either range is out of bounds.
+    ///
+    /// # Safety
+    ///
+    /// The caller must ensure that this call does not race with a read or
+    /// write of the same range of `dst`.
+    pub unsafe fn copy_to_page(
+        &self,
+        off: usize,
+        dst: &Page,
+        dst_off: usize,
+        len: usize,
+    ) -> Result {
+        self.with_mapped(off, len, |src| {
+            // SAFETY: `src` is valid for reading `len` bytes, and the caller
+            // guarantees there is no racing access to `dst`.
+            unsafe { dst.write_raw(src, dst_off, len) }
+        })
+    }
+
+    /// Copy `len` bytes from `src` starting at `src_off` into this segment
+    /// starting at byte `off`.
+    ///
+    /// Returns [`EINVAL`] if either range is out of bounds.
+    ///
+    /// # Safety
+    ///
+    /// The caller must ensure that this call does not race with a write to the
+    /// same range of `src`.
+    pub unsafe fn copy_from_page(
+        &self,
+        off: usize,
+        src: &Page,
+        src_off: usize,
+        len: usize,
+    ) -> Result {
+        self.with_mapped(off, len, |dst| {
+            // SAFETY: `dst` is valid for writing `len` bytes. The data buffer
+            // of the bio is owned by the driver while the request is in
+            // flight. The caller guarantees there is no racing write to `src`.
+            unsafe { src.read_raw(dst, src_off, len) }
+        })
+    }
+
+    /// Fill `len` bytes starting at byte `off` of this segment with zeroes.
+    ///
+    /// Returns [`EINVAL`] if the range is out of bounds.
+    pub fn zero(&self, off: usize, len: usize) -> Result {
+        self.with_mapped(off, len, |dst| {
+            // SAFETY: `dst` is valid for writing `len` bytes. The data buffer
+            // of the bio is owned by the driver while the request is in
+            // flight.
+            unsafe { ptr::write_bytes(dst, 0, len) };
+            Ok(())
+        })
+    }
+}
diff --git a/rust/kernel/block/mq.rs b/rust/kernel/block/mq.rs
index 1fd0d54dd549..cb5b699630d8 100644
--- a/rust/kernel/block/mq.rs
+++ b/rust/kernel/block/mq.rs
@@ -99,5 +99,8 @@
 mod tag_set;
 
 pub use operations::Operations;
-pub use request::Request;
+pub use request::{
+    Command,
+    Request, //
+};
 pub use tag_set::TagSet;
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 0fe640f3aec6..57d543165430 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -37,6 +37,8 @@ pub struct GenDiskBuilder {
     logical_block_size: u32,
     physical_block_size: u32,
     capacity_sectors: u64,
+    max_hw_discard_sectors: u32,
+    discard_granularity: u32,
 }
 
 impl Default for GenDiskBuilder {
@@ -46,6 +48,8 @@ fn default() -> Self {
             logical_block_size: bindings::PAGE_SIZE as u32,
             physical_block_size: bindings::PAGE_SIZE as u32,
             capacity_sectors: 0,
+            max_hw_discard_sectors: 0,
+            discard_granularity: 0,
         }
     }
 }
@@ -106,6 +110,25 @@ pub fn capacity_sectors(mut self, capacity: u64) -> Self {
         self
     }
 
+    /// Set the maximum number of sectors (512 bytes) the device can discard in
+    /// a single request.
+    ///
+    /// Zero, the default, means that the device does not support discard.
+    pub fn max_hw_discard_sectors(mut self, sectors: u32) -> Self {
+        self.max_hw_discard_sectors = sectors;
+        self
+    }
+
+    /// Set the discard granularity of the device in bytes.
+    ///
+    /// This is the internal allocation unit of the device. Discards smaller
+    /// than this, or not aligned to it, may not free any storage. Zero, the
+    /// default, lets the block layer use the logical block size.
+    pub fn discard_granularity(mut self, granularity: u32) -> Self {
+        self.discard_granularity = granularity;
+        self
+    }
+
     /// Build a new `GenDisk` and add it to the VFS.
     pub fn build<T: Operations>(
         self,
@@ -123,6 +146,8 @@ pub fn build<T: Operations>(
 
         lim.logical_block_size = self.logical_block_size;
         lim.physical_block_size = self.physical_block_size;
+        lim.max_hw_discard_sectors = self.max_hw_discard_sectors;
+        lim.discard_granularity = self.discard_granularity;
         if self.rotational {
             lim.features = bindings::BLK_FEAT_ROTATIONAL;
         }
diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
index 6115f9aec228..aaaac88d8ae0 100644
--- a/rust/kernel/block/mq/request.rs
+++ b/rust/kernel/block/mq/request.rs
@@ -6,7 +6,13 @@
 
 use crate::{
     bindings,
-    block::mq::Operations,
+    block::{
+        bio::{
+            Bio,
+            BioIter, //
+        },
+        mq::Operations, //
+    },
     prelude::*,
     sync::{
         aref::{
@@ -165,6 +171,62 @@ pub fn complete(this: ARef<Self>) {
         }
     }
 
+    /// Return the operation requested by this request.
+    pub fn command(&self) -> Command {
+        // SAFETY: By type invariant, `self.0` is a valid `struct request`.
+        // `cmd_flags` is not modified while the request is owned by the driver.
+        let op = unsafe { (*self.0.get()).cmd_flags } & bindings::REQ_OP_MASK;
+
+        match op {
+            bindings::req_op_REQ_OP_READ => Command::Read,
+            bindings::req_op_REQ_OP_WRITE => Command::Write,
+            bindings::req_op_REQ_OP_FLUSH => Command::Flush,
+            bindings::req_op_REQ_OP_DISCARD => Command::Discard,
+            bindings::req_op_REQ_OP_WRITE_ZEROES => Command::WriteZeroes,
+            op => Command::Other(op),
+        }
+    }
+
+    /// Return the start sector of the request.
+    ///
+    /// This is the equivalent of the C `blk_rq_pos()` function.
+    pub fn sector(&self) -> u64 {
+        // SAFETY: By type invariant, `self.0` is a valid `struct request`.
+        // `__sector` is not modified by the block layer while the request is
+        // owned by the driver.
+        unsafe { (*self.0.get()).__sector }
+    }
+
+    /// Return the number of bytes remaining in the request.
+    ///
+    /// This is the equivalent of the C `blk_rq_bytes()` function.
+    pub fn bytes(&self) -> u32 {
+        // SAFETY: By type invariant, `self.0` is a valid `struct request`.
+        // `__data_len` is not modified by the block layer while the request is
+        // owned by the driver.
+        unsafe { (*self.0.get()).__data_len }
+    }
+
+    /// Return an iterator over the [`Bio`]s attached to the request.
+    ///
+    /// Use [`Bio::segment_iter`] on each to visit all data segments, which is
+    /// the equivalent of the C `rq_for_each_segment()` macro.
+    pub fn bio_iter(&self) -> BioIter<'_> {
+        // SAFETY: By type invariant, `self.0` is a valid `struct request`.
+        let bio = unsafe { (*self.0.get()).bio };
+
+        BioIter {
+            bio: if bio.is_null() {
+                None
+            } else {
+                // SAFETY: The existence of `&self` implies the request is
+                // owned by the driver, so its bios stay valid and are not
+                // modified by the block layer for the lifetime of `&self`.
+                Some(unsafe { Bio::from_raw(bio) })
+            },
+        }
+    }
+
     /// Return a pointer to the [`RequestDataWrapper`] stored in the private area
     /// of the request structure.
     ///
@@ -194,6 +256,23 @@ pub(crate) fn wrapper_ref(&self) -> &RequestDataWrapper {
     }
 }
 
+/// The operation of a [`Request`].
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Command {
+    /// Read sectors from the device.
+    Read,
+    /// Write sectors to the device.
+    Write,
+    /// Flush the volatile write cache.
+    Flush,
+    /// Discard sectors.
+    Discard,
+    /// Write zeroes to a range of sectors.
+    WriteZeroes,
+    /// Any other operation, carrying the raw C `enum req_op` value.
+    Other(u32),
+}
+
 /// A wrapper around data stored in the private area of the C [`struct request`].
 ///
 /// [`struct request`]: srctree/include/linux/blk-mq.h
-- 
2.39.5



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

* [PATCH 2/3] rust: page: add reference counting, raw pointers and a private bit lock
  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-17 23:32 ` Vitaly Wool
  2026-11-18 15:23   ` Andreas Hindborg
  2026-11-18 23:36   ` sashiko-bot
  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
  3 siblings, 2 replies; 11+ 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, Igor B, Vitaly Wool

From: Igor B <igor.b@beldev.am>

A `Page` always owns its page exclusively, with no way to take another
reference or keep it as a raw pointer. Add:

- `Page::get()`, which takes another reference with `get_page()`;
- `Page::into_raw()` and `Page::from_raw()`, to convert a `Page` to and
  from the `struct page` pointer it holds a reference to;
- `Page::try_get_raw()`, which takes a reference from a possibly stale
  pointer with `get_page_unless_zero()`, for lock-free lookups like
  brd_lookup_page(). This is sound because a `struct page` is never
  freed, even once its memory is;
- `Page::lock_private_bit()`, which takes a bit spinlock in the page's
  `private` field and returns a guard that releases it. This gives a
  page used as plain memory a lock of its own at no memory cost.

Add Rust helpers for `get_page()`, `get_page_unless_zero()`,
`bit_spin_lock()` and `bit_spin_unlock()`.

This patch was tested with the help of  Claude Code AI coding assistant.

Signed-off-by: Igor Belousov <igor.b@beldev.am>
Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>
---
 rust/helpers/bit_spinlock.c |  13 +++
 rust/helpers/helpers.c      |   1 +
 rust/helpers/page.c         |  10 +++
 rust/kernel/page.rs         | 160 ++++++++++++++++++++++++++++++++++++
 4 files changed, 184 insertions(+)
 create mode 100644 rust/helpers/bit_spinlock.c

diff --git a/rust/helpers/bit_spinlock.c b/rust/helpers/bit_spinlock.c
new file mode 100644
index 000000000000..5c59632bd171
--- /dev/null
+++ b/rust/helpers/bit_spinlock.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/bit_spinlock.h>
+
+__rust_helper void rust_helper_bit_spin_lock(int bitnum, unsigned long *addr)
+{
+	bit_spin_lock(bitnum, addr);
+}
+
+__rust_helper void rust_helper_bit_spin_unlock(int bitnum, unsigned long *addr)
+{
+	bit_spin_unlock(bitnum, addr);
+}
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index d62c7be1ca7b..e955a33e3535 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -44,6 +44,7 @@
 #include "barrier.c"
 #include "binder.c"
 #include "bitmap.c"
+#include "bit_spinlock.c"
 #include "bitops.c"
 #include "blk.c"
 #include "bug.c"
diff --git a/rust/helpers/page.c b/rust/helpers/page.c
index f8463fbed2a2..9c287bfcc371 100644
--- a/rust/helpers/page.c
+++ b/rust/helpers/page.c
@@ -26,3 +26,13 @@ __rust_helper int rust_helper_page_to_nid(const struct page *page)
 	return page_to_nid(page);
 }
 #endif
+
+__rust_helper void rust_helper_get_page(struct page *page)
+{
+	get_page(page);
+}
+
+__rust_helper bool rust_helper_get_page_unless_zero(struct page *page)
+{
+	return get_page_unless_zero(page);
+}
diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
index 1c0796ea229f..e75d9efbcce6 100644
--- a/rust/kernel/page.rs
+++ b/rust/kernel/page.rs
@@ -12,6 +12,11 @@
         code::*,
         Result, //
     },
+    ffi::{
+        c_int,
+        c_ulong, //
+    },
+    types::NotThreadSafe,
     uaccess::UserSliceReader, //
 };
 use core::{
@@ -200,6 +205,139 @@ pub fn as_ptr(&self) -> *mut bindings::page {
         self.page.as_ptr()
     }
 
+    /// Takes an additional reference on this page.
+    ///
+    /// The returned [`Page`] independently owns one reference to the same page as `self`. The
+    /// page is only actually freed once every such [`Page`], including `self`, has been dropped.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use kernel::page::Page;
+    ///
+    /// let page = Page::alloc_page(GFP_KERNEL)?;
+    /// let page2 = page.get();
+    ///
+    /// drop(page);
+    /// // `page2` still keeps the page alive.
+    /// drop(page2);
+    /// # Ok::<(), kernel::alloc::AllocError>(())
+    /// ```
+    #[inline]
+    pub fn get(&self) -> Self {
+        // SAFETY: `self.page` is valid by the type invariant, and calling `get_page` on a page
+        // that is kept alive by `self` is always safe.
+        unsafe { bindings::get_page(self.page.as_ptr()) };
+        // INVARIANT: We just took a new reference to the page pointed to by `self.page`, so the
+        // new `Page` has ownership over that reference.
+        Self { page: self.page }
+    }
+
+    /// Consumes the [`Page`], returning the raw pointer to its `struct page`.
+    ///
+    /// The reference owned by `self` is not dropped: the caller becomes responsible for it, and
+    /// releases it by turning the pointer back into a [`Page`] with [`from_raw`](Self::from_raw).
+    #[inline]
+    pub fn into_raw(self) -> NonNull<bindings::page> {
+        ManuallyDrop::new(self).page
+    }
+
+    /// Takes back ownership of a page from a pointer returned by [`into_raw`](Self::into_raw).
+    ///
+    /// # Safety
+    ///
+    /// `ptr` must have been returned by [`Page::into_raw`], and the reference it stands for must
+    /// not have been taken back already, by an earlier call to this function.
+    #[inline]
+    pub unsafe fn from_raw(ptr: NonNull<bindings::page>) -> Self {
+        // INVARIANT: By the safety requirements of this function, `ptr` stands for a reference to a
+        // valid page that nobody else owns.
+        Self { page: ptr }
+    }
+
+    /// Attempts to take ownership of a page from a raw, possibly stale pointer.
+    ///
+    /// On success, returns a new [`Page`] that owns one reference to the page. On failure
+    /// (meaning the page's reference count had already reached zero, i.e. its last owner had
+    /// already released it), returns `None` without otherwise touching the page.
+    ///
+    /// This is the kernel's usual way of giving a lock-free, concurrent lookup (such as one
+    /// protected by the RCU read lock; see [`kernel::sync::rcu`](crate::sync::rcu)) a safe way to
+    /// turn a pointer it found into an owned reference, without taking any lock: unlike
+    /// [`get`](Self::get), this does not assume `ptr` is already known to be alive.
+    ///
+    /// # Safety
+    ///
+    /// `ptr` must point at a valid `struct page`. Note that, unlike most kernel objects, a
+    /// `struct page` is never freed or reused for a different purpose for as long as the system
+    /// is running: only the memory it describes is freed and may be reused once its reference
+    /// count drops to zero. It is therefore always safe to inspect and modify the reference count
+    /// through a `struct page` pointer that was, at some point, validly obtained, even if the
+    /// page has since been fully released by its last owner, as long as the pointer has not since
+    /// been reused to mean something other than a `struct page` pointer (which can only happen if
+    /// the caller itself reinterprets it as something else).
+    #[inline]
+    pub unsafe fn try_get_raw(ptr: NonNull<bindings::page>) -> Option<Self> {
+        // SAFETY: By the safety requirements of this function, `ptr` points at a valid
+        // `struct page`.
+        //
+        // INVARIANT: If this call returns `true`, then it has just incremented the reference
+        // count of the page pointed to by `ptr`, and we have ownership over that new reference.
+        if unsafe { bindings::get_page_unless_zero(ptr.as_ptr()) } {
+            Some(Self { page: ptr })
+        } else {
+            None
+        }
+    }
+
+    /// Returns a pointer to the `private` field of this page.
+    #[inline]
+    fn private_ptr(&self) -> *mut c_ulong {
+        // SAFETY: `self.page` points to a valid `struct page` by the type invariant. Taking the
+        // address of a field neither reads nor writes it.
+        unsafe { &raw mut (*self.as_ptr()).__bindgen_anon_1.__bindgen_anon_1.private }
+    }
+
+    /// Acquires bit `BIT` of the page's `private` field as a bit spinlock.
+    ///
+    /// Spins until the bit is clear, then sets it. The lock is released when the returned guard
+    /// is dropped. As with any spinlock, preemption is disabled while it is held. Bit spinlocks
+    /// are not tracked by lockdep.
+    ///
+    /// This gives a page that is used as plain memory, such as a page holding the contents of a
+    /// RAM disk, a lock of its own without growing any other structure.
+    ///
+    /// # Safety
+    ///
+    /// The caller must own the page's `private` field, and must only access it through this
+    /// function while the page is shared. This is the case for a page allocated with
+    /// [`Page::alloc_page`], which has `private` zeroed, as long as the page is never handed to
+    /// another user of `private`, such as the page cache.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use kernel::page::Page;
+    ///
+    /// let page = Page::alloc_page(GFP_KERNEL)?;
+    /// // SAFETY: `page` was just allocated, and its `private` field is only used here.
+    /// let guard = unsafe { page.lock_private_bit::<0>() };
+    /// drop(guard);
+    /// # Ok::<(), kernel::alloc::AllocError>(())
+    /// ```
+    #[inline]
+    pub unsafe fn lock_private_bit<const BIT: u32>(&self) -> PagePrivateBitGuard<'_, BIT> {
+        const { assert!(BIT < c_ulong::BITS) };
+        // SAFETY: `private_ptr()` returns a valid pointer, and the caller guarantees that the
+        // field is only accessed by bit spinlock operations.
+        unsafe { bindings::bit_spin_lock(BIT as c_int, self.private_ptr()) };
+        // INVARIANT: The lock was just acquired.
+        PagePrivateBitGuard {
+            page: self,
+            _not_send: NotThreadSafe,
+        }
+    }
+
     /// Get the node id containing this page.
     #[inline]
     pub fn nid(&self) -> i32 {
@@ -373,6 +511,28 @@ pub unsafe fn copy_from_user_slice_raw(
     }
 }
 
+/// A bit spinlock held in the `private` field of a [`Page`].
+///
+/// Created by [`Page::lock_private_bit`]. The lock is released when the guard is dropped.
+///
+/// # Invariants
+///
+/// The guard holds bit `BIT` of the `private` field of `page` locked.
+#[must_use = "the lock is released immediately when the guard is unused"]
+pub struct PagePrivateBitGuard<'a, const BIT: u32> {
+    page: &'a Page,
+    _not_send: NotThreadSafe,
+}
+
+impl<const BIT: u32> Drop for PagePrivateBitGuard<'_, BIT> {
+    #[inline]
+    fn drop(&mut self) {
+        // SAFETY: `private_ptr()` returns a valid pointer, and the lock is held by the type
+        // invariant.
+        unsafe { bindings::bit_spin_unlock(BIT as c_int, self.page.private_ptr()) };
+    }
+}
+
 impl Drop for Page {
     #[inline]
     fn drop(&mut self) {
-- 
2.39.5



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

* [PATCH 3/3] rust: block: add rbrd, a RAM backed block driver
  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-17 23:32 ` [PATCH 2/3] rust: page: add reference counting, raw pointers and a private bit lock Vitaly Wool
@ 2026-11-17 23:32 ` Vitaly Wool
  2026-11-18 23:36   ` sashiko-bot
  2026-11-18 11:43 ` [PATCH 0/3] " Jan Engelhardt
  3 siblings, 1 reply; 11+ 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

Add a RAM backed block driver written in Rust, based on rnull and
working like brd: pages are allocated on first write, unwritten areas
read as zeroes and discards free the pages they fully cover. Devices
are created through configfs, with `power`, `blocksize` and `size`
(MiB) attributes:

  mkdir /sys/kernel/config/rbrd/rram0
  echo 1 > /sys/kernel/config/rbrd/rram0/power    # adds /dev/rram0

Pages are kept in a flat array of atomic pointers allocated at power
on. Lookups take a speculative reference with `Page::try_get_raw()`
and re-check the slot, like brd_lookup_page(); inserts use a
compare-and-exchange and discards an exchange with null, so the I/O
path takes no lock. Copies to and from each page are serialized by
a bit spinlock in its `page->private`, as opposed to the existing
RAM block device driver which allows simultaneous reads and writes
to pages. Thus, this driver always keeps data integrity.

Requests are served from queue_rq() with GFP_NOWAIT allocations; on
failure the block layer retries with BLK_STS_RESOURCE. There is one
hardware queue per CPU, which also avoids mq-deadline, and a queue
depth of 32.

Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>
---
 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 +++++++++++++++++++++++++++++++++
 7 files changed, 630 insertions(+)
 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

diff --git a/MAINTAINERS b/MAINTAINERS
index ccbcdc0799b9..fcf1ea505101 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4886,6 +4886,7 @@ W:	https://rust-for-linux.com
 B:	https://github.com/Rust-for-Linux/linux/issues
 C:	https://rust-for-linux.zulipchat.com/#narrow/stream/Block
 T:	git https://github.com/Rust-for-Linux/linux.git rust-block-next
+F:	drivers/block/rbrd/
 F:	drivers/block/rnull/
 F:	rust/kernel/block.rs
 F:	rust/kernel/block/
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 858320b6ebb7..34face102851 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -18,6 +18,7 @@ if BLK_DEV
 
 source "drivers/block/null_blk/Kconfig"
 source "drivers/block/rnull/Kconfig"
+source "drivers/block/rbrd/Kconfig"
 
 config BLK_DEV_FD
 	tristate "Normal floppy disk support"
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 2d8096eb8cdf..54e3e06fbce1 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_BLK_DEV_RNBD)	+= rnbd/
 
 obj-$(CONFIG_BLK_DEV_NULL_BLK)	+= null_blk/
 obj-$(CONFIG_BLK_DEV_RUST_NULL) += rnull/
+obj-$(CONFIG_BLK_DEV_RUST_RAM) += rbrd/
 
 obj-$(CONFIG_BLK_DEV_UBLK)			+= ublk_drv.o
 obj-$(CONFIG_BLK_DEV_ZONED_LOOP) += zloop.o
diff --git a/drivers/block/rbrd/Kconfig b/drivers/block/rbrd/Kconfig
new file mode 100644
index 000000000000..94b836d3ff35
--- /dev/null
+++ b/drivers/block/rbrd/Kconfig
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Rust RAM backed block device driver configuration
+
+config BLK_DEV_RUST_RAM
+	tristate "Rust RAM block device driver (Experimental)"
+	depends on RUST && CONFIGFS_FS
+	help
+	  This is a RAM backed block device driver written in Rust, based
+	  on the Rust null block driver. Like the C brd driver, it stores
+	  device contents in pages allocated on demand. Devices are created
+	  and configured through configfs under /sys/kernel/config/rbrd/.
+
+	  Device contents are lost when a device is powered off or the
+	  module is unloaded.
+
+	  If unsure, say N.
diff --git a/drivers/block/rbrd/Makefile b/drivers/block/rbrd/Makefile
new file mode 100644
index 000000000000..b5e0c10b4bea
--- /dev/null
+++ b/drivers/block/rbrd/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_BLK_DEV_RUST_RAM) += rbrd_mod.o
+rbrd_mod-y := rbrd.o
diff --git a/drivers/block/rbrd/configfs.rs b/drivers/block/rbrd/configfs.rs
new file mode 100644
index 000000000000..0179bf2cb123
--- /dev/null
+++ b/drivers/block/rbrd/configfs.rs
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0
+
+use super::RamDisk;
+use kernel::{
+    block::mq::gen_disk::{
+        GenDisk,
+        GenDiskBuilder, //
+    },
+    configfs::{
+        self,
+        AttributeOperations, //
+    },
+    configfs_attrs,
+    fmt::Write as _,
+    new_mutex,
+    page::PAGE_SIZE,
+    prelude::*,
+    str::{
+        kstrtobool_bytes,
+        CString, //
+    },
+    sync::Mutex, //
+};
+
+pub(crate) fn subsystem() -> impl PinInit<kernel::configfs::Subsystem<Config>, Error> {
+    let item_type = configfs_attrs! {
+        container: configfs::Subsystem<Config>,
+        data: Config,
+        child: DeviceConfig,
+        attributes: [
+            features: 0,
+        ],
+    };
+
+    kernel::configfs::Subsystem::new(c"rbrd", item_type, try_pin_init!(Config {}))
+}
+
+#[pin_data]
+pub(crate) struct Config {}
+
+#[vtable]
+impl AttributeOperations<0> for Config {
+    type Data = Config;
+
+    fn show(_this: &Config, page: &mut [u8; PAGE_SIZE]) -> Result<usize> {
+        let mut writer = kernel::str::Formatter::new(page);
+        writer.write_str("blocksize,size,power\n")?;
+        Ok(writer.bytes_written())
+    }
+}
+
+#[vtable]
+impl configfs::GroupOperations for Config {
+    type Child = DeviceConfig;
+
+    fn make_group(
+        &self,
+        name: &CStr,
+    ) -> Result<impl PinInit<configfs::Group<DeviceConfig>, Error>> {
+        let item_type = configfs_attrs! {
+            container: configfs::Group<DeviceConfig>,
+            data: DeviceConfig,
+            attributes: [
+                power: 0,
+                blocksize: 1,
+                size: 2,
+            ],
+        };
+
+        Ok(configfs::Group::new(
+            name.try_into()?,
+            item_type,
+            try_pin_init!(DeviceConfig {
+                data <- new_mutex!(DeviceConfigInner {
+                    powered: false,
+                    block_size: 512,
+                    disk: None,
+                    capacity_mib: 64,
+                    name: name.try_into()?,
+                }),
+            }),
+        ))
+    }
+}
+
+#[pin_data]
+pub(crate) struct DeviceConfig {
+    #[pin]
+    data: Mutex<DeviceConfigInner>,
+}
+
+#[pin_data]
+struct DeviceConfigInner {
+    powered: bool,
+    name: CString,
+    block_size: u32,
+    capacity_mib: u64,
+    disk: Option<GenDisk<RamDisk>>,
+}
+
+#[vtable]
+impl configfs::AttributeOperations<0> for DeviceConfig {
+    type Data = DeviceConfig;
+
+    fn show(this: &DeviceConfig, page: &mut [u8; PAGE_SIZE]) -> Result<usize> {
+        let mut writer = kernel::str::Formatter::new(page);
+
+        if this.data.lock().powered {
+            writer.write_str("1\n")?;
+        } else {
+            writer.write_str("0\n")?;
+        }
+
+        Ok(writer.bytes_written())
+    }
+
+    fn store(this: &DeviceConfig, page: &[u8]) -> Result {
+        let power_op = kstrtobool_bytes(page)?;
+        let mut guard = this.data.lock();
+
+        if !guard.powered && power_op {
+            guard.disk = Some(RamDisk::new(
+                &guard.name,
+                guard.block_size,
+                guard.capacity_mib,
+            )?);
+            guard.powered = true;
+        } else if guard.powered && !power_op {
+            // Removes the disk and frees all of its contents.
+            drop(guard.disk.take());
+            guard.powered = false;
+        }
+
+        Ok(())
+    }
+}
+
+#[vtable]
+impl configfs::AttributeOperations<1> for DeviceConfig {
+    type Data = DeviceConfig;
+
+    fn show(this: &DeviceConfig, page: &mut [u8; PAGE_SIZE]) -> Result<usize> {
+        let mut writer = kernel::str::Formatter::new(page);
+        writer.write_fmt(fmt!("{}\n", this.data.lock().block_size))?;
+        Ok(writer.bytes_written())
+    }
+
+    fn store(this: &DeviceConfig, page: &[u8]) -> Result {
+        let mut guard = this.data.lock();
+        if guard.powered {
+            return Err(EBUSY);
+        }
+
+        let text = core::str::from_utf8(page)?.trim();
+        let value = text.parse::<u32>().map_err(|_| EINVAL)?;
+
+        GenDiskBuilder::validate_block_size(value)?;
+        guard.block_size = value;
+        Ok(())
+    }
+}
+
+#[vtable]
+impl configfs::AttributeOperations<2> for DeviceConfig {
+    type Data = DeviceConfig;
+
+    fn show(this: &DeviceConfig, page: &mut [u8; PAGE_SIZE]) -> Result<usize> {
+        let mut writer = kernel::str::Formatter::new(page);
+        writer.write_fmt(fmt!("{}\n", this.data.lock().capacity_mib))?;
+        Ok(writer.bytes_written())
+    }
+
+    fn store(this: &DeviceConfig, page: &[u8]) -> Result {
+        let mut guard = this.data.lock();
+        if guard.powered {
+            return Err(EBUSY);
+        }
+
+        let text = core::str::from_utf8(page)?.trim();
+        let value = text.parse::<u64>().map_err(|_| EINVAL)?;
+        if value == 0 {
+            return Err(EINVAL);
+        }
+
+        guard.capacity_mib = value;
+        Ok(())
+    }
+}
diff --git a/drivers/block/rbrd/rbrd.rs b/drivers/block/rbrd/rbrd.rs
new file mode 100644
index 000000000000..e5e698172507
--- /dev/null
+++ b/drivers/block/rbrd/rbrd.rs
@@ -0,0 +1,420 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! A RAM backed block device driver written in Rust.
+//!
+//! The driver is based on the Rust null block driver and works like the C
+//! `brd` driver: every device stores its contents in pages that are allocated
+//! on the first write to them. Unlike `brd`, the pages are tracked in a flat
+//! array with one slot per page of the device, allocated when the device is
+//! created, instead of in an XArray. Reads of never written areas return
+//! zeroes. Discards free whole pages.
+//!
+//! Devices are created through configfs:
+//!
+//! ```text
+//! mkdir /sys/kernel/config/rbrd/rram0
+//! echo 512 > /sys/kernel/config/rbrd/rram0/size     # MiB
+//! echo 1 > /sys/kernel/config/rbrd/rram0/power      # creates /dev/rram0
+//! ```
+//!
+//! The contents of a device are lost when it is powered off.
+
+mod configfs;
+
+use kernel::{
+    bindings,
+    block::{
+        self,
+        bio::Segment,
+        mq::{
+            self,
+            gen_disk::{
+                self,
+                GenDisk, //
+            },
+            Command,
+            Operations,
+            TagSet, //
+        }, //
+    },
+    page::{
+        Page,
+        PagePrivateBitGuard,
+        PAGE_SHIFT,
+        PAGE_SIZE, //
+    },
+    prelude::*,
+    sync::{
+        aref::ARef,
+        atomic::{
+            Acquire,
+            Atomic,
+            Full,
+            Relaxed, //
+        },
+        Arc, //
+    }, //
+};
+
+use core::ptr::{
+    self,
+    NonNull, //
+};
+
+module! {
+    type: RamDiskModule,
+    name: "rbrd",
+    authors: ["Vitaly Wool"],
+    description: "Rust RAM backed block device driver",
+    license: "GPL v2",
+}
+
+#[pin_data]
+struct RamDiskModule {
+    #[pin]
+    configfs_subsystem: kernel::configfs::Subsystem<configfs::Config>,
+}
+
+impl kernel::InPlaceModule for RamDiskModule {
+    fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
+        pr_info!("Rust RAM block driver loaded\n");
+
+        try_pin_init!(Self {
+            configfs_subsystem <- configfs::subsystem(),
+        })
+    }
+}
+
+/// Maximum size of a single discard request.
+///
+/// Discards are processed in atomic context, page by page. Bound the amount of
+/// work done per request; larger discards are split by the block layer.
+const MAX_DISCARD_SECTORS: u32 = (128 << 20) >> block::SECTOR_SHIFT;
+
+/// GFP flags for allocations in the I/O path, which must not sleep.
+fn io_gfp() -> kernel::alloc::Flags {
+    GFP_NOWAIT | __GFP_NOWARN
+}
+
+struct RamDisk;
+
+impl RamDisk {
+    fn new(name: &CStr, block_size: u32, capacity_mib: u64) -> Result<GenDisk<Self>> {
+        if capacity_mib == 0 {
+            return Err(EINVAL);
+        }
+
+        let capacity_sectors = capacity_mib
+            .checked_mul(1 << (20 - block::SECTOR_SHIFT))
+            .ok_or(EINVAL)?;
+        let nr_pages = usize::try_from(capacity_mib)?
+            .checked_mul((1 << 20) / PAGE_SIZE)
+            .ok_or(EINVAL)?;
+
+        // One hardware queue per CPU. Besides avoiding contention on a single
+        // hardware context, this keeps blk-mq from attaching the mq-deadline
+        // scheduler, which it does by default for single queue devices.
+        //
+        // Requests are completed within `queue_rq()`, which releases their tag
+        // right away, so only a few tags per queue are ever in use at once. A
+        // small depth keeps the requests preallocated for every queue cheap.
+        let tagset = Arc::pin_init(TagSet::new(kernel::cpu::nr_cpu_ids(), 32, 1), GFP_KERNEL)?;
+        let storage = KBox::try_pin_init(Storage::new(nr_pages), GFP_KERNEL)?;
+
+        gen_disk::GenDiskBuilder::new()
+            .capacity_sectors(capacity_sectors)
+            .logical_block_size(block_size)?
+            .physical_block_size(block_size)?
+            .max_hw_discard_sectors(MAX_DISCARD_SECTORS)
+            .discard_granularity(PAGE_SIZE as u32)
+            .build(fmt!("{}", name.to_str()?), tagset, storage)
+    }
+}
+
+/// A flat array of page slots, one per page of the device.
+///
+/// Each slot is either null or holds a pointer obtained from
+/// [`Page::into_raw`], i.e. owns one reference to that page.
+struct PageArray(KVVec<Atomic<*mut bindings::page>>);
+
+impl PageArray {
+    fn new(nr_pages: usize) -> Result<Self> {
+        let mut slots = KVVec::with_capacity(nr_pages, GFP_KERNEL)?;
+        for _ in 0..nr_pages {
+            // Cannot fail: the capacity was reserved above.
+            slots.push(Atomic::new(ptr::null_mut()), GFP_KERNEL)?;
+        }
+        Ok(Self(slots))
+    }
+
+    fn slot(&self, index: usize) -> Option<&Atomic<*mut bindings::page>> {
+        self.0.get(index)
+    }
+}
+
+impl Drop for PageArray {
+    fn drop(&mut self) {
+        for slot in self.0.iter() {
+            if let Some(ptr) = NonNull::new(slot.xchg(ptr::null_mut(), Relaxed)) {
+                // SAFETY: Non-null slots hold pointers from `Page::into_raw`
+                // and own the reference they stand for, which we take back.
+                drop(unsafe { Page::from_raw(ptr) });
+            }
+        }
+    }
+}
+
+/// The backing store of a RAM disk.
+///
+/// Slot `n` of `pages` holds the page for bytes `n * PAGE_SIZE .. (n + 1) *
+/// PAGE_SIZE` of the device, or null if it was never written or since
+/// discarded.
+///
+/// The slot array is allocated up front and lives as long as the device, so,
+/// unlike the nodes of an XArray, it never needs RCU protection, and no lock is
+/// taken to look up, insert or remove a page: [`Self::lookup_page`] is an
+/// atomic load followed by a speculative reference (see [`Page::try_get_raw`]),
+/// [`Self::try_insert_page`] a compare-and-exchange on an empty slot, and
+/// [`Self::discard`] an exchange with null. The price is 8 bytes of slot per
+/// page of capacity, whether or not it is ever written.
+///
+/// Rust's raw page access requires that a page is not read and written, or
+/// written twice, concurrently, a guarantee the C `brd` driver does not itself
+/// provide for overlapping I/O. A bit spinlock in `page->private` of each
+/// backing page provides it here (see [`Storage::lock_copy`]). It is held only
+/// for the duration of a single copy, never while looking up, allocating or
+/// removing a page.
+#[pin_data]
+struct Storage {
+    pages: PageArray,
+}
+
+/// The bit of `page->private` that serializes copies to and from a backing
+/// page.
+const PAGE_COPY_LOCK_BIT: u32 = 0;
+
+impl Storage {
+    /// Locks the copy lock of a backing page.
+    fn lock_copy(page: &Page) -> PagePrivateBitGuard<'_, PAGE_COPY_LOCK_BIT> {
+        // SAFETY: Backing pages are allocated by this driver with
+        // `Page::alloc_page` and never handed to anybody else, and their
+        // `private` field is only used for this lock.
+        unsafe { page.lock_private_bit::<PAGE_COPY_LOCK_BIT>() }
+    }
+
+    fn new(nr_pages: usize) -> impl PinInit<Self, Error> {
+        try_pin_init!(Self {
+            pages: PageArray::new(nr_pages)?,
+        })
+    }
+
+    /// Looks up the page for `index`, without taking any lock.
+    ///
+    /// Takes a reference on the page in the slot with an operation that fails
+    /// if the page's reference count has already reached zero, i.e. if a
+    /// concurrent [`Self::discard`] already released it, and then re-reads the
+    /// slot to confirm it still holds the same page, retrying otherwise:
+    /// without that check, a page that was concurrently discarded and whose
+    /// memory was reused for something else in the meantime could be mistaken
+    /// for one that is still ours. See [`Page::try_get_raw`] for more on why
+    /// this is safe.
+    fn lookup_page(&self, index: usize) -> Option<Page> {
+        let slot = self.pages.slot(index)?;
+
+        loop {
+            let ptr = NonNull::new(slot.load(Acquire))?;
+
+            // SAFETY: Every non-null pointer stored in a slot came from
+            // `Page::into_raw`, i.e. is a `struct page` pointer; `struct page`
+            // objects are never freed or reused for anything else, so `ptr`
+            // always points at a valid one, whether or not it is (still)
+            // actually owned by this slot.
+            let Some(page) = (unsafe { Page::try_get_raw(ptr) }) else {
+                // The page's last reference was already dropped concurrently.
+                return None;
+            };
+
+            if slot.load(Relaxed) == ptr.as_ptr() {
+                return Some(page);
+            }
+
+            // The slot was concurrently emptied, or now holds a different
+            // page; `page` is not (or no longer) ours to use. Drop our
+            // reference and retry.
+            drop(page);
+        }
+    }
+
+    /// Allocates a page and installs it at `index` if the slot is still empty.
+    ///
+    /// Returns `None` if another writer installed a page there first, in which
+    /// case the caller looks it up again.
+    fn try_insert_page(&self, index: usize) -> Result<Option<Page>> {
+        let slot = self.pages.slot(index).ok_or(EIO)?;
+        let page = Page::alloc_page(io_gfp() | __GFP_ZERO | __GFP_HIGHMEM)?;
+        // Take our own reference before handing ownership of `page` to the
+        // slot, which keeps the other one.
+        let ours = page.get();
+        let ptr = page.into_raw();
+
+        // `Full` ordering publishes the zeroed page contents along with the
+        // pointer, pairing with the `Acquire` load in `lookup_page()`.
+        if slot.cmpxchg(ptr::null_mut(), ptr.as_ptr(), Full).is_ok() {
+            return Ok(Some(ours));
+        }
+
+        drop(ours);
+        // SAFETY: `ptr` came from `into_raw` above and was not stored, so we
+        // still own the reference it stands for.
+        drop(unsafe { Page::from_raw(ptr) });
+        Ok(None)
+    }
+
+    /// Transfer all data of `rq` between the request buffers and the backing
+    /// store.
+    fn transfer(&self, rq: &mq::Request<RamDisk>, write: bool) -> Result {
+        for bio in rq.bio_iter() {
+            for segment in bio.segment_iter() {
+                self.transfer_segment(&segment, write)?;
+            }
+        }
+        Ok(())
+    }
+
+    /// Transfer one segment, splitting it where it crosses a page boundary of
+    /// the backing store.
+    fn transfer_segment(&self, segment: &Segment<'_>, write: bool) -> Result {
+        let start = segment.sector() << block::SECTOR_SHIFT;
+        let mut done = 0;
+
+        // The block layer never issues I/O beyond the capacity of the device,
+        // which the array covers in full; check it once per segment.
+        if !segment.is_empty() {
+            let last = (start + segment.len() as u64 - 1) >> PAGE_SHIFT;
+            if usize::try_from(last)? >= self.pages.0.len() {
+                return Err(EIO);
+            }
+        }
+
+        while done < segment.len() {
+            let pos = start + done as u64;
+            let index = usize::try_from(pos >> PAGE_SHIFT)?;
+            let page_off = (pos as usize) & (PAGE_SIZE - 1);
+            let len = (segment.len() - done).min(PAGE_SIZE - page_off);
+
+            if write {
+                self.write_chunk(segment, done, index, page_off, len)?;
+            } else {
+                self.read_chunk(segment, done, index, page_off, len)?;
+            }
+
+            done += len;
+        }
+
+        Ok(())
+    }
+
+    fn read_chunk(
+        &self,
+        segment: &Segment<'_>,
+        off: usize,
+        index: usize,
+        page_off: usize,
+        len: usize,
+    ) -> Result {
+        match self.lookup_page(index) {
+            Some(page) => {
+                let _guard = Self::lock_copy(&page);
+                // SAFETY: the page's copy lock rules out a concurrent write to
+                // it.
+                unsafe { segment.copy_from_page(off, &page, page_off, len) }
+            }
+            // Never written; reads as zeroes.
+            None => segment.zero(off, len),
+        }
+    }
+
+    fn write_chunk(
+        &self,
+        segment: &Segment<'_>,
+        off: usize,
+        index: usize,
+        page_off: usize,
+        len: usize,
+    ) -> Result {
+        let page = loop {
+            if let Some(page) = self.lookup_page(index) {
+                break page;
+            }
+            if let Some(page) = self.try_insert_page(index)? {
+                break page;
+            }
+        };
+
+        let _guard = Self::lock_copy(&page);
+        // SAFETY: the page's copy lock rules out a concurrent read or write to
+        // it.
+        unsafe { segment.copy_to_page(off, &page, page_off, len) }
+    }
+
+    /// Free all backing pages that are entirely covered by the range.
+    fn discard(&self, sector: u64, bytes: u32) {
+        let start = sector << block::SECTOR_SHIFT;
+        let end = start + u64::from(bytes);
+        let first = start.div_ceil(PAGE_SIZE as u64);
+        let last = end >> PAGE_SHIFT;
+
+        for index in first..last {
+            let Some(slot) = usize::try_from(index)
+                .ok()
+                .and_then(|index| self.pages.0.get(index))
+            else {
+                break;
+            };
+
+            if let Some(ptr) = NonNull::new(slot.xchg(ptr::null_mut(), Full)) {
+                // SAFETY: Non-null slots hold pointers from `Page::into_raw`
+                // and own the reference they stand for, which we just took
+                // back by emptying the slot. A concurrent `lookup_page()` that
+                // already took its own reference keeps the page alive until
+                // that reference is dropped too.
+                drop(unsafe { Page::from_raw(ptr) });
+            }
+        }
+    }
+}
+
+#[vtable]
+impl Operations for RamDisk {
+    type QueueData = Pin<KBox<Storage>>;
+
+    fn queue_rq(storage: Pin<&Storage>, rq: ARef<mq::Request<Self>>, _is_last: bool) -> Result {
+        // On error, `rq` is dropped and the error is returned to the block
+        // layer, which ends the request. `ENOMEM` from a failed page allocation
+        // becomes `BLK_STS_RESOURCE`, which makes the block layer retry the
+        // request later. Retrying is safe, since every transfer is idempotent.
+        match rq.command() {
+            Command::Read => storage.transfer(&rq, false)?,
+            Command::Write => storage.transfer(&rq, true)?,
+            Command::Discard => storage.discard(rq.sector(), rq.bytes()),
+            // There is no volatile cache; data is in RAM once written.
+            Command::Flush => {}
+            Command::WriteZeroes | Command::Other(_) => return Err(EOPNOTSUPP),
+        }
+
+        mq::Request::end_ok(rq)
+            .map_err(|_e| kernel::error::code::EIO)
+            // We take no refcounts on the request, so we expect to be able to
+            // end the request. The request reference must be unique at this
+            // point, and so `end_ok` cannot fail.
+            .expect("Fatal error - expected to be able to end request");
+
+        Ok(())
+    }
+
+    fn commit_rqs(_storage: Pin<&Storage>) {}
+
+    fn complete(_rq: ARef<mq::Request<Self>>) {
+        // All requests are completed synchronously in `queue_rq`.
+    }
+}
-- 
2.39.5



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

* Re: [PATCH 0/3] rust: block: add rbrd, a RAM backed block driver
  2026-11-17 23:32 [PATCH 0/3] rust: block: add rbrd, a RAM backed block driver Vitaly Wool
                   ` (2 preceding siblings ...)
  2026-11-17 23:32 ` [PATCH 3/3] rust: block: add rbrd, a RAM backed block driver Vitaly Wool
@ 2026-11-18 11:43 ` Jan Engelhardt
  2026-11-18 14:48   ` Vitaly Wool
  3 siblings, 1 reply; 11+ messages in thread
From: Jan Engelhardt @ 2026-11-18 11:43 UTC (permalink / raw)
  To: Vitaly Wool
  Cc: Andreas Hindborg, Jens Axboe, Miguel Ojeda, Alice Ryhl,
	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


On Wednesday 2026-11-18 00:32, Vitaly Wool wrote:
>
>  test                  brd    rbrd   change
>  write, 8 threads     2004    1563    -22%
>
>We think this is a small price for page integrity

A free 28% improvement, just by using a C driver, and a bit of 
discipline in the program (not submitting the same page).
Supercomputing will be all over brd if they need a ramdisk.


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

* Re: Re: [PATCH 0/3] rust: block: add rbrd, a RAM backed block driver
  2026-11-18 11:43 ` [PATCH 0/3] " Jan Engelhardt
@ 2026-11-18 14:48   ` Vitaly Wool
  0 siblings, 0 replies; 11+ messages in thread
From: Vitaly Wool @ 2026-11-18 14:48 UTC (permalink / raw)
  To: Jan Engelhardt
  Cc: Andreas Hindborg, Jens Axboe, Miguel Ojeda, Alice Ryhl,
	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

> >
> >  test                  brd    rbrd   change
> >  write, 8 threads     2004    1563    -22%
> >
> >We think this is a small price for page integrity
>
> A free 28% improvement, just by using a C driver, and a bit of 
> discipline in the program (not submitting the same page).
> Supercomputing will be all over brd if they need a ramdisk.

The posted result were for Rapberry PI/QEMU, The more cores/
computing power we get, the better rbrd actually looks, so
supercomputing should not be worried.

As an example, on a Ryzen 9, median kIOPS over 3 test runs look
this way:

test		bs	brd (24 vCPU)
				rbrd (24 vCPU)
					rbrd/brd (24 vCPU)
						brd (16 vCPU)
							rbrd (16 vCPU)
								rbrd/brd (16 vCPU)
read		4k	4661	5207	112%	4411	5251	119%
read		64k	241	265	110%	177	189	107%
write		4k	2034	2597	128%	1942	2606	134%
write		64k	111	134	122%	105	131	124%
randread	4k	3508	4690	134%	3398	4853	143%
randread	64k	229	245	107%	170	188	111%
randwrite	4k	1833	2598	142%	1773	2680	151%
randwrite	64k	108	134	125%	104	132	127%

Maybe this is what we should have posted in the cover letter in the
first place :

~Vitaly


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

* Re: [PATCH 1/3] rust: block: add bio segment iteration and request accessors
  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-18 23:36   ` sashiko-bot
  1 sibling, 0 replies; 11+ messages in thread
From: Andreas Hindborg @ 2026-11-18 15:19 UTC (permalink / raw)
  To: Vitaly Wool, 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, Igor B, Vitaly Wool

Hi Vitaly,

"Vitaly Wool" <vitaly.wool@konsulko.se> writes:

> From: Igor B <igor.b@beldev.am>
>
> The Rust blk-mq abstractions only cover what the null block driver
> needs: requests can be started and ended, but a driver cannot find out
> what a request asks for or reach its data.
>
> For a driver that actually transfers data we need:
>
> - A `bio` module with a `Bio` wrapper, an iterator over the bios of a
>   request and an iterator over the single-page segments of a bio, the
>   equivalent of rq_for_each_segment(). Segments can be copied to and
>   from a `Page` and zeroed, with bounds checks. Iteration goes through
>   two new C helpers wrapping bio_iter_iovec() and
>   bio_advance_iter_single(), so the multi-page bvec handling stays in
>   C.
>
> - `Request::command()`, `Request::sector()`, `Request::bytes()` and
>   `Request::bio_iter()`, exposing the operation, start sector, length
>   and bios of a request. REQ_OP_MASK is added as a constant helper,
>   since bindgen cannot evaluate it.
>
> - `GenDiskBuilder::max_hw_discard_sectors()` and
>   `GenDiskBuilder::discard_granularity()`, so drivers can advertise
>   discard support.
>
> These are used by the rbrd driver added in forthcoming patch.
>
> Signed-off-by: Igor Belousov <igor.b@beldev.am>
> Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>

I already submitted this [1]. I have a version rebased on v7.4 if you are
interested.


Best regards,
Andreas Hindborg


[1] https://lore.kernel.org/all/20260216-rnull-v6-19-rc5-send-v1-0-de9a7af4b469@kernel.org/



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

* Re: [PATCH 2/3] rust: page: add reference counting, raw pointers and a private bit lock
  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-18 23:36   ` sashiko-bot
  1 sibling, 0 replies; 11+ messages in thread
From: Andreas Hindborg @ 2026-11-18 15:23 UTC (permalink / raw)
  To: Vitaly Wool, 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, Igor B, Vitaly Wool

"Vitaly Wool" <vitaly.wool@konsulko.se> writes:

> From: Igor B <igor.b@beldev.am>
>
> A `Page` always owns its page exclusively, with no way to take another
> reference or keep it as a raw pointer. Add:
>
> - `Page::get()`, which takes another reference with `get_page()`;
> - `Page::into_raw()` and `Page::from_raw()`, to convert a `Page` to and
>   from the `struct page` pointer it holds a reference to;
> - `Page::try_get_raw()`, which takes a reference from a possibly stale
>   pointer with `get_page_unless_zero()`, for lock-free lookups like
>   brd_lookup_page(). This is sound because a `struct page` is never
>   freed, even once its memory is;
> - `Page::lock_private_bit()`, which takes a bit spinlock in the page's
>   `private` field and returns a guard that releases it. This gives a
>   page used as plain memory a lock of its own at no memory cost.
>
> Add Rust helpers for `get_page()`, `get_page_unless_zero()`,
> `bit_spin_lock()` and `bit_spin_unlock()`.
>
> This patch was tested with the help of  Claude Code AI coding assistant.
>
> Signed-off-by: Igor Belousov <igor.b@beldev.am>
> Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>

I already submitted most of this as part of the `Ownable` work [1]. I
sent v22 of the `Ownable` series a few days ago [2]. I stripped out the
page stuff to send as a separate series. I plan to send the page things
this week. It covers both reference counted pages and frozen pages.

Best regards,
Andreas Hindborg

[1] https://lore.kernel.org/all/20260910-unique-ref-v21-0-e83257373062@kernel.org/
[2] https://lore.kernel.org/all/20261116-unique-ref-v22-0-12029383206d@kernel.org/



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

* Re: [PATCH 1/3] rust: block: add bio segment iteration and request accessors
  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-18 23:36   ` sashiko-bot
  1 sibling, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-18 23:36 UTC (permalink / raw)
  To: Vitaly Wool, 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-mm, Igor B

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] rust: block: NULL bi_io_vec dereference in
  SegmentIter::next()
- [Medium] rust: block: unsound safe Segment::zero() and copy_*_page()
  safety docs
- [Low] rust: block: wrong default block size in discard_granularity()
  docs
- [Low] rust: block: missing #[inline] and Bio::from_raw() INVARIANT
  comment
--

commit f73d6ca145fdbea749b64ff55a7ec48747dee38e
Author: Igor B <igor.b@beldev.am>

rust: block: add bio segment iteration and request accessors

This commit adds a Rust bio wrapper and segment iterator, request
accessors for command, sector, byte length, and bios, and GenDiskBuilder
helpers for configuring discard limits.

> diff --git a/rust/kernel/block/bio.rs b/rust/kernel/block/bio.rs
> new file mode 100644
> index 0000000000000..183f9ae6d48d9
> --- /dev/null
> +++ b/rust/kernel/block/bio.rs
> @@ -0,0 +1,253 @@

[ ... ]

> +/// A wrapper around a C [`struct bio`].
> +///
> +/// # Invariants
> +///
> +/// `self.0` is a valid `struct bio` that is part of a request owned by the
> +/// driver. Neither the bio nor its data pages are released while a `&Bio` is
> +/// alive.
> +///
> +/// [`struct bio`]: srctree/include/linux/blk_types.h
> +#[repr(transparent)]
> +pub struct Bio(Opaque<bindings::bio>);
> +
> +impl Bio {
> +    /// Create a reference to a [`Bio`] from a raw pointer.
> +    ///
> +    /// # Safety
> +    ///
> +    /// `ptr` must point to a valid `struct bio` that stays valid, and is not
> +    /// modified by anyone but the holder of the returned reference, for the
> +    /// duration of `'a`.
> +    pub(crate) unsafe fn from_raw<'a>(ptr: *mut bindings::bio) -> &'a Self {
> +        // SAFETY: `Bio` is `repr(transparent)` over `bindings::bio`, and the
> +        // safety requirements of this function make the reference valid.
> +        unsafe { &*ptr.cast::<Self>() }
> +    }

[Severity: Low]
Since struct Bio has an # Invariants section, Bio::from_raw() should have
an // INVARIANT: comment explaining how the caller's safety guarantees
satisfy those invariants.

Also, in the kernel crate abstractions, small functions and functions that
forward to C bindings should be marked #[inline]; none of the new methods in
rust/kernel/block/bio.rs, rust/kernel/block/mq/gen_disk.rs, or
rust/kernel/block/mq/request.rs have #[inline].

[ ... ]

> +    /// Return an iterator over the single-page segments of this bio.
> +    ///
> +    /// This is the equivalent of the C `bio_for_each_segment()` macro.
> +    pub fn segment_iter(&self) -> SegmentIter<'_> {
> +        SegmentIter {
> +            bio: self,
> +            // SAFETY: By the type invariant `self.raw()` is valid.
> +            iter: unsafe { (*self.raw()).bi_iter },
> +        }
> +    }

[ ... ]

> +impl<'a> Iterator for SegmentIter<'a> {
> +    type Item = Segment<'a>;
> +
> +    fn next(&mut self) -> Option<Segment<'a>> {
> +        if self.iter.bi_size == 0 {
> +            return None;
> +        }
> +
> +        let sector = self.iter.bi_sector;
> +
> +        // SAFETY: By the type invariant of `Bio`, `self.bio.raw()` is valid,
> +        // and `self.iter` is a copy of its `bi_iter` that was only advanced
> +        // through `bio_advance_iter_single`, so it is within bounds.
> +        let bvec = unsafe { bindings::bio_iter_iovec(self.bio.raw(), &self.iter) };

[Severity: Medium]
Can calling Bio::segment_iter() in safe Rust cause a NULL pointer
dereference in SegmentIter::next() on a discard or write-zeroes request?

In block/blk-lib.c, bios for REQ_OP_DISCARD, REQ_OP_WRITE_ZEROES, and
REQ_OP_SECURE_ERASE are allocated with nr_vecs = 0, which sets
bio->bi_io_vec = NULL while setting bio->bi_iter.bi_size to the non-zero
byte length of the operation (and REQ_DMABUF bios store bi_dmabuf_map in
the union with bi_io_vec).  Because Request::bio_iter() and
Bio::segment_iter() are safe functions and neither checks bio_has_data()
or !bio_no_advance_iter(), iterating segments of such a bio calls
bio_iter_iovec() with bi_size > 0 and dereferences a NULL (or non-bvec)
bi_io_vec pointer.

[ ... ]

> +    /// Copy `len` bytes starting at byte `off` of this segment into `dst`
> +    /// starting at `dst_off`.
> +    ///
> +    /// Returns [`EINVAL`] if either range is out of bounds.
> +    ///
> +    /// # Safety
> +    ///
> +    /// The caller must ensure that this call does not race with a read or
> +    /// write of the same range of `dst`.
> +    pub unsafe fn copy_to_page(
> +        &self,
> +        off: usize,
> +        dst: &Page,
> +        dst_off: usize,
> +        len: usize,
> +    ) -> Result {
> +        self.with_mapped(off, len, |src| {
> +            // SAFETY: `src` is valid for reading `len` bytes, and the caller
> +            // guarantees there is no racing access to `dst`.
> +            unsafe { dst.write_raw(src, dst_off, len) }
> +        })
> +    }
> +
> +    /// Copy `len` bytes from `src` starting at `src_off` into this segment
> +    /// starting at byte `off`.
> +    ///
> +    /// Returns [`EINVAL`] if either range is out of bounds.
> +    ///
> +    /// # Safety
> +    ///
> +    /// The caller must ensure that this call does not race with a write to the
> +    /// same range of `src`.
> +    pub unsafe fn copy_from_page(
> +        &self,
> +        off: usize,
> +        src: &Page,
> +        src_off: usize,
> +        len: usize,
> +    ) -> Result {
> +        self.with_mapped(off, len, |dst| {
> +            // SAFETY: `dst` is valid for writing `len` bytes. The data buffer
> +            // of the bio is owned by the driver while the request is in
> +            // flight. The caller guarantees there is no racing write to `src`.
> +            unsafe { src.read_raw(dst, src_off, len) }
> +        })
> +    }
> +
> +    /// Fill `len` bytes starting at byte `off` of this segment with zeroes.
> +    ///
> +    /// Returns [`EINVAL`] if the range is out of bounds.
> +    pub fn zero(&self, off: usize, len: usize) -> Result {
> +        self.with_mapped(off, len, |dst| {
> +            // SAFETY: `dst` is valid for writing `len` bytes. The data buffer
> +            // of the bio is owned by the driver while the request is in
> +            // flight.
> +            unsafe { ptr::write_bytes(dst, 0, len) };
> +            Ok(())
> +        })
> +    }
> +}

[Severity: Medium]
Is Segment::zero(&self, ...) sound as a safe method, and are the safety
contracts on copy_to_page() and copy_from_page() complete?

Request<T> implements Send, Sync, and AlwaysRefCounted, and
Request::bio_iter(), Bio::segment_iter(), and Segment::zero() all take
&self.  Two threads holding shared &Request<T> references (or a bio with
multiple bvecs referencing the same page) can call Segment::zero()
concurrently from safe Rust, causing a data race.  Moreover, on
REQ_OP_WRITE bios the segment pages are read-only source buffers that can
point to shared kernel pages such as largest_zero_folio() in
__blkdev_issue_zero_pages(), so writing to them via Segment::zero() or
Segment::copy_from_page() corrupts shared memory.

Segment::zero() should be unsafe (matching Page::fill_zero_raw()), and the
safety requirements for zero(), copy_from_page(), and copy_to_page()
should also require that no concurrent accesses race on the segment's own
page range and that mutating methods are only called on writable request
buffers.

> diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
> index 0fe640f3aec63..57d5431654303 100644
> --- a/rust/kernel/block/mq/gen_disk.rs
> +++ b/rust/kernel/block/mq/gen_disk.rs

[ ... ]

> @@ -106,6 +110,25 @@ pub fn capacity_sectors(mut self, capacity: u64) -> Self {
>          self
>      }
>  
> +    /// Set the maximum number of sectors (512 bytes) the device can discard in
> +    /// a single request.
> +    ///
> +    /// Zero, the default, means that the device does not support discard.
> +    pub fn max_hw_discard_sectors(mut self, sectors: u32) -> Self {
> +        self.max_hw_discard_sectors = sectors;
> +        self
> +    }
> +
> +    /// Set the discard granularity of the device in bytes.
> +    ///
> +    /// This is the internal allocation unit of the device. Discards smaller
> +    /// than this, or not aligned to it, may not free any storage. Zero, the
> +    /// default, lets the block layer use the logical block size.
> +    pub fn discard_granularity(mut self, granularity: u32) -> Self {
> +        self.discard_granularity = granularity;
> +        self
> +    }

[Severity: Low]
Does a discard_granularity of zero default to the logical block size or
the physical block size?

In block/blk-settings.c, blk_validate_limits() clamps
lim->discard_granularity with:

    lim->discard_granularity =
        max(lim->discard_granularity, lim->physical_block_size);

so leaving discard_granularity at zero causes the block layer to use
physical_block_size rather than logical_block_size.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117233211.3137168-1-vitaly.wool@konsulko.se?part=1


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

* Re: [PATCH 2/3] rust: page: add reference counting, raw pointers and a private bit lock
  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-18 23:36   ` sashiko-bot
  1 sibling, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-18 23:36 UTC (permalink / raw)
  To: Vitaly Wool, 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-mm, Igor B

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] rust: page: unsound speculative ref and __free_pages() drop in
  try_get_raw()
- [Medium] rust: page: BorrowedPage lifetime escape via Deref to
  Page::get()
--

commit ce2ee3f082c492cf922004e652ef173e3c507e27
Author: Igor B <igor.b@beldev.am>

rust: page: add reference counting, raw pointers and a private bit lock

This commit adds reference counting, raw pointer conversion helpers, and a
private bit spinlock to the Rust Page abstraction, along with the
underlying C helpers.

> diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
> index 1c0796ea229f0..e75d9efbcce63 100644
> --- a/rust/kernel/page.rs
> +++ b/rust/kernel/page.rs
[ ... ]
> @@ -200,6 +205,139 @@ pub fn as_ptr(&self) -> *mut bindings::page {
>          self.page.as_ptr()
>      }
>  
> +    /// Takes an additional reference on this page.
[ ... ]
> +    #[inline]
> +    pub fn get(&self) -> Self {
> +        // SAFETY: `self.page` is valid by the type invariant, and calling `get_page` on a page
> +        // that is kept alive by `self` is always safe.
> +        unsafe { bindings::get_page(self.page.as_ptr()) };
> +        // INVARIANT: We just took a new reference to the page pointed to by `self.page`, so the
> +        // new `Page` has ownership over that reference.
> +        Self { page: self.page }
> +    }

[Severity: Medium]
Does taking &self in Page::get() allow a non-owning BorrowedPage<'a> to
escape its borrow lifetime 'a in safe code?

BorrowedPage<'a> implements Deref<Target = Page>, so safe callers can call
borrowed_page.get() to obtain an owned Page with no lifetime bound.
For example, VBox::page_iter() and VVec::page_iter() yield BorrowedPage<'a>
items tied to a mutable borrow of the container; calling .get() lets safe
code retain and access the underlying physical page after 'a ends while
VBox/VVec holds exclusive mutable access or frees the memory.  In addition,
BorrowedPage::from_raw() only requires a valid struct page pointer for 'a,
not a refcounted order-0 page: if it wraps a slab or large_kmalloc page,
get_page() warns and returns without incrementing the refcount, and
dropping the returned Page calls __free_pages() without owning a reference.

> +
> +    /// Consumes the [`Page`], returning the raw pointer to its `struct page`.
[ ... ]
> +    /// Attempts to take ownership of a page from a raw, possibly stale pointer.
> +    ///
> +    /// On success, returns a new [`Page`] that owns one reference to the page. On failure
> +    /// (meaning the page's reference count had already reached zero, i.e. its last owner had
> +    /// already released it), returns `None` without otherwise touching the page.
> +    ///
> +    /// This is the kernel's usual way of giving a lock-free, concurrent lookup (such as one
> +    /// protected by the RCU read lock; see [`kernel::sync::rcu`](crate::sync::rcu)) a safe way to
> +    /// turn a pointer it found into an owned reference, without taking any lock: unlike
> +    /// [`get`](Self::get), this does not assume `ptr` is already known to be alive.
> +    ///
> +    /// # Safety
> +    ///
> +    /// `ptr` must point at a valid `struct page`. Note that, unlike most kernel objects, a
> +    /// `struct page` is never freed or reused for a different purpose for as long as the system
> +    /// is running: only the memory it describes is freed and may be reused once its reference
> +    /// count drops to zero. It is therefore always safe to inspect and modify the reference count
> +    /// through a `struct page` pointer that was, at some point, validly obtained, even if the
> +    /// page has since been fully released by its last owner, as long as the pointer has not since
> +    /// been reused to mean something other than a `struct page` pointer (which can only happen if
> +    /// the caller itself reinterprets it as something else).
> +    #[inline]
> +    pub unsafe fn try_get_raw(ptr: NonNull<bindings::page>) -> Option<Self> {
> +        // SAFETY: By the safety requirements of this function, `ptr` points at a valid
> +        // `struct page`.
> +        //
> +        // INVARIANT: If this call returns `true`, then it has just incremented the reference
> +        // count of the page pointed to by `ptr`, and we have ownership over that new reference.
> +        if unsafe { bindings::get_page_unless_zero(ptr.as_ptr()) } {
> +            Some(Self { page: ptr })
> +        } else {
> +            None
> +        }
> +    }

[Severity: High]
Can Page::try_get_raw() acquire a speculative reference to a page that was
freed and reallocated to another kernel subsystem, and then release it with
__free_pages(ptr, 0) instead of put_page()?

CPU0                              CPU1
----                              ----
ptr = load page slot
                                  drop(last_page_owner)
                                    __free_pages(ptr, 0)
                                  page reallocated (e.g. compound
                                  or LRU folio, refcount >= 1)
Page::try_get_raw(ptr)
  get_page_unless_zero(ptr) -> true
                                  new owner drops its ref
slot check fails:
drop(page)
  __free_pages(ptr, 0)  <-- VM_BUG_ON_PAGE / bad_page()

Because Page::drop() frees pages immediately via __free_pages(ptr, 0)
without an RCU grace period, the struct page at ptr can be reallocated to
an unrelated user (such as a higher-order compound folio or an LRU/memcg
folio) before get_page_unless_zero() runs.  get_page_unless_zero() then
succeeds on the new allocation.  Unlike C's brd_lookup_page(), which
releases a mismatched speculative reference with put_page() (calling
folio_put()), dropping the returned Page calls __free_pages(ptr, 0):

rust/kernel/page.rs:<Page as Drop>::drop() {
    unsafe { bindings::__free_pages(self.page.as_ptr(), 0) };
}

As noted on __free_pages() in mm/page_alloc.c, speculative references must
be dropped with put_page() rather than __free_pages(); calling
__free_pages(ptr, 0) on a compound or LRU folio triggers VM_BUG_ON_PAGE(
compound && compound_order(page) != order) in __free_pages_prepare() or
bad_page() when freeing a page still on an LRU list.

In addition, the Safety contract of try_get_raw() does not require the
caller to re-validate the lookup slot after get_page_unless_zero() succeeds
before accessing the returned Page.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117233211.3137168-1-vitaly.wool@konsulko.se?part=2


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

* Re: [PATCH 3/3] rust: block: add rbrd, a RAM backed block driver
  2026-11-17 23:32 ` [PATCH 3/3] rust: block: add rbrd, a RAM backed block driver Vitaly Wool
@ 2026-11-18 23:36   ` sashiko-bot
  0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-18 23:36 UTC (permalink / raw)
  To: Vitaly Wool, 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-mm

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] rbrd: dropping speculative page in lookup_page() calls
  __free_pages()
- [Medium] rbrd: lookup_page() returns None instead of retrying on
  try_get_raw() failure
- [Low] rbrd: Kbuild module name rbrd_mod mismatches module! macro name
  rbrd
--

commit b57d882ab6ffa2969530912dd82ffe3996588b30
Author: Vitaly Wool <vitaly.wool@konsulko.se>

rust: block: add rbrd, a RAM backed block driver

This commit adds a RAM-backed block device driver in Rust that allocates
backing pages on first write, tracks them in a flat array of atomic
pointers, and exposes device configuration through configfs.

> diff --git a/drivers/block/rbrd/Makefile b/drivers/block/rbrd/Makefile
> new file mode 100644
> index 0000000000000..b5e0c10b4beaf
> --- /dev/null
> +++ b/drivers/block/rbrd/Makefile
> @@ -0,0 +1,2 @@
> +obj-$(CONFIG_BLK_DEV_RUST_RAM) += rbrd_mod.o
> +rbrd_mod-y := rbrd.o

[Severity: Low]
Does naming the Kbuild target rbrd_mod.o mismatch the module! declaration
in drivers/block/rbrd/rbrd.rs, which sets name: "rbrd"?

That sets KBUILD_MODNAME to rbrd_mod and RUST_MODFILE to
drivers/block/rbrd/rbrd_mod, so loadable builds produce rbrd_mod.ko while
built-in builds emit .modinfo entries prefixed with rbrd. that do not match
the rbrd_mod name recorded in modules.builtin.

> diff --git a/drivers/block/rbrd/rbrd.rs b/drivers/block/rbrd/rbrd.rs
> new file mode 100644
> index 0000000000000..e5e6981725074
> --- /dev/null
> +++ b/drivers/block/rbrd/rbrd.rs

[ ... ]

> +    fn lookup_page(&self, index: usize) -> Option<Page> {
> +        let slot = self.pages.slot(index)?;
> +
> +        loop {
> +            let ptr = NonNull::new(slot.load(Acquire))?;
> +
> +            // SAFETY: Every non-null pointer stored in a slot came from
> +            // `Page::into_raw`, i.e. is a `struct page` pointer; `struct page`
> +            // objects are never freed or reused for anything else, so `ptr`
> +            // always points at a valid one, whether or not it is (still)
> +            // actually owned by this slot.
> +            let Some(page) = (unsafe { Page::try_get_raw(ptr) }) else {
> +                // The page's last reference was already dropped concurrently.
> +                return None;
> +            };

[Severity: Medium]
Should lookup_page() continue the loop instead of returning None when
Page::try_get_raw(ptr) fails?

CPU0                      CPU1                      CPU2
lookup_page(index)
  ptr = slot.load()
                          discard()
                            slot.xchg(null)
                            drop(page1)
                                                    try_insert_page(index)
                                                      slot.cmpxchg(null, page2)
  Page::try_get_raw(ptr)
    -> None
  return None  <-- misses page2 in slot

If page1 is discarded and page2 is inserted into the same slot before CPU0
calls Page::try_get_raw(ptr), lookup_page() returns None even though the
slot holds page2.  read_chunk() then zeroes the buffer instead of reading
page2, and write_chunk() calls try_insert_page() and performs an extra
GFP_NOWAIT page allocation that can fail with ENOMEM.

> +
> +            if slot.load(Relaxed) == ptr.as_ptr() {
> +                return Some(page);
> +            }
> +
> +            // The slot was concurrently emptied, or now holds a different
> +            // page; `page` is not (or no longer) ours to use. Drop our
> +            // reference and retry.
> +            drop(page);
> +        }
> +    }

[Severity: Medium]
Can dropping the speculative Page reference here free a reallocated page
with __free_pages(page, 0) instead of put_page()?

CPU0                           CPU1                      CPU2
lookup_page(index)
  ptr = slot.load()
                               discard()
                                 slot.xchg(null)
                                 drop(page)
                                                         (reallocates ptr as a
                                                          compound or LRU folio)
  Page::try_get_raw(ptr)
    get_page_unless_zero(ptr)
                                                         folio_put()
  slot.load() != ptr
  drop(page)
    __free_pages(ptr, 0)  <-- bypasses __folio_put() / wrong order

rust/kernel/page.rs:<Page as Drop>::drop() {
	unsafe { bindings::__free_pages(self.page.as_ptr(), 0) };
}

Once discard() frees the page back to the page allocator, another subsystem
can reallocate that struct page as an LRU, memcg-charged, hugetlb, or
higher-order compound folio before Page::try_get_raw() increments its
refcount.  If the new owner drops its reference before CPU0 re-checks the
slot, drop(page) releases the last reference via __free_pages(ptr, 0)
rather than put_page(ptr), bypassing __folio_put() and triggering
VM_BUG_ON_PAGE() / bad_page() or corrupting the page allocator.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117233211.3137168-1-vitaly.wool@konsulko.se?part=3


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

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

Thread overview: 11+ 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-18 23:36   ` sashiko-bot
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-18 23:36   ` sashiko-bot
2026-11-17 23:32 ` [PATCH 3/3] rust: block: add rbrd, a RAM backed block driver Vitaly Wool
2026-11-18 23:36   ` sashiko-bot
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