linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: lutz.euler@freenet.de (Lutz Euler)
To: Liu Bo <liubo2009@cn.fujitsu.com>, linux-btrfs@vger.kernel.org
Subject: Re: Bulk discard doesn't work after add/delete of devices
Date: Tue, 14 Feb 2012 18:32:31 +0100	[thread overview]
Message-ID: <20282.39599.228651.376423@localhost.localdomain> (raw)
In-Reply-To: <4F38A665.4030506@cn.fujitsu.com>

Hi,

Liu Bo wrote:

> Actually I have no idea how to deal with this properly :(
> 
> Because btrfs supports multi-devices so that we have to set the
> filesystem logical range to [0, (u64)-1] to get things to work well,
> while other filesystems's logical range is [0, device's total_bytes].
> 
> What's more, in btrfs, devices can be mirrored to RAID, and the free
> space is also ordered by logical addr [0, (u64)-1], so IMO it is
> impossible to interpreted the range.

I do not concur with this reasoning, but please see below that I concur
with your conclusion.

I still think that the range could be interpreted like I hinted at in my
mail:

>> So, to make bulk discard of ranges useful, it seems the incoming range
>> should be interpreted relative to the size of the filesystem and not
>> to the allocated chunks. As AFAIK the size of the filesystem is just
>> the sum of the sizes of its devices it might be possible to map the
>> range onto a virtual concatenation of the devices, these perhaps
>> ordered by devid, and then to find the free space by searching for the
>> resulting devid(s) and device-relative offsets in the device tree?

This would only be somewhat difficult to use if the filesystem consisted
of a mixture of non trim-capable and trim-capable devices and if the
idea behind ranges is that the user can expect an equal amount of
trim-capable storage behind different equally sized ranges - but I don't
know if this is indeed an idea behind ranges. If, on the other hand,
there is a way outside of the ioctl to find out which devices the
filesystem consists of and which of these support discard, the above
mentioned way to interpret ranges would extend to this setting.

But maybe this would already be too ugly, essentially working around
the shortcomings of an interface that is too restricted.

Moreover, I don't know why ranges smaller than the filesystem are
supported by fstrim. I couldn't find any use cases or rationale for it
in fstrim's or the ioctl's documentation or elsewhere. This makes it
difficult to find out what might be useful in the case of a multi-device
filesystem ;-)

So, with ranges being this unclear, I concur with your suggestion:

> I'd better pick up "treat the "trim the complete filesystem" case
> specially", and drop the following commit:
>
> commit f4c697e6406da5dd445eda8d923c53e1138793dd
> Author: Lukas Czerner <lczerner@redhat.com>
> Date:   Mon Sep 5 16:34:54 2011 +0200
>
>     btrfs: return EINVAL if start > total_bytes in fitrim ioctl

More specifically, what I do wish for is:
- Fix the problem I started the thread for: Make fstrim of the complete
  filesystem work.
And then, if possible:
- Simplify btrfs_trim_fs as much as possible to remove all traces
  of support for ranges smaller than the filesystem, document that this
  anyway wouldn't do what the user might expect, and, if possible,
  return an error in these cases.
- Also trim unallocated space (for use after balancing and at mkfs
  time).

Thanks for your time and your work,

Lutz

  reply	other threads:[~2012-02-14 17:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-05 20:37 Bulk discard doesn't work after add/delete of devices Lutz Euler
2012-02-09  8:42 ` Liu Bo
2012-02-09 15:50   ` Lutz Euler
2012-02-10  1:56     ` Liu Bo
2012-02-12 17:01       ` Lutz Euler
2012-02-13  5:57         ` Liu Bo
2012-02-14 17:32           ` Lutz Euler [this message]
2012-02-29  0:17         ` Lutz Euler
2012-04-10 17:34           ` Lutz Euler
2012-11-14 21:10             ` Lutz Euler
2012-11-14 21:17               ` [PATCH] Btrfs: really fix trim 0 bytes after a device delete Lutz Euler
2015-01-03 15:30                 ` [PATCH V2] " Lutz Euler
2015-01-03 16:16                   ` fstrim not working on one of three BTRFS filesystems Lutz Euler
2015-05-19 15:18                     ` Rich Freeman
2015-01-05 16:59                   ` [PATCH V2] Btrfs: really fix trim 0 bytes after a device delete Martin Steigerwald
2015-01-05 19:29                     ` Lutz Euler
2015-05-01 10:43                   ` Martin Steigerwald
  -- strict thread matches above, loose matches on Subject: below --
2014-12-28 16:58 fstrim not working on one of three BTRFS filesystems Martin Steigerwald
2014-12-29  1:53 ` Robert White
2014-12-29  2:08 ` Duncan
2014-12-29  9:06   ` Martin Steigerwald
2014-12-29 13:23 ` Martin Steigerwald

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=20282.39599.228651.376423@localhost.localdomain \
    --to=lutz.euler@freenet.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=liubo2009@cn.fujitsu.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).