Skip to contentSkip to conversation

defrag/compression: will it break reflinks on kernel 4.15.0?

DISCUSSION Andrew Skretvedt 2 participants 2 messages Jul 27, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

I've started experimenting with compression on a btrfs filesystem. I'd like to use 'zstd'.

I'm on linux kernel 4.15.0.

I have a handful of snapshots and I know that if all the reflinks will be broken, I won't have enough space to keep them all. So the choice I'm facing is that breaks will happen; I should delete enough snapshots to ensure space is sufficient, or breaks won't happen and I can leave my snapshots alone.

Background detail and deeper questions:

I *was* on v4.4 of the userspace tools (ubuntu btrfs-tools package). I'm *now* on v5.4.1 of these tools (ubuntu btrfs-progs package) via some careful cherry-picking from a newer release to keep all dependencies satisfied.

I began by adjusting mount options to include "compress=zstd"; this was fine. I understand that new writes are getting compressed (if passed by the compressibility heuristic). But, I understand that to compress what's already present, I have to issue defrag command(s) with -c. I was set to go forward and tripped over requesting -czstd, as v4.4 of the tools didn't support zstd, and I didn't notice. This is what prompted me to make the tools upgrade.

The manpage "btrfs-filesystem" includes:

Quoted 4 lines

Warning
Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14-rc2 as well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data

I thought I was prepared for this, but now I want to try to be more certain about what will happen if I start issuing 'defrag -czstd' commands. Because version 3.x kernels are mentioned several times at specific subversions, the warnings only apply to newer sub-subversions of them. I *think* that my 4.15.0 kernel will *not break* reflinks.

Is that correct?

Extra questions:

I see that the userspace tools' version tracks along with the kernel version. Is it a mistake to use a newer version of the tools than the running kernel, i.e. should I drop back to v4.15 of the tools?

Quoted 1 line

From the wiki, I understand that while zstd support was added in kernel

4.14, user-selection of compression level in zstd was not added until kernel 5.1. So I cannot use mount options like "compress=zstd:3" on kernel 4.15. BUT, can I yet do "defrag -czstd:3" since I'm running v5.4.1 tools? Or, must I (should I) just stick to -czstd and accept the default level it would use. What is that for zstd?

Thanks.

Signature · 4 lines
OpenPGP 0xC6901B2A6C976BB3 (https://keys.openpgp.org)

-- 
OpenPGP 0xC6901B2A6C976BB3 (https://keys.openpgp.org)
#1 lore raw
Quoted 11 lines · Andrew Skretvedt

I've started experimenting with compression on a btrfs filesystem. I'd like to use 'zstd'.

I'm on linux kernel 4.15.0.

I have a handful of snapshots and I know that if all the reflinks will be broken, I won't have enough space to keep them all. So the choice I'm facing is that breaks will happen; I should delete enough snapshots to ensure space is sufficient, or breaks won't happen and I can leave my snapshots alone.

Or just enable compression now, going forward.

Quoted 7 lines

The manpage "btrfs-filesystem" includes:

Quoted 4 lines

Warning
Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14-rc2 as well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data

Quoted 5 lines

I thought I was prepared for this, but now I want to try to be more certain about what will happen if I start issuing 'defrag -czstd' commands. Because version 3.x kernels are mentioned several times at specific subversions, the warnings only apply to newer sub-subversions of them. I *think* that my 4.15.0 kernel will *not break* reflinks.

It will break reflinks.

Quoted 3 lines

I see that the userspace tools' version tracks along with the kernel version. Is it a mistake to use a newer version of the tools than the running kernel, i.e. should I drop back to v4.15 of the tools?

No. Ideally use the most recent version you can.

Quoted 7 lines
Quoted 2 lines

From the wiki, I understand that while zstd support was added in kernel

4.14, user-selection of compression level in zstd was not added until kernel 5.1. So I cannot use mount options like "compress=zstd:3" on kernel 4.15. BUT, can I yet do "defrag -czstd:3" since I'm running v5.4.1 tools? Or, must I (should I) just stick to -czstd and accept the default level it would use. What is that for zstd?

Compression level currently is configurable only by mount option. There are proposals to enhance this for both defragmenting and property (XATTR). But as level 3 is the zstd default, you will get zstd:3 just by using zstd.

Signature · 1 line
Chris Murphy