Add a configfs attribute to configure the queue depth (number of tags) for the rnull block device. Signed-off-by: Andreas Hindborg --- drivers/block/rnull/configfs.rs | 5 +++++ drivers/block/rnull/rnull.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs.rs index a84854e7c358..2dfc87dff66a 100644 --- a/drivers/block/rnull/configfs.rs +++ b/drivers/block/rnull/configfs.rs @@ -118,6 +118,7 @@ fn make_group( mbps: 16, blocking: 17, shared_tags: 18, + hw_queue_depth: 19 ], }; @@ -153,6 +154,7 @@ fn make_group( blocking: false, shared_tags: false, shared_tag_set: self.shared_tag_set.clone(), + hw_queue_depth: 64, }), }), core::iter::empty(), @@ -231,6 +233,7 @@ struct DeviceConfigInner { blocking: bool, shared_tags: bool, shared_tag_set: Arc>, + hw_queue_depth: u32, } #[vtable] @@ -274,6 +277,7 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result { blocking: guard.blocking, memory_backed: guard.memory_backed, no_sched: guard.no_sched, + hw_queue_depth: guard.hw_queue_depth, }, })?); guard.powered = true; @@ -447,3 +451,4 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result { configfs_simple_field!(DeviceConfig, 16, mbps, u32); configfs_simple_bool_field!(DeviceConfig, 17, blocking); configfs_simple_bool_field!(DeviceConfig, 18, shared_tags); +configfs_simple_field!(DeviceConfig, 19, hw_queue_depth, u32); diff --git a/drivers/block/rnull/rnull.rs b/drivers/block/rnull/rnull.rs index bcf6a85f1cbc..491979daa50e 100644 --- a/drivers/block/rnull/rnull.rs +++ b/drivers/block/rnull/rnull.rs @@ -147,6 +147,10 @@ default: false, description: "Share tag set between devices for blk-mq", }, + hw_queue_depth: u32 { + default: 64, + description: "Queue depth for each hardware queue. Default: 64", + }, }, } @@ -172,6 +176,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit { let blocking = module_parameters::blocking.value(); let memory_backed = module_parameters::memory_backed.value(); let no_sched = module_parameters::no_sched.value(); + let hw_queue_depth = module_parameters::hw_queue_depth.value(); let shared_tag_set = NullBlkDevice::build_tag_set(TagSetOptions { submit_queues, @@ -179,6 +184,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit { blocking, memory_backed, no_sched, + hw_queue_depth, })?; let mut disks = KVec::new(); @@ -209,6 +215,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit { blocking, memory_backed, no_sched, + hw_queue_depth, }, })?; disks.push(disk, GFP_KERNEL)?; @@ -264,6 +271,7 @@ struct TagSetOptions { blocking: bool, memory_backed: bool, no_sched: bool, + hw_queue_depth: u32, } impl NullBlkDevice { @@ -276,6 +284,7 @@ fn build_tag_set(options: TagSetOptions) -> Result>> { blocking, memory_backed, no_sched, + hw_queue_depth, } = options; if home_node > kernel::numa::num_online_nodes().try_into()? { @@ -297,7 +306,7 @@ fn build_tag_set(options: TagSetOptions) -> Result>> { } Arc::pin_init( - TagSet::new(submit_queues, (), 256, 1, numa_node, flags), + TagSet::new(submit_queues, (), hw_queue_depth, 1, numa_node, flags), GFP_KERNEL, ) } -- 2.51.2