From patchwork Wed Oct 10 00:14:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10633735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0FE846E4 for ; Wed, 10 Oct 2018 00:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFBDC284C9 for ; Wed, 10 Oct 2018 00:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3B3E28FE7; Wed, 10 Oct 2018 00:14:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68CAC28F95 for ; Wed, 10 Oct 2018 00:14:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7673B6B0292; Tue, 9 Oct 2018 20:14:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6BFC56B0294; Tue, 9 Oct 2018 20:14:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 450DF6B0295; Tue, 9 Oct 2018 20:14:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 02A626B0292 for ; Tue, 9 Oct 2018 20:14:50 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id w18-v6so2676336plp.3 for ; Tue, 09 Oct 2018 17:14:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=cfF3N75h3lxZbqAALtDnQMXfh3h0NJ+K2oVFMPxgqNM=; b=VpU4729KFdbANaG4QTPIpe8IJI3LHDGQKPdqAh/4gbNwTCapIlbx3bi40PuJ72c8F5 xxW9KUSwoqYoT9x8O+p0DNr2JLmfjlM3W4L9AyPWWX2bMS11dqPxbw8kjzrMt3GE4LFX 9JdItGQ1wbU4OoakwJNJrjr+5cHEs0mqxsvk/3Bag2pn/7B2/yrAMZ/ngxpC5IkGuS69 h5zT72xc73usStqketaKXKZWHnt7qw1Hb2FuMoJ2bZE/HQODsURHMwZIzFdaxrhx4age IQNAuE4gIzOkD6brwWOlBhfBn0B2CLV7Nd5Dv/XNiot3OvJUGaF5kKN9mLUDx6L3JN80 MnJQ== X-Gm-Message-State: ABuFfoh/bZnQAL517NTcmhhTzr0HhX1goK3qyFRPWGetN8f1w79Kqw08 Mit1r0AOF3nGC6th9idWTi0oSG1hxwgOX25RBfy6PqieVF/ZmKkyV6WtR3AB8qvokRenWjwlPt/ ouVnA3L8RNZ9e6ivFPgVeBBddHD2JinxBCHMcJvSUJCg9atfIkX9RG0yHIOULLb9O9A== X-Received: by 2002:a63:ea43:: with SMTP id l3-v6mr27834546pgk.427.1539130489666; Tue, 09 Oct 2018 17:14:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV62cV0WDb/17KPA/k+jr88MJdzxbfEBvr+QYpMHy72p5C0Zp4U6oUcLSQ/ck5GHjRS/gpVtR X-Received: by 2002:a63:ea43:: with SMTP id l3-v6mr27834519pgk.427.1539130489114; Tue, 09 Oct 2018 17:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130489; cv=none; d=google.com; s=arc-20160816; b=Xn5iEWimyGQszXKorvtM0v9SAnDMFlBEaDK1VvNBVndPpxCm2znxedmNCuKQNaNcEF 0FbqOqrqcnVTpyYdhBcIR5UUirRH+jdjkg3tm/2IdFqGYAlarmNs+kQun1MTEnPHQ1DP j75+Q0LhU/tQ825xTdK9uUk4+goSiF0AQsTbldCcSfUyNAn0h0DRObRIkVF9XMU7iVck InH5YMSV4tSQ2hROUxxRWmzOXJ3o9kfon3Iw7i754gF7dJmnwNOXuP2W4UzD/Mlm7TE4 dzUkYLG45VujzfuRP6G0MyZp1F5d+l3EsE5xYcQAorRtBFHqPcqxTVGS8McxoM7rO7Yd IzOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=cfF3N75h3lxZbqAALtDnQMXfh3h0NJ+K2oVFMPxgqNM=; b=Mz+R9k7w4jL6dcZqgVFvMf/rJVqxXvmoTjw1QsGZZA3+jP74COfy1xgLn1m9m61ZYk eoub9V582EmayVsnhJt/4L5gtoOsA0uY/zxALnxJlrIkETicQrpqXZkZx6pbmHepTQs2 GQLPsHs6Qp+y6ySVrp8GgAs3+vwxhSB6N0QJUbbodEC2u4E5dwb0nIdJLpoFQngZbq3o ubU89QuCl95W0boXheeZ0hABQC8jj16k4DSi0T9CgdlVDxJxctOGAyfIUInzPI7Nzvpc z1+r/ZvlVzhOo55eHqU7fLl9yR4SyCWjwSAqOuywqNLmnYcK0vAAY7k/3MPzH44mj+pZ bOFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=1eaks0kI; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id g16-v6si18836101pgi.329.2018.10.09.17.14.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:49 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=1eaks0kI; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9A0E2G4123299; Wed, 10 Oct 2018 00:14:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=cfF3N75h3lxZbqAALtDnQMXfh3h0NJ+K2oVFMPxgqNM=; b=1eaks0kIJfxw2JXtKkfWiqTh+Gl2LR+tWeEWHnEg4GCd4DnEOvme5zIkKV8W4bsGvDay VQXLxtscuWkUqX9Xkg6Guzxm1dtKo6HlvbR/uat2zVHIsAXI8Vg0BsqWjywaeciTJD7H S8SZdtD2TkOZJl8/xzQNFmFW4R+tE3R24IqhtENT3T6DkrbCUdpVJW0YYyd9mMhAYxHk PXoH/3DzheuC9d+vnEgdat6Wr2YJom8KnmsxfO3vx4tWIHfAf9u6OSapJrPEDnlZyO2u 7Nj0SNhYUtuKp0jMwdAICoknacdyyhiGhuSRcQ07boUQ+8u9UBsU15OtcuVE+CzdI2ox kQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmftrvu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:48 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0ElQr016709 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:47 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0EkIA022134; Wed, 10 Oct 2018 00:14:47 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:46 +0000 Subject: [PATCH 24/25] xfs: fix pagecache truncation prior to reflink From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Tue, 09 Oct 2018 17:14:45 -0700 Message-ID: <153913048498.32295.11135506483495360686.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=773 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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. Signed-off-by: Darrick J. Wong --- 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 ec09e2783afe..0f4678920240 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1328,8 +1328,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); /* * Update inode timestamps and remove security privileges before we