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