]> www.infradead.org Git - users/hch/xfsprogs.git/commit
xfs_repair: fix maximum file offset comparison
authorDarrick J. Wong <djwong@kernel.org>
Thu, 21 Nov 2024 00:24:22 +0000 (16:24 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 28 Nov 2024 02:33:13 +0000 (18:33 -0800)
commit24111e5e7bcd7ab4a755f8622d315e98cd8f7c74
tree4b0b45f9da5d3ee996b0c3d461518604c96d91ae
parentf22f2ed8dc22ba3bec01349ece0aa76f2da6b539
xfs_repair: fix maximum file offset comparison

When running generic/525 with rtinherit=1 and rextsize=28k, generic/525
trips over the following block mapping:

data offset 2251799813685247 startblock 7 (0/7) count 1 flag 0
data offset 2251799813685248 startblock 8 (0/8) count 6 flag 1

with this error:

inode 155 - extent exceeds max offset - start 2251799813685248, count 6,
physical block 8

This is due to an incorrect check in xfs_repair, which tries to validate
that a block mapping cannot exceed what it thinks is the maximum file
offset.  Unfortunately, the check is wrong, because only br_startoff is
subject to the 2^52-1 limit -- not br_startoff + br_blockcount.

Nowadays libxfs provides a symbol XFS_MAX_FILEOFF for the maximum
allowable file block offset that can be mapped into a file.  Use this
instead of the open-coded logic in versions.c and correct all the other
checks.  Note that this problem only surfaced when rtgroups were enabled
because hch changed xfs_repair to use the same tree-based block state
data structure that we use for AGs when rtgroups are enabled.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
repair/dinode.c
repair/globals.c
repair/globals.h
repair/prefetch.c
repair/versions.c