public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iomap: get/put the page in iomap_page_create/release()
@ 2019-01-15 21:10 Christoph Hellwig
  2019-01-15 23:07 ` Dave Chinner
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2019-01-15 21:10 UTC (permalink / raw)
  To: linux-xfs; +Cc: Piotr Jaroszynski

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.

Fixes: 82cb14175e7d ("xfs: add support for sub-pagesize writeback without buffer_heads")
Cc: Piotr Jaroszynski <pjaroszynski@nvidia.com>
---
 fs/iomap.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/iomap.c b/fs/iomap.c
index a3088fae567b..cb184ff68680 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -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);
 	}
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] iomap: get/put the page in iomap_page_create/release()
  2019-01-15 21:10 [PATCH] iomap: get/put the page in iomap_page_create/release() Christoph Hellwig
@ 2019-01-15 23:07 ` Dave Chinner
  2019-01-17  7:51   ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Dave Chinner @ 2019-01-15 23:07 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs, Piotr Jaroszynski

On Tue, Jan 15, 2019 at 10:10:28PM +0100, Christoph Hellwig wrote:
> 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.
> 
> Fixes: 82cb14175e7d ("xfs: add support for sub-pagesize writeback without buffer_heads")
> Cc: Piotr Jaroszynski <pjaroszynski@nvidia.com>

Missing a SOB.

But apart from that, I've been running an identical patch in my test
tree, so:

Reviewed-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iomap: get/put the page in iomap_page_create/release()
  2019-01-15 23:07 ` Dave Chinner
@ 2019-01-17  7:51   ` Christoph Hellwig
  2019-01-17 17:32     ` Piotr Jaroszynski
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2019-01-17  7:51 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, linux-xfs, Piotr Jaroszynski

On Wed, Jan 16, 2019 at 10:07:45AM +1100, Dave Chinner wrote:
> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iomap: get/put the page in iomap_page_create/release()
  2019-01-17  7:51   ` Christoph Hellwig
@ 2019-01-17 17:32     ` Piotr Jaroszynski
  2019-01-19  9:45       ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Piotr Jaroszynski @ 2019-01-17 17:32 UTC (permalink / raw)
  To: Christoph Hellwig, Dave Chinner; +Cc: linux-xfs

On 1/16/19 11:51 PM, Christoph Hellwig wrote:
> On Wed, Jan 16, 2019 at 10:07:45AM +1100, Dave Chinner wrote:
>> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iomap: get/put the page in iomap_page_create/release()
  2019-01-17 17:32     ` Piotr Jaroszynski
@ 2019-01-19  9:45       ` Christoph Hellwig
  2019-01-19 19:01         ` Piotr Jaroszynski
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2019-01-19  9:45 UTC (permalink / raw)
  To: Piotr Jaroszynski; +Cc: Christoph Hellwig, Dave Chinner, linux-xfs

On Thu, Jan 17, 2019 at 09:32:32AM -0800, Piotr Jaroszynski wrote:
> On 1/16/19 11:51 PM, Christoph Hellwig wrote:
> > On Wed, Jan 16, 2019 at 10:07:45AM +1100, Dave Chinner wrote:
> >> 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!

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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] iomap: get/put the page in iomap_page_create/release()
  2019-01-19  9:45       ` Christoph Hellwig
@ 2019-01-19 19:01         ` Piotr Jaroszynski
  0 siblings, 0 replies; 8+ messages in thread
From: Piotr Jaroszynski @ 2019-01-19 19:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Dave Chinner, linux-xfs

On 1/19/19 1:45 AM, Christoph Hellwig wrote:
> On Thu, Jan 17, 2019 at 09:32:32AM -0800, Piotr Jaroszynski wrote:
>> On 1/16/19 11:51 PM, Christoph Hellwig wrote:
>>> On Wed, Jan 16, 2019 at 10:07:45AM +1100, Dave Chinner wrote:
>>>> 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!
> 
> 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:
Signed-off-by: Piotr Jaroszynski <pjaroszynski@nvidia.com>

Thanks,
Piotr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] iomap: get/put the page in iomap_page_create/release()
@ 2019-01-21 15:17 Christoph Hellwig
  2019-01-31 23:28 ` Darrick J. Wong
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2019-01-21 15:17 UTC (permalink / raw)
  To: linux-xfs; +Cc: linux-fsdevel, Piotr Jaroszynski

From: Piotr Jaroszynski <pjaroszynski@nvidia.com>

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.

Fixes: 82cb14175e7d ("xfs: add support for sub-pagesize writeback without buffer_heads")
Signed-off-by: Piotr Jaroszynski <pjaroszynski@nvidia.com>
[hch: actually get/put the page iomap_migrate_page() to make it work
      properly]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/iomap.c b/fs/iomap.c
index 987fefc054b4..47362397cb82 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -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);
 	}
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] iomap: get/put the page in iomap_page_create/release()
  2019-01-21 15:17 Christoph Hellwig
@ 2019-01-31 23:28 ` Darrick J. Wong
  0 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2019-01-31 23:28 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs, linux-fsdevel, Piotr Jaroszynski

On Mon, Jan 21, 2019 at 04:17:02PM +0100, Christoph Hellwig wrote:
> From: Piotr Jaroszynski <pjaroszynski@nvidia.com>
> 
> 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.
> 
> Fixes: 82cb14175e7d ("xfs: add support for sub-pagesize writeback without buffer_heads")
> Signed-off-by: Piotr Jaroszynski <pjaroszynski@nvidia.com>
> [hch: actually get/put the page iomap_migrate_page() to make it work
>       properly]
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok (apparently I forgot to ack this explicitly...)
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/iomap.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/iomap.c b/fs/iomap.c
> index 987fefc054b4..47362397cb82 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -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);
>  	}
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-01-31 23:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-15 21:10 [PATCH] iomap: get/put the page in iomap_page_create/release() Christoph Hellwig
2019-01-15 23:07 ` Dave Chinner
2019-01-17  7:51   ` Christoph Hellwig
2019-01-17 17:32     ` Piotr Jaroszynski
2019-01-19  9:45       ` Christoph Hellwig
2019-01-19 19:01         ` Piotr Jaroszynski
  -- strict thread matches above, loose matches on Subject: below --
2019-01-21 15:17 Christoph Hellwig
2019-01-31 23:28 ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox