enhancementhelp wanted
Description
It would be useful have an (optional) limit on the space used by snapshots. This is of benefit because quotas in ZFS include the snapshot data space (potentially leading to snapshots 'stealing' available space from a filesystem).
This would permit reserving space for the filesystem of a dataset.
For instance, if one wants 50GB available and 20GB for snapshots, then the following could be set:
zfs set quota=70G pool/dataset
potential change to sanoid config:
[pool/dataset]
use_template = hardlimit
recursive = yes
process_children_only = yes
[template_hardlimit]
frequently = 0
hourly = 36
daily = 30
monthly = 3
yearly = 0
autosnap = yes
autoprune = yes
spacelimit = 20G
spaceprune = oldest
then there would always be 50GB available to the filesystem
spaceprune could have optional algorithms for smart pruning, e.g. oldest|largest|prompt, which could be:
oldest: deletes oldest snaps first to get space back under quota (if the next snap fails, it deletes more)largest: deletes largest snap firstprompt: prompts user (by email) when snaps exceed thespacelimit
I haven't thought through the algorithm too much but the space occupied by snaps is pretty easy to access:
zfs list -ro space pool/dataset
NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD
pool/dataset 70.0G 46.3M 23.5M 22.8M 0B 0B