mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
block: move {bdev,queue_limit}_discard_alignment out of line
No need to inline these fairly larger helpers. Also fix the return value to be unsigned, just like the field in struct queue_limits. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20220415045258.199825-22-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
f0f975a4dd
commit
5c4b4a5c6f
@@ -1252,39 +1252,7 @@ bdev_zone_write_granularity(struct block_device *bdev)
|
||||
}
|
||||
|
||||
int bdev_alignment_offset(struct block_device *bdev);
|
||||
|
||||
static inline int queue_limit_discard_alignment(struct queue_limits *lim, sector_t sector)
|
||||
{
|
||||
unsigned int alignment, granularity, offset;
|
||||
|
||||
if (!lim->max_discard_sectors)
|
||||
return 0;
|
||||
|
||||
/* Why are these in bytes, not sectors? */
|
||||
alignment = lim->discard_alignment >> SECTOR_SHIFT;
|
||||
granularity = lim->discard_granularity >> SECTOR_SHIFT;
|
||||
if (!granularity)
|
||||
return 0;
|
||||
|
||||
/* Offset of the partition start in 'granularity' sectors */
|
||||
offset = sector_div(sector, granularity);
|
||||
|
||||
/* And why do we do this modulus *again* in blkdev_issue_discard()? */
|
||||
offset = (granularity + alignment - offset) % granularity;
|
||||
|
||||
/* Turn it back into bytes, gaah */
|
||||
return offset << SECTOR_SHIFT;
|
||||
}
|
||||
|
||||
static inline int bdev_discard_alignment(struct block_device *bdev)
|
||||
{
|
||||
struct request_queue *q = bdev_get_queue(bdev);
|
||||
|
||||
if (bdev_is_partition(bdev))
|
||||
return queue_limit_discard_alignment(&q->limits,
|
||||
bdev->bd_start_sect);
|
||||
return q->limits.discard_alignment;
|
||||
}
|
||||
unsigned int bdev_discard_alignment(struct block_device *bdev);
|
||||
|
||||
static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev)
|
||||
{
|
||||
|
Reference in New Issue
Block a user