Skip to content

Commit e354381

Browse files
Dave Chinnerdchinner
authored andcommitted
xfs: bmapbt checking on debug kernels too expensive
For large sparse or fragmented files, checking every single entry in the bmapbt on every operation is prohibitively expensive. Especially as such checks rarely discover problems during normal operations on high extent coutn files. Our regression tests don't tend to exercise files with hundreds of thousands to millions of extents, so mostly this isn't noticed. However, trying to run things like xfs_mdrestore of large filesystem dumps on a debug kernel quickly becomes impossible as the CPU is completely burnt up repeatedly walking the sparse file bmapbt that is generated for every allocation that is made. Hence, if the file has more than 10,000 extents, just don't bother with walking the tree to check it exhaustively. The btree code has checks that ensure that the newly inserted/removed/modified record is correctly ordered, so the entrie tree walk in thses cases has limited additional value. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Brian Foster <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent 121e213 commit e354381

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,11 @@ xfs_check_block(
325325

326326
/*
327327
* Check that the extents for the inode ip are in the right order in all
328-
* btree leaves.
328+
* btree leaves. THis becomes prohibitively expensive for large extent count
329+
* files, so don't bother with inodes that have more than 10,000 extents in
330+
* them. The btree record ordering checks will still be done, so for such large
331+
* bmapbt constructs that is going to catch most corruptions.
329332
*/
330-
331333
STATIC void
332334
xfs_bmap_check_leaf_extents(
333335
xfs_btree_cur_t *cur, /* btree cursor or null */
@@ -352,6 +354,10 @@ xfs_bmap_check_leaf_extents(
352354
return;
353355
}
354356

357+
/* skip large extent count inodes */
358+
if (ip->i_d.di_nextents > 10000)
359+
return;
360+
355361
bno = NULLFSBLOCK;
356362
mp = ip->i_mount;
357363
ifp = XFS_IFORK_PTR(ip, whichfork);

0 commit comments

Comments
 (0)