summaryrefslogtreecommitdiff
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-10-22 16:41:11 -0700
commit0e2e50ea5a14f9969be1cc2929844409df31ccfe (patch)
tree62623d542700458e7518792c0bf48302e0e4e962
parent3cb516472b8d71a2b5d29902f125ac48767f75eb (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>
-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 934c129a99be..0b7071461224 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"
@@ -1677,6 +1678,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 494460e81acc..531a663fe9af 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. */