There's a small window in which another CPU could dirty the page after
we've cleaned it, and before we've moved it to mapping->dirty_pages().
The end result is a dirty page on mapping->locked_pages, which is
wrong.
So take mapping->page_lock before clearing the dirty bit.
if (bdi != current->backing_dev_info &&
bdi_write_congested(bdi))
goto keep_locked;
+ write_lock(&mapping->page_lock);
if (test_clear_page_dirty(page)) {
int res;
struct writeback_control wbc = {
.for_reclaim = 1,
};
- write_lock(&mapping->page_lock);
list_move(&page->list, &mapping->locked_pages);
write_unlock(&mapping->page_lock);
}
goto keep;
}
+ write_unlock(&mapping->page_lock);
}
/*