diff options
Diffstat (limited to 'include/linux/backing-dev.h')
| -rw-r--r-- | include/linux/backing-dev.h | 69 |
1 files changed, 5 insertions, 64 deletions
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index d5eb4ad1c534..c85f74946a8b 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h | |||
| @@ -19,13 +19,17 @@ | |||
| 19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
| 20 | 20 | ||
| 21 | int __must_check bdi_init(struct backing_dev_info *bdi); | 21 | int __must_check bdi_init(struct backing_dev_info *bdi); |
| 22 | void bdi_destroy(struct backing_dev_info *bdi); | 22 | void bdi_exit(struct backing_dev_info *bdi); |
| 23 | 23 | ||
| 24 | __printf(3, 4) | 24 | __printf(3, 4) |
| 25 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, | 25 | int bdi_register(struct backing_dev_info *bdi, struct device *parent, |
| 26 | const char *fmt, ...); | 26 | const char *fmt, ...); |
| 27 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); | 27 | int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); |
| 28 | void bdi_unregister(struct backing_dev_info *bdi); | ||
| 29 | |||
| 28 | int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); | 30 | int __must_check bdi_setup_and_register(struct backing_dev_info *, char *); |
| 31 | void bdi_destroy(struct backing_dev_info *bdi); | ||
| 32 | |||
| 29 | void wb_start_writeback(struct bdi_writeback *wb, long nr_pages, | 33 | void wb_start_writeback(struct bdi_writeback *wb, long nr_pages, |
| 30 | bool range_cyclic, enum wb_reason reason); | 34 | bool range_cyclic, enum wb_reason reason); |
| 31 | void wb_start_background_writeback(struct bdi_writeback *wb); | 35 | void wb_start_background_writeback(struct bdi_writeback *wb); |
| @@ -408,61 +412,6 @@ static inline void unlocked_inode_to_wb_end(struct inode *inode, bool locked) | |||
| 408 | rcu_read_unlock(); | 412 | rcu_read_unlock(); |
| 409 | } | 413 | } |
| 410 | 414 | ||
| 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 */ | 415 | #else /* CONFIG_CGROUP_WRITEBACK */ |
| 467 | 416 | ||
| 468 | static inline bool inode_cgwb_enabled(struct inode *inode) | 417 | static inline bool inode_cgwb_enabled(struct inode *inode) |
| @@ -522,14 +471,6 @@ static inline void wb_blkcg_offline(struct blkcg *blkcg) | |||
| 522 | { | 471 | { |
| 523 | } | 472 | } |
| 524 | 473 | ||
| 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) | 474 | static inline int inode_congested(struct inode *inode, int cong_bits) |
| 534 | { | 475 | { |
| 535 | return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); | 476 | return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); |
