summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 11:19:46 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-12-15 17:29:25 -0800
commit04f73643ecba38e603e8cc0e4ec83be7b97fad9f (patch)
tree13f5293fa5c4a27f04d127ece8006141f0ec96f8 /fs/xfs/scrub
parent60b5996b704e4e592674423c6b36b10d94f08446 (diff)
xfs: check new rtbitmap records against rt refcount btree
When we're rebuilding the realtime bitmap, check the proposed free extents against the rt refcount btree to make sure we don't commit any grievous errors. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/scrub')
-rw-r--r--fs/xfs/scrub/repair.c6
-rw-r--r--fs/xfs/scrub/rtbitmap_repair.c13
2 files changed, 19 insertions, 0 deletions
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 327858306cf9..641b3c8c4e40 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -41,6 +41,7 @@
#include "xfs_rtrmap_btree.h"
#include "xfs_rtalloc.h"
#include "xfs_imeta.h"
+#include "xfs_rtrefcount_btree.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/trace.h"
@@ -2062,6 +2063,11 @@ xrep_rt_btcur_init(
xfs_has_rtrmapbt(mp))
sr->rmap_cur = xfs_rtrmapbt_init_cursor(mp, sc->tp,
mp->m_rrmapip);
+
+ if (sc->sm->sm_type != XFS_SCRUB_TYPE_RTREFCBT &&
+ xfs_has_rtreflink(mp))
+ sr->refc_cur = xfs_rtrefcountbt_init_cursor(mp, sc->tp,
+ mp->m_rrefcountip);
}
/* Reinitialize the per-AG block reservation for the AG we just fixed. */
diff --git a/fs/xfs/scrub/rtbitmap_repair.c b/fs/xfs/scrub/rtbitmap_repair.c
index ffd9f132a512..66be199580b8 100644
--- a/fs/xfs/scrub/rtbitmap_repair.c
+++ b/fs/xfs/scrub/rtbitmap_repair.c
@@ -20,6 +20,7 @@
#include "xfs_rmap.h"
#include "xfs_rtrmap_btree.h"
#include "xfs_swapext.h"
+#include "xfs_refcount.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/trace.h"
@@ -79,6 +80,7 @@ xrep_rtbitmap_mark_free(
unsigned int bit;
unsigned int mod;
xfs_rtword_t mask;
+ bool shared;
int error;
if (!xfs_verify_rtext(mp, rb->next_rtbno, next - rb->next_rtbno))
@@ -92,6 +94,17 @@ xrep_rtbitmap_mark_free(
if (mod)
return -EFSCORRUPTED;
+ /* Must not be shared or CoW staging. */
+ if (rb->sc->sr.refc_cur) {
+ error = xfs_refcount_has_record(rb->sc->sr.refc_cur,
+ rb->next_rtbno, next - rb->next_rtbno,
+ &shared);
+ if (error)
+ return error;
+ if (shared)
+ return -EFSCORRUPTED;
+ }
+
trace_xrep_rtbitmap_record_free(mp, start_ext, next_ext - 1);
/* Set bits as needed to round start_ext up to the nearest word. */