btrfs: auto enable discard=async when possible
authorDavid Sterba <dsterba@suse.com>
Tue, 26 Jul 2022 18:54:10 +0000 (20:54 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:41 +0000 (18:00 +0100)
commit63a7cb13071842966c1ce931edacbc23573aada5
treef888ce16a46f6aad0414e3457b15f0bcf416e615
parent467761f90405004e58795116aa7d81f3d298dcfb
btrfs: auto enable discard=async when possible

There's a request to automatically enable async discard for capable
devices. We can do that, the async mode is designed to wait for larger
freed extents and is not intrusive, with limits to iops, kbps or latency.

The status and tunables will be exported in /sys/fs/btrfs/FSID/discard .

The automatic selection is done if there's at least one discard capable
device in the filesystem (not capable devices are skipped). Mounting
with any other discard option will honor that option, notably mounting
with nodiscard will keep it disabled.

Link: https://lore.kernel.org/linux-btrfs/CAEg-Je_b1YtdsCR0zS5XZ_SbvJgN70ezwvRwLiCZgDGLbeMB=w@mail.gmail.com/
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/super.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h