linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org, lists@colorremedies.com
Subject: Re: [PATCH] btrfs: Enhance btrfs_trim_fs function to handle error better
Date: Tue, 21 Nov 2017 16:01:22 +0100	[thread overview]
Message-ID: <20171121150122.GM3553@twin.jikos.cz> (raw)
In-Reply-To: <6639f8f2-7842-65ad-bfbb-fa04439b58c2@gmx.com>

On Tue, Nov 21, 2017 at 09:07:01AM +0800, Qu Wenruo wrote:
> On 2017年11月21日 01:51, David Sterba wrote:
> > On Mon, Nov 20, 2017 at 01:56:51PM +0800, Qu Wenruo wrote:
> >> 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.
> >>
> >> And the return value will only reflect the final error from device
> >> trimming.
> >>
> >> This patch will fix such behavior by:
> >>
> >> 1) Recording first error from block group or device trimming
> >>    So return value will also reflect any error found when trimming.
> >>    Make developer more aware of the problem.
> >>
> >> 2) Outputting btrfs warning message for each trimming failure
> >>    Any error for block group or device trimming will cause btrfs warning
> >>    kernel message.
> > 
> > I think this could become too noisy, trimming failures are soft errors
> > IMO, so it should be enough to report all errors cumulatively
> > per-device.
> 
> Although block group trimming errors are not that obvious to be reported
> at per-device base.

The idea is to give an early warning that some device is not all ok, but
fstrim might be the wrong place to do such checks and reports anyway.

> >> @@ -11012,15 +11031,23 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
> >>  	list_for_each_entry(device, devices, dev_alloc_list) {
> >>  		ret = btrfs_trim_free_extents(device, range->minlen,
> >>  					      &group_trimmed);
> >> -		if (ret)
> >> +		if (ret) {
> >> +			btrfs_warn_rl(fs_info,
> >> +		"failed to trim unallocated space for devid %llu ret %d",
> >> +				      device->devid, ret);
> > 
> > So the idea is to print one message here, with devid, number of errors
> > and how many bytes were skipped.
> 
> About number of errors, did you mean also accounting the errors found in
> block group trimming?
> In that case, it may not be related to all devices of a block group.
> 
> So this doesn't look appropriate to account block group errors into
> device error.

Right, the more I think about that, the per-device reports make less
sense.

After another look to btrfs_trim_free_extents, there are some error
cases that are not fatal and mostly related to interrupting the whole
operation, so this needs to be reworked.

      reply	other threads:[~2017-11-21 15:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-20  5:56 [PATCH] btrfs: Enhance btrfs_trim_fs function to handle error better Qu Wenruo
2017-11-20 17:51 ` David Sterba
2017-11-21  1:07   ` Qu Wenruo
2017-11-21 15:01     ` David Sterba [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171121150122.GM3553@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.com \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).