Skip to content

Commit 27e8fcc

Browse files
adam900710kdave
authored andcommitted
btrfs: scrub: cancel the run if there is a pending signal
Unlike relocation, scrub never checks pending signals, and even for relocation is only explicitly checking for fatal signal (SIGKILL), not for regular ones. Thankfully relocation can still be interrupted by regular signals by the usage of wait_on_bit(), which is called with TASK_INTERRUPTIBLE. Do the same for scrub/dev-replace, so that regular signals can also cancel the scrub/replace run, and more importantly handle v2 cgroup freezing which is based on signal handling code inside the kernel, and freezing() function will not return true for v2 cgroup freezing. This will address the problem that systemd slice freezing will timeout on long running scrub/dev-replace. Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 69ccd83 commit 27e8fcc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/scrub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@ static int queue_scrub_stripe(struct scrub_ctx *sctx, struct btrfs_block_group *
20762076
* - -ECANCELED
20772077
* Being explicitly canceled through ioctl.
20782078
* - -EINTR
2079-
* Being interrupted by fs/process freezing.
2079+
* Being interrupted by signal or fs/process freezing.
20802080
*/
20812081
static int should_cancel_scrub(const struct scrub_ctx *sctx)
20822082
{
@@ -2105,7 +2105,7 @@ static int should_cancel_scrub(const struct scrub_ctx *sctx)
21052105
* will timeout, as the running scrub will prevent the fs from being frozen.
21062106
*/
21072107
if (fs_info->sb->s_writers.frozen > SB_UNFROZEN ||
2108-
freezing(current))
2108+
freezing(current) || signal_pending(current))
21092109
return -EINTR;
21102110
return 0;
21112111
}

0 commit comments

Comments
 (0)