summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub/rtbitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/scrub/rtbitmap.c')
-rw-r--r--fs/xfs/scrub/rtbitmap.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c
index 6cbd3f6413e0..ca17df198cb2 100644
--- a/fs/xfs/scrub/rtbitmap.c
+++ b/fs/xfs/scrub/rtbitmap.c
@@ -9,12 +9,16 @@
#include "xfs_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
+#include "xfs_btree.h"
#include "xfs_log_format.h"
#include "xfs_trans.h"
#include "xfs_rtalloc.h"
#include "xfs_inode.h"
+#include "xfs_rmap.h"
+#include "xfs_rtrmap_btree.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
+#include "scrub/btree.h"
/* Set us up with the realtime metadata locked. */
int
@@ -32,11 +36,31 @@ xchk_setup_rt(
sc->ip = sc->mp->m_rbmip;
xfs_ilock(sc->ip, sc->ilock_flags);
+ if (xfs_sb_version_hasrmapbt(&sc->mp->m_sb)) {
+ unsigned int lockmode = XFS_ILOCK_EXCL;
+
+ xfs_ilock(sc->mp->m_rrmapip, lockmode);
+ xfs_trans_ijoin(sc->tp, sc->mp->m_rrmapip, lockmode);
+ }
+
return 0;
}
/* Realtime bitmap. */
+/* Cross-reference rtbitmap entries with other metadata. */
+STATIC void
+xchk_rtbitmap_xref(
+ struct xfs_scrub *sc,
+ xfs_rtblock_t startblock,
+ xfs_rtblock_t blockcount)
+{
+ if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
+ return;
+
+ xchk_xref_has_no_owner(sc, startblock, blockcount);
+}
+
/* Scrub a free extent record from the realtime bitmap. */
STATIC int
xchk_rtbitmap_rec(
@@ -55,6 +79,8 @@ xchk_rtbitmap_rec(
!xfs_verify_rtbno(sc->mp, startblock) ||
!xfs_verify_rtbno(sc->mp, startblock + blockcount - 1))
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
+
+ xchk_rtbitmap_xref(sc, startblock, blockcount);
return 0;
}
@@ -70,6 +96,10 @@ xchk_rtbitmap(
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
return error;
+ error = xchk_rt_init(sc, &sc->sa);
+ if (error)
+ return error;
+
error = xfs_rtalloc_query_all(sc->tp, xchk_rtbitmap_rec, sc);
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, 0, &error))
goto out;