From: zhangjun <openzhangj@gmail.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Richard Weinberger <richard@nod.at>,
"Darrick J . Wong" <darrick.wong@oracle.com>,
zhangjun <openzhangj@gmail.com>
Subject: [PATCH] fix page_count in ->iomap_migrate_page()
Date: Fri, 14 Dec 2018 00:56:01 -0500 [thread overview]
Message-ID: <1544766961-3492-1-git-send-email-openzhangj@gmail.com> (raw)
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
next reply other threads:[~2018-12-14 5:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-14 5:56 zhangjun [this message]
2018-12-14 11:25 ` [PATCH] fix page_count in ->iomap_migrate_page() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1544766961-3492-1-git-send-email-openzhangj@gmail.com \
--to=openzhangj@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard@nod.at \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).