[PATCH v2 2/9] block: reuse part_in_flight_rw for part_in_flight

Yu Kuai posted 9 patches 7 months, 3 weeks ago
There is a newer version of this series
[PATCH v2 2/9] block: reuse part_in_flight_rw for part_in_flight
Posted by Yu Kuai 7 months, 3 weeks ago
From: Yu Kuai <yukuai3@huawei.com>

They are almost identical, to make code cleaner.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/genhd.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index c2bd86cd09de..f671d9ee00c4 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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.
  *
-- 
2.39.2
Re: [PATCH v2 2/9] block: reuse part_in_flight_rw for part_in_flight
Posted by Hannes Reinecke 7 months, 3 weeks ago
On 4/27/25 10:29, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> They are almost identical, to make code cleaner.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   block/genhd.c | 24 +++++++++---------------
>   1 file changed, 9 insertions(+), 15 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH v2 2/9] block: reuse part_in_flight_rw for part_in_flight
Posted by John Garry 7 months, 3 weeks ago
On 27/04/2025 09:29, Yu Kuai wrote:
> From: Yu Kuai<yukuai3@huawei.com>
> 
> They are almost identical, to make code cleaner.
> 
> Signed-off-by: Yu Kuai<yukuai3@huawei.com>

FWIW:
Reviewed-by: John Garry <john.g.garry@oracle.com>
Re: [PATCH v2 2/9] block: reuse part_in_flight_rw for part_in_flight
Posted by Christoph Hellwig 7 months, 3 weeks ago
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>