Skip to content

Commit 31508da

Browse files
shroffnikawasaki
authored andcommitted
null_blk: prevent submit and poll queues update for shared tagset
When a user updates the number of submit or poll queues on a null_blk device, the block layer creates new hardware queues (hctxs). However, if the device is using a shared tagset, null_blk does not map any software queues (ctx) to the newly created hctx (via null_map_queues()), resulting in those hardware queues being left unused for I/O. This behavior is misleading, as the user may expect the new queues to be functional, even though they are effectively ignored. To avoid this confusion and potential misconfiguration: - Reject runtime updates to submit_queues or poll_queues via sysfs when the device uses a shared tagset by returning -EINVAL. - During configuration validation (prior to powering on the device), reset submit_queues and poll_queues to the module parameters (g_submit_queues and g_poll_queues) if the shared tagset is enabled. This ensures consistent behavior and avoids creating unused hardware queues (hctxs) due to ineffective runtime queue updates. Signed-off-by: Nilay Shroff <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Yu Kuai <[email protected]>
1 parent 8ae67b8 commit 31508da

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

drivers/block/null_blk/main.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ static int nullb_update_nr_hw_queues(struct nullb_device *dev,
388388
if (!submit_queues)
389389
return -EINVAL;
390390

391+
/*
392+
* Cannot update queues with shared tagset.
393+
*/
394+
if (dev->shared_tags)
395+
return -EINVAL;
396+
391397
/*
392398
* Make sure that null_init_hctx() does not access nullb->queues[] past
393399
* the end of that array.
@@ -1884,18 +1890,24 @@ static int null_validate_conf(struct nullb_device *dev)
18841890
dev->queue_mode = NULL_Q_MQ;
18851891
}
18861892

1887-
if (dev->use_per_node_hctx) {
1888-
if (dev->submit_queues != nr_online_nodes)
1889-
dev->submit_queues = nr_online_nodes;
1890-
} else if (dev->submit_queues > nr_cpu_ids)
1891-
dev->submit_queues = nr_cpu_ids;
1892-
else if (dev->submit_queues == 0)
1893-
dev->submit_queues = 1;
1894-
dev->prev_submit_queues = dev->submit_queues;
1895-
1896-
if (dev->poll_queues > g_poll_queues)
1893+
if (dev->shared_tags) {
1894+
dev->submit_queues = g_submit_queues;
18971895
dev->poll_queues = g_poll_queues;
1896+
} else {
1897+
if (dev->use_per_node_hctx) {
1898+
if (dev->submit_queues != nr_online_nodes)
1899+
dev->submit_queues = nr_online_nodes;
1900+
} else if (dev->submit_queues > nr_cpu_ids)
1901+
dev->submit_queues = nr_cpu_ids;
1902+
else if (dev->submit_queues == 0)
1903+
dev->submit_queues = 1;
1904+
1905+
if (dev->poll_queues > g_poll_queues)
1906+
dev->poll_queues = g_poll_queues;
1907+
}
1908+
dev->prev_submit_queues = dev->submit_queues;
18981909
dev->prev_poll_queues = dev->poll_queues;
1910+
18991911
dev->irqmode = min_t(unsigned int, dev->irqmode, NULL_IRQ_TIMER);
19001912

19011913
/* Do memory allocation, so set blocking */

0 commit comments

Comments
 (0)