diff options
author | Bart Van Assche <bvanassche@acm.org> | 2018-09-26 17:01:05 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-09-26 17:11:28 -0400 |
commit | 154b00d566e221152514ba8259f38b21571081ef (patch) | |
tree | a345b1b1a6ec827fdbe0930269f4a8126205939a | |
parent | cd84a62e0078dce09f4ed349bec84f86c9d54b30 (diff) |
block: Split blk_pm_add_request() and blk_pm_put_request()
Move the pm_request_resume() and pm_runtime_mark_last_busy() calls into
two new functions and thereby separate legacy block layer code from code
that works for both the legacy block layer and blk-mq. A later patch will
add calls to the new functions in the blk-mq code.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Jianchao Wang <jianchao.w.wang@oracle.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-core.c | 1 | ||||
-rw-r--r-- | block/blk-pm.h | 36 | ||||
-rw-r--r-- | block/elevator.c | 1 |
3 files changed, 33 insertions, 5 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 1a691f5269bb..fd91e9bf2893 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1744,6 +1744,7 @@ void __blk_put_request(struct request_queue *q, struct request *req) | |||
1744 | 1744 | ||
1745 | blk_req_zone_write_unlock(req); | 1745 | blk_req_zone_write_unlock(req); |
1746 | blk_pm_put_request(req); | 1746 | blk_pm_put_request(req); |
1747 | blk_pm_mark_last_busy(req); | ||
1747 | 1748 | ||
1748 | elv_completed_request(q, req); | 1749 | elv_completed_request(q, req); |
1749 | 1750 | ||
diff --git a/block/blk-pm.h b/block/blk-pm.h index 1ffc8ef203ec..a8564ea72a41 100644 --- a/block/blk-pm.h +++ b/block/blk-pm.h | |||
@@ -6,8 +6,23 @@ | |||
6 | #include <linux/pm_runtime.h> | 6 | #include <linux/pm_runtime.h> |
7 | 7 | ||
8 | #ifdef CONFIG_PM | 8 | #ifdef CONFIG_PM |
9 | static inline void blk_pm_request_resume(struct request_queue *q) | ||
10 | { | ||
11 | if (q->dev && (q->rpm_status == RPM_SUSPENDED || | ||
12 | q->rpm_status == RPM_SUSPENDING)) | ||
13 | pm_request_resume(q->dev); | ||
14 | } | ||
15 | |||
16 | static inline void blk_pm_mark_last_busy(struct request *rq) | ||
17 | { | ||
18 | if (rq->q->dev && !(rq->rq_flags & RQF_PM)) | ||
19 | pm_runtime_mark_last_busy(rq->q->dev); | ||
20 | } | ||
21 | |||
9 | static inline void blk_pm_requeue_request(struct request *rq) | 22 | static inline void blk_pm_requeue_request(struct request *rq) |
10 | { | 23 | { |
24 | lockdep_assert_held(rq->q->queue_lock); | ||
25 | |||
11 | if (rq->q->dev && !(rq->rq_flags & RQF_PM)) | 26 | if (rq->q->dev && !(rq->rq_flags & RQF_PM)) |
12 | rq->q->nr_pending--; | 27 | rq->q->nr_pending--; |
13 | } | 28 | } |
@@ -15,17 +30,28 @@ static inline void blk_pm_requeue_request(struct request *rq) | |||
15 | static inline void blk_pm_add_request(struct request_queue *q, | 30 | static inline void blk_pm_add_request(struct request_queue *q, |
16 | struct request *rq) | 31 | struct request *rq) |
17 | { | 32 | { |
18 | if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 && | 33 | lockdep_assert_held(q->queue_lock); |
19 | (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING)) | 34 | |
20 | pm_request_resume(q->dev); | 35 | if (q->dev && !(rq->rq_flags & RQF_PM)) |
36 | q->nr_pending++; | ||
21 | } | 37 | } |
22 | 38 | ||
23 | static inline void blk_pm_put_request(struct request *rq) | 39 | static inline void blk_pm_put_request(struct request *rq) |
24 | { | 40 | { |
25 | if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending) | 41 | lockdep_assert_held(rq->q->queue_lock); |
26 | pm_runtime_mark_last_busy(rq->q->dev); | 42 | |
43 | if (rq->q->dev && !(rq->rq_flags & RQF_PM)) | ||
44 | --rq->q->nr_pending; | ||
27 | } | 45 | } |
28 | #else | 46 | #else |
47 | static inline void blk_pm_request_resume(struct request_queue *q) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | static inline void blk_pm_mark_last_busy(struct request *rq) | ||
52 | { | ||
53 | } | ||
54 | |||
29 | static inline void blk_pm_requeue_request(struct request *rq) | 55 | static inline void blk_pm_requeue_request(struct request *rq) |
30 | { | 56 | { |
31 | } | 57 | } |
diff --git a/block/elevator.c b/block/elevator.c index e18ac68626e3..1c992bf6cfb1 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -601,6 +601,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where) | |||
601 | trace_block_rq_insert(q, rq); | 601 | trace_block_rq_insert(q, rq); |
602 | 602 | ||
603 | blk_pm_add_request(q, rq); | 603 | blk_pm_add_request(q, rq); |
604 | blk_pm_request_resume(q); | ||
604 | 605 | ||
605 | rq->q = q; | 606 | rq->q = q; |
606 | 607 | ||