Lines Matching refs:wb
50 struct bdi_writeback *wb = &bdi->wb; in bdi_debug_stats_show() local
58 spin_lock(&wb->list_lock); in bdi_debug_stats_show()
59 list_for_each_entry(inode, &wb->b_dirty, i_io_list) in bdi_debug_stats_show()
61 list_for_each_entry(inode, &wb->b_io, i_io_list) in bdi_debug_stats_show()
63 list_for_each_entry(inode, &wb->b_more_io, i_io_list) in bdi_debug_stats_show()
65 list_for_each_entry(inode, &wb->b_dirty_time, i_io_list) in bdi_debug_stats_show()
68 spin_unlock(&wb->list_lock); in bdi_debug_stats_show()
71 wb_thresh = wb_calc_thresh(wb, dirty_thresh); in bdi_debug_stats_show()
89 (unsigned long) K(wb_stat(wb, WB_WRITEBACK)), in bdi_debug_stats_show()
90 (unsigned long) K(wb_stat(wb, WB_RECLAIMABLE)), in bdi_debug_stats_show()
94 (unsigned long) K(wb_stat(wb, WB_DIRTIED)), in bdi_debug_stats_show()
95 (unsigned long) K(wb_stat(wb, WB_WRITTEN)), in bdi_debug_stats_show()
96 (unsigned long) K(wb->write_bandwidth), in bdi_debug_stats_show()
101 !list_empty(&bdi->bdi_list), bdi->wb.state); in bdi_debug_stats_show()
274 void wb_wakeup_delayed(struct bdi_writeback *wb) in wb_wakeup_delayed() argument
279 spin_lock_bh(&wb->work_lock); in wb_wakeup_delayed()
280 if (test_bit(WB_registered, &wb->state)) in wb_wakeup_delayed()
281 queue_delayed_work(bdi_wq, &wb->dwork, timeout); in wb_wakeup_delayed()
282 spin_unlock_bh(&wb->work_lock); in wb_wakeup_delayed()
290 static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, in wb_init() argument
295 memset(wb, 0, sizeof(*wb)); in wb_init()
297 wb->bdi = bdi; in wb_init()
298 wb->last_old_flush = jiffies; in wb_init()
299 INIT_LIST_HEAD(&wb->b_dirty); in wb_init()
300 INIT_LIST_HEAD(&wb->b_io); in wb_init()
301 INIT_LIST_HEAD(&wb->b_more_io); in wb_init()
302 INIT_LIST_HEAD(&wb->b_dirty_time); in wb_init()
303 spin_lock_init(&wb->list_lock); in wb_init()
305 wb->bw_time_stamp = jiffies; in wb_init()
306 wb->balanced_dirty_ratelimit = INIT_BW; in wb_init()
307 wb->dirty_ratelimit = INIT_BW; in wb_init()
308 wb->write_bandwidth = INIT_BW; in wb_init()
309 wb->avg_write_bandwidth = INIT_BW; in wb_init()
311 spin_lock_init(&wb->work_lock); in wb_init()
312 INIT_LIST_HEAD(&wb->work_list); in wb_init()
313 INIT_DELAYED_WORK(&wb->dwork, wb_workfn); in wb_init()
315 wb->congested = wb_congested_get_create(bdi, blkcg_id, gfp); in wb_init()
316 if (!wb->congested) in wb_init()
319 err = fprop_local_init_percpu(&wb->completions, gfp); in wb_init()
324 err = percpu_counter_init(&wb->stat[i], 0, gfp); in wb_init()
333 percpu_counter_destroy(&wb->stat[i]); in wb_init()
334 fprop_local_destroy_percpu(&wb->completions); in wb_init()
336 wb_congested_put(wb->congested); in wb_init()
343 static void wb_shutdown(struct bdi_writeback *wb) in wb_shutdown() argument
346 spin_lock_bh(&wb->work_lock); in wb_shutdown()
347 if (!test_and_clear_bit(WB_registered, &wb->state)) { in wb_shutdown()
348 spin_unlock_bh(&wb->work_lock); in wb_shutdown()
351 spin_unlock_bh(&wb->work_lock); in wb_shutdown()
358 mod_delayed_work(bdi_wq, &wb->dwork, 0); in wb_shutdown()
359 flush_delayed_work(&wb->dwork); in wb_shutdown()
360 WARN_ON(!list_empty(&wb->work_list)); in wb_shutdown()
363 static void wb_exit(struct bdi_writeback *wb) in wb_exit() argument
367 WARN_ON(delayed_work_pending(&wb->dwork)); in wb_exit()
370 percpu_counter_destroy(&wb->stat[i]); in wb_exit()
372 fprop_local_destroy_percpu(&wb->completions); in wb_exit()
373 wb_congested_put(wb->congested); in wb_exit()
480 struct bdi_writeback *wb = container_of(work, struct bdi_writeback, in cgwb_release_workfn() local
482 struct backing_dev_info *bdi = wb->bdi; in cgwb_release_workfn()
485 list_del_rcu(&wb->bdi_node); in cgwb_release_workfn()
488 wb_shutdown(wb); in cgwb_release_workfn()
490 css_put(wb->memcg_css); in cgwb_release_workfn()
491 css_put(wb->blkcg_css); in cgwb_release_workfn()
493 fprop_local_destroy_percpu(&wb->memcg_completions); in cgwb_release_workfn()
494 percpu_ref_exit(&wb->refcnt); in cgwb_release_workfn()
495 wb_exit(wb); in cgwb_release_workfn()
496 kfree_rcu(wb, rcu); in cgwb_release_workfn()
504 struct bdi_writeback *wb = container_of(refcnt, struct bdi_writeback, in cgwb_release() local
506 schedule_work(&wb->release_work); in cgwb_release()
509 static void cgwb_kill(struct bdi_writeback *wb) in cgwb_kill() argument
513 WARN_ON(!radix_tree_delete(&wb->bdi->cgwb_tree, wb->memcg_css->id)); in cgwb_kill()
514 list_del(&wb->memcg_node); in cgwb_kill()
515 list_del(&wb->blkcg_node); in cgwb_kill()
516 percpu_ref_kill(&wb->refcnt); in cgwb_kill()
526 struct bdi_writeback *wb; in cgwb_create() local
538 wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id); in cgwb_create()
539 if (wb && wb->blkcg_css != blkcg_css) { in cgwb_create()
540 cgwb_kill(wb); in cgwb_create()
541 wb = NULL; in cgwb_create()
544 if (wb) in cgwb_create()
548 wb = kmalloc(sizeof(*wb), gfp); in cgwb_create()
549 if (!wb) in cgwb_create()
552 ret = wb_init(wb, bdi, blkcg_css->id, gfp); in cgwb_create()
556 ret = percpu_ref_init(&wb->refcnt, cgwb_release, 0, gfp); in cgwb_create()
560 ret = fprop_local_init_percpu(&wb->memcg_completions, gfp); in cgwb_create()
564 wb->memcg_css = memcg_css; in cgwb_create()
565 wb->blkcg_css = blkcg_css; in cgwb_create()
566 INIT_WORK(&wb->release_work, cgwb_release_workfn); in cgwb_create()
567 set_bit(WB_registered, &wb->state); in cgwb_create()
577 if (test_bit(WB_registered, &bdi->wb.state) && in cgwb_create()
580 ret = radix_tree_insert(&bdi->cgwb_tree, memcg_css->id, wb); in cgwb_create()
583 list_add_tail_rcu(&wb->bdi_node, &bdi->wb_list); in cgwb_create()
584 list_add(&wb->memcg_node, memcg_cgwb_list); in cgwb_create()
585 list_add(&wb->blkcg_node, blkcg_cgwb_list); in cgwb_create()
599 fprop_local_destroy_percpu(&wb->memcg_completions); in cgwb_create()
601 percpu_ref_exit(&wb->refcnt); in cgwb_create()
603 wb_exit(wb); in cgwb_create()
605 kfree(wb); in cgwb_create()
639 struct bdi_writeback *wb; in wb_get_create() local
644 return &bdi->wb; in wb_get_create()
648 wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id); in wb_get_create()
649 if (wb) { in wb_get_create()
655 if (unlikely(wb->blkcg_css != blkcg_css || in wb_get_create()
656 !wb_tryget(wb))) in wb_get_create()
657 wb = NULL; in wb_get_create()
661 } while (!wb && !cgwb_create(bdi, memcg_css, gfp)); in wb_get_create()
663 return wb; in wb_get_create()
675 ret = wb_init(&bdi->wb, bdi, 1, GFP_KERNEL); in cgwb_bdi_init()
677 bdi->wb.memcg_css = mem_cgroup_root_css; in cgwb_bdi_init()
678 bdi->wb.blkcg_css = blkcg_root_css; in cgwb_bdi_init()
689 WARN_ON(test_bit(WB_registered, &bdi->wb.state)); in cgwb_bdi_destroy()
725 struct bdi_writeback *wb, *next; in wb_memcg_offline() local
728 list_for_each_entry_safe(wb, next, memcg_cgwb_list, memcg_node) in wb_memcg_offline()
729 cgwb_kill(wb); in wb_memcg_offline()
743 struct bdi_writeback *wb, *next; in wb_blkcg_offline() local
746 list_for_each_entry_safe(wb, next, &blkcg->cgwb_list, blkcg_node) in wb_blkcg_offline()
747 cgwb_kill(wb); in wb_blkcg_offline()
764 err = wb_init(&bdi->wb, bdi, 1, GFP_KERNEL); in cgwb_bdi_init()
794 list_add_tail_rcu(&bdi->wb.bdi_node, &bdi->wb_list); in bdi_init()
818 set_bit(WB_registered, &bdi->wb.state); in bdi_register()
865 wb_shutdown(&bdi->wb); in bdi_unregister()
890 wb_exit(&bdi->wb); in bdi_exit()