mbox series

[0/5] Validate logical block size in blk_validate_limits()

Message ID 20240705115127.3417539-1-john.g.garry@oracle.com (mailing list archive)
Headers show
Series Validate logical block size in blk_validate_limits() | expand

Message

John Garry July 5, 2024, 11:51 a.m. UTC
This series adds validation of the logical block size in
blk_validate_limits().

Some drivers had already been validating this themselves. As such, we can
mostly drop that driver validation.

nbd is problematic, as we cannot only change to just stop calling
blk_validate_limits(). This is because the LBS is updated in a 2-stage
process:
a. update block size in the driver and validate
b. update queue limits

So if we stop validating the limits in a., there is a user-visible change
in behaviour (as we stop rejecting invalid limits from the NBD_SET_BLKSIZE
ioctl). So I left that untouched.

This topic was originally mentioned in [0] and then again in [1] by
Keith.

I have also included a related virtio_blk change to deal with
blk_size config fallback.

[0] https://lore.kernel.org/linux-block/10b3e3fe-6ad5-4e0e-b822-f51656c976ee@oracle.com/
[1] https://lore.kernel.org/linux-block/Zl4dxaQgPbw19Irk@kbusch-mbp.dhcp.thefacebook.com/

John Garry (5):
  virtio_blk: Fix default logical block size fallback
  block: Validate logical block size in blk_validate_limits()
  null_blk: Don't bother validating blocksize
  virtio_blk: Don't bother validating blocksize
  loop: Don't bother validating blocksize

 block/blk-settings.c          |  2 ++
 drivers/block/loop.c          | 12 +-----------
 drivers/block/null_blk/main.c |  3 ---
 drivers/block/virtio_blk.c    | 31 +++++++++++--------------------
 include/linux/blkdev.h        |  1 +
 5 files changed, 15 insertions(+), 34 deletions(-)

Comments

Michael S. Tsirkin July 5, 2024, 3:29 p.m. UTC | #1
On Fri, Jul 05, 2024 at 11:51:22AM +0000, John Garry wrote:
> This series adds validation of the logical block size in
> blk_validate_limits().
> 
> Some drivers had already been validating this themselves. As such, we can
> mostly drop that driver validation.
> 
> nbd is problematic, as we cannot only change to just stop calling
> blk_validate_limits(). This is because the LBS is updated in a 2-stage
> process:
> a. update block size in the driver and validate
> b. update queue limits
> 
> So if we stop validating the limits in a., there is a user-visible change
> in behaviour (as we stop rejecting invalid limits from the NBD_SET_BLKSIZE
> ioctl). So I left that untouched.
> 
> This topic was originally mentioned in [0] and then again in [1] by
> Keith.
> 
> I have also included a related virtio_blk change to deal with
> blk_size config fallback.
> 
> [0] https://lore.kernel.org/linux-block/10b3e3fe-6ad5-4e0e-b822-f51656c976ee@oracle.com/
> [1] https://lore.kernel.org/linux-block/Zl4dxaQgPbw19Irk@kbusch-mbp.dhcp.thefacebook.com/

virtio bits:

Acked-by: Michael S. Tsirkin <mst@redhat.com>

I assume this everything will go in gother with block patches?


> John Garry (5):
>   virtio_blk: Fix default logical block size fallback
>   block: Validate logical block size in blk_validate_limits()
>   null_blk: Don't bother validating blocksize
>   virtio_blk: Don't bother validating blocksize
>   loop: Don't bother validating blocksize
> 
>  block/blk-settings.c          |  2 ++
>  drivers/block/loop.c          | 12 +-----------
>  drivers/block/null_blk/main.c |  3 ---
>  drivers/block/virtio_blk.c    | 31 +++++++++++--------------------
>  include/linux/blkdev.h        |  1 +
>  5 files changed, 15 insertions(+), 34 deletions(-)
> 
> -- 
> 2.31.1
John Garry July 5, 2024, 4:06 p.m. UTC | #2
On 05/07/2024 16:29, Michael S. Tsirkin wrote:
>> [0]https://urldefense.com/v3/__https://lore.kernel.org/linux-block/10b3e3fe-6ad5-4e0e-b822-f51656c976ee@oracle.com/__;!!ACWV5N9M2RV99hQ!LzUcadOhRalf0I9KR0o_PEx2_Igd2az2Mpv6IdBkLGXLb4E5G9NHZFpm89oJbvJuJbdRQ4W2E2Y6Hg$  
>> [1]https://urldefense.com/v3/__https://lore.kernel.org/linux-block/Zl4dxaQgPbw19Irk@kbusch-mbp.dhcp.thefacebook.com/__;!!ACWV5N9M2RV99hQ!LzUcadOhRalf0I9KR0o_PEx2_Igd2az2Mpv6IdBkLGXLb4E5G9NHZFpm89oJbvJuJbdRQ4Wqz9meMA$  
> virtio bits:
> 
> Acked-by: Michael S. Tsirkin<mst@redhat.com>
> 
> I assume this everything will go in gother with block patches?

That would make sense. I hope that Jens is happy to pick them up. I'll 
send a v2 soon, addressing comments from Christoph.