[PATCH 1/4] block: export part_in_flight()

From: Yu Kuai
Date: Sat Apr 12 2025 - 03:40:20 EST


From: Yu Kuai <yukuai3@xxxxxxxxxx>

This helper will be used in mdraid in later patches, check if there
are normal IO inflight while generating background sync IO, to fix a
problem in mdraid that foreground IO can be starved by background sync
IO.

Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
block/blk.h | 1 -
block/genhd.c | 1 +
include/linux/part_stat.h | 1 +
3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk.h b/block/blk.h
index 006e3be433d2..f476f233f195 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -418,7 +418,6 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi,
int blk_dev_init(void);

void update_io_ticks(struct block_device *part, unsigned long now, bool end);
-unsigned int part_in_flight(struct block_device *part);

static inline void req_set_nomerge(struct request_queue *q, struct request *req)
{
diff --git a/block/genhd.c b/block/genhd.c
index c2bd86cd09de..5b408d9b5a9d 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -139,6 +139,7 @@ unsigned int part_in_flight(struct block_device *part)

return inflight;
}
+EXPORT_SYMBOL_GPL(part_in_flight);

static void part_in_flight_rw(struct block_device *part,
unsigned int inflight[2])
diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h
index c5e9cac0575e..79ed730a8d50 100644
--- a/include/linux/part_stat.h
+++ b/include/linux/part_stat.h
@@ -79,4 +79,5 @@ static inline void part_stat_set_all(struct block_device *part, int value)
#define part_stat_local_read_cpu(part, field, cpu) \
local_read(&(part_stat_get_cpu(part, field, cpu)))

+unsigned int part_in_flight(struct block_device *part);
#endif /* _LINUX_PART_STAT_H */
--
2.39.2