From patchwork Sun Sep 3 07:29:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9936019 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 C08A46037D for ; Sun, 3 Sep 2017 07:30:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B25B528632 for ; Sun, 3 Sep 2017 07:30:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A738F2868D; Sun, 3 Sep 2017 07:30:31 +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 4492228632 for ; Sun, 3 Sep 2017 07:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751756AbdICHaa (ORCPT ); Sun, 3 Sep 2017 03:30:30 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:44908 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751702AbdICHaa (ORCPT ); Sun, 3 Sep 2017 03:30:30 -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=5jCA8AXedypHbFic+xVrHbSkFU45Jeao9iuW/yYJzJY=; b=oN7hIghcO3/hMA4z8owe4zcyq NmDlssQYzPROSrZ6xQfWwzHpW/dRqamqgOlrVVUcBkHmbZ5wMwgyXRiZwA4zHVwAQUrkVhjU2NwB0 hnKGc7TRy+FwANuDg00Z4QVWyZ8qy3PmL7/Uzu/Dgj4GwhWWJjsd8oDKHUnOTCHX3mFrZoWzrtqgf 396f0Cm0HD1NXvI3H5HdUKjX9iai5Bi6Okn31QjRr5paHUCOwngbZ96+pDQDRs6NeUO29dSOBOY4M kpgfCQd9lrzLP0dHBsnSvWXF9kJZ/PkBarabMMLvOiEX2Tw9Rt9wDW8CGzpcpmmFAlucjdFvCi62T mnSF0Q7cg==; Received: from [91.114.64.3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1doPMT-00078P-NH for linux-xfs@vger.kernel.org; Sun, 03 Sep 2017 07:30:30 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 10/17] xfs: refactor xfs_bmap_add_extent_hole_real Date: Sun, 3 Sep 2017 09:29:49 +0200 Message-Id: <20170903072956.3175-11-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_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 | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index eae66f7999c8..05d4778ce528 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -2860,6 +2860,7 @@ xfs_bmap_add_extent_hole_real( xfs_bmbt_irec_t right; /* right neighbor extent entry */ int rval=0; /* return value (logging flags) */ int state; /* state bits, accessed thru macros */ + struct xfs_bmbt_irec old; ASSERT(*idx >= 0); ASSERT(*idx <= xfs_iext_count(ifp)); @@ -2929,9 +2930,8 @@ xfs_bmap_add_extent_hole_real( */ --*idx; trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); - xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, *idx), - left.br_blockcount + new->br_blockcount + - right.br_blockcount); + left.br_blockcount += new->br_blockcount + right.br_blockcount; + 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); @@ -2958,10 +2958,7 @@ xfs_bmap_add_extent_hole_real( XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); error = xfs_bmbt_update(cur, left.br_startoff, left.br_startblock, - left.br_blockcount + - new->br_blockcount + - right.br_blockcount, - left.br_state); + left.br_blockcount, left.br_state); if (error) goto done; } @@ -2974,26 +2971,25 @@ xfs_bmap_add_extent_hole_real( * Merge the new allocation with the left neighbor. */ --*idx; + old = left; trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); - xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, *idx), - left.br_blockcount + new->br_blockcount); + left.br_blockcount += new->br_blockcount; + xfs_iext_update_extent(ifp, *idx, &left); trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); if (cur == NULL) { rval = xfs_ilog_fext(whichfork); } else { rval = 0; - error = xfs_bmbt_lookup_eq(cur, left.br_startoff, - left.br_startblock, left.br_blockcount, + error = xfs_bmbt_lookup_eq(cur, old.br_startoff, + old.br_startblock, old.br_blockcount, &i); if (error) goto done; XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); error = xfs_bmbt_update(cur, left.br_startoff, left.br_startblock, - left.br_blockcount + - new->br_blockcount, - left.br_state); + left.br_blockcount, left.br_state); if (error) goto done; } @@ -3005,29 +3001,27 @@ xfs_bmap_add_extent_hole_real( * on the right. * Merge the new allocation with the right neighbor. */ + old = right; trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); - xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, *idx), - new->br_startoff, new->br_startblock, - new->br_blockcount + right.br_blockcount, - right.br_state); + right.br_startoff = new->br_startoff; + right.br_startblock = new->br_startblock; + right.br_blockcount += new->br_blockcount; + xfs_iext_update_extent(ifp, *idx, &right); trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); if (cur == NULL) { rval = xfs_ilog_fext(whichfork); } else { rval = 0; - error = xfs_bmbt_lookup_eq(cur, - right.br_startoff, - right.br_startblock, - right.br_blockcount, &i); + error = xfs_bmbt_lookup_eq(cur, old.br_startoff, + old.br_startblock, old.br_blockcount, + &i); if (error) goto done; XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); - error = xfs_bmbt_update(cur, new->br_startoff, - new->br_startblock, - new->br_blockcount + - right.br_blockcount, - right.br_state); + error = xfs_bmbt_update(cur, right.br_startoff, + right.br_startblock, + right.br_blockcount, right.br_state); if (error) goto done; }