RE: [PATCH 1/2] blkdev.h: Introduce size_to_sectors hlper function

From: Elliott, Robert (Servers)
Date: Thu May 02 2019 - 17:52:22 EST




> -----Original Message-----
> From: linux-kernel-owner@xxxxxxxxxxxxxxx [mailto:linux-kernel-owner@xxxxxxxxxxxxxxx] On Behalf Of
> Marcos Paulo de Souza
> Sent: Monday, April 29, 2019 8:32 PM
> Subject: [PATCH 1/2] blkdev.h: Introduce size_to_sectors hlper function
>
> This function takes an argument to specify the size of a block device,
> in bytes, and return the number of sectors of 512 bytes.
>
...
> +static inline sector_t size_to_sectors(long long size)
> +{
> + return size >> SECTOR_SHIFT;
> +}

At least one of the users in PATCH 2/2 passes an unsigned value that won't
fit in a signed argument:

- blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
+ blk_queue_max_discard_sectors(nullb->q, size_to_sectors(UINT_MAX));