summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2018-12-06 11:41:21 -0500
committerJens Axboe <axboe@kernel.dk>2018-12-10 10:30:38 -0500
commite016b78201a2d9ff40f3f0da072292689af24c7f (patch)
treec81a404bcfe431857279e2f18c4a20e38191609c
parent1226b8dd0e91331cfab500f305b2c264445a0392 (diff)
block: return just one value from part_in_flight
The previous patches deleted all the code that needed the second value returned from part_in_flight - now the kernel only uses the first value. Consequently, part_in_flight (and blk_mq_in_flight) may be changed so that it only returns one value. This patch just refactors the code, there's no functional change. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-mq.c12
-rw-r--r--block/blk-mq.h3
-rw-r--r--block/genhd.c34
-rw-r--r--block/partition-generic.c6
-rw-r--r--include/linux/genhd.h3
5 files changed, 22 insertions, 36 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index b645275dfe5f..9690f4f8de7e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -100,25 +100,23 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx,
100 struct mq_inflight *mi = priv; 100 struct mq_inflight *mi = priv;
101 101
102 /* 102 /*
103 * index[0] counts the specific partition that was asked for. index[1] 103 * index[0] counts the specific partition that was asked for.
104 * counts the ones that are active on the whole device, so increment
105 * that if mi->part is indeed a partition, and not a whole device.
106 */ 104 */
107 if (rq->part == mi->part) 105 if (rq->part == mi->part)
108 mi->inflight[0]++; 106 mi->inflight[0]++;
109 if (mi->part->partno)
110 mi->inflight[1]++;
111 107
112 return true; 108 return true;
113} 109}
114 110
115void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, 111unsigned int blk_mq_in_flight(struct request_queue *q, struct hd_struct *part)
116 unsigned int inflight[2])
117{ 112{
113 unsigned inflight[2];
118 struct mq_inflight mi = { .part = part, .inflight = inflight, }; 114 struct mq_inflight mi = { .part = part, .inflight = inflight, };
119 115
120 inflight[0] = inflight[1] = 0; 116 inflight[0] = inflight[1] = 0;
121 blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); 117 blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi);
118
119 return inflight[0];
122} 120}
123 121
124static bool blk_mq_check_inflight_rw(struct blk_mq_hw_ctx *hctx, 122static bool blk_mq_check_inflight_rw(struct blk_mq_hw_ctx *hctx,
diff --git a/block/blk-mq.h b/block/blk-mq.h
index a664ea44ffd4..0c9c9ea2fefe 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -187,8 +187,7 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx)
187 return hctx->nr_ctx && hctx->tags; 187 return hctx->nr_ctx && hctx->tags;
188} 188}
189 189
190void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, 190unsigned int blk_mq_in_flight(struct request_queue *q, struct hd_struct *part);
191 unsigned int inflight[2]);
192void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part, 191void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part,
193 unsigned int inflight[2]); 192 unsigned int inflight[2]);
194 193
diff --git a/block/genhd.c b/block/genhd.c
index 9827a2c05db7..1dd8fd6613b8 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -65,34 +65,24 @@ void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw)
65 part_stat_local_dec(&part_to_disk(part)->part0, in_flight[rw]); 65 part_stat_local_dec(&part_to_disk(part)->part0, in_flight[rw]);
66} 66}
67 67
68void part_in_flight(struct request_queue *q, struct hd_struct *part, 68unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part)
69 unsigned int inflight[2])
70{ 69{
71 int cpu; 70 int cpu;
71 unsigned int inflight;
72 72
73 if (queue_is_mq(q)) { 73 if (queue_is_mq(q)) {
74 blk_mq_in_flight(q, part, inflight); 74 return blk_mq_in_flight(q, part);
75 return;
76 } 75 }
77 76
78 inflight[0] = 0; 77 inflight = 0;
79 for_each_possible_cpu(cpu) { 78 for_each_possible_cpu(cpu) {
80 inflight[0] += part_stat_local_read_cpu(part, in_flight[0], cpu) + 79 inflight += part_stat_local_read_cpu(part, in_flight[0], cpu) +
81 part_stat_local_read_cpu(part, in_flight[1], cpu); 80 part_stat_local_read_cpu(part, in_flight[1], cpu);
82 } 81 }
83 if ((int)inflight[0] < 0) 82 if ((int)inflight < 0)
84 inflight[0] = 0; 83 inflight = 0;
85 84
86 if (part->partno) { 85 return inflight;
87 part = &part_to_disk(part)->part0;
88 inflight[1] = 0;
89 for_each_possible_cpu(cpu) {
90 inflight[1] += part_stat_local_read_cpu(part, in_flight[0], cpu) +
91 part_stat_local_read_cpu(part, in_flight[1], cpu);
92 }
93 if ((int)inflight[1] < 0)
94 inflight[1] = 0;
95 }
96} 86}
97 87
98void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, 88void part_in_flight_rw(struct request_queue *q, struct hd_struct *part,
@@ -1348,7 +1338,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
1348 struct disk_part_iter piter; 1338 struct disk_part_iter piter;
1349 struct hd_struct *hd; 1339 struct hd_struct *hd;
1350 char buf[BDEVNAME_SIZE]; 1340 char buf[BDEVNAME_SIZE];
1351 unsigned int inflight[2]; 1341 unsigned int inflight;
1352 1342
1353 /* 1343 /*
1354 if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next) 1344 if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next)
@@ -1360,7 +1350,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
1360 1350
1361 disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0); 1351 disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
1362 while ((hd = disk_part_iter_next(&piter))) { 1352 while ((hd = disk_part_iter_next(&piter))) {
1363 part_in_flight(gp->queue, hd, inflight); 1353 inflight = part_in_flight(gp->queue, hd);
1364 seq_printf(seqf, "%4d %7d %s " 1354 seq_printf(seqf, "%4d %7d %s "
1365 "%lu %lu %lu %u " 1355 "%lu %lu %lu %u "
1366 "%lu %lu %lu %u " 1356 "%lu %lu %lu %u "
@@ -1376,7 +1366,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
1376 part_stat_read(hd, merges[STAT_WRITE]), 1366 part_stat_read(hd, merges[STAT_WRITE]),
1377 part_stat_read(hd, sectors[STAT_WRITE]), 1367 part_stat_read(hd, sectors[STAT_WRITE]),
1378 (unsigned int)part_stat_read_msecs(hd, STAT_WRITE), 1368 (unsigned int)part_stat_read_msecs(hd, STAT_WRITE),
1379 inflight[0], 1369 inflight,
1380 jiffies_to_msecs(part_stat_read(hd, io_ticks)), 1370 jiffies_to_msecs(part_stat_read(hd, io_ticks)),
1381 jiffies_to_msecs(part_stat_read(hd, time_in_queue)), 1371 jiffies_to_msecs(part_stat_read(hd, time_in_queue)),
1382 part_stat_read(hd, ios[STAT_DISCARD]), 1372 part_stat_read(hd, ios[STAT_DISCARD]),
diff --git a/block/partition-generic.c b/block/partition-generic.c
index 42d6138ac876..8e596a8dff32 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -120,9 +120,9 @@ ssize_t part_stat_show(struct device *dev,
120{ 120{
121 struct hd_struct *p = dev_to_part(dev); 121 struct hd_struct *p = dev_to_part(dev);
122 struct request_queue *q = part_to_disk(p)->queue; 122 struct request_queue *q = part_to_disk(p)->queue;
123 unsigned int inflight[2]; 123 unsigned int inflight;
124 124
125 part_in_flight(q, p, inflight); 125 inflight = part_in_flight(q, p);
126 return sprintf(buf, 126 return sprintf(buf,
127 "%8lu %8lu %8llu %8u " 127 "%8lu %8lu %8llu %8u "
128 "%8lu %8lu %8llu %8u " 128 "%8lu %8lu %8llu %8u "
@@ -137,7 +137,7 @@ ssize_t part_stat_show(struct device *dev,
137 part_stat_read(p, merges[STAT_WRITE]), 137 part_stat_read(p, merges[STAT_WRITE]),
138 (unsigned long long)part_stat_read(p, sectors[STAT_WRITE]), 138 (unsigned long long)part_stat_read(p, sectors[STAT_WRITE]),
139 (unsigned int)part_stat_read_msecs(p, STAT_WRITE), 139 (unsigned int)part_stat_read_msecs(p, STAT_WRITE),
140 inflight[0], 140 inflight,
141 jiffies_to_msecs(part_stat_read(p, io_ticks)), 141 jiffies_to_msecs(part_stat_read(p, io_ticks)),
142 jiffies_to_msecs(part_stat_read(p, time_in_queue)), 142 jiffies_to_msecs(part_stat_read(p, time_in_queue)),
143 part_stat_read(p, ios[STAT_DISCARD]), 143 part_stat_read(p, ios[STAT_DISCARD]),
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 636b4f687e35..06c0fd594097 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -391,8 +391,7 @@ static inline void free_part_stats(struct hd_struct *part)
391#define part_stat_local_read_cpu(gendiskp, field, cpu) \ 391#define part_stat_local_read_cpu(gendiskp, field, cpu) \
392 local_read(&(part_stat_get_cpu(gendiskp, field, cpu))) 392 local_read(&(part_stat_get_cpu(gendiskp, field, cpu)))
393 393
394void part_in_flight(struct request_queue *q, struct hd_struct *part, 394unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part);
395 unsigned int inflight[2]);
396void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, 395void part_in_flight_rw(struct request_queue *q, struct hd_struct *part,
397 unsigned int inflight[2]); 396 unsigned int inflight[2]);
398void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, 397void part_dec_in_flight(struct request_queue *q, struct hd_struct *part,