Benno Lossin <benno.lossin@xxxxxxxxx> writes: >> +impl kernel::Module for NullBlkModule { >> + fn init(_module: &'static ThisModule) -> Result<Self> { >> + pr_info!("Rust null_blk loaded\n"); >> + let tagset = Arc::pin_init(TagSet::try_new(1, 256, 1), flags::GFP_KERNEL)?; >> + >> + let disk = { >> + let block_size: u16 = 4096; >> + if block_size % 512 != 0 || !(512..=4096).contains(&block_size) { >> + return Err(kernel::error::code::EINVAL); >> + } >> + >> + let mut disk = gen_disk::GenDisk::try_new(tagset)?; >> + disk.set_name(format_args!("rnullb{}", 0))?; >> + disk.set_capacity_sectors(4096 << 11); >> + disk.set_queue_logical_block_size(block_size.into()); >> + disk.set_queue_physical_block_size(block_size.into()); >> + disk.set_rotational(false); >> + disk.add() >> + }?; > > Personally, I would prefer to put the `?` into the line above. I have no strong opinion here. > >> + >> + let disk = Box::pin_init(new_mutex!(disk, "nullb:disk"), flags::GFP_KERNEL)?; >> + >> + Ok(Self { _disk: disk }) >> + } >> +} >> + >> +struct NullBlkDevice; >> + >> +#[vtable] >> +impl Operations for NullBlkDevice { >> + #[inline(always)] >> + fn queue_rq(rq: ARef<mq::Request<Self>>, _is_last: bool) -> Result { >> + mq::Request::end_ok(rq) >> + .map_err(|_e| kernel::error::code::EIO) >> + .expect("Fatal error - expected to be able to end request"); > > I expected something more along the lines of: "expected to be able to > end request, since `NullBlkDevice` never takes refcounts on Requests and > as such the ARef must be unique, but `end_ok` only fails if that is not > the case". But maybe that would fit better in a comment, what do you > think? I can add a comment 👍 BR Andreas