Skip to contentSkip to conversation

block/mq-deadline: Fix a bug in deadline_from_pos()

PATCH Applied Bart Van Assche 3 participants 3 messages Jul 12, 2023 – Jul 13, 2023 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/mq-deadline: Fix a bug in deadline_from_pos()

A bug was introduced in deadline_from_pos() while implementing the suggestion to use round_down() in the following code:

	pos -= bdev_offset_from_zone_start(rq->q->disk->part0, pos);

This patch makes deadline_from_pos() use round_down() such that 'pos' is rounded down.

Cc Christoph Hellwig <[email protected]>
Cc Damien Le Moal <[email protected]>
Fixes 0effb390c4ba ("block: mq-deadline: Handle requeued requests correctly")
---
 block/mq-deadline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/mq-deadline.c +1 -1
index 0bed2bdeed89..f783ed71ae19 100644
@@ -176,7 +176,7 @@ static inline struct request *deadline_from_pos(struct dd_per_prio *per_prio,
 	 * zoned writes, start searching from the start of a zone.
 	 */
 	if (blk_rq_is_seq_zoned_write(rq))
-		pos -= round_down(pos, rq->q->limits.chunk_sectors);
+		pos = round_down(pos, rq->q->limits.chunk_sectors);
 
 	while (node) {
 		rq = rb_entry_rq(node);
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Bart Van Assche

A bug was introduced in deadline_from_pos() while implementing the suggestion to use round_down() in the following code:

	pos -= bdev_offset_from_zone_start(rq->q->disk->part0, pos);

This patch makes deadline_from_pos() use round_down() such that 'pos' is rounded down.

Quoted 6 lines
Cc Christoph Hellwig <[email protected]>
Cc Damien Le Moal <[email protected]>
Fixes 0effb390c4ba ("block: mq-deadline: Handle requeued requests correctly")

Thanks for the fix. I confirmed that it avoids the I/O error using a zoned null_blk device, a QEMU ZNS emulation device and a real ZNS drive.

maintainer Applied
#2 lore raw
In reply to Bart Van Assche
Quoted 9 lines · Bart Van Assche

A bug was introduced in deadline_from_pos() while implementing the suggestion to use round_down() in the following code:

	pos -= bdev_offset_from_zone_start(rq->q->disk->part0, pos);

This patch makes deadline_from_pos() use round_down() such that 'pos' is rounded down.

[...]

Applied, thanks!

[1/1] block/mq-deadline: Fix a bug in deadline_from_pos()
(no commit info)

Best regards,

Signature · 1 line
Jens Axboe