xref: /linux-6.15/include/linux/blk-cgroup.h (revision bbb1ebe7)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BLK_CGROUP_H
3 #define _BLK_CGROUP_H
4 /*
5  * Common Block IO controller cgroup interface
6  *
7  * Based on ideas and code from CFQ, CFS and BFQ:
8  * Copyright (C) 2003 Jens Axboe <[email protected]>
9  *
10  * Copyright (C) 2008 Fabio Checconi <[email protected]>
11  *		      Paolo Valente <[email protected]>
12  *
13  * Copyright (C) 2009 Vivek Goyal <[email protected]>
14  * 	              Nauman Rafique <[email protected]>
15  */
16 
17 #include <linux/cgroup.h>
18 #include <linux/percpu.h>
19 #include <linux/percpu_counter.h>
20 #include <linux/u64_stats_sync.h>
21 #include <linux/seq_file.h>
22 #include <linux/radix-tree.h>
23 #include <linux/blkdev.h>
24 #include <linux/atomic.h>
25 #include <linux/kthread.h>
26 #include <linux/fs.h>
27 
28 #define FC_APPID_LEN              129
29 
30 #ifdef CONFIG_BLK_CGROUP
31 extern struct cgroup_subsys_state * const blkcg_root_css;
32 
33 void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay);
34 void blkcg_maybe_throttle_current(void);
35 bool blk_cgroup_congested(void);
36 void blkcg_pin_online(struct cgroup_subsys_state *blkcg_css);
37 void blkcg_unpin_online(struct cgroup_subsys_state *blkcg_css);
38 struct list_head *blkcg_get_cgwb_list(struct cgroup_subsys_state *css);
39 struct cgroup_subsys_state *bio_blkcg_css(struct bio *bio);
40 
41 #else	/* CONFIG_BLK_CGROUP */
42 
43 #define blkcg_root_css	((struct cgroup_subsys_state *)ERR_PTR(-EINVAL))
44 
45 static inline void blkcg_maybe_throttle_current(void) { }
46 static inline bool blk_cgroup_congested(void) { return false; }
47 
48 #ifdef CONFIG_BLOCK
49 static inline void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay) { }
50 static inline struct cgroup_subsys_state *bio_blkcg_css(struct bio *bio)
51 {
52 	return NULL;
53 }
54 #endif /* CONFIG_BLOCK */
55 
56 #endif	/* CONFIG_BLK_CGROUP */
57 
58 int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len);
59 char *blkcg_get_fc_appid(struct bio *bio);
60 
61 #endif	/* _BLK_CGROUP_H */
62