From: Jes Sorensen <jsorensen@xxxxxx> This exports bytes read/write/discard per bucket to sysfs Signed-off-by: Jes Sorensen <jsorensen@xxxxxx> --- block/blk-sysfs.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 8841146cad54..44517799a2e8 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -529,6 +529,23 @@ static ssize_t queue_dax_show(struct request_queue *q, char *page) return queue_var_show(blk_queue_dax(q), page); } +static ssize_t queue_stat_show(struct request_queue *q, char *p) +{ + char name[3][8] = {"read", "write", "discard"}; + int bkt, off, i; + + off = 0; + for (i = 0; i < 3; i++) { + off += sprintf(p + off, "%s: ", name[i]); + for (bkt = 0; bkt < (BLK_REQ_STATS_BKTS / 3); bkt++) { + off += sprintf(p + off, "%llu ", + q->req_stat[i + 3 * bkt].sectors << 9); + } + off += sprintf(p + off, "\n"); + } + return off; +} + static ssize_t queue_reqstat_show(struct request_queue *q, char *page) { return queue_var_show(test_bit(QUEUE_FLAG_REQSTATS, @@ -764,6 +781,11 @@ static struct queue_sysfs_entry queue_reqstat_entry = { .store = queue_reqstat_store, }; +static struct queue_sysfs_entry queue_stat_entry = { + .attr = {.name = "stat", .mode = 0444 }, + .show = queue_stat_show, +}; + static struct attribute *queue_attrs[] = { &queue_requests_entry.attr, &queue_ra_entry.attr, @@ -804,6 +826,7 @@ static struct attribute *queue_attrs[] = { &throtl_sample_time_entry.attr, #endif &queue_reqstat_entry.attr, + &queue_stat_entry.attr, NULL, }; -- 2.17.1