blkio: Export disk time and sectors used by a group to user space
[deliverable/linux.git] / block / blk-cgroup.h
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;
29 unsigned short blkcg_id;
30 #ifdef CONFIG_DEBUG_BLK_CGROUP
31 /* Store cgroup path */
32 char path[128];
33 /* How many times this group has been removed from service tree */
34 unsigned long dequeue;
35 #endif
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;
42 };
43
44 #define BLKIO_WEIGHT_MIN 100
45 #define BLKIO_WEIGHT_MAX 1000
46 #define BLKIO_WEIGHT_DEFAULT 500
47
48 #ifdef CONFIG_DEBUG_BLK_CGROUP
49 static inline char *blkg_path(struct blkio_group *blkg)
50 {
51 return blkg->path;
52 }
53 void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg,
54 unsigned long dequeue);
55 #else
56 static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
57 static inline void blkiocg_update_blkio_group_dequeue_stats(
58 struct blkio_group *blkg, unsigned long dequeue) {}
59 #endif
60
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,
65 struct blkio_group *blkg, void *key, dev_t dev);
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);
69 void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
70 unsigned long time, unsigned long sectors);
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,
76 struct blkio_group *blkg, void *key, dev_t dev)
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; }
85 static inline void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
86 unsigned long time, unsigned long sectors)
87 {
88 }
89 #endif
90 #endif /* _BLK_CGROUP_H */
This page took 0.043114 seconds and 5 git commands to generate.