Skip to content

Commit 9f372e8

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: stable@vger.kernel.org # 5.4+ Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f6174bb commit 9f372e8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/btrfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7117,6 +7117,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
71177117
ret = -EAGAIN;
71187118
goto out;
71197119
}
7120+
7121+
cond_resched();
71207122
}
71217123

71227124
if (file_extent)

0 commit comments

Comments
 (0)