xref: /linux/block/blk-cgroup.h (revision 2868ef7b39490e6b41c2c61cd9a5cd891e778b54)
131e4c28dSVivek Goyal #ifndef _BLK_CGROUP_H
231e4c28dSVivek Goyal #define _BLK_CGROUP_H
331e4c28dSVivek Goyal /*
431e4c28dSVivek Goyal  * Common Block IO controller cgroup interface
531e4c28dSVivek Goyal  *
631e4c28dSVivek Goyal  * Based on ideas and code from CFQ, CFS and BFQ:
731e4c28dSVivek Goyal  * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
831e4c28dSVivek Goyal  *
931e4c28dSVivek Goyal  * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
1031e4c28dSVivek Goyal  *		      Paolo Valente <paolo.valente@unimore.it>
1131e4c28dSVivek Goyal  *
1231e4c28dSVivek Goyal  * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
1331e4c28dSVivek Goyal  * 	              Nauman Rafique <nauman@google.com>
1431e4c28dSVivek Goyal  */
1531e4c28dSVivek Goyal 
1631e4c28dSVivek Goyal #include <linux/cgroup.h>
1731e4c28dSVivek Goyal 
1831e4c28dSVivek Goyal struct blkio_cgroup {
1931e4c28dSVivek Goyal 	struct cgroup_subsys_state css;
2031e4c28dSVivek Goyal 	unsigned int weight;
2131e4c28dSVivek Goyal 	spinlock_t lock;
2231e4c28dSVivek Goyal 	struct hlist_head blkg_list;
2331e4c28dSVivek Goyal };
2431e4c28dSVivek Goyal 
2531e4c28dSVivek Goyal struct blkio_group {
2631e4c28dSVivek Goyal 	/* An rcu protected unique identifier for the group */
2731e4c28dSVivek Goyal 	void *key;
2831e4c28dSVivek Goyal 	struct hlist_node blkcg_node;
29b1c35769SVivek Goyal 	unsigned short blkcg_id;
30*2868ef7bSVivek Goyal #ifdef CONFIG_DEBUG_BLK_CGROUP
31*2868ef7bSVivek Goyal 	/* Store cgroup path */
32*2868ef7bSVivek Goyal 	char path[128];
33*2868ef7bSVivek Goyal #endif
3431e4c28dSVivek Goyal };
3531e4c28dSVivek Goyal 
3631e4c28dSVivek Goyal #define BLKIO_WEIGHT_MIN	100
3731e4c28dSVivek Goyal #define BLKIO_WEIGHT_MAX	1000
3831e4c28dSVivek Goyal #define BLKIO_WEIGHT_DEFAULT	500
3931e4c28dSVivek Goyal 
40*2868ef7bSVivek Goyal #ifdef CONFIG_DEBUG_BLK_CGROUP
41*2868ef7bSVivek Goyal static inline char *blkg_path(struct blkio_group *blkg)
42*2868ef7bSVivek Goyal {
43*2868ef7bSVivek Goyal 	return blkg->path;
44*2868ef7bSVivek Goyal }
45*2868ef7bSVivek Goyal #else
46*2868ef7bSVivek Goyal static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
47*2868ef7bSVivek Goyal #endif
48*2868ef7bSVivek Goyal 
4931e4c28dSVivek Goyal #ifdef CONFIG_BLK_CGROUP
5031e4c28dSVivek Goyal extern struct blkio_cgroup blkio_root_cgroup;
5131e4c28dSVivek Goyal extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
5231e4c28dSVivek Goyal extern void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
5331e4c28dSVivek Goyal 				struct blkio_group *blkg, void *key);
5431e4c28dSVivek Goyal extern int blkiocg_del_blkio_group(struct blkio_group *blkg);
5531e4c28dSVivek Goyal extern struct blkio_group *blkiocg_lookup_group(struct blkio_cgroup *blkcg,
5631e4c28dSVivek Goyal 						void *key);
5731e4c28dSVivek Goyal #else
5831e4c28dSVivek Goyal static inline struct blkio_cgroup *
5931e4c28dSVivek Goyal cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
6031e4c28dSVivek Goyal 
6131e4c28dSVivek Goyal static inline void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
6231e4c28dSVivek Goyal 			struct blkio_group *blkg, void *key)
6331e4c28dSVivek Goyal {
6431e4c28dSVivek Goyal }
6531e4c28dSVivek Goyal 
6631e4c28dSVivek Goyal static inline int
6731e4c28dSVivek Goyal blkiocg_del_blkio_group(struct blkio_group *blkg) { return 0; }
6831e4c28dSVivek Goyal 
6931e4c28dSVivek Goyal static inline struct blkio_group *
7031e4c28dSVivek Goyal blkiocg_lookup_group(struct blkio_cgroup *blkcg, void *key) { return NULL; }
7131e4c28dSVivek Goyal #endif
7231e4c28dSVivek Goyal #endif /* _BLK_CGROUP_H */
73