Skip to content

Commit 9a45022

Browse files
fdmananakdave
authored andcommitted
btrfs: allow swap activation to be interruptible
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@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>
1 parent 03018e5 commit 9a45022

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/btrfs/inode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10073,6 +10073,11 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
1007310073
bsi.block_start = physical_block_start;
1007410074
bsi.block_len = len;
1007510075
}
10076+
10077+
if (fatal_signal_pending(current)) {
10078+
ret = -EINTR;
10079+
goto out;
10080+
}
1007610081
}
1007710082

1007810083
if (bsi.block_len)

0 commit comments

Comments
 (0)