Lines Matching refs:wb
49 struct bdi_writeback *wb = &bdi->wb;
57 spin_lock(&wb->list_lock);
58 list_for_each_entry(inode, &wb->b_dirty, i_io_list)
60 list_for_each_entry(inode, &wb->b_io, i_io_list)
62 list_for_each_entry(inode, &wb->b_more_io, i_io_list)
64 list_for_each_entry(inode, &wb->b_dirty_time, i_io_list)
67 spin_unlock(&wb->list_lock);
70 wb_thresh = wb_calc_thresh(wb, dirty_thresh);
88 (unsigned long) K(wb_stat(wb, WB_WRITEBACK)),
89 (unsigned long) K(wb_stat(wb, WB_RECLAIMABLE)),
93 (unsigned long) K(wb_stat(wb, WB_DIRTIED)),
94 (unsigned long) K(wb_stat(wb, WB_WRITTEN)),
95 (unsigned long) K(wb->write_bandwidth),
100 !list_empty(&bdi->bdi_list), bdi->wb.state);
251 * This function is used when the first inode for this wb is marked dirty. It
264 void wb_wakeup_delayed(struct bdi_writeback *wb)
269 spin_lock_bh(&wb->work_lock);
270 if (test_bit(WB_registered, &wb->state))
271 queue_delayed_work(bdi_wq, &wb->dwork, timeout);
272 spin_unlock_bh(&wb->work_lock);
280 static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
285 memset(wb, 0, sizeof(*wb));
287 if (wb != &bdi->wb)
289 wb->bdi = bdi;
290 wb->last_old_flush = jiffies;
291 INIT_LIST_HEAD(&wb->b_dirty);
292 INIT_LIST_HEAD(&wb->b_io);
293 INIT_LIST_HEAD(&wb->b_more_io);
294 INIT_LIST_HEAD(&wb->b_dirty_time);
295 spin_lock_init(&wb->list_lock);
297 wb->bw_time_stamp = jiffies;
298 wb->balanced_dirty_ratelimit = INIT_BW;
299 wb->dirty_ratelimit = INIT_BW;
300 wb->write_bandwidth = INIT_BW;
301 wb->avg_write_bandwidth = INIT_BW;
303 spin_lock_init(&wb->work_lock);
304 INIT_LIST_HEAD(&wb->work_list);
305 INIT_DELAYED_WORK(&wb->dwork, wb_workfn);
306 wb->dirty_sleep = jiffies;
308 err = fprop_local_init_percpu(&wb->completions, gfp);
313 err = percpu_counter_init(&wb->stat[i], 0, gfp);
322 percpu_counter_destroy(&wb->stat[i]);
323 fprop_local_destroy_percpu(&wb->completions);
325 if (wb != &bdi->wb)
330 static void cgwb_remove_from_bdi_list(struct bdi_writeback *wb);
335 static void wb_shutdown(struct bdi_writeback *wb)
338 spin_lock_bh(&wb->work_lock);
339 if (!test_and_clear_bit(WB_registered, &wb->state)) {
340 spin_unlock_bh(&wb->work_lock);
343 spin_unlock_bh(&wb->work_lock);
345 cgwb_remove_from_bdi_list(wb);
348 * tells wb_workfn() that @wb is dying and its work_list needs to
351 mod_delayed_work(bdi_wq, &wb->dwork, 0);
352 flush_delayed_work(&wb->dwork);
353 WARN_ON(!list_empty(&wb->work_list));
356 static void wb_exit(struct bdi_writeback *wb)
360 WARN_ON(delayed_work_pending(&wb->dwork));
363 percpu_counter_destroy(&wb->stat[i]);
365 fprop_local_destroy_percpu(&wb->completions);
366 if (wb != &wb->bdi->wb)
367 bdi_put(wb->bdi);
383 struct bdi_writeback *wb = container_of(rcu_head,
386 percpu_ref_exit(&wb->refcnt);
387 kfree(wb);
392 struct bdi_writeback *wb = container_of(work, struct bdi_writeback,
394 struct blkcg *blkcg = css_to_blkcg(wb->blkcg_css);
396 mutex_lock(&wb->bdi->cgwb_release_mutex);
397 wb_shutdown(wb);
399 css_put(wb->memcg_css);
400 css_put(wb->blkcg_css);
401 mutex_unlock(&wb->bdi->cgwb_release_mutex);
406 fprop_local_destroy_percpu(&wb->memcg_completions);
407 wb_exit(wb);
408 call_rcu(&wb->rcu, cgwb_free_rcu);
413 struct bdi_writeback *wb = container_of(refcnt, struct bdi_writeback,
415 queue_work(cgwb_release_wq, &wb->release_work);
418 static void cgwb_kill(struct bdi_writeback *wb)
422 WARN_ON(!radix_tree_delete(&wb->bdi->cgwb_tree, wb->memcg_css->id));
423 list_del(&wb->memcg_node);
424 list_del(&wb->blkcg_node);
425 percpu_ref_kill(&wb->refcnt);
428 static void cgwb_remove_from_bdi_list(struct bdi_writeback *wb)
431 list_del_rcu(&wb->bdi_node);
442 struct bdi_writeback *wb;
454 wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id);
455 if (wb && wb->blkcg_css != blkcg_css) {
456 cgwb_kill(wb);
457 wb = NULL;
460 if (wb)
464 wb = kmalloc(sizeof(*wb), gfp);
465 if (!wb) {
470 ret = wb_init(wb, bdi, gfp);
474 ret = percpu_ref_init(&wb->refcnt, cgwb_release, 0, gfp);
478 ret = fprop_local_init_percpu(&wb->memcg_completions, gfp);
482 wb->memcg_css = memcg_css;
483 wb->blkcg_css = blkcg_css;
484 INIT_WORK(&wb->release_work, cgwb_release_workfn);
485 set_bit(WB_registered, &wb->state);
488 * The root wb determines the registered state of the whole bdi and
490 * whether they're still online. Don't link @wb if any is dead.
495 if (test_bit(WB_registered, &bdi->wb.state) &&
498 ret = radix_tree_insert(&bdi->cgwb_tree, memcg_css->id, wb);
500 list_add_tail_rcu(&wb->bdi_node, &bdi->wb_list);
501 list_add(&wb->memcg_node, memcg_cgwb_list);
502 list_add(&wb->blkcg_node, blkcg_cgwb_list);
517 fprop_local_destroy_percpu(&wb->memcg_completions);
519 percpu_ref_exit(&wb->refcnt);
521 wb_exit(wb);
523 kfree(wb);
530 * wb_get_lookup - get wb for a given memcg
534 * Try to get the wb for @memcg_css on @bdi. The returned wb has its
541 * A wb is keyed by its associated memcg. As blkcg implicitly enables
547 * and disabled closer to root in the hierarchy, each wb keeps track of
549 * each lookup. On mismatch, the existing wb is discarded and a new one is
555 struct bdi_writeback *wb;
558 return &bdi->wb;
561 wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id);
562 if (wb) {
567 if (unlikely(wb->blkcg_css != blkcg_css || !wb_tryget(wb)))
568 wb = NULL;
573 return wb;
577 * wb_get_create - get wb for a given memcg, create if necessary
582 * Try to get the wb for @memcg_css on @bdi. If it doesn't exist, try to
589 struct bdi_writeback *wb;
594 return &bdi->wb;
597 wb = wb_get_lookup(bdi, memcg_css);
598 } while (!wb && !cgwb_create(bdi, memcg_css, gfp));
600 return wb;
611 ret = wb_init(&bdi->wb, bdi, GFP_KERNEL);
613 bdi->wb.memcg_css = &root_mem_cgroup->css;
614 bdi->wb.blkcg_css = blkcg_root_css;
623 struct bdi_writeback *wb;
625 WARN_ON(test_bit(WB_registered, &bdi->wb.state));
635 wb = list_first_entry(&bdi->wb_list, struct bdi_writeback,
638 wb_shutdown(wb);
646 * wb_memcg_offline - kill all wb's associated with a memcg being offlined
649 * Also prevents creation of any new wb's associated with @memcg.
654 struct bdi_writeback *wb, *next;
657 list_for_each_entry_safe(wb, next, memcg_cgwb_list, memcg_node)
658 cgwb_kill(wb);
659 memcg_cgwb_list->next = NULL; /* prevent new wb's */
664 * wb_blkcg_offline - kill all wb's associated with a blkcg being offlined
667 * Also prevents creation of any new wb's associated with @blkcg.
671 struct bdi_writeback *wb, *next;
674 list_for_each_entry_safe(wb, next, &blkcg->cgwb_list, blkcg_node)
675 cgwb_kill(wb);
676 blkcg->cgwb_list.next = NULL; /* prevent new wb's */
683 list_add_tail_rcu(&bdi->wb.bdi_node, &bdi->wb_list);
706 return wb_init(&bdi->wb, bdi, GFP_KERNEL);
713 list_add_tail_rcu(&bdi->wb.bdi_node, &bdi->wb_list);
716 static void cgwb_remove_from_bdi_list(struct bdi_writeback *wb)
718 list_del_rcu(&wb->bdi_node);
826 set_bit(WB_registered, &bdi->wb.state);
880 wb_shutdown(&bdi->wb);
907 if (test_bit(WB_registered, &bdi->wb.state))
910 wb_exit(&bdi->wb);
940 if (test_and_clear_bit(bit, &bdi->wb.congested))
953 if (!test_and_set_bit(bit, &bdi->wb.congested))