From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f195.google.com ([209.85.210.195]:40482 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbeLNF6I (ORCPT ); Fri, 14 Dec 2018 00:58:08 -0500 From: zhangjun To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Weinberger , "Darrick J . Wong" , zhangjun Subject: [PATCH] fix page_count in ->iomap_migrate_page() Date: Fri, 14 Dec 2018 00:56:01 -0500 Message-Id: <1544766961-3492-1-git-send-email-openzhangj@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- 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