[PATCH v2] null_blk: Set mq device as blocking with zoned mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit aa1c09cb65e2 ("null_blk: Fix locking in zoned mode") changed zone
locking to using the potentially sleeping wait_on_bit_io() function. A
zoned null_blk device must thus be marked as blocking to avoid calls to
queue_rq() from invalid contexts triggering might_sleep() warnings.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Fixes: aa1c09cb65e2 ("null_blk: Fix locking in zoned mode")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx>
---
Changes from v1:
* Add "|| g_zoned" to condition for setting blocking to correctly handle
  creation through modprobe.

 drivers/block/null_blk_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 4685ea401d5b..6bcf95d611a3 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1714,7 +1714,7 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
 		set->flags |= BLK_MQ_F_TAG_HCTX_SHARED;
 	set->driver_data = NULL;
 
-	if ((nullb && nullb->dev->blocking) || g_blocking)
+	if ((nullb && nullb->dev->blocking) || g_blocking || g_zoned)
 		set->flags |= BLK_MQ_F_BLOCKING;
 
 	return blk_mq_alloc_tag_set(set);
@@ -1736,10 +1736,11 @@ static int null_validate_conf(struct nullb_device *dev)
 	dev->queue_mode = min_t(unsigned int, dev->queue_mode, NULL_Q_MQ);
 	dev->irqmode = min_t(unsigned int, dev->irqmode, NULL_IRQ_TIMER);
 
-	/* Do memory allocation, so set blocking */
-	if (dev->memory_backed)
+	/* Memory allocation and zone handling may sleep, so set blocking */
+	if (dev->memory_backed || dev->zoned)
 		dev->blocking = true;
-	else /* cache is meaningless */
+	/* Cache is meaningless without memory backing */
+	if (!dev->memory_backed)
 		dev->cache_size = 0;
 	dev->cache_size = min_t(unsigned long, ULONG_MAX / 1024 / 1024,
 						dev->cache_size);
-- 
2.26.2




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux