summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2024-12-09 16:43:44 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-01-02 10:30:55 +0100
commitbb8e287f596b62fac18ed84cc03a9f1752f6b3b8 (patch)
treeaae0271db23512510d8e407b529da5fc1dbfd076
parent6abbbd8286b6f944eecf3c74444c138590135211 (diff)
downloadlinux-bb8e287f596b62fac18ed84cc03a9f1752f6b3b8.tar.gz
linux-bb8e287f596b62fac18ed84cc03a9f1752f6b3b8.tar.bz2
linux-bb8e287f596b62fac18ed84cc03a9f1752f6b3b8.zip
btrfs: avoid monopolizing a core when activating a swap file
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: 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>
-rw-r--r--fs/btrfs/inode.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index eb5f03c3336c..16789490078f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7387,6 +7387,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
ret = -EAGAIN;
goto out;
}
+
+ cond_resched();
}
if (orig_start)