Skip to content

Commit

Permalink
block: make part_in_flight() take an array of two ints
Browse files Browse the repository at this point in the history
Instead of returning the count that matches the partition, pass
in an array of two ints. Index 0 will be filled with the inflight
count for the partition in question, and index 1 will filled
with the root inflight count, if the partition passed in is not the
root.

This is in preparation for being able to calculate both in one
go.

Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Aug 9, 2017
1 parent d62e26b commit 0609e0e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
8 changes: 4 additions & 4 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,15 +1472,15 @@ static void add_acct_request(struct request_queue *q, struct request *rq,
static void part_round_stats_single(struct request_queue *q, int cpu,
struct hd_struct *part, unsigned long now)
{
int inflight;
int inflight[2];

if (now == part->stamp)
return;

inflight = part_in_flight(q, part);
if (inflight) {
part_in_flight(q, part, inflight);
if (inflight[0]) {
__part_stat_add(cpu, part, time_in_queue,
inflight * (now - part->stamp));
inflight[0] * (now - part->stamp));
__part_stat_add(cpu, part, io_ticks, (now - part->stamp));
}
part->stamp = now;
Expand Down
4 changes: 3 additions & 1 deletion block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
struct disk_part_iter piter;
struct hd_struct *hd;
char buf[BDEVNAME_SIZE];
unsigned int inflight[2];
int cpu;

/*
Expand All @@ -1219,6 +1220,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
cpu = part_stat_lock();
part_round_stats(gp->queue, cpu, hd);
part_stat_unlock();
part_in_flight(gp->queue, hd, inflight);
seq_printf(seqf, "%4d %7d %s %lu %lu %lu "
"%u %lu %lu %lu %u %u %u %u\n",
MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
Expand All @@ -1231,7 +1233,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
part_stat_read(hd, merges[WRITE]),
part_stat_read(hd, sectors[WRITE]),
jiffies_to_msecs(part_stat_read(hd, ticks[WRITE])),
part_in_flight(gp->queue, hd),
inflight[0],
jiffies_to_msecs(part_stat_read(hd, io_ticks)),
jiffies_to_msecs(part_stat_read(hd, time_in_queue))
);
Expand Down
4 changes: 3 additions & 1 deletion block/partition-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ ssize_t part_stat_show(struct device *dev,
{
struct hd_struct *p = dev_to_part(dev);
struct request_queue *q = dev_to_disk(dev)->queue;
unsigned int inflight[2];
int cpu;

cpu = part_stat_lock();
part_round_stats(q, cpu, p);
part_stat_unlock();
part_in_flight(q, p, inflight);
return sprintf(buf,
"%8lu %8lu %8llu %8u "
"%8lu %8lu %8llu %8u "
Expand All @@ -131,7 +133,7 @@ ssize_t part_stat_show(struct device *dev,
part_stat_read(p, merges[WRITE]),
(unsigned long long)part_stat_read(p, sectors[WRITE]),
jiffies_to_msecs(part_stat_read(p, ticks[WRITE])),
part_in_flight(q, p),
inflight[0],
jiffies_to_msecs(part_stat_read(p, io_ticks)),
jiffies_to_msecs(part_stat_read(p, time_in_queue)));
}
Expand Down
13 changes: 10 additions & 3 deletions include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,18 @@ static inline void part_dec_in_flight(struct request_queue *q,
atomic_dec(&part_to_disk(part)->part0.in_flight[rw]);
}

static inline int part_in_flight(struct request_queue *q,
struct hd_struct *part)
static inline void part_in_flight(struct request_queue *q,
struct hd_struct *part,
unsigned int inflight[2])
{
return atomic_read(&part->in_flight[0]) +
inflight[0] = atomic_read(&part->in_flight[0]) +
atomic_read(&part->in_flight[1]);
if (part->partno) {
part = &part_to_disk(part)->part0;
inflight[1] = atomic_read(&part->in_flight[0]) +
atomic_read(&part->in_flight[1]);
} else
inflight[1] = 0;
}

static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk)
Expand Down

0 comments on commit 0609e0e

Please sign in to comment.