]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: Timely free truncated dirty pages
authorJan Kara <jack@suse.cz>
Wed, 11 Jan 2017 18:20:04 +0000 (10:20 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 11 Jan 2017 18:20:04 +0000 (10:20 -0800)
commit7ca308afe916083dedf84d6514d20f14f984044a
tree871ad399028165211ec365d7bc19a35798a32995
parent28e7afd26d96389524aa48015f54bfd47b36371a
xfs: Timely free truncated dirty pages

Commit 49755aa3944d "xfs: skip dirty pages in ->releasepage()" started
to skip dirty pages in xfs_vm_releasepage() which also has the effect
that if a dirty page is truncated, it does not get freed by
block_invalidatepage() and is lingering in LRU list waiting for reclaim.
So a simple loop like:

while true; do
dd if=/dev/zero of=file bs=1M count=100
rm file
done

will keep using more and more memory until we hit low watermarks and
start pagecache reclaim which will eventually reclaim also the truncate
pages. Keeping these truncated (and thus never usable) pages in memory
is just a waste of memory, is unnecessarily stressing page cache
reclaim, and reportedly also leads to anonymous mmap(2) returning ENOMEM
prematurely.

So instead of just skipping dirty pages in xfs_vm_releasepage(), return
to old behavior of skipping them only if they have delalloc or unwritten
buffers and fix the spurious warnings by warning only if the page is
clean.

CC: stable@vger.kernel.org
CC: Brian Foster <bfoster@redhat.com>
CC: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Petr Tůma <petr.tuma@d3s.mff.cuni.cz>
Fixes: 49755aa3944dec88c25aaeaff3a2ba922d4c7ffb
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_aops.c