block: add a bdev_max_discard_sectors helper
Add a helper to query the number of sectors support per each discard bio based on the block device and use this helper to stop various places from poking into the request_queue to see if discard is supported and if so how much. This mirrors what is done e.g. for write zeroes as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com> [drbd] Acked-by: Coly Li <colyli@suse.de> [bcache] Acked-by: David Sterba <dsterba@suse.com> [btrfs] Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20220415045258.199825-24-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
e3cc28ea28
commit
cf0fbf894b
7 changed files with 18 additions and 15 deletions
|
|
@ -1254,6 +1254,11 @@ bdev_zone_write_granularity(struct block_device *bdev)
|
|||
int bdev_alignment_offset(struct block_device *bdev);
|
||||
unsigned int bdev_discard_alignment(struct block_device *bdev);
|
||||
|
||||
static inline unsigned int bdev_max_discard_sectors(struct block_device *bdev)
|
||||
{
|
||||
return bdev_get_queue(bdev)->limits.max_discard_sectors;
|
||||
}
|
||||
|
||||
static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev)
|
||||
{
|
||||
struct request_queue *q = bdev_get_queue(bdev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue