From patchwork Sun Sep 3 07:29:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9936017 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 385B16037D for ; Sun, 3 Sep 2017 07:30:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A60C28632 for ; Sun, 3 Sep 2017 07:30:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F6862868D; Sun, 3 Sep 2017 07:30:29 +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 6CC0028632 for ; Sun, 3 Sep 2017 07:30:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbdICHa1 (ORCPT ); Sun, 3 Sep 2017 03:30:27 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:37975 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624AbdICHa1 (ORCPT ); Sun, 3 Sep 2017 03:30:27 -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=xP00pKlNMgbNzJ7SLpNgK/FZyHPEEW/0xY7NXUdFnu0=; b=Y6xrm/m8JB1g7e53INpRWdqMM OdgaUWmWQni4IcDQVrku6tQfd4B4HIsdPW9s+2q+WVeuPF+UIdqM2y4LftqibH4bpjgCv+f1Vx5ze d/nOeGX6uSQEM4FxAguN1gdK30dFw3HpZ3gE009aaFiPAdBj4r7hgSCZZlURpKzU02cj3lipgNIKz nRFgvAL/s3XB3wL8N7ANIa9zHM5vC6sg2sTiomHpltSLN8SaMJ51QSttUTokUyJb/9zKlqS27a6Zj ITqLNR8A4NppwD+VBroK4qDe27yM5or8CHjr4XMVluKn9B+R6HvZSYp8kQGituwCE76gcKNrF3Kep 3xl0a01/g==; Received: from [91.114.64.3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1doPMQ-000753-NV for linux-xfs@vger.kernel.org; Sun, 03 Sep 2017 07:30:27 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 09/17] xfs: refactor xfs_bmap_add_extent_hole_delay Date: Sun, 3 Sep 2017 09:29:48 +0200 Message-Id: <20170903072956.3175-10-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170903072956.3175-1-hch@lst.de> References: <20170903072956.3175-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 Use xfs_iext_get_extent to find, and xfs_iext_update_extent to update entries in the in-core extent list. This isolates the function from the detailed layout of the extent list, and generally makes the code a lot more readable. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_bmap.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index c15b81611403..eae66f7999c8 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -2701,7 +2701,7 @@ xfs_bmap_add_extent_hole_delay( xfs_filblks_t oldlen=0; /* old indirect size */ xfs_bmbt_irec_t right; /* right neighbor extent entry */ int state; /* state bits, accessed thru macros */ - xfs_filblks_t temp=0; /* temp for indirect calculations */ + xfs_filblks_t temp; /* temp for indirect calculations */ ifp = XFS_IFORK_PTR(ip, whichfork); state = 0; @@ -2764,14 +2764,14 @@ xfs_bmap_add_extent_hole_delay( right.br_blockcount; trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); - xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, *idx), temp); oldlen = startblockval(left.br_startblock) + startblockval(new->br_startblock) + startblockval(right.br_startblock); newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), oldlen); - xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, *idx), - nullstartblock((int)newlen)); + left.br_startblock = nullstartblock(newlen); + left.br_blockcount = temp; + xfs_iext_update_extent(ifp, *idx, &left); trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); xfs_iext_remove(ip, *idx + 1, 1, state); @@ -2787,13 +2787,13 @@ xfs_bmap_add_extent_hole_delay( temp = left.br_blockcount + new->br_blockcount; trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); - xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, *idx), temp); oldlen = startblockval(left.br_startblock) + startblockval(new->br_startblock); newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), oldlen); - xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, *idx), - nullstartblock((int)newlen)); + left.br_blockcount = temp; + left.br_startblock = nullstartblock(newlen); + xfs_iext_update_extent(ifp, *idx, &left); trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); break; @@ -2809,9 +2809,10 @@ xfs_bmap_add_extent_hole_delay( startblockval(right.br_startblock); newlen = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), oldlen); - xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, *idx), - new->br_startoff, - nullstartblock((int)newlen), temp, right.br_state); + right.br_startoff = new->br_startoff; + right.br_startblock = nullstartblock(newlen); + right.br_blockcount = temp; + xfs_iext_update_extent(ifp, *idx, &right); trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); break;