Skip to content

Commit c9254f2

Browse files
KAGA-KOKOaxboe
authored andcommitted
block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag
This flag will be used in the next patch to let the block layer core know whether or not a SCSI request queue has been quiesced. A quiesced SCSI queue namely only processes RQF_PREEMPT requests. Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Martin Steigerwald <martin@lichtvoll.de> Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Cc: Ming Lei <ming.lei@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 039c635 commit c9254f2

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

block/blk-core.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,36 @@ void blk_sync_queue(struct request_queue *q)
348348
}
349349
EXPORT_SYMBOL(blk_sync_queue);
350350

351+
/**
352+
* blk_set_preempt_only - set QUEUE_FLAG_PREEMPT_ONLY
353+
* @q: request queue pointer
354+
*
355+
* Returns the previous value of the PREEMPT_ONLY flag - 0 if the flag was not
356+
* set and 1 if the flag was already set.
357+
*/
358+
int blk_set_preempt_only(struct request_queue *q)
359+
{
360+
unsigned long flags;
361+
int res;
362+
363+
spin_lock_irqsave(q->queue_lock, flags);
364+
res = queue_flag_test_and_set(QUEUE_FLAG_PREEMPT_ONLY, q);
365+
spin_unlock_irqrestore(q->queue_lock, flags);
366+
367+
return res;
368+
}
369+
EXPORT_SYMBOL_GPL(blk_set_preempt_only);
370+
371+
void blk_clear_preempt_only(struct request_queue *q)
372+
{
373+
unsigned long flags;
374+
375+
spin_lock_irqsave(q->queue_lock, flags);
376+
queue_flag_clear(QUEUE_FLAG_PREEMPT_ONLY, q);
377+
spin_unlock_irqrestore(q->queue_lock, flags);
378+
}
379+
EXPORT_SYMBOL_GPL(blk_clear_preempt_only);
380+
351381
/**
352382
* __blk_run_queue_uncond - run a queue whether or not it has been stopped
353383
* @q: The queue to run

block/blk-mq-debugfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static const char *const blk_queue_flag_name[] = {
7474
QUEUE_FLAG_NAME(REGISTERED),
7575
QUEUE_FLAG_NAME(SCSI_PASSTHROUGH),
7676
QUEUE_FLAG_NAME(QUIESCED),
77+
QUEUE_FLAG_NAME(PREEMPT_ONLY),
7778
};
7879
#undef QUEUE_FLAG_NAME
7980

include/linux/blkdev.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ struct request_queue {
632632
#define QUEUE_FLAG_REGISTERED 26 /* queue has been registered to a disk */
633633
#define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */
634634
#define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */
635+
#define QUEUE_FLAG_PREEMPT_ONLY 29 /* only process REQ_PREEMPT requests */
635636

636637
#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
637638
(1 << QUEUE_FLAG_SAME_COMP) | \
@@ -732,6 +733,11 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
732733
((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
733734
REQ_FAILFAST_DRIVER))
734735
#define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags)
736+
#define blk_queue_preempt_only(q) \
737+
test_bit(QUEUE_FLAG_PREEMPT_ONLY, &(q)->queue_flags)
738+
739+
extern int blk_set_preempt_only(struct request_queue *q);
740+
extern void blk_clear_preempt_only(struct request_queue *q);
735741

736742
static inline bool blk_account_rq(struct request *rq)
737743
{

0 commit comments

Comments
 (0)