]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: handle user interrupt properly in btrfs_trim_fs()
authorjinbaohong <jinbaohong@synology.com>
Wed, 28 Jan 2026 07:06:40 +0000 (07:06 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:56:25 +0000 (07:56 +0100)
commitbfb670b9183b0e4ba660aff2e396ec1cc01d0761
tree0482c2f098e96faf9f02484767af6ecd6b38b5f6
parent1cc4ada4182fadb82837831cabf1027bff0322d7
btrfs: handle user interrupt properly in btrfs_trim_fs()

When a fatal signal is pending or the process is freezing,
btrfs_trim_block_group() and btrfs_trim_free_extents() return -ERESTARTSYS.
Currently this is treated as a regular error: the loops continue to the
next iteration and count it as a block group or device failure.

Instead, break out of the loops immediately and return -ERESTARTSYS to
userspace without counting it as a failure. Also skip the device loop
entirely if the block group loop was interrupted.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Robbie Ko <robbieko@synology.com>
Signed-off-by: jinbaohong <jinbaohong@synology.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c