aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/Kconfig.iosched4
-rw-r--r--block/blk-cgroup.c2100
-rw-r--r--block/blk-cgroup.h647
-rw-r--r--block/blk-core.c281
-rw-r--r--block/blk-ioc.c126
-rw-r--r--block/blk-sysfs.c6
-rw-r--r--block/blk-throttle.c697
-rw-r--r--block/blk.h32
-rw-r--r--block/cfq-iosched.c1072
-rw-r--r--block/cfq.h115
-rw-r--r--block/deadline-iosched.c8
-rw-r--r--block/elevator.c121
-rw-r--r--block/noop-iosched.c8
-rw-r--r--fs/bio.c61
-rw-r--r--fs/ioprio.c2
-rw-r--r--fs/splice.c4
-rw-r--r--include/linux/bio.h8
-rw-r--r--include/linux/blk_types.h10
-rw-r--r--include/linux/blkdev.h20
-rw-r--r--include/linux/elevator.h8
-rw-r--r--include/linux/iocontext.h39
-rw-r--r--include/linux/ioprio.h22
-rw-r--r--init/Kconfig2
-rw-r--r--kernel/fork.c5
24 files changed, 2446 insertions, 2952 deletions
diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched
index 3199b76f795d..421bef9c4c48 100644
--- a/block/Kconfig.iosched
+++ b/block/Kconfig.iosched
@@ -23,8 +23,6 @@ config IOSCHED_DEADLINE
23 23
24config IOSCHED_CFQ 24config IOSCHED_CFQ
25 tristate "CFQ I/O scheduler" 25 tristate "CFQ I/O scheduler"
26 # If BLK_CGROUP is a module, CFQ has to be built as module.
27 depends on (BLK_CGROUP=m && m) || !BLK_CGROUP || BLK_CGROUP=y
28 default y 26 default y
29 ---help--- 27 ---help---
30 The CFQ I/O scheduler tries to distribute bandwidth equally 28 The CFQ I/O scheduler tries to distribute bandwidth equally
@@ -34,8 +32,6 @@ config IOSCHED_CFQ
34 32
35 This is the default I/O scheduler. 33 This is the default I/O scheduler.
36 34
37 Note: If BLK_CGROUP=m, then CFQ can be built only as module.
38
39config CFQ_GROUP_IOSCHED 35config CFQ_GROUP_IOSCHED
40 bool "CFQ Group Scheduling support" 36 bool "CFQ Group Scheduling support"
41 depends on IOSCHED_CFQ && BLK_CGROUP 37 depends on IOSCHED_CFQ && BLK_CGROUP
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 126c341955de..02cf6335e9bd 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -11,1570 +11,612 @@
11 * Nauman Rafique <nauman@google.com> 11 * Nauman Rafique <nauman@google.com>
12 */ 12 */
13#include <linux/ioprio.h> 13#include <linux/ioprio.h>
14#include <linux/seq_file.h>
15#include <linux/kdev_t.h> 14#include <linux/kdev_t.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/err.h> 16#include <linux/err.h>
18#include <linux/blkdev.h> 17#include <linux/blkdev.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include "blk-cgroup.h"
21#include <linux/genhd.h> 19#include <linux/genhd.h>
20#include <linux/delay.h>
21#include <linux/atomic.h>
22#include "blk-cgroup.h"
23#include "blk.h"
22 24
23#define MAX_KEY_LEN 100 25#define MAX_KEY_LEN 100
24 26
25static DEFINE_SPINLOCK(blkio_list_lock); 27static DEFINE_MUTEX(blkcg_pol_mutex);
26static LIST_HEAD(blkio_list);
27 28
28struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; 29struct blkcg blkcg_root = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT };
29EXPORT_SYMBOL_GPL(blkio_root_cgroup); 30EXPORT_SYMBOL_GPL(blkcg_root);
30 31
31/* for encoding cft->private value on file */ 32static struct blkcg_policy *blkcg_policy[BLKCG_MAX_POLS];
32#define BLKIOFILE_PRIVATE(x, val) (((x) << 16) | (val))
33/* What policy owns the file, proportional or throttle */
34#define BLKIOFILE_POLICY(val) (((val) >> 16) & 0xffff)
35#define BLKIOFILE_ATTR(val) ((val) & 0xffff)
36 33
37static inline void blkio_policy_insert_node(struct blkio_cgroup *blkcg, 34struct blkcg *cgroup_to_blkcg(struct cgroup *cgroup)
38 struct blkio_policy_node *pn)
39{ 35{
40 list_add(&pn->node, &blkcg->policy_list); 36 return container_of(cgroup_subsys_state(cgroup, blkio_subsys_id),
37 struct blkcg, css);
41} 38}
39EXPORT_SYMBOL_GPL(cgroup_to_blkcg);
42 40
43static inline bool cftype_blkg_same_policy(struct cftype *cft, 41static struct blkcg *task_blkcg(struct task_struct *tsk)
44 struct blkio_group *blkg)
45{ 42{
46 enum blkio_policy_id plid = BLKIOFILE_POLICY(cft->private); 43 return container_of(task_subsys_state(tsk, blkio_subsys_id),
47 44 struct blkcg, css);
48 if (blkg->plid == plid)
49 return 1;
50
51 return 0;
52} 45}
53 46
54/* Determines if policy node matches cgroup file being accessed */ 47struct blkcg *bio_blkcg(struct bio *bio)
55static inline bool pn_matches_cftype(struct cftype *cft,
56 struct blkio_policy_node *pn)
57{ 48{
58 enum blkio_policy_id plid = BLKIOFILE_POLICY(cft->private); 49 if (bio && bio->bi_css)
59 int fileid = BLKIOFILE_ATTR(cft->private); 50 return container_of(bio->bi_css, struct blkcg, css);
60 51 return task_blkcg(current);
61 return (plid == pn->plid && fileid == pn->fileid);
62} 52}
53EXPORT_SYMBOL_GPL(bio_blkcg);
63 54
64/* Must be called with blkcg->lock held */ 55static bool blkcg_policy_enabled(struct request_queue *q,
65static inline void blkio_policy_delete_node(struct blkio_policy_node *pn) 56 const struct blkcg_policy *pol)
66{ 57{
67 list_del(&pn->node); 58 return pol && test_bit(pol->plid, q->blkcg_pols);
68} 59}
69 60
70/* Must be called with blkcg->lock held */ 61/**
71static struct blkio_policy_node * 62 * blkg_free - free a blkg
72blkio_policy_search_node(const struct blkio_cgroup *blkcg, dev_t dev, 63 * @blkg: blkg to free
73 enum blkio_policy_id plid, int fileid) 64 *
65 * Free @blkg which may be partially allocated.
66 */
67static void blkg_free(struct blkcg_gq *blkg)
74{ 68{
75 struct blkio_policy_node *pn; 69 int i;
76
77 list_for_each_entry(pn, &blkcg->policy_list, node) {
78 if (pn->dev == dev && pn->plid == plid && pn->fileid == fileid)
79 return pn;
80 }
81 70
82 return NULL; 71 if (!blkg)
83} 72 return;
84 73
85struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup) 74 for (i = 0; i < BLKCG_MAX_POLS; i++) {
86{ 75 struct blkcg_policy *pol = blkcg_policy[i];
87 return container_of(cgroup_subsys_state(cgroup, blkio_subsys_id), 76 struct blkg_policy_data *pd = blkg->pd[i];
88 struct blkio_cgroup, css);
89}
90EXPORT_SYMBOL_GPL(cgroup_to_blkio_cgroup);
91 77
92struct blkio_cgroup *task_blkio_cgroup(struct task_struct *tsk) 78 if (!pd)
93{ 79 continue;
94 return container_of(task_subsys_state(tsk, blkio_subsys_id),
95 struct blkio_cgroup, css);
96}
97EXPORT_SYMBOL_GPL(task_blkio_cgroup);
98 80
99static inline void 81 if (pol && pol->pd_exit_fn)
100blkio_update_group_weight(struct blkio_group *blkg, unsigned int weight) 82 pol->pd_exit_fn(blkg);
101{
102 struct blkio_policy_type *blkiop;
103 83
104 list_for_each_entry(blkiop, &blkio_list, list) { 84 kfree(pd);
105 /* If this policy does not own the blkg, do not send updates */
106 if (blkiop->plid != blkg->plid)
107 continue;
108 if (blkiop->ops.blkio_update_group_weight_fn)
109 blkiop->ops.blkio_update_group_weight_fn(blkg->key,
110 blkg, weight);
111 } 85 }
86
87 kfree(blkg);
112} 88}
113 89
114static inline void blkio_update_group_bps(struct blkio_group *blkg, u64 bps, 90/**
115 int fileid) 91 * blkg_alloc - allocate a blkg