Skip to content

Commit 021a244

Browse files
snitmaxboe
authored andcommitted
block: add QUEUE_FLAG_NOWAIT
Add QUEUE_FLAG_NOWAIT to allow a block device to advertise support for REQ_NOWAIT. Bio-based devices may set QUEUE_FLAG_NOWAIT where applicable. Update QUEUE_FLAG_MQ_DEFAULT to include QUEUE_FLAG_NOWAIT. Also update submit_bio_checks() to verify it is set for REQ_NOWAIT bios. Reported-by: Konstantin Khlebnikov <[email protected]> Suggested-by: Christoph Hellwig <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 700cd59 commit 021a244

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

block/blk-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,9 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
814814

815815
/*
816816
* For a REQ_NOWAIT based request, return -EOPNOTSUPP
817-
* if queue is not a request based queue.
817+
* if queue does not support NOWAIT.
818818
*/
819-
if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_mq(q))
819+
if ((bio->bi_opf & REQ_NOWAIT) && !blk_queue_nowait(q))
820820
goto not_supported;
821821

822822
if (should_fail_bio(bio))

include/linux/blkdev.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,12 @@ struct request_queue {
619619
#define QUEUE_FLAG_PCI_P2PDMA 25 /* device supports PCI p2p requests */
620620
#define QUEUE_FLAG_ZONE_RESETALL 26 /* supports Zone Reset All */
621621
#define QUEUE_FLAG_RQ_ALLOC_TIME 27 /* record rq->alloc_time_ns */
622-
#define QUEUE_FLAG_HCTX_ACTIVE 28 /* at least one blk-mq hctx is active */
622+
#define QUEUE_FLAG_HCTX_ACTIVE 28 /* at least one blk-mq hctx is active */
623+
#define QUEUE_FLAG_NOWAIT 29 /* device supports NOWAIT */
623624

624625
#define QUEUE_FLAG_MQ_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
625-
(1 << QUEUE_FLAG_SAME_COMP))
626+
(1 << QUEUE_FLAG_SAME_COMP) | \
627+
(1 << QUEUE_FLAG_NOWAIT))
626628

627629
void blk_queue_flag_set(unsigned int flag, struct request_queue *q);
628630
void blk_queue_flag_clear(unsigned int flag, struct request_queue *q);
@@ -664,6 +666,7 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q);
664666
#define blk_queue_pm_only(q) atomic_read(&(q)->pm_only)
665667
#define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)
666668
#define blk_queue_registered(q) test_bit(QUEUE_FLAG_REGISTERED, &(q)->queue_flags)
669+
#define blk_queue_nowait(q) test_bit(QUEUE_FLAG_NOWAIT, &(q)->queue_flags)
667670

668671
extern void blk_set_pm_only(struct request_queue *q);
669672
extern void blk_clear_pm_only(struct request_queue *q);

0 commit comments

Comments
 (0)