blkio: Export disk time and sectors used by a group to user space
[linux-2.6/x86.git] / block / blk-cgroup.h
blobb24ab71db8268cca32cf0623d6a191732c065776
1 #ifndef _BLK_CGROUP_H
2 #define _BLK_CGROUP_H
3 /*
4 * Common Block IO controller cgroup interface
6 * Based on ideas and code from CFQ, CFS and BFQ:
7 * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
9 * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
10 * Paolo Valente <paolo.valente@unimore.it>
12 * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
13 * Nauman Rafique <nauman@google.com>
16 #include <linux/cgroup.h>
18 struct blkio_cgroup {
19 struct cgroup_subsys_state css;
20 unsigned int weight;
21 spinlock_t lock;
22 struct hlist_head blkg_list;
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;
39 /* total disk time and nr sectors dispatched by this group */
40 unsigned long time;
41 unsigned long sectors;
44 #define BLKIO_WEIGHT_MIN 100
45 #define BLKIO_WEIGHT_MAX 1000
46 #define BLKIO_WEIGHT_DEFAULT 500
48 #ifdef CONFIG_DEBUG_BLK_CGROUP
49 static inline char *blkg_path(struct blkio_group *blkg)
51 return blkg->path;
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
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; }
75 static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
76 struct blkio_group *blkg, void *key, dev_t dev)
80 static inline int
81 blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
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)
89 #endif
90 #endif /* _BLK_CGROUP_H */