Skip to content

Commit 6772fcc

Browse files
author
Darrick J. Wong
committed
xfs: convert xbitmap to interval tree
Convert the xbitmap code to use interval trees instead of linked lists. This reduces the amount of coding required to handle the disunion operation and in the future will make it easier to set bits in arbitrary order yet later be able to extract maximally sized extents, which we'll need for rebuilding certain structures. We define our own interval tree type so that it can deal with 64-bit indices even on 32-bit machines. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 7296a6d commit 6772fcc

3 files changed

Lines changed: 185 additions & 157 deletions

File tree

fs/xfs/scrub/agheader_repair.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ xrep_agfl_fill(
663663
}
664664

665665
/* Write out a totally new AGFL. */
666-
STATIC void
666+
STATIC int
667667
xrep_agfl_init_header(
668668
struct xfs_scrub *sc,
669669
struct xfs_buf *agfl_bp,
@@ -676,6 +676,7 @@ xrep_agfl_init_header(
676676
};
677677
struct xfs_mount *mp = sc->mp;
678678
struct xfs_agfl *agfl;
679+
int error;
679680

680681
ASSERT(flcount <= xfs_agfl_size(mp));
681682

@@ -697,12 +698,15 @@ xrep_agfl_init_header(
697698
xbitmap_init(&af.used_extents);
698699
af.agfl_bno = xfs_buf_to_agfl_bno(agfl_bp),
699700
xbitmap_walk(agfl_extents, xrep_agfl_fill, &af);
700-
xbitmap_disunion(agfl_extents, &af.used_extents);
701+
error = xbitmap_disunion(agfl_extents, &af.used_extents);
702+
if (error)
703+
return error;
701704

702705
/* Write new AGFL to disk. */
703706
xfs_trans_buf_set_type(sc->tp, agfl_bp, XFS_BLFT_AGFL_BUF);
704707
xfs_trans_log_buf(sc->tp, agfl_bp, 0, BBTOB(agfl_bp->b_length) - 1);
705708
xbitmap_destroy(&af.used_extents);
709+
return 0;
706710
}
707711

708712
/* Repair the AGFL. */
@@ -755,7 +759,9 @@ xrep_agfl(
755759
* buffers until we know that part works.
756760
*/
757761
xrep_agfl_update_agf(sc, agf_bp, flcount);
758-
xrep_agfl_init_header(sc, agfl_bp, &agfl_extents, flcount);
762+
error = xrep_agfl_init_header(sc, agfl_bp, &agfl_extents, flcount);
763+
if (error)
764+
goto err;
759765

760766
/*
761767
* Ok, the AGFL should be ready to go now. Roll the transaction to

0 commit comments

Comments
 (0)