linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why do full balance and deduplication reduce available free space?
@ 2017-10-02 10:02 Niccolò Belli
  2017-10-02 10:16 ` Hans van Kranenburg
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Niccolò Belli @ 2017-10-02 10:02 UTC (permalink / raw)
  To: linux-btrfs

Hi,
I have several subvolumes mounted with compress-force=lzo and autodefrag. 
Since I use lots of snapshots (snapper keeps around 24 hourly snapshots, 7 
daily snapshots and 4 weekly snapshots) I had to create a systemd timer to 
perform a full balance and deduplication each night. In fact data needs to 
be already deduplicated when snapshots are created, otherwise I have no 
other way to deduplicate snapshots.

This is how I performe balance: btrfs balance start --full-balance rootfs
This is how I perform deduplication (duperemove is from git master):
duperemove -drh --dedupe-options=noblock --hashfile=../rootfs.hash 
<all_subvols_except_snapshots_ones>

Looking at the logs I noticed something weird: available free space 
actually decreases after balance or deduplication.

This is just before the timer starts:

Overall:
    Device size:                 128.00GiB
    Device allocated:             49.03GiB
    Device unallocated:           78.97GiB
    Device missing:                  0.00B
    Used:                         43.78GiB
    Free (estimated):             82.97GiB      (min: 82.97GiB)
    Data ratio:                       1.00
    Metadata ratio:                   1.00
    Global reserve:              512.00MiB      (used: 0.00B)

Data,single: Size:44.00GiB, Used:40.00GiB
   /dev/sda5      44.00GiB

Metadata,single: Size:5.00GiB, Used:3.78GiB
   /dev/sda5       5.00GiB

System,single: Size:32.00MiB, Used:16.00KiB
   /dev/sda5      32.00MiB

Unallocated:
   /dev/sda5      78.97GiB



I also manually performed a full balance just before the timer starts:

Overall:
    Device size:                 128.00GiB
    Device allocated:             46.03GiB
    Device unallocated:           81.97GiB
    Device missing:                  0.00B
    Used:                         43.78GiB
    Free (estimated):             82.96GiB      (min: 82.96GiB)
    Data ratio:                       1.00
    Metadata ratio:                   1.00
    Global reserve:              512.00MiB      (used: 0.00B)

Data,single: Size:41.00GiB, Used:40.01GiB
   /dev/sda5      41.00GiB

Metadata,single: Size:5.00GiB, Used:3.77GiB
   /dev/sda5       5.00GiB

System,single: Size:32.00MiB, Used:16.00KiB
   /dev/sda5      32.00MiB

Unallocated:
   /dev/sda5      81.97GiB



As you can see even doing a full balance was enough to reduce the available 
free space!

Then the timer started and it performed the deduplication:

Overall:
    Device size:                 128.00GiB
    Device allocated:             46.03GiB
    Device unallocated:           81.97GiB
    Device missing:                  0.00B
    Used:                         43.87GiB
    Free (estimated):             82.94GiB      (min: 82.94GiB)
    Data ratio:                       1.00
    Metadata ratio:                   1.00
    Global reserve:              512.00MiB      (used: 176.00KiB)

Data,single: Size:41.00GiB, Used:40.03GiB
   /dev/sda5      41.00GiB

Metadata,single: Size:5.00GiB, Used:3.84GiB
   /dev/sda5       5.00GiB

System,single: Size:32.00MiB, Used:16.00KiB
   /dev/sda5      32.00MiB

Unallocated:
   /dev/sda5      81.97GiB



Once again it reduced the available free space!

Then, after the deduplication, the timer also performed a full balance:

Overall:
    Device size:                 128.00GiB
    Device allocated:             46.03GiB
    Device unallocated:           81.97GiB
    Device missing:                  0.00B
    Used:                         44.00GiB
    Free (estimated):             82.93GiB      (min: 82.93GiB)
    Data ratio:                       1.00
    Metadata ratio:                   1.00
    Global reserve:              512.00MiB      (used: 0.00B)

Data,single: Size:41.00GiB, Used:40.04GiB
   /dev/sda5      41.00GiB

Metadata,single: Size:5.00GiB, Used:3.97GiB
   /dev/sda5       5.00GiB

System,single: Size:32.00MiB, Used:16.00KiB
   /dev/sda5      32.00MiB

Unallocated:
   /dev/sda5      81.97GiB




It further reduced the available free space! Balance and deduplication 
actually reduced my available free space of 400MB!
400MB each night!
How is it possible? Should I avoid doing balances and deduplications at 
all?

Thanks,
Niccolò

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-10-09 17:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-02 10:02 Why do full balance and deduplication reduce available free space? Niccolò Belli
2017-10-02 10:16 ` Hans van Kranenburg
2017-10-02 10:29   ` Niccolò Belli
2017-10-02 11:14     ` Paul Jones
2017-10-02 11:26       ` Is it really possible to dedupe read-only snapshots!? Niccolò Belli
2017-10-02 14:15 ` Why do full balance and deduplication reduce available free space? Niccolò Belli
2017-10-02 19:35 ` Kai Krakow
2017-10-02 20:19   ` Niccolò Belli
2017-10-09 17:38     ` Kai Krakow
2017-10-02 20:27 ` Goffredo Baroncelli

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).