Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Christoph Hellwig and committed by
Jens Axboe
958148a6 aa427d7b

+22 -12
+12 -10
block/blk-core.c
··· 629 629 blk_mq_submit_bio(bio); 630 630 } else if (likely(bio_queue_enter(bio) == 0)) { 631 631 struct gendisk *disk = bio->bi_bdev->bd_disk; 632 - 633 - disk->fops->submit_bio(bio); 632 + 633 + if ((bio->bi_opf & REQ_POLLED) && 634 + !(disk->queue->limits.features & BLK_FEAT_POLL)) { 635 + bio->bi_status = BLK_STS_NOTSUPP; 636 + bio_endio(bio); 637 + } else { 638 + disk->fops->submit_bio(bio); 639 + } 634 640 blk_queue_exit(disk->queue); 635 641 } 636 642 ··· 811 805 } 812 806 } 813 807 814 - if (!(q->limits.features & BLK_FEAT_POLL) && 815 - (bio->bi_opf & REQ_POLLED)) { 816 - bio_clear_polled(bio); 817 - goto not_supported; 818 - } 819 - 820 808 switch (bio_op(bio)) { 821 809 case REQ_OP_READ: 822 810 break; ··· 935 935 return 0; 936 936 937 937 q = bdev_get_queue(bdev); 938 - if (cookie == BLK_QC_T_NONE || !(q->limits.features & BLK_FEAT_POLL)) 938 + if (cookie == BLK_QC_T_NONE) 939 939 return 0; 940 940 941 941 blk_flush_plug(current->plug, false); ··· 951 951 */ 952 952 if (!percpu_ref_tryget(&q->q_usage_counter)) 953 953 return 0; 954 - if (queue_is_mq(q)) { 954 + if (!(q->limits.features & BLK_FEAT_POLL)) { 955 + ret = 0; 956 + } else if (queue_is_mq(q)) { 955 957 ret = blk_mq_poll(q, cookie, iob, flags); 956 958 } else { 957 959 struct gendisk *disk = q->disk;
+10 -2
block/blk-mq.c
··· 3096 3096 } 3097 3097 3098 3098 /* 3099 - * Device reconfiguration may change logical block size, so alignment 3100 - * check has to be done with queue usage counter held 3099 + * Device reconfiguration may change logical block size or reduce the 3100 + * number of poll queues, so the checks for alignment and poll support 3101 + * have to be done with queue usage counter held. 3101 3102 */ 3102 3103 if (unlikely(bio_unaligned(bio, q))) { 3103 3104 bio_io_error(bio); 3105 + goto queue_exit; 3106 + } 3107 + 3108 + if ((bio->bi_opf & REQ_POLLED) && 3109 + !(q->limits.features & BLK_FEAT_POLL)) { 3110 + bio->bi_status = BLK_STS_NOTSUPP; 3111 + bio_endio(bio); 3104 3112 goto queue_exit; 3105 3113 } 3106 3114