summaryrefslogtreecommitdiffstats
path: root/include/linux/blk-cgroup.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-08-18 17:55:16 -0400
committerJens Axboe <axboe@fb.com>2015-08-18 18:49:17 -0400
commite4a9bde9589fdc51283755cdd75d47b27ca7c6fb (patch)
treecc26b9cdba09e6571342f16182cafee5e82852b0 /include/linux/blk-cgroup.h
parent814376483e7d85b69a70634633f1f9d01c6ee0cf (diff)
blkcg: replace blkcg_policy->cpd_size with ->cpd_alloc/free_fn() methods
Each active policy has a cpd (blkcg_policy_data) on each blkcg. The cpd's were allocated by blkcg core and each policy could request to allocate extra space at the end by setting blkcg_policy->cpd_size larger than the size of cpd. This is a bit unusual but blkg (blkcg_gq) policy data used to be handled this way too so it made sense to be consistent; however, blkg policy data switched to alloc/free callbacks. This patch makes similar changes to cpd handling. blkcg_policy->cpd_alloc/free_fn() are added to replace ->cpd_size. As cpd allocation is now done from policy side, it can simply allocate a larger area which embeds cpd at the beginning. As ->cpd_alloc_fn() may be able to perform all necessary initializations, this patch makes ->cpd_init_fn() optional. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Arianna Avanzini <avanzini.arianna@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include/linux/blk-cgroup.h')
-rw-r--r--include/linux/blk-cgroup.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 7988d4749fff..15f2382bc723 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -81,11 +81,11 @@ struct blkg_policy_data {
81}; 81};
82 82
83/* 83/*
84 * Policies that need to keep per-blkcg data which is independent 84 * Policies that need to keep per-blkcg data which is independent from any
85 * from any request_queue associated to it must specify its size 85 * request_queue associated to it should implement cpd_alloc/free_fn()
86 * with the cpd_size field of the blkcg_policy structure and 86 * methods. A policy can allocate private data area by allocating larger
87 * embed a blkcg_policy_data in it. cpd_init() is invoked to let 87 * data structure which embeds blkcg_policy_data at the beginning.
88 * each policy handle per-blkcg data. 88 * cpd_init() is invoked to let each policy handle per-blkcg data.
89 */ 89 */
90struct blkcg_policy_data { 90struct blkcg_policy_data {
91 /* the blkcg and policy id this per-policy data belongs to */ 91 /* the blkcg and policy id this per-policy data belongs to */
@@ -124,7 +124,9 @@ struct blkcg_gq {
124 struct rcu_head rcu_head; 124 struct rcu_head rcu_head;
125}; 125};
126 126
127typedef struct blkcg_policy_data *(blkcg_pol_alloc_cpd_fn)(gfp_t gfp);
127typedef void (blkcg_pol_init_cpd_fn)(struct blkcg_policy_data *cpd); 128typedef void (blkcg_pol_init_cpd_fn)(struct blkcg_policy_data *cpd);
129typedef void (blkcg_pol_free_cpd_fn)(struct blkcg_policy_data *cpd);
128typedef struct blkg_policy_data *(blkcg_pol_alloc_pd_fn)(gfp_t gfp, int node); 130typedef struct blkg_policy_data *(blkcg_pol_alloc_pd_fn)(gfp_t gfp, int node);
129typedef void (blkcg_pol_init_pd_fn)(struct blkg_policy_data *pd); 131typedef void (blkcg_pol_init_pd_fn)(struct blkg_policy_data *pd);
130typedef void (blkcg_pol_online_pd_fn)(struct blkg_policy_data *pd); 132typedef void (blkcg_pol_online_pd_fn)(struct blkg_policy_data *pd);
@@ -134,13 +136,14 @@ typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkg_policy_data *pd);
134 136
135struct blkcg_policy { 137struct blkcg_policy {
136 int plid; 138 int plid;
137 /* policy specific per-blkcg data size */
138 size_t cpd_size;
139 /* cgroup files for the policy */ 139 /* cgroup files for the policy */
140 struct cftype *cftypes; 140 struct cftype *cftypes;
141 141
142 /* operations */ 142 /* operations */
143 blkcg_pol_alloc_cpd_fn *cpd_alloc_fn;
143 blkcg_pol_init_cpd_fn *cpd_init_fn; 144 blkcg_pol_init_cpd_fn *cpd_init_fn;
145 blkcg_pol_free_cpd_fn *cpd_free_fn;
146
144 blkcg_pol_alloc_pd_fn *pd_alloc_fn; 147 blkcg_pol_alloc_pd_fn *pd_alloc_fn;
145 blkcg_pol_init_pd_fn *pd_init_fn; 148 blkcg_pol_init_pd_fn *pd_init_fn;
146 blkcg_pol_online_pd_fn *pd_online_fn; 149 blkcg_pol_online_pd_fn *pd_online_fn;