Commit 829fdb50 authored by Tejun Heo's avatar Tejun Heo

blkcg: export conf/stat helpers to prepare for reorganization

conf/stat handling is about to be moved to policy implementation from
blkcg core.  Export conf/stat helpers from blkcg core so that
blk-throttle and cfq-iosched can use them.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 726fa694
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* Nauman Rafique <nauman@google.com> * Nauman Rafique <nauman@google.com>
*/ */
#include <linux/ioprio.h> #include <linux/ioprio.h>
#include <linux/seq_file.h>
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -767,10 +766,9 @@ static const char *blkg_dev_name(struct blkio_group *blkg) ...@@ -767,10 +766,9 @@ static const char *blkg_dev_name(struct blkio_group *blkg)
* This is to be used to construct print functions for * This is to be used to construct print functions for
* cftype->read_seq_string method. * cftype->read_seq_string method.
*/ */
static void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
u64 (*prfill)(struct seq_file *, u64 (*prfill)(struct seq_file *, struct blkg_policy_data *, int),
struct blkg_policy_data *, int), int pol, int data, bool show_total)
int pol, int data, bool show_total)
{ {
struct blkio_group *blkg; struct blkio_group *blkg;
struct hlist_node *n; struct hlist_node *n;
...@@ -785,6 +783,7 @@ static void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, ...@@ -785,6 +783,7 @@ static void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
if (show_total) if (show_total)
seq_printf(sf, "Total %llu\n", (unsigned long long)total); seq_printf(sf, "Total %llu\n", (unsigned long long)total);
} }
EXPORT_SYMBOL_GPL(blkcg_print_blkgs);
/** /**
* __blkg_prfill_u64 - prfill helper for a single u64 value * __blkg_prfill_u64 - prfill helper for a single u64 value
...@@ -794,8 +793,7 @@ static void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, ...@@ -794,8 +793,7 @@ static void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
* *
* Print @v to @sf for the device assocaited with @pd. * Print @v to @sf for the device assocaited with @pd.
*/ */
static u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v)
u64 v)
{ {
const char *dname = blkg_dev_name(pd->blkg); const char *dname = blkg_dev_name(pd->blkg);
...@@ -805,6 +803,7 @@ static u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, ...@@ -805,6 +803,7 @@ static u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd,
seq_printf(sf, "%s %llu\n", dname, (unsigned long long)v); seq_printf(sf, "%s %llu\n", dname, (unsigned long long)v);
return v; return v;
} }
EXPORT_SYMBOL_GPL(__blkg_prfill_u64);
/** /**
* __blkg_prfill_rwstat - prfill helper for a blkg_rwstat * __blkg_prfill_rwstat - prfill helper for a blkg_rwstat
...@@ -814,9 +813,8 @@ static u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, ...@@ -814,9 +813,8 @@ static u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd,
* *
* Print @rwstat to @sf for the device assocaited with @pd. * Print @rwstat to @sf for the device assocaited with @pd.
*/ */
static u64 __blkg_prfill_rwstat(struct seq_file *sf, u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
struct blkg_policy_data *pd, const struct blkg_rwstat *rwstat)
const struct blkg_rwstat *rwstat)
{ {
static const char *rwstr[] = { static const char *rwstr[] = {
[BLKG_RWSTAT_READ] = "Read", [BLKG_RWSTAT_READ] = "Read",
...@@ -856,8 +854,8 @@ static u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, ...@@ -856,8 +854,8 @@ static u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
} }
/* print blkg_stat specified by BLKCG_STAT_PRIV() */ /* print blkg_stat specified by BLKCG_STAT_PRIV() */
static int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf) struct seq_file *sf)
{ {
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
...@@ -866,10 +864,11 @@ static int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, ...@@ -866,10 +864,11 @@ static int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft,
BLKCG_STAT_OFF(cft->private), false); BLKCG_STAT_OFF(cft->private), false);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(blkcg_print_stat);
/* print blkg_rwstat specified by BLKCG_STAT_PRIV() */ /* print blkg_rwstat specified by BLKCG_STAT_PRIV() */
static int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf) struct seq_file *sf)
{ {
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
...@@ -878,6 +877,7 @@ static int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, ...@@ -878,6 +877,7 @@ static int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft,
BLKCG_STAT_OFF(cft->private), true); BLKCG_STAT_OFF(cft->private), true);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(blkcg_print_rwstat);
static u64 blkg_prfill_cpu_stat(struct seq_file *sf, static u64 blkg_prfill_cpu_stat(struct seq_file *sf,
struct blkg_policy_data *pd, int off) struct blkg_policy_data *pd, int off)
...@@ -914,8 +914,8 @@ static u64 blkg_prfill_cpu_rwstat(struct seq_file *sf, ...@@ -914,8 +914,8 @@ static u64 blkg_prfill_cpu_rwstat(struct seq_file *sf,
} }
/* print per-cpu blkg_stat specified by BLKCG_STAT_PRIV() */ /* print per-cpu blkg_stat specified by BLKCG_STAT_PRIV() */
static int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft, int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf) struct seq_file *sf)
{ {
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
...@@ -924,10 +924,11 @@ static int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft, ...@@ -924,10 +924,11 @@ static int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft,
BLKCG_STAT_OFF(cft->private), false); BLKCG_STAT_OFF(cft->private), false);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(blkcg_print_cpu_stat);
/* print per-cpu blkg_rwstat specified by BLKCG_STAT_PRIV() */ /* print per-cpu blkg_rwstat specified by BLKCG_STAT_PRIV() */
static int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf) struct seq_file *sf)
{ {
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
...@@ -936,6 +937,7 @@ static int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, ...@@ -936,6 +937,7 @@ static int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,
BLKCG_STAT_OFF(cft->private), true); BLKCG_STAT_OFF(cft->private), true);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(blkcg_print_cpu_rwstat);
#ifdef CONFIG_DEBUG_BLK_CGROUP #ifdef CONFIG_DEBUG_BLK_CGROUP
static u64 blkg_prfill_avg_queue_size(struct seq_file *sf, static u64 blkg_prfill_avg_queue_size(struct seq_file *sf,
...@@ -964,12 +966,6 @@ static int blkcg_print_avg_queue_size(struct cgroup *cgrp, struct cftype *cft, ...@@ -964,12 +966,6 @@ static int blkcg_print_avg_queue_size(struct cgroup *cgrp, struct cftype *cft,
} }
#endif /* CONFIG_DEBUG_BLK_CGROUP */ #endif /* CONFIG_DEBUG_BLK_CGROUP */
struct blkg_conf_ctx {
struct gendisk *disk;
struct blkio_group *blkg;
u64 v;
};
/** /**
* blkg_conf_prep - parse and prepare for per-blkg config update * blkg_conf_prep - parse and prepare for per-blkg config update
* @blkcg: target block cgroup * @blkcg: target block cgroup
...@@ -981,8 +977,8 @@ struct blkg_conf_ctx { ...@@ -981,8 +977,8 @@ struct blkg_conf_ctx {
* value. This function returns with RCU read locked and must be paired * value. This function returns with RCU read locked and must be paired
* with blkg_conf_finish(). * with blkg_conf_finish().
*/ */
static int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input, int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input,
struct blkg_conf_ctx *ctx) struct blkg_conf_ctx *ctx)
__acquires(rcu) __acquires(rcu)
{ {
struct gendisk *disk; struct gendisk *disk;
...@@ -1026,6 +1022,7 @@ static int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input, ...@@ -1026,6 +1022,7 @@ static int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input,
ctx->v = v; ctx->v = v;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(blkg_conf_prep);
/** /**
* blkg_conf_finish - finish up per-blkg config update * blkg_conf_finish - finish up per-blkg config update
...@@ -1034,12 +1031,13 @@ static int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input, ...@@ -1034,12 +1031,13 @@ static int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input,
* Finish up after per-blkg config update. This function must be paired * Finish up after per-blkg config update. This function must be paired
* with blkg_conf_prep(). * with blkg_conf_prep().
*/ */
static void blkg_conf_finish(struct blkg_conf_ctx *ctx) void blkg_conf_finish(struct blkg_conf_ctx *ctx)
__releases(rcu) __releases(rcu)
{ {
rcu_read_unlock(); rcu_read_unlock();
put_disk(ctx->disk); put_disk(ctx->disk);
} }
EXPORT_SYMBOL_GPL(blkg_conf_finish);
/* for propio conf */ /* for propio conf */
static u64 blkg_prfill_weight_device(struct seq_file *sf, static u64 blkg_prfill_weight_device(struct seq_file *sf,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/cgroup.h> #include <linux/cgroup.h>
#include <linux/u64_stats_sync.h> #include <linux/u64_stats_sync.h>
#include <linux/seq_file.h>
enum blkio_policy_id { enum blkio_policy_id {
BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */ BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */
...@@ -193,6 +194,32 @@ extern void blkg_destroy_all(struct request_queue *q, bool destroy_root); ...@@ -193,6 +194,32 @@ extern void blkg_destroy_all(struct request_queue *q, bool destroy_root);
extern void update_root_blkg_pd(struct request_queue *q, extern void update_root_blkg_pd(struct request_queue *q,
enum blkio_policy_id plid); enum blkio_policy_id plid);
void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
u64 (*prfill)(struct seq_file *, struct blkg_policy_data *, int),
int pol, int data, bool show_total);
u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v);
u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
const struct blkg_rwstat *rwstat);
int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf);
int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf);
int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf);
int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,
struct seq_file *sf);
struct blkg_conf_ctx {
struct gendisk *disk;
struct blkio_group *blkg;
u64 v;
};
int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input,
struct blkg_conf_ctx *ctx);
void blkg_conf_finish(struct blkg_conf_ctx *ctx);
/** /**
* blkg_to_pdata - get policy private data * blkg_to_pdata - get policy private data
* @blkg: blkg of interest * @blkg: blkg of interest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment