Skip to content

Commit 04edf02

Browse files
author
Matthew Wilcox
committed
fs: Convert writeback to XArray
A couple of short loops. Signed-off-by: Matthew Wilcox <willy@infradead.org>
1 parent ec82e1c commit 04edf02

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

‎fs/fs-writeback.c‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ static void inode_switch_wbs_work_fn(struct work_struct *work)
339339
struct address_space *mapping = inode->i_mapping;
340340
struct bdi_writeback *old_wb = inode->i_wb;
341341
struct bdi_writeback *new_wb = isw->new_wb;
342-
struct radix_tree_iter iter;
342+
XA_STATE(xas, &mapping->i_pages, 0);
343+
struct page *page;
343344
bool switched = false;
344-
void **slot;
345345

346346
/*
347347
* By the time control reaches here, RCU grace period has passed
@@ -375,25 +375,18 @@ static void inode_switch_wbs_work_fn(struct work_struct *work)
375375
* to possibly dirty pages while PAGECACHE_TAG_WRITEBACK points to
376376
* pages actually under writeback.
377377
*/
378-
radix_tree_for_each_tagged(slot, &mapping->i_pages, &iter, 0,
379-
PAGECACHE_TAG_DIRTY) {
380-
struct page *page = radix_tree_deref_slot_protected(slot,
381-
&mapping->i_pages.xa_lock);
382-
if (likely(page) && PageDirty(page)) {
378+
xas_for_each_marked(&xas, page, ULONG_MAX, PAGECACHE_TAG_DIRTY) {
379+
if (PageDirty(page)) {
383380
dec_wb_stat(old_wb, WB_RECLAIMABLE);
384381
inc_wb_stat(new_wb, WB_RECLAIMABLE);
385382
}
386383
}
387384

388-
radix_tree_for_each_tagged(slot, &mapping->i_pages, &iter, 0,
389-
PAGECACHE_TAG_WRITEBACK) {
390-
struct page *page = radix_tree_deref_slot_protected(slot,
391-
&mapping->i_pages.xa_lock);
392-
if (likely(page)) {
393-
WARN_ON_ONCE(!PageWriteback(page));
394-
dec_wb_stat(old_wb, WB_WRITEBACK);
395-
inc_wb_stat(new_wb, WB_WRITEBACK);
396-
}
385+
xas_set(&xas, 0);
386+
xas_for_each_marked(&xas, page, ULONG_MAX, PAGECACHE_TAG_WRITEBACK) {
387+
WARN_ON_ONCE(!PageWriteback(page));
388+
dec_wb_stat(old_wb, WB_WRITEBACK);
389+
inc_wb_stat(new_wb, WB_WRITEBACK);
397390
}
398391

399392
wb_get(new_wb);

0 commit comments

Comments
 (0)