aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2018-09-26 17:01:04 -0400
committerJens Axboe <axboe@kernel.dk>2018-09-26 17:11:28 -0400
commitcd84a62e0078dce09f4ed349bec84f86c9d54b30 (patch)
tree2cdd58e3abebc23c86351ca12815b751a62bdc1a /include/linux/blkdev.h
parentbca6b067b0b269a7b8ba129e2a918309ca8b4a55 (diff)
block, scsi: Change the preempt-only flag into a counter
The RQF_PREEMPT flag is used for three purposes: - In the SCSI core, for making sure that power management requests are executed even if a device is in the "quiesced" state. - For domain validation by SCSI drivers that use the parallel port. - In the IDE driver, for IDE preempt requests. Rename "preempt-only" into "pm-only" because the primary purpose of this mode is power management. Since the power management core may but does not have to resume a runtime suspended device before performing system-wide suspend and since a later patch will set "pm-only" mode as long as a block device is runtime suspended, make it possible to set "pm-only" mode from more than one context. Since with this change scsi_device_quiesce() is no longer idempotent, make that function return early if it is called for a quiesced queue. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Cc: Jianchao Wang <jianchao.w.wang@oracle.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index cd863511dedb..13bb54f26736 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -504,6 +504,12 @@ struct request_queue {
504 * various queue flags, see QUEUE_* below 504 * various queue flags, see QUEUE_* below
505 */ 505 */
506 unsigned long queue_flags; 506 unsigned long queue_flags;
507 /*
508 * Number of contexts that have called blk_set_pm_only(). If this
509 * counter is above zero then only RQF_PM and RQF_PREEMPT requests are
510 * processed.
511 */
512 atomic_t pm_only;
507 513
508 /* 514 /*
509 * ida allocated id for this queue. Used to index queues from 515 * ida allocated id for this queue. Used to index queues from
@@ -698,7 +704,6 @@ struct request_queue {
698#define QUEUE_FLAG_REGISTERED 26 /* queue has been registered to a disk */ 704#define QUEUE_FLAG_REGISTERED 26 /* queue has been registered to a disk */
699#define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */ 705#define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */
700#define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */ 706#define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */
701#define QUEUE_FLAG_PREEMPT_ONLY 29 /* only process REQ_PREEMPT requests */
702 707
703#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ 708#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
704 (1 << QUEUE_FLAG_SAME_COMP) | \ 709 (1 << QUEUE_FLAG_SAME_COMP) | \
@@ -736,12 +741,11 @@ bool blk_queue_flag_test_and_clear(unsigned int flag, struct request_queue *q);
736 ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ 741 ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
737 REQ_FAILFAST_DRIVER)) 742 REQ_FAILFAST_DRIVER))
738#define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags) 743#define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags)
739#define blk_queue_preempt_only(q) \ 744#define blk_queue_pm_only(q) atomic_read(&(q)->pm_only)
740 test_bit(QUEUE_FLAG_PREEMPT_ONLY, &(q)->queue_flags)
741#define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags) 745#define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)
742 746
743extern int blk_set_preempt_only(struct request_queue *q); 747extern void blk_set_pm_only(struct request_queue *q);
744extern void blk_clear_preempt_only(struct request_queue *q); 748extern void blk_clear_pm_only(struct request_queue *q);
745 749
746static inline int queue_in_flight(struct request_queue *q) 750static inline int queue_in_flight(struct request_queue *q)
747{ 751{