Re: [PATCH 04/10] block: nbd: use blk_is_valid_logical_block_size

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

 



On 2020/07/21 19:54, Maxim Levitsky wrote:
> This allows to remove nbd's own check for valid block size
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
> ---
>  drivers/block/nbd.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index ce7e9f223b20b..2cd9c4e824f8b 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1347,14 +1347,6 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
>  		nbd_config_put(nbd);
>  }
>  
> -static bool nbd_is_valid_blksize(unsigned long blksize)
> -{
> -	if (!blksize || !is_power_of_2(blksize) || blksize < 512 ||
> -	    blksize > PAGE_SIZE)
> -		return false;
> -	return true;
> -}
> -
>  static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
>  {
>  	nbd->tag_set.timeout = timeout * HZ;
> @@ -1379,7 +1371,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  	case NBD_SET_BLKSIZE:
>  		if (!arg)
>  			arg = NBD_DEF_BLKSIZE;
> -		if (!nbd_is_valid_blksize(arg))
> +		if (!blk_is_valid_logical_block_size(arg))
>  			return -EINVAL;
>  		nbd_size_set(nbd, arg,
>  			     div_s64(config->bytesize, arg));
> @@ -1811,7 +1803,7 @@ static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd)
>  		bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
>  		if (!bsize)
>  			bsize = NBD_DEF_BLKSIZE;
> -		if (!nbd_is_valid_blksize(bsize)) {
> +		if (!blk_is_valid_logical_block_size(bsize)) {
>  			printk(KERN_ERR "Invalid block size %llu\n", bsize);
>  			return -EINVAL;
>  		}
> 

Looks good to me.

Reviewed-by: Damien Le Moal <damien.lemoal@xxxxxxx>

-- 
Damien Le Moal
Western Digital Research




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux