Skip to content

Commit 296dbc7

Browse files
yoeaxboe
authored andcommitted
nbd: correct the maximum value for discard sectors
The version of the NBD protocol implemented by the kernel driver currently has a 32 bit field for length values. As the NBD protocol uses bytes as a unit of length, length values larger than 2^32 bytes cannot be expressed. Update the max_hw_discard_sectors field to match that. Signed-off-by: Wouter Verhelst <[email protected]> Fixes: 2682832 ("nbd: use the atomic queue limits API in nbd_set_size") Reviewed-by: Damien Le Moal <[email protected]> Cc: Eric Blake <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 41372f5 commit 296dbc7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/block/nbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
350350

351351
lim = queue_limits_start_update(nbd->disk->queue);
352352
if (nbd->config->flags & NBD_FLAG_SEND_TRIM)
353-
lim.max_hw_discard_sectors = UINT_MAX;
353+
lim.max_hw_discard_sectors = UINT_MAX >> SECTOR_SHIFT;
354354
else
355355
lim.max_hw_discard_sectors = 0;
356356
if (!(nbd->config->flags & NBD_FLAG_SEND_FLUSH)) {

0 commit comments

Comments
 (0)