0

Context

I have some Synology NAS storing backups created by WBADMIN from Windows using SMB, which means VHDX image files in the end with compression disabled, as otherwise WBADMIN refuses to work on those files. Those files need to still be available on the NAS for some time, but it's VERY unlikely that those need to be mounted again by anyone, therefore I would like to apply compression afterwards now to simply safe some space. If it's ever need to be mounted again, things can easily be decompressed, so let's ignore that for now. DSM provides all the necessary tools to deal with compression of existing data on the shell as well:

chattr -R +c [...]
btrfs filesystem defragment -r -c [...]

The important thing to note is that the existing VHDX files are protected by automatically created snapshots already and the NAS continues to create snapshots automatically after I compressed the files. So what happens with those snapshots?

Are blocks hold by existing snapshots compressed as well?

According this explanation I don't think so. Additionally this would somewhat defeat the whole purpose of snapshots guaranteeing unchanged data for some point in time. Things simply were not compressed in the past when the snapshots were created, so in theory that data needs to be available somehow.

OTOH, compression is designed to be somewhat transparent anyway already and that might be argued all the way through to existing blocks even in snapshots. Might safe a lot of space in the end. Compression even is that transparent that du is not able to recognize.

Are newly compressed blocks changes hold by new snapshots?

I have a snapshot BEFORE compressing, compress the VHDX files and create a new snapshot AFTERWARDS. Nothing else changes in the VHDX by Windows or WBADMIN or whomever, so from a logical point of view the file is still unchanged. Though, the individual blocks/extents of the file managed by BTRFS have been changed a lot, depending on how good compression has been applied.

This results in actual storage newly allocated between the two snapshots, doesn't it? So after compression, until earlier snapshots holding uncompressed data are deleted, overall storage might simply be less than before.

Or am I wrong somewhere? Thanks!

1 Answer 1

0

There is an answers on the mailing list, thanks for that. The results:

Are blocks hold by existing snapshots compressed as well?

No, defragmentation always creates new, independent data and doesn't change any existing blocks. Without earlier snapshots, blocks might only be deleted after compression, but if snapshots hold blocks they will be preserved and their compressed data will be stored ADDITIONALLY.

These commands are more or less equivalent:

btrfs fi defrag -czstd foo

touch foo.tmp; setfattr -n btrfs.compression -v zstd foo.tmp; cp -a foo foo.tmp; mv -f foo.tmp foo

Are newly compressed blocks changes hold by new snapshots?

Yes, after compression the overall FREE space most likely will be less than before until older snapshots holding uncompressed data will be deleted. Which is not a big deal in my use case, though, because at some point old snapshots won't have any changes of interest anymore anyway, but only protect always the same data against accidental changes. So deleting old snapshots to replace uncompressed with compressed data is OK at some point.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .