From patchwork Sun Feb 24 20:31:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10828049 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 989161575 for ; Sun, 24 Feb 2019 20:31:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 839132AB25 for ; Sun, 24 Feb 2019 20:31:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77DFB2AB38; Sun, 24 Feb 2019 20:31:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 230F42AB25 for ; Sun, 24 Feb 2019 20:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728249AbfBXUbR (ORCPT ); Sun, 24 Feb 2019 15:31:17 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:48606 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726458AbfBXUbR (ORCPT ); Sun, 24 Feb 2019 15:31:17 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1OKPFX5138935; Sun, 24 Feb 2019 20:31:14 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=3mXaoaf/fohhi55xK083/DByIYlB5X/8HNSxod86Z1c=; b=LOrotu0irH7DsXmHPOuSwfg5lcuhrRNaoAvothoGAG098MdQiqovoQEfG0ra7goTmVYB MCyTyPpcgnTasAIS9OxQvpK2XUNskoHN/Ss5bgT1MQ+YTaKM+t5UFZPOogid4v52IO57 1Wr4fhnnHVX62b4UlbidqHyXnrT2wX808RXiquzjFeo9ylREfZkugWEKQc+ELmtUNJyI Wqq0nZHMjQZmPW98W6DIOYHsKoMSk77MVU2Rzxqe0Ddn379JbppvzkMR3jNa8L5+7Y6G H20Qdbr99zjup95fud0AkgWFETyRBrc8NcRlOoFddDmQysjYY82A4DFCXhdII2Q9xOwd kw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2qtxtrax7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Feb 2019 20:31:14 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1OKV6UZ023808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Feb 2019 20:31:07 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x1OKV6UJ013361; Sun, 24 Feb 2019 20:31:06 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 24 Feb 2019 12:31:06 -0800 Subject: [PATCH 2/2] xfs: rework breaking of shared extents in xfs_file_iomap_begin From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Sun, 24 Feb 2019 12:31:05 -0800 Message-ID: <155104026500.24373.14839198455533713908.stgit@magnolia> In-Reply-To: <155104025871.24373.7462613353398620970.stgit@magnolia> References: <155104025871.24373.7462613353398620970.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9177 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=801 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902240161 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Rework the data flow in xfs_file_iomap_begin where we decide if we have to break shared extents. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_iomap.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index a376fb2d4b94..a3043b1bcd9a 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -982,7 +982,7 @@ xfs_file_iomap_begin( * been done up front, so we don't need to do them here. */ if (xfs_is_cow_inode(ip)) { - struct xfs_bmbt_irec orig = imap; + struct xfs_bmbt_irec cmap; bool convert_now = (flags & IOMAP_DIRECT); /* if zeroing doesn't need COW allocation, then we are done. */ @@ -991,7 +991,8 @@ xfs_file_iomap_begin( goto out_found; /* may drop and re-acquire the ilock */ - error = xfs_reflink_allocate_cow(ip, &imap, &shared, &lockmode, + cmap = imap; + error = xfs_reflink_allocate_cow(ip, &cmap, &shared, &lockmode, convert_now); if (error) goto out_unlock; @@ -1001,10 +1002,12 @@ xfs_file_iomap_begin( * previous block (if there was any) so that the higher level * write code can perform read-modify-write operations. For * direct I/O code, which must be block aligned we need to - * report the newly allocated address. + * report the newly allocated address. If the data fork has + * a hole, copy the COW fork mapping to avoid allocating to + * the data fork. */ - if (!convert_now && orig.br_startblock != HOLESTARTBLOCK) - imap = orig; + if (convert_now || imap.br_startblock == HOLESTARTBLOCK) + imap = cmap; end_fsb = imap.br_startoff + imap.br_blockcount; length = XFS_FSB_TO_B(mp, end_fsb) - offset;