Skip to content

Commit 6e1a822

Browse files
fdmananagregkh
authored andcommitted
btrfs: avoid monopolizing a core when activating a swap file
commit 2c8507c upstream. During swap activation we iterate over the extents of a file and we can have many thousands of them, so we can end up in a busy loop monopolizing a core. Avoid this by doing a voluntary reschedule after processing each extent. CC: [email protected] # 5.4+ Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 13eb3ca commit 6e1a822

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7153,6 +7153,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
71537153
ret = -EAGAIN;
71547154
goto out;
71557155
}
7156+
7157+
cond_resched();
71567158
}
71577159

71587160
if (orig_start)

0 commit comments

Comments
 (0)