Re: [PATCH 1/1] null_blk: allow user to set QUEUE_FLAG_NOWAIT

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

 



> +static bool g_nowait = true;
> +module_param_named(nowait, g_nowait, bool, 0444);
> +MODULE_PARM_DESC(virt_boundary, "Set QUEUE_FLAG_NOWAIT irrespective of queue mode. Default: True");
Copy paste error. MODULE_PARM_DESC(nowait,...
> +
>  static bool g_virt_boundary = false;
>  module_param_named(virt_boundary, g_virt_boundary, bool, 0444);
>  MODULE_PARM_DESC(virt_boundary, "Require a virtual boundary for the device. Default: False");
> @@ -983,11 +990,11 @@ static struct nullb_page *null_insert_page(struct nullb *nullb,
>  
>  	spin_unlock_irq(&nullb->lock);
>  
> -	t_page = null_alloc_page();
> +	t_page = null_alloc_page(nullb->dev->nowait ? GFP_NOWAIT : GFP_NOIO);
>  	if (!t_page)
>  		goto out_lock;
>  
> -	if (radix_tree_preload(GFP_NOIO))
> +	if (radix_tree_preload(nullb->dev->nowait ? GFP_NOWAIT : GFP_NOIO))

This is not correct. You need to use radix_tree_maybe_preload because
GFP_NOWAIT should not block and this WARN_ON_ONCE flag will trigger in
radix_tree_preload:

/* Warn on non-sensical use... */
WARN_ON_ONCE(!gfpflags_allow_blocking(gfp_mask));

I also verified this locally with your patch and while doing a simple fio 
write with setting memory_backed=1.

WARNING: CPU: 2 PID: 515 at lib/radix-tree.c:366 radix_tree_preload+0x12/0x20
...
RIP: 0010:radix_tree_preload+0x12/0x20
<snip>
Call Trace:
 <TASK>
 null_insert_page+0x186/0x4e0 [null_blk]
 null_transfer+0x588/0x990 [null_blk]
<snip>

>  		goto out_freepage;
>  
>  	spin_lock_irq(&nullb->lock);
> @@ -2093,6 +2100,11 @@ static int null_add_dev(struct nullb_device *dev)
>  	blk_queue_flag_set(QUEUE_FLAG_NONROT, nullb->q);
>  	blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, nullb->q);
>  
> +	if (dev->nowait)
> +		blk_queue_flag_set(QUEUE_FLAG_NOWAIT, nullb->q);
> +	else
> +		blk_queue_flag_clear(QUEUE_FLAG_NOWAIT, nullb->q);
> +
>  	mutex_lock(&lock);
>  	rv = ida_simple_get(&nullb_indexes, 0, 0, GFP_KERNEL);
>  	if (rv < 0) {
> diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h
> index eb5972c50be8..1d7af446d728 100644
> --- a/drivers/block/null_blk/null_blk.h
> +++ b/drivers/block/null_blk/null_blk.h
> @@ -107,6 +107,7 @@ struct nullb_device {
>  	unsigned int index; /* index of the disk, only valid with a disk */
>  	unsigned int mbps; /* Bandwidth throttle cap (in MB/s) */
>  	bool blocking; /* blocking blk-mq device */
> +	bool nowait; /* to set QUEUE_FLAG_NOWAIT on device queue */
>  	bool use_per_node_hctx; /* use per-node allocation for hardware context */
>  	bool power; /* power on/off the device */
>  	bool memory_backed; /* if data is stored in memory */
> -- 
> 2.29.0
> 

-- 
Pankaj Raghav





[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