diff options
author | Jens Axboe <axboe@kernel.dk> | 2017-08-08 19:51:45 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-08-09 15:09:28 -0400 |
commit | f299b7c7a9dee64425e5965bd4f56dc024c1befc (patch) | |
tree | d81520896fad3b9d3e87c19d538ec00c052d1b7c /block/genhd.c | |
parent | 0609e0efc5e15195ecf8c6d2f2e890d98760e337 (diff) |
blk-mq: provide internal in-flight variant
We don't have to inc/dec some counter, since we can just
iterate the tags. That makes inc/dec a noop, but means we
have to iterate busy tags to get an in-flight count.
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c index 822f65f95e2a..3dc4d115480f 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -45,6 +45,43 @@ static void disk_add_events(struct gendisk *disk); | |||
45 | static void disk_del_events(struct gendisk *disk); | 45 | static void disk_del_events(struct gendisk *disk); |
46 | static void disk_release_events(struct gendisk *disk); | 46 | static void disk_release_events(struct gendisk *disk); |
47 | 47 | ||
48 | void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, int rw) | ||
49 | { | ||
50 | if (q->mq_ops) | ||
51 | return; | ||
52 | |||
53 | atomic_inc(&part->in_flight[rw]); | ||
54 | if (part->partno) | ||
55 | atomic_inc(&part_to_disk(part)->part0.in_flight[rw]); | ||
56 | } | ||
57 | |||
58 | void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw) | ||
59 | { | ||
60 | if (q->mq_ops) | ||
61 | return; | ||
62 | |||
63 | atomic_dec(&part->in_flight[rw]); | ||
64 | if (part->partno) | ||
65 | atomic_dec(&part_to_disk(part)->part0.in_flight[rw]); | ||
66 | } | ||
67 | |||
68 | void part_in_flight(struct request_queue *q, struct hd_struct *part, | ||
69 | unsigned int inflight[2]) | ||
70 | { | ||
71 | if (q->mq_ops) { | ||
72 | blk_mq_in_flight(q, part, inflight); | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | inflight[0] = atomic_read(&part->in_flight[0]) + | ||
77 | atomic_read(&part->in_flight[1]); | ||
78 | if (part->partno) { | ||
79 | part = &part_to_disk(part)->part0; | ||
80 | inflight[1] = atomic_read(&part->in_flight[0]) + | ||
81 | atomic_read(&part->in_flight[1]); | ||
82 | } | ||
83 | } | ||
84 | |||
48 | /** | 85 | /** |
49 | * disk_get_part - get partition | 86 | * disk_get_part - get partition |
50 | * @disk: disk to look partition from | 87 | * @disk: disk to look partition from |