On Mon, Nov 12, 2018 at 08:32:41AM +0800, Qu Wenruo wrote: > Commit 93bba24d4b5ad1e5cd8b43f64e66ff9d6355dd20 upstream. > > 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@xxxxxxxxxxxxxxxxx> > CC: stable@xxxxxxxxxxxxxxx # 4.9 > Signed-off-by: Qu Wenruo <wqu@xxxxxxxx> > Reviewed-by: David Sterba <dsterba@xxxxxxxx> > [ add bg_ret and dev_ret to the messages ] > Signed-off-by: David Sterba <dsterba@xxxxxxxx> > --- > fs/btrfs/extent-tree.c | 40 +++++++++++++++++++++++++++++----------- > 1 file changed, 29 insertions(+), 11 deletions(-) Does not apply to the latest 4.9.y tree :( Can you please rebase and resend both of these? thanks, greg k-h