aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-04-01 15:30:01 -0400
committerTejun Heo <tj@kernel.org>2012-04-01 15:55:00 -0400
commit959d851caa48829eb85cb85aa949fd6b4c5d5bc6 (patch)
tree3ba9c94ec346275fb44c4f0d1cd2537cdff8d811 /block/blk-cgroup.c
parenta5567932fc926739e29e98487128080f40c61710 (diff)
parent48ddbe194623ae089cc0576e60363f2d2e85662a (diff)
Merge branch 'for-3.5' of ../cgroup into block/for-3.5/core-merged
cgroup/for-3.5 contains the following changes which blk-cgroup needs to proceed with the on-going cleanup. * Dynamic addition and removal of cftypes to make config/stat file handling modular for policies. * cgroup removal update to not wait for css references to drain to fix blkcg removal hang caused by cfq caching cfqgs. Pull in cgroup/for-3.5 into block/for-3.5/core. This causes the following conflicts in block/blk-cgroup.c. * 761b3ef50e "cgroup: remove cgroup_subsys argument from callbacks" conflicts with blkiocg_pre_destroy() addition and blkiocg_attach() removal. Resolved by removing @subsys from all subsys methods. * 676f7c8f84 "cgroup: relocate cftype and cgroup_subsys definitions in controllers" conflicts with ->pre_destroy() and ->attach() updates and removal of modular config. Resolved by dropping forward declarations of the methods and applying updates to the relocated blkio_subsys. * 4baf6e3325 "cgroup: convert all non-memcg controllers to the new cftype interface" builds upon the previous item. Resolved by adding ->base_cftypes to the relocated blkio_subsys. Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r--block/blk-cgroup.c51
1 files changed, 17 insertions, 34 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index aa54c4110f54..4fdeb46b4436 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -43,32 +43,12 @@ EXPORT_SYMBOL_GPL(blkio_root_cgroup);
43 43
44static struct blkio_policy_type *blkio_policy[BLKIO_NR_POLICIES]; 44static struct blkio_policy_type *blkio_policy[BLKIO_NR_POLICIES];
45 45
46static struct cgroup_subsys_state *blkiocg_create(struct cgroup_subsys *,
47 struct cgroup *);
48static int blkiocg_can_attach(struct cgroup_subsys *, struct cgroup *,
49 struct cgroup_taskset *);
50static int blkiocg_pre_destroy(struct cgroup_subsys *, struct cgroup *);
51static void blkiocg_destroy(struct cgroup_subsys *, struct cgroup *);
52static int blkiocg_populate(struct cgroup_subsys *, struct cgroup *);
53
54/* for encoding cft->private value on file */ 46/* for encoding cft->private value on file */
55#define BLKIOFILE_PRIVATE(x, val) (((x) << 16) | (val)) 47#define BLKIOFILE_PRIVATE(x, val) (((x) << 16) | (val))
56/* What policy owns the file, proportional or throttle */ 48/* What policy owns the file, proportional or throttle */
57#define BLKIOFILE_POLICY(val) (((val) >> 16) & 0xffff) 49#define BLKIOFILE_POLICY(val) (((val) >> 16) & 0xffff)
58#define BLKIOFILE_ATTR(val) ((val) & 0xffff) 50#define BLKIOFILE_ATTR(val) ((val) & 0xffff)
59 51
60struct cgroup_subsys blkio_subsys = {
61 .name = "blkio",
62 .create = blkiocg_create,
63 .can_attach = blkiocg_can_attach,
64 .pre_destroy = blkiocg_pre_destroy,
65 .destroy = blkiocg_destroy,
66 .populate = blkiocg_populate,
67 .subsys_id = blkio_subsys_id,
68 .module = THIS_MODULE,
69};
70EXPORT_SYMBOL_GPL(blkio_subsys);
71
72struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup) 52struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup)
73{ 53{
74 return container_of(cgroup_subsys_state(cgroup, blkio_subsys_id), 54 return container_of(cgroup_subsys_state(cgroup, blkio_subsys_id),
@@ -1563,17 +1543,11 @@ struct cftype blkio_files[] = {
1563 .read_map = blkiocg_file_read_map, 1543 .read_map = blkiocg_file_read_map,
1564 }, 1544 },
1565#endif 1545#endif
1546 { } /* terminate */
1566}; 1547};
1567 1548
1568static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup)
1569{
1570 return cgroup_add_files(cgroup, subsys, blkio_files,
1571 ARRAY_SIZE(blkio_files));
1572}
1573
1574/** 1549/**
1575 * blkiocg_pre_destroy - cgroup pre_destroy callback 1550 * blkiocg_pre_destroy - cgroup pre_destroy callback
1576 * @subsys: cgroup subsys
1577 * @cgroup: cgroup of interest 1551 * @cgroup: cgroup of interest
1578 * 1552 *
1579 * This function is called when @cgroup is about to go away and responsible 1553 * This function is called when @cgroup is about to go away and responsible
@@ -1583,8 +1557,7 @@ static int blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup)
1583 * 1557 *
1584 * This is the blkcg counterpart of ioc_release_fn(). 1558 * This is the blkcg counterpart of ioc_release_fn().
1585 */ 1559 */
1586static int blkiocg_pre_destroy(struct cgroup_subsys *subsys, 1560static int blkiocg_pre_destroy(struct cgroup *cgroup)
1587 struct cgroup *cgroup)
1588{ 1561{
1589 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup); 1562 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup);
1590 1563
@@ -1609,7 +1582,7 @@ static int blkiocg_pre_destroy(struct cgroup_subsys *subsys,
1609 return 0; 1582 return 0;
1610} 1583}
1611 1584
1612static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup) 1585static void blkiocg_destroy(struct cgroup *cgroup)
1613{ 1586{
1614 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup); 1587 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgroup);
1615 1588
@@ -1617,8 +1590,7 @@ static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup)
1617 kfree(blkcg); 1590 kfree(blkcg);
1618} 1591}
1619 1592
1620static struct cgroup_subsys_state * 1593static struct cgroup_subsys_state *blkiocg_create(struct cgroup *cgroup)
1621blkiocg_create(struct cgroup_subsys *subsys, struct cgroup *cgroup)
1622{ 1594{
1623 static atomic64_t id_seq = ATOMIC64_INIT(0); 1595 static atomic64_t id_seq = ATOMIC64_INIT(0);
1624 struct blkio_cgroup *blkcg; 1596 struct blkio_cgroup *blkcg;
@@ -1706,8 +1678,7 @@ void blkcg_exit_queue(struct request_queue *q)
1706 * of the main cic data structures. For now we allow a task to change 1678 * of the main cic data structures. For now we allow a task to change
1707 * its cgroup only if it's the only owner of its ioc. 1679 * its cgroup only if it's the only owner of its ioc.
1708 */ 1680 */
1709static int blkiocg_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 1681static int blkiocg_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
1710 struct cgroup_taskset *tset)
1711{ 1682{
1712 struct task_struct *task; 1683 struct task_struct *task;
1713 struct io_context *ioc; 1684 struct io_context *ioc;
@@ -1750,6 +1721,18 @@ static void blkcg_bypass_end(void)
1750 mutex_unlock(&all_q_mutex); 1721 mutex_unlock(&all_q_mutex);
1751} 1722}
1752 1723
1724struct cgroup_subsys blkio_subsys = {
1725 .name = "blkio",
1726 .create = blkiocg_create,
1727 .can_attach = blkiocg_can_attach,
1728 .pre_destroy = blkiocg_pre_destroy,
1729 .destroy = blkiocg_destroy,
1730 .subsys_id = blkio_subsys_id,
1731 .base_cftypes = blkio_files,
1732 .module = THIS_MODULE,
1733};
1734EXPORT_SYMBOL_GPL(blkio_subsys);
1735
1753void blkio_policy_register(struct blkio_policy_type *blkiop) 1736void blkio_policy_register(struct blkio_policy_type *blkiop)
1754{ 1737{
1755 struct request_queue *q; 1738 struct request_queue *q;