diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /block/blk-cgroup.h | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'block/blk-cgroup.h')
-rw-r--r-- | block/blk-cgroup.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h new file mode 100644 index 000000000000..8ccc20464dae --- /dev/null +++ b/block/blk-cgroup.h | |||
@@ -0,0 +1,130 @@ | |||
1 | #ifndef _BLK_CGROUP_H | ||
2 | #define _BLK_CGROUP_H | ||
3 | /* | ||
4 | * Common Block IO controller cgroup interface | ||
5 | * | ||
6 | * Based on ideas and code from CFQ, CFS and BFQ: | ||
7 | * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk> | ||
8 | * | ||
9 | * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it> | ||
10 | * Paolo Valente <paolo.valente@unimore.it> | ||
11 | * | ||
12 | * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com> | ||
13 | * Nauman Rafique <nauman@google.com> | ||
14 | */ | ||
15 | |||
16 | #include <linux/cgroup.h> | ||
17 | |||
18 | #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) | ||
19 | |||
20 | #ifndef CONFIG_BLK_CGROUP | ||
21 | /* When blk-cgroup is a module, its subsys_id isn't a compile-time constant */ | ||
22 | extern struct cgroup_subsys blkio_subsys; | ||
23 | #define blkio_subsys_id blkio_subsys.subsys_id | ||
24 | #endif | ||
25 | |||
26 | struct blkio_cgroup { | ||
27 | struct cgroup_subsys_state css; | ||
28 | unsigned int weight; | ||
29 | spinlock_t lock; | ||
30 | struct hlist_head blkg_list; | ||
31 | }; | ||
32 | |||
33 | struct blkio_group { | ||
34 | /* An rcu protected unique identifier for the group */ | ||
35 | void *key; | ||
36 | struct hlist_node blkcg_node; | ||
37 | unsigned short blkcg_id; | ||
38 | #ifdef CONFIG_DEBUG_BLK_CGROUP | ||
39 | /* Store cgroup path */ | ||
40 | char path[128]; | ||
41 | /* How many times this group has been removed from service tree */ | ||
42 | unsigned long dequeue; | ||
43 | #endif | ||
44 | /* The device MKDEV(major, minor), this group has been created for */ | ||
45 | dev_t dev; | ||
46 | |||
47 | /* total disk time and nr sectors dispatched by this group */ | ||
48 | unsigned long time; | ||
49 | unsigned long sectors; | ||
50 | }; | ||
51 | |||
52 | typedef void (blkio_unlink_group_fn) (void *key, struct blkio_group *blkg); | ||
53 | typedef void (blkio_update_group_weight_fn) (struct blkio_group *blkg, | ||
54 | unsigned int weight); | ||
55 | |||
56 | struct blkio_policy_ops { | ||
57 | blkio_unlink_group_fn *blkio_unlink_group_fn; | ||
58 | blkio_update_group_weight_fn *blkio_update_group_weight_fn; | ||
59 | }; | ||
60 | |||
61 | struct blkio_policy_type { | ||
62 | struct list_head list; | ||
63 | struct blkio_policy_ops ops; | ||
64 | }; | ||
65 | |||
66 | /* Blkio controller policy registration */ | ||
67 | extern void blkio_policy_register(struct blkio_policy_type *); | ||
68 | extern void blkio_policy_unregister(struct blkio_policy_type *); | ||
69 | |||
70 | #else | ||
71 | |||
72 | struct blkio_group { | ||
73 | }; | ||
74 | |||
75 | struct blkio_policy_type { | ||
76 | }; | ||
77 | |||
78 | static inline void blkio_policy_register(struct blkio_policy_type *blkiop) { } | ||
79 | static inline void blkio_policy_unregister(struct blkio_policy_type *blkiop) { } | ||
80 | |||
81 | #endif | ||
82 | |||
83 | #define BLKIO_WEIGHT_MIN 100 | ||
84 | #define BLKIO_WEIGHT_MAX 1000 | ||
85 | #define BLKIO_WEIGHT_DEFAULT 500 | ||
86 | |||
87 | #ifdef CONFIG_DEBUG_BLK_CGROUP | ||
88 | static inline char *blkg_path(struct blkio_group *blkg) | ||
89 | { | ||
90 | return blkg->path; | ||
91 | } | ||
92 | void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg, | ||
93 | unsigned long dequeue); | ||
94 | #else | ||
95 | static inline char *blkg_path(struct blkio_group *blkg) { return NULL; } | ||
96 | static inline void blkiocg_update_blkio_group_dequeue_stats( | ||
97 | struct blkio_group *blkg, unsigned long dequeue) {} | ||
98 | #endif | ||
99 | |||
100 | #if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE) | ||
101 | extern struct blkio_cgroup blkio_root_cgroup; | ||
102 | extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); | ||
103 | extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | ||
104 | struct blkio_group *blkg, void *key, dev_t dev); | ||
105 | extern int blkiocg_del_blkio_group(struct blkio_group *blkg); | ||
106 | extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, | ||
107 | void *key); | ||
108 | void blkiocg_update_blkio_group_stats(struct blkio_group *blkg, | ||
109 | unsigned long time, unsigned long sectors); | ||
110 | #else | ||
111 | struct cgroup; | ||
112 | static inline struct blkio_cgroup * | ||
113 | cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } | ||
114 | |||
115 | static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | ||
116 | struct blkio_group *blkg, void *key, dev_t dev) | ||
117 | { | ||
118 | } | ||
119 | |||
120 | static inline int | ||
121 | blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } | ||
122 | |||
123 | static inline struct blkio_group * | ||
124 | blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; } | ||
125 | static inline void blkiocg_update_blkio_group_stats(struct blkio_group *blkg, | ||
126 | unsigned long time, unsigned long sectors) | ||
127 | { | ||
128 | } | ||
129 | #endif | ||
130 | #endif /* _BLK_CGROUP_H */ | ||