• Home
  • Raw
  • Download

Lines Matching full:wb

85 static bool wb_io_lists_populated(struct bdi_writeback *wb)  in wb_io_lists_populated()  argument
87 if (wb_has_dirty_io(wb)) { in wb_io_lists_populated()
90 set_bit(WB_has_dirty_io, &wb->state); in wb_io_lists_populated()
91 WARN_ON_ONCE(!wb->avg_write_bandwidth); in wb_io_lists_populated()
92 atomic_long_add(wb->avg_write_bandwidth, in wb_io_lists_populated()
93 &wb->bdi->tot_write_bandwidth); in wb_io_lists_populated()
98 static void wb_io_lists_depopulated(struct bdi_writeback *wb) in wb_io_lists_depopulated() argument
100 if (wb_has_dirty_io(wb) && list_empty(&wb->b_dirty) && in wb_io_lists_depopulated()
101 list_empty(&wb->b_io) && list_empty(&wb->b_more_io)) { in wb_io_lists_depopulated()
102 clear_bit(WB_has_dirty_io, &wb->state); in wb_io_lists_depopulated()
103 WARN_ON_ONCE(atomic_long_sub_return(wb->avg_write_bandwidth, in wb_io_lists_depopulated()
104 &wb->bdi->tot_write_bandwidth) < 0); in wb_io_lists_depopulated()
111 * @wb: target bdi_writeback
112 * @head: one of @wb->b_{dirty|io|more_io|dirty_time}
114 * Move @inode->i_io_list to @list of @wb and set %WB_has_dirty_io.
119 struct bdi_writeback *wb, in inode_io_list_move_locked() argument
122 assert_spin_locked(&wb->list_lock); in inode_io_list_move_locked()
127 if (head != &wb->b_dirty_time) in inode_io_list_move_locked()
128 return wb_io_lists_populated(wb); in inode_io_list_move_locked()
130 wb_io_lists_depopulated(wb); in inode_io_list_move_locked()
137 * @wb: bdi_writeback @inode is being removed from
139 * Remove @inode which may be on one of @wb->b_{dirty|io|more_io} lists and
143 struct bdi_writeback *wb) in inode_io_list_del_locked() argument
145 assert_spin_locked(&wb->list_lock); in inode_io_list_del_locked()
150 wb_io_lists_depopulated(wb); in inode_io_list_del_locked()
153 static void wb_wakeup(struct bdi_writeback *wb) in wb_wakeup() argument
155 spin_lock_bh(&wb->work_lock); in wb_wakeup()
156 if (test_bit(WB_registered, &wb->state)) in wb_wakeup()
157 mod_delayed_work(bdi_wq, &wb->dwork, 0); in wb_wakeup()
158 spin_unlock_bh(&wb->work_lock); in wb_wakeup()
161 static void finish_writeback_work(struct bdi_writeback *wb, in finish_writeback_work() argument
177 static void wb_queue_work(struct bdi_writeback *wb, in wb_queue_work() argument
180 trace_writeback_queue(wb, work); in wb_queue_work()
185 spin_lock_bh(&wb->work_lock); in wb_queue_work()
187 if (test_bit(WB_registered, &wb->state)) { in wb_queue_work()
188 list_add_tail(&work->list, &wb->work_list); in wb_queue_work()
189 mod_delayed_work(bdi_wq, &wb->dwork, 0); in wb_queue_work()
191 finish_writeback_work(wb, work); in wb_queue_work()
193 spin_unlock_bh(&wb->work_lock); in wb_queue_work()
253 struct bdi_writeback *wb = NULL; in __inode_attach_wb() local
260 wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC); in __inode_attach_wb()
264 wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC); in __inode_attach_wb()
269 if (!wb) in __inode_attach_wb()
270 wb = &bdi->wb; in __inode_attach_wb()
276 if (unlikely(cmpxchg(&inode->i_wb, NULL, wb))) in __inode_attach_wb()
277 wb_put(wb); in __inode_attach_wb()
282 * locked_inode_to_wb_and_lock_list - determine a locked inode's wb and lock it
285 * Returns @inode's wb with its list_lock held. @inode->i_lock must be
286 * held on entry and is released on return. The returned wb is guaranteed
287 * to stay @inode's associated wb until its list_lock is released.
292 __acquires(&wb->list_lock) in locked_inode_to_wb_and_lock_list()
295 struct bdi_writeback *wb = inode_to_wb(inode); in locked_inode_to_wb_and_lock_list() local
299 * @inode->i_lock and @wb->list_lock but list_lock nests in locked_inode_to_wb_and_lock_list()
303 wb_get(wb); in locked_inode_to_wb_and_lock_list()
305 spin_lock(&wb->list_lock); in locked_inode_to_wb_and_lock_list()
308 if (likely(wb == inode->i_wb)) { in locked_inode_to_wb_and_lock_list()
309 wb_put(wb); /* @inode already has ref */ in locked_inode_to_wb_and_lock_list()
310 return wb; in locked_inode_to_wb_and_lock_list()
313 spin_unlock(&wb->list_lock); in locked_inode_to_wb_and_lock_list()
314 wb_put(wb); in locked_inode_to_wb_and_lock_list()
321 * inode_to_wb_and_lock_list - determine an inode's wb and lock it
328 __acquires(&wb->list_lock) in inode_to_wb_and_lock_list()
373 * since I_WB_SWITCH assertion and all wb stat update transactions in inode_switch_wbs_work_fn()
378 * gives us exclusion against all wb related operations on @inode in inode_switch_wbs_work_fn()
449 * ensures that the new wb is visible if they see !I_WB_SWITCH. in inode_switch_wbs_work_fn()
483 * inode_switch_wbs - change the wb association of an inode
485 * @new_wb_id: ID of the new wb
487 * Switch @inode's wb association to the wb identified by @new_wb_id. The
510 /* find and pin the new wb */ in inode_switch_wbs()
572 wbc->wb = inode_to_wb(inode); in wbc_attach_and_unlock_inode()
575 wbc->wb_id = wbc->wb->memcg_css->id; in wbc_attach_and_unlock_inode()
582 wb_get(wbc->wb); in wbc_attach_and_unlock_inode()
586 * A dying wb indicates that either the blkcg associated with the in wbc_attach_and_unlock_inode()
588 * case, a replacement wb should already be available and we should in wbc_attach_and_unlock_inode()
589 * refresh the wb immediately. In the second case, trying to in wbc_attach_and_unlock_inode()
592 if (unlikely(wb_dying(wbc->wb) && !css_is_dying(wbc->wb->memcg_css))) in wbc_attach_and_unlock_inode()
623 * current wb and the last round's winner wb (max of last round's current
624 * wb, the winner from two rounds ago, and the last round's majority
636 struct bdi_writeback *wb = wbc->wb; in wbc_detach_inode() local
642 if (!wb) in wbc_detach_inode()
669 wb->avg_write_bandwidth); in wbc_detach_inode()
680 * The switch verdict is reached if foreign wb's consume in wbc_detach_inode()
697 * Switch if the current wb isn't the consistent winner. in wbc_detach_inode()
701 * the wrong wb for an extended period of time. in wbc_detach_inode()
715 wb_put(wbc->wb); in wbc_detach_inode()
716 wbc->wb = NULL; in wbc_detach_inode()
742 if (!wbc->wb || wbc->no_cgroup_owner) in wbc_account_cgroup_owner()
780 * associated with @inode is congested; otherwise, the root wb's congestion
793 struct bdi_writeback *wb; in inode_congested() local
797 wb = unlocked_inode_to_wb_begin(inode, &lock_cookie); in inode_congested()
798 congested = wb_congested(wb, cong_bits); in inode_congested()
803 return wb_congested(&inode_to_bdi(inode)->wb, cong_bits); in inode_congested()
809 * @wb: target bdi_writeback to split @nr_pages to
812 * Split @wb's portion of @nr_pages according to @wb's write bandwidth in
813 * relation to the total write bandwidth of all wb's w/ dirty inodes on
814 * @wb->bdi.
816 static long wb_split_bdi_pages(struct bdi_writeback *wb, long nr_pages) in wb_split_bdi_pages() argument
818 unsigned long this_bw = wb->avg_write_bandwidth; in wb_split_bdi_pages()
819 unsigned long tot_bw = atomic_long_read(&wb->bdi->tot_write_bandwidth); in wb_split_bdi_pages()
825 * This may be called on clean wb's and proportional distribution in wb_split_bdi_pages()
836 * bdi_split_work_to_wbs - split a wb_writeback_work to all wb's of a bdi
839 * @skip_if_busy: skip wb's which already have writeback in progress
841 * Split and issue @base_work to all wb's (bdi_writeback's) of @bdi which
843 * distributed to the busy wbs according to each wb's proportion in the
851 struct bdi_writeback *wb = list_entry(&bdi->wb_list, in bdi_split_work_to_wbs() local
857 list_for_each_entry_continue_rcu(wb, &bdi->wb_list, bdi_node) { in bdi_split_work_to_wbs()
869 if (!wb_has_dirty_io(wb) && in bdi_split_work_to_wbs()
871 list_empty(&wb->b_dirty_time))) in bdi_split_work_to_wbs()
873 if (skip_if_busy && writeback_in_progress(wb)) in bdi_split_work_to_wbs()
876 nr_pages = wb_split_bdi_pages(wb, base_work->nr_pages); in bdi_split_work_to_wbs()
883 wb_queue_work(wb, work); in bdi_split_work_to_wbs()
888 * If wb_tryget fails, the wb has been shutdown, skip it. in bdi_split_work_to_wbs()
890 * Pin @wb so that it stays on @bdi->wb_list. This allows in bdi_split_work_to_wbs()
891 * continuing iteration from @wb after dropping and in bdi_split_work_to_wbs()
894 if (!wb_tryget(wb)) in bdi_split_work_to_wbs()
904 wb_queue_work(wb, work); in bdi_split_work_to_wbs()
905 last_wb = wb; in bdi_split_work_to_wbs()
933 struct bdi_writeback *wb; in cgroup_writeback_by_id() local
953 * And find the associated wb. If the wb isn't there already in cgroup_writeback_by_id()
956 wb = wb_get_lookup(bdi, memcg_css); in cgroup_writeback_by_id()
957 if (!wb) { in cgroup_writeback_by_id()
972 mem_cgroup_wb_stats(wb, &filepages, &headroom, &dirty, in cgroup_writeback_by_id()
986 wb_queue_work(wb, work); in cgroup_writeback_by_id()
992 wb_put(wb); in cgroup_writeback_by_id()
1001 * cgroup_writeback_umount - flush inode wb switches for umount
1004 * flushes in-flight inode wb switches. An inode wb switch goes through
1006 * that all previously scheduled switches are finished. As wb switches are
1008 * flushing iff wb switches are in flight.
1015 * ensure that all in-flight wb switches are in the workqueue. in cgroup_writeback_umount()
1039 __acquires(&wb->list_lock) in locked_inode_to_wb_and_lock_list()
1041 struct bdi_writeback *wb = inode_to_wb(inode); in locked_inode_to_wb_and_lock_list() local
1044 spin_lock(&wb->list_lock); in locked_inode_to_wb_and_lock_list()
1045 return wb; in locked_inode_to_wb_and_lock_list()
1049 __acquires(&wb->list_lock) in inode_to_wb_and_lock_list()
1051 struct bdi_writeback *wb = inode_to_wb(inode); in inode_to_wb_and_lock_list() local
1053 spin_lock(&wb->list_lock); in inode_to_wb_and_lock_list()
1054 return wb; in inode_to_wb_and_lock_list()
1057 static long wb_split_bdi_pages(struct bdi_writeback *wb, long nr_pages) in wb_split_bdi_pages() argument
1068 if (!skip_if_busy || !writeback_in_progress(&bdi->wb)) { in bdi_split_work_to_wbs()
1070 wb_queue_work(&bdi->wb, base_work); in bdi_split_work_to_wbs()
1086 static void wb_start_writeback(struct bdi_writeback *wb, enum wb_reason reason) in wb_start_writeback() argument
1088 if (!wb_has_dirty_io(wb)) in wb_start_writeback()
1099 if (test_bit(WB_start_all, &wb->state) || in wb_start_writeback()
1100 test_and_set_bit(WB_start_all, &wb->state)) in wb_start_writeback()
1103 wb->start_all_reason = reason; in wb_start_writeback()
1104 wb_wakeup(wb); in wb_start_writeback()
1109 * @wb: bdi_writback to write from
1113 * this function returns, it is only guaranteed that for given wb
1117 void wb_start_background_writeback(struct bdi_writeback *wb) in wb_start_background_writeback() argument
1123 trace_writeback_wake_background(wb); in wb_start_background_writeback()
1124 wb_wakeup(wb); in wb_start_background_writeback()
1132 struct bdi_writeback *wb; in inode_io_list_del() local
1134 wb = inode_to_wb_and_lock_list(inode); in inode_io_list_del()
1136 inode_io_list_del_locked(inode, wb); in inode_io_list_del()
1138 spin_unlock(&wb->list_lock); in inode_io_list_del()
1187 static void redirty_tail_locked(struct inode *inode, struct bdi_writeback *wb) in redirty_tail_locked() argument
1191 if (!list_empty(&wb->b_dirty)) { in redirty_tail_locked()
1194 tail = wb_inode(wb->b_dirty.next); in redirty_tail_locked()
1198 inode_io_list_move_locked(inode, wb, &wb->b_dirty); in redirty_tail_locked()
1202 static void redirty_tail(struct inode *inode, struct bdi_writeback *wb) in redirty_tail() argument
1205 redirty_tail_locked(inode, wb); in redirty_tail()
1212 static void requeue_io(struct inode *inode, struct bdi_writeback *wb) in requeue_io() argument
1214 inode_io_list_move_locked(inode, wb, &wb->b_more_io); in requeue_io()
1305 static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work, in queue_io() argument
1311 assert_spin_locked(&wb->list_lock); in queue_io()
1312 list_splice_init(&wb->b_more_io, &wb->b_io); in queue_io()
1313 moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, dirtied_before); in queue_io()
1316 moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io, in queue_io()
1319 wb_io_lists_populated(wb); in queue_io()
1320 trace_writeback_queue_io(wb, work, dirtied_before, moved); in queue_io()
1394 static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, in requeue_inode() argument
1414 redirty_tail_locked(inode, wb); in requeue_inode()
1425 requeue_io(inode, wb); in requeue_inode()
1434 redirty_tail_locked(inode, wb); in requeue_inode()
1442 redirty_tail_locked(inode, wb); in requeue_inode()
1445 inode_io_list_move_locked(inode, wb, &wb->b_dirty_time); in requeue_inode()
1449 inode_io_list_del_locked(inode, wb); in requeue_inode()
1546 struct bdi_writeback *wb; in writeback_single_inode() local
1585 wb = inode_to_wb_and_lock_list(inode); in writeback_single_inode()
1592 inode_io_list_del_locked(inode, wb); in writeback_single_inode()
1593 spin_unlock(&wb->list_lock); in writeback_single_inode()
1600 static long writeback_chunk_size(struct bdi_writeback *wb, in writeback_chunk_size() argument
1621 pages = min(wb->avg_write_bandwidth / 2, in writeback_chunk_size()
1636 * NOTE! This is called with wb->list_lock held, and will
1641 struct bdi_writeback *wb, in writeback_sb_inodes() argument
1658 while (!list_empty(&wb->b_io)) { in writeback_sb_inodes()
1659 struct inode *inode = wb_inode(wb->b_io.prev); in writeback_sb_inodes()
1670 redirty_tail(inode, wb); in writeback_sb_inodes()
1689 redirty_tail_locked(inode, wb); in writeback_sb_inodes()
1704 requeue_io(inode, wb); in writeback_sb_inodes()
1708 spin_unlock(&wb->list_lock); in writeback_sb_inodes()
1719 spin_lock(&wb->list_lock); in writeback_sb_inodes()
1725 write_chunk = writeback_chunk_size(wb, work); in writeback_sb_inodes()
1756 * have been switched to another wb in the meantime. in writeback_sb_inodes()
1766 if (unlikely(tmp_wb != wb)) { in writeback_sb_inodes()
1768 spin_lock(&wb->list_lock); in writeback_sb_inodes()
1785 static long __writeback_inodes_wb(struct bdi_writeback *wb, in __writeback_inodes_wb() argument
1791 while (!list_empty(&wb->b_io)) { in __writeback_inodes_wb()
1792 struct inode *inode = wb_inode(wb->b_io.prev); in __writeback_inodes_wb()
1801 redirty_tail(inode, wb); in __writeback_inodes_wb()
1804 wrote += writeback_sb_inodes(sb, wb, work); in __writeback_inodes_wb()
1819 static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages, in writeback_inodes_wb() argument
1831 spin_lock(&wb->list_lock); in writeback_inodes_wb()
1832 if (list_empty(&wb->b_io)) in writeback_inodes_wb()
1833 queue_io(wb, &work, jiffies); in writeback_inodes_wb()
1834 __writeback_inodes_wb(wb, &work); in writeback_inodes_wb()
1835 spin_unlock(&wb->list_lock); in writeback_inodes_wb()
1856 static long wb_writeback(struct bdi_writeback *wb, in wb_writeback() argument
1867 spin_lock(&wb->list_lock); in wb_writeback()
1882 !list_empty(&wb->work_list)) in wb_writeback()
1889 if (work->for_background && !wb_over_bg_thresh(wb)) in wb_writeback()
1904 trace_writeback_start(wb, work); in wb_writeback()
1905 if (list_empty(&wb->b_io)) in wb_writeback()
1906 queue_io(wb, work, dirtied_before); in wb_writeback()
1908 progress = writeback_sb_inodes(work->sb, wb, work); in wb_writeback()
1910 progress = __writeback_inodes_wb(wb, work); in wb_writeback()
1911 trace_writeback_written(wb, work); in wb_writeback()
1913 wb_update_bandwidth(wb, wb_start); in wb_writeback()
1928 if (list_empty(&wb->b_more_io)) in wb_writeback()
1935 trace_writeback_wait(wb, work); in wb_writeback()
1936 inode = wb_inode(wb->b_more_io.prev); in wb_writeback()
1938 spin_unlock(&wb->list_lock); in wb_writeback()
1941 spin_lock(&wb->list_lock); in wb_writeback()
1943 spin_unlock(&wb->list_lock); in wb_writeback()
1952 static struct wb_writeback_work *get_next_work_item(struct bdi_writeback *wb) in get_next_work_item() argument
1956 spin_lock_bh(&wb->work_lock); in get_next_work_item()
1957 if (!list_empty(&wb->work_list)) { in get_next_work_item()
1958 work = list_entry(wb->work_list.next, in get_next_work_item()
1962 spin_unlock_bh(&wb->work_lock); in get_next_work_item()
1966 static long wb_check_background_flush(struct bdi_writeback *wb) in wb_check_background_flush() argument
1968 if (wb_over_bg_thresh(wb)) { in wb_check_background_flush()
1978 return wb_writeback(wb, &work); in wb_check_background_flush()
1984 static long wb_check_old_data_flush(struct bdi_writeback *wb) in wb_check_old_data_flush() argument
1995 expired = wb->last_old_flush + in wb_check_old_data_flush()
2000 wb->last_old_flush = jiffies; in wb_check_old_data_flush()
2012 return wb_writeback(wb, &work); in wb_check_old_data_flush()
2018 static long wb_check_start_all(struct bdi_writeback *wb) in wb_check_start_all() argument
2022 if (!test_bit(WB_start_all, &wb->state)) in wb_check_start_all()
2028 .nr_pages = wb_split_bdi_pages(wb, nr_pages), in wb_check_start_all()
2031 .reason = wb->start_all_reason, in wb_check_start_all()
2034 nr_pages = wb_writeback(wb, &work); in wb_check_start_all()
2037 clear_bit(WB_start_all, &wb->state); in wb_check_start_all()
2045 static long wb_do_writeback(struct bdi_writeback *wb) in wb_do_writeback() argument
2050 set_bit(WB_writeback_running, &wb->state); in wb_do_writeback()
2051 while ((work = get_next_work_item(wb)) != NULL) { in wb_do_writeback()
2052 trace_writeback_exec(wb, work); in wb_do_writeback()
2053 wrote += wb_writeback(wb, work); in wb_do_writeback()
2054 finish_writeback_work(wb, work); in wb_do_writeback()
2060 wrote += wb_check_start_all(wb); in wb_do_writeback()
2065 wrote += wb_check_old_data_flush(wb); in wb_do_writeback()
2066 wrote += wb_check_background_flush(wb); in wb_do_writeback()
2067 clear_bit(WB_writeback_running, &wb->state); in wb_do_writeback()
2078 struct bdi_writeback *wb = container_of(to_delayed_work(work), in wb_workfn() local
2082 set_worker_desc("flush-%s", bdi_dev_name(wb->bdi)); in wb_workfn()
2086 !test_bit(WB_registered, &wb->state))) { in wb_workfn()
2088 * The normal path. Keep writing back @wb until its in wb_workfn()
2090 * if @wb is shutting down even when we're running off the in wb_workfn()
2094 pages_written = wb_do_writeback(wb); in wb_workfn()
2096 } while (!list_empty(&wb->work_list)); in wb_workfn()
2103 pages_written = writeback_inodes_wb(wb, 1024, in wb_workfn()
2108 if (!list_empty(&wb->work_list)) in wb_workfn()
2109 wb_wakeup(wb); in wb_workfn()
2110 else if (wb_has_dirty_io(wb) && dirty_writeback_interval) in wb_workfn()
2111 wb_wakeup_delayed(wb); in wb_workfn()
2123 struct bdi_writeback *wb; in __wakeup_flusher_threads_bdi() local
2128 list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node) in __wakeup_flusher_threads_bdi()
2129 wb_start_writeback(wb, reason); in __wakeup_flusher_threads_bdi()
2183 struct bdi_writeback *wb; in wakeup_dirtytime_writeback() local
2185 list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node) in wakeup_dirtytime_writeback()
2186 if (!list_empty(&wb->b_dirty_time)) in wakeup_dirtytime_writeback()
2187 wb_wakeup(wb); in wakeup_dirtytime_writeback()
2307 struct bdi_writeback *wb; in __mark_inode_dirty() local
2311 wb = locked_inode_to_wb_and_lock_list(inode); in __mark_inode_dirty()
2318 dirty_list = &wb->b_dirty; in __mark_inode_dirty()
2320 dirty_list = &wb->b_dirty_time; in __mark_inode_dirty()
2322 wakeup_bdi = inode_io_list_move_locked(inode, wb, in __mark_inode_dirty()
2325 spin_unlock(&wb->list_lock); in __mark_inode_dirty()
2335 (wb->bdi->capabilities & BDI_CAP_WRITEBACK)) in __mark_inode_dirty()
2336 wb_wakeup_delayed(wb); in __mark_inode_dirty()
2392 * Move each inode back to the wb list before we drop the lock in wait_sb_inodes()
2401 * do not have the mapping lock. Skip it here, wb completion in wait_sb_inodes()
2541 /* protect against inode wb switch, see inode_switch_wbs_work_fn() */ in sync_inodes_sb()