]> www.infradead.org Git - nvme.git/commit
btrfs: add cancellation points to trim loops
authorLuca Stefani <luca.stefani.ge1@gmail.com>
Tue, 17 Sep 2024 20:33:05 +0000 (22:33 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 7 Oct 2024 21:21:56 +0000 (23:21 +0200)
commit69313850dce33ce8c24b38576a279421f4c60996
tree018fa34b1d6dc82cc1379a9b3c76b3c2f6e018ae
parenta99fcb0158978ed332009449b484e5f3ca2d7df4
btrfs: add cancellation points to trim loops

There are reports that system cannot suspend due to running trim because
the task responsible for trimming the device isn't able to finish in
time, especially since we have a free extent discarding phase, which can
trim a lot of unallocated space. There are no limits on the trim size
(unlike the block group part).

Since trime isn't a critical call it can be interrupted at any time,
in such cases we stop the trim, report the amount of discarded bytes and
return an error.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=219180
Link: https://bugzilla.suse.com/show_bug.cgi?id=1229737
CC: stable@vger.kernel.org # 5.15+
Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c
fs/btrfs/free-space-cache.c
fs/btrfs/free-space-cache.h