From patchwork Sat Oct 13 00:08:11 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: 10639685 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 59FA35CAF for ; Sat, 13 Oct 2018 00:08:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47CA02B096 for ; Sat, 13 Oct 2018 00:08:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF292B877; Sat, 13 Oct 2018 00:08:23 +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 C1E5B2B096 for ; Sat, 13 Oct 2018 00:08:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DBF46B028A; Fri, 12 Oct 2018 20:08:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 78C586B028C; Fri, 12 Oct 2018 20:08:21 -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 67B946B028D; Fri, 12 Oct 2018 20:08:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 27C8C6B028A for ; Fri, 12 Oct 2018 20:08:21 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id 25-v6so10070531pfs.5 for ; Fri, 12 Oct 2018 17:08:21 -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=BAmjaVNwsxPVB5sUSfTAqrwEVWB2JGb7rkeHwzu4sgmnTkXNjhceJsePw4Mt9UClo3 JUnuNmYMXLixlBwQd88wbw3VNwud4Z7nHkQix5KmccoTep2ueFP70uPuvmmz+5ZPPRC0 8Qorjd5XZO1LepyT9XUPofANB7z9R+DTTdznW/zZNJpxtSds4rG4TrDRULbLcP5kSxO8 rU/RdOXvFugipyoP29pulMm6GXi4E2waQCa7Ozklscz0EZlqR9vs2+xkrEtGHYMydfwE iDpJtzwEeD/rXnJj6oBV/cxWYu8CJXIgWv+eQmWIJKrnVVEVh27XhJp/WdVlD/npJmdg cDHw== X-Gm-Message-State: ABuFfoidnfw7C5xO88BpUgoK6Uz/rpZO4RyVBcFzpxB99J/XRYYCFVyX zI0KIUbqcgD/6p/7Yj9azFeRiLcB2+OdIzHd0gmK1LI/FRy6OQMd257zRMj/kx1frzHqgLqUymD rqrsYxHCBtuoLxzLQenRiFyoJjVgotiJ1UFUjdJZJCRIwGRhLncQ0l7ZaR1D7IK42Kg== X-Received: by 2002:a62:18d3:: with SMTP id 202-v6mr7989720pfy.143.1539389300837; Fri, 12 Oct 2018 17:08:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61LySgiFjm5lLFL7kFDAv4nHqL1EwjQ+0PB7RHy/OPCmkVCc3xX1BhestGycKIeklIzqOgL X-Received: by 2002:a62:18d3:: with SMTP id 202-v6mr7989675pfy.143.1539389300193; Fri, 12 Oct 2018 17:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389300; cv=none; d=google.com; s=arc-20160816; b=gyKwM9RiL7SalJP5oU8N4J6DNFs6anQC9DBVIfGLCFdZjHHpH52FBPlAGQdYPVuHT9 3OZN+PQnxXneq/1A6op1k1el7knJITGJyT8Uxt9O2jgWvJ602st2KsN8FeV9Qm/3d6ZC X8/dxDZ36RMe8tGmjg/bZTHnDba6b6PofxvKwM73wt7ABJhk6rmaAOuot84lPlPCv7sD jtEBFMMF1OruiEQ0rLYrOCqiIWaq/jJxxrXv3d5DRD9UH1dlWtsIqBiJtVz3TmRs+akC 9NSSgkD6pGC8YRdafYcqtWRoOSttQsHCnSoHmZkzLgs3Iflr9QzzesX3lH5aBrUHB9Pq LIUw== 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=HnIyD7ZfsFb5M5QVYuaukM/afDLaBfCBONV8B1fejvCBzGXr1b+buzdCd89gln5IFG o0GC9TAERvDdNJB4/3HMQgWNaQMYkKWY1wQaoWj5hfdXJBfMlFfxRDVlj0Fuo2kMhtfJ PBUErH7rDkHyVSbIGAVaLv2EXd7Fh5NYDbq6cP1kzU2mOEY7Z50/so6g/B0EPZ2Zt/EC 4IxfiWdji8xbwgBBwTY2LHDB14nPvIpYf1+O9AmyQ5NgVjGEHRhrQW+FgT5D5mhLX9P2 EJ/W3iqMeYPhFr+LYTEVhbPXdSBC0urqQXWepXkGNMaVz/TJqFoV1C2RFwAMj/Jcq7i+ Elyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=kqHFE6Mt; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id w11-v6si2615205pfn.212.2018.10.12.17.08.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:20 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=kqHFE6Mt; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9D03uDA104670; Sat, 13 Oct 2018 00:08:19 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=kqHFE6MtSWI5Oyu8aJl0GaLuQpX2m1466590GNN6ly7cpfUuVTv3SEo3+TLDM6Fg1mhx Ol6d9sjB6KOzK40YWMQmZFn8WuvXmhCus9cxkf1mmvdnT/aLhjN3fjA0jQHYCBQooo38 ybDmqi+zTphvGclYsgt1dhSVnQNNVPpaTQCTGF1UkeXM/cverhXQuGRgNXth/LJobmYb Al5aJ8vpGnmxQx+ewsgJL+w3OJDU1MQ+QggZC4VOYc6FSjvmq0IEOUjfThj2ClTSSFrw yElDlD8Rqhw5Ib9b4rwv1PV//qsKZDlQpgFVWJCLCm2TpYczeIzdmlvf1tr/sYJHp+IH PQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnprnfmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08DRU021198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:13 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08DFM020092; Sat, 13 Oct 2018 00:08:13 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:12 +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: Fri, 12 Oct 2018 17:08:11 -0700 Message-ID: <153938929138.8361.13789018254018500647.stgit@magnolia> In-Reply-To: <153938912912.8361.13446310416406388958.stgit@magnolia> References: <153938912912.8361.13446310416406388958.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9044 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-1810130000 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);