block: return just one value from part_in_flight
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 6 Dec 2018 16:41:21 +0000 (11:41 -0500)
committerJens Axboe <axboe@kernel.dk>
Mon, 10 Dec 2018 15:30:38 +0000 (08:30 -0700)
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>
block/blk-mq.c
block/blk-mq.h
block/genhd.c
block/partition-generic.c
include/linux/genhd.h

index b645275dfe5f22ea9ce39be7757e219388cfc093..9690f4f8de7ee7815a7f045706ccf8bcbeed89e4 100644 (file)
@@ -100,25 +100,23 @@ static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx,
        struct mq_inflight *mi = priv;
 
        /*
-        * index[0] counts the specific partition that was asked for. index[1]
-        * counts the ones that are active on the whole device, so increment
-        * that if mi->part is indeed a partition, and not a whole device.
+        * index[0] counts the specific partition that was asked for.
         */
        if (rq->part == mi->part)
                mi->inflight[0]++;
-       if (mi->part->partno)
-               mi->inflight[1]++;
 
        return true;
 }
 
-void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part,
-                     unsigned int inflight[2])
+unsigned int blk_mq_in_flight(struct request_queue *q, struct hd_struct *part)
 {
+       unsigned inflight[2];
        struct mq_inflight mi = { .part = part, .inflight = inflight, };
 
        inflight[0] = inflight[1] = 0;
        blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi);
+
+       return inflight[0];
 }
 
 static bool blk_mq_check_inflight_rw(struct blk_mq_hw_ctx *hctx,
index a664ea44ffd43d8b558589707eb6402537dcd9ab..0c9c9ea2fefedaeaf34807681853806242451f83 100644 (file)
@@ -187,8 +187,7 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx)
        return hctx->nr_ctx && hctx->tags;
 }
 
-void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part,
-                     unsigned int inflight[2]);
+unsigned int blk_mq_in_flight(struct request_queue *q, struct hd_struct *part);
 void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part,
                         unsigned int inflight[2]);
 
index 9827a2c05db7d02ec359b7ab566d87bd8801376b..1dd8fd6613b8d20e2292b73d001396efe1a6f718 100644 (file)
@@ -65,34 +65,24 @@ void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw)
                part_stat_local_dec(&part_to_disk(part)->part0, in_flight[rw]);
 }
 
-void part_in_flight(struct request_queue *q, struct hd_struct *part,
-                   unsigned int inflight[2])
+unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part)
 {
        int cpu;
+       unsigned int inflight;
 
        if (queue_is_mq(q)) {
-               blk_mq_in_flight(q, part, inflight);
-               return;
+               return blk_mq_in_flight(q, part);
        }
 
-       inflight[0] = 0;
+       inflight = 0;
        for_each_possible_cpu(cpu) {
-               inflight[0] += part_stat_local_read_cpu(part, in_flight[0], cpu) +
-                              part_stat_local_read_cpu(part, in_flight[1], cpu);
+               inflight += part_stat_local_read_cpu(part, in_flight[0], cpu) +
+                           part_stat_local_read_cpu(part, in_flight[1], cpu);
        }
-       if ((int)inflight[0] < 0)
-               inflight[0] = 0;
+       if ((int)inflight < 0)
+               inflight = 0;
 
-       if (part->partno) {
-               part = &part_to_disk(part)->part0;
-               inflight[1] = 0;
-               for_each_possible_cpu(cpu) {
-                       inflight[1] += part_stat_local_read_cpu(part, in_flight[0], cpu) +
-                                      part_stat_local_read_cpu(part, in_flight[1], cpu);
-               }
-               if ((int)inflight[1] < 0)
-                       inflight[1] = 0;
-       }
+       return inflight;
 }
 
 void 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)
        struct disk_part_iter piter;
        struct hd_struct *hd;
        char buf[BDEVNAME_SIZE];
-       unsigned int inflight[2];
+       unsigned int inflight;
 
        /*
        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)
 
        disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
        while ((hd = disk_part_iter_next(&piter))) {
-               part_in_flight(gp->queue, hd, inflight);
+               inflight = part_in_flight(gp->queue, hd);
                seq_printf(seqf, "%4d %7d %s "
                           "%lu %lu %lu %u "
                           "%lu %lu %lu %u "
@@ -1376,7 +1366,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
                           part_stat_read(hd, merges[STAT_WRITE]),
                           part_stat_read(hd, sectors[STAT_WRITE]),
                           (unsigned int)part_stat_read_msecs(hd, STAT_WRITE),
-                          inflight[0],
+                          inflight,
                           jiffies_to_msecs(part_stat_read(hd, io_ticks)),
                           jiffies_to_msecs(part_stat_read(hd, time_in_queue)),
                           part_stat_read(hd, ios[STAT_DISCARD]),
index 42d6138ac87677d3ff1390cf28d0eac5bf5235a2..8e596a8dff3217c1010b8c6364f78f33ef8b8b56 100644 (file)
@@ -120,9 +120,9 @@ ssize_t part_stat_show(struct device *dev,
 {
        struct hd_struct *p = dev_to_part(dev);
        struct request_queue *q = part_to_disk(p)->queue;
-       unsigned int inflight[2];
+       unsigned int inflight;
 
-       part_in_flight(q, p, inflight);
+       inflight = part_in_flight(q, p);
        return sprintf(buf,
                "%8lu %8lu %8llu %8u "
                "%8lu %8lu %8llu %8u "
@@ -137,7 +137,7 @@ ssize_t part_stat_show(struct device *dev,
                part_stat_read(p, merges[STAT_WRITE]),
                (unsigned long long)part_stat_read(p, sectors[STAT_WRITE]),
                (unsigned int)part_stat_read_msecs(p, STAT_WRITE),
-               inflight[0],
+               inflight,
                jiffies_to_msecs(part_stat_read(p, io_ticks)),
                jiffies_to_msecs(part_stat_read(p, time_in_queue)),
                part_stat_read(p, ios[STAT_DISCARD]),
index 636b4f687e35abea62ff545eb4359696e923d870..06c0fd594097d9566170d7d77a0da1d62ba174d9 100644 (file)
@@ -391,8 +391,7 @@ static inline void free_part_stats(struct hd_struct *part)
 #define part_stat_local_read_cpu(gendiskp, field, cpu)                 \
        local_read(&(part_stat_get_cpu(gendiskp, field, cpu)))
 
-void part_in_flight(struct request_queue *q, struct hd_struct *part,
-                   unsigned int inflight[2]);
+unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part);
 void part_in_flight_rw(struct request_queue *q, struct hd_struct *part,
                       unsigned int inflight[2]);
 void part_dec_in_flight(struct request_queue *q, struct hd_struct *part,