1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2eea8f41cSTejun Heo #ifndef _BLK_CGROUP_H 3eea8f41cSTejun Heo #define _BLK_CGROUP_H 4eea8f41cSTejun Heo /* 5eea8f41cSTejun Heo * Common Block IO controller cgroup interface 6eea8f41cSTejun Heo * 7eea8f41cSTejun Heo * Based on ideas and code from CFQ, CFS and BFQ: 8eea8f41cSTejun Heo * Copyright (C) 2003 Jens Axboe <[email protected]> 9eea8f41cSTejun Heo * 10eea8f41cSTejun Heo * Copyright (C) 2008 Fabio Checconi <[email protected]> 11eea8f41cSTejun Heo * Paolo Valente <[email protected]> 12eea8f41cSTejun Heo * 13eea8f41cSTejun Heo * Copyright (C) 2009 Vivek Goyal <[email protected]> 14eea8f41cSTejun Heo * Nauman Rafique <[email protected]> 15eea8f41cSTejun Heo */ 16eea8f41cSTejun Heo 17eea8f41cSTejun Heo #include <linux/cgroup.h> 18f7331648STejun Heo #include <linux/percpu.h> 1924bdb8efSTejun Heo #include <linux/percpu_counter.h> 20f7331648STejun Heo #include <linux/u64_stats_sync.h> 21eea8f41cSTejun Heo #include <linux/seq_file.h> 22eea8f41cSTejun Heo #include <linux/radix-tree.h> 23eea8f41cSTejun Heo #include <linux/blkdev.h> 24eea8f41cSTejun Heo #include <linux/atomic.h> 25902ec5b6SShaohua Li #include <linux/kthread.h> 265cdf2e3fSDennis Zhou #include <linux/fs.h> 27eea8f41cSTejun Heo 2824bdb8efSTejun Heo /* percpu_counter batch for blkg_[rw]stats, per-cpu drift doesn't matter */ 2924bdb8efSTejun Heo #define BLKG_STAT_CPU_BATCH (INT_MAX / 2) 3024bdb8efSTejun Heo 31eea8f41cSTejun Heo /* Max limits for throttle policy */ 32eea8f41cSTejun Heo #define THROTL_IOPS_MAX UINT_MAX 33*d2bcbeabSMuneendra Kumar #define FC_APPID_LEN 129 34*d2bcbeabSMuneendra Kumar 35eea8f41cSTejun Heo 36eea8f41cSTejun Heo #ifdef CONFIG_BLK_CGROUP 37eea8f41cSTejun Heo 38f7331648STejun Heo enum blkg_iostat_type { 39f7331648STejun Heo BLKG_IOSTAT_READ, 40f7331648STejun Heo BLKG_IOSTAT_WRITE, 41f7331648STejun Heo BLKG_IOSTAT_DISCARD, 42f7331648STejun Heo 43f7331648STejun Heo BLKG_IOSTAT_NR, 44f7331648STejun Heo }; 45f7331648STejun Heo 46eea8f41cSTejun Heo struct blkcg_gq; 47eea8f41cSTejun Heo 48eea8f41cSTejun Heo struct blkcg { 49eea8f41cSTejun Heo struct cgroup_subsys_state css; 50eea8f41cSTejun Heo spinlock_t lock; 51d866dbf6STejun Heo refcount_t online_pin; 52eea8f41cSTejun Heo 53eea8f41cSTejun Heo struct radix_tree_root blkg_tree; 5455679c8dSBart Van Assche struct blkcg_gq __rcu *blkg_hint; 55eea8f41cSTejun Heo struct hlist_head blkg_list; 56eea8f41cSTejun Heo 5781437648STejun Heo struct blkcg_policy_data *cpd[BLKCG_MAX_POLS]; 5852ebea74STejun Heo 597876f930STejun Heo struct list_head all_blkcgs_node; 60*d2bcbeabSMuneendra Kumar #ifdef CONFIG_BLK_CGROUP_FC_APPID 61*d2bcbeabSMuneendra Kumar char fc_app_id[FC_APPID_LEN]; 62*d2bcbeabSMuneendra Kumar #endif 6352ebea74STejun Heo #ifdef CONFIG_CGROUP_WRITEBACK 6452ebea74STejun Heo struct list_head cgwb_list; 6552ebea74STejun Heo #endif 66eea8f41cSTejun Heo }; 67eea8f41cSTejun Heo 68f7331648STejun Heo struct blkg_iostat { 69f7331648STejun Heo u64 bytes[BLKG_IOSTAT_NR]; 70f7331648STejun Heo u64 ios[BLKG_IOSTAT_NR]; 71f7331648STejun Heo }; 72f7331648STejun Heo 73f7331648STejun Heo struct blkg_iostat_set { 74f7331648STejun Heo struct u64_stats_sync sync; 75f7331648STejun Heo struct blkg_iostat cur; 76f7331648STejun Heo struct blkg_iostat last; 77f7331648STejun Heo }; 78f7331648STejun Heo 79e6269c44STejun Heo /* 80eea8f41cSTejun Heo * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a 81eea8f41cSTejun Heo * request_queue (q). This is used by blkcg policies which need to track 82eea8f41cSTejun Heo * information per blkcg - q pair. 83eea8f41cSTejun Heo * 84001bea73STejun Heo * There can be multiple active blkcg policies and each blkg:policy pair is 85001bea73STejun Heo * represented by a blkg_policy_data which is allocated and freed by each 86001bea73STejun Heo * policy's pd_alloc/free_fn() methods. A policy can allocate private data 87001bea73STejun Heo * area by allocating larger data structure which embeds blkg_policy_data 88001bea73STejun Heo * at the beginning. 89eea8f41cSTejun Heo */ 90eea8f41cSTejun Heo struct blkg_policy_data { 91eea8f41cSTejun Heo /* the blkg and policy id this per-policy data belongs to */ 92eea8f41cSTejun Heo struct blkcg_gq *blkg; 93eea8f41cSTejun Heo int plid; 94eea8f41cSTejun Heo }; 95eea8f41cSTejun Heo 96e4bc13adSLinus Torvalds /* 97e4a9bde9STejun Heo * Policies that need to keep per-blkcg data which is independent from any 98e4a9bde9STejun Heo * request_queue associated to it should implement cpd_alloc/free_fn() 99e4a9bde9STejun Heo * methods. A policy can allocate private data area by allocating larger 100e4a9bde9STejun Heo * data structure which embeds blkcg_policy_data at the beginning. 101e4a9bde9STejun Heo * cpd_init() is invoked to let each policy handle per-blkcg data. 102e4bc13adSLinus Torvalds */ 103e4bc13adSLinus Torvalds struct blkcg_policy_data { 10481437648STejun Heo /* the blkcg and policy id this per-policy data belongs to */ 10581437648STejun Heo struct blkcg *blkcg; 106e4bc13adSLinus Torvalds int plid; 107e4bc13adSLinus Torvalds }; 108e4bc13adSLinus Torvalds 109eea8f41cSTejun Heo /* association between a blk cgroup and a request queue */ 110eea8f41cSTejun Heo struct blkcg_gq { 111eea8f41cSTejun Heo /* Pointer to the associated request_queue */ 112eea8f41cSTejun Heo struct request_queue *q; 113eea8f41cSTejun Heo struct list_head q_node; 114eea8f41cSTejun Heo struct hlist_node blkcg_node; 115eea8f41cSTejun Heo struct blkcg *blkcg; 116eea8f41cSTejun Heo 117eea8f41cSTejun Heo /* all non-root blkcg_gq's are guaranteed to have access to parent */ 118eea8f41cSTejun Heo struct blkcg_gq *parent; 119eea8f41cSTejun Heo 120eea8f41cSTejun Heo /* reference count */ 1217fcf2b03SDennis Zhou struct percpu_ref refcnt; 122eea8f41cSTejun Heo 123eea8f41cSTejun Heo /* is this blkg online? protected by both blkcg and q locks */ 124eea8f41cSTejun Heo bool online; 125eea8f41cSTejun Heo 126f7331648STejun Heo struct blkg_iostat_set __percpu *iostat_cpu; 127f7331648STejun Heo struct blkg_iostat_set iostat; 12877ea7338STejun Heo 129eea8f41cSTejun Heo struct blkg_policy_data *pd[BLKCG_MAX_POLS]; 130eea8f41cSTejun Heo 131d3f77dfdSTejun Heo spinlock_t async_bio_lock; 132d3f77dfdSTejun Heo struct bio_list async_bios; 133d3f77dfdSTejun Heo struct work_struct async_bio_work; 134d09d8df3SJosef Bacik 135d09d8df3SJosef Bacik atomic_t use_delay; 136d09d8df3SJosef Bacik atomic64_t delay_nsec; 137d09d8df3SJosef Bacik atomic64_t delay_start; 138d09d8df3SJosef Bacik u64 last_delay; 139d09d8df3SJosef Bacik int last_use; 140d3f77dfdSTejun Heo 141d3f77dfdSTejun Heo struct rcu_head rcu_head; 142eea8f41cSTejun Heo }; 143eea8f41cSTejun Heo 144e4a9bde9STejun Heo typedef struct blkcg_policy_data *(blkcg_pol_alloc_cpd_fn)(gfp_t gfp); 14581437648STejun Heo typedef void (blkcg_pol_init_cpd_fn)(struct blkcg_policy_data *cpd); 146e4a9bde9STejun Heo typedef void (blkcg_pol_free_cpd_fn)(struct blkcg_policy_data *cpd); 14769d7fde5STejun Heo typedef void (blkcg_pol_bind_cpd_fn)(struct blkcg_policy_data *cpd); 148cf09a8eeSTejun Heo typedef struct blkg_policy_data *(blkcg_pol_alloc_pd_fn)(gfp_t gfp, 149cf09a8eeSTejun Heo struct request_queue *q, struct blkcg *blkcg); 150a9520cd6STejun Heo typedef void (blkcg_pol_init_pd_fn)(struct blkg_policy_data *pd); 151a9520cd6STejun Heo typedef void (blkcg_pol_online_pd_fn)(struct blkg_policy_data *pd); 152a9520cd6STejun Heo typedef void (blkcg_pol_offline_pd_fn)(struct blkg_policy_data *pd); 153001bea73STejun Heo typedef void (blkcg_pol_free_pd_fn)(struct blkg_policy_data *pd); 154a9520cd6STejun Heo typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkg_policy_data *pd); 155903d23f0SJosef Bacik typedef size_t (blkcg_pol_stat_pd_fn)(struct blkg_policy_data *pd, char *buf, 156903d23f0SJosef Bacik size_t size); 157eea8f41cSTejun Heo 158eea8f41cSTejun Heo struct blkcg_policy { 159eea8f41cSTejun Heo int plid; 160eea8f41cSTejun Heo /* cgroup files for the policy */ 1612ee867dcSTejun Heo struct cftype *dfl_cftypes; 162880f50e2STejun Heo struct cftype *legacy_cftypes; 163eea8f41cSTejun Heo 164eea8f41cSTejun Heo /* operations */ 165e4a9bde9STejun Heo blkcg_pol_alloc_cpd_fn *cpd_alloc_fn; 166e4bc13adSLinus Torvalds blkcg_pol_init_cpd_fn *cpd_init_fn; 167e4a9bde9STejun Heo blkcg_pol_free_cpd_fn *cpd_free_fn; 16869d7fde5STejun Heo blkcg_pol_bind_cpd_fn *cpd_bind_fn; 169e4a9bde9STejun Heo 170001bea73STejun Heo blkcg_pol_alloc_pd_fn *pd_alloc_fn; 171eea8f41cSTejun Heo blkcg_pol_init_pd_fn *pd_init_fn; 172eea8f41cSTejun Heo blkcg_pol_online_pd_fn *pd_online_fn; 173eea8f41cSTejun Heo blkcg_pol_offline_pd_fn *pd_offline_fn; 174001bea73STejun Heo blkcg_pol_free_pd_fn *pd_free_fn; 175eea8f41cSTejun Heo blkcg_pol_reset_pd_stats_fn *pd_reset_stats_fn; 176903d23f0SJosef Bacik blkcg_pol_stat_pd_fn *pd_stat_fn; 177eea8f41cSTejun Heo }; 178eea8f41cSTejun Heo 179eea8f41cSTejun Heo extern struct blkcg blkcg_root; 180496d5e75STejun Heo extern struct cgroup_subsys_state * const blkcg_root_css; 18107b0fdecSTejun Heo extern bool blkcg_debug_stats; 182eea8f41cSTejun Heo 18324f29046STejun Heo struct blkcg_gq *blkg_lookup_slowpath(struct blkcg *blkcg, 18424f29046STejun Heo struct request_queue *q, bool update_hint); 185eea8f41cSTejun Heo int blkcg_init_queue(struct request_queue *q); 186eea8f41cSTejun Heo void blkcg_exit_queue(struct request_queue *q); 187eea8f41cSTejun Heo 188eea8f41cSTejun Heo /* Blkio controller policy registration */ 189eea8f41cSTejun Heo int blkcg_policy_register(struct blkcg_policy *pol); 190eea8f41cSTejun Heo void blkcg_policy_unregister(struct blkcg_policy *pol); 191eea8f41cSTejun Heo int blkcg_activate_policy(struct request_queue *q, 192eea8f41cSTejun Heo const struct blkcg_policy *pol); 193eea8f41cSTejun Heo void blkcg_deactivate_policy(struct request_queue *q, 194eea8f41cSTejun Heo const struct blkcg_policy *pol); 195eea8f41cSTejun Heo 196dd165eb3STejun Heo const char *blkg_dev_name(struct blkcg_gq *blkg); 197eea8f41cSTejun Heo void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg, 198eea8f41cSTejun Heo u64 (*prfill)(struct seq_file *, 199eea8f41cSTejun Heo struct blkg_policy_data *, int), 200eea8f41cSTejun Heo const struct blkcg_policy *pol, int data, 201eea8f41cSTejun Heo bool show_total); 202eea8f41cSTejun Heo u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v); 203eea8f41cSTejun Heo 204eea8f41cSTejun Heo struct blkg_conf_ctx { 20522ae8ce8SChristoph Hellwig struct block_device *bdev; 206eea8f41cSTejun Heo struct blkcg_gq *blkg; 20736aa9e5fSTejun Heo char *body; 208eea8f41cSTejun Heo }; 209eea8f41cSTejun Heo 21022ae8ce8SChristoph Hellwig struct block_device *blkcg_conf_open_bdev(char **inputp); 211eea8f41cSTejun Heo int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, 21236aa9e5fSTejun Heo char *input, struct blkg_conf_ctx *ctx); 213eea8f41cSTejun Heo void blkg_conf_finish(struct blkg_conf_ctx *ctx); 214eea8f41cSTejun Heo 2150fe061b9SDennis Zhou /** 2160fe061b9SDennis Zhou * blkcg_css - find the current css 2170fe061b9SDennis Zhou * 2180fe061b9SDennis Zhou * Find the css associated with either the kthread or the current task. 2190fe061b9SDennis Zhou * This may return a dying css, so it is up to the caller to use tryget logic 2200fe061b9SDennis Zhou * to confirm it is alive and well. 2210fe061b9SDennis Zhou */ 2220fe061b9SDennis Zhou static inline struct cgroup_subsys_state *blkcg_css(void) 2230fe061b9SDennis Zhou { 2240fe061b9SDennis Zhou struct cgroup_subsys_state *css; 2250fe061b9SDennis Zhou 2260fe061b9SDennis Zhou css = kthread_blkcg(); 2270fe061b9SDennis Zhou if (css) 2280fe061b9SDennis Zhou return css; 2290fe061b9SDennis Zhou return task_css(current, io_cgrp_id); 2300fe061b9SDennis Zhou } 2310fe061b9SDennis Zhou 232eea8f41cSTejun Heo static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css) 233eea8f41cSTejun Heo { 234eea8f41cSTejun Heo return css ? container_of(css, struct blkcg, css) : NULL; 235eea8f41cSTejun Heo } 236eea8f41cSTejun Heo 2370fe061b9SDennis Zhou /** 2380fe061b9SDennis Zhou * __bio_blkcg - internal, inconsistent version to get blkcg 2390fe061b9SDennis Zhou * 2400fe061b9SDennis Zhou * DO NOT USE. 2410fe061b9SDennis Zhou * This function is inconsistent and consequently is dangerous to use. The 2420fe061b9SDennis Zhou * first part of the function returns a blkcg where a reference is owned by the 2430fe061b9SDennis Zhou * bio. This means it does not need to be rcu protected as it cannot go away 2440fe061b9SDennis Zhou * with the bio owning a reference to it. However, the latter potentially gets 2450fe061b9SDennis Zhou * it from task_css(). This can race against task migration and the cgroup 2460fe061b9SDennis Zhou * dying. It is also semantically different as it must be called rcu protected 2470fe061b9SDennis Zhou * and is susceptible to failure when trying to get a reference to it. 2480fe061b9SDennis Zhou * Therefore, it is not ok to assume that *_get() will always succeed on the 2490fe061b9SDennis Zhou * blkcg returned here. 2500fe061b9SDennis Zhou */ 2510fe061b9SDennis Zhou static inline struct blkcg *__bio_blkcg(struct bio *bio) 25227e6fa99SDennis Zhou (Facebook) { 253db6638d7SDennis Zhou if (bio && bio->bi_blkg) 254db6638d7SDennis Zhou return bio->bi_blkg->blkcg; 2550fe061b9SDennis Zhou return css_to_blkcg(blkcg_css()); 2560fe061b9SDennis Zhou } 2570fe061b9SDennis Zhou 2580fe061b9SDennis Zhou /** 2590fe061b9SDennis Zhou * bio_blkcg - grab the blkcg associated with a bio 2600fe061b9SDennis Zhou * @bio: target bio 2610fe061b9SDennis Zhou * 2620fe061b9SDennis Zhou * This returns the blkcg associated with a bio, %NULL if not associated. 2630fe061b9SDennis Zhou * Callers are expected to either handle %NULL or know association has been 2640fe061b9SDennis Zhou * done prior to calling this. 2650fe061b9SDennis Zhou */ 2660fe061b9SDennis Zhou static inline struct blkcg *bio_blkcg(struct bio *bio) 2670fe061b9SDennis Zhou { 268db6638d7SDennis Zhou if (bio && bio->bi_blkg) 269db6638d7SDennis Zhou return bio->bi_blkg->blkcg; 2700fe061b9SDennis Zhou return NULL; 271fd383c2dSTejun Heo } 272fd383c2dSTejun Heo 273d09d8df3SJosef Bacik static inline bool blk_cgroup_congested(void) 274d09d8df3SJosef Bacik { 275d09d8df3SJosef Bacik struct cgroup_subsys_state *css; 276d09d8df3SJosef Bacik bool ret = false; 277d09d8df3SJosef Bacik 278d09d8df3SJosef Bacik rcu_read_lock(); 279d09d8df3SJosef Bacik css = kthread_blkcg(); 280d09d8df3SJosef Bacik if (!css) 281d09d8df3SJosef Bacik css = task_css(current, io_cgrp_id); 282d09d8df3SJosef Bacik while (css) { 283d09d8df3SJosef Bacik if (atomic_read(&css->cgroup->congestion_count)) { 284d09d8df3SJosef Bacik ret = true; 285d09d8df3SJosef Bacik break; 286d09d8df3SJosef Bacik } 287d09d8df3SJosef Bacik css = css->parent; 288d09d8df3SJosef Bacik } 289d09d8df3SJosef Bacik rcu_read_unlock(); 290d09d8df3SJosef Bacik return ret; 291d09d8df3SJosef Bacik } 292d09d8df3SJosef Bacik 293eea8f41cSTejun Heo /** 294c7c98fd3SJosef Bacik * bio_issue_as_root_blkg - see if this bio needs to be issued as root blkg 295c7c98fd3SJosef Bacik * @return: true if this bio needs to be submitted with the root blkg context. 296c7c98fd3SJosef Bacik * 297c7c98fd3SJosef Bacik * In order to avoid priority inversions we sometimes need to issue a bio as if 298c7c98fd3SJosef Bacik * it were attached to the root blkg, and then backcharge to the actual owning 299c7c98fd3SJosef Bacik * blkg. The idea is we do bio_blkcg() to look up the actual context for the 300c7c98fd3SJosef Bacik * bio and attach the appropriate blkg to the bio. Then we call this helper and 301c7c98fd3SJosef Bacik * if it is true run with the root blkg for that queue and then do any 302c7c98fd3SJosef Bacik * backcharging to the originating cgroup once the io is complete. 303c7c98fd3SJosef Bacik */ 304c7c98fd3SJosef Bacik static inline bool bio_issue_as_root_blkg(struct bio *bio) 305c7c98fd3SJosef Bacik { 3060d1e0c7cSJosef Bacik return (bio->bi_opf & (REQ_META | REQ_SWAP)) != 0; 307c7c98fd3SJosef Bacik } 308c7c98fd3SJosef Bacik 309c7c98fd3SJosef Bacik /** 310eea8f41cSTejun Heo * blkcg_parent - get the parent of a blkcg 311eea8f41cSTejun Heo * @blkcg: blkcg of interest 312eea8f41cSTejun Heo * 313eea8f41cSTejun Heo * Return the parent blkcg of @blkcg. Can be called anytime. 314eea8f41cSTejun Heo */ 315eea8f41cSTejun Heo static inline struct blkcg *blkcg_parent(struct blkcg *blkcg) 316eea8f41cSTejun Heo { 317eea8f41cSTejun Heo return css_to_blkcg(blkcg->css.parent); 318eea8f41cSTejun Heo } 319eea8f41cSTejun Heo 320eea8f41cSTejun Heo /** 32124f29046STejun Heo * __blkg_lookup - internal version of blkg_lookup() 32224f29046STejun Heo * @blkcg: blkcg of interest 32324f29046STejun Heo * @q: request_queue of interest 32424f29046STejun Heo * @update_hint: whether to update lookup hint with the result or not 32524f29046STejun Heo * 32624f29046STejun Heo * This is internal version and shouldn't be used by policy 32724f29046STejun Heo * implementations. Looks up blkgs for the @blkcg - @q pair regardless of 32824f29046STejun Heo * @q's bypass state. If @update_hint is %true, the caller should be 32924f29046STejun Heo * holding @q->queue_lock and lookup hint is updated on success. 33024f29046STejun Heo */ 33124f29046STejun Heo static inline struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg, 33224f29046STejun Heo struct request_queue *q, 33324f29046STejun Heo bool update_hint) 33424f29046STejun Heo { 33524f29046STejun Heo struct blkcg_gq *blkg; 33624f29046STejun Heo 33785b6bc9dSTejun Heo if (blkcg == &blkcg_root) 33885b6bc9dSTejun Heo return q->root_blkg; 33985b6bc9dSTejun Heo 34024f29046STejun Heo blkg = rcu_dereference(blkcg->blkg_hint); 34124f29046STejun Heo if (blkg && blkg->q == q) 34224f29046STejun Heo return blkg; 34324f29046STejun Heo 34424f29046STejun Heo return blkg_lookup_slowpath(blkcg, q, update_hint); 34524f29046STejun Heo } 34624f29046STejun Heo 34724f29046STejun Heo /** 34824f29046STejun Heo * blkg_lookup - lookup blkg for the specified blkcg - q pair 34924f29046STejun Heo * @blkcg: blkcg of interest 35024f29046STejun Heo * @q: request_queue of interest 35124f29046STejun Heo * 35224f29046STejun Heo * Lookup blkg for the @blkcg - @q pair. This function should be called 353012d4a65SBart Van Assche * under RCU read lock. 35424f29046STejun Heo */ 35524f29046STejun Heo static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, 35624f29046STejun Heo struct request_queue *q) 35724f29046STejun Heo { 35824f29046STejun Heo WARN_ON_ONCE(!rcu_read_lock_held()); 35924f29046STejun Heo return __blkg_lookup(blkcg, q, false); 36024f29046STejun Heo } 36124f29046STejun Heo 36224f29046STejun Heo /** 363b86d865cSBart Van Assche * blk_queue_root_blkg - return blkg for the (blkcg_root, @q) pair 3646bad9b21SBart Van Assche * @q: request_queue of interest 3656bad9b21SBart Van Assche * 3666bad9b21SBart Van Assche * Lookup blkg for @q at the root level. See also blkg_lookup(). 3676bad9b21SBart Van Assche */ 368b86d865cSBart Van Assche static inline struct blkcg_gq *blk_queue_root_blkg(struct request_queue *q) 3696bad9b21SBart Van Assche { 370b86d865cSBart Van Assche return q->root_blkg; 3716bad9b21SBart Van Assche } 3726bad9b21SBart Van Assche 3736bad9b21SBart Van Assche /** 374eea8f41cSTejun Heo * blkg_to_pdata - get policy private data 375eea8f41cSTejun Heo * @blkg: blkg of interest 376eea8f41cSTejun Heo * @pol: policy of interest 377eea8f41cSTejun Heo * 378eea8f41cSTejun Heo * Return pointer to private data associated with the @blkg-@pol pair. 379eea8f41cSTejun Heo */ 380eea8f41cSTejun Heo static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg, 381eea8f41cSTejun Heo struct blkcg_policy *pol) 382eea8f41cSTejun Heo { 383eea8f41cSTejun Heo return blkg ? blkg->pd[pol->plid] : NULL; 384eea8f41cSTejun Heo } 385eea8f41cSTejun Heo 386e4bc13adSLinus Torvalds static inline struct blkcg_policy_data *blkcg_to_cpd(struct blkcg *blkcg, 387e4bc13adSLinus Torvalds struct blkcg_policy *pol) 388e4bc13adSLinus Torvalds { 38981437648STejun Heo return blkcg ? blkcg->cpd[pol->plid] : NULL; 390e4bc13adSLinus Torvalds } 391e4bc13adSLinus Torvalds 392eea8f41cSTejun Heo /** 393eea8f41cSTejun Heo * pdata_to_blkg - get blkg associated with policy private data 394eea8f41cSTejun Heo * @pd: policy private data of interest 395eea8f41cSTejun Heo * 396eea8f41cSTejun Heo * @pd is policy private data. Determine the blkg it's associated with. 397eea8f41cSTejun Heo */ 398eea8f41cSTejun Heo static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd) 399eea8f41cSTejun Heo { 400eea8f41cSTejun Heo return pd ? pd->blkg : NULL; 401eea8f41cSTejun Heo } 402eea8f41cSTejun Heo 40381437648STejun Heo static inline struct blkcg *cpd_to_blkcg(struct blkcg_policy_data *cpd) 40481437648STejun Heo { 40581437648STejun Heo return cpd ? cpd->blkcg : NULL; 40681437648STejun Heo } 40781437648STejun Heo 40859b57717SDennis Zhou (Facebook) extern void blkcg_destroy_blkgs(struct blkcg *blkcg); 40959b57717SDennis Zhou (Facebook) 41059b57717SDennis Zhou (Facebook) /** 411d866dbf6STejun Heo * blkcg_pin_online - pin online state 41259b57717SDennis Zhou (Facebook) * @blkcg: blkcg of interest 41359b57717SDennis Zhou (Facebook) * 414d866dbf6STejun Heo * While pinned, a blkcg is kept online. This is primarily used to 415d866dbf6STejun Heo * impedance-match blkg and cgwb lifetimes so that blkg doesn't go offline 416d866dbf6STejun Heo * while an associated cgwb is still active. 41759b57717SDennis Zhou (Facebook) */ 418d866dbf6STejun Heo static inline void blkcg_pin_online(struct blkcg *blkcg) 41959b57717SDennis Zhou (Facebook) { 420d866dbf6STejun Heo refcount_inc(&blkcg->online_pin); 42159b57717SDennis Zhou (Facebook) } 42259b57717SDennis Zhou (Facebook) 42359b57717SDennis Zhou (Facebook) /** 424d866dbf6STejun Heo * blkcg_unpin_online - unpin online state 42559b57717SDennis Zhou (Facebook) * @blkcg: blkcg of interest 42659b57717SDennis Zhou (Facebook) * 427d866dbf6STejun Heo * This is primarily used to impedance-match blkg and cgwb lifetimes so 428d866dbf6STejun Heo * that blkg doesn't go offline while an associated cgwb is still active. 429d866dbf6STejun Heo * When this count goes to zero, all active cgwbs have finished so the 43059b57717SDennis Zhou (Facebook) * blkcg can continue destruction by calling blkcg_destroy_blkgs(). 43159b57717SDennis Zhou (Facebook) */ 432d866dbf6STejun Heo static inline void blkcg_unpin_online(struct blkcg *blkcg) 43359b57717SDennis Zhou (Facebook) { 4344308a434STejun Heo do { 4354308a434STejun Heo if (!refcount_dec_and_test(&blkcg->online_pin)) 4364308a434STejun Heo break; 43759b57717SDennis Zhou (Facebook) blkcg_destroy_blkgs(blkcg); 4384308a434STejun Heo blkcg = blkcg_parent(blkcg); 4394308a434STejun Heo } while (blkcg); 44059b57717SDennis Zhou (Facebook) } 44159b57717SDennis Zhou (Facebook) 442eea8f41cSTejun Heo /** 443eea8f41cSTejun Heo * blkg_path - format cgroup path of blkg 444eea8f41cSTejun Heo * @blkg: blkg of interest 445eea8f41cSTejun Heo * @buf: target buffer 446eea8f41cSTejun Heo * @buflen: target buffer length 447eea8f41cSTejun Heo * 448eea8f41cSTejun Heo * Format the path of the cgroup of @blkg into @buf. 449eea8f41cSTejun Heo */ 450eea8f41cSTejun Heo static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen) 451eea8f41cSTejun Heo { 4524c737b41STejun Heo return cgroup_path(blkg->blkcg->css.cgroup, buf, buflen); 453eea8f41cSTejun Heo } 454eea8f41cSTejun Heo 455eea8f41cSTejun Heo /** 456eea8f41cSTejun Heo * blkg_get - get a blkg reference 457eea8f41cSTejun Heo * @blkg: blkg to get 458eea8f41cSTejun Heo * 459eea8f41cSTejun Heo * The caller should be holding an existing reference. 460eea8f41cSTejun Heo */ 461eea8f41cSTejun Heo static inline void blkg_get(struct blkcg_gq *blkg) 462eea8f41cSTejun Heo { 4637fcf2b03SDennis Zhou percpu_ref_get(&blkg->refcnt); 464eea8f41cSTejun Heo } 465eea8f41cSTejun Heo 466d09d8df3SJosef Bacik /** 4677754f669SDennis Zhou * blkg_tryget - try and get a blkg reference 468d09d8df3SJosef Bacik * @blkg: blkg to get 469d09d8df3SJosef Bacik * 470d09d8df3SJosef Bacik * This is for use when doing an RCU lookup of the blkg. We may be in the midst 471d09d8df3SJosef Bacik * of freeing this blkg, so we can only use it if the refcnt is not zero. 472d09d8df3SJosef Bacik */ 4737754f669SDennis Zhou static inline bool blkg_tryget(struct blkcg_gq *blkg) 474d09d8df3SJosef Bacik { 4756ab21879SDennis Zhou return blkg && percpu_ref_tryget(&blkg->refcnt); 47607b05bccSDennis Zhou (Facebook) } 477d09d8df3SJosef Bacik 478beea9da0SDennis Zhou /** 479eea8f41cSTejun Heo * blkg_put - put a blkg reference 480eea8f41cSTejun Heo * @blkg: blkg to put 481eea8f41cSTejun Heo */ 482eea8f41cSTejun Heo static inline void blkg_put(struct blkcg_gq *blkg) 483eea8f41cSTejun Heo { 4847fcf2b03SDennis Zhou percpu_ref_put(&blkg->refcnt); 485eea8f41cSTejun Heo } 486eea8f41cSTejun Heo 487eea8f41cSTejun Heo /** 488eea8f41cSTejun Heo * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants 489eea8f41cSTejun Heo * @d_blkg: loop cursor pointing to the current descendant 490eea8f41cSTejun Heo * @pos_css: used for iteration 491eea8f41cSTejun Heo * @p_blkg: target blkg to walk descendants of 492eea8f41cSTejun Heo * 493eea8f41cSTejun Heo * Walk @c_blkg through the descendants of @p_blkg. Must be used with RCU 494eea8f41cSTejun Heo * read locked. If called under either blkcg or queue lock, the iteration 495eea8f41cSTejun Heo * is guaranteed to include all and only online blkgs. The caller may 496eea8f41cSTejun Heo * update @pos_css by calling css_rightmost_descendant() to skip subtree. 497eea8f41cSTejun Heo * @p_blkg is included in the iteration and the first node to be visited. 498eea8f41cSTejun Heo */ 499eea8f41cSTejun Heo #define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg) \ 500eea8f41cSTejun Heo css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \ 501eea8f41cSTejun Heo if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \ 502eea8f41cSTejun Heo (p_blkg)->q, false))) 503eea8f41cSTejun Heo 504eea8f41cSTejun Heo /** 505eea8f41cSTejun Heo * blkg_for_each_descendant_post - post-order walk of a blkg's descendants 506eea8f41cSTejun Heo * @d_blkg: loop cursor pointing to the current descendant 507eea8f41cSTejun Heo * @pos_css: used for iteration 508eea8f41cSTejun Heo * @p_blkg: target blkg to walk descendants of 509eea8f41cSTejun Heo * 510eea8f41cSTejun Heo * Similar to blkg_for_each_descendant_pre() but performs post-order 511eea8f41cSTejun Heo * traversal instead. Synchronization rules are the same. @p_blkg is 512eea8f41cSTejun Heo * included in the iteration and the last node to be visited. 513eea8f41cSTejun Heo */ 514eea8f41cSTejun Heo #define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg) \ 515eea8f41cSTejun Heo css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \ 516eea8f41cSTejun Heo if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \ 517eea8f41cSTejun Heo (p_blkg)->q, false))) 518eea8f41cSTejun Heo 519d3f77dfdSTejun Heo bool __blkcg_punt_bio_submit(struct bio *bio); 520d3f77dfdSTejun Heo 521d3f77dfdSTejun Heo static inline bool blkcg_punt_bio_submit(struct bio *bio) 522d3f77dfdSTejun Heo { 523d3f77dfdSTejun Heo if (bio->bi_opf & REQ_CGROUP_PUNT) 524d3f77dfdSTejun Heo return __blkcg_punt_bio_submit(bio); 525d3f77dfdSTejun Heo else 526d3f77dfdSTejun Heo return false; 527d3f77dfdSTejun Heo } 528e439bedfSDennis Zhou 529e439bedfSDennis Zhou static inline void blkcg_bio_issue_init(struct bio *bio) 530e439bedfSDennis Zhou { 531e439bedfSDennis Zhou bio_issue_init(&bio->bi_issue, bio_sectors(bio)); 532e439bedfSDennis Zhou } 533e439bedfSDennis Zhou 534d09d8df3SJosef Bacik static inline void blkcg_use_delay(struct blkcg_gq *blkg) 535d09d8df3SJosef Bacik { 53654c52e10STejun Heo if (WARN_ON_ONCE(atomic_read(&blkg->use_delay) < 0)) 53754c52e10STejun Heo return; 538d09d8df3SJosef Bacik if (atomic_add_return(1, &blkg->use_delay) == 1) 539d09d8df3SJosef Bacik atomic_inc(&blkg->blkcg->css.cgroup->congestion_count); 540d09d8df3SJosef Bacik } 541d09d8df3SJosef Bacik 542d09d8df3SJosef Bacik static inline int blkcg_unuse_delay(struct blkcg_gq *blkg) 543d09d8df3SJosef Bacik { 544d09d8df3SJosef Bacik int old = atomic_read(&blkg->use_delay); 545d09d8df3SJosef Bacik 54654c52e10STejun Heo if (WARN_ON_ONCE(old < 0)) 54754c52e10STejun Heo return 0; 548d09d8df3SJosef Bacik if (old == 0) 549d09d8df3SJosef Bacik return 0; 550d09d8df3SJosef Bacik 551d09d8df3SJosef Bacik /* 552d09d8df3SJosef Bacik * We do this song and dance because we can race with somebody else 553d09d8df3SJosef Bacik * adding or removing delay. If we just did an atomic_dec we'd end up 554d09d8df3SJosef Bacik * negative and we'd already be in trouble. We need to subtract 1 and 555d09d8df3SJosef Bacik * then check to see if we were the last delay so we can drop the 556d09d8df3SJosef Bacik * congestion count on the cgroup. 557d09d8df3SJosef Bacik */ 558d09d8df3SJosef Bacik while (old) { 559d09d8df3SJosef Bacik int cur = atomic_cmpxchg(&blkg->use_delay, old, old - 1); 560d09d8df3SJosef Bacik if (cur == old) 561d09d8df3SJosef Bacik break; 562d09d8df3SJosef Bacik old = cur; 563d09d8df3SJosef Bacik } 564d09d8df3SJosef Bacik 565d09d8df3SJosef Bacik if (old == 0) 566d09d8df3SJosef Bacik return 0; 567d09d8df3SJosef Bacik if (old == 1) 568d09d8df3SJosef Bacik atomic_dec(&blkg->blkcg->css.cgroup->congestion_count); 569d09d8df3SJosef Bacik return 1; 570d09d8df3SJosef Bacik } 571d09d8df3SJosef Bacik 57254c52e10STejun Heo /** 57354c52e10STejun Heo * blkcg_set_delay - Enable allocator delay mechanism with the specified delay amount 57454c52e10STejun Heo * @blkg: target blkg 57554c52e10STejun Heo * @delay: delay duration in nsecs 57654c52e10STejun Heo * 57754c52e10STejun Heo * When enabled with this function, the delay is not decayed and must be 57854c52e10STejun Heo * explicitly cleared with blkcg_clear_delay(). Must not be mixed with 57954c52e10STejun Heo * blkcg_[un]use_delay() and blkcg_add_delay() usages. 58054c52e10STejun Heo */ 58154c52e10STejun Heo static inline void blkcg_set_delay(struct blkcg_gq *blkg, u64 delay) 58254c52e10STejun Heo { 58354c52e10STejun Heo int old = atomic_read(&blkg->use_delay); 58454c52e10STejun Heo 58554c52e10STejun Heo /* We only want 1 person setting the congestion count for this blkg. */ 58654c52e10STejun Heo if (!old && atomic_cmpxchg(&blkg->use_delay, old, -1) == old) 58754c52e10STejun Heo atomic_inc(&blkg->blkcg->css.cgroup->congestion_count); 58854c52e10STejun Heo 58954c52e10STejun Heo atomic64_set(&blkg->delay_nsec, delay); 59054c52e10STejun Heo } 59154c52e10STejun Heo 59254c52e10STejun Heo /** 59354c52e10STejun Heo * blkcg_clear_delay - Disable allocator delay mechanism 59454c52e10STejun Heo * @blkg: target blkg 59554c52e10STejun Heo * 59654c52e10STejun Heo * Disable use_delay mechanism. See blkcg_set_delay(). 59754c52e10STejun Heo */ 598d09d8df3SJosef Bacik static inline void blkcg_clear_delay(struct blkcg_gq *blkg) 599d09d8df3SJosef Bacik { 600d09d8df3SJosef Bacik int old = atomic_read(&blkg->use_delay); 60154c52e10STejun Heo 602d09d8df3SJosef Bacik /* We only want 1 person clearing the congestion count for this blkg. */ 60354c52e10STejun Heo if (old && atomic_cmpxchg(&blkg->use_delay, old, 0) == old) 604d09d8df3SJosef Bacik atomic_dec(&blkg->blkcg->css.cgroup->congestion_count); 605d09d8df3SJosef Bacik } 606d09d8df3SJosef Bacik 607db18a53eSChristoph Hellwig void blk_cgroup_bio_start(struct bio *bio); 608d09d8df3SJosef Bacik void blkcg_add_delay(struct blkcg_gq *blkg, u64 now, u64 delta); 609d09d8df3SJosef Bacik void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay); 610d09d8df3SJosef Bacik void blkcg_maybe_throttle_current(void); 611eea8f41cSTejun Heo #else /* CONFIG_BLK_CGROUP */ 612eea8f41cSTejun Heo 613efa7d1c7STejun Heo struct blkcg { 614efa7d1c7STejun Heo }; 615eea8f41cSTejun Heo 616eea8f41cSTejun Heo struct blkg_policy_data { 617eea8f41cSTejun Heo }; 618eea8f41cSTejun Heo 619e4bc13adSLinus Torvalds struct blkcg_policy_data { 620e4bc13adSLinus Torvalds }; 621e4bc13adSLinus Torvalds 622eea8f41cSTejun Heo struct blkcg_gq { 623eea8f41cSTejun Heo }; 624eea8f41cSTejun Heo 625eea8f41cSTejun Heo struct blkcg_policy { 626eea8f41cSTejun Heo }; 627eea8f41cSTejun Heo 628496d5e75STejun Heo #define blkcg_root_css ((struct cgroup_subsys_state *)ERR_PTR(-EINVAL)) 629496d5e75STejun Heo 630d09d8df3SJosef Bacik static inline void blkcg_maybe_throttle_current(void) { } 631d09d8df3SJosef Bacik static inline bool blk_cgroup_congested(void) { return false; } 632d09d8df3SJosef Bacik 633efa7d1c7STejun Heo #ifdef CONFIG_BLOCK 634efa7d1c7STejun Heo 635d09d8df3SJosef Bacik static inline void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay) { } 636d09d8df3SJosef Bacik 637eea8f41cSTejun Heo static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; } 638b86d865cSBart Van Assche static inline struct blkcg_gq *blk_queue_root_blkg(struct request_queue *q) 639b86d865cSBart Van Assche { return NULL; } 640eea8f41cSTejun Heo static inline int blkcg_init_queue(struct request_queue *q) { return 0; } 641eea8f41cSTejun Heo static inline void blkcg_exit_queue(struct request_queue *q) { } 642eea8f41cSTejun Heo static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; } 643eea8f41cSTejun Heo static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { } 644eea8f41cSTejun Heo static inline int blkcg_activate_policy(struct request_queue *q, 645eea8f41cSTejun Heo const struct blkcg_policy *pol) { return 0; } 646eea8f41cSTejun Heo static inline void blkcg_deactivate_policy(struct request_queue *q, 647eea8f41cSTejun Heo const struct blkcg_policy *pol) { } 648eea8f41cSTejun Heo 6490fe061b9SDennis Zhou static inline struct blkcg *__bio_blkcg(struct bio *bio) { return NULL; } 650eea8f41cSTejun Heo static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; } 651eea8f41cSTejun Heo 652eea8f41cSTejun Heo static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg, 653eea8f41cSTejun Heo struct blkcg_policy *pol) { return NULL; } 654eea8f41cSTejun Heo static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd) { return NULL; } 655eea8f41cSTejun Heo static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; } 656eea8f41cSTejun Heo static inline void blkg_get(struct blkcg_gq *blkg) { } 657eea8f41cSTejun Heo static inline void blkg_put(struct blkcg_gq *blkg) { } 658eea8f41cSTejun Heo 659d3f77dfdSTejun Heo static inline bool blkcg_punt_bio_submit(struct bio *bio) { return false; } 660e439bedfSDennis Zhou static inline void blkcg_bio_issue_init(struct bio *bio) { } 661db18a53eSChristoph Hellwig static inline void blk_cgroup_bio_start(struct bio *bio) { } 662ae118896STejun Heo 663eea8f41cSTejun Heo #define blk_queue_for_each_rl(rl, q) \ 664eea8f41cSTejun Heo for ((rl) = &(q)->root_rl; (rl); (rl) = NULL) 665eea8f41cSTejun Heo 666efa7d1c7STejun Heo #endif /* CONFIG_BLOCK */ 667eea8f41cSTejun Heo #endif /* CONFIG_BLK_CGROUP */ 668*d2bcbeabSMuneendra Kumar 669*d2bcbeabSMuneendra Kumar #ifdef CONFIG_BLK_CGROUP_FC_APPID 670*d2bcbeabSMuneendra Kumar /* 671*d2bcbeabSMuneendra Kumar * Sets the fc_app_id field associted to blkcg 672*d2bcbeabSMuneendra Kumar * @app_id: application identifier 673*d2bcbeabSMuneendra Kumar * @cgrp_id: cgroup id 674*d2bcbeabSMuneendra Kumar * @app_id_len: size of application identifier 675*d2bcbeabSMuneendra Kumar */ 676*d2bcbeabSMuneendra Kumar static inline int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len) 677*d2bcbeabSMuneendra Kumar { 678*d2bcbeabSMuneendra Kumar struct cgroup *cgrp; 679*d2bcbeabSMuneendra Kumar struct cgroup_subsys_state *css; 680*d2bcbeabSMuneendra Kumar struct blkcg *blkcg; 681*d2bcbeabSMuneendra Kumar int ret = 0; 682*d2bcbeabSMuneendra Kumar 683*d2bcbeabSMuneendra Kumar if (app_id_len > FC_APPID_LEN) 684*d2bcbeabSMuneendra Kumar return -EINVAL; 685*d2bcbeabSMuneendra Kumar 686*d2bcbeabSMuneendra Kumar cgrp = cgroup_get_from_id(cgrp_id); 687*d2bcbeabSMuneendra Kumar if (!cgrp) 688*d2bcbeabSMuneendra Kumar return -ENOENT; 689*d2bcbeabSMuneendra Kumar css = cgroup_get_e_css(cgrp, &io_cgrp_subsys); 690*d2bcbeabSMuneendra Kumar if (!css) { 691*d2bcbeabSMuneendra Kumar ret = -ENOENT; 692*d2bcbeabSMuneendra Kumar goto out_cgrp_put; 693*d2bcbeabSMuneendra Kumar } 694*d2bcbeabSMuneendra Kumar blkcg = css_to_blkcg(css); 695*d2bcbeabSMuneendra Kumar /* 696*d2bcbeabSMuneendra Kumar * There is a slight race condition on setting the appid. 697*d2bcbeabSMuneendra Kumar * Worst case an I/O may not find the right id. 698*d2bcbeabSMuneendra Kumar * This is no different from the I/O we let pass while obtaining 699*d2bcbeabSMuneendra Kumar * the vmid from the fabric. 700*d2bcbeabSMuneendra Kumar * Adding the overhead of a lock is not necessary. 701*d2bcbeabSMuneendra Kumar */ 702*d2bcbeabSMuneendra Kumar strlcpy(blkcg->fc_app_id, app_id, app_id_len); 703*d2bcbeabSMuneendra Kumar css_put(css); 704*d2bcbeabSMuneendra Kumar out_cgrp_put: 705*d2bcbeabSMuneendra Kumar cgroup_put(cgrp); 706*d2bcbeabSMuneendra Kumar return ret; 707*d2bcbeabSMuneendra Kumar } 708*d2bcbeabSMuneendra Kumar 709*d2bcbeabSMuneendra Kumar /** 710*d2bcbeabSMuneendra Kumar * blkcg_get_fc_appid - get the fc app identifier associated with a bio 711*d2bcbeabSMuneendra Kumar * @bio: target bio 712*d2bcbeabSMuneendra Kumar * 713*d2bcbeabSMuneendra Kumar * On success return the fc_app_id, on failure return NULL 714*d2bcbeabSMuneendra Kumar */ 715*d2bcbeabSMuneendra Kumar static inline char *blkcg_get_fc_appid(struct bio *bio) 716*d2bcbeabSMuneendra Kumar { 717*d2bcbeabSMuneendra Kumar if (bio && bio->bi_blkg && 718*d2bcbeabSMuneendra Kumar (bio->bi_blkg->blkcg->fc_app_id[0] != '\0')) 719*d2bcbeabSMuneendra Kumar return bio->bi_blkg->blkcg->fc_app_id; 720*d2bcbeabSMuneendra Kumar return NULL; 721*d2bcbeabSMuneendra Kumar } 722*d2bcbeabSMuneendra Kumar #else 723*d2bcbeabSMuneendra Kumar static inline int blkcg_set_fc_appid(char *buf, u64 id, size_t len) { return -EINVAL; } 724*d2bcbeabSMuneendra Kumar static inline char *blkcg_get_fc_appid(struct bio *bio) { return NULL; } 725*d2bcbeabSMuneendra Kumar #endif /*CONFIG_BLK_CGROUP_FC_APPID*/ 726eea8f41cSTejun Heo #endif /* _BLK_CGROUP_H */ 727