aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2015-08-18 17:55:15 -0400
committerJens Axboe <axboe@fb.com>2015-08-18 18:49:17 -0400
commit814376483e7d85b69a70634633f1f9d01c6ee0cf (patch)
tree04d6f2749e947f348a184e75e7bf1bea9ff7d163 /block/blk-cgroup.c
parenta9520cd6f2ac1fbbf206b915946534c6dddbaae2 (diff)
blkcg: minor updates around blkcg_policy_data
* Rename blkcg->pd[] to blkcg->cpd[] so that cpd is consistently used for blkcg_policy_data. * Make blkcg_policy->cpd_init_fn() take blkcg_policy_data instead of blkcg. This makes it consistent with blkg_policy_data methods and to-be-added cpd alloc/free methods. * blkcg_policy_data->blkcg and cpd_to_blkcg() added so that cpd_init_fn() can determine the associated blkcg from blkcg_policy_data. v2: blkcg_policy_data->blkcg initializations were missing. Added. 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 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 8343450cffe2..247c42c8c83b 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -821,7 +821,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
821 mutex_unlock(&blkcg_pol_mutex); 821 mutex_unlock(&blkcg_pol_mutex);
822 822
823 for (i = 0; i < BLKCG_MAX_POLS; i++) 823 for (i = 0; i < BLKCG_MAX_POLS; i++)
824 kfree(blkcg->pd[i]); 824 kfree(blkcg->cpd[i]);
825 kfree(blkcg); 825 kfree(blkcg);
826} 826}
827 827
@@ -857,15 +857,16 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
857 if (!pol || !pol->cpd_size) 857 if (!pol || !pol->cpd_size)
858 continue; 858 continue;
859 859
860 BUG_ON(blkcg->pd[i]); 860 BUG_ON(blkcg->cpd[i]);
861 cpd = kzalloc(pol->cpd_size, GFP_KERNEL); 861 cpd = kzalloc(pol->cpd_size, GFP_KERNEL);
862 if (!cpd) { 862 if (!cpd) {
863 ret = ERR_PTR(-ENOMEM); 863 ret = ERR_PTR(-ENOMEM);
864 goto free_pd_blkcg; 864 goto free_pd_blkcg;
865 } 865 }
866 blkcg->pd[i] = cpd; 866 blkcg->cpd[i] = cpd;
867 cpd->blkcg = blkcg;
867 cpd->plid = i; 868 cpd->plid = i;
868 pol->cpd_init_fn(blkcg); 869 pol->cpd_init_fn(cpd);
869 } 870 }
870 871
871 spin_lock_init(&blkcg->lock); 872 spin_lock_init(&blkcg->lock);
@@ -881,7 +882,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
881 882
882free_pd_blkcg: 883free_pd_blkcg:
883 for (i--; i >= 0; i--) 884 for (i--; i >= 0; i--)
884 kfree(blkcg->pd[i]); 885 kfree(blkcg->cpd[i]);
885free_blkcg: 886free_blkcg:
886 kfree(blkcg); 887 kfree(blkcg);
887 mutex_unlock(&blkcg_pol_mutex); 888 mutex_unlock(&blkcg_pol_mutex);
@@ -1168,9 +1169,10 @@ int blkcg_policy_register(struct blkcg_policy *pol)
1168 goto err_free_cpds; 1169 goto err_free_cpds;
1169 } 1170 }
1170 1171
1171 blkcg->pd[pol->plid] = cpd; 1172 blkcg->cpd[pol->plid] = cpd;
1173 cpd->blkcg = blkcg;
1172 cpd->plid = pol->plid; 1174 cpd->plid = pol->plid;
1173 pol->cpd_init_fn(blkcg); 1175 pol->cpd_init_fn(cpd);
1174 } 1176 }
1175 } 1177 }
1176 1178
@@ -1186,8 +1188,8 @@ int blkcg_policy_register(struct blkcg_policy *pol)
1186err_free_cpds: 1188err_free_cpds:
1187 if (pol->cpd_size) { 1189 if (pol->cpd_size) {
1188 list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) { 1190 list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
1189 kfree(blkcg->pd[pol->plid]); 1191 kfree(blkcg->cpd[pol->plid]);
1190 blkcg->pd[pol->plid] = NULL; 1192 blkcg->cpd[pol->plid] = NULL;
1191 } 1193 }
1192 } 1194 }
1193 blkcg_policy[pol->plid] = NULL; 1195 blkcg_policy[pol->plid] = NULL;
@@ -1222,8 +1224,8 @@ void blkcg_policy_unregister(struct blkcg_policy *pol)
1222 1224
1223 if (pol->cpd_size) { 1225 if (pol->cpd_size) {
1224 list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) { 1226 list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
1225 kfree(blkcg->pd[pol->plid]); 1227 kfree(blkcg->cpd[pol->plid]);
1226 blkcg->pd[pol->plid] = NULL; 1228 blkcg->cpd[pol->plid] = NULL;
1227 } 1229 }
1228 } 1230 }
1229 blkcg_policy[pol->plid] = NULL; 1231 blkcg_policy[pol->plid] = NULL;