lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CY4PR04MB37512BDEFD7B977FCD32A10AE7780@CY4PR04MB3751.namprd04.prod.outlook.com>
Date:   Tue, 21 Jul 2020 11:05:55 +0000
From:   Damien Le Moal <Damien.LeMoal@....com>
To:     Maxim Levitsky <mlevitsk@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Keith Busch <kbusch@...nel.org>,
        Josef Bacik <josef@...icpanda.com>,
        "open list:BLOCK LAYER" <linux-block@...r.kernel.org>,
        Sagi Grimberg <sagi@...mberg.me>, Jens Axboe <axboe@...nel.dk>,
        "open list:NVM EXPRESS DRIVER" <linux-nvme@...ts.infradead.org>,
        "open list:SCSI CDROM DRIVER" <linux-scsi@...r.kernel.org>,
        Tejun Heo <tj@...nel.org>,
        Bart Van Assche <bvanassche@....org>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Jason Wang <jasowang@...hat.com>,
        Maxim Levitsky <maximlevitsky@...il.com>,
        Stefan Hajnoczi <stefanha@...hat.com>,
        Colin Ian King <colin.king@...onical.com>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Ajay Joshi <Ajay.Joshi@....com>,
        Ming Lei <ming.lei@...hat.com>,
        "open list:SONY MEMORYSTICK SUBSYSTEM" <linux-mmc@...r.kernel.org>,
        Christoph Hellwig <hch@....de>,
        Satya Tangirala <satyat@...gle.com>,
        "open list:NETWORK BLOCK DEVICE (NBD)" <nbd@...er.debian.org>,
        Hou Tao <houtao1@...wei.com>, Jens Axboe <axboe@...com>,
        "open list:VIRTIO CORE AND NET DRIVERS" 
        <virtualization@...ts.linux-foundation.org>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        Alex Dubov <oakad@...oo.com>
Subject: Re: [PATCH 01/10] block: introduce blk_is_valid_logical_block_size

On 2020/07/21 19:53, Maxim Levitsky wrote:
> Kernel block layer has never supported logical block
> sizes less that SECTOR_SIZE nor larger that PAGE_SIZE.
> 
> Some drivers have runtime configurable block size,
> so it makes sense to have common helper for that.

...common helper to check the validity of the logical block size set by the driver.

("for that" does not refer to a clear action)

> 
> Signed-off-by: Maxim Levitsky  <mlevitsk@...hat.com>
> ---
>  block/blk-settings.c   | 18 ++++++++++++++++++
>  include/linux/blkdev.h |  1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 9a2c23cd97007..3c4ef0d00c2bc 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -311,6 +311,21 @@ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
>  }
>  EXPORT_SYMBOL(blk_queue_max_segment_size);
>  
> +
> +/**
> + * blk_check_logical_block_size - check if logical block size is supported
> + * by the kernel
> + * @size:  the logical block size, in bytes
> + *
> + * Description:
> + *   This function checks if the block layers supports given block size
> + **/
> +bool blk_is_valid_logical_block_size(unsigned int size)
> +{
> +	return size >= SECTOR_SIZE && size <= PAGE_SIZE && !is_power_of_2(size);
> +}
> +EXPORT_SYMBOL(blk_is_valid_logical_block_size);
> +
>  /**
>   * blk_queue_logical_block_size - set logical block size for the queue
>   * @q:  the request queue for the device
> @@ -323,6 +338,8 @@ EXPORT_SYMBOL(blk_queue_max_segment_size);
>   **/
>  void blk_queue_logical_block_size(struct request_queue *q, unsigned int size)
>  {
> +	WARN_ON(!blk_is_valid_logical_block_size(size));
> +
>  	q->limits.logical_block_size = size;
>  
>  	if (q->limits.physical_block_size < size)
> @@ -330,6 +347,7 @@ void blk_queue_logical_block_size(struct request_queue *q, unsigned int size)
>  
>  	if (q->limits.io_min < q->limits.physical_block_size)
>  		q->limits.io_min = q->limits.physical_block_size;
> +

white line change.

>  }
>  EXPORT_SYMBOL(blk_queue_logical_block_size);
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 57241417ff2f8..2ed3151397e41 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1099,6 +1099,7 @@ extern void blk_queue_max_write_same_sectors(struct request_queue *q,
>  		unsigned int max_write_same_sectors);
>  extern void blk_queue_max_write_zeroes_sectors(struct request_queue *q,
>  		unsigned int max_write_same_sectors);
> +extern bool blk_is_valid_logical_block_size(unsigned int size);
>  extern void blk_queue_logical_block_size(struct request_queue *, unsigned int);
>  extern void blk_queue_max_zone_append_sectors(struct request_queue *q,
>  		unsigned int max_zone_append_sectors);
> 


-- 
Damien Le Moal
Western Digital Research

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ