How do I tell if an individual file is compressed in BTRFS?

Solution 1:

It's an old question but it has gone unanswered. There is now a tool called compsize which handles exactly what the question is asking for.

Solution 2:

It is currently not possible, because this information is not stored: each file must be checked individually by a tool that do not exist yet.

See How do I find out the compressed / uncompressed file sizes on btrfs? for more details ans links.

Solution 3:

Fedora has compsize packaged, also SuSE has it.

$ sudo dnf install compsize
$ rm -f testfile;sync;head -qc10m /dev/zero >testfile;sync;compsize testfile
Type       Perc     Disk Usage   Uncompressed Referenced  
TOTAL        3%      320K          10M          10M       
zlib         3%      320K          10M          10M