On Tue, Nov 30, 2010 at 11:01, Josef Bacik <[email protected]> wrote:
> On Tue, Nov 30, 2010 at 09:37:17AM -0800, Josh Berry wrote:
>> On Tue, Nov 30, 2010 at 08:46, Josef Bacik <[email protected]> wrote:
>> > Btrfs only allocates chunks as we need them, however we do not delete 
>> > chunks as
>> > we stop using them.  This patch adds this capability.  Whenever we clear 
>> > the
>> > last bit of used space in a block group we try and mark it read only, and 
>> > then
>> > when the last pinned space is finally removed we queue up the deletion 
>> > work.
>> > I've tested this with xfstests and my enospc tests.  When filling up the 
>> > disk
>> > I see that we've allocated the entire disk of chunks, and then when I do 
>> > rm *
>> > there is a bunch of space freed up.  Thanks,
>>
>> Stupid user question:
>>
>> I have a btrfs filesystem on a 2.6.36 kernel that used to have ~800GB
>> of data on it.  Then I deleted ~500GB of it (moved it elsewhere), but
>> my space usage as reported by df and the btrfs tool didn't decrease
>> appreciably.  Might this be why?
>>
>
> So without this patch, with a full fs I do this
>
> [r...@test1244 ~]# ./btrfs-progs-unstable/btrfs fi df /mnt/btrfs-test/
> Data: total=980.25MB, used=909.91MB
> System, DUP: total=16.00MB, used=4.00KB
> System: total=4.00MB, used=0.00
> Metadata, DUP: total=511.88MB, used=190.42MB
> Metadata: total=8.00MB, used=0.00
>
> If I removed everything from the fs, you'd still see Data total=980.25MB, but
> used should be close to 0 (this is assuming no snapshots and such).  With this
> patch if I rm -rf /mnt/btrfs/* I get this
>
> [r...@test1244 ~]# ./btrfs-progs-unstable/btrfs fi df /mnt/btrfs-test/
> Data: total=204.75MB, used=192.00KB
> System, DUP: total=16.00MB, used=4.00KB
> System: total=4.00MB, used=0.00
> Metadata, DUP: total=307.12MB, used=24.00KB
> Metadata: total=8.00MB, used=0.00
>
> So that free'd up ~700mb in data space and ~200mb in metadata space that can 
> be
> allocated to either data/metadata based on your usage patterns.  I hope that
> helps explain it.

That makes sense, thanks.

I was still seeing very high data-used, but it turns out there was an
old snapshot I didn't know I had, so the problem was really
stupid-user error. :)

-- Josh
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to