summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs/xfs_rmap.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-04-11 19:00:04 -0700
committerDarrick J. Wong <djwong@kernel.org>2023-04-11 19:00:04 -0700
commitee12eaaa435a7be17152ac50943ee77249de624a (patch)
treefc7b010f0de443c60d9daa0cc6137b97ad60a1e2 /fs/xfs/libxfs/xfs_rmap.c
parent69010fe3ac1fe9932a64268c32b67964fe5c06a8 (diff)
xfs: complain about bad records in query_range helpers
For every btree type except for the bmbt, refactor the code that complains about bad records into a helper and make the ->query_range helpers call it so that corruptions found via that avenue are logged. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_rmap.c')
-rw-r--r--fs/xfs/libxfs/xfs_rmap.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 5c7b081cef87..641114a023f2 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -235,6 +235,24 @@ xfs_rmap_check_irec(
return NULL;
}
+static inline int
+xfs_rmap_complain_bad_rec(
+ struct xfs_btree_cur *cur,
+ xfs_failaddr_t fa,
+ const struct xfs_rmap_irec *irec)
+{
+ struct xfs_mount *mp = cur->bc_mp;
+
+ xfs_warn(mp,
+ "Reverse Mapping BTree record corruption in AG %d detected at %pS!",
+ cur->bc_ag.pag->pag_agno, fa);
+ xfs_warn(mp,
+ "Owner 0x%llx, flags 0x%x, start block 0x%x block count 0x%x",
+ irec->rm_owner, irec->rm_flags, irec->rm_startblock,
+ irec->rm_blockcount);
+ return -EFSCORRUPTED;
+}
+
/*
* Get the data from the pointed-to record.
*/
@@ -244,8 +262,6 @@ xfs_rmap_get_rec(
struct xfs_rmap_irec *irec,
int *stat)
{
- struct xfs_mount *mp = cur->bc_mp;
- struct xfs_perag *pag = cur->bc_ag.pag;
union xfs_btree_rec *rec;
xfs_failaddr_t fa;
int error;
@@ -258,18 +274,9 @@ xfs_rmap_get_rec(
if (!fa)
fa = xfs_rmap_check_irec(cur, irec);
if (fa)
- goto out_bad_rec;
+ return xfs_rmap_complain_bad_rec(cur, fa, irec);
return 0;
-out_bad_rec:
- xfs_warn(mp,
- "Reverse Mapping BTree record corruption in AG %d detected at %pS!",
- pag->pag_agno, fa);
- xfs_warn(mp,
- "Owner 0x%llx, flags 0x%x, start block 0x%x block count 0x%x",
- irec->rm_owner, irec->rm_flags, irec->rm_startblock,
- irec->rm_blockcount);
- return -EFSCORRUPTED;
}
struct xfs_find_left_neighbor_info {
@@ -2335,10 +2342,13 @@ xfs_rmap_query_range_helper(
{
struct xfs_rmap_query_range_info *query = priv;
struct xfs_rmap_irec irec;
+ xfs_failaddr_t fa;
- if (xfs_rmap_btrec_to_irec(rec, &irec) != NULL ||
- xfs_rmap_check_irec(cur, &irec) != NULL)
- return -EFSCORRUPTED;
+ fa = xfs_rmap_btrec_to_irec(rec, &irec);
+ if (!fa)
+ fa = xfs_rmap_check_irec(cur, &irec);
+ if (fa)
+ return xfs_rmap_complain_bad_rec(cur, fa, &irec);
return query->fn(cur, &irec, query->priv);
}