]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Enhance btrfs_trim_fs function to handle error better
authorQu Wenruo <wqu@suse.com>
Fri, 7 Sep 2018 06:16:23 +0000 (14:16 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 15 Oct 2018 15:23:32 +0000 (17:23 +0200)
commitbf018171072ea4e39f9815df92d5239550a51d69
tree2451183c2a6d66f33588535be87b5bf39b7da771
parent6ce09dccc305bdf73d4d3eaede6db5a0c9c0395a
btrfs: Enhance btrfs_trim_fs function to handle error better

Function btrfs_trim_fs() doesn't handle errors in a consistent way. If
error happens when trimming existing block groups, it will skip the
remaining blocks and continue to trim unallocated space for each device.

The return value will only reflect the final error from device trimming.

This patch will fix such behavior by:

1) Recording the last error from block group or device trimming
   The return value will also reflect the last error during trimming.
   Make developer more aware of the problem.

2) Continuing trimming if possible
   If we failed to trim one block group or device, we could still try
   the next block group or device.

3) Report number of failures during block group and device trimming
   It would be less noisy, but still gives user a brief summary of
   what's going wrong.

Such behavior can avoid confusion for cases like failure to trim the
first block group and then only unallocated space is trimmed.

Reported-by: Chris Murphy <lists@colorremedies.com>
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ add bg_ret and dev_ret to the messages ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c