diff mbox series

[07/17] block: simplify blk_check_zone_append

Message ID 20220704124500.155247-8-hch@lst.de (mailing list archive)
State Superseded
Headers show
Series [01/17] block: remove a superflous ifdef in blkdev.h | expand

Commit Message

Christoph Hellwig July 4, 2022, 12:44 p.m. UTC
Use the bdev based helpers instead of open coding them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Johannes Thumshirn July 4, 2022, 1:21 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Damien Le Moal July 5, 2022, 2:40 a.m. UTC | #2
On 7/4/22 21:44, Christoph Hellwig wrote:
> Use the bdev based helpers instead of open coding them.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index bc16e9bae2dc4..b530ce7b370c4 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -565,7 +565,6 @@ static int blk_partition_remap(struct bio *bio)
>  static inline blk_status_t blk_check_zone_append(struct request_queue *q,
>  						 struct bio *bio)
>  {
> -	sector_t pos = bio->bi_iter.bi_sector;
>  	int nr_sectors = bio_sectors(bio);
>  
>  	/* Only applicable to zoned block devices */
> @@ -573,8 +572,8 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
>  		return BLK_STS_NOTSUPP;
>  
>  	/* The bio sector must point to the start of a sequential zone */
> -	if (pos & (blk_queue_zone_sectors(q) - 1) ||
> -	    !blk_queue_zone_is_seq(q, pos))
> +	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
> +	    !bio_zone_is_seq(bio))
>  		return BLK_STS_IOERR;
>  
>  	/*

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Chaitanya Kulkarni July 5, 2022, 6:27 a.m. UTC | #3
On 7/4/2022 5:44 AM, Christoph Hellwig wrote:
> Use the bdev based helpers instead of open coding them.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---


Reviewed-by : Chaitanya Kulkarni <kch@nvidia.com>

-ck
diff mbox series

Patch

diff --git a/block/blk-core.c b/block/blk-core.c
index bc16e9bae2dc4..b530ce7b370c4 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -565,7 +565,6 @@  static int blk_partition_remap(struct bio *bio)
 static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 						 struct bio *bio)
 {
-	sector_t pos = bio->bi_iter.bi_sector;
 	int nr_sectors = bio_sectors(bio);
 
 	/* Only applicable to zoned block devices */
@@ -573,8 +572,8 @@  static inline blk_status_t blk_check_zone_append(struct request_queue *q,
 		return BLK_STS_NOTSUPP;
 
 	/* The bio sector must point to the start of a sequential zone */
-	if (pos & (blk_queue_zone_sectors(q) - 1) ||
-	    !blk_queue_zone_is_seq(q, pos))
+	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
+	    !bio_zone_is_seq(bio))
 		return BLK_STS_IOERR;
 
 	/*