Skip to content

Commit a12cb6f

Browse files
author
Kent Overstreet
committed
bcachefs: Fix accidental O(n^2) in fiemap
Since bch2_seek_pagecache_data() searches for dirty data, we only want to call it for holes in the extents btree - otherwise we have an accidental O(n^2), as we repeatedly search the same range. Reported-by: Marcin Mirosław <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 43b9fec commit a12cb6f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/bcachefs/fs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,9 @@ static int bch2_next_fiemap_extent(struct btree_trans *trans,
14291429
if (ret)
14301430
goto err;
14311431

1432-
ret = bch2_next_fiemap_pagecache_extent(trans, inode, start, end, cur);
1432+
u64 pagecache_end = k.k ? max(start, bkey_start_offset(k.k)) : end;
1433+
1434+
ret = bch2_next_fiemap_pagecache_extent(trans, inode, start, pagecache_end, cur);
14331435
if (ret)
14341436
goto err;
14351437

0 commit comments

Comments
 (0)