iomap: get/put the page in iomap_page_create/release()
PATCH 1/1 iomap: get/put the page in iomap_page_create/release()
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 in iomap_page_release().
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() anyway though.
Based on an earlier patch and changelog from Piotr Jaroszynski, except that this version actually puts/gets the page aswell when migrating pages using a copy, and thus actually survives xfstests.
--- fs/iomap.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/iomap.c +9 -0
@@ -116,6 +116,12 @@ iomap_page_create(struct inode *inode, struct page *page)atomic_set (&iop->read_count,0 );atomic_set (&iop->write_count,0 );bitmap_zero (iop->uptodate,PAGE_SIZE /SECTOR_SIZE ); + +/* +* migrate_page_move_mapping() assumes that pages with private data have +* their count elevated by 1. +*/ +get_page (page);set_page_private (page, (unsigned long )iop);SetPagePrivate (page);return iop;
@@ -132,6 +138,7 @@ iomap_page_release(struct page *page)WARN_ON_ONCE (atomic_read (&iop->write_count));ClearPagePrivate (page);set_page_private (page,0 ); +put_page (page);kfree (iop); }
@@ -569,8 +576,10 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,if (page_has_private (page)) {ClearPagePrivate (page); +get_page (newpage);set_page_private (newpage,page_private (page));set_page_private (page,0 ); +put_page (page);SetPagePrivate (newpage); }
Signature · 1 line
2.20.1
Quoted 18 lines · Christoph Hellwig
migrate_page_move_mapping()expects pages with private data set to have apage_countelevated by 1. This is what used to happen for xfs through thebuffer_headscode before the switch to iomap in commit82cb14175e7d("xfs: add support for sub-pagesize writeback withoutbuffer_heads"). Not having the count elevated causesmove_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 ofiomap_page_create()and lowering it iniomap_page_release().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 tomove_pages()anyway though.
Quoted 6 lines
Based on an earlier patch and changelog from Piotr Jaroszynski, except that this version actually puts/gets the page aswell when migrating pages using a copy, and thus actually survives xfstests.
Fixes 82cb14175e7d ("xfs: add support for sub-pagesize writeback without buffer_heads")Cc Piotr Jaroszynski <[email protected]>
Missing a SOB.
But apart from that, I've been running an identical patch in my test tree, so:
Signature · 2 lines
Dave Chinner [email protected]
Quoted 4 lines · Dave Chinner
Missing a SOB.
But apart from that, I've been running an identical patch in my test tree, so:
Piotr: do you still want to claim authorship for this fixed up patch, in which case I'll need your sob. Otherwise I can submit it under my name.
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Dave Chinner
Missing a SOB.
But apart from that, I've been running an identical patch in my test tree, so:
Piotr: do you still want to claim authorship for this fixed up patch, in which case I'll need your sob. Otherwise I can submit it under my name.
Sorry for the delay and thank you for handling the revert while I was out on paternity leave. I'm fine with whatever is easiest for you, and thanks for fixing up the patch!
Thanks,
Piotr
Quoted 7 lines · Piotr Jaroszynski
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Dave Chinner
Missing a SOB.
But apart from that, I've been running an identical patch in my test tree, so:
Quoted 7 lines
Quoted 3 lines
Piotr: do you still want to claim authorship for this fixed up patch, in which case I'll need your sob. Otherwise I can submit it under my name.
Sorry for the delay and thank you for handling the revert while I was out on paternity leave. I'm fine with whatever is easiest for you, and thanks for fixing up the patch!
In that case I'll happily keep you as the author. Can you re-cofirm your signoff for this modified variant so we pick it up?
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Piotr Jaroszynski
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Dave Chinner
Missing a SOB.
But apart from that, I've been running an identical patch in my test tree, so:
Piotr: do you still want to claim authorship for this fixed up patch, in which case I'll need your sob. Otherwise I can submit it under my name.
Quoted 7 lines
Quoted 3 lines
Sorry for the delay and thank you for handling the revert while I was out on paternity leave. I'm fine with whatever is easiest for you, and thanks for fixing up the patch!
In that case I'll happily keep you as the author. Can you re-cofirm your signoff for this modified variant so we pick it up?
Sure:
Thanks,
Piotr