aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-30 11:52:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-30 11:52:42 -0400
commit0d167518e045cc8bb63f0a8a0a85ad4fa4e0044f (patch)
tree101a9b5d425d79f663e4f25f1e90b7a8cc6604f1
parent2f83766d4b18774c856329a8fca4c9338dfeda39 (diff)
parentff26eaadf4d914e397872b99885d45756104e9ae (diff)
Merge branch 'for-3.5/core' of git://git.kernel.dk/linux-block
Merge block/IO core bits from Jens Axboe: "This is a bit bigger on the core side than usual, but that is purely because we decided to hold off on parts of Tejun's submission on 3.4 to give it a bit more time to simmer. As a consequence, it's seen a long cycle in for-next. It contains: - Bug fix from Dan, wrong locking type. - Relax splice gifting restriction from Eric. - A ton of updates from Tejun, primarily for blkcg. This improves the code a lot, making the API nicer and cleaner, and also includes fixes for how we handle and tie policies and re-activate on switches. The changes also include generic bug fixes. - A simple fix from Vivek, along with a fix for doing proper delayed allocation of the blkcg stats." Fix up annoying conflict just due to different merge resolution in Documentation/feature-removal-schedule.txt * 'for-3.5/core' of git://git.kernel.dk/linux-block: (92 commits) blkcg: tg_stats_alloc_lock is an irq lock vmsplice: relax alignement requirements for SPLICE_F_GIFT blkcg: use radix tree to index blkgs from blkcg blkcg: fix blkcg->css ref leak in __blkg_lookup_create() block: fix elvpriv allocation failure handling block: collapse blk_alloc_request() into get_request() blkcg: collapse blkcg_policy_ops into blkcg_policy blkcg: embed struct blkg_policy_data in policy specific data blkcg: mass rename of blkcg API blkcg: style cleanups for blk-cgroup.h blkcg: remove blkio_group->path[] blkcg: blkg_rwstat_read() was missing inline blkcg: shoot down blkgs if all policies are deactivated blkcg: drop stuff unused after per-queue policy activation update blkcg: implement per-queue policy activation blkcg: add request_queue->root_blkg blkcg: make request_queue bypassing on allocation blkcg: make sure blkg_lookup() returns %NULL if @q is bypassing blkcg: make blkg_conf_prep() take @pol and return with queue lock held blkcg: remove static policy ID enums ...
-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)