From 814376483e7d85b69a70634633f1f9d01c6ee0cf Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 18 Aug 2015 14:55:15 -0700 Subject: 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 Cc: Vivek Goyal Cc: Arianna Avanzini Signed-off-by: Jens Axboe --- block/blk-cgroup.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'block/blk-cgroup.c') 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) mutex_unlock(&blkcg_pol_mutex); for (i = 0; i < BLKCG_MAX_POLS; i++) - kfree(blkcg->pd[i]); + kfree(blkcg->cpd[i]); kfree(blkcg); } @@ -857,15 +857,16 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) if (!pol || !pol->cpd_size) continue; - BUG_ON(blkcg->pd[i]); + BUG_ON(blkcg->cpd[i]); cpd = kzalloc(pol->cpd_size, GFP_KERNEL); if (!cpd) { ret = ERR_PTR(-ENOMEM); goto free_pd_blkcg; } - blkcg->pd[i] = cpd; + blkcg->cpd[i] = cpd; + cpd->blkcg = blkcg; cpd->plid = i; - pol->cpd_init_fn(blkcg); + pol->cpd_init_fn(cpd); } spin_lock_init(&blkcg->lock); @@ -881,7 +882,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) free_pd_blkcg: for (i--; i >= 0; i--) - kfree(blkcg->pd[i]); + kfree(blkcg->cpd[i]); free_blkcg: kfree(blkcg); mutex_unlock(&blkcg_pol_mutex); @@ -1168,9 +1169,10 @@ int blkcg_policy_register(struct blkcg_policy *pol) goto err_free_cpds; } - blkcg->pd[pol->plid] = cpd; + blkcg->cpd[pol->plid] = cpd; + cpd->blkcg = blkcg; cpd->plid = pol->plid; - pol->cpd_init_fn(blkcg); + pol->cpd_init_fn(cpd); } } @@ -1186,8 +1188,8 @@ int blkcg_policy_register(struct blkcg_policy *pol) err_free_cpds: if (pol->cpd_size) { list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) { - kfree(blkcg->pd[pol->plid]); - blkcg->pd[pol->plid] = NULL; + kfree(blkcg->cpd[pol->plid]); + blkcg->cpd[pol->plid] = NULL; } } blkcg_policy[pol->plid] = NULL; @@ -1222,8 +1224,8 @@ void blkcg_policy_unregister(struct blkcg_policy *pol) if (pol->cpd_size) { list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) { - kfree(blkcg->pd[pol->plid]); - blkcg->pd[pol->plid] = NULL; + kfree(blkcg->cpd[pol->plid]); + blkcg->cpd[pol->plid] = NULL; } } blkcg_policy[pol->plid] = NULL; -- cgit v1.2.3