[PATCH 4.19 11/44] fs/iomap.c: get/put the page in iomap_page_create/release()
From: Greg Kroah-Hartman
Date: Tue Dec 18 2018 - 11:40:55 EST
4.19-stable review patch. If anyone has any objections, please let me know.
From: Piotr Jaroszynski <pjaroszynski@xxxxxxxxxx>
commit 61c6de667263184125d5ca75e894fcad632b0dd3 upstream.
migrate_page_move_mapping() expects pages with private data set to have
a page_count elevated by 1. This is what used to happen for xfs through
the buffer_heads code before the switch to iomap in commit 82cb14175e7d
("xfs: add support for sub-pagesize writeback without buffer_heads").
Not having the count elevated causes move_pages() to fail on memory
mapped files coming from xfs.
Make iomap compatible with the migrate_page_move_mapping() assumption by
elevating the page count as part of iomap_page_create() and lowering it
It causes the move_pages() syscall to misbehave on memory mapped files
from xfs. It does not not move any pages, which I suppose is "just" a
perf issue, but it also ends up returning a positive number which is out
of spec for the syscall. Talking to Michal Hocko, it sounds like
returning positive numbers might be a necessary update to move_pages()
I only hit this in tests that verify that move_pages() actually moved
the pages. The test also got confused by the positive return from
move_pages() (it got treated as a success as positive numbers were not
expected and not handled) making it a bit harder to track down what's
Fixes: 82cb14175e7d ("xfs: add support for sub-pagesize writeback without buffer_heads")
Signed-off-by: Piotr Jaroszynski <pjaroszynski@xxxxxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
Cc: William Kucharski <william.kucharski@xxxxxxxxxx>
Cc: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
Cc: Brian Foster <bfoster@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
fs/iomap.c | 7 +++++++
1 file changed, 7 insertions(+)
@@ -117,6 +117,12 @@ iomap_page_create(struct inode *inode, s
bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
+ * migrate_page_move_mapping() assumes that pages with private data have
+ * their count elevated by 1.
set_page_private(page, (unsigned long)iop);
@@ -133,6 +139,7 @@ iomap_page_release(struct page *page)