diff options
| author | Tejun Heo <tj@kernel.org> | 2012-04-01 17:38:43 -0400 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2012-04-01 17:38:43 -0400 |
| commit | 829fdb50004de78f1bd187e428d72edcd9721cb8 (patch) | |
| tree | 96dbdb62c97e0b7a9a31a7af6d18a6c34e820528 /block | |
| parent | 726fa6945e6e5f0389bf47a790e1df734a67de54 (diff) | |
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: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'block')
| -rw-r--r-- | block/blk-cgroup.c | 52 | ||||
| -rw-r--r-- | block/blk-cgroup.h | 27 |
2 files changed, 52 insertions, 27 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index b07a501839e7..53976f2704a5 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | * Nauman Rafique <nauman@google.com> | 11 | * Nauman Rafique <nauman@google.com> |
| 12 | */ | 12 | */ |
| 13 | #include <linux/ioprio.h> | 13 | #include <linux/ioprio.h> |
| 14 | #include <linux/seq_file.h> | ||
| 15 | #include <linux/kdev_t.h> | 14 | #include <linux/kdev_t.h> |
| 16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 17 | #include <linux/err.h> | 16 | #include <linux/err.h> |
| @@ -767,10 +766,9 @@ static const char *blkg_dev_name(struct blkio_group *blkg) | |||
| 767 | * This is to be used to construct print functions for | 766 | * This is to be used to construct print functions for |
| 768 | * cftype->read_seq_string method. | 767 | * cftype->read_seq_string method. |
| 769 | */ | 768 | */ |
| 770 | static void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, | 769 | void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, |
| 771 | u64 (*prfill)(struct seq_file *, | 770 | u64 (*prfill)(struct seq_file *, struct blkg_policy_data *, int), |
| 772 | struct blkg_policy_data *, int), | 771 | int pol, int data, bool show_total) |
| 773 | int pol, int data, bool show_total) | ||
| 774 | { | 772 | { |
| 775 | struct blkio_group *blkg; | 773 | struct blkio_group *blkg; |
| 776 | struct hlist_node *n; | 774 | struct hlist_node *n; |
| @@ -785,6 +783,7 @@ static void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, | |||
| 785 | if (show_total) | 783 | if (show_total) |
| 786 | seq_printf(sf, "Total %llu\n", (unsigned long long)total); | 784 | seq_printf(sf, "Total %llu\n", (unsigned long long)total); |
| 787 | } | 785 | } |
| 786 | EXPORT_SYMBOL_GPL(blkcg_print_blkgs); | ||
| 788 | 787 | ||
| 789 | /** | 788 | /** |
| 790 | * __blkg_prfill_u64 - prfill helper for a single u64 value | 789 | * __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 | * | 793 | * |
| 795 | * Print @v to @sf for the device assocaited with @pd. | 794 | * Print @v to @sf for the device assocaited with @pd. |
| 796 | */ | 795 | */ |
| 797 | static u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, | 796 | u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v) |
| 798 | u64 v) | ||
| 799 | { | 797 | { |
| 800 | const char *dname = blkg_dev_name(pd->blkg); | 798 | const char *dname = blkg_dev_name(pd->blkg); |
| 801 | 799 | ||
| @@ -805,6 +803,7 @@ static u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, | |||
| 805 | seq_printf(sf, "%s %llu\n", dname, (unsigned long long)v); | 803 | seq_printf(sf, "%s %llu\n", dname, (unsigned long long)v); |
| 806 | return v; | 804 | return v; |
| 807 | } | 805 | } |
| 806 | EXPORT_SYMBOL_GPL(__blkg_prfill_u64); | ||
| 808 | 807 | ||
| 809 | /** | 808 | /** |
| 810 | * __blkg_prfill_rwstat - prfill helper for a blkg_rwstat | 809 | * __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 | * | 813 | * |
| 815 | * Print @rwstat to @sf for the device assocaited with @pd. | 814 | * Print @rwstat to @sf for the device assocaited with @pd. |
| 816 | */ | 815 | */ |
| 817 | static u64 __blkg_prfill_rwstat(struct seq_file *sf, | 816 | u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, |
| 818 | struct blkg_policy_data *pd, | 817 | const struct blkg_rwstat *rwstat) |
| 819 | const struct blkg_rwstat *rwstat) | ||
| 820 | { | 818 | { |
| 821 | static const char *rwstr[] = { | 819 | static const char *rwstr[] = { |
| 822 | [BLKG_RWSTAT_READ] = "Read", | 820 | [BLKG_RWSTAT_READ] = "Read", |
| @@ -856,8 +854,8 @@ static u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, | |||
| 856 | } | 854 | } |
| 857 | 855 | ||
| 858 | /* print blkg_stat specified by BLKCG_STAT_PRIV() */ | 856 | /* print blkg_stat specified by BLKCG_STAT_PRIV() */ |
| 859 | static int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, | 857 | int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, |
| 860 | struct seq_file *sf) | 858 | struct seq_file *sf) |
| 861 | { | 859 | { |
| 862 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | 860 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); |
| 863 | 861 | ||
| @@ -866,10 +864,11 @@ static int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, | |||
| 866 | BLKCG_STAT_OFF(cft->private), false); | 864 | BLKCG_STAT_OFF(cft->private), false); |
| 867 | return 0; | 865 | return 0; |
| 868 | } | 866 | } |
| 867 | EXPORT_SYMBOL_GPL(blkcg_print_stat); | ||
| 869 | 868 | ||
| 870 | /* print blkg_rwstat specified by BLKCG_STAT_PRIV() */ | 869 | /* print blkg_rwstat specified by BLKCG_STAT_PRIV() */ |
| 871 | static int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, | 870 | int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, |
| 872 | struct seq_file *sf) | 871 | struct seq_file *sf) |
| 873 | { | 872 | { |
| 874 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | 873 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); |
| 875 | 874 | ||
| @@ -878,6 +877,7 @@ static int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, | |||
| 878 | BLKCG_STAT_OFF(cft->private), true); | 877 | BLKCG_STAT_OFF(cft->private), true); |
| 879 | return 0; | 878 | return 0; |
| 880 | } | 879 | } |
| 880 | EXPORT_SYMBOL_GPL(blkcg_print_rwstat); | ||
| 881 | 881 | ||
| 882 | static u64 blkg_prfill_cpu_stat(struct seq_file *sf, | 882 | static u64 blkg_prfill_cpu_stat(struct seq_file *sf, |
| 883 | struct blkg_policy_data *pd, int off) | 883 | struct blkg_policy_data *pd, int off) |
| @@ -914,8 +914,8 @@ static u64 blkg_prfill_cpu_rwstat(struct seq_file *sf, | |||
| 914 | } | 914 | } |
| 915 | 915 | ||
| 916 | /* print per-cpu blkg_stat specified by BLKCG_STAT_PRIV() */ | 916 | /* print per-cpu blkg_stat specified by BLKCG_STAT_PRIV() */ |
| 917 | static int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft, | 917 | int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft, |
| 918 | struct seq_file *sf) | 918 | struct seq_file *sf) |
| 919 | { | 919 | { |
| 920 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | 920 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); |
| 921 | 921 | ||
| @@ -924,10 +924,11 @@ static int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft, | |||
| 924 | BLKCG_STAT_OFF(cft->private), false); | 924 | BLKCG_STAT_OFF(cft->private), false); |
| 925 | return 0; | 925 | return 0; |
| 926 | } | 926 | } |
| 927 | EXPORT_SYMBOL_GPL(blkcg_print_cpu_stat); | ||
| 927 | 928 | ||
| 928 | /* print per-cpu blkg_rwstat specified by BLKCG_STAT_PRIV() */ | 929 | /* print per-cpu blkg_rwstat specified by BLKCG_STAT_PRIV() */ |
| 929 | static int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, | 930 | int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, |
| 930 | struct seq_file *sf) | 931 | struct seq_file *sf) |
| 931 | { | 932 | { |
| 932 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | 933 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); |
| 933 | 934 | ||
| @@ -936,6 +937,7 @@ static int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, | |||
| 936 | BLKCG_STAT_OFF(cft->private), true); | 937 | BLKCG_STAT_OFF(cft->private), true); |
| 937 | return 0; | 938 | return 0; |
| 938 | } | 939 | } |
| 940 | EXPORT_SYMBOL_GPL(blkcg_print_cpu_rwstat); | ||
| 939 | 941 | ||
| 940 | #ifdef CONFIG_DEBUG_BLK_CGROUP | 942 | #ifdef CONFIG_DEBUG_BLK_CGROUP |
| 941 | static u64 blkg_prfill_avg_queue_size(struct seq_file *sf, | 943 | 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 | } | 966 | } |
| 965 | #endif /* CONFIG_DEBUG_BLK_CGROUP */ | 967 | #endif /* CONFIG_DEBUG_BLK_CGROUP */ |
| 966 | 968 | ||
| 967 | struct blkg_conf_ctx { | ||
| 968 | struct gendisk *disk; | ||
| 969 | struct blkio_group *blkg; | ||
| 970 | u64 v; | ||
| 971 | }; | ||
| 972 | |||
| 973 | /** | 969 | /** |
| 974 | * blkg_conf_prep - parse and prepare for per-blkg config update | 970 | * blkg_conf_prep - parse and prepare for per-blkg config update |
| 975 | * @blkcg: target block cgroup | 971 | * @blkcg: target block cgroup |
| @@ -981,8 +977,8 @@ struct blkg_conf_ctx { | |||
| 981 | * value. This function returns with RCU read locked and must be paired | 977 | * value. This function returns with RCU read locked and must be paired |
| 982 | * with blkg_conf_finish(). | 978 | * with blkg_conf_finish(). |
| 983 | */ | 979 | */ |
| 984 | static int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input, | 980 | int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input, |
| 985 | struct blkg_conf_ctx *ctx) | 981 | struct blkg_conf_ctx *ctx) |
| 986 | __acquires(rcu) | 982 | __acquires(rcu) |
| 987 | { | 983 | { |
| 988 | struct gendisk *disk; | 984 | struct gendisk *disk; |
| @@ -1026,6 +1022,7 @@ static int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input, | |||
| 1026 | ctx->v = v; | 1022 | ctx->v = v; |
| 1027 | return 0; | 1023 | return 0; |
| 1028 | } | 1024 | } |
| 1025 | EXPORT_SYMBOL_GPL(blkg_conf_prep); | ||
| 1029 | 1026 | ||
| 1030 | /** | 1027 | /** |
| 1031 | * blkg_conf_finish - finish up per-blkg config update | 1028 | * 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 | * Finish up after per-blkg config update. This function must be paired | 1031 | * Finish up after per-blkg config update. This function must be paired |
| 1035 | * with blkg_conf_prep(). | 1032 | * with blkg_conf_prep(). |
| 1036 | */ | 1033 | */ |
| 1037 | static void blkg_conf_finish(struct blkg_conf_ctx *ctx) | 1034 | void blkg_conf_finish(struct blkg_conf_ctx *ctx) |
| 1038 | __releases(rcu) | 1035 | __releases(rcu) |
| 1039 | { | 1036 | { |
| 1040 | rcu_read_unlock(); | 1037 | rcu_read_unlock(); |
| 1041 | put_disk(ctx->disk); | 1038 | put_disk(ctx->disk); |
| 1042 | } | 1039 | } |
| 1040 | EXPORT_SYMBOL_GPL(blkg_conf_finish); | ||
| 1043 | 1041 | ||
| 1044 | /* for propio conf */ | 1042 | /* for propio conf */ |
| 1045 | static u64 blkg_prfill_weight_device(struct seq_file *sf, | 1043 | static u64 blkg_prfill_weight_device(struct seq_file *sf, |
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index 108ffbf0d184..361ecfa4d28d 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | #include <linux/cgroup.h> | 16 | #include <linux/cgroup.h> |
| 17 | #include <linux/u64_stats_sync.h> | 17 | #include <linux/u64_stats_sync.h> |
| 18 | #include <linux/seq_file.h> | ||
| 18 | 19 | ||
| 19 | enum blkio_policy_id { | 20 | enum blkio_policy_id { |
| 20 | BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */ | 21 | BLKIO_POLICY_PROP = 0, /* Proportional Bandwidth division */ |
| @@ -193,6 +194,32 @@ extern void blkg_destroy_all(struct request_queue *q, bool destroy_root); | |||
| 193 | extern void update_root_blkg_pd(struct request_queue *q, | 194 | extern void update_root_blkg_pd(struct request_queue *q, |
| 194 | enum blkio_policy_id plid); | 195 | enum blkio_policy_id plid); |
| 195 | 196 | ||
| 197 | void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, | ||
| 198 | u64 (*prfill)(struct seq_file *, struct blkg_policy_data *, int), | ||
| 199 | int pol, int data, bool show_total); | ||
| 200 | u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v); | ||
| 201 | u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd, | ||
| 202 | const struct blkg_rwstat *rwstat); | ||
| 203 | int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, | ||
| 204 | struct seq_file *sf); | ||
| 205 | int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, | ||
| 206 | struct seq_file *sf); | ||
| 207 | int blkcg_print_cpu_stat(struct cgroup *cgrp, struct cftype *cft, | ||
| 208 | struct seq_file *sf); | ||
| 209 | int blkcg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, | ||
| 210 | struct seq_file *sf); | ||
| 211 | |||
| 212 | struct blkg_conf_ctx { | ||
| 213 | struct gendisk *disk; | ||
| 214 | struct blkio_group *blkg; | ||
| 215 | u64 v; | ||
| 216 | }; | ||
| 217 | |||
| 218 | int blkg_conf_prep(struct blkio_cgroup *blkcg, const char *input, | ||
| 219 | struct blkg_conf_ctx *ctx); | ||
| 220 | void blkg_conf_finish(struct blkg_conf_ctx *ctx); | ||
| 221 | |||
| 222 | |||
| 196 | /** | 223 | /** |
| 197 | * blkg_to_pdata - get policy private data | 224 | * blkg_to_pdata - get policy private data |
| 198 | * @blkg: blkg of interest | 225 | * @blkg: blkg of interest |
