virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Maxim Levitsky <mlevitsk@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Keith Busch <kbusch@kernel.org>,
	Josef Bacik <josef@toxicpanda.com>,
	"open list:BLOCK LAYER" <linux-block@vger.kernel.org>,
	Sagi Grimberg <sagi@grimberg.me>, Jens Axboe <axboe@kernel.dk>,
	"open list:NVM EXPRESS DRIVER" <linux-nvme@lists.infradead.org>,
	"open list:SCSI CDROM DRIVER" <linux-scsi@vger.kernel.org>,
	Tejun Heo <tj@kernel.org>, Bart Van Assche <bvanassche@acm.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Jason Wang <jasowang@redhat.com>,
	Maxim Levitsky <maximlevitsky@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Colin Ian King <colin.king@canonical.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Ajay Joshi <Ajay.Joshi@wdc.com>, Ming Lei <ming.lei@redhat.>
Subject: Re: [PATCH 01/10] block: introduce blk_is_valid_logical_block_size
Date: Tue, 21 Jul 2020 11:31:10 +0000	[thread overview]
Message-ID: <CY4PR04MB37515A4950060845E5860755E7780@CY4PR04MB3751.namprd04.prod.outlook.com> (raw)
In-Reply-To: cef747910431d81524e455e6380df1c610d1884c.camel@redhat.com

On 2020/07/21 20:09, Maxim Levitsky wrote:
> On Tue, 2020-07-21 at 11:05 +0000, Damien Le Moal wrote:
>> 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.
> Agree, will fix.
>>
>> ("for that" does not refer to a clear action)
>>
>>> Signed-off-by: Maxim Levitsky  <mlevitsk@redhat.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);
> Note here a typo, made in last minute change which I didn't test.
> It should be without '!'

Oh ! Indeed. I missed that.

> 
> Best regards,
> 	Maxim Levitsky
> 
>>> +}
>>> +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

  reply	other threads:[~2020-07-21 11:31 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 10:52 [PATCH 00/10] RFC: move logical block size checking to the block core Maxim Levitsky
2020-07-21 10:52 ` [PATCH 01/10] block: introduce blk_is_valid_logical_block_size Maxim Levitsky
2020-07-21 11:05   ` Damien Le Moal
2020-07-21 11:09     ` Maxim Levitsky
2020-07-21 11:31       ` Damien Le Moal [this message]
2020-07-21 15:13   ` Christoph Hellwig
2020-07-22  8:50     ` Maxim Levitsky
2020-07-23  9:13   ` [block] 4c873fbf07: WARNING:at_block/blk-settings.c:#blk_queue_logical_block_size kernel test robot
2020-07-21 10:52 ` [PATCH 02/10] block: virtio-blk: check logical block size Maxim Levitsky
2020-07-21 11:07   ` Damien Le Moal
2020-07-21 15:14   ` Christoph Hellwig
2020-07-22  2:55     ` Martin K. Petersen
2020-07-22  9:11       ` Maxim Levitsky
2020-07-21 10:52 ` [PATCH 03/10] block: loop: use blk_is_valid_logical_block_size Maxim Levitsky
2020-07-21 11:08   ` Damien Le Moal
2020-07-21 10:52 ` [PATCH 04/10] block: nbd: " Maxim Levitsky
2020-07-21 11:09   ` Damien Le Moal
2020-07-21 10:52 ` [PATCH 05/10] block: null: " Maxim Levitsky
2020-07-21 11:15   ` Damien Le Moal
2020-07-21 12:42     ` Maxim Levitsky
2020-07-21 10:52 ` [PATCH 06/10] block: ms_block: " Maxim Levitsky
2020-07-21 11:17   ` Damien Le Moal
2020-07-21 10:52 ` [PATCH 07/10] block: mspro_blk: " Maxim Levitsky
2020-07-21 11:17   ` Damien Le Moal
2020-07-21 10:52 ` [PATCH 08/10] block: nvme: " Maxim Levitsky
2020-07-21 11:23   ` Damien Le Moal
2020-07-21 10:52 ` [PATCH 09/10] block: scsi: sd: " Maxim Levitsky
2020-07-21 11:25   ` Damien Le Moal
2020-07-21 12:55     ` Maxim Levitsky
2020-07-21 10:52 ` [PATCH 10/10] block: scsi: sr: " Maxim Levitsky
2020-07-21 11:29   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4PR04MB37515A4950060845E5860755E7780@CY4PR04MB3751.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=Ajay.Joshi@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=colin.king@canonical.com \
    --cc=jasowang@redhat.com \
    --cc=josef@toxicpanda.com \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=maximlevitsky@gmail.com \
    --cc=ming.lei@redhat. \
    --cc=mlevitsk@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=stefanha@redhat.com \
    --cc=tj@kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).