From patchwork Fri Nov 3 14:45:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10040429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 526E46032D for ; Fri, 3 Nov 2017 14:45:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 473FE29680 for ; Fri, 3 Nov 2017 14:45:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C00A2968C; Fri, 3 Nov 2017 14:45:53 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 32C7E29680 for ; Fri, 3 Nov 2017 14:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932954AbdKCOpt (ORCPT ); Fri, 3 Nov 2017 10:45:49 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:32990 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932812AbdKCOpq (ORCPT ); Fri, 3 Nov 2017 10:45:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding: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=UMOMAsWAXJUaGvohxHkiEKElKMD2C/8zCUkdruz+dhQ=; b=q6C0paxsn+cPIDAmMZ6UNSQwQ 54SDYKJKjP4vq4D/+zvLrFTLeUJWHk/IUSMHLBTbUMSLK1LR/APaYgVsP0qD7/k8yAENOGFR43w3G L6jATKynUlLlIPzExa3z/Fe5MXss+ruzIpXdFznDq8iILXyl/PaElf08fqTSp8i1hZ23biZuWfzf4 NaRWh2ipFH2LPPb5iswSAnWb9zX71GFgWvYpPiTtOn4U+btNaeMIgwGYH/xrxd+PH/soRKWy8bsiw lFRcegMDRI4qO6DzdaNtpyYsh62Nj/35B6B1NVO9eJDKq6qF3kd+iBk64eDbmhoXeMyUhd/VPJB/L eZVHNib1w==; Received: from [94.72.11.11] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1eAdE8-0001j6-SB for linux-xfs@vger.kernel.org; Fri, 03 Nov 2017 14:45:45 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 01/21] xfs: don't create overlapping extents in xfs_bmap_add_extent_delay_real Date: Fri, 3 Nov 2017 17:45:19 +0300 Message-Id: <20171103144539.2187-2-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171103144539.2187-1-hch@lst.de> References: <20171103144539.2187-1-hch@lst.de> 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 Two cases in xfs_bmap_add_extent_delay_real currently insert a new extent before updating the existing one that is being split. While this works fine with a simple extent list, a more complex tree can't easily cope with overlapping extent. Reshuffle the code a bit to update the slot of the existing delalloc extent to the new real extent before inserting the shortened delalloc extent before or after it. This avoids the overlapping extents while still allowing to update the br_startblock field of the delalloc extent with the updated indirect block reservation. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index ebb5958f1c5c..db369653eb50 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1791,7 +1791,7 @@ xfs_bmap_add_extent_delay_real( * Filling in the first part of a previous delayed allocation. * The left neighbor is not contiguous. */ - xfs_iext_insert(bma->ip, bma->idx, 1, new, state); + xfs_iext_update_extent(bma->ip, state, bma->idx, new); (*nextents)++; if (bma->cur == NULL) rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; @@ -1824,7 +1824,7 @@ xfs_bmap_add_extent_delay_real( PREV.br_startoff = new_endoff; PREV.br_blockcount = temp; PREV.br_startblock = nullstartblock(da_new); - xfs_iext_update_extent(bma->ip, state, bma->idx + 1, &PREV); + xfs_iext_insert(bma->ip, bma->idx + 1, 1, &PREV, state); break; case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: @@ -1867,7 +1867,7 @@ xfs_bmap_add_extent_delay_real( * Filling in the last part of a previous delayed allocation. * The right neighbor is not contiguous. */ - xfs_iext_insert(bma->ip, bma->idx + 1, 1, new, state); + xfs_iext_update_extent(bma->ip, state, bma->idx, new); (*nextents)++; if (bma->cur == NULL) rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; @@ -1899,7 +1899,7 @@ xfs_bmap_add_extent_delay_real( PREV.br_startblock = nullstartblock(da_new); PREV.br_blockcount = temp; - xfs_iext_update_extent(bma->ip, state, bma->idx, &PREV); + xfs_iext_insert(bma->ip, bma->idx, 1, &PREV, state); bma->idx++; break;