loop: Simplify discard granularity calc

A bdev discard granularity is always at least SECTOR_SIZE, so don't check
for a zero value.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20241101092215.422428-1-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
John Garry 2024-11-01 09:22:15 +00:00 committed by Jens Axboe
parent f187b9bf1a
commit d47de6ac88

View File

@ -789,8 +789,7 @@ static void loop_config_discard(struct loop_device *lo,
struct block_device *bdev = I_BDEV(inode);
max_discard_sectors = bdev_write_zeroes_sectors(bdev);
granularity = bdev_discard_granularity(bdev) ?:
bdev_physical_block_size(bdev);
granularity = bdev_discard_granularity(bdev);
/*
* We use punch hole to reclaim the free space used by the