mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
block: Generalize chunk_sectors support as boundary support
The purpose of the chunk_sectors limit is to ensure that a mergeble request fits within the boundary of the chunck_sector value. Such a feature will be useful for other request_queue boundary limits, so generalize the chunk_sectors merge code. This idea was proposed by Hannes Reinecke. Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Acked-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Link: https://lore.kernel.org/r/20240620125359.2684798-3-john.g.garry@oracle.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -907,14 +907,15 @@ static inline bool bio_straddles_zones(struct bio *bio)
|
||||
}
|
||||
|
||||
/*
|
||||
* Return how much of the chunk is left to be used for I/O at a given offset.
|
||||
* Return how much within the boundary is left to be used for I/O at a given
|
||||
* offset.
|
||||
*/
|
||||
static inline unsigned int blk_chunk_sectors_left(sector_t offset,
|
||||
unsigned int chunk_sectors)
|
||||
static inline unsigned int blk_boundary_sectors_left(sector_t offset,
|
||||
unsigned int boundary_sectors)
|
||||
{
|
||||
if (unlikely(!is_power_of_2(chunk_sectors)))
|
||||
return chunk_sectors - sector_div(offset, chunk_sectors);
|
||||
return chunk_sectors - (offset & (chunk_sectors - 1));
|
||||
if (unlikely(!is_power_of_2(boundary_sectors)))
|
||||
return boundary_sectors - sector_div(offset, boundary_sectors);
|
||||
return boundary_sectors - (offset & (boundary_sectors - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user