From patchwork Wed Oct 17 22:46:39 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: 10646403 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 CF263157A for ; Wed, 17 Oct 2018 22:46:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A6D288C7 for ; Wed, 17 Oct 2018 22:46:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4C2B288E4; Wed, 17 Oct 2018 22:46:46 +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 59804288C7 for ; Wed, 17 Oct 2018 22:46:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43D776B0006; Wed, 17 Oct 2018 18:46:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EF9B6B0008; Wed, 17 Oct 2018 18:46:44 -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 244056B028B; Wed, 17 Oct 2018 18:46:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id D1B256B0006 for ; Wed, 17 Oct 2018 18:46:43 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id z12-v6so28124122pfl.17 for ; Wed, 17 Oct 2018 15:46:43 -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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=JmrTDGEzzVr/nCbsXoeCXukK2bxZvloDGw7Vavm9PQ+HZw5B+j3KIgPn9VDrwysBoN BHafYsu78aGCtXyPhiJjxvBmXlUnbQhkP0tnL4/9K5MdIgt/0Hn7n9xpWXmuI6St1axf +sKyoZTWf4AVUknoEs09Fiwl0cvt9lzi+yAkgiHTm/aaLJ0ouoT0c0f1uUyFIdT6QuWi 9PILLHv7jq9923tLWiAtGekbw+pCcFOHI70ArHDf0V1m6fGx3QKALgiC3ZhGnjOWEgod z90VqUycmVAvC/S6ZJkJylQe4zl2WbWyOcPMkHEd4lpYuWcXtd4m57JBivEjqm/RP0FY tNpA== X-Gm-Message-State: ABuFfoi1FNLU48mnCY0wlnlgoq2gMRyPSkkRNUnXc3Itt83DBN+F5Iu5 pXEug0IM1D7k0mxnGeqf0p1feCtn08xp+Zg5TFeT3V9o0+7PCXg6U1sHMRmcQmP0m/L46LEeUvD w3hTKaSEw8AHQtu+rQbvUnDtDL3ZLYXpAFhN4OGLOluaz3us6Yfytk2oRlLHHQZwUQQ== X-Received: by 2002:a17:902:a40c:: with SMTP id p12-v6mr27867018plq.165.1539816403514; Wed, 17 Oct 2018 15:46:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV61in7PKau5ddX+RBJKPVw3Rb6ss6Veao5LS7shCmqMwxezbCAJjIebfyCgpywyKk0PbTLT1 X-Received: by 2002:a17:902:a40c:: with SMTP id p12-v6mr27866995plq.165.1539816402924; Wed, 17 Oct 2018 15:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816402; cv=none; d=google.com; s=arc-20160816; b=JbEal7fpf+4HGxJgJdhqh2M7ZQWFCvHRSHuMixjFtg4r9s98vziQTtCwxnAaS7GNxm XTiYk/eyT5hUBIeuQUa9XSRv4PxhBTEynYaqeNn+yF9t7EHy4StdJh1G0apwNwEiS0Oz s4X43+YmhQZQjs/vmqf0XyVrn302Xo3haoC9CdMYsQLP2o9DlEYbI+BmFOZqIX2bLGHj 8CGj3vnLnWdPei8jOH4qNfSPG6SSLkK8z2TDYiBDCOU/vMO8iR0HayWAaxHmJjq9XOp4 /iqfRpPuSn0MqRIeOHUwbm45EVhiipxyInwxYg/Pa8auHgC5Ukz8oK5i+YfQa/SgWnra /TiQ== 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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=ouIFP/Yz1d1OkB42ENSV1iudw7kgnyZJpQ4Fu2veo9YofwAQzoKM3OPhNiWHMvf6t6 1FsRcbyAe23c52Igw8285N+W+9PbGSi/ofLZfqJxfz6tpcJGYgFcOvzywxJGbWxSMJpf d6w9ejKKjiPwSOBa+mziuoYdcNOgjlBZDoqXfOG+CEQc6kKBi//mtv7IwdW2oyXBH7pD HKuQ0jmuNKRYwpn4eyl+3B1rJWVZR8cEJSQINFp8CF39Ru1xt1zR/l3q/2Yaq/EWqjZi sK3JvfpVFcfh79/0C8EHbLIsR0PA74ZhOC1PfuBBaGGr165ZqAp8Z/DMTrLcMjy+KIfo sCXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ufFadL0Y; 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 a9-v6si11926518pla.291.2018.10.17.15.46.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:42 -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=ufFadL0Y; 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 w9HMiKIe040242; Wed, 17 Oct 2018 22:46:42 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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=ufFadL0YPA8f4GUDQyuEefSLolBmVx61eERC4UgMImb7wMgc+TbVhfuk79EO5+v5o0KY ughVyo8bMkXAwK2HByJKg1CEDNKHSLztfzp4Q9J44HdO1BCOF2omr72+t8z3aGpcGcMk 4eg8Enh36yyRJl4W7oQswucet3lyRwMqhZrtwRd8UM6zRgk94xWL/4r63jctaXvn7pOX Gz6j4VdaxVg91wBp3EkfUriZe7QNiNs9FApLY3jk/erfykxI//5w2Zfaa6trt+gmIQMl 84SqNFIsN7GFhSVfefVXWnkW+mWoJqmgDYNGUZnC3rLOkGNHkY2icpETnoKORJecGQjg nQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2n384ua047-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:42 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMkfdY011472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:41 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMkfS8015518; Wed, 17 Oct 2018 22:46:41 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:40 -0700 Subject: [PATCH 20/29] 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, 17 Oct 2018 15:46:39 -0700 Message-ID: <153981639941.5568.14471990950819406360.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=999 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 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 2a5c96bc9677..7c709229e108 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4862,8 +4862,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);