Skip to content

Commit 0abe6fc

Browse files
author
Darrick J. Wong
committed
xfs: cross-reference rmap records with inode btrees
Strengthen the rmap btree record checker a little more by comparing OWN_INOBT reverse mappings against the inode btrees. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 3a3108e commit 0abe6fc

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

fs/xfs/scrub/rmap.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "xfs_bit.h"
1919
#include "xfs_alloc.h"
2020
#include "xfs_alloc_btree.h"
21+
#include "xfs_ialloc_btree.h"
2122
#include "scrub/scrub.h"
2223
#include "scrub/common.h"
2324
#include "scrub/btree.h"
@@ -56,6 +57,7 @@ struct xchk_rmap {
5657
struct xagb_bitmap fs_owned;
5758
struct xagb_bitmap log_owned;
5859
struct xagb_bitmap ag_owned;
60+
struct xagb_bitmap inobt_owned;
5961

6062
/* Did we complete the AG space metadata bitmaps? */
6163
bool bitmaps_complete;
@@ -299,6 +301,9 @@ xchk_rmapbt_mark_bitmap(
299301
case XFS_RMAP_OWN_AG:
300302
bmp = &cr->ag_owned;
301303
break;
304+
case XFS_RMAP_OWN_INOBT:
305+
bmp = &cr->inobt_owned;
306+
break;
302307
}
303308

304309
if (!bmp)
@@ -430,6 +435,31 @@ xchk_rmapbt_walk_ag_metadata(
430435
error = xfs_agfl_walk(sc->mp, agf, agfl_bp, xchk_rmapbt_walk_agfl,
431436
&cr->ag_owned);
432437
xfs_trans_brelse(sc->tp, agfl_bp);
438+
if (error)
439+
goto out;
440+
441+
/* OWN_INOBT: inobt, finobt */
442+
cur = sc->sa.ino_cur;
443+
if (!cur)
444+
cur = xfs_inobt_init_cursor(sc->sa.pag, sc->tp, sc->sa.agi_bp,
445+
XFS_BTNUM_INO);
446+
error = xagb_bitmap_set_btblocks(&cr->inobt_owned, cur);
447+
if (cur != sc->sa.ino_cur)
448+
xfs_btree_del_cursor(cur, error);
449+
if (error)
450+
goto out;
451+
452+
if (xfs_has_finobt(sc->mp)) {
453+
cur = sc->sa.fino_cur;
454+
if (!cur)
455+
cur = xfs_inobt_init_cursor(sc->sa.pag, sc->tp,
456+
sc->sa.agi_bp, XFS_BTNUM_FINO);
457+
error = xagb_bitmap_set_btblocks(&cr->inobt_owned, cur);
458+
if (cur != sc->sa.fino_cur)
459+
xfs_btree_del_cursor(cur, error);
460+
if (error)
461+
goto out;
462+
}
433463

434464
out:
435465
/*
@@ -475,6 +505,9 @@ xchk_rmapbt_check_bitmaps(
475505

476506
if (xagb_bitmap_hweight(&cr->ag_owned) != 0)
477507
xchk_btree_xref_set_corrupt(sc, cur, level);
508+
509+
if (xagb_bitmap_hweight(&cr->inobt_owned) != 0)
510+
xchk_btree_xref_set_corrupt(sc, cur, level);
478511
}
479512

480513
/* Scrub the rmap btree for some AG. */
@@ -492,6 +525,7 @@ xchk_rmapbt(
492525
xagb_bitmap_init(&cr->fs_owned);
493526
xagb_bitmap_init(&cr->log_owned);
494527
xagb_bitmap_init(&cr->ag_owned);
528+
xagb_bitmap_init(&cr->inobt_owned);
495529

496530
error = xchk_rmapbt_walk_ag_metadata(sc, cr);
497531
if (error)
@@ -505,6 +539,7 @@ xchk_rmapbt(
505539
xchk_rmapbt_check_bitmaps(sc, cr);
506540

507541
out:
542+
xagb_bitmap_destroy(&cr->inobt_owned);
508543
xagb_bitmap_destroy(&cr->ag_owned);
509544
xagb_bitmap_destroy(&cr->log_owned);
510545
xagb_bitmap_destroy(&cr->fs_owned);

0 commit comments

Comments
 (0)