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>
This commit is contained in:
parent
a9520cd6f2
commit
814376483e
|
@ -821,7 +821,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
|
||||||
mutex_unlock(&blkcg_pol_mutex);
|
mutex_unlock(&blkcg_pol_mutex);
|
||||||
|
|
||||||
for (i = 0; i < BLKCG_MAX_POLS; i++)
|
for (i = 0; i < BLKCG_MAX_POLS; i++)
|
||||||
kfree(blkcg->pd[i]);
|
kfree(blkcg->cpd[i]);
|
||||||
kfree(blkcg);
|
kfree(blkcg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,15 +857,16 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
|
||||||
if (!pol || !pol->cpd_size)
|
if (!pol || !pol->cpd_size)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BUG_ON(blkcg->pd[i]);
|
BUG_ON(blkcg->cpd[i]);
|
||||||
cpd = kzalloc(pol->cpd_size, GFP_KERNEL);
|
cpd = kzalloc(pol->cpd_size, GFP_KERNEL);
|
||||||
if (!cpd) {
|
if (!cpd) {
|
||||||
ret = ERR_PTR(-ENOMEM);
|
ret = ERR_PTR(-ENOMEM);
|
||||||
goto free_pd_blkcg;
|
goto free_pd_blkcg;
|
||||||
}
|
}
|
||||||
blkcg->pd[i] = cpd;
|
blkcg->cpd[i] = cpd;
|
||||||
|
cpd->blkcg = blkcg;
|
||||||
cpd->plid = i;
|
cpd->plid = i;
|
||||||
pol->cpd_init_fn(blkcg);
|
pol->cpd_init_fn(cpd);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_init(&blkcg->lock);
|
spin_lock_init(&blkcg->lock);
|
||||||
|
@ -881,7 +882,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
|
||||||
|
|
||||||
free_pd_blkcg:
|
free_pd_blkcg:
|
||||||
for (i--; i >= 0; i--)
|
for (i--; i >= 0; i--)
|
||||||
kfree(blkcg->pd[i]);
|
kfree(blkcg->cpd[i]);
|
||||||
free_blkcg:
|
free_blkcg:
|
||||||
kfree(blkcg);
|
kfree(blkcg);
|
||||||
mutex_unlock(&blkcg_pol_mutex);
|
mutex_unlock(&blkcg_pol_mutex);
|
||||||
|
@ -1168,9 +1169,10 @@ int blkcg_policy_register(struct blkcg_policy *pol)
|
||||||
goto err_free_cpds;
|
goto err_free_cpds;
|
||||||
}
|
}
|
||||||
|
|
||||||
blkcg->pd[pol->plid] = cpd;
|
blkcg->cpd[pol->plid] = cpd;
|
||||||
|
cpd->blkcg = blkcg;
|
||||||
cpd->plid = pol->plid;
|
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:
|
err_free_cpds:
|
||||||
if (pol->cpd_size) {
|
if (pol->cpd_size) {
|
||||||
list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
|
list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
|
||||||
kfree(blkcg->pd[pol->plid]);
|
kfree(blkcg->cpd[pol->plid]);
|
||||||
blkcg->pd[pol->plid] = NULL;
|
blkcg->cpd[pol->plid] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blkcg_policy[pol->plid] = NULL;
|
blkcg_policy[pol->plid] = NULL;
|
||||||
|
@ -1222,8 +1224,8 @@ void blkcg_policy_unregister(struct blkcg_policy *pol)
|
||||||
|
|
||||||
if (pol->cpd_size) {
|
if (pol->cpd_size) {
|
||||||
list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
|
list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
|
||||||
kfree(blkcg->pd[pol->plid]);
|
kfree(blkcg->cpd[pol->plid]);
|
||||||
blkcg->pd[pol->plid] = NULL;
|
blkcg->cpd[pol->plid] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blkcg_policy[pol->plid] = NULL;
|
blkcg_policy[pol->plid] = NULL;
|
||||||
|
|
|
@ -220,7 +220,7 @@ struct cfqg_stats {
|
||||||
/* Per-cgroup data */
|
/* Per-cgroup data */
|
||||||
struct cfq_group_data {
|
struct cfq_group_data {
|
||||||
/* must be the first member */
|
/* must be the first member */
|
||||||
struct blkcg_policy_data pd;
|
struct blkcg_policy_data cpd;
|
||||||
|
|
||||||
unsigned int weight;
|
unsigned int weight;
|
||||||
unsigned int leaf_weight;
|
unsigned int leaf_weight;
|
||||||
|
@ -612,7 +612,7 @@ static inline struct cfq_group *pd_to_cfqg(struct blkg_policy_data *pd)
|
||||||
static struct cfq_group_data
|
static struct cfq_group_data
|
||||||
*cpd_to_cfqgd(struct blkcg_policy_data *cpd)
|
*cpd_to_cfqgd(struct blkcg_policy_data *cpd)
|
||||||
{
|
{
|
||||||
return cpd ? container_of(cpd, struct cfq_group_data, pd) : NULL;
|
return cpd ? container_of(cpd, struct cfq_group_data, cpd) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct blkcg_gq *cfqg_to_blkg(struct cfq_group *cfqg)
|
static inline struct blkcg_gq *cfqg_to_blkg(struct cfq_group *cfqg)
|
||||||
|
@ -1568,12 +1568,11 @@ static void cfqg_stats_init(struct cfqg_stats *stats)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cfq_cpd_init(const struct blkcg *blkcg)
|
static void cfq_cpd_init(struct blkcg_policy_data *cpd)
|
||||||
{
|
{
|
||||||
struct cfq_group_data *cgd =
|
struct cfq_group_data *cgd = cpd_to_cfqgd(cpd);
|
||||||
cpd_to_cfqgd(blkcg->pd[blkcg_policy_cfq.plid]);
|
|
||||||
|
|
||||||
if (blkcg == &blkcg_root) {
|
if (cpd_to_blkcg(cpd) == &blkcg_root) {
|
||||||
cgd->weight = 2 * CFQ_WEIGHT_DEFAULT;
|
cgd->weight = 2 * CFQ_WEIGHT_DEFAULT;
|
||||||
cgd->leaf_weight = 2 * CFQ_WEIGHT_DEFAULT;
|
cgd->leaf_weight = 2 * CFQ_WEIGHT_DEFAULT;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct blkcg {
|
||||||
struct blkcg_gq *blkg_hint;
|
struct blkcg_gq *blkg_hint;
|
||||||
struct hlist_head blkg_list;
|
struct hlist_head blkg_list;
|
||||||
|
|
||||||
struct blkcg_policy_data *pd[BLKCG_MAX_POLS];
|
struct blkcg_policy_data *cpd[BLKCG_MAX_POLS];
|
||||||
|
|
||||||
struct list_head all_blkcgs_node;
|
struct list_head all_blkcgs_node;
|
||||||
#ifdef CONFIG_CGROUP_WRITEBACK
|
#ifdef CONFIG_CGROUP_WRITEBACK
|
||||||
|
@ -88,7 +88,8 @@ struct blkg_policy_data {
|
||||||
* each policy handle per-blkcg data.
|
* each policy handle per-blkcg data.
|
||||||
*/
|
*/
|
||||||
struct blkcg_policy_data {
|
struct blkcg_policy_data {
|
||||||
/* the policy id this per-policy data belongs to */
|
/* the blkcg and policy id this per-policy data belongs to */
|
||||||
|
struct blkcg *blkcg;
|
||||||
int plid;
|
int plid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ struct blkcg_gq {
|
||||||
struct rcu_head rcu_head;
|
struct rcu_head rcu_head;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (blkcg_pol_init_cpd_fn)(const struct blkcg *blkcg);
|
typedef void (blkcg_pol_init_cpd_fn)(struct blkcg_policy_data *cpd);
|
||||||
typedef struct blkg_policy_data *(blkcg_pol_alloc_pd_fn)(gfp_t gfp, int node);
|
typedef struct blkg_policy_data *(blkcg_pol_alloc_pd_fn)(gfp_t gfp, int node);
|
||||||
typedef void (blkcg_pol_init_pd_fn)(struct blkg_policy_data *pd);
|
typedef void (blkcg_pol_init_pd_fn)(struct blkg_policy_data *pd);
|
||||||
typedef void (blkcg_pol_online_pd_fn)(struct blkg_policy_data *pd);
|
typedef void (blkcg_pol_online_pd_fn)(struct blkg_policy_data *pd);
|
||||||
|
@ -243,7 +244,7 @@ static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
|
||||||
static inline struct blkcg_policy_data *blkcg_to_cpd(struct blkcg *blkcg,
|
static inline struct blkcg_policy_data *blkcg_to_cpd(struct blkcg *blkcg,
|
||||||
struct blkcg_policy *pol)
|
struct blkcg_policy *pol)
|
||||||
{
|
{
|
||||||
return blkcg ? blkcg->pd[pol->plid] : NULL;
|
return blkcg ? blkcg->cpd[pol->plid] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -257,6 +258,11 @@ static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd)
|
||||||
return pd ? pd->blkg : NULL;
|
return pd ? pd->blkg : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct blkcg *cpd_to_blkcg(struct blkcg_policy_data *cpd)
|
||||||
|
{
|
||||||
|
return cpd ? cpd->blkcg : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blkg_path - format cgroup path of blkg
|
* blkg_path - format cgroup path of blkg
|
||||||
* @blkg: blkg of interest
|
* @blkg: blkg of interest
|
||||||
|
|
Loading…
Reference in New Issue