From patchwork Wed Oct 17 22:46:32 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: 10646401 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 72AAC15E2 for ; Wed, 17 Oct 2018 22:46:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EA7288C7 for ; Wed, 17 Oct 2018 22:46:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52DCD288E4; Wed, 17 Oct 2018 22:46:44 +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 EC10B288C7 for ; Wed, 17 Oct 2018 22:46:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E018A6B0005; Wed, 17 Oct 2018 18:46:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DB1FD6B0006; Wed, 17 Oct 2018 18:46:42 -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 CA41E6B0007; Wed, 17 Oct 2018 18:46:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f70.google.com (mail-yw1-f70.google.com [209.85.161.70]) by kanga.kvack.org (Postfix) with ESMTP id 9617B6B0005 for ; Wed, 17 Oct 2018 18:46:42 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id i64-v6so17584931ywa.22 for ; Wed, 17 Oct 2018 15:46:42 -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=gYAryt5th2UPDrXqFluQKozy2EzkID1d3c65lHFuXAmotF1N06mHNInPO8f74BDKDn 048QVIuZ7b1iQJh4PlkFPVnhHhLKed5pwhzFTBK64yxL9UEjyTfdgoU2EyC56FZwkxeG wc/ABtt56h4EGajyn+YAH4j8oTs784VIVymA3Wglck4+n7SmwBsIhzHuZHfhE+1COoDD pFsQxKzWazQAK2Lq3z4p58AA8hp63qgmEQ3j/dQBtffPXDXSL9nNALaGvqRiHsALT0v0 utr769ZPPjTBiv9/zUjQfAtNCXsGsPe0xXwjO+8AGAohRoixD1NmaZAcA6JbkizVztnS KNGQ== X-Gm-Message-State: ABuFfojaHPSqIc2f8VwJeDQ/nTt8mNvbBvtaShaajFyaksT7acKX3CM8 nasFmnZiQp6lEf7DSo/V9rsv66l30UbFagY1CMgxgEOm00M2Wbxv7wIZOPs6qOgqa4lzoukotoa VtCyh3YcYRv7WbUh0KAr5JH4CtVt/9UbnNPyTcAkq9dCdXDoVh/ckHEqm8XkkIRmn2Q== X-Received: by 2002:a81:91c2:: with SMTP id i185-v6mr16756125ywg.390.1539816402381; Wed, 17 Oct 2018 15:46:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV60dEypKta9wd2nhNfk8tsVmQLVy+ZziDjyQlkzra0kQNkBuWjn0sMeRX2EM1eMANSG/IXmh X-Received: by 2002:a81:91c2:: with SMTP id i185-v6mr16756099ywg.390.1539816401884; Wed, 17 Oct 2018 15:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816401; cv=none; d=google.com; s=arc-20160816; b=XLys4HSmqP5FDOAxV0uAt2DHsX/gy0zy7Z7mTdvNyJxXmwZS5U5ufd0hrxolQiSwfq 0jvrWbzPo5TePGadHK9U7KdoiU4uakfeVv1jSIL7cPCZ+2L/cKCvHvETm8Dxka1Nd85K fJSCGgfBA9Ak4tIvGktL86Hb1HEGTZhKFiUsueYWoV3jIVfvOJWwlGSNCuaujDJqORGC PkwTIq+eRUtBhRnzsKx31p30V5emCtIa4hSXePDNGJlvj6lhU1diBdiUIcScvkkRY2Qp r16hCaBEUCB1JUER2/CvVUlROno5Bhekh8bg4spMHnNnQk217ej4nCxdqlTgoWZVFe0W B46A== 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=Q/mAgVsOI/HzUop+ABkaokgRg55wSFyBZ3oA7LxuIEhY8Pq2Ll7G0/OrNXVOV/7uhr ZP971Lp1+copxbpcOJro+McD2oF1073lAoQrblkCfLk/NXqZztyDf1Wf3dSX5/x1Jbfj pdlqw2tFKOYu0nrnDd5EsME26HO/K224/y5sPO7ilCxn847zUcTU/CLscdMJmHTra2SJ vLHO8zQzzgs16m3wyy2V5MpdHNhA1lD0qWlDea0LTQKFpm2rBRPBHETMcy+2+364BpNH OhjAFZyHhZESjJuPIqQAZ4+5UEeXU72bbMZwH8JifXlpGwyZssXhMEAe/CoPDkXrPInX uo1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="o3/bI3MG"; 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 d81-v6si6977816ywe.206.2018.10.17.15.46.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:41 -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="o3/bI3MG"; 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 w9HMi4iD048600; Wed, 17 Oct 2018 22:46:41 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=o3/bI3MGQg4IokfWjtLHh1ccM2XQaUDUSn+omteFW90NWDR9hNWg7IFQZC90rMsdN3xK Zp3qRe6pXtR5CMvDyQkBEJ/7lKQKD+wHGsMVkjMnSXPegWDGwGDp8QPRhcqVCFV1G4bW QXPXkQHP1C4UfwycxBvk1/yqB3o4ja9z5sv+GDUQudpemKySfn7wqBxkljn+GQmPazDf XydGX5aizZDcYtDqNFSH6ZghWiOF4ePwhQbwkHUmwWCn5wwiryoCFSDwS3zSNAO6Qhb1 fhSHqy/qxE11a9/dhn6/ORFTl7aQQ+EvRXdNjaUT/x7TwtMA4j7kLZh6SZBStGhKipqF NQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n38nq9t0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:40 +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 w9HMkZlG011233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:35 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMkYGG029063; Wed, 17 Oct 2018 22:46:34 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:34 -0700 Subject: [PATCH 19/29] 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: Wed, 17 Oct 2018 15:46:32 -0700 Message-ID: <153981639268.5568.1964703365268884972.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=803 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 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);