Skip to content

Commit dfed015

Browse files
author
Ming Lei
committed
block: check BLK_FEAT_POLL under q_usage_count
JIRA: https://issues.redhat.com/browse/RHEL-71345 Upstream Status: for-6.4/block commit 958148a Author: Christoph Hellwig <hch@lst.de> Date: Fri Jan 10 06:47:11 2025 +0100 block: check BLK_FEAT_POLL under q_usage_count Otherwise feature reconfiguration can race with I/O submission. Also drop the bio_clear_polled in the error path, as the flag does not matter for instant error completions, it is a left over from when we allowed polled I/O to proceed unpolled in this case. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20250110054726.1499538-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent 9bb410e commit dfed015

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

block/blk-core.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,14 @@ static void __submit_bio(struct bio *bio)
613613
blk_mq_submit_bio(bio);
614614
} else if (likely(bio_queue_enter(bio) == 0)) {
615615
struct gendisk *disk = bio->bi_bdev->bd_disk;
616-
617-
disk->fops->submit_bio(bio);
616+
617+
if ((bio->bi_opf & REQ_POLLED) &&
618+
!(disk->queue->limits.features & BLK_FEAT_POLL)) {
619+
bio->bi_status = BLK_STS_NOTSUPP;
620+
bio_endio(bio);
621+
} else {
622+
disk->fops->submit_bio(bio);
623+
}
618624
blk_queue_exit(disk->queue);
619625
}
620626

@@ -788,12 +794,6 @@ void submit_bio_noacct(struct bio *bio)
788794
}
789795
}
790796

791-
if (!(q->limits.features & BLK_FEAT_POLL) &&
792-
(bio->bi_opf & REQ_POLLED)) {
793-
bio_clear_polled(bio);
794-
goto not_supported;
795-
}
796-
797797
switch (bio_op(bio)) {
798798
case REQ_OP_READ:
799799
break;
@@ -918,7 +918,7 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
918918
return 0;
919919

920920
q = bdev_get_queue(bdev);
921-
if (cookie == BLK_QC_T_NONE || !(q->limits.features & BLK_FEAT_POLL))
921+
if (cookie == BLK_QC_T_NONE)
922922
return 0;
923923

924924
blk_flush_plug(current->plug, false);
@@ -934,7 +934,9 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
934934
*/
935935
if (!percpu_ref_tryget(&q->q_usage_counter))
936936
return 0;
937-
if (queue_is_mq(q)) {
937+
if (!(q->limits.features & BLK_FEAT_POLL)) {
938+
ret = 0;
939+
} else if (queue_is_mq(q)) {
938940
ret = blk_mq_poll(q, cookie, iob, flags);
939941
} else {
940942
struct gendisk *disk = q->disk;

block/blk-mq.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,14 +2976,22 @@ void blk_mq_submit_bio(struct bio *bio)
29762976
}
29772977

29782978
/*
2979-
* Device reconfiguration may change logical block size, so alignment
2980-
* check has to be done with queue usage counter held
2979+
* Device reconfiguration may change logical block size or reduce the
2980+
* number of poll queues, so the checks for alignment and poll support
2981+
* have to be done with queue usage counter held.
29812982
*/
29822983
if (unlikely(bio_unaligned(bio, q))) {
29832984
bio_io_error(bio);
29842985
goto queue_exit;
29852986
}
29862987

2988+
if ((bio->bi_opf & REQ_POLLED) &&
2989+
!(q->limits.features & BLK_FEAT_POLL)) {
2990+
bio->bi_status = BLK_STS_NOTSUPP;
2991+
bio_endio(bio);
2992+
goto queue_exit;
2993+
}
2994+
29872995
bio = __bio_split_to_limits(bio, &q->limits, &nr_segs);
29882996
if (!bio)
29892997
goto queue_exit;

0 commit comments

Comments
 (0)