diff options
Diffstat (limited to 'include/linux/backing-dev.h')
-rw-r--r-- | include/linux/backing-dev.h | 74 |
1 files changed, 7 insertions, 67 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index d5eb4ad1c534..c82794f20110 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
@@ -13,19 +13,22 @@ | |||
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/blkdev.h> | 14 | #include <linux/blkdev.h> |
15 | #include <linux/writeback.h> | 15 | #include <linux/writeback.h> |
16 | #include <linux/memcontrol.h> | ||
17 | #include <linux/blk-cgroup.h> | 16 | #include <linux/blk-cgroup.h> |
18 | #include <linux/backing-dev-defs.h> | 17 | #include <linux/backing-dev-defs.h> |
19 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
20 | 19 | ||
21 | int __must_check bdi_init(struct backing_dev_info *bdi); | 20 | int __must_check bdi_init(struct backing_dev_info *bdi); |
22 | void bdi_destroy(struct backing_dev_info *bdi); | 21 | void bdi_exit(struct backing_dev_info *bdi); |
23 | 22 | ||
24 | __printf(3, 4) | 23 | __printf(3, 4) |
25 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, | 24 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, |
26 | const char *fmt, ...); | 25 | const char *fmt, ...); |
27 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); | 26 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); |
27 | void bdi_unregister(struct backing_dev_info *bdi); | ||
28 | |||
28 | int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); | 29 | int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); |
30 | void bdi_destroy(struct backing_dev_info *bdi); | ||
31 | |||
29 | void wb_start_writeback(struct bdi_writeback *wb, long nr_pages, | 32 | void wb_start_writeback(struct bdi_writeback *wb, long nr_pages, |
30 | bool range_cyclic, enum wb_reason reason); | 33 | bool range_cyclic, enum wb_reason reason); |
31 | void wb_start_background_writeback(struct bdi_writeback *wb); | 34 | void wb_start_background_writeback(struct bdi_writeback *wb); |
@@ -263,8 +266,8 @@ static inline bool inode_cgwb_enabled(struct inode *inode) | |||
263 | { | 266 | { |
264 | struct backing_dev_info *bdi = inode_to_bdi(inode); | 267 | struct backing_dev_info *bdi = inode_to_bdi(inode); |
265 | 268 | ||
266 | return cgroup_on_dfl(mem_cgroup_root_css->cgroup) && | 269 | return cgroup_subsys_on_dfl(memory_cgrp_subsys) && |
267 | cgroup_on_dfl(blkcg_root_css->cgroup) && | 270 | cgroup_subsys_on_dfl(io_cgrp_subsys) && |
268 | bdi_cap_account_dirty(bdi) && | 271 | bdi_cap_account_dirty(bdi) && |
269 | (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) && | 272 | (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) && |
270 | (inode->i_sb->s_iflags & SB_I_CGROUPWB); | 273 | (inode->i_sb->s_iflags & SB_I_CGROUPWB); |
@@ -408,61 +411,6 @@ static inline void unlocked_inode_to_wb_end(struct inode *inode, bool locked) | |||
408 | rcu_read_unlock(); | 411 | rcu_read_unlock(); |
409 | } | 412 | } |
410 | 413 | ||
411 | struct wb_iter { | ||
412 | int start_memcg_id; | ||
413 | struct radix_tree_iter tree_iter; | ||
414 | void **slot; | ||
415 | }; | ||
416 | |||
417 | static inline struct bdi_writeback *__wb_iter_next(struct wb_iter *iter, | ||
418 | struct backing_dev_info *bdi) | ||
419 | { | ||
420 | struct radix_tree_iter *titer = &iter->tree_iter; | ||
421 | |||
422 | WARN_ON_ONCE(!rcu_read_lock_held()); | ||
423 | |||
424 | if (iter->start_memcg_id >= 0) { | ||
425 | iter->slot = radix_tree_iter_init(titer, iter->start_memcg_id); | ||
426 | iter->start_memcg_id = -1; | ||
427 | } else { | ||
428 | iter->slot = radix_tree_next_slot(iter->slot, titer, 0); | ||
429 | } | ||
430 | |||
431 | if (!iter->slot) | ||
432 | iter->slot = radix_tree_next_chunk(&bdi->cgwb_tree, titer, 0); | ||
433 | if (iter->slot) | ||
434 | return *iter->slot; | ||
435 | return NULL; | ||
436 | } | ||
437 | |||
438 | static inline struct bdi_writeback *__wb_iter_init(struct wb_iter *iter, | ||
439 | struct backing_dev_info *bdi, | ||
440 | int start_memcg_id) | ||
441 | { | ||
442 | iter->start_memcg_id = start_memcg_id; | ||
443 | |||
444 | if (start_memcg_id) | ||
445 | return __wb_iter_next(iter, bdi); | ||
446 | else | ||
447 | return &bdi->wb; | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * bdi_for_each_wb - walk all wb's of a bdi in ascending memcg ID order | ||
452 | * @wb_cur: cursor struct bdi_writeback pointer | ||
453 | * @bdi: bdi to walk wb's of | ||
454 | * @iter: pointer to struct wb_iter to be used as iteration buffer | ||
455 | * @start_memcg_id: memcg ID to start iteration from | ||
456 | * | ||
457 | * Iterate @wb_cur through the wb's (bdi_writeback's) of @bdi in ascending | ||
458 | * memcg ID order starting from @start_memcg_id. @iter is struct wb_iter | ||
459 | * to be used as temp storage during iteration. rcu_read_lock() must be | ||
460 | * held throughout iteration. | ||
461 | */ | ||
462 | #define bdi_for_each_wb(wb_cur, bdi, iter, start_memcg_id) \ | ||
463 | for ((wb_cur) = __wb_iter_init(iter, bdi, start_memcg_id); \ | ||
464 | (wb_cur); (wb_cur) = __wb_iter_next(iter, bdi)) | ||
465 | |||
466 | #else /* CONFIG_CGROUP_WRITEBACK */ | 414 | #else /* CONFIG_CGROUP_WRITEBACK */ |
467 | 415 | ||
468 | static inline bool inode_cgwb_enabled(struct inode *inode) | 416 | static inline bool inode_cgwb_enabled(struct inode *inode) |
@@ -522,14 +470,6 @@ static inline void wb_blkcg_offline(struct blkcg *blkcg) | |||
522 | { | 470 | { |
523 | } | 471 | } |
524 | 472 | ||
525 | struct wb_iter { | ||
526 | int next_id; | ||
527 | }; | ||
528 | |||
529 | #define bdi_for_each_wb(wb_cur, bdi, iter, start_blkcg_id) \ | ||
530 | for ((iter)->next_id = (start_blkcg_id); \ | ||
531 | ({ (wb_cur) = !(iter)->next_id++ ? &(bdi)->wb : NULL; }); ) | ||
532 | |||
533 | static inline int inode_congested(struct inode *inode, int cong_bits) | 473 | static inline int inode_congested(struct inode *inode, int cong_bits) |
534 | { | 474 | { |
535 | return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); | 475 | return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); |