Commit 9b3df1d5 authored by Filipe Manana's avatar Filipe Manana Committed by Wen Zhiwei
Browse files

btrfs: avoid monopolizing a core when activating a swap file

stable inclusion
from stable-v6.6.69
commit 6e1a8225930719a9f352d56320214e33e2dde0a6
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBNEPJ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6e1a8225930719a9f352d56320214e33e2dde0a6



--------------------------------

commit 2c8507c63f5498d4ee4af404a8e44ceae4345056 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: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 2cd3c1b2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -7157,6 +7157,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
			ret = -EAGAIN;
			goto out;
		}

		cond_resched();
	}

	if (orig_start)