Skip to content

Commit 2ecbf45

Browse files
Josef Bacikaxboe
authored andcommitted
blk-stat: export helpers for modifying blk_rq_stat
We need to use blk_rq_stat in the blkcg qos stuff, so export some of these helpers so they can be used by other things. Signed-off-by: Josef Bacik <jbacik@fb.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2cf8558 commit 2ecbf45

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

block/blk-stat.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ struct blk_queue_stats {
1717
bool enable_accounting;
1818
};
1919

20-
static void blk_stat_init(struct blk_rq_stat *stat)
20+
void blk_rq_stat_init(struct blk_rq_stat *stat)
2121
{
2222
stat->min = -1ULL;
2323
stat->max = stat->nr_samples = stat->mean = 0;
2424
stat->batch = 0;
2525
}
2626

2727
/* src is a per-cpu stat, mean isn't initialized */
28-
static void blk_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src)
28+
void blk_rq_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src)
2929
{
3030
if (!src->nr_samples)
3131
return;
@@ -39,7 +39,7 @@ static void blk_stat_sum(struct blk_rq_stat *dst, struct blk_rq_stat *src)
3939
dst->nr_samples += src->nr_samples;
4040
}
4141

42-
static void __blk_stat_add(struct blk_rq_stat *stat, u64 value)
42+
void blk_rq_stat_add(struct blk_rq_stat *stat, u64 value)
4343
{
4444
stat->min = min(stat->min, value);
4545
stat->max = max(stat->max, value);
@@ -69,7 +69,7 @@ void blk_stat_add(struct request *rq, u64 now)
6969
continue;
7070

7171
stat = &get_cpu_ptr(cb->cpu_stat)[bucket];
72-
__blk_stat_add(stat, value);
72+
blk_rq_stat_add(stat, value);
7373
put_cpu_ptr(cb->cpu_stat);
7474
}
7575
rcu_read_unlock();
@@ -82,15 +82,15 @@ static void blk_stat_timer_fn(struct timer_list *t)
8282
int cpu;
8383

8484
for (bucket = 0; bucket < cb->buckets; bucket++)
85-
blk_stat_init(&cb->stat[bucket]);
85+
blk_rq_stat_init(&cb->stat[bucket]);
8686

8787
for_each_online_cpu(cpu) {
8888
struct blk_rq_stat *cpu_stat;
8989

9090
cpu_stat = per_cpu_ptr(cb->cpu_stat, cpu);
9191
for (bucket = 0; bucket < cb->buckets; bucket++) {
92-
blk_stat_sum(&cb->stat[bucket], &cpu_stat[bucket]);
93-
blk_stat_init(&cpu_stat[bucket]);
92+
blk_rq_stat_sum(&cb->stat[bucket], &cpu_stat[bucket]);
93+
blk_rq_stat_init(&cpu_stat[bucket]);
9494
}
9595
}
9696

@@ -143,7 +143,7 @@ void blk_stat_add_callback(struct request_queue *q,
143143

144144
cpu_stat = per_cpu_ptr(cb->cpu_stat, cpu);
145145
for (bucket = 0; bucket < cb->buckets; bucket++)
146-
blk_stat_init(&cpu_stat[bucket]);
146+
blk_rq_stat_init(&cpu_stat[bucket]);
147147
}
148148

149149
spin_lock(&q->stats->lock);

block/blk-stat.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,8 @@ static inline void blk_stat_activate_msecs(struct blk_stat_callback *cb,
159159
mod_timer(&cb->timer, jiffies + msecs_to_jiffies(msecs));
160160
}
161161

162+
void blk_rq_stat_add(struct blk_rq_stat *, u64);
163+
void blk_rq_stat_sum(struct blk_rq_stat *, struct blk_rq_stat *);
164+
void blk_rq_stat_init(struct blk_rq_stat *);
165+
162166
#endif

0 commit comments

Comments
 (0)