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 | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs.rs index d1a70fe030cb2..90f2ecb454285 100644 --- a/drivers/block/rnull/configfs.rs +++ b/drivers/block/rnull/configfs.rs @@ -108,6 +108,7 @@ fn make_group( mbps: 16, blocking: 17, shared_tags: 18, + hw_queue_depth: 19 ], }; @@ -142,6 +143,7 @@ fn make_group( mbps: 0, blocking: false, shared_tags: false, + hw_queue_depth: 64, }), }), core::iter::empty(), @@ -209,6 +211,7 @@ struct DeviceConfigInner { mbps: u32, blocking: bool, shared_tags: bool, + hw_queue_depth: u32, } #[vtable] @@ -251,6 +254,7 @@ fn store(this: &DeviceConfig, page: &[u8]) -> Result { bandwidth_limit: u64::from(guard.mbps) * 2u64.pow(20), blocking: guard.blocking, shared_tags: guard.shared_tags, + hw_queue_depth: guard.hw_queue_depth, })?); guard.powered = true; } else if guard.powered && !power_op { @@ -472,3 +476,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 84e75a7042214..3fb19836ce6ff 100644 --- a/drivers/block/rnull/rnull.rs +++ b/drivers/block/rnull/rnull.rs @@ -149,6 +149,10 @@ default: 0, description: "Share tag set between devices for blk-mq", }, + hw_queue_depth: u32 { + default: 64, + description: "Queue depth for each hardware queue. Default: 64", + }, }, } @@ -197,6 +201,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit { bandwidth_limit: u64::from(*module_parameters::mbps.value()) * 2u64.pow(20), blocking: *module_parameters::blocking.value() != 0, shared_tags: *module_parameters::shared_tags.value() != 0, + hw_queue_depth: *module_parameters::hw_queue_depth.value(), })?; disks.push(disk, GFP_KERNEL)?; } @@ -230,6 +235,7 @@ struct NullBlkOptions<'a> { bandwidth_limit: u64, blocking: bool, shared_tags: bool, + hw_queue_depth: u32, } static SHARED_TAG_SET: SetOnce>> = SetOnce::new(); @@ -276,6 +282,7 @@ fn new(options: NullBlkOptions<'_>) -> Result>> { bandwidth_limit, blocking, shared_tags, + hw_queue_depth, } = options; let mut flags = mq::tag_set::Flags::default(); @@ -297,7 +304,7 @@ fn new(options: NullBlkOptions<'_>) -> Result>> { let tagset_ctor = || -> Result> { Arc::pin_init( - TagSet::new(submit_queues, (), 256, 1, home_node, flags), + TagSet::new(submit_queues, (), hw_queue_depth, 1, home_node, flags), GFP_KERNEL, ) }; -- 2.51.2