On 5/24/22 07:19, Hannes Reinecke wrote: >> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h >> index c4e4c7071b7b..f5c7a41032ba 100644 >> --- a/include/linux/blkdev.h >> +++ b/include/linux/blkdev.h >> @@ -676,6 +676,21 @@ static inline unsigned int >> blk_queue_zone_no(struct request_queue *q, >> return div64_u64(sector, zone_sectors); >> } >> +static inline bool blk_queue_is_zone_start(struct request_queue *q, >> sector_t sec) >> +{ >> + sector_t zone_sectors = blk_queue_zone_sectors(q); >> + u64 remainder = 0; >> + >> + if (!blk_queue_is_zoned(q)) >> + return false; >> + > > Not sure if we need this here; surely blk_queue_zone_sectors() will > already barf, and none of the callers did this check. > I totally agree with you but all the other blk_queue_* functions had this defensive check and I didn't want to break that pattern: static inline unsigned int blk_queue_zone_no(struct request_queue *q, sector_t sector) { .... if (!blk_queue_is_zoned(q)) return 0; .... } >> + if (is_power_of_2(zone_sectors)) >> + return IS_ALIGNED(sec, zone_sectors); >> + And, if the chunk sectors is 0, then we will do the npo2 calculation resulting in a divide by zero even though chances of that happening is very very low as you pointed out. >> + div64_u64_rem(sec, zone_sectors, &remainder); >> + return remainder == 0; >> +} >> + >> static inline bool blk_queue_zone_is_seq(struct request_queue *q, >> sector_t sector) >> { >> @@ -722,6 +737,12 @@ static inline unsigned int >> blk_queue_zone_no(struct request_queue *q, >> { >> return 0; >> } >> + >> +static inline bool blk_queue_is_zone_start(struct request_queue *q, >> sector_t sec) >> +{ >> + return false; >> +} >> + >> static inline unsigned int queue_max_open_zones(const struct >> request_queue *q) >> { >> return 0; > Otherwise looks good. > Thanks! > Cheers, > > Hannes