]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Always trim all unallocated space in btrfs_trim_free_extents
authorNikolay Borisov <nborisov@suse.com>
Mon, 3 Jun 2019 10:06:00 +0000 (13:06 +0300)
committerDavid Sterba <dsterba@suse.com>
Fri, 7 Jun 2019 12:52:05 +0000 (14:52 +0200)
commita86af15f311944440df3448e21918798bb424e7f
tree11af4b39c6e5589054d62fbbd23a5ea231d62266
parente6144fcff21ef28d3d8c295777b0cea03ba5f1f0
btrfs: Always trim all unallocated space in btrfs_trim_free_extents

This patch removes support for range parameters of FITRIM ioctl when
trimming unallocated space on devices. This is necessary since ranges
passed from user space are generally interpreted as logical addresses,
whereas btrfs_trim_free_extents used to interpret them as device
physical extents. This could result in counter-intuitive behavior for
users so it's best to remove that support altogether.

Additionally, the existing range support had a bug where if an offset
was passed to FITRIM which overflows u64 e.g. -1 (parsed as u64
18446744073709551615) then wrong data was fed into btrfs_issue_discard,
which in turn leads to wrap-around when aligning the passed range and
results in wrong regions being discarded which leads to data corruption.

Fixes: c01ec5df310c ("btrfs: Honour FITRIM range constraints during free space trim")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c