From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 032F6C433E0 for ; Thu, 18 Jun 2020 15:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2CF9206FA for ; Thu, 18 Jun 2020 15:37:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AfPVi1ZM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729367AbgFRPhr (ORCPT ); Thu, 18 Jun 2020 11:37:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23761 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727991AbgFRPhq (ORCPT ); Thu, 18 Jun 2020 11:37:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592494665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=20DfsWT8SS89PDM1nQqDrLlfYlI2+7xoKbtxok50PKk=; b=AfPVi1ZMXMgtNG/YVdqgTxLS37mI9ot9Nh4F3XsSux5lqbVhHReL3YSa36Rtv/Pqp7hzyu DEDXUfWh32CaVW/aCcS0ycxldV+vsz55toHPYuQbQz28MQkOjJiRnR8GeomCI/XIrE6H0t gpckHMgiKgRfo0R1CjFJGigsznyVTgg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-WeSFtY97OiaBDnbJ9dJDnA-1; Thu, 18 Jun 2020 11:37:43 -0400 X-MC-Unique: WeSFtY97OiaBDnbJ9dJDnA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69BAA1005513; Thu, 18 Jun 2020 15:37:42 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F04035C1D0; Thu, 18 Jun 2020 15:37:41 +0000 (UTC) Date: Thu, 18 Jun 2020 11:37:40 -0400 From: Brian Foster To: "Darrick J. Wong" Cc: sandeen@sandeen.net, linux-xfs@vger.kernel.org Subject: Re: [PATCH 09/12] xfs_repair: rebuild reverse mapping btrees with bulk loader Message-ID: <20200618153740.GE32216@bfoster> References: <159107201290.315004.4447998785149331259.stgit@magnolia> <159107207124.315004.2948634653215669449.stgit@magnolia> <20200618152511.GC32216@bfoster> <20200618153100.GG11255@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618153100.GG11255@magnolia> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On Thu, Jun 18, 2020 at 08:31:00AM -0700, Darrick J. Wong wrote: > On Thu, Jun 18, 2020 at 11:25:11AM -0400, Brian Foster wrote: > > On Mon, Jun 01, 2020 at 09:27:51PM -0700, Darrick J. Wong wrote: > > > From: Darrick J. Wong > > > > > > Use the btree bulk loading functions to rebuild the reverse mapping > > > btrees and drop the open-coded implementation. > > > > > > Signed-off-by: Darrick J. Wong > > > --- > > > libxfs/libxfs_api_defs.h | 1 > > > repair/agbtree.c | 70 ++++++++ > > > repair/agbtree.h | 5 + > > > repair/phase5.c | 409 ++-------------------------------------------- > > > 4 files changed, 96 insertions(+), 389 deletions(-) > > > > > > > > ... > > > diff --git a/repair/phase5.c b/repair/phase5.c > > > index e570349d..1c6448f4 100644 > > > --- a/repair/phase5.c > > > +++ b/repair/phase5.c > > ... > > > @@ -1244,6 +879,8 @@ build_agf_agfl( > > > freelist = xfs_buf_to_agfl_bno(agfl_buf); > > > fill_agfl(btr_bno, freelist, &agfl_idx); > > > fill_agfl(btr_cnt, freelist, &agfl_idx); > > > + if (xfs_sb_version_hasrmapbt(&mp->m_sb)) > > > + fill_agfl(btr_rmap, freelist, &agfl_idx); > > > > Is this new behavior? Either way, I guess it makes sense since the > > rmapbt feeds from/to the agfl: > > It's a defensive move to make sure we don't lose the blocks if we > overestimate the size of the rmapbt. We never did in the past (and we > shouldn't now) but I figured I should throw that in as a defensive > measure so we don't leak the blocks if something goes wrong. > > (Granted, I think in the past any overages would have been freed back > into the filesystem...) > I thought that was still the case since finish_rebuild() moves any unused blocks over to the lost_fsb slab, which is why I was asking about the agfl filling specifically.. Brian > Thanks for the review. > > --D > > > Reviewed-by: Brian Foster > > > > > > > > /* Set the AGF counters for the AGFL. */ > > > if (agfl_idx > 0) { > > > @@ -1343,7 +980,7 @@ phase5_func( > > > struct bt_rebuild btr_cnt; > > > struct bt_rebuild btr_ino; > > > struct bt_rebuild btr_fino; > > > - bt_status_t rmap_btree_curs; > > > + struct bt_rebuild btr_rmap; > > > bt_status_t refcnt_btree_curs; > > > int extra_blocks = 0; > > > uint num_freeblocks; > > > @@ -1378,11 +1015,7 @@ _("unable to rebuild AG %u. Not enough free space in on-disk AG.\n"), > > > init_ino_cursors(&sc, agno, num_freeblocks, &sb_icount_ag[agno], > > > &sb_ifree_ag[agno], &btr_ino, &btr_fino); > > > > > > - /* > > > - * Set up the btree cursors for the on-disk rmap btrees, which includes > > > - * pre-allocating all required blocks. > > > - */ > > > - init_rmapbt_cursor(mp, agno, &rmap_btree_curs); > > > + init_rmapbt_cursor(&sc, agno, num_freeblocks, &btr_rmap); > > > > > > /* > > > * Set up the btree cursors for the on-disk refcount btrees, > > > @@ -1448,10 +1081,8 @@ _("unable to rebuild AG %u. Not enough free space in on-disk AG.\n"), > > > ASSERT(btr_bno.freeblks == btr_cnt.freeblks); > > > > > > if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { > > > - build_rmap_tree(mp, agno, &rmap_btree_curs); > > > - write_cursor(&rmap_btree_curs); > > > - sb_fdblocks_ag[agno] += (rmap_btree_curs.num_tot_blocks - > > > - rmap_btree_curs.num_free_blocks) - 1; > > > + build_rmap_tree(&sc, agno, &btr_rmap); > > > + sb_fdblocks_ag[agno] += btr_rmap.newbt.afake.af_blocks - 1; > > > } > > > > > > if (xfs_sb_version_hasreflink(&mp->m_sb)) { > > > @@ -1462,7 +1093,7 @@ _("unable to rebuild AG %u. Not enough free space in on-disk AG.\n"), > > > /* > > > * set up agf and agfl > > > */ > > > - build_agf_agfl(mp, agno, &btr_bno, &btr_cnt, &rmap_btree_curs, > > > + build_agf_agfl(mp, agno, &btr_bno, &btr_cnt, &btr_rmap, > > > &refcnt_btree_curs, lost_fsb); > > > > > > build_inode_btrees(&sc, agno, &btr_ino, &btr_fino); > > > @@ -1479,7 +1110,7 @@ _("unable to rebuild AG %u. Not enough free space in on-disk AG.\n"), > > > if (xfs_sb_version_hasfinobt(&mp->m_sb)) > > > finish_rebuild(mp, &btr_fino, lost_fsb); > > > if (xfs_sb_version_hasrmapbt(&mp->m_sb)) > > > - finish_cursor(&rmap_btree_curs); > > > + finish_rebuild(mp, &btr_rmap, lost_fsb); > > > if (xfs_sb_version_hasreflink(&mp->m_sb)) > > > finish_cursor(&refcnt_btree_curs); > > > > > > > > >