This is a note to let you know that I've just added the patch titled btrfs: allow swap activation to be interruptible to the 6.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-allow-swap-activation-to-be-interruptible.patch and it can be found in the queue-6.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 6dae8c4a635846f3c57dcf27cbaadd6ecdd1b65e Author: Filipe Manana <fdmanana@xxxxxxxx> Date: Mon Dec 9 16:31:41 2024 +0000 btrfs: allow swap activation to be interruptible [ Upstream commit 9a45022a0efadd99bcc58f7f1cc2b6fb3b808c40 ] During swap activation we iterate over the extents of a file, then do several checks for each extent, some of which may take some significant time such as checking if an extent is shared. Since a file can have many thousands of extents, this can be a very slow operation and it's currently not interruptible. I had a bug during development of a previous patch that resulted in an infinite loop when iterating the extents, so a core was busy looping and I couldn't cancel the operation, which is very annoying and requires a reboot. So make the loop interruptible by checking for fatal signals at the end of each iteration and stopping immediately if there is one. CC: stable@xxxxxxxxxxxxxxx # 5.4+ Reviewed-by: Qu Wenruo <wqu@xxxxxxxx> Signed-off-by: Filipe Manana <fdmanana@xxxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 4b3e256e0d0b..b5cfb85af937 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10056,6 +10056,11 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file, bsi.block_start = physical_block_start; bsi.block_len = len; } + + if (fatal_signal_pending(current)) { + ret = -EINTR; + goto out; + } } if (bsi.block_len)