blob: b24ab71db8268cca32cf0623d6a191732c065776 [file] [log] [blame]
Vivek Goyal31e4c282009-12-03 12:59:42 -05001#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
18struct blkio_cgroup {
19 struct cgroup_subsys_state css;
20 unsigned int weight;
21 spinlock_t lock;
22 struct hlist_head blkg_list;
23};
24
25struct blkio_group {
26 /* An rcu protected unique identifier for the group */
27 void *key;
28 struct hlist_node blkcg_node;
Vivek Goyalb1c35762009-12-03 12:59:47 -050029 unsigned short blkcg_id;
Vivek Goyal2868ef72009-12-03 12:59:48 -050030#ifdef CONFIG_DEBUG_BLK_CGROUP
31 /* Store cgroup path */
32 char path[128];
Vivek Goyal22084192009-12-03 12:59:49 -050033 /* How many times this group has been removed from service tree */
34 unsigned long dequeue;
Vivek Goyal2868ef72009-12-03 12:59:48 -050035#endif
Vivek Goyal22084192009-12-03 12:59:49 -050036 /* 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;
Vivek Goyal31e4c282009-12-03 12:59:42 -050042};
43
44#define BLKIO_WEIGHT_MIN 100
45#define BLKIO_WEIGHT_MAX 1000
46#define BLKIO_WEIGHT_DEFAULT 500
47
Vivek Goyal2868ef72009-12-03 12:59:48 -050048#ifdef CONFIG_DEBUG_BLK_CGROUP
49static inline char *blkg_path(struct blkio_group *blkg)
50{
51 return blkg->path;
52}
Vivek Goyal22084192009-12-03 12:59:49 -050053void blkiocg_update_blkio_group_dequeue_stats(struct blkio_group *blkg,
54 unsigned long dequeue);
Vivek Goyal2868ef72009-12-03 12:59:48 -050055#else
56static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
Vivek Goyal22084192009-12-03 12:59:49 -050057static inline void blkiocg_update_blkio_group_dequeue_stats(
58 struct blkio_group *blkg, unsigned long dequeue) {}
Vivek Goyal2868ef72009-12-03 12:59:48 -050059#endif
60
Vivek Goyal31e4c282009-12-03 12:59:42 -050061#ifdef CONFIG_BLK_CGROUP
62extern struct blkio_cgroup blkio_root_cgroup;
63extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
64extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
Vivek Goyal22084192009-12-03 12:59:49 -050065 struct blkio_group *blkg, void *key, dev_t dev);
Vivek Goyal31e4c282009-12-03 12:59:42 -050066extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
67extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg,
68 void *key);
Vivek Goyal22084192009-12-03 12:59:49 -050069void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
70 unsigned long time, unsigned long sectors);
Vivek Goyal31e4c282009-12-03 12:59:42 -050071#else
72static inline struct blkio_cgroup *
73cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
74
75static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
Vivek Goyal22084192009-12-03 12:59:49 -050076 struct blkio_group *blkg, void *key, dev_t dev)
Vivek Goyal31e4c282009-12-03 12:59:42 -050077{
78}
79
80static inline int
81blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
82
83static inline struct blkio_group *
84blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; }
Vivek Goyal22084192009-12-03 12:59:49 -050085static inline void blkiocg_update_blkio_group_stats(struct blkio_group *blkg,
86 unsigned long time, unsigned long sectors)
87{
88}
Vivek Goyal31e4c282009-12-03 12:59:42 -050089#endif
90#endif /* _BLK_CGROUP_H */