Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4078722imu; Tue, 18 Dec 2018 08:43:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/WhL8f+G6kPmVtBGgQyNmSOzGfSJiB0cASF5mszx85M1Sb4Khv7e2mkHwUgRjdcWqNu1nJ0 X-Received: by 2002:a17:902:30a3:: with SMTP id v32mr17341588plb.26.1545151419634; Tue, 18 Dec 2018 08:43:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545151419; cv=none; d=google.com; s=arc-20160816; b=bmeh1L0pgtwYdYtoUw+z16fkitXpopN/hWTOcC8dnYW2N/xkOgpxOOw1i7nsPg6Iez f5GiISEkfJXry4oAg6kLdYyjpWu8M9El/r23fQr/8KGOE/oB0IA3A/c4qK/YMe64JTUM tM2iw9hpG5px6FsoeVX0qjM4+ipgbL89PY2VMpwPctLBMktw7ZuQKkYy8mexgdKbFPiP hoKMF23hGXEqfXjsaDcYNFqVcUQ4Y839fjlZMH23b9OYJVVXStW7/6FffknwtgFIY5oQ 7WqkVhL2K5Buej7A/pAxJ0kdF8pu4BsgKOFNbsOCQRlkmeMfoSRblRprYs/FlI01dIix 28DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yaKQ63bILXYll1rzb9tN+UmSG909zfRy1QYQpSQrgIA=; b=kB4ziaibuZTeZpgEKaaSdTIlAWWaaWXu5e/S7CtJfvh/9cnYiNOXLZiXkzqyN+v2DZ r4IJKR49TV0oWCes1XBmnltyHhxrIrHhDsbHMk3nwATqgFkEI5Ep1ACcj/E0xrxw7IpO ripq2CMeKnlJvUq0YtrbFROxGPE8omIWiF+GmvP4WMH5WvDhNcbZMKpfqv4z6s2L5y+C JvRQ2UgeYDpXPTUi6aW/Aht4bc8SSbL8otAqwIojP5LNqqvkRkt0TFbtfKotPftQNk2N fpe1QXTMssgK88ilSb8zYuvZ7Fe4lZpy5qbwHMA2Et7GquznttzcDaOJ3JcxISX2jqjH AoDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UauZZBu1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u64si13700093pgu.534.2018.12.18.08.43.16; Tue, 18 Dec 2018 08:43:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UauZZBu1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727399AbeLRQkx (ORCPT + 99 others); Tue, 18 Dec 2018 11:40:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:38044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727380AbeLRQkv (ORCPT ); Tue, 18 Dec 2018 11:40:51 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB742218A2; Tue, 18 Dec 2018 16:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545151250; bh=7T1tSXXB4hz/K/C1nnFbDfPij8X5uoYpihcGDmvnXfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UauZZBu1QZOytjrIB0CnTYSQ1TujwYEBO/ajwQi6XC/6S5RU+ZjOsbwU50fQJ4oXI 83fS7Xml8JFa5+/92mbBR17E/YuqejZX63hL5vNgi0+roeabyXDF6C2Qjr5PUvWN9I 9gnKsna4PtOV5/quqDiF/csv9sus3Kng2IADAyZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Piotr Jaroszynski , Christoph Hellwig , William Kucharski , "Darrick J. Wong" , Brian Foster , Andrew Morton , Linus Torvalds Subject: [PATCH 4.19 11/44] fs/iomap.c: get/put the page in iomap_page_create/release() Date: Tue, 18 Dec 2018 17:39:23 +0100 Message-Id: <20181218163928.831329181@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181218163927.119623235@linuxfoundation.org> References: <20181218163927.119623235@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Piotr Jaroszynski commit 61c6de667263184125d5ca75e894fcad632b0dd3 upstream. 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 (https://lkml.kernel.org/r/20181116114955.GJ14706@dhcp22.suse.cz). I only hit this in tests that verify that move_pages() actually moved the pages. The test also got confused by the positive return from move_pages() (it got treated as a success as positive numbers were not expected and not handled) making it a bit harder to track down what's going on. Link: http://lkml.kernel.org/r/20181115184140.1388751-1-pjaroszynski@nvidia.com Fixes: 82cb14175e7d ("xfs: add support for sub-pagesize writeback without buffer_heads") Signed-off-by: Piotr Jaroszynski Reviewed-by: Christoph Hellwig Cc: William Kucharski Cc: Darrick J. Wong Cc: Brian Foster Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/iomap.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/iomap.c +++ b/fs/iomap.c @@ -117,6 +117,12 @@ iomap_page_create(struct inode *inode, s 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; @@ -133,6 +139,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); }