Message ID | 20201105071656.421762-1-damien.lemoal@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] null_blk: Set mq device as blocking with zoned mode | expand |
On 2020/11/05 16:17, Damien Le Moal wrote: > 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@intel.com> > Fixes: aa1c09cb65e2 ("null_blk: Fix locking in zoned mode") > Cc: stable@vger.kernel.org > Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Jens, Please ignore this patch. Sending shortly another one that removes the need for BLK_MQ_F_BLOCKING when memory backing is disabled. > --- > 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); >
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);
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@intel.com> Fixes: aa1c09cb65e2 ("null_blk: Fix locking in zoned mode") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> --- 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(-)