From patchwork Sun Feb 24 20:30:58 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: 10828047 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 EC1F91575 for ; Sun, 24 Feb 2019 20:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6A7C2AB25 for ; Sun, 24 Feb 2019 20:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9B882AB38; Sun, 24 Feb 2019 20:31:11 +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 6648A2AB25 for ; Sun, 24 Feb 2019 20:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728210AbfBXUbK (ORCPT ); Sun, 24 Feb 2019 15:31:10 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:57024 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726458AbfBXUbK (ORCPT ); Sun, 24 Feb 2019 15:31:10 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1OKQQA4139029; Sun, 24 Feb 2019 20:31:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=rpNpGzICWPnmIsP5rVmRlIpwBrO93NV28hn4f0du0mk=; b=rtQ9Frf5mJeCBhWbhDH2lHKVsN+3ImCGVY3qVoeY58GrWEV6SMdv44uOQPmLk/dAZKmH MGZdmSElxSypjthnVomwTO+puesKPh6Zf3Ms28uPhGxkf+MJScDLwIaCmvWagoLIPSeC s0CAoVLpoGOh/m1AQ6FwNJ/JrKyKI1xThVg0UB3eVVfHaWz/fLoQnuihCn1ybgxGLP1r SvwFT/0IcK8CcGMN93BEF6/j/meiB7xO/LaU0MpyvHywDNnVLfZQz1vfbubk6NJhFbkp NWFUtQAJ4v1Tv0Fa/NIClDdD3Jkh1Apye4LFcVwJULGSM0awlq+M5aIX8JtWJU95fu8u Nw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2qtupdu85d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Feb 2019 20:31:06 +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 x1OKV0Yg023486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 24 Feb 2019 20:31:01 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x1OKV0vD013336; Sun, 24 Feb 2019 20:31:00 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 24 Feb 2019 12:30:59 -0800 Subject: [PATCH 1/2] xfs: don't pass iomap flags to xfs_reflink_allocate_cow From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com Date: Sun, 24 Feb 2019 12:30:58 -0800 Message-ID: <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=999 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 Don't pass raw iomap flags to xfs_reflink_allocate_cow; signal our intention with a boolean argument. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_iomap.c | 6 +++--- fs/xfs/xfs_reflink.c | 4 ++-- fs/xfs/xfs_reflink.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 01210eae8bf3..a376fb2d4b94 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -983,6 +983,7 @@ xfs_file_iomap_begin( */ if (xfs_is_cow_inode(ip)) { struct xfs_bmbt_irec orig = imap; + bool convert_now = (flags & IOMAP_DIRECT); /* if zeroing doesn't need COW allocation, then we are done. */ if ((flags & IOMAP_ZERO) && @@ -991,7 +992,7 @@ xfs_file_iomap_begin( /* may drop and re-acquire the ilock */ error = xfs_reflink_allocate_cow(ip, &imap, &shared, &lockmode, - flags); + convert_now); if (error) goto out_unlock; @@ -1002,8 +1003,7 @@ xfs_file_iomap_begin( * direct I/O code, which must be block aligned we need to * report the newly allocated address. */ - if (!(flags & IOMAP_DIRECT) && - orig.br_startblock != HOLESTARTBLOCK) + if (!convert_now && orig.br_startblock != HOLESTARTBLOCK) imap = orig; end_fsb = imap.br_startoff + imap.br_blockcount; diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index e2d9179bd50d..d42e3ef9050e 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -361,7 +361,7 @@ xfs_reflink_allocate_cow( struct xfs_bmbt_irec *imap, bool *shared, uint *lockmode, - unsigned iomap_flags) + bool convert_now) { struct xfs_mount *mp = ip->i_mount; xfs_fileoff_t offset_fsb = imap->br_startoff; @@ -444,7 +444,7 @@ xfs_reflink_allocate_cow( * to initiate a disk write. For direct I/O we are going to write the * data and need the conversion, but for buffered writes we're done. */ - if (!(iomap_flags & IOMAP_DIRECT) || imap->br_state == XFS_EXT_NORM) + if (!convert_now || imap->br_state == XFS_EXT_NORM) return 0; trace_xfs_reflink_convert_cow(ip, imap); return xfs_reflink_convert_cow_locked(ip, offset_fsb, count_fsb); diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index 2a3052fbe23e..28a43b7f581d 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -27,7 +27,7 @@ bool xfs_inode_need_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap, extern int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap, bool *shared, uint *lockmode, - unsigned iomap_flags); + bool convert_now); extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count); 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;