mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
block: export API to get the number of bdev inflight IO
- rename part_in_{flight, flight_rw} to bdev_count_{inflight, inflight_rw}
- export bdev_count_inflight, to fix a problem in mdraid that foreground
IO can be starved by background sync IO in later patches
Link: https://lore.kernel.org/linux-raid/20250506124903.2540268-6-yukuai1@huaweicloud.com
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
This commit is contained in:
parent
6b6c3a97ab
commit
f2987c5816
|
|
@ -1018,7 +1018,7 @@ again:
|
|||
stamp = READ_ONCE(part->bd_stamp);
|
||||
if (unlikely(time_after(now, stamp)) &&
|
||||
likely(try_cmpxchg(&part->bd_stamp, &stamp, now)) &&
|
||||
(end || part_in_flight(part)))
|
||||
(end || bdev_count_inflight(part)))
|
||||
__part_stat_add(part, io_ticks, now - stamp);
|
||||
|
||||
if (bdev_is_partition(part)) {
|
||||
|
|
|
|||
|
|
@ -419,7 +419,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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ static void part_stat_read_all(struct block_device *part,
|
|||
}
|
||||
}
|
||||
|
||||
static void part_in_flight_rw(struct block_device *part,
|
||||
static void bdev_count_inflight_rw(struct block_device *part,
|
||||
unsigned int inflight[2], bool mq_driver)
|
||||
{
|
||||
int cpu;
|
||||
|
|
@ -147,14 +147,24 @@ static void part_in_flight_rw(struct block_device *part,
|
|||
inflight[WRITE] = 0;
|
||||
}
|
||||
|
||||
unsigned int part_in_flight(struct block_device *part)
|
||||
/**
|
||||
* bdev_count_inflight - get the number of inflight IOs for a block device.
|
||||
*
|
||||
* @part: the block device.
|
||||
*
|
||||
* Inflight here means started IO accounting, from bdev_start_io_acct() for
|
||||
* bio-based block device, and from blk_account_io_start() for rq-based block
|
||||
* device.
|
||||
*/
|
||||
unsigned int bdev_count_inflight(struct block_device *part)
|
||||
{
|
||||
unsigned int inflight[2] = {0};
|
||||
|
||||
part_in_flight_rw(part, inflight, false);
|
||||
bdev_count_inflight_rw(part, inflight, false);
|
||||
|
||||
return inflight[READ] + inflight[WRITE];
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(bdev_count_inflight);
|
||||
|
||||
/*
|
||||
* Can be deleted altogether. Later.
|
||||
|
|
@ -1052,7 +1062,7 @@ ssize_t part_stat_show(struct device *dev,
|
|||
struct disk_stats stat;
|
||||
unsigned int inflight;
|
||||
|
||||
inflight = part_in_flight(bdev);
|
||||
inflight = bdev_count_inflight(bdev);
|
||||
if (inflight) {
|
||||
part_stat_lock();
|
||||
update_io_ticks(bdev, jiffies, true);
|
||||
|
|
@ -1101,7 +1111,7 @@ ssize_t part_inflight_show(struct device *dev, struct device_attribute *attr,
|
|||
struct request_queue *q = bdev_get_queue(bdev);
|
||||
unsigned int inflight[2] = {0};
|
||||
|
||||
part_in_flight_rw(bdev, inflight, queue_is_mq(q));
|
||||
bdev_count_inflight_rw(bdev, inflight, queue_is_mq(q));
|
||||
|
||||
return sysfs_emit(buf, "%8u %8u\n", inflight[READ], inflight[WRITE]);
|
||||
}
|
||||
|
|
@ -1356,7 +1366,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
|
|||
if (bdev_is_partition(hd) && !bdev_nr_sectors(hd))
|
||||
continue;
|
||||
|
||||
inflight = part_in_flight(hd);
|
||||
inflight = bdev_count_inflight(hd);
|
||||
if (inflight) {
|
||||
part_stat_lock();
|
||||
update_io_ticks(hd, jiffies, true);
|
||||
|
|
|
|||
|
|
@ -79,4 +79,6 @@ 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 bdev_count_inflight(struct block_device *part);
|
||||
|
||||
#endif /* _LINUX_PART_STAT_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user