From patchwork Mon Oct 1 12:37:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10622059 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 7CEA41515 for ; Mon, 1 Oct 2018 12:37:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F4292873E for ; Mon, 1 Oct 2018 12:37:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63E1928906; Mon, 1 Oct 2018 12:37:47 +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 0CA6528A13 for ; Mon, 1 Oct 2018 12:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729324AbeJATPW (ORCPT ); Mon, 1 Oct 2018 15:15:22 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54272 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729319AbeJATPW (ORCPT ); Mon, 1 Oct 2018 15:15:22 -0400 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:To:From:Sender: Reply-To:Cc: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=YwajOeDhOw0pPSspuh9tHrrrS6kIoS8Mszv64W7T0Tg=; b=rbKZD4YC6IEp02DcKUNWGwo9V pH3Mmr3hRpj/r+HsJOtYtmvnYWcZRCSTSU5EUX++jRCH5lWUd/0R9mFpV3nkKDWMocUqDeXGmVAVk 0LDtkXiHlJX53TRSHSY1x7z92Fv0enFudBv5+3q0oK35BD7uzmSimbZmpDri7lLBpeeSt+IfX+Mo1 td+d1Mpo9jG+/RHyym3uWAlCD4Fl0fW/XO2uMc8TCyTNJoF8EDU5QR8gP8y1UCSJ0UxieDWvnS2UK x5q2J9tr/8glo/E0Y9utpvzZa+6J1rprJRAo905wtXs5jpJxZSKxND/uXLbwXHYuUrPUfwHhWa1vn Phr4qo39g==; Received: from [38.126.112.138] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g6xSL-0004JT-P3 for linux-xfs@vger.kernel.org; Mon, 01 Oct 2018 12:37:45 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 6/7] xfs: fix fork selection in xfs_find_trim_cow_extent Date: Mon, 1 Oct 2018 05:37:40 -0700 Message-Id: <20181001123741.32005-7-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181001123741.32005-1-hch@lst.de> References: <20181001123741.32005-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 We should want to write directly into the data fork for blocks that don't have an extent in the COW fork covering them yet. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_reflink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 1e39a7d21c7e..ead35209ffae 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -369,9 +369,13 @@ xfs_find_trim_cow_extent( * If we don't find an overlapping extent, trim the range we need to * allocate to fit the hole we found. */ - if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got) || - got.br_startoff > offset_fsb) + if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got)) + got.br_startoff = offset_fsb + count_fsb; + if (got.br_startoff > offset_fsb) { + xfs_trim_extent(imap, imap->br_startoff, + got.br_startoff - imap->br_startoff); return xfs_reflink_trim_around_shared(ip, imap, shared); + } *shared = true; if (isnullstartblock(got.br_startblock)) {