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

mm: fix warning in __set_page_dirty_nobuffers

New tmpfs use of !PageUptodate pages for fallocate() is triggering the
WARNING: at mm/page-writeback.c:1990 when __set_page_dirty_nobuffers()
is called from migrate_page_copy() for compaction.

It is anomalous that migration should use __set_page_dirty_nobuffers()
on an address_space that does not participate in dirty and writeback
accounting; and this has also been observed to insert surprising dirty
tags into a tmpfs radix_tree, despite tmpfs not using tags at all.

We should probably give migrate_page_copy() a better way to preserve the
tag and migrate accounting info, when mapping_cap_account_dirty(). But
that needs some more work: so in the interim, avoid the warning by using
a simple SetPageDirty on PageSwapBacked pages.

Reported-and-tested-by: Dave Jones <davej@redhat.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Hugh Dickins and committed by
Linus Torvalds
752dc185 2f9d3df8

+4 -1
+4 -1
mm/migrate.c
··· 436 436 * is actually a signal that all of the page has become dirty. 437 437 * Whereas only part of our page may be dirty. 438 438 */ 439 - __set_page_dirty_nobuffers(newpage); 439 + if (PageSwapBacked(page)) 440 + SetPageDirty(newpage); 441 + else 442 + __set_page_dirty_nobuffers(newpage); 440 443 } 441 444 442 445 mlock_migrate_page(newpage, page);