kilobyte / compsize

btrfs: find compression type/ratio on a file or set of files
Other
344 stars 23 forks source link

Confuse about compression types. #23

Closed RomuloPBenedetti closed 6 years ago

RomuloPBenedetti commented 6 years ago

I've moved a folder from another partition to the current one, mounted with compress-force=zstd, to my surprise, with compsize I get:

rbenedetti at rbenedettid > $sudo compsize /mnt/HDDs/
Processed 8890 files, 47691 regular extents (47691 refs), 3540 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       75%      5.6G         7.4G         7.4G
none       100%      2.8G         2.8G         2.8G
zlib        60%      2.8G         4.6G         4.6G

rbenedetti at rbenedettid > $sudo cat /proc/mounts | grep HDDs
systemd-1 /mnt/HDDs autofs rw,relatime,fd=50,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=20037 0 0
/dev/mapper/cryptHDDC /mnt/HDDs btrfs rw,seclabel,noatime,compress-force=zstd,flushoncommit,space_cache,autodefrag,subvolid=5,subvol=/ 0 0  

The partition was empty before, I expected it to be forcible compressed to zstd, as it came from another file system.

kilobyte commented 6 years ago

I expect this to be actually zlib — it's very easy to set compression mode wrong, btrfs provides too many ways to set it. Could you check for example:

btrfs prop get /some/file compression

? — it'd check just one of things that override global mount options. So does chattr +c.

If you have a directory that you're certain has no compression prop, you can copy in a test file that's 1. compressible, 2. long enough, 3. in a way that won't reflink it (cp may do so, safer to use cat or tar); it should get compressed with the mount's default.

RomuloPBenedetti commented 6 years ago

Thanks I was completely unaware that the compression property could get more priority than mount options. The device folder mnt/HDDs that was in another BTRFS partition had zlib as compression property.

kilobyte commented 6 years ago

So all is ok then...? Compsize reports the state, documentation about how to set it is probably out of scope here. Not sure where it should go, as the setting order is currently only tribal knowledge among btrfs developers.

Please reopen if there's anything you'd like added to compsize itself.