linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix page_count in ->iomap_migrate_page()
@ 2018-12-14  5:56 zhangjun
  2018-12-14 11:25 ` Richard Weinberger
  2018-12-15  4:26 ` Gao Xiang
  0 siblings, 2 replies; 8+ messages in thread
From: zhangjun @ 2018-12-14  5:56 UTC (permalink / raw)
  To: Alexander Viro
  Cc: linux-fsdevel, linux-kernel, Richard Weinberger,
	Darrick J . Wong, zhangjun

IOMAP uses PG_private a little different with buffer_head based
filesystem.
It uses it as marker and when set, the page counter is not incremented,
migrate_page_move_mapping() assumes that PG_private indicates a counter
of +1.
so, we have to pass a extra count of -1 to migrate_page_move_mapping()
if the flag is set.

Signed-off-by: zhangjun <openzhangj@gmail.com>
---
 fs/iomap.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 64ce240..352e58a 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -544,8 +544,17 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage,
 		struct page *page, enum migrate_mode mode)
 {
 	int ret;
+	int extra_count = 0;
 
-	ret = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0);
+	/*
+	 * IOMAP uses PG_private as marker and does not raise the page counter.
+	 * migrate_page_move_mapping() expects a incremented counter if PG_private
+	 * is set. Therefore pass -1 as extra_count for this case.
+	 */
+	if (page_has_private(page))
+		extra_count = -1;
+	ret = migrate_page_move_mapping(mapping, newpage, page,
+		       NULL, mode, extra_count);
 	if (ret != MIGRATEPAGE_SUCCESS)
 		return ret;
 
-- 
2.7.4


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

end of thread, other threads:[~2018-12-15 11:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14  5:56 [PATCH] fix page_count in ->iomap_migrate_page() zhangjun
2018-12-14 11:25 ` Richard Weinberger
2018-12-14 12:26   ` Gao Xiang
2018-12-14 13:35     ` Richard Weinberger
2018-12-14 13:55       ` Gao Xiang
2018-12-15 10:51   ` Christoph Hellwig
2018-12-15 11:17     ` Richard Weinberger
2018-12-15  4:26 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).