From: Yu Kuai <yukuai3@huawei.com>
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@huawei.com>
---
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
On Sat, Apr 12, 2025 at 03:31:59PM +0800, Yu Kuai wrote: > From: Yu Kuai <yukuai3@huawei.com> > > 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. If we export this it needs a kerneldoc comment, and probably also a better name. Looking at this I'm also a little confused about blk_mq_in_flight_rw vs blk_mq_in_flight and why one needs blk-mq special casing and the other not, maybe we need to dig into the history and try to understand that as well while we're at it.
Hi,
在 2025/04/14 14:32, Christoph Hellwig 写道:
> On Sat, Apr 12, 2025 at 03:31:59PM +0800, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> 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.
>
> If we export this it needs a kerneldoc comment, and probably also
> a better name.
Sure about comment.
>
> Looking at this I'm also a little confused about blk_mq_in_flight_rw vs
> blk_mq_in_flight and why one needs blk-mq special casing and the other
> not, maybe we need to dig into the history and try to understand that
> as well while we're at it.
There are two kinds of helpers:
1) part_in_flight and part_in_flight_rw
2) blk_mq_in_flight and blk_mq_in_flight_rw
1) is accounted at blk_account_io_start(), while 2) is
blk_mq_start_request(), I think this is the essential difference.
part_in_flight_rw() and blk_mq_in_flight_rw() is also used in sysfs API
inflight for bio/rq based device. And commit 7be835694dae ("block: fix
that util can be greater than 100%") convert blk_mq_in_flight() to
part_in_flight() from disk stats API. Now I just checked there is no use
for blk_mq_in_flight() anymore and maybe it can be removed.
Thanks,
Kuai
>
>
> .
>
On Mon, Apr 14, 2025 at 02:48:23PM +0800, Yu Kuai wrote:
> > If we export this it needs a kerneldoc comment, and probably also
> > a better name.
>
> Sure about comment.
I think a name like bdev_count_inflight might also be helpful as there
is nothing partition-specific in the helper.
> There are two kinds of helpers:
>
> 1) part_in_flight and part_in_flight_rw
> 2) blk_mq_in_flight and blk_mq_in_flight_rw
>
> 1) is accounted at blk_account_io_start(), while 2) is
> blk_mq_start_request(), I think this is the essential difference.
>
> part_in_flight_rw() and blk_mq_in_flight_rw() is also used in sysfs API
> inflight for bio/rq based device. And commit 7be835694dae ("block: fix
> that util can be greater than 100%") convert blk_mq_in_flight() to
> part_in_flight() from disk stats API. Now I just checked there is no use
> for blk_mq_in_flight() anymore and maybe it can be removed.
Yeah. I'm still confused about having the different methods to count
the _rw vs non-_rw variants for blk-mq, but I guess that's not really
in scope for your series.
© 2016 - 2025 Red Hat, Inc.