Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: Convert writeback to XArray

A couple of short loops.

Signed-off-by: Matthew Wilcox <willy@infradead.org>

+9 -16
+9 -16
fs/fs-writeback.c
··· 339 339 struct address_space *mapping = inode->i_mapping; 340 340 struct bdi_writeback *old_wb = inode->i_wb; 341 341 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; 343 344 bool switched = false; 344 - void **slot; 345 345 346 346 /* 347 347 * By the time control reaches here, RCU grace period has passed ··· 375 375 * to possibly dirty pages while PAGECACHE_TAG_WRITEBACK points to 376 376 * pages actually under writeback. 377 377 */ 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)) { 383 380 dec_wb_stat(old_wb, WB_RECLAIMABLE); 384 381 inc_wb_stat(new_wb, WB_RECLAIMABLE); 385 382 } 386 383 } 387 384 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); 397 390 } 398 391 399 392 wb_get(new_wb);