]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
block: reuse part_in_flight_rw for part_in_flight
authorYu Kuai <yukuai3@huawei.com>
Tue, 6 May 2025 12:48:55 +0000 (20:48 +0800)
committerYu Kuai <yukuai3@huawei.com>
Sat, 10 May 2025 08:05:38 +0000 (16:05 +0800)
They are almost identical, to make code cleaner.

Link: https://lore.kernel.org/linux-raid/20250506124903.2540268-2-yukuai1@huaweicloud.com
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
block/genhd.c

index 9c7c657380db75e5ad61940a0b15a0f7d7a90c9f..1df776e4ef927ebf1ae93480485f6c0255a741aa 100644 (file)
@@ -125,21 +125,6 @@ static void part_stat_read_all(struct block_device *part,
        }
 }
 
-unsigned int part_in_flight(struct block_device *part)
-{
-       unsigned int inflight = 0;
-       int cpu;
-
-       for_each_possible_cpu(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)
-               inflight = 0;
-
-       return inflight;
-}
-
 static void part_in_flight_rw(struct block_device *part,
                unsigned int inflight[2])
 {
@@ -157,6 +142,15 @@ static void part_in_flight_rw(struct block_device *part,
                inflight[1] = 0;
 }
 
+unsigned int part_in_flight(struct block_device *part)
+{
+       unsigned int inflight[2];
+
+       part_in_flight_rw(part, inflight);
+
+       return inflight[READ] + inflight[WRITE];
+}
+
 /*
  * Can be deleted altogether. Later.
  *