Lines Matching refs:bdi
52 struct backing_dev_info *bdi = m->private; in bdi_debug_stats_show() local
53 struct bdi_writeback *wb = &bdi->wb; in bdi_debug_stats_show()
103 !list_empty(&bdi->bdi_list), bdi->wb.state); in bdi_debug_stats_show()
109 static void bdi_debug_register(struct backing_dev_info *bdi, const char *name) in bdi_debug_register() argument
111 bdi->debug_dir = debugfs_create_dir(name, bdi_debug_root); in bdi_debug_register()
113 debugfs_create_file("stats", 0444, bdi->debug_dir, bdi, in bdi_debug_register()
117 static void bdi_debug_unregister(struct backing_dev_info *bdi) in bdi_debug_unregister() argument
119 debugfs_remove_recursive(bdi->debug_dir); in bdi_debug_unregister()
125 static inline void bdi_debug_register(struct backing_dev_info *bdi, in bdi_debug_register() argument
129 static inline void bdi_debug_unregister(struct backing_dev_info *bdi) in bdi_debug_unregister() argument
138 struct backing_dev_info *bdi = dev_get_drvdata(dev); in read_ahead_kb_store() local
146 bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10); in read_ahead_kb_store()
155 struct backing_dev_info *bdi = dev_get_drvdata(dev); \
161 BDI_SHOW(read_ahead_kb, K(bdi->ra_pages))
166 struct backing_dev_info *bdi = dev_get_drvdata(dev); in min_ratio_store() local
174 ret = bdi_set_min_ratio(bdi, ratio); in min_ratio_store()
180 BDI_SHOW(min_ratio, bdi->min_ratio)
185 struct backing_dev_info *bdi = dev_get_drvdata(dev); in max_ratio_store() local
193 ret = bdi_set_max_ratio(bdi, ratio); in max_ratio_store()
199 BDI_SHOW(max_ratio, bdi->max_ratio)
233 static int bdi_init(struct backing_dev_info *bdi);
288 static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, in wb_init() argument
295 wb->bdi = bdi; in wb_init()
394 struct backing_dev_info *bdi = wb->bdi; in cgwb_release_workfn() local
396 mutex_lock(&wb->bdi->cgwb_release_mutex); in cgwb_release_workfn()
401 mutex_unlock(&wb->bdi->cgwb_release_mutex); in cgwb_release_workfn()
414 bdi_put(bdi); in cgwb_release_workfn()
430 WARN_ON(!radix_tree_delete(&wb->bdi->cgwb_tree, wb->memcg_css->id)); in cgwb_kill()
444 static int cgwb_create(struct backing_dev_info *bdi, in cgwb_create() argument
463 wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id); in cgwb_create()
479 ret = wb_init(wb, bdi, gfp); in cgwb_create()
496 bdi_get(bdi); in cgwb_create()
506 if (test_bit(WB_registered, &bdi->wb.state) && in cgwb_create()
509 ret = radix_tree_insert(&bdi->cgwb_tree, memcg_css->id, wb); in cgwb_create()
511 list_add_tail_rcu(&wb->bdi_node, &bdi->wb_list); in cgwb_create()
528 bdi_put(bdi); in cgwb_create()
564 struct bdi_writeback *wb_get_lookup(struct backing_dev_info *bdi, in wb_get_lookup() argument
570 return &bdi->wb; in wb_get_lookup()
573 wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id); in wb_get_lookup()
597 struct bdi_writeback *wb_get_create(struct backing_dev_info *bdi, in wb_get_create() argument
606 return &bdi->wb; in wb_get_create()
609 wb = wb_get_lookup(bdi, memcg_css); in wb_get_create()
610 } while (!wb && !cgwb_create(bdi, memcg_css, gfp)); in wb_get_create()
615 static int cgwb_bdi_init(struct backing_dev_info *bdi) in cgwb_bdi_init() argument
619 INIT_RADIX_TREE(&bdi->cgwb_tree, GFP_ATOMIC); in cgwb_bdi_init()
620 mutex_init(&bdi->cgwb_release_mutex); in cgwb_bdi_init()
621 init_rwsem(&bdi->wb_switch_rwsem); in cgwb_bdi_init()
623 ret = wb_init(&bdi->wb, bdi, GFP_KERNEL); in cgwb_bdi_init()
625 bdi->wb.memcg_css = &root_mem_cgroup->css; in cgwb_bdi_init()
626 bdi->wb.blkcg_css = blkcg_root_css; in cgwb_bdi_init()
631 static void cgwb_bdi_unregister(struct backing_dev_info *bdi) in cgwb_bdi_unregister() argument
637 WARN_ON(test_bit(WB_registered, &bdi->wb.state)); in cgwb_bdi_unregister()
640 radix_tree_for_each_slot(slot, &bdi->cgwb_tree, &iter, 0) in cgwb_bdi_unregister()
644 mutex_lock(&bdi->cgwb_release_mutex); in cgwb_bdi_unregister()
646 while (!list_empty(&bdi->wb_list)) { in cgwb_bdi_unregister()
647 wb = list_first_entry(&bdi->wb_list, struct bdi_writeback, in cgwb_bdi_unregister()
654 mutex_unlock(&bdi->cgwb_release_mutex); in cgwb_bdi_unregister()
742 static void cgwb_bdi_register(struct backing_dev_info *bdi) in cgwb_bdi_register() argument
745 list_add_tail_rcu(&bdi->wb.bdi_node, &bdi->wb_list); in cgwb_bdi_register()
766 static int cgwb_bdi_init(struct backing_dev_info *bdi) in cgwb_bdi_init() argument
768 return wb_init(&bdi->wb, bdi, GFP_KERNEL); in cgwb_bdi_init()
771 static void cgwb_bdi_unregister(struct backing_dev_info *bdi) { } in cgwb_bdi_unregister() argument
773 static void cgwb_bdi_register(struct backing_dev_info *bdi) in cgwb_bdi_register() argument
775 list_add_tail_rcu(&bdi->wb.bdi_node, &bdi->wb_list); in cgwb_bdi_register()
785 static int bdi_init(struct backing_dev_info *bdi) in bdi_init() argument
789 bdi->dev = NULL; in bdi_init()
791 kref_init(&bdi->refcnt); in bdi_init()
792 bdi->min_ratio = 0; in bdi_init()
793 bdi->max_ratio = 100; in bdi_init()
794 bdi->max_prop_frac = FPROP_FRAC_BASE; in bdi_init()
795 INIT_LIST_HEAD(&bdi->bdi_list); in bdi_init()
796 INIT_LIST_HEAD(&bdi->wb_list); in bdi_init()
797 init_waitqueue_head(&bdi->wb_waitq); in bdi_init()
799 ret = cgwb_bdi_init(bdi); in bdi_init()
806 struct backing_dev_info *bdi; in bdi_alloc() local
808 bdi = kzalloc_node(sizeof(*bdi), GFP_KERNEL, node_id); in bdi_alloc()
809 if (!bdi) in bdi_alloc()
812 if (bdi_init(bdi)) { in bdi_alloc()
813 kfree(bdi); in bdi_alloc()
816 bdi->capabilities = BDI_CAP_WRITEBACK | BDI_CAP_WRITEBACK_ACCT; in bdi_alloc()
817 bdi->ra_pages = VM_READAHEAD_PAGES; in bdi_alloc()
818 bdi->io_pages = VM_READAHEAD_PAGES; in bdi_alloc()
819 timer_setup(&bdi->laptop_mode_wb_timer, laptop_mode_timer_fn, 0); in bdi_alloc()
820 return bdi; in bdi_alloc()
828 struct backing_dev_info *bdi; in bdi_lookup_rb_node() local
834 bdi = rb_entry(parent, struct backing_dev_info, rb_node); in bdi_lookup_rb_node()
836 if (bdi->id > id) in bdi_lookup_rb_node()
838 else if (bdi->id < id) in bdi_lookup_rb_node()
858 struct backing_dev_info *bdi = NULL; in bdi_get_by_id() local
864 bdi = rb_entry(*p, struct backing_dev_info, rb_node); in bdi_get_by_id()
865 bdi_get(bdi); in bdi_get_by_id()
869 return bdi; in bdi_get_by_id()
872 int bdi_register_va(struct backing_dev_info *bdi, const char *fmt, va_list args) in bdi_register_va() argument
877 if (bdi->dev) /* The driver needs to use separate queues per device */ in bdi_register_va()
880 vsnprintf(bdi->dev_name, sizeof(bdi->dev_name), fmt, args); in bdi_register_va()
881 dev = device_create(bdi_class, NULL, MKDEV(0, 0), bdi, bdi->dev_name); in bdi_register_va()
885 cgwb_bdi_register(bdi); in bdi_register_va()
886 bdi->dev = dev; in bdi_register_va()
888 bdi_debug_register(bdi, dev_name(dev)); in bdi_register_va()
889 set_bit(WB_registered, &bdi->wb.state); in bdi_register_va()
893 bdi->id = ++bdi_id_cursor; in bdi_register_va()
895 p = bdi_lookup_rb_node(bdi->id, &parent); in bdi_register_va()
896 rb_link_node(&bdi->rb_node, parent, p); in bdi_register_va()
897 rb_insert_color(&bdi->rb_node, &bdi_tree); in bdi_register_va()
899 list_add_tail_rcu(&bdi->bdi_list, &bdi_list); in bdi_register_va()
903 trace_writeback_bdi_register(bdi); in bdi_register_va()
907 int bdi_register(struct backing_dev_info *bdi, const char *fmt, ...) in bdi_register() argument
913 ret = bdi_register_va(bdi, fmt, args); in bdi_register()
919 void bdi_set_owner(struct backing_dev_info *bdi, struct device *owner) in bdi_set_owner() argument
921 WARN_ON_ONCE(bdi->owner); in bdi_set_owner()
922 bdi->owner = owner; in bdi_set_owner()
929 static void bdi_remove_from_list(struct backing_dev_info *bdi) in bdi_remove_from_list() argument
932 rb_erase(&bdi->rb_node, &bdi_tree); in bdi_remove_from_list()
933 list_del_rcu(&bdi->bdi_list); in bdi_remove_from_list()
939 void bdi_unregister(struct backing_dev_info *bdi) in bdi_unregister() argument
941 del_timer_sync(&bdi->laptop_mode_wb_timer); in bdi_unregister()
944 bdi_remove_from_list(bdi); in bdi_unregister()
945 wb_shutdown(&bdi->wb); in bdi_unregister()
946 cgwb_bdi_unregister(bdi); in bdi_unregister()
952 if (bdi->min_ratio) in bdi_unregister()
953 bdi_set_min_ratio(bdi, 0); in bdi_unregister()
955 if (bdi->dev) { in bdi_unregister()
956 bdi_debug_unregister(bdi); in bdi_unregister()
957 device_unregister(bdi->dev); in bdi_unregister()
958 bdi->dev = NULL; in bdi_unregister()
961 if (bdi->owner) { in bdi_unregister()
962 put_device(bdi->owner); in bdi_unregister()
963 bdi->owner = NULL; in bdi_unregister()
970 struct backing_dev_info *bdi = in release_bdi() local
973 WARN_ON_ONCE(test_bit(WB_registered, &bdi->wb.state)); in release_bdi()
974 WARN_ON_ONCE(bdi->dev); in release_bdi()
975 wb_exit(&bdi->wb); in release_bdi()
976 kfree(bdi); in release_bdi()
979 void bdi_put(struct backing_dev_info *bdi) in bdi_put() argument
981 kref_put(&bdi->refcnt, release_bdi); in bdi_put()
995 return I_BDEV(inode)->bd_disk->bdi; in inode_to_bdi()
1001 const char *bdi_dev_name(struct backing_dev_info *bdi) in bdi_dev_name() argument
1003 if (!bdi || !bdi->dev) in bdi_dev_name()
1005 return bdi->dev_name; in bdi_dev_name()
1015 void clear_bdi_congested(struct backing_dev_info *bdi, int sync) in clear_bdi_congested() argument
1021 if (test_and_clear_bit(bit, &bdi->wb.congested)) in clear_bdi_congested()
1029 void set_bdi_congested(struct backing_dev_info *bdi, int sync) in set_bdi_congested() argument
1034 if (!test_and_set_bit(bit, &bdi->wb.congested)) in set_bdi_congested()