From patchwork Mon Feb 18 09:18:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10817505 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 375AD13A4 for ; Mon, 18 Feb 2019 09:18:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 228E120174 for ; Mon, 18 Feb 2019 09:18:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 166DE29279; Mon, 18 Feb 2019 09:18:46 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 AAB6120174 for ; Mon, 18 Feb 2019 09:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728448AbfBRJSp (ORCPT ); Mon, 18 Feb 2019 04:18:45 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44944 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727423AbfBRJSp (ORCPT ); Mon, 18 Feb 2019 04:18:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ND/6+roD0kOqcNmSkBdCfyoQzXArN06FkvooWF6ijBs=; b=FP4C8WLoSolilebO1QElC4c9iY OjcFgloM9A51uSplj9DZkr1m8hPfMUHALbCyLNhBAChajXoS6o7hXzE1r/hEr3ubdC29Uzv3CuToq fSyYQtc4rdcaApn69eBuDfyS9VQM7jagA/yieVSe7pq+iDdgwPH/szc/9lZ8X1Acb/YBu30BQhvlh czseATAnBNIA7nez3JS2Jr3D7uR5r+NPjXLqVqXR+/pub9euZWuIb3IxfGnDABhBftBVNnQId8b2M 0CZa2DGsU+fKBI4uqL3a0leexv8KBH9QfS2oL3Z70uo2PQnHqiypJ0VFM2VTdV/3njObhgdk6T60G fADMoChg==; Received: from [88.128.83.71] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvf4W-0002mx-9z; Mon, 18 Feb 2019 09:18:44 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: "Darrick J . Wong" Subject: [PATCH 4/8] xfs: also truncate holes covered by COW blocks Date: Mon, 18 Feb 2019 10:18:23 +0100 Message-Id: <20190218091827.12619-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218091827.12619-1-hch@lst.de> References: <20190218091827.12619-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 This only matters if we want to write data through the COW fork that is not actually an overwrite of existing data. Reasons for that are speculative COW fork allocations using the cowextsize, or a mode where we always write through the COW fork. Currently both can't actually happen, but I plan to enable them. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_aops.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 2ed8733eca49..983d11c27d32 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -447,28 +447,29 @@ xfs_map_blocks( wpc->fork = XFS_DATA_FORK; + /* landed in a hole or beyond EOF? */ if (imap.br_startoff > offset_fsb) { - /* landed in a hole or beyond EOF */ imap.br_blockcount = imap.br_startoff - offset_fsb; imap.br_startoff = offset_fsb; imap.br_startblock = HOLESTARTBLOCK; imap.br_state = XFS_EXT_NORM; - } else { - /* - * Truncate to the next COW extent if there is one. This is the - * only opportunity to do this because we can skip COW fork - * lookups for the subsequent blocks in the mapping; however, - * the requirement to treat the COW range separately remains. - */ - if (cow_fsb != NULLFILEOFF && - cow_fsb < imap.br_startoff + imap.br_blockcount) - imap.br_blockcount = cow_fsb - imap.br_startoff; - - /* got a delalloc extent? */ - if (isnullstartblock(imap.br_startblock)) - goto allocate_blocks; } + /* + * Truncate to the next COW extent if there is one. This is the only + * opportunity to do this because we can skip COW fork lookups for the + * subsequent blocks in the mapping; however, the requirement to treat + * the COW range separately remains. + */ + if (cow_fsb != NULLFILEOFF && + cow_fsb < imap.br_startoff + imap.br_blockcount) + imap.br_blockcount = cow_fsb - imap.br_startoff; + + /* got a delalloc extent? */ + if (imap.br_startblock != HOLESTARTBLOCK && + isnullstartblock(imap.br_startblock)) + goto allocate_blocks; + wpc->imap = imap; trace_xfs_map_blocks_found(ip, offset, count, wpc->fork, &imap); return 0;