Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10428820ybi; Wed, 24 Jul 2019 23:03:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0HCvH8Gq6eQDAyKfomFVysXmmZwBl3/VM84Ps95IB2fbRAgaA7J8DXz7LmCUie1k6st2T X-Received: by 2002:a17:90a:17c4:: with SMTP id q62mr92685594pja.104.1564034612933; Wed, 24 Jul 2019 23:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034612; cv=none; d=google.com; s=arc-20160816; b=CWIoh6khiYneM6i9MEpp2BfF2DGgLQA6gh9f2aL/yeYWW+5/FrL+Z9iqI3DkCgdRfb 8mt5Y//L+Ge9AP6ppnWjIp9yMvtkF94wsY+VA9ODnVSI7dw8Oe4bd8zp8L+/B+zoOSNJ 1JbM793Iz6G2/I2DBVXRH46hdcfFUof0UnZNX/oCD3duYfUTSNYytkFh9xYIB+i6Z5d5 E3EIdQF4aoJO0A76BGNaXm8zEt2iK9K7cifzaFDFsO/L2wzZyjjxNXnnAJTQRlGLdMRj wQ8QQi3R6Swff7dMrJfmL/U+M5AKysUT8AzafWSUOh79aYasUpzIQGx/EptOLnuzw/Ir Fq5Q== 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=lsbDygZBSu7oGBwZDe1evmQAZt/D3Xisd1A+lff4JoU=; b=NCY/QduUfKlQ411k2Heug4TcyQm2o35UnS+wGQewvzi4ozsyT129NERY5yWmJxlI19 6rFgtJLq1my3GZ0FoXIexvMGZYKuqWdBjn7fxzO8ynyEhelHqwf9ijod+b5KlqxTy2iL DnjULh0+hLfqQX0bbMkOFe9Qn0XDmkItdHmIiJ8CPeYlFb86aAB8HqiE4ZH9EMUKWJdM Wmc3rzahRXQG3XgVBCI2wtxsQxDHkX08GrUuHl0NoKVhKwmdxyMveuff6AUD3+dMWEJI 5vzlyezzil66MxQnszsfCntgCuLkyXF//zDj+aAknLX880J53OrgH+cL8b5EOrh8tDfd upZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XRMVbd7a; 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 h189si15796207pgc.236.2019.07.24.23.03.17; Wed, 24 Jul 2019 23:03:32 -0700 (PDT) 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=XRMVbd7a; 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 S2391340AbfGYFpl (ORCPT + 99 others); Thu, 25 Jul 2019 01:45:41 -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