From patchwork Wed Oct 17 22:47:06 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: 10646471 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 904D415E2 for ; Wed, 17 Oct 2018 22:47:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81681288C7 for ; Wed, 17 Oct 2018 22:47:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 750BD288E7; Wed, 17 Oct 2018 22:47:18 +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 1566B288C7 for ; Wed, 17 Oct 2018 22:47:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 046CF6B0291; Wed, 17 Oct 2018 18:47:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F36E16B0293; Wed, 17 Oct 2018 18:47:16 -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 DFEEA6B0294; Wed, 17 Oct 2018 18:47:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id B2ED16B0291 for ; Wed, 17 Oct 2018 18:47:16 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id b76-v6so17579304ywb.11 for ; Wed, 17 Oct 2018 15:47:16 -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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=ft024OZMu1cvnT2IukJtt87Itp//GymrvlpB5tKXh4hynkyfOrITrtoWVvVfv5pz8U 4LAAsjgvPC9ypYRr/l4qkMPi8RU7woJeIgD2PrwVtuoJQgJWXtff32/os2VsxTFdw+8B 6MmxZCi3eOuCLoOu0WRKnHMm/iEP3fPpGx1tLlqwvrMw5BZx7JnsSiTFAzyinQH5i+s9 Hnw9XQV9MtvekesmQ8HsOZpuyBMYcio6KI2wF8th6XuQLxfCYS+RbRMV2BYKfbhEc/Gk tZQXJw5VscSCbhX2ZPKKDPQQMarlgNerP6FqzJVkUtqajEnWvcEgdl3Gzsc/ce+9YJzW a8XA== X-Gm-Message-State: ABuFfoj+AOxFiEASAzh12fFvzu71fA3ekIYVJeWKiiA96EyH630kR2OW k+4VGkMWetWmE8WFADbdbehKUpbHHW6GXnpveIzpceOlfjEixM8N0c7Lq45KghxpCa5QfTYtVE5 J7XlgsLS/gKA6lg0OoSa3wDti0CTcDQY8uOvtWkzYqdhrDYQOPMfef0neK1zaxl/rBQ== X-Received: by 2002:a81:ed8:: with SMTP id 207-v6mr15900477ywo.425.1539816436494; Wed, 17 Oct 2018 15:47:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV613pH3TLNHtRowMhqxy9EEy1crr7W9Mf+0XH8KGzZX+mK+Jbt1YClX2V53nYqDMp3A8rH6U X-Received: by 2002:a81:ed8:: with SMTP id 207-v6mr15900460ywo.425.1539816435856; Wed, 17 Oct 2018 15:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816435; cv=none; d=google.com; s=arc-20160816; b=jEruccukccTYOLPTqHfpPBmOTYUR6UqSFtGB5SbJPQ47k7fJqDX3oyCSd9yCcKY+0t 1AlVKMqnEkp/3a6z20axbfLey5g8x+KKavhkTulEdqgrmi1ptI5qRQXtMD655vUV0iij z7OujQQpPkmd2rykTzQb+MYPgoavc/ceNtluGPcf22qu5qwAT0x54DKA1tyFD9XdxF5k DsSknHar+IrOtN6qj2QdWLGy7KHNqkog/bqGehn5n2Gt9HHDmsnN0vSGanavCmDOqe7O 3lkTWImZaxeceac39fQM2zH1FumkINGpZ+Cy8VauNJ784PUUy21Elu9CwbDEWvXYZA7D bW0g== 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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=bMlDzQksZeTP0b2k0s6NQyHUMN4NHmSWElqwg4iVOcExmRDc7Ac8Mr4Mv1ts3VPfxp Kll+1odipoUis/Nd/snHc1KEzpRsGrG3fUhZHKI7NTK7kceQ90xUNunbOFIx7WHOCM9v D6INlL9EE9QgvVQLX2MTshlV++DhDAW24q1LiaJcBsJCLjBSexZ99qUInk5pGWheeHGo C0JMkLT+PA8Mr6P/nmbWQwKhTjXaRakSPMPq8lXW3EH9t/OoJKNwu2BeVJLAcoFf2+QF b9Jx3etq77Sk1QVcjg2brdCQiUvlftkoMOibJibTFr4WoIPVlnbAqG9fASasrkzSU5pM eZog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=qoLvGvXL; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id h5-v6si3930282ywb.278.2018.10.17.15.47.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47:15 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=qoLvGvXL; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 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 (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9HMhlRq048467; Wed, 17 Oct 2018 22:47:15 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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=qoLvGvXLW/mrOXWPJD7EXkzG6Z31dK3ldUbZ74sXxqpN0oTWNkjoEqRr/lcWC4x+PKVF t0QUEBQw0LlSo7KHBWE5XXuRt3y8VMEG/+V6WiL3zutRxXaLCAvDISDzaDN6CbVODyov FWixDpXUva3ebZg1ZTziiVmKnUAfhTjRDMx4E5+VVusNDonLaEPXM7S4Fwg73obGiLrH uyVUUI80d+OiAx28Rk7ld79sY3W3f0JZtkOL6KVa9X0dMdlJrS+vpHDLyq3eNCoojx1X IpfRIASRl6ZGM49hli0UvK8hrQma8o2OzZRG8QozLQBC1Rhn9e2ptbLmTFVMXQntL+TI Rg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n38nq9t3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMl9Qf012414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:09 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMl8er029254; Wed, 17 Oct 2018 22:47:08 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:08 -0700 Subject: [PATCH 24/29] 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, Dave Chinner , linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Wed, 17 Oct 2018 15:47:06 -0700 Message-ID: <153981642640.5568.16793693439327747778.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=947 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 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 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 --- 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 9b1ea42c81d1..e8e86646bb4b 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); return 1; out_unlock: