Skip to content

Commit

Permalink
blk-stat: convert blk-stat bucket callback to signed
Browse files Browse the repository at this point in the history
In order to allow for filtering of IO based on some other properties
of the request than direction we allow the bucket function to return
an int.

If the bucket callback returns a negative do no count it in the stats
accumulation.

Signed-off-by: Stephen Bates <[email protected]>

Fixed up Kyber scheduler stat callback.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
sbates130272 authored and axboe committed Apr 20, 2017
1 parent caf7df1 commit a37244e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions block/blk-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct blk_queue_stats {
bool enable_accounting;
};

unsigned int blk_stat_rq_ddir(const struct request *rq)
int blk_stat_rq_ddir(const struct request *rq)
{
return rq_data_dir(rq);
}
Expand Down Expand Up @@ -104,6 +104,8 @@ void blk_stat_add(struct request *rq)
list_for_each_entry_rcu(cb, &q->stats->callbacks, list) {
if (blk_stat_is_active(cb)) {
bucket = cb->bucket_fn(rq);
if (bucket < 0)
continue;
stat = &this_cpu_ptr(cb->cpu_stat)[bucket];
__blk_stat_add(stat, value);
}
Expand Down Expand Up @@ -135,7 +137,7 @@ static void blk_stat_timer_fn(unsigned long data)

struct blk_stat_callback *
blk_stat_alloc_callback(void (*timer_fn)(struct blk_stat_callback *),
unsigned int (*bucket_fn)(const struct request *),
int (*bucket_fn)(const struct request *),
unsigned int buckets, void *data)
{
struct blk_stat_callback *cb;
Expand Down
9 changes: 5 additions & 4 deletions block/blk-stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ struct blk_stat_callback {

/**
* @bucket_fn: Given a request, returns which statistics bucket it
* should be accounted under.
* should be accounted under. Return -1 for no bucket for this
* request.
*/
unsigned int (*bucket_fn)(const struct request *);
int (*bucket_fn)(const struct request *);

/**
* @buckets: Number of statistics buckets.
Expand Down Expand Up @@ -120,7 +121,7 @@ void blk_stat_enable_accounting(struct request_queue *q);
*
* Return: Data direction of the request, either READ or WRITE.
*/
unsigned int blk_stat_rq_ddir(const struct request *rq);
int blk_stat_rq_ddir(const struct request *rq);

/**
* blk_stat_alloc_callback() - Allocate a block statistics callback.
Expand All @@ -135,7 +136,7 @@ unsigned int blk_stat_rq_ddir(const struct request *rq);
*/
struct blk_stat_callback *
blk_stat_alloc_callback(void (*timer_fn)(struct blk_stat_callback *),
unsigned int (*bucket_fn)(const struct request *),
int (*bucket_fn)(const struct request *),
unsigned int buckets, void *data);

/**
Expand Down
2 changes: 1 addition & 1 deletion block/kyber-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct kyber_hctx_data {
atomic_t wait_index[KYBER_NUM_DOMAINS];
};

static unsigned int rq_sched_domain(const struct request *rq)
static int rq_sched_domain(const struct request *rq)
{
unsigned int op = rq->cmd_flags;

Expand Down

0 comments on commit a37244e

Please sign in to comment.