From patchwork Tue Oct 16 03:20:21 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: 10642961 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 E021918BC for ; Tue, 16 Oct 2018 03:20:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC861298AF for ; Tue, 16 Oct 2018 03:20:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C130229AD5; Tue, 16 Oct 2018 03:20:27 +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 545DD298AF for ; Tue, 16 Oct 2018 03:20:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 131996B0287; Mon, 15 Oct 2018 23:20:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E4026B0288; Mon, 15 Oct 2018 23:20:26 -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 EEBDD6B0289; Mon, 15 Oct 2018 23:20:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id AE31B6B0287 for ; Mon, 15 Oct 2018 23:20:25 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id s24-v6so17059992plp.12 for ; Mon, 15 Oct 2018 20:20:25 -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=PyBPAavOIq55658ZH1Sj+FtMrq4d/FyfXvZlBhg5/0I=; b=IzLhtDcPpBUiTR4o2QJ1R5uXZDF8Rw3TXDijDjfgZJDN4YIJP/lgUc9O0FtNSxArp/ sVniuexEXSuDBq1Lm2bkezp1kYbprZs4f66VIt5xK8ci1m5PlW5E2p9XIrppgrjCTM9V XuYWscDXzGuI42I1+S1TtJRu94Yjke/qVoLuYbhNelsuRcC6AMCYe06ulMyNp3ELIKcJ E6aiP6/Y63Xue6J4mwF6fbJ/wOii2Qc1jj+MbeSk4CoP8xNp67uMbjQSHbzqXg5yfQbD L/pXho20lfpTGXf9UAM3VEKTlbjHw3AW0pCa8EXB8Dd88FZhRb/Oi4DWKZqeJZCkrxmT eHWw== X-Gm-Message-State: ABuFfohdKtpoX8RHq0IWDhNZKlYZes8p5iFQCS+1NSh6nSJ8o7/qM+sH zpZoaH4Iu4WI6G80hxsKj9irLp1huDDW6UBhPGyxv21fcza0RhA4nBaSuVi67Xwnhik/JyRApcq nRBKKH9ANVTnICq7aoke11xMHOHGnF6baLJQ0sKeIOsru41+NXwPtROtHp1IZbgzzww== X-Received: by 2002:a65:4145:: with SMTP id x5-v6mr18460028pgp.309.1539660025379; Mon, 15 Oct 2018 20:20:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV60RvTc+M037YdWyrjxz8PhXAVfFANX+/wCMXlKCq6vrkUZpKtPUOm6Dh2+huUTr84uVQN+4 X-Received: by 2002:a65:4145:: with SMTP id x5-v6mr18460001pgp.309.1539660024788; Mon, 15 Oct 2018 20:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539660024; cv=none; d=google.com; s=arc-20160816; b=JMvlYVVRugbMkFJZ2keO/TYOEL0F0ienKUdgeG46pbphEbJiuhD7aXhwLUYjppoy2R 8EogVEOtx9HjE3Ax1IALy1TWqMXSkpQw9/0fakTWaVsx2l6q8f3X9YC8SlHGO9EhOKqV e9+sZlw99L/E3S/rjYyfBvC73I/9vn2PFEJwERwg4Aj7CWVtzRa6RmcPZ6+6mawP2Xvf 1pXx2EsorcmGsPPVjf9eEkmmIkuxPbfP0H+gt6097cB7X2AMXVgDvYecmMO0nlmcusd9 gYTWMdsqSbMSli/YB4+CbJuU1ytqXT/EA6bAuw7H441LCh63EHE11u/6/nKvhLGNy99i 1gtg== 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=PyBPAavOIq55658ZH1Sj+FtMrq4d/FyfXvZlBhg5/0I=; b=P43dvDtHaX3WFpDhgnoSP7gXasP3syqGVCZ6n2JlLnlA02EdyDAdrvAF6M0dM1P29n VHSVI8xbm4jJ+IMIc+Lhrf6Fe1/w1PCFYOcJBwgjhNqWM7Q2CAmBvPzfV5CwvNorIVnB Mlt3JR1PEygYgMwX+OtjZuIA5E1Vf+P5Qzo1sFFaTR02nXszD9JProY1fMvNvods1pNn +iONhGTAC3zTNKIMuVzUJAmqZaXpLrxcp+42u/vb1ElPEQ3gg03CfCv0lhfsLOLo2NXi R9pUr6d+YS/iasnXGQhQWnphrVN7SIm/biGEo3Uc0kKT100WQeBji0iuRE0rffZWIdek MVug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="3/ATnRlF"; 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 z138-v6si14311689pfc.181.2018.10.15.20.20.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:20:24 -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="3/ATnRlF"; 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 w9G3J3t4051349; Tue, 16 Oct 2018 03:20:24 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=PyBPAavOIq55658ZH1Sj+FtMrq4d/FyfXvZlBhg5/0I=; b=3/ATnRlF0+K3juooAcYQQkcfgKZy7Qsol0XStB+WNT/h/ZmfR4RSs36kpd1rMHfXPMWB 4VCmI+OdxEDK+1aQkwjR5/Ioya8Z31FwYwM/qYojKk5EYJgGU1DyGjHvgLgMgal3N5rp zrSuPDKQGNoQHe3OwrYIrob24OWMl8lm7OsQAMLC/0l7jcNJU+nDIud2NrfRqB6nE2PE hqB2AX0V9LMmv/mZ5dwu1ZotvA36FWhcgQiPR0S16djsNiQo1FwlixIKGFJcnfLwKWpG r9WsUMC3CbdNNYpg3zKPMeCFMnQ/pbbCcunRZeRYsMtk3QrByoaTmMEwoobJmZq5ko/x RQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384tx29q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:24 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9G3KNdc032476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:23 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9G3KNGr007142; Tue, 16 Oct 2018 03:20:23 GMT Received: from localhost (/10.159.227.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 15 Oct 2018 20:20:22 -0700 Subject: [PATCH 20/26] ocfs2: truncate page cache for clone destination file before remapping 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: Mon, 15 Oct 2018 20:20:21 -0700 Message-ID: <153966002134.3607.2095885321354295269.stgit@magnolia> In-Reply-To: <153965939489.1256.7400115244528045860.stgit@magnolia> References: <153965939489.1256.7400115244528045860.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9047 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=801 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810160028 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 When cloning blocks into another file, truncate the page cache before we start remapping blocks so that concurrent reads wait for us to finish. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 46bbd315c39f..2a5c96bc9677 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4861,14 +4861,12 @@ int ocfs2_reflink_remap_range(struct file *file_in, down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem, SINGLE_DEPTH_NESTING); - ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, - out_bh, pos_out, len); - /* Zap any page cache for the destination file's range. */ - if (!ret) - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + len) - 1); + truncate_inode_pages_range(&inode_out->i_data, pos_out, + PAGE_ALIGN(pos_out + len) - 1); + ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, + out_bh, pos_out, len); up_write(&OCFS2_I(inode_in)->ip_alloc_sem); if (!same_inode) up_write(&OCFS2_I(inode_out)->ip_alloc_sem);