From patchwork Fri Sep 22 13:59:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9966197 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 E636D6035E for ; Fri, 22 Sep 2017 13:59:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E51FF298E8 for ; Fri, 22 Sep 2017 13:59:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D897E298E9; Fri, 22 Sep 2017 13:59:54 +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 7BB8120223 for ; Fri, 22 Sep 2017 13:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752259AbdIVN7w (ORCPT ); Fri, 22 Sep 2017 09:59:52 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:39207 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752218AbdIVN7v (ORCPT ); Fri, 22 Sep 2017 09:59:51 -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=Bc/XnxcGNNoQcZiKEe2gg4mrCAjTGGoA11FZOlOWHMU=; b=u51wMiFFmGh9HA+sQeT6p/mzr k3YWhae+YkPZ6pUN8ftSv/Aos4sGTijRF7mWyIRl7YEHQ+TCuOvwwlHyoY5E8t7yckhLjcZ+1otly b8DrSvu6/JyK232Xnuc/tN8r+Uvsb5X+pzoIER8TU7dVPQ1r7bI2OPuH4dBrDI1hut/pkVLcvjenB B3n8ULE3P3rJkGS9TV1N2SuITn3IgkrOHWFUoNscjUE1nK0uzN6xVg31dYuLQQkMXhdnE+WeJK3OE 24DY4WVM1PAR/Hb49eAFIWIAnwMq+iwFU2QZ2J+w7CXO8q/r9NXFuw+i9FF1/QarhYsSxYt0P3SRI LR50lNZFw==; Received: from ip-64-134-232-11.public.wayport.net ([64.134.232.11] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dvOUh-0001BP-4B for linux-xfs@vger.kernel.org; Fri, 22 Sep 2017 13:59:51 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 10/19] xfs: refactor xfs_bmap_add_extent_hole_delay Date: Fri, 22 Sep 2017 06:59:36 -0700 Message-Id: <20170922135945.31574-11-hch@lst.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170922135945.31574-1-hch@lst.de> References: <20170922135945.31574-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 Reviewed-by: Darrick J. Wong --- 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 bd00f4d135af..833c76084f38 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;