From patchwork Sun Oct 21 16:17:16 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: 10651157 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 AFE2C13A9 for ; Sun, 21 Oct 2018 16:17:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EB07287BE for ; Sun, 21 Oct 2018 16:17:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 930BB287C0; Sun, 21 Oct 2018 16:17: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 338F8287CB for ; Sun, 21 Oct 2018 16:17:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08E486B027E; Sun, 21 Oct 2018 12:17:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 03F626B0280; Sun, 21 Oct 2018 12:17: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 E6F3E6B0281; Sun, 21 Oct 2018 12:17:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id B7D646B027E for ; Sun, 21 Oct 2018 12:17:21 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id p18-v6so23371308ybe.0 for ; Sun, 21 Oct 2018 09:17: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=PyBPAavOIq55658ZH1Sj+FtMrq4d/FyfXvZlBhg5/0I=; b=n/fgOyYNjNtGZW7ntX6Q+RH6z9u3VePu/mzDnc/8aQVCxztJNQzSJ+k/e8JSEstz2i 77WTcvl9ZqrMPb2t/s8rwRu38sxnK9bZ2CHgfEeBiNCrRcKlxhAHhL3Xgw0AkANzzA8s TuhtcnX4BULjq/CQbV23lVsoF6vA7cu/0mnntstzqjYArpMUTbco9VqBJ2iGUCqVlXEw WfEW9nKkdlqLdlBvBGW9qwJG+rSog7phDzUcWELsW27DlTMVxTZZje8KkZ/N0rrcaCWk nRhuwg3UCrsPMU+bWs65Mf62EexzDHs8Hvu9hUAtWyQi01tk4J252aun5yNUvxwTXv1o iWxw== X-Gm-Message-State: ABuFfoiRDSmtJLtkIue2OBxcMUKndnDn09T2MABYMwD/48emzS50TrzK /QHBni0E6fLtjaaDjZyq47sEUy47SaqfW3Qj01QSQ7NKZVLvoryTPHl1rtJOALRuiq5Ei1Ed6OY tdGJRt/LM/gOfEvEGmcG+f0bqSolyEfN1SJhCRh6UJXz6T+yy6KyylghwLoWB3iYQGw== X-Received: by 2002:a25:a349:: with SMTP id d67-v6mr28406483ybi.479.1540138641518; Sun, 21 Oct 2018 09:17:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VJ6hKH6siopggp75dW7GY6tqw5ZOoY4NEVl6NGnetCkL7qTsX3/XvAPOm5icDbPCNQ5P/ X-Received: by 2002:a25:a349:: with SMTP id d67-v6mr28406457ybi.479.1540138640985; Sun, 21 Oct 2018 09:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138640; cv=none; d=google.com; s=arc-20160816; b=gmQEdqbgLPR/p5jpcpblelLZmEhwVrumZUQuhdF5Fxo+Aaz7nCaXGmKv0Jcu+Y40JD 7EXuh3dF4Y05UAv1pSNrk8CP+GGFNRQMJVasvsCU4STe0a1+YeLunpPgmYF6kJNzsh2N YdvN58/dXUIKNjpKreCV+wgLX+bLb2qVaOs+KlX/x3JQzRk4kRxlId12aiC5mhB93KNN PVBs0IXsTiNH0lcMHLcPTNOte/oBYZ3TTyM/oU+bu4NOcuSZENe8Y82uzF110bz7cefJ u4/gYmcf8/dkdtbaaEVbzUXUY/4nutwHsCZB3ZsiIKECXU2/a2Gj3VWUiqgBldn1+tMa ThYA== 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=sD/CM77M4aPp/PkZ2h19/qWSVMWqt+zgkwP9zZy+j12yF8CRSCOkVa0AUjKv2y8HtV UCoLsXQbBPtnn6lQcg8FPPsfivNJB03Vj2qVe1hQpxPr2U+YwCnvABzL+0PfOCWjbiIE NdUPwfczKzM3d2tUKPkDb/s89BiRPNzkh1VJUC2ryGgwewl8KtJQ6Sg3ycVd41AcUF/O RPlztyZqHI/c+6W8OBeB+SMCZ96NLGLGSD93rOXr1pxleRXB3vXODyk9wSdOASO4cfS9 dAzR3UdEyre0OtUgqbSy7IHBc50xbA3mw8M1g7giqmx1xHsPu/gxOFecYTkS2NXS6G41 x9mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=YGb4AKbE; 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 126-v6si13727092yby.29.2018.10.21.09.17.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:20 -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=YGb4AKbE; 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 w9LGEaSZ154207; Sun, 21 Oct 2018 16:17:20 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=YGb4AKbENQy21KfMqY1cHXftzd2QbfPHoYtmOfvP3KbPY3cX4AqiUD1EedUX4l/2tFSO IGZF9AGH7ogIdORPIrLuuJCDkxMKOGiOHqLBTojkcKLBlSl1bTdGot0wq06iTp4FpZwn /cLrXMCGn3bVD61b3KYsA0Owr1UNEKjohuIuG19lSsZp+Zu5QFXTprXx3CfeXUokDSs4 CDozA7CBTc+0aBUTd19Iv5V0a1AAJ2TBov3wEunJvglCGWVXZWewhkJV52lsefqVZ1Fh u38v/XqYf1+sCMrZswWZ3ew9pqbmVl0dDLC6bxu6XV/jtpwU3Odw1ZP/AgUsqwNRZdOG SQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n7ustu1ur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:20 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHI8t013658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:19 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGHIW1019313; Sun, 21 Oct 2018 16:17:18 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:17 -0700 Subject: [PATCH 19/28] 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: Sun, 21 Oct 2018 09:17:16 -0700 Message-ID: <154013863631.29026.17663976179167255577.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 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=802 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 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);