From patchwork Thu Oct 11 04:14:59 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: 10635983 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 EBE3E933 for ; Thu, 11 Oct 2018 04:15:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1C362787C for ; Thu, 11 Oct 2018 04:15:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C581E2A63B; Thu, 11 Oct 2018 04:15:05 +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 69C082787C for ; Thu, 11 Oct 2018 04:15:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D963B6B0293; Thu, 11 Oct 2018 00:15:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D45FE6B0295; Thu, 11 Oct 2018 00:15:03 -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 C36A86B0296; Thu, 11 Oct 2018 00:15:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 944536B0293 for ; Thu, 11 Oct 2018 00:15:03 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id q6-v6so7525946qtb.14 for ; Wed, 10 Oct 2018 21:15:03 -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=pleIHv/sRduv8+OkUOJBlq1ti8nIBaJ9AMLqPSF5HiA=; b=kCwHYwLtWx2SpGoO6XacmN4mhC8pBcTxjpb71QrymNTablRzDOsZnHNwtW0cbcyYN1 MuqFvDcq8TtY4PKENZiEmEYmSfriV9WCDw8BWnuFhZPBM0on7gI/N3Ubd5Qs5FAQ4lyv k6OgM7KusDnZvcfZaScE4zLaRC47+aa2w5f+bKPenkoZbxxE1lt4ygUoQCYN2wT0K8Vk RVK0V+XTqqGRk33xgYA4bvc9hK09d/9F0vtxYJpcnEBLXZx7gTBFKXwhI93N+76MxDC0 c/jYaa/Elsn9jIBgZ8PD8Th5+ZlizUEBvAtpuaXsxJISXjJBtzd3lkszOmdGjqrmDLxu bRUw== X-Gm-Message-State: ABuFfoiFr6T1UPneizyvYeJ5kCJNFq1MWPsL5Zu9spgYoTuCz0IXsH1o wrgMRkOuyjX3NzyAmmBz2ihMBxHa9Lo5rSkmKwRJNUveJ45COMFI1IOXHKpqCCJqni5dv6ZnklP SSGth8YGOCRXxLN+2RsxyfHs/G3VhXfkPYV41L3BoIP51Z5IPTftVmnh8Bolq/UPBAA== X-Received: by 2002:ac8:5548:: with SMTP id o8-v6mr16186217qtr.283.1539231303321; Wed, 10 Oct 2018 21:15:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV60TAPgF/02e/uw3EpCxLxc71O4aD7BIshyBMYpDd5rnNlTtEm80lJAsLfubXkyJE4W27AgG X-Received: by 2002:ac8:5548:: with SMTP id o8-v6mr16186190qtr.283.1539231302865; Wed, 10 Oct 2018 21:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231302; cv=none; d=google.com; s=arc-20160816; b=oCAX5LjOyRajOWJiCe75g8W5upwQ9NMVoLNNr7gKszagyDP4t2z0ybtNdZV8a4fkBl w8frE0n1cH+njdO5+oTN6BHna0E2vSjk+L/Zx4FMOCek49Wn1xUW0MEPhmwzuQkKBkzG TYLylX6vEYL0dLbbgx58ZocKUDi+ZXpBU0E4q7fiWNbVdGUkxh4AkxU/bW5fS/yydKq1 4/pa1nrgxIOd+4vIYzCMseM6RoM3ieZbSIc+J1aCCvngcKoE6f2pVxRcWDo9U1lnGh0T fkQEVm9wM+wNTUfS6YYz1tS1C+fr/7rgTXOzPZB5GZ7vEI2cXBSDYMtiVYjge1+tyxAn ctzQ== 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=pleIHv/sRduv8+OkUOJBlq1ti8nIBaJ9AMLqPSF5HiA=; b=KGQyHXZQ2Bq1GusU5HhTK2FgMsX6u5U+B98F9Es63W8BlvO7ufYLPGWXTwScJNEvtj 2RfUXURdtp+VSbNOWz7XDOgu5HT7+5LLy8p+F/gzcEfHZ5yXMJY8iaIyw+LaywTi3ow6 xU41PLFuky7aZtmQIXB30+VPhAdi8BRw2UAxHn6gsg0gxwQVA/aZkNRiZO5Ivd8+73Ei XkGje2oViJpJ5atv3XWh5hO19UembQKiTxiP7mxn5vjvl3qHM1M9/LVhgos0cfWUL/pD iuXkln2CEl00s08iaEJv+REABa7F2u7znCf8Box1MtSqYu5Z71mq9ySNJm4DbHaqsJi0 guxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=oqCDDeqg; 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 h1-v6si5143925qkj.159.2018.10.10.21.15.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:15:02 -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=oqCDDeqg; 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 w9B4Dte0058453; Thu, 11 Oct 2018 04:15:01 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=pleIHv/sRduv8+OkUOJBlq1ti8nIBaJ9AMLqPSF5HiA=; b=oqCDDeqgvBTu19DRen40L0j00QC3X+PzEg08HfGvtV4MrpnTqSGjecGy7V2qOe0ImjeM zhdZ/sBWzQccLz7eII7FrEWxTRRpTYzd1ZeVxR4DbFm5K6nQDGVw/ef5K5Xi+UC0xKgb BtrXlqrwtvuL+XdJ2DOXMSJyNXx/4fuJR5ouBOE40E9fpW+QzPtRPJY39FvM4vyU9m9d 7uEiy6A8AM3m5lX/P5Os7A6MrQ5NrvshFRgRvGbnTY7+b20RUriDEDsvhQSYF7xdnN3U WxTg4dGwtg38VogxgsA0pnBEtd1cIcod03VjIgUlrXogqgymW0+4Ptt3CjBSjsQ1cye+ AA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mxn0q9e3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:01 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4F1He020909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:01 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4F0K1009814; Thu, 11 Oct 2018 04:15:00 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:15:00 +0000 Subject: [PATCH 21/25] ocfs2: 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: Wed, 10 Oct 2018 21:14:59 -0700 Message-ID: <153923129911.5546.12641183057086407273.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110040 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 should be fine. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 851ba3ae7ce8..b9e0418a1974 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4870,8 +4870,9 @@ int ocfs2_reflink_remap_range(struct file *file_in, SINGLE_DEPTH_NESTING); /* 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); ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, out_bh, pos_out, len);