[PATCH 7/7] xfs_repair: use libxfs_verify_rtbno to verify rt extents

Darrick J. Wong
2020-09-07T17:53:46Z

From: Darrick J. Wong <darrick.wong@oracle.com>

Use the existing realtime block validation function to check the first
and last block of an extent in a realtime file.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
repair/dinode.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/repair/dinode.c b/repair/dinode.c
index 7577b50ffb2b..24ad6f0f071e 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -176,16 +176,15 @@ verify_dfsbno_range(

return XR_DFSBNORANGE_VALID;
}
-
static int
process_rt_rec(
- xfs_mount_t *mp,
- xfs_bmbt_irec_t *irec,
+ struct xfs_mount *mp,
+ struct xfs_bmbt_irec *irec,
xfs_ino_t ino,
xfs_rfsblock_t *tot,
int check_dups)
{
- xfs_fsblock_t b;
+ xfs_fsblock_t b, lastb;
xfs_rtblock_t ext;
int state;
int pwe; /* partially-written extent */
@@ -193,7 +192,7 @@ process_rt_rec(
/*
* check numeric validity of the extent
*/
- if (irec->br_startblock >= mp->m_sb.sb_rblocks) {
+ if (!libxfs_verify_rtbno(mp, irec->br_startblock)) {
do_warn(
_("inode %" PRIu64 " - bad rt extent start block number %" PRIu64 ", offset %" PRIu64 "\n"),
ino,
@@ -201,21 +200,23 @@ _("inode %" PRIu64 " - bad rt extent start block number %" PRIu64 ", offset %" P
irec->br_startoff);
return 1;
}
- if (irec->br_startblock + irec->br_blockcount - 1 >= mp->m_sb.sb_rblocks) {
+
+ lastb = irec->br_startblock + irec->br_blockcount - 1;
+ if (!libxfs_verify_rtbno(mp, lastb)) {
do_warn(
_("inode %" PRIu64 " - bad rt extent last block number %" PRIu64 ", offset %" PRIu64 "\n"),
ino,
- irec->br_startblock + irec->br_blockcount - 1,
+ lastb,
irec->br_startoff);
return 1;
}
- if (irec->br_startblock + irec->br_blockcount - 1 < irec->br_startblock) {
+ if (lastb < irec->br_startblock) {
do_warn(
_("inode %" PRIu64 " - bad rt extent overflows - start %" PRIu64 ", "
"end %" PRIu64 ", offset %" PRIu64 "\n"),
ino,
irec->br_startblock,
- irec->br_startblock + irec->br_blockcount - 1,
+ lastb,
irec->br_startoff);
return 1;
}