Skip to content

Commit b85a3c1

Browse files
damien-lemoalaxboe
authored andcommitted
block: Introduce bio_straddles_zones() and bio_offset_from_zone_start()
Implement the inline helper functions bio_straddles_zones() and bio_offset_from_zone_start() to respectively test if a BIO crosses a zone boundary (the start sector and last sector belong to different zones) and to obtain the offset of a BIO from the start sector of its target zone. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Tested-by: Hans Holmberg <[email protected]> Tested-by: Dennis Maisenbacher <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a0508c3 commit b85a3c1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/linux/blkdev.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,13 @@ static inline unsigned int bio_zone_no(struct bio *bio)
853853
return disk_zone_no(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
854854
}
855855

856+
static inline bool bio_straddles_zones(struct bio *bio)
857+
{
858+
return bio_sectors(bio) &&
859+
bio_zone_no(bio) !=
860+
disk_zone_no(bio->bi_bdev->bd_disk, bio_end_sector(bio) - 1);
861+
}
862+
856863
static inline unsigned int bio_zone_is_seq(struct bio *bio)
857864
{
858865
return disk_zone_is_seq(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
@@ -1328,6 +1335,12 @@ static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
13281335
return sector & (bdev_zone_sectors(bdev) - 1);
13291336
}
13301337

1338+
static inline sector_t bio_offset_from_zone_start(struct bio *bio)
1339+
{
1340+
return bdev_offset_from_zone_start(bio->bi_bdev,
1341+
bio->bi_iter.bi_sector);
1342+
}
1343+
13311344
static inline bool bdev_is_zone_start(struct block_device *bdev,
13321345
sector_t sector)
13331346
{

0 commit comments

Comments
 (0)