blk-cgroup.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. #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. #include <linux/cgroup.h>
  16. #include <linux/u64_stats_sync.h>
  17. #include <linux/seq_file.h>
  18. #include <linux/radix-tree.h>
  19. #include <linux/blkdev.h>
  20. #include <linux/atomic.h>
  21. /* Max limits for throttle policy */
  22. #define THROTL_IOPS_MAX UINT_MAX
  23. #ifdef CONFIG_BLK_CGROUP
  24. enum blkg_rwstat_type {
  25. BLKG_RWSTAT_READ,
  26. BLKG_RWSTAT_WRITE,
  27. BLKG_RWSTAT_SYNC,
  28. BLKG_RWSTAT_ASYNC,
  29. BLKG_RWSTAT_NR,
  30. BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR,
  31. };
  32. struct blkcg_gq;
  33. struct blkcg {
  34. struct cgroup_subsys_state css;
  35. spinlock_t lock;
  36. struct radix_tree_root blkg_tree;
  37. struct blkcg_gq *blkg_hint;
  38. struct hlist_head blkg_list;
  39. struct blkcg_policy_data *pd[BLKCG_MAX_POLS];
  40. struct list_head all_blkcgs_node;
  41. #ifdef CONFIG_CGROUP_WRITEBACK
  42. struct list_head cgwb_list;
  43. #endif
  44. };
  45. struct blkg_stat {
  46. struct u64_stats_sync syncp;
  47. uint64_t cnt;
  48. };
  49. struct blkg_rwstat {
  50. struct u64_stats_sync syncp;
  51. uint64_t cnt[BLKG_RWSTAT_NR];
  52. };
  53. /*
  54. * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a
  55. * request_queue (q). This is used by blkcg policies which need to track
  56. * information per blkcg - q pair.
  57. *
  58. * There can be multiple active blkcg policies and each has its private
  59. * data on each blkg, the size of which is determined by
  60. * blkcg_policy->pd_size. blkcg core allocates and frees such areas
  61. * together with blkg and invokes pd_init/exit_fn() methods.
  62. *
  63. * Such private data must embed struct blkg_policy_data (pd) at the
  64. * beginning and pd_size can't be smaller than pd.
  65. */
  66. struct blkg_policy_data {
  67. /* the blkg and policy id this per-policy data belongs to */
  68. struct blkcg_gq *blkg;
  69. int plid;
  70. /* used during policy activation */
  71. struct list_head alloc_node;
  72. };
  73. /*
  74. * Policies that need to keep per-blkcg data which is independent
  75. * from any request_queue associated to it must specify its size
  76. * with the cpd_size field of the blkcg_policy structure and
  77. * embed a blkcg_policy_data in it. blkcg core allocates
  78. * policy-specific per-blkcg structures lazily the first time
  79. * they are actually needed, so it handles them together with
  80. * blkgs. cpd_init() is invoked to let each policy handle
  81. * per-blkcg data.
  82. */
  83. struct blkcg_policy_data {
  84. /* the policy id this per-policy data belongs to */
  85. int plid;
  86. /* used during policy activation */
  87. struct list_head alloc_node;
  88. };
  89. /* association between a blk cgroup and a request queue */
  90. struct blkcg_gq {
  91. /* Pointer to the associated request_queue */
  92. struct request_queue *q;
  93. struct list_head q_node;
  94. struct hlist_node blkcg_node;
  95. struct blkcg *blkcg;
  96. /*
  97. * Each blkg gets congested separately and the congestion state is
  98. * propagated to the matching bdi_writeback_congested.
  99. */
  100. struct bdi_writeback_congested *wb_congested;
  101. /* all non-root blkcg_gq's are guaranteed to have access to parent */
  102. struct blkcg_gq *parent;
  103. /* request allocation list for this blkcg-q pair */
  104. struct request_list rl;
  105. /* reference count */
  106. atomic_t refcnt;
  107. /* is this blkg online? protected by both blkcg and q locks */
  108. bool online;
  109. struct blkg_policy_data *pd[BLKCG_MAX_POLS];
  110. struct rcu_head rcu_head;
  111. };
  112. typedef void (blkcg_pol_init_cpd_fn)(const struct blkcg *blkcg);
  113. typedef void (blkcg_pol_init_pd_fn)(struct blkcg_gq *blkg);
  114. typedef void (blkcg_pol_online_pd_fn)(struct blkcg_gq *blkg);
  115. typedef void (blkcg_pol_offline_pd_fn)(struct blkcg_gq *blkg);
  116. typedef void (blkcg_pol_exit_pd_fn)(struct blkcg_gq *blkg);
  117. typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkcg_gq *blkg);
  118. struct blkcg_policy {
  119. int plid;
  120. /* policy specific private data size */
  121. size_t pd_size;
  122. /* policy specific per-blkcg data size */
  123. size_t cpd_size;
  124. /* cgroup files for the policy */
  125. struct cftype *cftypes;
  126. /* operations */
  127. blkcg_pol_init_cpd_fn *cpd_init_fn;
  128. blkcg_pol_init_pd_fn *pd_init_fn;
  129. blkcg_pol_online_pd_fn *pd_online_fn;
  130. blkcg_pol_offline_pd_fn *pd_offline_fn;
  131. blkcg_pol_exit_pd_fn *pd_exit_fn;
  132. blkcg_pol_reset_pd_stats_fn *pd_reset_stats_fn;
  133. };
  134. extern struct blkcg blkcg_root;
  135. extern struct cgroup_subsys_state * const blkcg_root_css;
  136. struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, struct request_queue *q);
  137. struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
  138. struct request_queue *q);
  139. int blkcg_init_queue(struct request_queue *q);
  140. void blkcg_drain_queue(struct request_queue *q);
  141. void blkcg_exit_queue(struct request_queue *q);
  142. /* Blkio controller policy registration */
  143. int blkcg_policy_register(struct blkcg_policy *pol);
  144. void blkcg_policy_unregister(struct blkcg_policy *pol);
  145. int blkcg_activate_policy(struct request_queue *q,
  146. const struct blkcg_policy *pol);
  147. void blkcg_deactivate_policy(struct request_queue *q,
  148. const struct blkcg_policy *pol);
  149. void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
  150. u64 (*prfill)(struct seq_file *,
  151. struct blkg_policy_data *, int),
  152. const struct blkcg_policy *pol, int data,
  153. bool show_total);
  154. u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v);
  155. u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
  156. const struct blkg_rwstat *rwstat);
  157. u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off);
  158. u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
  159. int off);
  160. u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off);
  161. struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd,
  162. int off);
  163. struct blkg_conf_ctx {
  164. struct gendisk *disk;
  165. struct blkcg_gq *blkg;
  166. u64 v;
  167. };
  168. int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
  169. const char *input, struct blkg_conf_ctx *ctx);
  170. void blkg_conf_finish(struct blkg_conf_ctx *ctx);
  171. static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css)
  172. {
  173. return css ? container_of(css, struct blkcg, css) : NULL;
  174. }
  175. static inline struct blkcg *task_blkcg(struct task_struct *tsk)
  176. {
  177. return css_to_blkcg(task_css(tsk, blkio_cgrp_id));
  178. }
  179. static inline struct blkcg *bio_blkcg(struct bio *bio)
  180. {
  181. if (bio && bio->bi_css)
  182. return css_to_blkcg(bio->bi_css);
  183. return task_blkcg(current);
  184. }
  185. static inline struct cgroup_subsys_state *
  186. task_get_blkcg_css(struct task_struct *task)
  187. {
  188. return task_get_css(task, blkio_cgrp_id);
  189. }
  190. /**
  191. * blkcg_parent - get the parent of a blkcg
  192. * @blkcg: blkcg of interest
  193. *
  194. * Return the parent blkcg of @blkcg. Can be called anytime.
  195. */
  196. static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)
  197. {
  198. return css_to_blkcg(blkcg->css.parent);
  199. }
  200. /**
  201. * blkg_to_pdata - get policy private data
  202. * @blkg: blkg of interest
  203. * @pol: policy of interest
  204. *
  205. * Return pointer to private data associated with the @blkg-@pol pair.
  206. */
  207. static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
  208. struct blkcg_policy *pol)
  209. {
  210. return blkg ? blkg->pd[pol->plid] : NULL;
  211. }
  212. static inline struct blkcg_policy_data *blkcg_to_cpd(struct blkcg *blkcg,
  213. struct blkcg_policy *pol)
  214. {
  215. return blkcg ? blkcg->pd[pol->plid] : NULL;
  216. }
  217. /**
  218. * pdata_to_blkg - get blkg associated with policy private data
  219. * @pd: policy private data of interest
  220. *
  221. * @pd is policy private data. Determine the blkg it's associated with.
  222. */
  223. static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd)
  224. {
  225. return pd ? pd->blkg : NULL;
  226. }
  227. /**
  228. * blkg_path - format cgroup path of blkg
  229. * @blkg: blkg of interest
  230. * @buf: target buffer
  231. * @buflen: target buffer length
  232. *
  233. * Format the path of the cgroup of @blkg into @buf.
  234. */
  235. static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
  236. {
  237. char *p;
  238. p = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen);
  239. if (!p) {
  240. strncpy(buf, "<unavailable>", buflen);
  241. return -ENAMETOOLONG;
  242. }
  243. memmove(buf, p, buf + buflen - p);
  244. return 0;
  245. }
  246. /**
  247. * blkg_get - get a blkg reference
  248. * @blkg: blkg to get
  249. *
  250. * The caller should be holding an existing reference.
  251. */
  252. static inline void blkg_get(struct blkcg_gq *blkg)
  253. {
  254. WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
  255. atomic_inc(&blkg->refcnt);
  256. }
  257. void __blkg_release_rcu(struct rcu_head *rcu);
  258. /**
  259. * blkg_put - put a blkg reference
  260. * @blkg: blkg to put
  261. */
  262. static inline void blkg_put(struct blkcg_gq *blkg)
  263. {
  264. WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
  265. if (atomic_dec_and_test(&blkg->refcnt))
  266. call_rcu(&blkg->rcu_head, __blkg_release_rcu);
  267. }
  268. struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg, struct request_queue *q,
  269. bool update_hint);
  270. /**
  271. * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants
  272. * @d_blkg: loop cursor pointing to the current descendant
  273. * @pos_css: used for iteration
  274. * @p_blkg: target blkg to walk descendants of
  275. *
  276. * Walk @c_blkg through the descendants of @p_blkg. Must be used with RCU
  277. * read locked. If called under either blkcg or queue lock, the iteration
  278. * is guaranteed to include all and only online blkgs. The caller may
  279. * update @pos_css by calling css_rightmost_descendant() to skip subtree.
  280. * @p_blkg is included in the iteration and the first node to be visited.
  281. */
  282. #define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg) \
  283. css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css) \
  284. if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \
  285. (p_blkg)->q, false)))
  286. /**
  287. * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
  288. * @d_blkg: loop cursor pointing to the current descendant
  289. * @pos_css: used for iteration
  290. * @p_blkg: target blkg to walk descendants of
  291. *
  292. * Similar to blkg_for_each_descendant_pre() but performs post-order
  293. * traversal instead. Synchronization rules are the same. @p_blkg is
  294. * included in the iteration and the last node to be visited.
  295. */
  296. #define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg) \
  297. css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css) \
  298. if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \
  299. (p_blkg)->q, false)))
  300. /**
  301. * blk_get_rl - get request_list to use
  302. * @q: request_queue of interest
  303. * @bio: bio which will be attached to the allocated request (may be %NULL)
  304. *
  305. * The caller wants to allocate a request from @q to use for @bio. Find
  306. * the request_list to use and obtain a reference on it. Should be called
  307. * under queue_lock. This function is guaranteed to return non-%NULL
  308. * request_list.
  309. */
  310. static inline struct request_list *blk_get_rl(struct request_queue *q,
  311. struct bio *bio)
  312. {
  313. struct blkcg *blkcg;
  314. struct blkcg_gq *blkg;
  315. rcu_read_lock();
  316. blkcg = bio_blkcg(bio);
  317. /* bypass blkg lookup and use @q->root_rl directly for root */
  318. if (blkcg == &blkcg_root)
  319. goto root_rl;
  320. /*
  321. * Try to use blkg->rl. blkg lookup may fail under memory pressure
  322. * or if either the blkcg or queue is going away. Fall back to
  323. * root_rl in such cases.
  324. */
  325. blkg = blkg_lookup_create(blkcg, q);
  326. if (unlikely(IS_ERR(blkg)))
  327. goto root_rl;
  328. blkg_get(blkg);
  329. rcu_read_unlock();
  330. return &blkg->rl;
  331. root_rl:
  332. rcu_read_unlock();
  333. return &q->root_rl;
  334. }
  335. /**
  336. * blk_put_rl - put request_list
  337. * @rl: request_list to put
  338. *
  339. * Put the reference acquired by blk_get_rl(). Should be called under
  340. * queue_lock.
  341. */
  342. static inline void blk_put_rl(struct request_list *rl)
  343. {
  344. /* root_rl may not have blkg set */
  345. if (rl->blkg && rl->blkg->blkcg != &blkcg_root)
  346. blkg_put(rl->blkg);
  347. }
  348. /**
  349. * blk_rq_set_rl - associate a request with a request_list
  350. * @rq: request of interest
  351. * @rl: target request_list
  352. *
  353. * Associate @rq with @rl so that accounting and freeing can know the
  354. * request_list @rq came from.
  355. */
  356. static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl)
  357. {
  358. rq->rl = rl;
  359. }
  360. /**
  361. * blk_rq_rl - return the request_list a request came from
  362. * @rq: request of interest
  363. *
  364. * Return the request_list @rq is allocated from.
  365. */
  366. static inline struct request_list *blk_rq_rl(struct request *rq)
  367. {
  368. return rq->rl;
  369. }
  370. struct request_list *__blk_queue_next_rl(struct request_list *rl,
  371. struct request_queue *q);
  372. /**
  373. * blk_queue_for_each_rl - iterate through all request_lists of a request_queue
  374. *
  375. * Should be used under queue_lock.
  376. */
  377. #define blk_queue_for_each_rl(rl, q) \
  378. for ((rl) = &(q)->root_rl; (rl); (rl) = __blk_queue_next_rl((rl), (q)))
  379. static inline void blkg_stat_init(struct blkg_stat *stat)
  380. {
  381. u64_stats_init(&stat->syncp);
  382. }
  383. /**
  384. * blkg_stat_add - add a value to a blkg_stat
  385. * @stat: target blkg_stat
  386. * @val: value to add
  387. *
  388. * Add @val to @stat. The caller is responsible for synchronizing calls to
  389. * this function.
  390. */
  391. static inline void blkg_stat_add(struct blkg_stat *stat, uint64_t val)
  392. {
  393. u64_stats_update_begin(&stat->syncp);
  394. stat->cnt += val;
  395. u64_stats_update_end(&stat->syncp);
  396. }
  397. /**
  398. * blkg_stat_read - read the current value of a blkg_stat
  399. * @stat: blkg_stat to read
  400. *
  401. * Read the current value of @stat. This function can be called without
  402. * synchroniztion and takes care of u64 atomicity.
  403. */
  404. static inline uint64_t blkg_stat_read(struct blkg_stat *stat)
  405. {
  406. unsigned int start;
  407. uint64_t v;
  408. do {
  409. start = u64_stats_fetch_begin_irq(&stat->syncp);
  410. v = stat->cnt;
  411. } while (u64_stats_fetch_retry_irq(&stat->syncp, start));
  412. return v;
  413. }
  414. /**
  415. * blkg_stat_reset - reset a blkg_stat
  416. * @stat: blkg_stat to reset
  417. */
  418. static inline void blkg_stat_reset(struct blkg_stat *stat)
  419. {
  420. stat->cnt = 0;
  421. }
  422. /**
  423. * blkg_stat_merge - merge a blkg_stat into another
  424. * @to: the destination blkg_stat
  425. * @from: the source
  426. *
  427. * Add @from's count to @to.
  428. */
  429. static inline void blkg_stat_merge(struct blkg_stat *to, struct blkg_stat *from)
  430. {
  431. blkg_stat_add(to, blkg_stat_read(from));
  432. }
  433. static inline void blkg_rwstat_init(struct blkg_rwstat *rwstat)
  434. {
  435. u64_stats_init(&rwstat->syncp);
  436. }
  437. /**
  438. * blkg_rwstat_add - add a value to a blkg_rwstat
  439. * @rwstat: target blkg_rwstat
  440. * @rw: mask of REQ_{WRITE|SYNC}
  441. * @val: value to add
  442. *
  443. * Add @val to @rwstat. The counters are chosen according to @rw. The
  444. * caller is responsible for synchronizing calls to this function.
  445. */
  446. static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
  447. int rw, uint64_t val)
  448. {
  449. u64_stats_update_begin(&rwstat->syncp);
  450. if (rw & REQ_WRITE)
  451. rwstat->cnt[BLKG_RWSTAT_WRITE] += val;
  452. else
  453. rwstat->cnt[BLKG_RWSTAT_READ] += val;
  454. if (rw & REQ_SYNC)
  455. rwstat->cnt[BLKG_RWSTAT_SYNC] += val;
  456. else
  457. rwstat->cnt[BLKG_RWSTAT_ASYNC] += val;
  458. u64_stats_update_end(&rwstat->syncp);
  459. }
  460. /**
  461. * blkg_rwstat_read - read the current values of a blkg_rwstat
  462. * @rwstat: blkg_rwstat to read
  463. *
  464. * Read the current snapshot of @rwstat and return it as the return value.
  465. * This function can be called without synchronization and takes care of
  466. * u64 atomicity.
  467. */
  468. static inline struct blkg_rwstat blkg_rwstat_read(struct blkg_rwstat *rwstat)
  469. {
  470. unsigned int start;
  471. struct blkg_rwstat tmp;
  472. do {
  473. start = u64_stats_fetch_begin_irq(&rwstat->syncp);
  474. tmp = *rwstat;
  475. } while (u64_stats_fetch_retry_irq(&rwstat->syncp, start));
  476. return tmp;
  477. }
  478. /**
  479. * blkg_rwstat_total - read the total count of a blkg_rwstat
  480. * @rwstat: blkg_rwstat to read
  481. *
  482. * Return the total count of @rwstat regardless of the IO direction. This
  483. * function can be called without synchronization and takes care of u64
  484. * atomicity.
  485. */
  486. static inline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat)
  487. {
  488. struct blkg_rwstat tmp = blkg_rwstat_read(rwstat);
  489. return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE];
  490. }
  491. /**
  492. * blkg_rwstat_reset - reset a blkg_rwstat
  493. * @rwstat: blkg_rwstat to reset
  494. */
  495. static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
  496. {
  497. memset(rwstat->cnt, 0, sizeof(rwstat->cnt));
  498. }
  499. /**
  500. * blkg_rwstat_merge - merge a blkg_rwstat into another
  501. * @to: the destination blkg_rwstat
  502. * @from: the source
  503. *
  504. * Add @from's counts to @to.
  505. */
  506. static inline void blkg_rwstat_merge(struct blkg_rwstat *to,
  507. struct blkg_rwstat *from)
  508. {
  509. struct blkg_rwstat v = blkg_rwstat_read(from);
  510. int i;
  511. u64_stats_update_begin(&to->syncp);
  512. for (i = 0; i < BLKG_RWSTAT_NR; i++)
  513. to->cnt[i] += v.cnt[i];
  514. u64_stats_update_end(&to->syncp);
  515. }
  516. #else /* CONFIG_BLK_CGROUP */
  517. struct blkcg {
  518. };
  519. struct blkg_policy_data {
  520. };
  521. struct blkcg_policy_data {
  522. };
  523. struct blkcg_gq {
  524. };
  525. struct blkcg_policy {
  526. };
  527. #define blkcg_root_css ((struct cgroup_subsys_state *)ERR_PTR(-EINVAL))
  528. static inline struct cgroup_subsys_state *
  529. task_get_blkcg_css(struct task_struct *task)
  530. {
  531. return NULL;
  532. }
  533. #ifdef CONFIG_BLOCK
  534. static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; }
  535. static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
  536. static inline void blkcg_drain_queue(struct request_queue *q) { }
  537. static inline void blkcg_exit_queue(struct request_queue *q) { }
  538. static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; }
  539. static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { }
  540. static inline int blkcg_activate_policy(struct request_queue *q,
  541. const struct blkcg_policy *pol) { return 0; }
  542. static inline void blkcg_deactivate_policy(struct request_queue *q,
  543. const struct blkcg_policy *pol) { }
  544. static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; }
  545. static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
  546. struct blkcg_policy *pol) { return NULL; }
  547. static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd) { return NULL; }
  548. static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; }
  549. static inline void blkg_get(struct blkcg_gq *blkg) { }
  550. static inline void blkg_put(struct blkcg_gq *blkg) { }
  551. static inline struct request_list *blk_get_rl(struct request_queue *q,
  552. struct bio *bio) { return &q->root_rl; }
  553. static inline void blk_put_rl(struct request_list *rl) { }
  554. static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl) { }
  555. static inline struct request_list *blk_rq_rl(struct request *rq) { return &rq->q->root_rl; }
  556. #define blk_queue_for_each_rl(rl, q) \
  557. for ((rl) = &(q)->root_rl; (rl); (rl) = NULL)
  558. #endif /* CONFIG_BLOCK */
  559. #endif /* CONFIG_BLK_CGROUP */
  560. #endif /* _BLK_CGROUP_H */