]>
Commit | Line | Data |
---|---|---|
31e4c28d VG |
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 | ||
2f5ea477 JA |
18 | #ifdef CONFIG_BLK_CGROUP |
19 | ||
31e4c28d VG |
20 | struct blkio_cgroup { |
21 | struct cgroup_subsys_state css; | |
22 | unsigned int weight; | |
23 | spinlock_t lock; | |
24 | struct hlist_head blkg_list; | |
25 | }; | |
26 | ||
27 | struct blkio_group { | |
28 | /* An rcu protected unique identifier for the group */ | |
29 | void *key; | |
30 | struct hlist_node blkcg_node; | |
b1c35769 | 31 | unsigned short blkcg_id; |
2868ef7b VG |
32 | #ifdef CONFIG_DEBUG_BLK_CGROUP |
33 | /* Store cgroup path */ | |
34 | char path[128]; | |
22084190 VG |
35 | /* How many times this group has been removed from service tree */ |
36 | unsigned long dequeue; | |
2868ef7b | 37 | #endif |
22084190 VG |
38 | /* The device MKDEV(major, minor), this group has been created for */ |
39 | dev_t dev; | |
40 | ||
41 | /* total disk time and nr sectors dispatched by this group */ | |
42 | unsigned long time; | |
43 | unsigned long sectors; | |
31e4c28d VG |
44 | }; |
45 | ||
9d6a986c VG |
46 | extern bool blkiocg_css_tryget(struct blkio_cgroup *blkcg); |
47 | extern void blkiocg_css_put(struct blkio_cgroup *blkcg); | |
48 | ||
2f5ea477 JA |
49 | #else |
50 | ||
51 | struct blkio_group { | |
52 | }; | |
53 | ||
54 | #endif | |
55 | ||
31e4c28d VG |
56 | #define BLKIO_WEIGHT_MIN 100 |
57 | #define BLKIO_WEIGHT_MAX 1000 | |
58 | #define BLKIO_WEIGHT_DEFAULT 500 | |
59 | ||
2868ef7b VG |
60 | #ifdef CONFIG_DEBUG_BLK_CGROUP |
61 | static inline char *blkg_path(struct blkio_group *blkg) | |
62 | { | |
63 | return blkg->path; | |
64 | } | |
22084190 VG |
65 | void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg, |
66 | unsigned long dequeue); | |
2868ef7b VG |
67 | #else |
68 | static inline char *blkg_path(struct blkio_group *blkg) { return NULL; } | |
22084190 VG |
69 | static inline void blkiocg_update_blkio_group_dequeue_stats( |
70 | struct blkio_group *blkg, unsigned long dequeue) {} | |
2868ef7b VG |
71 | #endif |
72 | ||
31e4c28d VG |
73 | #ifdef CONFIG_BLK_CGROUP |
74 | extern struct blkio_cgroup blkio_root_cgroup; | |
75 | extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); | |
76 | extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | |
22084190 | 77 | struct blkio_group *blkg, void *key, dev_t dev); |
31e4c28d VG |
78 | extern int blkiocg_del_blkio_group(struct blkio_group *blkg); |
79 | extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg, | |
80 | void *key); | |
22084190 VG |
81 | void blkiocg_update_blkio_group_stats(struct blkio_group *blkg, |
82 | unsigned long time, unsigned long sectors); | |
31e4c28d | 83 | #else |
2f5ea477 | 84 | struct cgroup; |
31e4c28d VG |
85 | static inline struct blkio_cgroup * |
86 | cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; } | |
87 | ||
88 | static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg, | |
22084190 | 89 | struct blkio_group *blkg, void *key, dev_t dev) |
31e4c28d VG |
90 | { |
91 | } | |
92 | ||
93 | static inline int | |
94 | blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; } | |
95 | ||
96 | static inline struct blkio_group * | |
97 | blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; } | |
22084190 VG |
98 | static inline void blkiocg_update_blkio_group_stats(struct blkio_group *blkg, |
99 | unsigned long time, unsigned long sectors) | |
100 | { | |
101 | } | |
31e4c28d VG |
102 | #endif |
103 | #endif /* _BLK_CGROUP_H */ |