From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 047D5C7618B for ; Thu, 25 Jul 2019 05:45:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D16C422BF3 for ; Thu, 25 Jul 2019 05:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033543; bh=CoBKqWiIa5zNNpcZbYdbs8ZD4v5CkUIQKUpQ5kFDWfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0lY0+0g8L76c3Vbr0Ss887pbjS/pt4X8G//2yWRzrWK0VJiJvFa2RhRaJpnYgjcG4 263Rpf6xnAIrOg/h1MhkWznnCxHsRNOUK8yx1XLDN15O8pO7RRpaOXgo+H/PY8fe4O c9uoplnI4xLji8jcNkAXk2yQpm6ja87J7Vn2XN3M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391348AbfGYFpm (ORCPT ); Thu, 25 Jul 2019 01:45:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:33034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391324AbfGYFpk (ORCPT ); Thu, 25 Jul 2019 01:45:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 C65D722BEB; Thu, 25 Jul 2019 05:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033539; bh=CoBKqWiIa5zNNpcZbYdbs8ZD4v5CkUIQKUpQ5kFDWfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XRMVbd7aFWI57NC4Z8cSyraK4C8y6FGgv/KWm6yXd3MOKh7fWMReERNmaz5HXaEdq LCukYPVWWCYgbEjUEGKFvPvCQvFoRwAsnnhdqqJzrm+RfD1Njb7FqTgeJ6VpTLGctk ou0tRdEHYHSqg+jKKGinp49DFQwBSfQPaiP7z360= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Dave Chinner , Christoph Hellwig , Dave Chinner , Luis Chamberlain , Sasha Levin Subject: [PATCH 4.19 242/271] xfs: fix pagecache truncation prior to reflink Date: Wed, 24 Jul 2019 21:21:51 +0200 Message-Id: <20190724191715.912215063@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 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 commit 4918ef4ea008cd2ff47eb852894e3f9b9047f4f3 upstream. Prior to remapping blocks, it is necessary to remove pages from the destination file's page cache. Unfortunately, the truncation is not aggressive enough -- if page size > block size, we'll end up zeroing subpage blocks instead of removing them. So, round the start offset down and the end offset up to page boundaries. We already wrote all the dirty data so the larger range shouldn't be a problem. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Christoph Hellwig Signed-off-by: Dave Chinner Signed-off-by: Luis Chamberlain Signed-off-by: Sasha Levin --- fs/xfs/xfs_reflink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 7088f44c0c59..38ea08a3dd1d 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1369,8 +1369,9 @@ xfs_reflink_remap_prep( goto out_unlock; /* Zap any page cache for the destination file's range. */ - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + *len) - 1); + truncate_inode_pages_range(&inode_out->i_data, + round_down(pos_out, PAGE_SIZE), + round_up(pos_out + *len, PAGE_SIZE) - 1); /* If we're altering the file contents... */ if (!is_dedupe) { -- 2.20.1